aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/ui
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-01-08 21:30:46 +0100
committerDaniel Gultsch <daniel@gultsch.de>2016-01-08 21:30:46 +0100
commita3e136b5504641f9782b9d94e35311dad19fbc1d (patch)
treefa38ed8d6050ad3b9f643dc32b897f8795bcae4e /src/main/java/eu/siacs/conversations/ui
parent0bb3ae37f0762ad264a4b98b3ebc4753017441af (diff)
show per conference notification settings in details activity
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java63
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java5
2 files changed, 67 insertions, 1 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
index b3de28b3..6653dd24 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
@@ -28,6 +28,7 @@ import org.openintents.openpgp.util.OpenPgpUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
+import java.util.concurrent.atomic.AtomicInteger;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
@@ -64,7 +65,9 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
private TextView mConferenceType;
private TableLayout mConferenceInfoTable;
private TextView mConferenceInfoMam;
+ private TextView mNotifyStatusText;
private ImageButton mChangeConferenceSettingsButton;
+ private ImageButton mNotifyStatusButton;
private Button mInviteButton;
private String uuid = null;
private User mSelectedUser = null;
@@ -99,6 +102,47 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
}
};
+
+ private OnClickListener mNotifyStatusClickListener = new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(ConferenceDetailsActivity.this);
+ builder.setTitle(R.string.pref_notification_settings);
+ String[] choices = {
+ getString(R.string.notify_on_all_messages),
+ getString(R.string.notify_only_when_highlighted),
+ getString(R.string.notify_never)
+ };
+ final AtomicInteger choice;
+ if (mConversation.getLongAttribute(Conversation.ATTRIBUTE_MUTED_TILL,0) == Long.MAX_VALUE) {
+ choice = new AtomicInteger(2);
+ } else {
+ choice = new AtomicInteger(mConversation.alwaysNotify() ? 0 : 1);
+ }
+ builder.setSingleChoiceItems(choices, choice.get(), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ choice.set(which);
+ }
+ });
+ builder.setNegativeButton(R.string.cancel, null);
+ builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (choice.get() == 2) {
+ mConversation.setMutedTill(Long.MAX_VALUE);
+ } else {
+ mConversation.setMutedTill(0);
+ mConversation.setAttribute(Conversation.ATTRIBUTE_ALWAYS_NOTIFY,String.valueOf(choice.get() == 0));
+ }
+ xmppConnectionService.updateConversation(mConversation);
+ updateView();
+ }
+ });
+ builder.create().show();
+ }
+ };
+
private OnClickListener mChangeConferenceSettings = new OnClickListener() {
@Override
public void onClick(View v) {
@@ -222,6 +266,9 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
this.mConferenceInfoTable = (TableLayout) findViewById(R.id.muc_info_more);
mConferenceInfoTable.setVisibility(this.mAdvancedMode ? View.VISIBLE : View.GONE);
this.mConferenceInfoMam = (TextView) findViewById(R.id.muc_info_mam);
+ this.mNotifyStatusButton = (ImageButton) findViewById(R.id.notification_status_button);
+ this.mNotifyStatusButton.setOnClickListener(this.mNotifyStatusClickListener);
+ this.mNotifyStatusText = (TextView) findViewById(R.id.notification_status_text);
}
@Override
@@ -493,6 +540,22 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
mChangeConferenceSettingsButton.setVisibility(View.GONE);
}
}
+
+ long mutedTill = mConversation.getLongAttribute(Conversation.ATTRIBUTE_MUTED_TILL,0);
+ if (mutedTill == Long.MAX_VALUE) {
+ mNotifyStatusText.setText(R.string.notify_never);
+ mNotifyStatusButton.setImageResource(R.drawable.ic_notifications_off_grey600_24dp);
+ } else if (System.currentTimeMillis() < mutedTill) {
+ mNotifyStatusText.setText(R.string.notify_paused);
+ mNotifyStatusButton.setImageResource(R.drawable.ic_notifications_paused_grey600_24dp);
+ } else if (mConversation.alwaysNotify()) {
+ mNotifyStatusButton.setImageResource(R.drawable.ic_notifications_grey600_24dp);
+ mNotifyStatusText.setText(R.string.notify_on_all_messages);
+ } else {
+ mNotifyStatusButton.setImageResource(R.drawable.ic_notifications_none_grey600_24dp);
+ mNotifyStatusText.setText(R.string.notify_only_when_highlighted);
+ }
+
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
membersView.removeAllViews();
final ArrayList<User> users = mucOptions.getUsers();
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
index 302faaf1..f5f48a26 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
@@ -102,8 +102,11 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
} else if (muted_till >= System.currentTimeMillis()) {
notificationStatus.setVisibility(View.VISIBLE);
notificationStatus.setImageResource(R.drawable.ic_notifications_paused_grey600_24dp);
- } else {
+ } else if (conversation.alwaysNotify()) {
notificationStatus.setVisibility(View.GONE);
+ } else {
+ notificationStatus.setVisibility(View.VISIBLE);
+ notificationStatus.setImageResource(R.drawable.ic_notifications_none_grey600_24dp);
}
mTimestamp.setText(UIHelper.readableTimeDifference(activity,conversation.getLatestMessage().getTimeSent()));