aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2016-11-20 14:30:16 +0100
committerChristian Schneppe <christian@pix-art.de>2016-11-20 14:30:16 +0100
commit47a46c20ab506988c6c52196b6e15727fb0b4b1f (patch)
tree42ca9328326a5f7ba0ab6ae42245f6a799e5a1bd /src
parent9d6c146f5c9e0988827cd6184318a1d0d3adf965 (diff)
show 'clear devices' button underneath own devices
Diffstat (limited to '')
-rw-r--r--src/main/java/de/pixart/messenger/OmemoActivity.java46
-rw-r--r--src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java25
-rw-r--r--src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlSession.java4
-rw-r--r--src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java10
-rw-r--r--src/main/java/de/pixart/messenger/ui/EditAccountActivity.java34
-rw-r--r--src/main/res/layout/activity_edit_account.xml13
-rw-r--r--src/main/res/menu/editaccount.xml4
7 files changed, 70 insertions, 66 deletions
diff --git a/src/main/java/de/pixart/messenger/OmemoActivity.java b/src/main/java/de/pixart/messenger/OmemoActivity.java
index dcf420442..85e0498a7 100644
--- a/src/main/java/de/pixart/messenger/OmemoActivity.java
+++ b/src/main/java/de/pixart/messenger/OmemoActivity.java
@@ -16,6 +16,7 @@ import android.widget.Toast;
import java.security.cert.X509Certificate;
import de.pixart.messenger.crypto.axolotl.FingerprintStatus;
+import de.pixart.messenger.crypto.axolotl.XmppAxolotlSession;
import de.pixart.messenger.entities.Account;
import de.pixart.messenger.ui.XmppActivity;
import de.pixart.messenger.ui.widget.Switch;
@@ -60,27 +61,33 @@ public abstract class OmemoActivity extends XmppActivity {
}
}
- protected boolean addFingerprintRow(LinearLayout keys, final Account account, final String fingerprint, boolean highlight) {
- final FingerprintStatus status = account.getAxolotlService().getFingerprintTrust(fingerprint);
- return status != null && addFingerprintRowWithListeners(keys, account, fingerprint, highlight, status, true, true, new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- account.getAxolotlService().setFingerprintTrust(fingerprint, FingerprintStatus.createActive(isChecked));
- }
- });
+ protected void addFingerprintRow(LinearLayout keys, final XmppAxolotlSession session, boolean highlight) {
+ final Account account = session.getAccount();
+ final String fingerprint = session.getFingerprint();
+ addFingerprintRowWithListeners(keys,
+ session.getAccount(),
+ session.getFingerprint(),
+ highlight,
+ session.getTrust(),
+ true,
+ true,
+ new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ account.getAxolotlService().setFingerprintTrust(fingerprint, FingerprintStatus.createActive(isChecked));
+ }
+ });
}
- protected boolean addFingerprintRowWithListeners(LinearLayout keys, final Account account,
- final String fingerprint,
- boolean highlight,
- FingerprintStatus status,
- boolean showTag,
- boolean undecidedNeedEnablement,
- CompoundButton.OnCheckedChangeListener
- onCheckedChangeListener) {
- if (status.isCompromised()) {
- return false;
- }
+ protected void addFingerprintRowWithListeners(LinearLayout keys, final Account account,
+ final String fingerprint,
+ boolean highlight,
+ FingerprintStatus status,
+ boolean showTag,
+ boolean undecidedNeedEnablement,
+ CompoundButton.OnCheckedChangeListener
+ onCheckedChangeListener) {
+
View view = getLayoutInflater().inflate(R.layout.contact_key, keys, false);
TextView key = (TextView) view.findViewById(R.id.key);
TextView keyType = (TextView) view.findViewById(R.id.key_type);
@@ -184,7 +191,6 @@ public abstract class OmemoActivity extends XmppActivity {
key.setText(CryptoHelper.prettifyFingerprint(fingerprint.substring(2)));
keys.addView(view);
- return true;
}
public void showPurgeKeyDialog(final Account account, final String fingerprint) {
diff --git a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
index bc293ea1f..13c80ef96 100644
--- a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
+++ b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
@@ -301,7 +301,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
return new HashSet<>(this.sessions.getAll(ownAddress).values());
}
- private Set<XmppAxolotlSession> findSessionsForContact(Contact contact) {
+ public Set<XmppAxolotlSession> findSessionsForContact(Contact contact) {
AxolotlAddress contactAddress = getAddressForJid(contact.getJid());
return new HashSet<>(this.sessions.getAll(contactAddress).values());
}
@@ -314,22 +314,6 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
return sessions;
}
- public Set<String> getFingerprintsForOwnSessions() {
- Set<String> fingerprints = new HashSet<>();
- for (XmppAxolotlSession session : findOwnSessions()) {
- fingerprints.add(session.getFingerprint());
- }
- return fingerprints;
- }
-
- public Set<String> getFingerprintsForContact(final Contact contact) {
- Set<String> fingerprints = new HashSet<>();
- for (XmppAxolotlSession session : findSessionsForContact(contact)) {
- fingerprints.add(session.getFingerprint());
- }
- return fingerprints;
- }
-
private boolean hasAny(Jid jid) {
return sessions.hasAny(getAddressForJid(jid));
}
@@ -415,12 +399,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
deviceIds.add(getOwnDeviceId());
IqPacket publish = mXmppConnectionService.getIqGenerator().publishDeviceIds(deviceIds);
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Wiping all other devices from Pep:" + publish);
- mXmppConnectionService.sendIqPacket(account, publish, new OnIqPacketReceived() {
- @Override
- public void onIqPacketReceived(Account account, IqPacket packet) {
- // TODO: implement this!
- }
- });
+ mXmppConnectionService.sendIqPacket(account, publish, null);
}
public void purgeKey(final String fingerprint) {
diff --git a/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlSession.java b/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlSession.java
index 27647fb66..f1e5589bf 100644
--- a/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlSession.java
+++ b/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlSession.java
@@ -132,4 +132,8 @@ public class XmppAxolotlSession {
return null;
}
}
+
+ public Account getAccount() {
+ return account;
+ }
}
diff --git a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
index 31d131549..e974fb0a0 100644
--- a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
@@ -39,6 +39,7 @@ import de.pixart.messenger.OmemoActivity;
import de.pixart.messenger.R;
import de.pixart.messenger.crypto.PgpEngine;
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;
@@ -458,9 +459,12 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
}
}
if (Config.supportOmemo()) {
- for (final String fingerprint : contact.getAccount().getAxolotlService().getFingerprintsForContact(contact)) {
- boolean highlight = fingerprint.equals(messageFingerprint);
- hasKeys |= addFingerprintRow(keys, contact.getAccount(), fingerprint, highlight);
+ for (final XmppAxolotlSession session : contact.getAccount().getAxolotlService().findSessionsForContact(contact)) {
+ if (!session.getTrust().isCompromised()) {
+ boolean highlight = session.getFingerprint().equals(messageFingerprint);
+ hasKeys = true;
+ addFingerprintRow(keys, session, highlight);
+ }
}
}
if (Config.supportOpenPgp() && contact.getPgpKeyId() != 0) {
diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
index 58453ba75..617e0e6d5 100644
--- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
@@ -44,6 +44,7 @@ import de.pixart.messenger.Config;
import de.pixart.messenger.OmemoActivity;
import de.pixart.messenger.R;
import de.pixart.messenger.crypto.axolotl.AxolotlService;
+import de.pixart.messenger.crypto.axolotl.XmppAxolotlSession;
import de.pixart.messenger.entities.Account;
import de.pixart.messenger.services.XmppConnectionService;
import de.pixart.messenger.services.XmppConnectionService.OnAccountUpdate;
@@ -258,6 +259,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
private TableRow mPushRow;
private String mSavedInstanceAccount;
private boolean mSavedInstanceInit = false;
+ private Button mClearDevicesButton;
public void refreshUiReal() {
invalidateOptionsMenu();
@@ -509,6 +511,13 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
this.mNamePort = (LinearLayout) findViewById(R.id.name_port);
this.mHostname = (EditText) findViewById(R.id.hostname);
this.mHostname.addTextChangedListener(mTextWatcher);
+ this.mClearDevicesButton = (Button) findViewById(R.id.clear_devices);
+ this.mClearDevicesButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ showWipePepDialog();
+ }
+ });
this.mPort = (EditText) findViewById(R.id.port);
this.mPort.setText("5222");
this.mPort.addTextChangedListener(mTextWatcher);
@@ -547,7 +556,6 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
final MenuItem showMoreInfo = menu.findItem(R.id.action_server_info_show_more);
final MenuItem changePassword = menu.findItem(R.id.action_change_password_on_server);
final MenuItem showPassword = menu.findItem(R.id.action_show_password);
- final MenuItem clearDevices = menu.findItem(R.id.action_clear_devices);
final MenuItem renewCertificate = menu.findItem(R.id.action_renew_certificate);
final MenuItem mamPrefs = menu.findItem(R.id.action_mam_prefs);
final MenuItem changePresence = menu.findItem(R.id.action_change_presence);
@@ -561,17 +569,12 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
changePassword.setVisible(false);
}
mamPrefs.setVisible(mAccount.getXmppConnection().getFeatures().mam());
- Set<Integer> otherDevices = mAccount.getAxolotlService().getOwnDeviceIds();
- if (otherDevices == null || otherDevices.isEmpty() || !Config.supportOmemo()) {
- clearDevices.setVisible(false);
- }
changePresence.setVisible(manuallyChangePresence());
} else {
showQrCode.setVisible(false);
showBlocklist.setVisible(false);
showMoreInfo.setVisible(false);
changePassword.setVisible(false);
- clearDevices.setVisible(false);
mamPrefs.setVisible(false);
changePresence.setVisible(false);
}
@@ -722,9 +725,6 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
case R.id.action_mam_prefs:
editMamPrefs();
break;
- case R.id.action_clear_devices:
- showWipePepDialog();
- break;
case R.id.action_renew_certificate:
renewCertificate();
break;
@@ -921,15 +921,21 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
}
boolean hasKeys = false;
keys.removeAllViews();
- for (final String fingerprint : mAccount.getAxolotlService().getFingerprintsForOwnSessions()) {
- if (ownAxolotlFingerprint.equals(fingerprint)) {
- continue;
+ for(XmppAxolotlSession session : mAccount.getAxolotlService().findOwnSessions()) {
+ if (!session.getTrust().isCompromised()) {
+ boolean highlight = session.getFingerprint().equals(messageFingerprint);
+ addFingerprintRow(keys,session,highlight);
+ hasKeys = true;
}
- boolean highlight = fingerprint.equals(messageFingerprint);
- hasKeys |= addFingerprintRow(keys, mAccount, fingerprint, highlight);
}
if (hasKeys && Config.supportOmemo()) {
keysCard.setVisibility(View.VISIBLE);
+ Set<Integer> otherDevices = mAccount.getAxolotlService().getOwnDeviceIds();
+ if (otherDevices == null || otherDevices.isEmpty()) {
+ mClearDevicesButton.setVisibility(View.GONE);
+ } else {
+ mClearDevicesButton.setVisibility(View.VISIBLE);
+ }
} else {
keysCard.setVisibility(View.GONE);
}
diff --git a/src/main/res/layout/activity_edit_account.xml b/src/main/res/layout/activity_edit_account.xml
index 7747055ec..a7c54cdbf 100644
--- a/src/main/res/layout/activity_edit_account.xml
+++ b/src/main/res/layout/activity_edit_account.xml
@@ -612,7 +612,7 @@
android:background="@drawable/infocard_border"
android:orientation="vertical"
android:padding="@dimen/infocard_padding"
- android:visibility="gone">
+ android:visibility="visible">
<TextView
android:id="@+id/other_device_keys_title"
@@ -629,7 +629,16 @@
android:layout_height="wrap_content"
android:divider="?android:dividerHorizontal"
android:orientation="vertical"
- android:showDividers="middle"></LinearLayout>
+ android:showDividers="middle">
+ </LinearLayout>
+ <Button
+ android:id="@+id/clear_devices"
+ style="?android:attr/borderlessButtonStyle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/clear_other_devices"
+ android:layout_gravity="center_horizontal"
+ android:textColor="@color/accent"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
diff --git a/src/main/res/menu/editaccount.xml b/src/main/res/menu/editaccount.xml
index fa53c08de..1e968c2d4 100644
--- a/src/main/res/menu/editaccount.xml
+++ b/src/main/res/menu/editaccount.xml
@@ -51,10 +51,6 @@
android:showAsAction="never"
android:title="@string/mgmt_account_reconnect" />
<item
- android:id="@+id/action_clear_devices"
- android:showAsAction="never"
- android:title="@string/clear_other_devices" />
- <item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"