hide inactive devices by default in contact details
This commit is contained in:
parent
40a9f70478
commit
8c34bb3c6f
|
@ -38,6 +38,7 @@ import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
import eu.siacs.conversations.crypto.PgpEngine;
|
import eu.siacs.conversations.crypto.PgpEngine;
|
||||||
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
|
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
|
||||||
|
import eu.siacs.conversations.crypto.axolotl.FingerprintStatus;
|
||||||
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
|
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
import eu.siacs.conversations.entities.Contact;
|
import eu.siacs.conversations.entities.Contact;
|
||||||
|
@ -112,11 +113,13 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
|
||||||
private CheckBox send;
|
private CheckBox send;
|
||||||
private CheckBox receive;
|
private CheckBox receive;
|
||||||
private Button addContactButton;
|
private Button addContactButton;
|
||||||
|
private Button mShowInactiveDevicesButton;
|
||||||
private QuickContactBadge badge;
|
private QuickContactBadge badge;
|
||||||
private LinearLayout keys;
|
private LinearLayout keys;
|
||||||
private FlowLayout tags;
|
private FlowLayout tags;
|
||||||
private boolean showDynamicTags = false;
|
private boolean showDynamicTags = false;
|
||||||
private boolean showLastSeen = false;
|
private boolean showLastSeen = false;
|
||||||
|
private boolean showInactiveOmemo = false;
|
||||||
private String messageFingerprint;
|
private String messageFingerprint;
|
||||||
|
|
||||||
private DialogInterface.OnClickListener addToPhonebook = new DialogInterface.OnClickListener() {
|
private DialogInterface.OnClickListener addToPhonebook = new DialogInterface.OnClickListener() {
|
||||||
|
@ -188,6 +191,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(final Bundle savedInstanceState) {
|
protected void onCreate(final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
showInactiveOmemo = savedInstanceState != null && savedInstanceState.getBoolean("show_inactive_omemo",false);
|
||||||
if (getIntent().getAction().equals(ACTION_VIEW_CONTACT)) {
|
if (getIntent().getAction().equals(ACTION_VIEW_CONTACT)) {
|
||||||
try {
|
try {
|
||||||
this.accountJid = Jid.fromString(getIntent().getExtras().getString(EXTRA_ACCOUNT));
|
this.accountJid = Jid.fromString(getIntent().getExtras().getString(EXTRA_ACCOUNT));
|
||||||
|
@ -217,10 +221,24 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
|
||||||
});
|
});
|
||||||
keys = (LinearLayout) findViewById(R.id.details_contact_keys);
|
keys = (LinearLayout) findViewById(R.id.details_contact_keys);
|
||||||
tags = (FlowLayout) findViewById(R.id.tags);
|
tags = (FlowLayout) findViewById(R.id.tags);
|
||||||
|
mShowInactiveDevicesButton = (Button) findViewById(R.id.show_inactive_devices);
|
||||||
if (getActionBar() != null) {
|
if (getActionBar() != null) {
|
||||||
getActionBar().setHomeButtonEnabled(true);
|
getActionBar().setHomeButtonEnabled(true);
|
||||||
getActionBar().setDisplayHomeAsUpEnabled(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
|
@Override
|
||||||
|
@ -444,13 +462,32 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Config.supportOmemo()) {
|
if (Config.supportOmemo()) {
|
||||||
|
boolean skippedInactive = false;
|
||||||
|
boolean showsInactive = false;
|
||||||
for (final XmppAxolotlSession session : contact.getAccount().getAxolotlService().findSessionsForContact(contact)) {
|
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);
|
boolean highlight = session.getFingerprint().equals(messageFingerprint);
|
||||||
hasKeys = true;
|
hasKeys = true;
|
||||||
addFingerprintRow(keys, session, highlight);
|
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) {
|
if (Config.supportOpenPgp() && contact.getPgpKeyId() != 0) {
|
||||||
hasKeys = true;
|
hasKeys = true;
|
||||||
|
|
|
@ -109,7 +109,6 @@
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/details_contact_keys"
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||||
|
@ -117,10 +116,30 @@
|
||||||
android:layout_marginTop="@dimen/activity_vertical_margin"
|
android:layout_marginTop="@dimen/activity_vertical_margin"
|
||||||
android:layout_marginBottom="@dimen/activity_vertical_margin"
|
android:layout_marginBottom="@dimen/activity_vertical_margin"
|
||||||
android:background="?attr/infocard_border"
|
android:background="?attr/infocard_border"
|
||||||
android:divider="?android:dividerHorizontal"
|
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="@dimen/infocard_padding"
|
android:padding="@dimen/infocard_padding">
|
||||||
android:showDividers="middle" >
|
<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:layout_marginTop="8dp"
|
||||||
|
android:id="@+id/show_inactive_devices"
|
||||||
|
style="?android:attr/borderlessButtonStyle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/show_inactive_devices"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:textColor="@color/accent"/>
|
||||||
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
@ -723,4 +723,6 @@
|
||||||
<string name="i_followed_this_link_from_a_trusted_source">I followed this link from a trusted source</string>
|
<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="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 keys</string>
|
<string name="verify_omemo_keys">Verify OMEMO keys</string>
|
||||||
|
<string name="show_inactive_devices">Show inactive devices</string>
|
||||||
|
<string name="hide_inactive_devices">Hide inactive devices</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue