diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-04-12 21:16:30 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-04-12 21:16:30 +0200 |
commit | bdf27d85ec984412c63df782b2dd66a365d10142 (patch) | |
tree | 4c5ac04215b44e179245fb25cb346e7207296c9c /src/main/java/de/pixart/messenger/ui | |
parent | 0d23f749d08ef3b07453675f3dbec9a31639fc56 (diff) |
prevent double tapping on overflow menu
Diffstat (limited to '')
9 files changed, 43 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java index 5dab8b9e7..478e132b3 100644 --- a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java @@ -307,6 +307,9 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers @Override public boolean onOptionsItemSelected(MenuItem menuItem) { + if (MenuDoubleTabUtil.shouldIgnoreTap()) { + return false; + } switch (menuItem.getItemId()) { case android.R.id.home: finish(); diff --git a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java index 42d7ab8da..3c33cc733 100644 --- a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java @@ -46,6 +46,7 @@ import de.pixart.messenger.services.XmppConnectionService.OnAccountUpdate; import de.pixart.messenger.services.XmppConnectionService.OnRosterUpdate; import de.pixart.messenger.utils.CryptoHelper; import de.pixart.messenger.utils.IrregularUnicodeDetector; +import de.pixart.messenger.utils.MenuDoubleTabUtil; import de.pixart.messenger.utils.Namespace; import de.pixart.messenger.utils.TimeframeUtils; import de.pixart.messenger.utils.UIHelper; @@ -60,7 +61,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp private Contact contact; private Conversation mConversation; - + ActivityContactDetailsBinding binding; private DialogInterface.OnClickListener removeFromRoster = new DialogInterface.OnClickListener() { @Override @@ -107,9 +108,6 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp } } }; - - ActivityContactDetailsBinding binding; - private Jid accountJid; private Jid contactJid; private boolean showDynamicTags = false; @@ -287,6 +285,9 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp @Override public boolean onOptionsItemSelected(final MenuItem menuItem) { + if (MenuDoubleTabUtil.shouldIgnoreTap()) { + return false; + } final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setNegativeButton(getString(R.string.cancel), null); switch (menuItem.getItemId()) { diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index b7c2cf4d8..50fea03f7 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -104,6 +104,7 @@ import de.pixart.messenger.ui.util.SendButtonAction; import de.pixart.messenger.ui.util.SendButtonTool; import de.pixart.messenger.ui.widget.EditMessage; import de.pixart.messenger.utils.FileUtils; +import de.pixart.messenger.utils.MenuDoubleTabUtil; import de.pixart.messenger.utils.MessageUtils; import de.pixart.messenger.utils.NickValidityChecker; import de.pixart.messenger.utils.StylingHelper; @@ -1378,7 +1379,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke @Override public boolean onOptionsItemSelected(final MenuItem item) { - if (conversation == null) { + if (MenuDoubleTabUtil.shouldIgnoreTap()) { + return false; + } else if (conversation == null) { return super.onOptionsItemSelected(item); } switch (item.getItemId()) { diff --git a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java index cb2bfa807..ce6ef842d 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java @@ -84,6 +84,7 @@ import de.pixart.messenger.ui.interfaces.OnConversationsListItemUpdated; import de.pixart.messenger.ui.util.ActivityResult; import de.pixart.messenger.ui.util.PendingItem; import de.pixart.messenger.utils.ExceptionHelper; +import de.pixart.messenger.utils.MenuDoubleTabUtil; import de.pixart.messenger.utils.UIHelper; import de.pixart.messenger.xmpp.OnUpdateBlocklist; import de.pixart.messenger.xmpp.chatstate.ChatState; @@ -505,6 +506,9 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio @Override public boolean onOptionsItemSelected(MenuItem item) { + if (MenuDoubleTabUtil.shouldIgnoreTap()) { + return false; + } switch (item.getItemId()) { case android.R.id.home: FragmentManager fm = getFragmentManager(); diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java index 74e2910c6..45d1c8ff1 100644 --- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java +++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java @@ -65,6 +65,7 @@ import de.pixart.messenger.ui.adapter.KnownHostsAdapter; import de.pixart.messenger.ui.adapter.PresenceTemplateAdapter; import de.pixart.messenger.ui.util.PendingItem; import de.pixart.messenger.utils.CryptoHelper; +import de.pixart.messenger.utils.MenuDoubleTabUtil; import de.pixart.messenger.utils.UIHelper; import de.pixart.messenger.utils.XmppUri; import de.pixart.messenger.xml.Element; @@ -788,6 +789,9 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat @Override public boolean onOptionsItemSelected(final MenuItem item) { + if (MenuDoubleTabUtil.shouldIgnoreTap()) { + return false; + } switch (item.getItemId()) { case R.id.mgmt_account_reconnect: XmppConnection connection = mAccount.getXmppConnection(); diff --git a/src/main/java/de/pixart/messenger/ui/ManageAccountActivity.java b/src/main/java/de/pixart/messenger/ui/ManageAccountActivity.java index a5ca8a7b6..b50c77207 100644 --- a/src/main/java/de/pixart/messenger/ui/ManageAccountActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ManageAccountActivity.java @@ -31,6 +31,7 @@ import de.pixart.messenger.entities.Account; import de.pixart.messenger.services.XmppConnectionService; import de.pixart.messenger.services.XmppConnectionService.OnAccountUpdate; import de.pixart.messenger.ui.adapter.AccountAdapter; +import de.pixart.messenger.utils.MenuDoubleTabUtil; import de.pixart.messenger.xmpp.XmppConnection; import rocks.xmpp.addr.Jid; @@ -188,6 +189,9 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda @Override public boolean onOptionsItemSelected(MenuItem item) { + if (MenuDoubleTabUtil.shouldIgnoreTap()) { + return false; + } switch (item.getItemId()) { case R.id.action_add_account: startActivity(new Intent(getApplicationContext(), diff --git a/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java b/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java index 7c9318fa5..f752dee5a 100644 --- a/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java @@ -26,6 +26,7 @@ import java.util.Locale; import de.pixart.messenger.R; import de.pixart.messenger.services.EmojiService; +import de.pixart.messenger.utils.MenuDoubleTabUtil; import static de.pixart.messenger.ui.SettingsActivity.USE_BUNDLED_EMOJIS; @@ -107,6 +108,9 @@ public class ShowLocationActivity extends XmppActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { + if (MenuDoubleTabUtil.shouldIgnoreTap()) { + return false; + } switch (item.getItemId()) { case android.R.id.home: finish(); diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java index 26ae3591e..db32a6763 100644 --- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java @@ -70,6 +70,7 @@ import de.pixart.messenger.services.XmppConnectionService.OnRosterUpdate; import de.pixart.messenger.ui.adapter.ListItemAdapter; import de.pixart.messenger.ui.interfaces.OnBackendConnected; import de.pixart.messenger.ui.util.PendingItem; +import de.pixart.messenger.utils.MenuDoubleTabUtil; import de.pixart.messenger.utils.XmppUri; import de.pixart.messenger.xmpp.OnUpdateBlocklist; import de.pixart.messenger.xmpp.XmppConnection; @@ -538,6 +539,9 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU @Override public boolean onOptionsItemSelected(MenuItem item) { + if (MenuDoubleTabUtil.shouldIgnoreTap()) { + return false; + } switch (item.getItemId()) { case R.id.action_join_conference: showJoinConferenceDialog(null); diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java index 112c01cee..a2e938e8f 100644 --- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java +++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java @@ -39,10 +39,12 @@ import android.support.v4.content.ContextCompat; import android.support.v7.app.ActionBar; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; +import android.support.v7.app.AppCompatDelegate; import android.text.InputType; import android.util.DisplayMetrics; import android.util.Log; import android.util.Pair; +import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.inputmethod.InputMethodManager; @@ -76,6 +78,7 @@ import de.pixart.messenger.services.XmppConnectionService.XmppConnectionBinder; import de.pixart.messenger.ui.util.PresenceSelector; import de.pixart.messenger.utils.CryptoHelper; import de.pixart.messenger.utils.ExceptionHelper; +import de.pixart.messenger.utils.MenuDoubleTabUtil; import de.pixart.messenger.xmpp.OnKeyStatusUpdated; import de.pixart.messenger.xmpp.OnUpdateBlocklist; import rocks.xmpp.addr.Jid; @@ -1022,6 +1025,14 @@ public abstract class XmppActivity extends AppCompatActivity { super.onPause(); } + @Override + public boolean onMenuOpened(int id, Menu menu) { + if (id == AppCompatDelegate.FEATURE_SUPPORT_ACTION_BAR && menu != null) { + MenuDoubleTabUtil.recordMenuOpen(); + } + return super.onMenuOpened(id, menu); + } + protected void showQrCode() { showQrCode(getShareableUri()); } |