change key activities to cards
This commit is contained in:
parent
58ec5ced8a
commit
30776a86c4
|
@ -1,6 +1,7 @@
|
|||
package eu.siacs.conversations.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.databinding.DataBindingUtil;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.util.Log;
|
||||
|
@ -29,6 +30,8 @@ import eu.siacs.conversations.Config;
|
|||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
|
||||
import eu.siacs.conversations.crypto.axolotl.FingerprintStatus;
|
||||
import eu.siacs.conversations.databinding.ActivityTrustKeysBinding;
|
||||
import eu.siacs.conversations.databinding.KeysCardBinding;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.entities.Conversation;
|
||||
import eu.siacs.conversations.utils.CryptoHelper;
|
||||
|
@ -38,19 +41,13 @@ import eu.siacs.conversations.xmpp.OnKeyStatusUpdated;
|
|||
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
||||
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||
|
||||
import static android.databinding.DataBindingUtil.inflate;
|
||||
|
||||
public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdated {
|
||||
private List<Jid> contactJids;
|
||||
|
||||
private Account mAccount;
|
||||
private Conversation mConversation;
|
||||
private TextView keyErrorMessage;
|
||||
private LinearLayout keyErrorMessageCard;
|
||||
private TextView ownKeysTitle;
|
||||
private LinearLayout ownKeys;
|
||||
private LinearLayout ownKeysCard;
|
||||
private LinearLayout foreignKeys;
|
||||
private Button mSaveButton;
|
||||
private Button mCancelButton;
|
||||
|
||||
private AtomicBoolean mUseCameraHintShown = new AtomicBoolean(false);
|
||||
|
||||
|
@ -75,6 +72,7 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
|
|||
}
|
||||
};
|
||||
private Toast mUseCameraHintToast = null;
|
||||
private ActivityTrustKeysBinding binding;
|
||||
|
||||
@Override
|
||||
protected void refreshUiReal() {
|
||||
|
@ -85,7 +83,7 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
|
|||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_trust_keys);
|
||||
this.binding = DataBindingUtil.setContentView(this,R.layout.activity_trust_keys);
|
||||
this.contactJids = new ArrayList<>();
|
||||
for(String jid : getIntent().getStringArrayExtra("contacts")) {
|
||||
try {
|
||||
|
@ -95,16 +93,8 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
|
|||
}
|
||||
}
|
||||
|
||||
keyErrorMessageCard = (LinearLayout) findViewById(R.id.key_error_message_card);
|
||||
keyErrorMessage = (TextView) findViewById(R.id.key_error_message);
|
||||
ownKeysTitle = (TextView) findViewById(R.id.own_keys_title);
|
||||
ownKeys = (LinearLayout) findViewById(R.id.own_keys_details);
|
||||
ownKeysCard = (LinearLayout) findViewById(R.id.own_keys_card);
|
||||
foreignKeys = (LinearLayout) findViewById(R.id.foreign_keys);
|
||||
mCancelButton = (Button) findViewById(R.id.cancel_button);
|
||||
mCancelButton.setOnClickListener(mCancelButtonListener);
|
||||
mSaveButton = (Button) findViewById(R.id.save_button);
|
||||
mSaveButton.setOnClickListener(mSaveButtonListener);
|
||||
binding.cancelButton.setOnClickListener(mCancelButtonListener);
|
||||
binding.saveButton.setOnClickListener(mSaveButtonListener);
|
||||
|
||||
|
||||
if (getSupportActionBar() != null) {
|
||||
|
@ -185,13 +175,13 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
|
|||
|
||||
private void populateView() {
|
||||
setTitle(getString(R.string.trust_omemo_fingerprints));
|
||||
ownKeys.removeAllViews();
|
||||
foreignKeys.removeAllViews();
|
||||
binding.ownKeysDetails.removeAllViews();
|
||||
binding.foreignKeys.removeAllViews();
|
||||
boolean hasOwnKeys = false;
|
||||
boolean hasForeignKeys = false;
|
||||
for(final String fingerprint : ownKeysToTrust.keySet()) {
|
||||
hasOwnKeys = true;
|
||||
addFingerprintRowWithListeners(ownKeys, mAccount, fingerprint, false,
|
||||
addFingerprintRowWithListeners(binding.ownKeysDetails, mAccount, fingerprint, false,
|
||||
FingerprintStatus.createActive(ownKeysToTrust.get(fingerprint)), false, false,
|
||||
new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
|
@ -206,46 +196,36 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
|
|||
synchronized (this.foreignKeysToTrust) {
|
||||
for (Map.Entry<Jid, Map<String, Boolean>> entry : foreignKeysToTrust.entrySet()) {
|
||||
hasForeignKeys = true;
|
||||
final LinearLayout layout = (LinearLayout) getLayoutInflater().inflate(R.layout.keys_card, foreignKeys, false);
|
||||
KeysCardBinding keysCardBinding = DataBindingUtil.inflate(getLayoutInflater(),R.layout.keys_card, binding.foreignKeys,false);
|
||||
//final LinearLayout layout = (LinearLayout) getLayoutInflater().inflate(R.layout.keys_card, foreignKeys, false);
|
||||
final Jid jid = entry.getKey();
|
||||
final TextView header = (TextView) layout.findViewById(R.id.foreign_keys_title);
|
||||
final LinearLayout keysContainer = (LinearLayout) layout.findViewById(R.id.foreign_keys_details);
|
||||
final TextView informNoKeys = (TextView) layout.findViewById(R.id.no_keys_to_accept);
|
||||
header.setText(jid.toString());
|
||||
header.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switchToContactDetails(mAccount.getRoster().getContact(jid));
|
||||
}
|
||||
});
|
||||
keysCardBinding.foreignKeysTitle.setText(jid.toString());
|
||||
keysCardBinding.foreignKeysTitle.setOnClickListener(v -> switchToContactDetails(mAccount.getRoster().getContact(jid)));
|
||||
final Map<String, Boolean> fingerprints = entry.getValue();
|
||||
for (final String fingerprint : fingerprints.keySet()) {
|
||||
addFingerprintRowWithListeners(keysContainer, mAccount, fingerprint, false,
|
||||
addFingerprintRowWithListeners(keysCardBinding.foreignKeysDetails, mAccount, fingerprint, false,
|
||||
FingerprintStatus.createActive(fingerprints.get(fingerprint)), false, false,
|
||||
new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
(buttonView, isChecked) -> {
|
||||
fingerprints.put(fingerprint, isChecked);
|
||||
lockOrUnlockAsNeeded();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
if (fingerprints.size() == 0) {
|
||||
informNoKeys.setVisibility(View.VISIBLE);
|
||||
keysCardBinding.noKeysToAccept.setVisibility(View.VISIBLE);
|
||||
if (hasNoOtherTrustedKeys(jid)) {
|
||||
if (!mAccount.getRoster().getContact(jid).mutualPresenceSubscription()) {
|
||||
informNoKeys.setText(R.string.error_no_keys_to_trust_presence);
|
||||
keysCardBinding.noKeysToAccept.setText(R.string.error_no_keys_to_trust_presence);
|
||||
} else {
|
||||
informNoKeys.setText(R.string.error_no_keys_to_trust_server_error);
|
||||
keysCardBinding.noKeysToAccept.setText(R.string.error_no_keys_to_trust_server_error);
|
||||
}
|
||||
} else {
|
||||
informNoKeys.setText(getString(R.string.no_keys_just_confirm, mAccount.getRoster().getContact(jid).getDisplayName()));
|
||||
keysCardBinding.noKeysToAccept.setText(getString(R.string.no_keys_just_confirm, mAccount.getRoster().getContact(jid).getDisplayName()));
|
||||
}
|
||||
} else {
|
||||
informNoKeys.setVisibility(View.GONE);
|
||||
keysCardBinding.noKeysToAccept.setVisibility(View.GONE);
|
||||
}
|
||||
foreignKeys.addView(layout);
|
||||
binding.foreignKeys.addView(keysCardBinding.foreignKeysCard);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,29 +233,29 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
|
|||
showCameraToast();
|
||||
}
|
||||
|
||||
ownKeysTitle.setText(mAccount.getJid().toBareJid().toString());
|
||||
ownKeysCard.setVisibility(hasOwnKeys ? View.VISIBLE : View.GONE);
|
||||
foreignKeys.setVisibility(hasForeignKeys ? View.VISIBLE : View.GONE);
|
||||
binding.ownKeysTitle.setText(mAccount.getJid().toBareJid().toString());
|
||||
binding.ownKeysCard.setVisibility(hasOwnKeys ? View.VISIBLE : View.GONE);
|
||||
binding.foreignKeys.setVisibility(hasForeignKeys ? View.VISIBLE : View.GONE);
|
||||
if(hasPendingKeyFetches()) {
|
||||
setFetching();
|
||||
lock();
|
||||
} else {
|
||||
if (!hasForeignKeys && hasNoOtherTrustedKeys()) {
|
||||
keyErrorMessageCard.setVisibility(View.VISIBLE);
|
||||
binding.keyErrorMessageCard.setVisibility(View.VISIBLE);
|
||||
if (lastFetchReport == AxolotlService.FetchStatus.ERROR
|
||||
|| mAccount.getAxolotlService().fetchMapHasErrors(contactJids)) {
|
||||
if (anyWithoutMutualPresenceSubscription(contactJids)) {
|
||||
keyErrorMessage.setText(R.string.error_no_keys_to_trust_presence);
|
||||
binding.keyErrorMessage.setText(R.string.error_no_keys_to_trust_presence);
|
||||
} else {
|
||||
keyErrorMessage.setText(R.string.error_no_keys_to_trust_server_error);
|
||||
binding.keyErrorMessage.setText(R.string.error_no_keys_to_trust_server_error);
|
||||
}
|
||||
} else {
|
||||
keyErrorMessage.setText(R.string.error_no_keys_to_trust);
|
||||
binding.keyErrorMessage.setText(R.string.error_no_keys_to_trust);
|
||||
}
|
||||
ownKeys.removeAllViews();
|
||||
ownKeysCard.setVisibility(View.GONE);
|
||||
foreignKeys.removeAllViews();
|
||||
foreignKeys.setVisibility(View.GONE);
|
||||
binding.ownKeysDetails.removeAllViews();
|
||||
binding.ownKeysCard.setVisibility(View.GONE);
|
||||
binding.foreignKeys.removeAllViews();
|
||||
binding.foreignKeys.setVisibility(View.GONE);
|
||||
}
|
||||
lockOrUnlockAsNeeded();
|
||||
setDone();
|
||||
|
@ -441,13 +421,13 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
|
|||
}
|
||||
|
||||
private void unlock() {
|
||||
mSaveButton.setEnabled(true);
|
||||
mSaveButton.setTextColor(getPrimaryTextColor());
|
||||
binding.saveButton.setEnabled(true);
|
||||
binding.saveButton.setTextColor(getPrimaryTextColor());
|
||||
}
|
||||
|
||||
private void lock() {
|
||||
mSaveButton.setEnabled(false);
|
||||
mSaveButton.setTextColor(getSecondaryTextColor());
|
||||
binding.saveButton.setEnabled(false);
|
||||
binding.saveButton.setTextColor(getSecondaryTextColor());
|
||||
}
|
||||
|
||||
private void lockOrUnlockAsNeeded() {
|
||||
|
@ -465,10 +445,10 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
|
|||
}
|
||||
|
||||
private void setDone() {
|
||||
mSaveButton.setText(getString(R.string.done));
|
||||
binding.saveButton.setText(getString(R.string.done));
|
||||
}
|
||||
|
||||
private void setFetching() {
|
||||
mSaveButton.setText(getString(R.string.fetching_keys));
|
||||
binding.saveButton.setText(getString(R.string.fetching_keys));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,65 +1,74 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/color_background_secondary" >
|
||||
android:background="?attr/color_background_secondary">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/button_bar"
|
||||
android:layout_alignParentTop="true" >
|
||||
android:layout_alignParentTop="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
<android.support.v7.widget.CardView
|
||||
android:id="@+id/key_error_message_card"
|
||||
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="?attr/infocard_border"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/infocard_padding"
|
||||
android:visibility="gone">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/infocard_padding">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/key_error_message_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/error_trustkeys_title"
|
||||
android:textColor="?attr/color_text_primary"
|
||||
android:textSize="?attr/TextSizeHeadline"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/error_trustkeys_title"/>
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/key_error_message"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="8dp"
|
||||
android:textColor="?attr/color_text_primary"
|
||||
android:textSize="?attr/TextSizeBody"
|
||||
android:padding="8dp"/>
|
||||
|
||||
android:textSize="?attr/TextSizeBody"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
</android.support.v7.widget.CardView>
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
android:id="@+id/own_keys_card"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_width="match_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="?attr/infocard_border"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/infocard_padding"
|
||||
android:visibility="gone">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/infocard_padding">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/own_keys_title"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -73,32 +82,34 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:divider="?android:dividerHorizontal"
|
||||
android:showDividers="middle"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:showDividers="middle">
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/foreign_keys"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/button_bar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true" >
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentStart="true">
|
||||
|
||||
<Button
|
||||
android:id="@+id/cancel_button"
|
||||
|
@ -107,14 +118,14 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/cancel"
|
||||
android:textColor="?attr/color_text_primary" />
|
||||
android:textColor="?attr/color_text_primary"/>
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginBottom="7dp"
|
||||
android:layout_marginTop="7dp"
|
||||
android:background="?attr/divider" />
|
||||
android:background="?attr/divider"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/save_button"
|
||||
|
@ -123,7 +134,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:enabled="true"
|
||||
android:textColor="?attr/color_text_secondary"
|
||||
android:text="@string/done"/>
|
||||
android:text="@string/done"
|
||||
android:textColor="?attr/color_text_secondary"/>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
</layout>
|
|
@ -1,13 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout android:id="@+id/foreign_keys_card"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
android:id="@+id/foreign_keys_card"
|
||||
|
||||
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:background="?attr/infocard_border"
|
||||
android:layout_marginTop="@dimen/activity_vertical_margin">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/infocard_padding">
|
||||
|
||||
|
@ -29,11 +35,13 @@
|
|||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_marginTop="8dp"
|
||||
android:id="@+id/no_keys_to_accept"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?attr/color_text_primary"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/no_keys_just_confirm"
|
||||
android:textColor="?attr/color_text_primary"
|
||||
android:textSize="?attr/TextSizeBody"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
||||
</layout>
|
Loading…
Reference in New Issue