From 684e2ca7c63cc4d5491b2dd0784d232e906e813a Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Thu, 20 Feb 2020 18:05:54 +0200 Subject: [PATCH] add two more limit options for the future date entry limit - one and two weeks --- .../net/ktnx/mobileledger/model/MobileLedgerProfile.java | 8 ++++++-- .../java/net/ktnx/mobileledger/ui/DatePickerFragment.java | 6 ++++++ .../mobileledger/ui/profiles/ProfileDetailFragment.java | 6 ++++++ app/src/main/res/menu/future_dates.xml | 2 ++ app/src/main/res/values-bg/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/model/MobileLedgerProfile.java b/app/src/main/java/net/ktnx/mobileledger/model/MobileLedgerProfile.java index 5fbb5ba0..7dc4bbfc 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/MobileLedgerProfile.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/MobileLedgerProfile.java @@ -489,8 +489,8 @@ public final class MobileLedgerProfile { } } public enum FutureDates { - None(0), OneMonth(30), TwoMonths(60), ThreeMonths(90), SixMonths(180), OneYear(365), - All(-1); + None(0), OneWeek(7), TwoWeeks(14), OneMonth(30), TwoMonths(60), ThreeMonths(90), + SixMonths(180), OneYear(365), All(-1); private static SparseArray map = new SparseArray<>(); static { @@ -511,6 +511,10 @@ public final class MobileLedgerProfile { } public String getText(Resources resources) { switch (value) { + case 7: + return resources.getString(R.string.future_dates_7); + case 14: + return resources.getString(R.string.future_dates_14); case 30: return resources.getString(R.string.future_dates_30); case 60: diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/DatePickerFragment.java b/app/src/main/java/net/ktnx/mobileledger/ui/DatePickerFragment.java index cd69f7d8..4c2721d4 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/DatePickerFragment.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/DatePickerFragment.java @@ -97,6 +97,12 @@ public class DatePickerFragment extends AppCompatDialogFragment case None: // already there break; + case OneWeek: + dateLimit.add(Calendar.DAY_OF_MONTH, 7); + break; + case TwoWeeks: + dateLimit.add(Calendar.DAY_OF_MONTH, 14); + break; case OneMonth: dateLimit.add(Calendar.MONTH, 1); break; diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java index dc7fa9cd..1ca52ddd 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java @@ -212,6 +212,12 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue menu.inflate(R.menu.future_dates); menu.setOnMenuItemClickListener(item -> { switch (item.getItemId()) { + case R.id.menu_future_dates_7: + futureDates = MobileLedgerProfile.FutureDates.OneWeek; + break; + case R.id.menu_future_dates_14: + futureDates = MobileLedgerProfile.FutureDates.TwoWeeks; + break; case R.id.menu_future_dates_30: futureDates = MobileLedgerProfile.FutureDates.OneMonth; break; diff --git a/app/src/main/res/menu/future_dates.xml b/app/src/main/res/menu/future_dates.xml index b318395b..bf88dac1 100644 --- a/app/src/main/res/menu/future_dates.xml +++ b/app/src/main/res/menu/future_dates.xml @@ -19,6 +19,8 @@ + + diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index bf14594f..3f8c56cd 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -118,6 +118,8 @@ Симул. съхр. СИМУЛАЦИЯ До шест месеца + До една седмица + До две седмици До един месец До една година До два месеца diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cd216197..97b40641 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -131,6 +131,8 @@ SIMULATION Allow input of dates in the future No future dates are allowed + Up to a week + Up to two weeks Up to a month Up to two months Up to three months -- 2.39.5