aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-01-02 18:47:24 +0100
committerChristian Schneppe <christian@pix-art.de>2017-01-02 18:47:24 +0100
commit712d97bf00e576abdbf143636b8588b16ae9bc19 (patch)
tree688b405bd509b9f49c80b7e1222030761d4132d5
parentfeaf7f41d3ab9474da64ee59586df5bc85f39931 (diff)
hide inactive devices by default in contact details
-rw-r--r--src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java45
-rw-r--r--src/main/res/layout/activity_contact_details.xml101
-rw-r--r--src/main/res/values/strings.xml2
3 files changed, 105 insertions, 43 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
index 9b00b7ae9..349051399 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.Config;
import de.pixart.messenger.R;
import de.pixart.messenger.crypto.PgpEngine;
import de.pixart.messenger.crypto.axolotl.AxolotlService;
+import de.pixart.messenger.crypto.axolotl.FingerprintStatus;
import de.pixart.messenger.crypto.axolotl.XmppAxolotlSession;
import de.pixart.messenger.entities.Account;
import de.pixart.messenger.entities.Contact;
@@ -113,11 +114,13 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
private CheckBox send;
private CheckBox receive;
private Button addContactButton;
+ private Button mShowInactiveDevicesButton;
private QuickContactBadge badge;
private LinearLayout keys;
private FlowLayout tags;
private boolean showDynamicTags = false;
private boolean showLastSeen = false;
+ private boolean showInactiveOmemo = false;
private String messageFingerprint;
private DialogInterface.OnClickListener addToPhonebook = new DialogInterface.OnClickListener() {
@@ -189,6 +192,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ showInactiveOmemo = savedInstanceState != null && savedInstanceState.getBoolean("show_inactive_omemo", false);
if (getIntent().getAction().equals(ACTION_VIEW_CONTACT)) {
try {
this.accountJid = Jid.fromString(getIntent().getExtras().getString(EXTRA_ACCOUNT));
@@ -218,10 +222,24 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
});
keys = (LinearLayout) findViewById(R.id.details_contact_keys);
tags = (FlowLayout) findViewById(R.id.tags);
+ mShowInactiveDevicesButton = (Button) findViewById(R.id.show_inactive_devices);
if (getActionBar() != null) {
getActionBar().setHomeButtonEnabled(true);
getActionBar().setDisplayHomeAsUpEnabled(true);
}
+ mShowInactiveDevicesButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ showInactiveOmemo = !showInactiveOmemo;
+ populateView();
+ }
+ });
+ }
+
+ @Override
+ public void onSaveInstanceState(final Bundle savedInstanceState) {
+ savedInstanceState.putBoolean("show_inactive_omemo", showInactiveOmemo);
+ super.onSaveInstanceState(savedInstanceState);
}
@Override
@@ -458,13 +476,32 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
}
}
if (Config.supportOmemo()) {
+ boolean skippedInactive = false;
+ boolean showsInactive = false;
for (final XmppAxolotlSession session : contact.getAccount().getAxolotlService().findSessionsForContact(contact)) {
- if (!session.getTrust().isCompromised()) {
+ final FingerprintStatus trust = session.getTrust();
+ if (!trust.isActive()) {
+ if (showInactiveOmemo) {
+ showsInactive = true;
+ } else {
+ skippedInactive = true;
+ continue;
+ }
+ }
+ if (!trust.isCompromised()) {
boolean highlight = session.getFingerprint().equals(messageFingerprint);
hasKeys = true;
addFingerprintRow(keys, session, highlight);
}
}
+ if (showsInactive || skippedInactive) {
+ mShowInactiveDevicesButton.setText(showsInactive ? R.string.hide_inactive_devices : R.string.show_inactive_devices);
+ mShowInactiveDevicesButton.setVisibility(View.VISIBLE);
+ } else {
+ mShowInactiveDevicesButton.setVisibility(View.GONE);
+ }
+ } else {
+ mShowInactiveDevicesButton.setVisibility(View.GONE);
}
if (Config.supportOpenPgp() && contact.getPgpKeyId() != 0) {
hasKeys = true;
@@ -562,11 +599,11 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
@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();
+ 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();
+ Toast.makeText(this, R.string.invalid_barcode, Toast.LENGTH_SHORT).show();
}
}
}
diff --git a/src/main/res/layout/activity_contact_details.xml b/src/main/res/layout/activity_contact_details.xml
index ca641886e..15e806ae6 100644
--- a/src/main/res/layout/activity_contact_details.xml
+++ b/src/main/res/layout/activity_contact_details.xml
@@ -13,10 +13,10 @@
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin"
- android:layout_marginBottom="@dimen/activity_vertical_margin"
android:background="@drawable/infocard_border"
android:padding="@dimen/infocard_padding">
@@ -24,66 +24,66 @@
android:id="@+id/details_contact_badge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:maxHeight="384dp"
- android:maxWidth="384dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
+ android:adjustViewBounds="true"
android:background="@drawable/message_border"
- android:padding="1dp"
- android:adjustViewBounds="true" />
+ android:maxHeight="384dp"
+ android:maxWidth="384dp"
+ android:padding="1dp" />
<LinearLayout
android:id="@+id/details_jidbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:orientation="vertical"
- android:layout_below="@+id/details_contact_badge"
- android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
- android:layout_marginTop="16dp"
android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true">
+ android:layout_alignParentRight="true"
+ android:layout_alignParentStart="true"
+ android:layout_below="@+id/details_contact_badge"
+ android:layout_marginTop="16dp"
+ android:orientation="vertical">
<TextView
android:id="@+id/details_contactjid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
android:text="@string/account_settings_example_jabber_id"
android:textColor="@color/black87"
+ android:textIsSelectable="true"
android:textSize="?attr/TextSizeHeadline"
android:textStyle="bold"
- android:layout_gravity="center_horizontal"
- android:textIsSelectable="true"
android:visibility="gone" />
<com.wefika.flowlayout.FlowLayout
android:id="@+id/tags"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginTop="4dp"
- android:layout_marginLeft="-2dp"
+ android:layout_gravity="center_horizontal"
android:layout_marginBottom="4dp"
- android:orientation="horizontal"
- android:layout_gravity="center_horizontal"></com.wefika.flowlayout.FlowLayout>
+ android:layout_marginLeft="-2dp"
+ android:layout_marginTop="4dp"
+ android:orientation="horizontal"></com.wefika.flowlayout.FlowLayout>
<TextView
android:id="@+id/details_lastseen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
android:textColor="@color/black54"
- android:textSize="?attr/TextSizeBody"
- android:layout_gravity="center_horizontal" />
+ android:textSize="?attr/TextSizeBody" />
<github.ankushsachdeva.emojicon.EmojiconTextView
- android:layout_marginTop="8dp"
android:id="@+id/status_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginTop="8dp"
+ android:gravity="center_horizontal"
android:textColor="@color/black54"
- android:textStyle="italic"
android:textSize="?attr/TextSizeBody"
- android:layout_gravity="center_horizontal"
- android:gravity="center_horizontal" />
+ android:textStyle="italic" />
</LinearLayout>
@@ -103,10 +103,10 @@
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin"
- android:layout_marginBottom="@dimen/activity_vertical_margin"
android:background="@drawable/infocard_border"
android:padding="@dimen/infocard_padding">
@@ -114,48 +114,71 @@
android:id="@+id/add_contact_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="@string/add_contact"
- android:layout_gravity="center_horizontal"
android:layout_alignParentTop="true"
- android:layout_centerHorizontal="true" />
+ android:layout_centerHorizontal="true"
+ android:layout_gravity="center_horizontal"
+ android:text="@string/add_contact" />
<CheckBox
android:id="@+id/details_send_presence"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true"
+ android:layout_below="@+id/add_contact_button"
android:text="@string/send_presence_updates"
android:textColor="@color/black87"
- android:textSize="?attr/TextSizeBody"
- android:layout_below="@+id/add_contact_button"
- android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true" />
+ android:textSize="?attr/TextSizeBody" />
<CheckBox
android:id="@+id/details_receive_presence"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true"
+ android:layout_below="@+id/details_send_presence"
android:text="@string/receive_presence_updates"
android:textColor="@color/black87"
- android:textSize="?attr/TextSizeBody"
- android:layout_below="@+id/details_send_presence"
- android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true" />
+ android:textSize="?attr/TextSizeBody" />
</RelativeLayout>
<LinearLayout
- android:id="@+id/details_contact_keys"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin"
- android:layout_marginBottom="@dimen/activity_vertical_margin"
android:background="@drawable/infocard_border"
- android:divider="?android:dividerHorizontal"
android:orientation="vertical"
- android:padding="@dimen/infocard_padding"
- android:showDividers="middle"></LinearLayout>
+ android:padding="@dimen/infocard_padding">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <LinearLayout
+ android:id="@+id/details_contact_keys"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:divider="?android:dividerHorizontal"
+ android:orientation="vertical"
+ android:showDividers="middle">
+ </LinearLayout>
+
+ <Button
+ android:id="@+id/show_inactive_devices"
+ style="?android:attr/borderlessButtonStyle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginTop="8dp"
+ android:text="@string/show_inactive_devices"
+ android:textColor="@color/accent" />
+ </LinearLayout>
+ </LinearLayout>
</LinearLayout>
</ScrollView>
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index d7f5ffa67..0f0e95d75 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -728,4 +728,6 @@
<string name="i_followed_this_link_from_a_trusted_source">I followed this link from a trusted source</string>
<string name="verifying_omemo_keys_trusted_source">You are about to verify the OMEMO keys of %1$s after clicking a link. This is only secure if you followed this link from a trusted source where only %2$s could have published this link.</string>
<string name="verify_omemo_keys">Verify OMEMO fingerprints</string>
+ <string name="show_inactive_devices">Show inactive devices</string>
+ <string name="hide_inactive_devices">Hide inactive devices</string>
</resources>