show scan button in TrustKeys only if there is something to scan
This commit is contained in:
parent
cbbf6f439b
commit
b2aae44645
|
@ -25,6 +25,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
|
@ -52,6 +53,8 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
|
||||||
private Button mSaveButton;
|
private Button mSaveButton;
|
||||||
private Button mCancelButton;
|
private Button mCancelButton;
|
||||||
|
|
||||||
|
private AtomicBoolean mUseCameraHintShown = new AtomicBoolean(false);
|
||||||
|
|
||||||
private AxolotlService.FetchStatus lastFetchReport = AxolotlService.FetchStatus.SUCCESS;
|
private AxolotlService.FetchStatus lastFetchReport = AxolotlService.FetchStatus.SUCCESS;
|
||||||
|
|
||||||
private final Map<String, Boolean> ownKeysToTrust = new HashMap<>();
|
private final Map<String, Boolean> ownKeysToTrust = new HashMap<>();
|
||||||
|
@ -114,11 +117,16 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.trust_keys, 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);
|
mUseCameraHintToast = Toast.makeText(this,R.string.use_camera_icon_to_scan_barcode,Toast.LENGTH_LONG);
|
||||||
ActionBar actionBar = getActionBar();
|
ActionBar actionBar = getActionBar();
|
||||||
mUseCameraHintToast.setGravity(Gravity.TOP | Gravity.END, 0 ,actionBar == null ? 0 : actionBar.getHeight());
|
mUseCameraHintToast.setGravity(Gravity.TOP | Gravity.END, 0 ,actionBar == null ? 0 : actionBar.getHeight());
|
||||||
mUseCameraHintToast.show();
|
mUseCameraHintToast.show();
|
||||||
return super.onCreateOptionsMenu(menu);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -218,6 +226,10 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((hasOwnKeys || foreignActuallyHasKeys()) && mUseCameraHintShown.compareAndSet(false,true)) {
|
||||||
|
showCameraToast();
|
||||||
|
}
|
||||||
|
|
||||||
ownKeysTitle.setText(mAccount.getJid().toBareJid().toString());
|
ownKeysTitle.setText(mAccount.getJid().toBareJid().toString());
|
||||||
ownKeysCard.setVisibility(hasOwnKeys ? View.VISIBLE : View.GONE);
|
ownKeysCard.setVisibility(hasOwnKeys ? View.VISIBLE : View.GONE);
|
||||||
foreignKeys.setVisibility(hasForeignKeys ? View.VISIBLE : View.GONE);
|
foreignKeys.setVisibility(hasForeignKeys ? View.VISIBLE : View.GONE);
|
||||||
|
@ -243,6 +255,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() {
|
private boolean reloadFingerprints() {
|
||||||
List<Jid> acceptedTargets = mConversation == null ? new ArrayList<Jid>() : mConversation.getAcceptedCryptoTargets();
|
List<Jid> acceptedTargets = mConversation == null ? new ArrayList<Jid>() : mConversation.getAcceptedCryptoTargets();
|
||||||
ownKeysToTrust.clear();
|
ownKeysToTrust.clear();
|
||||||
|
|
Loading…
Reference in a new issue