aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/ui
diff options
context:
space:
mode:
authorAndreas Straub <andy@strb.org>2015-07-28 22:00:54 +0200
committerAndreas Straub <andy@strb.org>2015-07-29 02:59:26 +0200
commitefcefc2e6301f6255ebcb3e11f0f0a51731bacca (patch)
treee6964de0e5d62efe357509f740b2ac7e1a70681e /src/main/java/eu/siacs/conversations/ui
parentd9bdce01043ffdf97cb4a893f8d057b3e4d5fb8f (diff)
Refactor out inner classes, cache trust store
Moves SQLiteAxolotlStore and XmppAxolotlSession into proper classes. IdentityKeys trust statuses are now cached in an LruCache to prevent hammering the database when rendering the UI.
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java2
-rw-r--r--src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java2
-rw-r--r--src/main/java/eu/siacs/conversations/ui/XmppActivity.java18
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java6
4 files changed, 14 insertions, 14 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index 92b8e5443..515e814bd 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -38,7 +38,7 @@ import de.timroes.android.listview.EnhancedListView;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
-import eu.siacs.conversations.crypto.axolotl.AxolotlService.SQLiteAxolotlStore.Trust;
+import eu.siacs.conversations.crypto.axolotl.SQLiteAxolotlStore.Trust;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Blockable;
import eu.siacs.conversations.entities.Contact;
diff --git a/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java b/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java
index 1bf07f3ea..0b5d092b9 100644
--- a/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java
@@ -16,7 +16,7 @@ import java.util.Map;
import java.util.Set;
import eu.siacs.conversations.R;
-import eu.siacs.conversations.crypto.axolotl.AxolotlService.SQLiteAxolotlStore.Trust;
+import eu.siacs.conversations.crypto.axolotl.SQLiteAxolotlStore.Trust;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
index 835685107..52c2e4f47 100644
--- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
@@ -70,7 +70,7 @@ import java.util.concurrent.RejectedExecutionException;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
-import eu.siacs.conversations.crypto.axolotl.AxolotlService;
+import eu.siacs.conversations.crypto.axolotl.SQLiteAxolotlStore;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
@@ -610,16 +610,16 @@ public abstract class XmppActivity extends Activity {
protected boolean addFingerprintRow(LinearLayout keys, final Account account, IdentityKey identityKey) {
final String fingerprint = identityKey.getFingerprint().replaceAll("\\s", "");
- final AxolotlService.SQLiteAxolotlStore.Trust trust = account.getAxolotlService()
+ final SQLiteAxolotlStore.Trust trust = account.getAxolotlService()
.getFingerprintTrust(fingerprint);
return addFingerprintRowWithListeners(keys, account, identityKey, trust, true,
new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- if (isChecked != (trust == AxolotlService.SQLiteAxolotlStore.Trust.TRUSTED)) {
+ if (isChecked != (trust == SQLiteAxolotlStore.Trust.TRUSTED)) {
account.getAxolotlService().setFingerprintTrust(fingerprint,
- (isChecked) ? AxolotlService.SQLiteAxolotlStore.Trust.TRUSTED :
- AxolotlService.SQLiteAxolotlStore.Trust.UNTRUSTED);
+ (isChecked) ? SQLiteAxolotlStore.Trust.TRUSTED :
+ SQLiteAxolotlStore.Trust.UNTRUSTED);
}
refreshUi();
xmppConnectionService.updateAccountUi();
@@ -630,7 +630,7 @@ public abstract class XmppActivity extends Activity {
@Override
public void onClick(View v) {
account.getAxolotlService().setFingerprintTrust(fingerprint,
- AxolotlService.SQLiteAxolotlStore.Trust.UNTRUSTED);
+ SQLiteAxolotlStore.Trust.UNTRUSTED);
refreshUi();
xmppConnectionService.updateAccountUi();
xmppConnectionService.updateConversationUi();
@@ -642,12 +642,12 @@ public abstract class XmppActivity extends Activity {
protected boolean addFingerprintRowWithListeners(LinearLayout keys, final Account account,
final IdentityKey identityKey,
- AxolotlService.SQLiteAxolotlStore.Trust trust,
+ SQLiteAxolotlStore.Trust trust,
boolean showTag,
CompoundButton.OnCheckedChangeListener
onCheckedChangeListener,
View.OnClickListener onClickListener) {
- if (trust == AxolotlService.SQLiteAxolotlStore.Trust.COMPROMISED) {
+ if (trust == SQLiteAxolotlStore.Trust.COMPROMISED) {
return false;
}
View view = getLayoutInflater().inflate(R.layout.contact_key, keys, false);
@@ -668,7 +668,7 @@ public abstract class XmppActivity extends Activity {
switch (trust) {
case UNTRUSTED:
case TRUSTED:
- trustToggle.setChecked(trust == AxolotlService.SQLiteAxolotlStore.Trust.TRUSTED, false);
+ trustToggle.setChecked(trust == SQLiteAxolotlStore.Trust.TRUSTED, false);
trustToggle.setEnabled(true);
key.setTextColor(getPrimaryTextColor());
keyType.setTextColor(getSecondaryTextColor());
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
index b158f0fe4..f55094af6 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -27,7 +27,7 @@ import android.widget.Toast;
import java.util.List;
import eu.siacs.conversations.R;
-import eu.siacs.conversations.crypto.axolotl.AxolotlService;
+import eu.siacs.conversations.crypto.axolotl.SQLiteAxolotlStore;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
@@ -173,11 +173,11 @@ public class MessageAdapter extends ArrayAdapter<Message> {
} else {
viewHolder.indicator.setVisibility(View.VISIBLE);
if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL) {
- AxolotlService.SQLiteAxolotlStore.Trust trust = message.getConversation()
+ SQLiteAxolotlStore.Trust trust = message.getConversation()
.getAccount().getAxolotlService().getFingerprintTrust(
message.getAxolotlFingerprint());
- if(trust == null || trust != AxolotlService.SQLiteAxolotlStore.Trust.TRUSTED) {
+ if(trust == null || trust != SQLiteAxolotlStore.Trust.TRUSTED) {
viewHolder.indicator.setColorFilter(Color.RED);
} else {
viewHolder.indicator.clearColorFilter();