diff --git a/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/adapters/PickerItemAdapter.java b/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/adapters/PickerItemAdapter.java index f71640d1..0aeef6af 100644 --- a/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/adapters/PickerItemAdapter.java +++ b/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/adapters/PickerItemAdapter.java @@ -33,14 +33,14 @@ public PickerItemAdapter(Context context, Picker picker) { this.inflater = LayoutInflater.from(context); this.currentPicker = checkNotNull(picker, "Picker must not be null"); this.originalPickers = currentPicker.getChildren(); - this.filteredPickers = new ArrayList(currentPicker.getChildren()); + this.filteredPickers = new ArrayList<>(currentPicker.getChildren()); } public PickerItemAdapter(Context context) { this.context = checkNotNull(context, "context must not be null!"); this.inflater = LayoutInflater.from(context); - this.originalPickers = new ArrayList(); - this.filteredPickers = new ArrayList(); + this.originalPickers = new ArrayList<>(); + this.filteredPickers = new ArrayList<>(); } public void setOnPickerItemClickListener(OnPickerItemClickListener onPickerItemClickListener) { diff --git a/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/adapters/dataEntry/rows/DatePickerRow.java b/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/adapters/dataEntry/rows/DatePickerRow.java index 28d115e9..a3220637 100755 --- a/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/adapters/dataEntry/rows/DatePickerRow.java +++ b/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/adapters/dataEntry/rows/DatePickerRow.java @@ -32,14 +32,13 @@ import org.dhis2.mobile.io.models.Field; import org.dhis2.mobile.R; -import org.dhis2.mobile.ui.pickers.DatePickerDialog; -import org.dhis2.mobile.ui.pickers.DatePickerDialog.OnDateSetListener; +import org.dhis2.mobile.ui.fragments.DatePickerDialog; +import org.dhis2.mobile.ui.fragments.DatePickerDialog.OnDateSetListener; import org.joda.time.LocalDate; import org.dhis2.mobile.ui.adapters.dataEntry.FieldAdapter; import android.content.Context; -import android.support.v4.app.FragmentActivity; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; diff --git a/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/fragments/AggregateReportFragment.java b/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/fragments/AggregateReportFragment.java index 83c5612f..52abc4f5 100644 --- a/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/fragments/AggregateReportFragment.java +++ b/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/fragments/AggregateReportFragment.java @@ -44,7 +44,6 @@ import org.dhis2.mobile.ui.adapters.PickerAdapter; import org.dhis2.mobile.ui.adapters.PickerAdapter.OnPickerListChangeListener; import org.dhis2.mobile.ui.models.Picker; -import org.dhis2.mobile.ui.pickers.PeriodPicker; import org.dhis2.mobile.utils.PrefUtils; import org.dhis2.mobile.utils.TextFileUtils; import org.dhis2.mobile.utils.ToastManager; diff --git a/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/pickers/DatePickerDialog.java b/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/fragments/DatePickerDialog.java similarity index 99% rename from dhis2-android-app/src/main/java/org/dhis2/mobile/ui/pickers/DatePickerDialog.java rename to dhis2-android-app/src/main/java/org/dhis2/mobile/ui/fragments/DatePickerDialog.java index 7b8fe356..577a4b73 100755 --- a/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/pickers/DatePickerDialog.java +++ b/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/fragments/DatePickerDialog.java @@ -1,4 +1,4 @@ -package org.dhis2.mobile.ui.pickers; +package org.dhis2.mobile.ui.fragments; /* * Copyright (C) 2007 The Android Open Source Project @@ -35,7 +35,6 @@ * guide.

*/ public class DatePickerDialog extends AlertDialog implements OnDateChangedListener { - private static final String YEAR = "year"; private static final String MONTH = "month"; private static final String DAY = "day"; diff --git a/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/pickers/PeriodPicker.java b/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/fragments/PeriodPicker.java similarity index 98% rename from dhis2-android-app/src/main/java/org/dhis2/mobile/ui/pickers/PeriodPicker.java rename to dhis2-android-app/src/main/java/org/dhis2/mobile/ui/fragments/PeriodPicker.java index 90c031a6..b0de3911 100644 --- a/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/pickers/PeriodPicker.java +++ b/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/fragments/PeriodPicker.java @@ -1,4 +1,4 @@ -package org.dhis2.mobile.ui.pickers; +package org.dhis2.mobile.ui.fragments; import android.os.Bundle; import android.support.annotation.Nullable; @@ -36,7 +36,9 @@ public static PeriodPicker newInstance(String title, String periodType, int open arguments.putString(ARG_TITLE, title); arguments.putString(ARG_PERIOD_TYPE, periodType); arguments.putInt(ARG_OPEN_FUTURE_PERIOD, openFuturePeriod); + periodPicker.setArguments(arguments); + periodPicker.setStyle(DialogFragment.STYLE_NO_TITLE, 0); return periodPicker; } diff --git a/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/pickers/DatePicker.java b/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/pickers/DatePicker.java deleted file mode 100755 index 061a3bc2..00000000 --- a/dhis2-android-app/src/main/java/org/dhis2/mobile/ui/pickers/DatePicker.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2014, Araz Abishov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package org.dhis2.mobile.ui.pickers; - -import org.dhis2.mobile.R; -import org.dhis2.mobile.ui.pickers.DatePickerDialog.OnDateSetListener; -import org.joda.time.LocalDate; - -import android.content.Context; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.TextView; - -public class DatePicker { - private final DatePickerDialog dialog; - private final TextView invoker; - private String savedSelection; - - public DatePicker(Context context, View root, int resId) { - OnClickListener invokerListener = new OnClickListener() { - - @Override - public void onClick(View view) { - dialog.show(); - } - }; - - invoker = (TextView) root.findViewById(resId); - invoker.setText(R.string.choose_report_date); - invoker.setOnClickListener(invokerListener); - - LocalDate currentDate = new LocalDate(); - dialog = new DatePickerDialog(context, context.getString(R.string.choose_report_date), currentDate.getYear(), - currentDate.getMonthOfYear() - 1, currentDate.getDayOfMonth()); - - disable(); - } - - public void setText(String title) { - if (title == null) { - invoker.setText(R.string.choose_report_date); - } else { - invoker.setText(title); - } - } - - public void setDialogTitle(String title) { - if (title == null) { - dialog.setTitle(R.string.choose_report_date); - } else { - dialog.setTitle(title); - } - } - - public void setOnDateSetListener(OnDateSetListener callback) { - dialog.setOnDateSetListener(callback); - } - - public void saveSelection(String savedSelection) { - this.savedSelection = savedSelection; - } - - public String getSavedSelection() { - return savedSelection; - } - - public void enable() { - invoker.setEnabled(true); - resetState(); - } - - public void disable() { - invoker.setEnabled(false); - resetState(); - } - - private void resetState() { - savedSelection = null; - invoker.setText(R.string.choose_report_date); - dialog.setTitle(R.string.choose_report_date); - } - - public void dismiss() { - dialog.dismiss(); - } - - public boolean isShowing() { - return dialog.isShowing(); - } -} diff --git a/dhis2-android-app/src/main/res/drawable/dialog_listview_item_selector.xml b/dhis2-android-app/src/main/res/drawable/dialog_listview_item_selector.xml deleted file mode 100755 index 10d1620a..00000000 --- a/dhis2-android-app/src/main/res/drawable/dialog_listview_item_selector.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - \ No newline at end of file diff --git a/dhis2-android-app/src/main/res/layout/fragment_filterable.xml b/dhis2-android-app/src/main/res/layout/fragment_filterable.xml index d4cb8e33..5169b737 100644 --- a/dhis2-android-app/src/main/res/layout/fragment_filterable.xml +++ b/dhis2-android-app/src/main/res/layout/fragment_filterable.xml @@ -30,6 +30,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" + android:background="@android:color/white" android:minHeight="428dp" android:minWidth="296dp" android:orientation="vertical"> @@ -51,6 +52,7 @@ + android:layout_height="match_parent" + android:cacheColorHint="@android:color/transparent"/> \ No newline at end of file diff --git a/dhis2-android-app/src/main/res/layout/fragment_period_picker.xml b/dhis2-android-app/src/main/res/layout/fragment_period_picker.xml index 3ebc6235..9f6591c9 100755 --- a/dhis2-android-app/src/main/res/layout/fragment_period_picker.xml +++ b/dhis2-android-app/src/main/res/layout/fragment_period_picker.xml @@ -2,6 +2,7 @@ diff --git a/dhis2-android-app/src/main/res/layout/listview_row_picker_item.xml b/dhis2-android-app/src/main/res/layout/listview_row_picker_item.xml index aee52782..737b9616 100755 --- a/dhis2-android-app/src/main/res/layout/listview_row_picker_item.xml +++ b/dhis2-android-app/src/main/res/layout/listview_row_picker_item.xml @@ -3,7 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@drawable/dialog_listview_item_selector" + android:background="?attr/selectableItemBackground" android:orientation="horizontal" >