show toast hint when touching inactive omemo fingerprints

This commit is contained in:
Daniel Gultsch 2016-07-17 20:31:04 +02:00
parent 0bc5dbdf94
commit 3e50d4831f
4 changed files with 39 additions and 1 deletions

View file

@ -86,6 +86,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
private TextView mSessionEst; private TextView mSessionEst;
private TextView mOtrFingerprint; private TextView mOtrFingerprint;
private TextView mAxolotlFingerprint; private TextView mAxolotlFingerprint;
private TextView mOwnFingerprintDesc;
private TextView mAccountJidLabel; private TextView mAccountJidLabel;
private ImageView mAvatar; private ImageView mAvatar;
private RelativeLayout mOtrFingerprintBox; private RelativeLayout mOtrFingerprintBox;
@ -468,6 +469,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
this.mAxolotlFingerprintBox = (RelativeLayout) findViewById(R.id.axolotl_fingerprint_box); this.mAxolotlFingerprintBox = (RelativeLayout) findViewById(R.id.axolotl_fingerprint_box);
this.mAxolotlFingerprintToClipboardButton = (ImageButton) findViewById(R.id.action_copy_axolotl_to_clipboard); this.mAxolotlFingerprintToClipboardButton = (ImageButton) findViewById(R.id.action_copy_axolotl_to_clipboard);
this.mRegenerateAxolotlKeyButton = (ImageButton) findViewById(R.id.action_regenerate_axolotl_key); this.mRegenerateAxolotlKeyButton = (ImageButton) findViewById(R.id.action_regenerate_axolotl_key);
this.mOwnFingerprintDesc = (TextView) findViewById(R.id.own_fingerprint_desc);
this.keysCard = (LinearLayout) findViewById(R.id.other_device_keys_card); this.keysCard = (LinearLayout) findViewById(R.id.other_device_keys_card);
this.keys = (LinearLayout) findViewById(R.id.other_device_keys); this.keys = (LinearLayout) findViewById(R.id.other_device_keys);
this.mNamePort = (LinearLayout) findViewById(R.id.name_port); this.mNamePort = (LinearLayout) findViewById(R.id.name_port);
@ -801,6 +803,11 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
final String ownAxolotlFingerprint = this.mAccount.getAxolotlService().getOwnFingerprint(); final String ownAxolotlFingerprint = this.mAccount.getAxolotlService().getOwnFingerprint();
if (ownAxolotlFingerprint != null && Config.supportOmemo()) { if (ownAxolotlFingerprint != null && Config.supportOmemo()) {
this.mAxolotlFingerprintBox.setVisibility(View.VISIBLE); 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.mAxolotlFingerprint.setText(CryptoHelper.prettifyFingerprint(ownAxolotlFingerprint.substring(2)));
this.mAxolotlFingerprintToClipboardButton this.mAxolotlFingerprintToClipboardButton
.setVisibility(View.VISIBLE); .setVisibility(View.VISIBLE);

View file

@ -128,8 +128,12 @@ public abstract class XmppActivity extends Activity {
} }
protected void replaceToast(String msg) { protected void replaceToast(String msg) {
replaceToast(msg, true);
}
protected void replaceToast(String msg, boolean showlong) {
hideToast(); hideToast();
mToast = Toast.makeText(this, msg ,Toast.LENGTH_LONG); mToast = Toast.makeText(this, msg ,showlong ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT);
mToast.show(); mToast.show();
} }
@ -806,6 +810,7 @@ public abstract class XmppActivity extends Activity {
return true; return true;
} }
}; };
boolean active = true;
view.setOnLongClickListener(purge); view.setOnLongClickListener(purge);
key.setOnLongClickListener(purge); key.setOnLongClickListener(purge);
keyType.setOnLongClickListener(purge); keyType.setOnLongClickListener(purge);
@ -836,6 +841,7 @@ public abstract class XmppActivity extends Activity {
trustToggle.setEnabled(false); trustToggle.setEnabled(false);
key.setTextColor(getTertiaryTextColor()); key.setTextColor(getTertiaryTextColor());
keyType.setTextColor(getTertiaryTextColor()); keyType.setTextColor(getTertiaryTextColor());
active = false;
break; break;
case INACTIVE_TRUSTED: case INACTIVE_TRUSTED:
case INACTIVE_TRUSTED_X509: case INACTIVE_TRUSTED_X509:
@ -844,6 +850,7 @@ public abstract class XmppActivity extends Activity {
trustToggle.setEnabled(false); trustToggle.setEnabled(false);
key.setTextColor(getTertiaryTextColor()); key.setTextColor(getTertiaryTextColor());
keyType.setTextColor(getTertiaryTextColor()); keyType.setTextColor(getTertiaryTextColor());
active = false;
break; break;
} }
@ -860,6 +867,28 @@ public abstract class XmppActivity extends Activity {
} }
key.setText(CryptoHelper.prettifyFingerprint(fingerprint.substring(2))); 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); keys.addView(view);
return true; return true;
} }

View file

@ -506,6 +506,7 @@
android:typeface="monospace"/> android:typeface="monospace"/>
<TextView <TextView
android:id="@+id/own_fingerprint_desc"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/this_device_omemo_fingerprint" android:text="@string/this_device_omemo_fingerprint"

View file

@ -667,4 +667,5 @@
<string name="pref_use_green_background">Green Background</string> <string name="pref_use_green_background">Green Background</string>
<string name="pref_use_green_background_summary">Use green background for received messages</string> <string name="pref_use_green_background_summary">Use green background for received messages</string>
<string name="unable_to_connect_to_keychain">Unable to connect to OpenKeychain</string> <string name="unable_to_connect_to_keychain">Unable to connect to OpenKeychain</string>
<string name="this_device_is_no_longer_in_use">This device is no longer in use</string>
</resources> </resources>