From a37bed80099fc9a11814e4b02a04dd21b21c6126 Mon Sep 17 00:00:00 2001 From: stom79 Date: Sun, 16 Dec 2018 15:23:27 +0100 Subject: [PATCH] Prepares frontend for notification date range #370 --- .../SettingsNotificationsFragment.java | 44 ++++++++++++++++++- .../gouv/etalab/mastodon/helper/Helper.java | 6 +++ .../fragment_settings_notifications.xml | 5 +++ app/src/main/res/values/strings.xml | 5 +++ 4 files changed, 59 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsNotificationsFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsNotificationsFragment.java index 2f172bff8..f9c013f17 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsNotificationsFragment.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsNotificationsFragment.java @@ -57,7 +57,7 @@ public class SettingsNotificationsFragment extends Fragment { private int style; private static final int ACTIVITY_CHOOSE_SOUND = 412; int count = 0; - + int count1 = 0; @Override public View onCreateView(@NonNull LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) { @@ -209,6 +209,48 @@ public class SettingsNotificationsFragment extends Fragment { } }); + + final Spinner action_notification = rootView.findViewById(R.id.action_notification); + ArrayAdapter adapterAction = ArrayAdapter.createFromResource(getContext(), + R.array.action_notification, android.R.layout.simple_spinner_item); + action_notification.setAdapter(adapterAction); + int positionNotificationAntion; + switch (sharedpreferences.getInt(Helper.SET_NOTIFICATION_ACTION, Helper.ACTION_ACTIVE)){ + case Helper.ACTION_ACTIVE: + positionNotificationAntion = 0; + break; + case Helper.ACTION_SILENT: + positionNotificationAntion = 1; + break; + default: + positionNotificationAntion = 0; + } + action_notification.setSelection(positionNotificationAntion); + action_notification.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + if( count1 > 0 ) { + SharedPreferences.Editor editor = sharedpreferences.edit(); + + switch (position) { + case 0: + editor.putInt(Helper.SET_NOTIFICATION_ACTION, Helper.ACTION_ACTIVE); + editor.apply(); + break; + case 1: + editor.putInt(Helper.SET_NOTIFICATION_ACTION, Helper.ACTION_SILENT); + editor.apply(); + break; + } + } + count1++; + } + @Override + public void onNothingSelected(AdapterView parent) { + + } + }); + set_notif_follow.setChecked(notif_follow); set_notif_follow_add.setChecked(notif_add); set_notif_follow_ask.setChecked(notif_ask); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java index fa8b741a4..b126d149e 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java @@ -283,6 +283,7 @@ public class Helper { public static final String SET_OLD_DIRECT_TIMELINE = "sset_old_direct_timeline"; public static final String SET_BATTERY_PROFILE = "set_battery_profile"; public static final String SET_DEFAULT_LOCALE_NEW = "set_default_locale_new"; + public static final String SET_NOTIFICATION_ACTION = "set_notification_action"; public static final int S_512KO = 1; public static final int S_1MO = 2; public static final int S_2MO = 3; @@ -290,6 +291,8 @@ public class Helper { public static final int ATTACHMENT_WIFI = 2; public static final int ATTACHMENT_ASK = 3; + + public static final int BATTERY_PROFILE_NORMAL = 1; public static final int BATTERY_PROFILE_MEDIUM = 2; public static final int BATTERY_PROFILE_LOW = 3; @@ -304,6 +307,9 @@ public class Helper { public static final int TRANS_DEEPL = 1; public static final int TRANS_NONE = 2; + public static final int ACTION_SILENT = 0; + public static final int ACTION_ACTIVE = 1; + public static final String SET_TRANS_FORCED = "set_trans_forced"; public static final String SET_NOTIFY = "set_notify"; public static final String SET_NOTIF_FOLLOW = "set_notif_follow"; diff --git a/app/src/main/res/layout/fragment_settings_notifications.xml b/app/src/main/res/layout/fragment_settings_notifications.xml index fb325aa5d..9751417f9 100644 --- a/app/src/main/res/layout/fragment_settings_notifications.xml +++ b/app/src/main/res/layout/fragment_settings_notifications.xml @@ -166,6 +166,11 @@ android:id="@+id/settings_time_to" android:layout_width="wrap_content" android:layout_height="wrap_content" /> + Block this domain? + + Notify + Silent + + Remove this toot? Delete & re-draft this toot?