aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/de/pixart/messenger/ui/TrustKeysActivity.java25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/TrustKeysActivity.java b/src/main/java/de/pixart/messenger/ui/TrustKeysActivity.java
index 2e3a51bd4..c3ba5620f 100644
--- a/src/main/java/de/pixart/messenger/ui/TrustKeysActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/TrustKeysActivity.java
@@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
import de.pixart.messenger.Config;
import de.pixart.messenger.R;
@@ -52,6 +53,8 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
private Button mSaveButton;
private Button mCancelButton;
+ private AtomicBoolean mUseCameraHintShown = new AtomicBoolean(false);
+
private AxolotlService.FetchStatus lastFetchReport = AxolotlService.FetchStatus.SUCCESS;
private final Map<String, Boolean> ownKeysToTrust = new HashMap<>();
@@ -116,11 +119,16 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.trust_keys, menu);
+ MenuItem scanQrCode = menu.findItem(R.id.action_scan_qr_code);
+ scanQrCode.setVisible(ownKeysToTrust.size() > 0 || foreignActuallyHasKeys());
+ return super.onCreateOptionsMenu(menu);
+ }
+
+ private void showCameraToast() {
mUseCameraHintToast = Toast.makeText(this,R.string.use_camera_icon_to_scan_barcode,Toast.LENGTH_LONG);
ActionBar actionBar = getActionBar();
mUseCameraHintToast.setGravity(Gravity.TOP | Gravity.END, 0 ,actionBar == null ? 0 : actionBar.getHeight());
mUseCameraHintToast.show();
- return super.onCreateOptionsMenu(menu);
}
@Override
@@ -220,6 +228,10 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
}
}
+ if ((hasOwnKeys || foreignActuallyHasKeys()) && mUseCameraHintShown.compareAndSet(false, true)) {
+ showCameraToast();
+ }
+
ownKeysTitle.setText(mAccount.getJid().toBareJid().toString());
ownKeysCard.setVisibility(hasOwnKeys ? View.VISIBLE : View.GONE);
foreignKeys.setVisibility(hasForeignKeys ? View.VISIBLE : View.GONE);
@@ -245,6 +257,17 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
}
}
+ private boolean foreignActuallyHasKeys() {
+ synchronized (this.foreignKeysToTrust) {
+ for (Map.Entry<Jid, Map<String, Boolean>> entry : foreignKeysToTrust.entrySet()) {
+ if (entry.getValue().size() > 0) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
private boolean reloadFingerprints() {
List<Jid> acceptedTargets = mConversation == null ? new ArrayList<Jid>() : mConversation.getAcceptedCryptoTargets();
ownKeysToTrust.clear();