aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-11-18 14:24:06 +0100
committeriNPUTmice <daniel@gultsch.de>2014-11-18 14:24:06 +0100
commitdcebc120aca633b129fb96ef76cd061317cf12f0 (patch)
treeb0148e734ef126a4b5419f16926825632fbd657b /src/main
parentab832bcff72c024c0936080ec6e55fdafd20a7da (diff)
show dynamic tags in contacts activity as well
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java59
-rw-r--r--src/main/res/layout/activity_contact_details.xml19
2 files changed, 33 insertions, 45 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
index 788244e36..3c9519a4a 100644
--- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
@@ -6,8 +6,10 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentSender.SendIntentException;
+import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
+import android.preference.PreferenceManager;
import android.provider.ContactsContract.CommonDataKinds;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Intents;
@@ -27,11 +29,13 @@ import android.widget.TextView;
import org.openintents.openpgp.util.OpenPgpUtils;
import java.util.Iterator;
+import java.util.List;
import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.PgpEngine;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
+import eu.siacs.conversations.entities.ListItem;
import eu.siacs.conversations.entities.Presences;
import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate;
@@ -95,11 +99,14 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
private Jid contactJid;
private TextView contactJidTv;
private TextView accountJidTv;
- private TextView status;
private TextView lastseen;
private CheckBox send;
private CheckBox receive;
private QuickContactBadge badge;
+ private LinearLayout keys;
+ private LinearLayout tags;
+ private boolean showDynamicTags;
+
private DialogInterface.OnClickListener addToPhonebook = new DialogInterface.OnClickListener() {
@Override
@@ -113,6 +120,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
ContactDetailsActivity.this.startActivityForResult(intent, 0);
}
};
+
private OnClickListener onBadgeClick = new OnClickListener() {
@Override
@@ -127,7 +135,6 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
builder.create().show();
}
};
- private LinearLayout keys;
@Override
public void onRosterUpdate() {
@@ -177,15 +184,17 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
contactJidTv = (TextView) findViewById(R.id.details_contactjid);
accountJidTv = (TextView) findViewById(R.id.details_account);
- status = (TextView) findViewById(R.id.details_contactstatus);
lastseen = (TextView) findViewById(R.id.details_lastseen);
send = (CheckBox) findViewById(R.id.details_send_presence);
receive = (CheckBox) findViewById(R.id.details_receive_presence);
badge = (QuickContactBadge) findViewById(R.id.details_contact_badge);
keys = (LinearLayout) findViewById(R.id.details_contact_keys);
+ tags = (LinearLayout) findViewById(R.id.tags);
getActionBar().setHomeButtonEnabled(true);
getActionBar().setDisplayHomeAsUpEnabled(true);
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
+ this.showDynamicTags = preferences.getBoolean("show_dynamic_tags",false);
}
@Override
@@ -280,36 +289,6 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
lastseen.setText(UIHelper.lastseen(getApplicationContext(),
contact.lastseen.time));
- switch (contact.getMostAvailableStatus()) {
- case Presences.CHAT:
- status.setText(R.string.contact_status_free_to_chat);
- status.setTextColor(mColorGreen);
- break;
- case Presences.ONLINE:
- status.setText(R.string.contact_status_online);
- status.setTextColor(mColorGreen);
- break;
- case Presences.AWAY:
- status.setText(R.string.contact_status_away);
- status.setTextColor(mColorOrange);
- break;
- case Presences.XA:
- status.setText(R.string.contact_status_extended_away);
- status.setTextColor(mColorOrange);
- break;
- case Presences.DND:
- status.setText(R.string.contact_status_do_not_disturb);
- status.setTextColor(mColorRed);
- break;
- case Presences.OFFLINE:
- status.setText(R.string.contact_status_offline);
- status.setTextColor(mSecondaryTextColor);
- break;
- default:
- status.setText(R.string.contact_status_offline);
- status.setTextColor(mSecondaryTextColor);
- break;
- }
if (contact.getPresences().size() > 1) {
contactJidTv.setText(contact.getJid() + " ("
+ contact.getPresences().size() + ")");
@@ -379,6 +358,20 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
} else {
keys.setVisibility(View.GONE);
}
+
+ List<ListItem.Tag> tagList = contact.getTags();
+ if (tagList.size() == 0 || !this.showDynamicTags) {
+ tags.setVisibility(View.GONE);
+ } else {
+ tags.setVisibility(View.VISIBLE);
+ tags.removeAllViewsInLayout();
+ for(ListItem.Tag tag : tagList) {
+ TextView tv = (TextView) inflater.inflate(R.layout.list_item_tag,tags,false);
+ tv.setText(tag.getName());
+ tv.setBackgroundColor(tag.getColor());
+ tags.addView(tv);
+ }
+ }
}
private void prepareContactBadge(QuickContactBadge badge, Contact contact) {
diff --git a/src/main/res/layout/activity_contact_details.xml b/src/main/res/layout/activity_contact_details.xml
index 2b94e6f67..21635208c 100644
--- a/src/main/res/layout/activity_contact_details.xml
+++ b/src/main/res/layout/activity_contact_details.xml
@@ -43,21 +43,16 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:orientation="horizontal" >
+ android:orientation="vertical" >
- <TextView
- android:id="@+id/details_contactstatus"
+ <LinearLayout
+ android:id="@+id/tags"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textColor="@color/secondarytext"
- android:textSize="?attr/TextSizeBody" />
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text=" ยท "
- android:textColor="@color/secondarytext"
- android:textSize="?attr/TextSizeBody" />
+ android:layout_marginTop="4dp"
+ android:layout_marginBottom="4dp"
+ android:orientation="horizontal">
+ </LinearLayout>
<TextView
android:id="@+id/details_lastseen"