refactor disable notifications dialog to make use of timeframeutils

This commit is contained in:
Daniel Gultsch 2018-03-05 15:27:22 +01:00
parent 89992f541c
commit 6aee638432
3 changed files with 10 additions and 20 deletions

View File

@ -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;

View File

@ -25,13 +25,6 @@
<item>5242880</item>
<item>10485760</item>
</string-array>
<string-array name="mute_options_descriptions">
<item>@string/thirty_minutes</item>
<item>@string/one_hour</item>
<item>@string/two_hours</item>
<item>@string/eight_hours</item>
<item>@string/until_further_notice</item>
</string-array>
<integer-array name="mute_options_durations">
<item>1800</item>
@ -79,14 +72,6 @@
<item>@string/always</item>
</string-array>
<string-array name="presence_show_options">
<item>@string/presence_chat</item>
<item>@string/presence_online</item>
<item>@string/presence_away</item>
<item>@string/presence_xa</item>
<item>@string/presence_dnd</item>
</string-array>
<string-array name="grace_periods">
<item>@string/gp_short</item>
<item>@string/gp_medium</item>

View File

@ -408,10 +408,6 @@
<string name="modified_conference_options">Modified group chat options!</string>
<string name="could_not_modify_conference_options">Could not modify group chat options</string>
<string name="never">Never</string>
<string name="thirty_minutes">30 minutes</string>
<string name="one_hour">1 hour</string>
<string name="two_hours">2 hours</string>
<string name="eight_hours">8 hours</string>
<string name="until_further_notice">Until further notice</string>
<string name="snooze">Snooze</string>
<string name="reply">Reply</string>