aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-02-09 23:55:40 +0100
committerChristian Schneppe <christian@pix-art.de>2017-02-09 23:55:40 +0100
commitad7e8e76f0fad8b3887c332fbaddcc77daee8df0 (patch)
tree5540c85f0142c098eac0d4ec86205381cb80cbcc /src
parente7b636019c7e9813a5e33c4eabdb39080a94009f (diff)
move (un)mute settings to contact-/conference details
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java21
-rw-r--r--src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java81
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationActivity.java48
-rw-r--r--src/main/res/layout/activity_contact_details.xml97
-rw-r--r--src/main/res/menu/conversations.xml25
5 files changed, 167 insertions, 105 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
index a7f6d421f..a6e2a40de 100644
--- a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
@@ -111,7 +111,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
getString(R.string.notify_never)
};
final AtomicInteger choice;
- if (mConversation.getLongAttribute(Conversation.ATTRIBUTE_MUTED_TILL, 0) == Long.MAX_VALUE) {
+ if (mConversation.getLongAttribute(Conversation.ATTRIBUTE_MUTED_TILL, 0) <= Long.MAX_VALUE) {
choice = new AtomicInteger(2);
} else {
choice = new AtomicInteger(mConversation.alwaysNotify() ? 0 : 1);
@@ -127,7 +127,24 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
@Override
public void onClick(DialogInterface dialog, int which) {
if (choice.get() == 2) {
- mConversation.setMutedTill(Long.MAX_VALUE);
+ AlertDialog.Builder builder = new AlertDialog.Builder(ConferenceDetailsActivity.this);
+ builder.setTitle(R.string.disable_notifications);
+ final int[] durations = getResources().getIntArray(R.array.mute_options_durations);
+ builder.setItems(R.array.mute_options_descriptions,
+ new DialogInterface.OnClickListener() {
+
+ @Override
+ public void onClick(final DialogInterface dialog, final int which) {
+ final long till;
+ if (durations[which] == -1) {
+ till = Long.MAX_VALUE;
+ } else {
+ till = System.currentTimeMillis() + (durations[which] * 1000);
+ }
+ mConversation.setMutedTill(till);
+ }
+ });
+ builder.create().show();
} else {
mConversation.setMutedTill(0);
mConversation.setAttribute(Conversation.ATTRIBUTE_ALWAYS_NOTIFY, String.valueOf(choice.get() == 0));
diff --git a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
index 4a77784af..adebdc3ad 100644
--- a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
@@ -34,6 +34,7 @@ import com.wefika.flowlayout.FlowLayout;
import org.openintents.openpgp.util.OpenPgpUtils;
import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
import de.pixart.messenger.Config;
import de.pixart.messenger.R;
@@ -43,6 +44,7 @@ import de.pixart.messenger.crypto.axolotl.FingerprintStatus;
import de.pixart.messenger.crypto.axolotl.XmppAxolotlSession;
import de.pixart.messenger.entities.Account;
import de.pixart.messenger.entities.Contact;
+import de.pixart.messenger.entities.Conversation;
import de.pixart.messenger.entities.ListItem;
import de.pixart.messenger.services.XmppConnectionService.OnAccountUpdate;
import de.pixart.messenger.services.XmppConnectionService.OnRosterUpdate;
@@ -59,6 +61,8 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
public static final String ACTION_VIEW_CONTACT = "view_contact";
private Contact contact;
+ private Conversation mConversation;
+
private DialogInterface.OnClickListener removeFromRoster = new DialogInterface.OnClickListener() {
@Override
@@ -123,6 +127,8 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
private boolean showLastSeen = false;
private boolean showInactiveOmemo = false;
private String messageFingerprint;
+ private TextView mNotifyStatusText;
+ private ImageButton mNotifyStatusButton;
private DialogInterface.OnClickListener addToPhonebook = new DialogInterface.OnClickListener() {
@@ -160,6 +166,62 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
}
};
+ private OnClickListener mNotifyStatusClickListener = new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(ContactDetailsActivity.this);
+ builder.setTitle(R.string.pref_notification_settings);
+ String[] choices = {
+ getString(R.string.notify_on_all_messages),
+ getString(R.string.notify_never)
+ };
+ final AtomicInteger choice;
+ if (mConversation.getLongAttribute(Conversation.ATTRIBUTE_MUTED_TILL, 0) <= Long.MAX_VALUE) {
+ choice = new AtomicInteger(1);
+ } else {
+ choice = new AtomicInteger(0);
+ }
+ 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() == 1) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(ContactDetailsActivity.this);
+ builder.setTitle(R.string.disable_notifications);
+ final int[] durations = getResources().getIntArray(R.array.mute_options_durations);
+ builder.setItems(R.array.mute_options_descriptions,
+ new DialogInterface.OnClickListener() {
+
+ @Override
+ public void onClick(final DialogInterface dialog, final int which) {
+ final long till;
+ if (durations[which] == -1) {
+ till = Long.MAX_VALUE;
+ } else {
+ till = System.currentTimeMillis() + (durations[which] * 1000);
+ }
+ mConversation.setMutedTill(till);
+ }
+ });
+ builder.create().show();
+ } else {
+ mConversation.setMutedTill(0);
+ mConversation.setAttribute(Conversation.ATTRIBUTE_ALWAYS_NOTIFY, String.valueOf(choice.get() == 0));
+ }
+ xmppConnectionService.updateConversation(mConversation);
+ populateView();
+ }
+ });
+ builder.create().show();
+ }
+ };
+
@Override
public void onRosterUpdate() {
refreshUi();
@@ -236,6 +298,9 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
populateView();
}
});
+ this.mNotifyStatusButton = (ImageButton) findViewById(R.id.notification_status_button);
+ this.mNotifyStatusButton.setOnClickListener(this.mNotifyStatusClickListener);
+ this.mNotifyStatusText = (TextView) findViewById(R.id.notification_status_text);
}
@Override
@@ -338,6 +403,18 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
if (contact == null) {
return;
}
+
+ 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 {
+ mNotifyStatusButton.setImageResource(R.drawable.ic_notifications_grey600_24dp);
+ mNotifyStatusText.setText(R.string.notify_on_all_messages);
+ }
if (getActionBar() != null) {
final ActionBar ab = getActionBar();
ab.setCustomView(R.layout.ab_title);
@@ -580,6 +657,10 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
if (account == null) {
return;
}
+ this.mConversation = xmppConnectionService.findOrCreateConversation(account, contactJid, false);
+ if (this.mConversation != null) {
+ populateView();
+ }
this.contact = account.getRoster().getContact(contactJid);
if (mPendingFingerprintVerificationUri != null) {
processFingerprintVerification(mPendingFingerprintVerificationUri);
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
index dadab9a72..6bcf9c631 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
@@ -512,8 +512,6 @@ public class ConversationActivity extends XmppActivity
final MenuItem menuClearHistory = menu.findItem(R.id.action_clear_history);
final MenuItem menuAdd = menu.findItem(R.id.action_add);
final MenuItem menuInviteContact = menu.findItem(R.id.action_invite);
- final MenuItem menuMute = menu.findItem(R.id.action_mute);
- final MenuItem menuUnmute = menu.findItem(R.id.action_unmute);
final MenuItem menuUpdater = menu.findItem(R.id.action_check_updates);
final MenuItem menuInviteUser = menu.findItem(R.id.action_invite_user);
@@ -524,8 +522,6 @@ public class ConversationActivity extends XmppActivity
menuInviteContact.setVisible(false);
menuAttach.setVisible(false);
menuClearHistory.setVisible(false);
- menuMute.setVisible(false);
- menuUnmute.setVisible(false);
} else {
menuAdd.setVisible(!isConversationsOverviewHideable());
//hide settings, accounts and updater in all menus except in main window
@@ -552,11 +548,6 @@ public class ConversationActivity extends XmppActivity
} else {
menuSecure.setVisible(Config.multipleEncryptionChoices());
}
- if (this.getSelectedConversation().isMuted()) {
- menuMute.setVisible(false);
- } else {
- menuUnmute.setVisible(false);
- }
}
}
if (Config.supportOmemo()) {
@@ -842,12 +833,6 @@ public class ConversationActivity extends XmppActivity
case R.id.action_clear_history:
clearHistoryDialog(getSelectedConversation());
break;
- case R.id.action_mute:
- muteConversationDialog(getSelectedConversation());
- break;
- case R.id.action_unmute:
- unmuteConversation(getSelectedConversation());
- break;
case R.id.action_block:
BlockContactDialog.show(this, xmppConnectionService, getSelectedConversation());
break;
@@ -1088,39 +1073,6 @@ public class ConversationActivity extends XmppActivity
}
}
- protected void muteConversationDialog(final Conversation conversation) {
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(R.string.disable_notifications);
- final int[] durations = getResources().getIntArray(R.array.mute_options_durations);
- builder.setItems(R.array.mute_options_descriptions,
- new OnClickListener() {
-
- @Override
- public void onClick(final DialogInterface dialog, final int which) {
- final long till;
- if (durations[which] == -1) {
- till = Long.MAX_VALUE;
- } else {
- till = System.currentTimeMillis() + (durations[which] * 1000);
- }
- conversation.setMutedTill(till);
- ConversationActivity.this.xmppConnectionService.updateConversation(conversation);
- updateConversationList();
- ConversationActivity.this.mConversationFragment.updateMessages();
- invalidateOptionsMenu();
- }
- });
- builder.create().show();
- }
-
- public void unmuteConversation(final Conversation conversation) {
- conversation.setMutedTill(0);
- this.xmppConnectionService.updateConversation(conversation);
- updateConversationList();
- ConversationActivity.this.mConversationFragment.updateMessages();
- invalidateOptionsMenu();
- }
-
@Override
public void onBackPressed() {
if (!isConversationsOverviewVisable()) {
diff --git a/src/main/res/layout/activity_contact_details.xml b/src/main/res/layout/activity_contact_details.xml
index 46b0f1768..4c0e54955 100644
--- a/src/main/res/layout/activity_contact_details.xml
+++ b/src/main/res/layout/activity_contact_details.xml
@@ -72,18 +72,55 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textColor="@color/black54"
- android:textSize="?attr/TextSizeBody" />
+ android:textSize="?attr/TextSizeBody"
+ android:layout_marginBottom="4dp"
+ android:layout_marginTop="4dp" />
<github.ankushsachdeva.emojicon.EmojiconTextView
android:id="@+id/status_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
- android:layout_marginTop="8dp"
+ android:layout_marginTop="4dp"
android:gravity="center_horizontal"
android:textColor="@color/black54"
android:textSize="?attr/TextSizeBody"
- android:textStyle="italic" />
+ android:textStyle="italic"
+ android:layout_marginBottom="4dp" />
+
+ <Button
+ android:id="@+id/add_contact_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ android:layout_centerHorizontal="true"
+ android:layout_gravity="center_horizontal"
+ android:text="@string/add_contact"
+ android:layout_marginBottom="4dp"
+ android:layout_marginTop="4dp" />
+
+ <CheckBox
+ android:id="@+id/details_send_presence"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true"
+ android:layout_below="@+id/add_contact_button"
+ android:text="@string/send_presence_updates"
+ android:textColor="@color/black87"
+ android:textSize="?attr/TextSizeBody"
+ android:layout_marginTop="4dp" />
+
+ <CheckBox
+ android:id="@+id/details_receive_presence"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true"
+ android:layout_below="@+id/details_send_presence"
+ android:text="@string/receive_presence_updates"
+ android:textColor="@color/black87"
+ android:textSize="?attr/TextSizeBody" />
</LinearLayout>
@@ -110,36 +147,36 @@
android:background="@drawable/infocard_border"
android:padding="@dimen/infocard_padding">
- <Button
- android:id="@+id/add_contact_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_centerHorizontal="true"
- android:layout_gravity="center_horizontal"
- android:text="@string/add_contact" />
-
- <CheckBox
- android:id="@+id/details_send_presence"
- android:layout_width="wrap_content"
+ <RelativeLayout
+ android:layout_width="fill_parent"
android:layout_height="wrap_content"
+ android:touchscreenBlocksFocus="true"
android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true"
- android:layout_below="@+id/add_contact_button"
- android:text="@string/send_presence_updates"
- android:textColor="@color/black87"
- android:textSize="?attr/TextSizeBody" />
+ android:layout_alignParentStart="true" >
- <CheckBox
- android:id="@+id/details_receive_presence"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true"
- android:layout_below="@+id/details_send_presence"
- android:text="@string/receive_presence_updates"
- android:textColor="@color/black87"
- android:textSize="?attr/TextSizeBody" />
+ <TextView
+ android:id="@+id/notification_status_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/notify_on_all_messages"
+ android:layout_centerVertical="true"
+ android:textColor="@color/black87"
+ android:textSize="?attr/TextSizeBody"
+ android:layout_alignParentLeft="true"
+ android:layout_toLeftOf="@+id/notification_status_button" />
+
+ <ImageButton
+ android:id="@+id/notification_status_button"
+ style="?android:attr/buttonStyleSmall"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_alignParentRight="true"
+ android:layout_centerVertical="true"
+ android:background="?android:selectableItemBackground"
+ android:padding="@dimen/image_button_padding"
+ android:src="@drawable/ic_notifications_grey600_24dp" />
+ </RelativeLayout>
</RelativeLayout>
diff --git a/src/main/res/menu/conversations.xml b/src/main/res/menu/conversations.xml
index 22d8a513a..35fc61990 100644
--- a/src/main/res/menu/conversations.xml
+++ b/src/main/res/menu/conversations.xml
@@ -18,19 +18,6 @@
android:orderInCategory="30"
android:showAsAction="always"
android:title="@string/attach_file" />
- <!-- <item
- android:id="@+id/action_contact_details"
- android:icon="?attr/icon_group"
- android:orderInCategory="40"
- android:showAsAction="never"
- android:title="@string/action_contact_details"/>
- <item
- android:id="@+id/action_muc_details"
- android:icon="?attr/icon_group"
- android:orderInCategory="40"
- android:showAsAction="never"
- android:title="@string/action_muc_details"/>
- -->
<item
android:id="@+id/action_invite"
android:orderInCategory="45"
@@ -52,18 +39,6 @@
android:showAsAction="never"
android:title="@string/action_end_conversation_muc" />
<item
- android:id="@+id/action_mute"
- android:orderInCategory="70"
- android:showAsAction="never"
- android:title="@string/disable_notifications" />
-
- <item
- android:id="@+id/action_unmute"
- android:orderInCategory="71"
- android:showAsAction="never"
- android:title="@string/enable_notifications" />
-
- <item
android:id="@+id/action_accounts"
android:orderInCategory="90"
android:showAsAction="never"