diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-07-17 20:31:04 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-07-25 19:42:50 +0200 |
commit | 89b7f8c65a4fc1e207e3ae9f6d37a878ebda5d8d (patch) | |
tree | d44cc6bf6d766c1b7e07cd091b2837de1704f7c2 /src | |
parent | c9001197cd4d8f4ecae590dc4daf25578ec4a0d3 (diff) |
show toast hint when touching inactive omemo fingerprints
Diffstat (limited to 'src')
4 files changed, 39 insertions, 1 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index c33d5ca58..da85ee494 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -84,6 +84,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate private TextView mSessionEst; private TextView mOtrFingerprint; private TextView mAxolotlFingerprint; + private TextView mOwnFingerprintDesc; private TextView mAccountJidLabel; private ImageView mAvatar; private RelativeLayout mOtrFingerprintBox; @@ -466,6 +467,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate this.mAxolotlFingerprintBox = (RelativeLayout) findViewById(R.id.axolotl_fingerprint_box); this.mAxolotlFingerprintToClipboardButton = (ImageButton) findViewById(R.id.action_copy_axolotl_to_clipboard); this.mRegenerateAxolotlKeyButton = (ImageButton) findViewById(R.id.action_regenerate_omemo_key); + this.mOwnFingerprintDesc = (TextView) findViewById(R.id.own_fingerprint_desc); this.keysCard = (LinearLayout) findViewById(R.id.other_device_keys_card); this.keys = (LinearLayout) findViewById(R.id.other_device_keys); this.mNamePort = (LinearLayout) findViewById(R.id.name_port); @@ -808,6 +810,11 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate final String ownAxolotlFingerprint = this.mAccount.getAxolotlService().getOwnFingerprint(); if (ownAxolotlFingerprint != null && Config.supportOmemo()) { this.mAxolotlFingerprintBox.setVisibility(View.VISIBLE); + if (ownAxolotlFingerprint.equals(messageFingerprint)) { + this.mOwnFingerprintDesc.setTextColor(getResources().getColor(R.color.accent)); + } else { + this.mOwnFingerprintDesc.setTextColor(getSecondaryTextColor()); + } this.mAxolotlFingerprint.setText(CryptoHelper.prettifyFingerprint(ownAxolotlFingerprint.substring(2))); this.mAxolotlFingerprintToClipboardButton .setVisibility(View.VISIBLE); diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index f008f088a..4c83e4f2a 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -128,8 +128,12 @@ public abstract class XmppActivity extends Activity { } protected void replaceToast(String msg) { + replaceToast(msg, true); + } + + protected void replaceToast(String msg, boolean showlong) { hideToast(); - mToast = Toast.makeText(this, msg ,Toast.LENGTH_LONG); + mToast = Toast.makeText(this, msg ,showlong ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT); mToast.show(); } @@ -791,6 +795,7 @@ public abstract class XmppActivity extends Activity { return true; } }; + boolean active = true; view.setOnLongClickListener(purge); key.setOnLongClickListener(purge); keyType.setOnLongClickListener(purge); @@ -821,6 +826,7 @@ public abstract class XmppActivity extends Activity { trustToggle.setEnabled(false); key.setTextColor(getTertiaryTextColor()); keyType.setTextColor(getTertiaryTextColor()); + active = false; break; case INACTIVE_TRUSTED: case INACTIVE_TRUSTED_X509: @@ -829,6 +835,7 @@ public abstract class XmppActivity extends Activity { trustToggle.setEnabled(false); key.setTextColor(getTertiaryTextColor()); keyType.setTextColor(getTertiaryTextColor()); + active = false; break; } @@ -845,6 +852,28 @@ public abstract class XmppActivity extends Activity { } key.setText(CryptoHelper.prettifyFingerprint(fingerprint.substring(2))); + + final View.OnClickListener toast; + if (!active) { + toast = new View.OnClickListener() { + @Override + public void onClick(View v) { + replaceToast(getString(R.string.this_device_is_no_longer_in_use), false); + } + }; + trustToggle.setOnClickListener(toast); + } else { + toast = new View.OnClickListener() { + @Override + public void onClick(View v) { + hideToast(); + } + }; + } + view.setOnClickListener(toast); + key.setOnClickListener(toast); + keyType.setOnClickListener(toast); + keys.addView(view); return true; } diff --git a/src/main/res/layout/activity_edit_account.xml b/src/main/res/layout/activity_edit_account.xml index d33c72bec..5d8016b33 100644 --- a/src/main/res/layout/activity_edit_account.xml +++ b/src/main/res/layout/activity_edit_account.xml @@ -525,6 +525,7 @@ android:typeface="monospace" /> <TextView + android:id="@+id/own_fingerprint_desc" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/this_device_omemo_fingerprint" diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 64810cc5e..0cffa2f4d 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -670,4 +670,5 @@ <string name="unable_to_connect_to_keychain">Unable to connect to OpenKeychain</string> <string name="no_permission">Pix-Art Messenger has no permissions</string> <string name="send_image">Send image?</string> + <string name="this_device_is_no_longer_in_use">This device is no longer in use</string> </resources> |