From 6aee63843218f12f60fb9756cccf0e0d343e1802 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 5 Mar 2018 15:27:22 +0100 Subject: [PATCH] refactor disable notifications dialog to make use of timeframeutils --- .../conversations/ui/ConversationFragment.java | 11 ++++++++++- src/main/res/values/arrays.xml | 15 --------------- src/main/res/values/strings.xml | 4 ---- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 3d1afea63..bdd2fefa3 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -95,6 +95,7 @@ import eu.siacs.conversations.ui.widget.EditMessage; import eu.siacs.conversations.utils.MessageUtils; import eu.siacs.conversations.utils.NickValidityChecker; import eu.siacs.conversations.utils.StylingHelper; +import eu.siacs.conversations.utils.TimeframeUtils; import eu.siacs.conversations.utils.UIHelper; import eu.siacs.conversations.xmpp.XmppConnection; import eu.siacs.conversations.xmpp.chatstate.ChatState; @@ -1316,7 +1317,15 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.disable_notifications); final int[] durations = getResources().getIntArray(R.array.mute_options_durations); - builder.setItems(R.array.mute_options_descriptions, (dialog, which) -> { + final CharSequence[] labels = new CharSequence[durations.length]; + for(int i = 0; i < durations.length; ++i) { + if (durations[i] == -1) { + labels[i] = getString(R.string.until_further_notice); + } else { + labels[i] = TimeframeUtils.resolve(activity,1000L * durations[i]); + } + } + builder.setItems(labels, (dialog, which) -> { final long till; if (durations[which] == -1) { till = Long.MAX_VALUE; diff --git a/src/main/res/values/arrays.xml b/src/main/res/values/arrays.xml index 5c332b8ce..06f5c496e 100644 --- a/src/main/res/values/arrays.xml +++ b/src/main/res/values/arrays.xml @@ -25,13 +25,6 @@ 5242880 10485760 - - @string/thirty_minutes - @string/one_hour - @string/two_hours - @string/eight_hours - @string/until_further_notice - 1800 @@ -79,14 +72,6 @@ @string/always - - @string/presence_chat - @string/presence_online - @string/presence_away - @string/presence_xa - @string/presence_dnd - - @string/gp_short @string/gp_medium diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index ffe61d427..ea4b4a1f9 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -408,10 +408,6 @@ Modified group chat options! Could not modify group chat options Never - 30 minutes - 1 hour - 2 hours - 8 hours Until further notice Snooze Reply