aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2016-11-29 21:39:50 +0100
committerChristian Schneppe <christian@pix-art.de>2016-11-29 21:39:50 +0100
commitbdda426ad4223773b5873ee20db22a22dff0e49b (patch)
tree0f958c1e14690a9731429ba5f1d801c5c94fb96b /src/main/java/de/pixart/messenger/ui
parent9671783d5bf7e2b8cf543b03b13fd292c2183614 (diff)
allow fingerprint verification via context menu
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java24
-rw-r--r--src/main/java/de/pixart/messenger/ui/EditAccountActivity.java18
-rw-r--r--src/main/java/de/pixart/messenger/ui/TrustKeysActivity.java27
3 files changed, 48 insertions, 21 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
index e974fb0a0..a97ffc321 100644
--- a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
@@ -27,6 +27,7 @@ import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.QuickContactBadge;
import android.widget.TextView;
+import android.widget.Toast;
import com.wefika.flowlayout.FlowLayout;
@@ -42,12 +43,12 @@ import de.pixart.messenger.crypto.axolotl.AxolotlService;
import de.pixart.messenger.crypto.axolotl.XmppAxolotlSession;
import de.pixart.messenger.entities.Account;
import de.pixart.messenger.entities.Contact;
-import de.pixart.messenger.entities.Conversation;
import de.pixart.messenger.entities.ListItem;
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.UIHelper;
+import de.pixart.messenger.utils.XmppUri;
import de.pixart.messenger.xmpp.OnKeyStatusUpdated;
import de.pixart.messenger.xmpp.OnUpdateBlocklist;
import de.pixart.messenger.xmpp.XmppConnection;
@@ -57,7 +58,6 @@ import de.pixart.messenger.xmpp.jid.Jid;
public class ContactDetailsActivity extends OmemoActivity implements OnAccountUpdate, OnRosterUpdate, OnUpdateBlocklist, OnKeyStatusUpdated {
public static final String ACTION_VIEW_CONTACT = "view_contact";
- private Conversation mConversation;
private Contact contact;
private DialogInterface.OnClickListener removeFromRoster = new DialogInterface.OnClickListener() {
@@ -541,13 +541,16 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
}
public void onBackendConnected() {
- if ((accountJid != null) && (contactJid != null)) {
- Account account = xmppConnectionService
- .findAccountByJid(accountJid);
+ if (accountJid != null && contactJid != null) {
+ Account account = xmppConnectionService.findAccountByJid(accountJid);
if (account == null) {
return;
}
this.contact = account.getRoster().getContact(contactJid);
+ if (mPendingFingerprintVerificationUri != null) {
+ processFingerprintVerification(mPendingFingerprintVerificationUri);
+ mPendingFingerprintVerificationUri = null;
+ }
populateView();
}
}
@@ -556,4 +559,15 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
public void onKeyStatusUpdated(AxolotlService.FetchStatus report) {
refreshUi();
}
+
+ @Override
+ protected void processFingerprintVerification(XmppUri uri) {
+ if (contact != null && contact.getJid().toBareJid().equals(uri.getJid()) && uri.hasFingerprints()) {
+ if (xmppConnectionService.verifyFingerprints(contact,uri.getFingerprints())) {
+ Toast.makeText(this,R.string.verified_fingerprints,Toast.LENGTH_SHORT).show();
+ }
+ } else {
+ Toast.makeText(this,R.string.invalid_barcode,Toast.LENGTH_SHORT).show();
+ }
+ }
}
diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
index 7e3417a6e..2617fd94c 100644
--- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
@@ -53,6 +53,7 @@ import de.pixart.messenger.services.XmppConnectionService.OnCaptchaRequested;
import de.pixart.messenger.ui.adapter.KnownHostsAdapter;
import de.pixart.messenger.utils.CryptoHelper;
import de.pixart.messenger.utils.UIHelper;
+import de.pixart.messenger.utils.XmppUri;
import de.pixart.messenger.xml.Element;
import de.pixart.messenger.xmpp.OnKeyStatusUpdated;
import de.pixart.messenger.xmpp.XmppConnection;
@@ -383,13 +384,24 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
}
@Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_BATTERY_OP || requestCode == REQUEST_DATA_SAVER) {
updateAccountInformation(mAccount == null);
}
}
+ @Override
+ protected void processFingerprintVerification(XmppUri uri) {
+ if (mAccount != null && mAccount.getJid().toBareJid().equals(uri.getJid()) && uri.hasFingerprints()) {
+ if (xmppConnectionService.verifyFingerprints(mAccount,uri.getFingerprints())) {
+ Toast.makeText(this,R.string.verified_fingerprints,Toast.LENGTH_SHORT).show();
+ }
+ } else {
+ Toast.makeText(this,R.string.invalid_barcode,Toast.LENGTH_SHORT).show();
+ }
+ }
+
protected void updateSaveButton() {
boolean accountInfoEdited = accountInfoEdited();
@@ -671,6 +683,10 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
this.mPassword.requestFocus();
}
}
+ if (mPendingFingerprintVerificationUri != null) {
+ processFingerprintVerification(mPendingFingerprintVerificationUri);
+ mPendingFingerprintVerificationUri = null;
+ }
updateAccountInformation(init);
}
diff --git a/src/main/java/de/pixart/messenger/ui/TrustKeysActivity.java b/src/main/java/de/pixart/messenger/ui/TrustKeysActivity.java
index 3564f7fc1..69e33fde9 100644
--- a/src/main/java/de/pixart/messenger/ui/TrustKeysActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/TrustKeysActivity.java
@@ -16,7 +16,6 @@ import android.widget.TextView;
import android.widget.Toast;
import com.google.zxing.integration.android.IntentIntegrator;
-import com.google.zxing.integration.android.IntentResult;
import org.whispersystems.libaxolotl.IdentityKey;
@@ -139,21 +138,15 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
}
@Override
- public void onActivityResult(int requestCode, int resultCode, Intent intent) {
- IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
- if (scanResult != null && scanResult.getFormatName() != null) {
- String data = scanResult.getContents();
- XmppUri uri = new XmppUri(data);
- if (xmppConnectionServiceBound) {
- processFingerprintVerification(uri);
- populateView();
- } else {
- this.mPendingFingerprintVerificationUri =uri;
- }
+ protected void onStop() {
+ super.onStop();
+ if (mUseCameraHintToast != null) {
+ mUseCameraHintToast.cancel();
}
}
- private void processFingerprintVerification(XmppUri uri) {
+ @Override
+ protected void processFingerprintVerification(XmppUri uri) {
if (mConversation != null
&& mAccount != null
&& uri.hasFingerprints()
@@ -163,13 +156,16 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
if (performedVerification && !keys && !hasNoOtherTrustedKeys() && !hasPendingKeyFetches()) {
Toast.makeText(this,R.string.all_omemo_keys_have_been_verified, Toast.LENGTH_SHORT).show();
finishOk();
+ return;
} else if (performedVerification) {
Toast.makeText(this,R.string.verified_fingerprints,Toast.LENGTH_SHORT).show();
}
} else {
+ reloadFingerprints();
Log.d(Config.LOGTAG,"xmpp uri was: "+uri.getJid()+" has Fingerprints: "+Boolean.toString(uri.hasFingerprints()));
Toast.makeText(this,R.string.barcode_does_not_contain_fingerprints_for_this_conversation,Toast.LENGTH_SHORT).show();
}
+ populateView();
}
private void populateView() {
@@ -289,9 +285,10 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
if (this.mPendingFingerprintVerificationUri != null) {
processFingerprintVerification(this.mPendingFingerprintVerificationUri);
this.mPendingFingerprintVerificationUri = null;
+ } else {
+ reloadFingerprints();
+ populateView();
}
- reloadFingerprints();
- populateView();
}
}