show dynamic tags in contacts activity as well
This commit is contained in:
parent
ab832bcff7
commit
dcebc120ac
|
@ -6,8 +6,10 @@ import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentSender.SendIntentException;
|
import android.content.IntentSender.SendIntentException;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.provider.ContactsContract.CommonDataKinds;
|
import android.provider.ContactsContract.CommonDataKinds;
|
||||||
import android.provider.ContactsContract.Contacts;
|
import android.provider.ContactsContract.Contacts;
|
||||||
import android.provider.ContactsContract.Intents;
|
import android.provider.ContactsContract.Intents;
|
||||||
|
@ -27,11 +29,13 @@ import android.widget.TextView;
|
||||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
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.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
import eu.siacs.conversations.entities.Contact;
|
import eu.siacs.conversations.entities.Contact;
|
||||||
|
import eu.siacs.conversations.entities.ListItem;
|
||||||
import eu.siacs.conversations.entities.Presences;
|
import eu.siacs.conversations.entities.Presences;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
|
import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate;
|
import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate;
|
||||||
|
@ -95,11 +99,14 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
|
||||||
private Jid contactJid;
|
private Jid contactJid;
|
||||||
private TextView contactJidTv;
|
private TextView contactJidTv;
|
||||||
private TextView accountJidTv;
|
private TextView accountJidTv;
|
||||||
private TextView status;
|
|
||||||
private TextView lastseen;
|
private TextView lastseen;
|
||||||
private CheckBox send;
|
private CheckBox send;
|
||||||
private CheckBox receive;
|
private CheckBox receive;
|
||||||
private QuickContactBadge badge;
|
private QuickContactBadge badge;
|
||||||
|
private LinearLayout keys;
|
||||||
|
private LinearLayout tags;
|
||||||
|
private boolean showDynamicTags;
|
||||||
|
|
||||||
private DialogInterface.OnClickListener addToPhonebook = new DialogInterface.OnClickListener() {
|
private DialogInterface.OnClickListener addToPhonebook = new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -113,6 +120,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
|
||||||
ContactDetailsActivity.this.startActivityForResult(intent, 0);
|
ContactDetailsActivity.this.startActivityForResult(intent, 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private OnClickListener onBadgeClick = new OnClickListener() {
|
private OnClickListener onBadgeClick = new OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -127,7 +135,6 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private LinearLayout keys;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRosterUpdate() {
|
public void onRosterUpdate() {
|
||||||
|
@ -177,15 +184,17 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
|
||||||
|
|
||||||
contactJidTv = (TextView) findViewById(R.id.details_contactjid);
|
contactJidTv = (TextView) findViewById(R.id.details_contactjid);
|
||||||
accountJidTv = (TextView) findViewById(R.id.details_account);
|
accountJidTv = (TextView) findViewById(R.id.details_account);
|
||||||
status = (TextView) findViewById(R.id.details_contactstatus);
|
|
||||||
lastseen = (TextView) findViewById(R.id.details_lastseen);
|
lastseen = (TextView) findViewById(R.id.details_lastseen);
|
||||||
send = (CheckBox) findViewById(R.id.details_send_presence);
|
send = (CheckBox) findViewById(R.id.details_send_presence);
|
||||||
receive = (CheckBox) findViewById(R.id.details_receive_presence);
|
receive = (CheckBox) findViewById(R.id.details_receive_presence);
|
||||||
badge = (QuickContactBadge) findViewById(R.id.details_contact_badge);
|
badge = (QuickContactBadge) findViewById(R.id.details_contact_badge);
|
||||||
keys = (LinearLayout) findViewById(R.id.details_contact_keys);
|
keys = (LinearLayout) findViewById(R.id.details_contact_keys);
|
||||||
|
tags = (LinearLayout) findViewById(R.id.tags);
|
||||||
getActionBar().setHomeButtonEnabled(true);
|
getActionBar().setHomeButtonEnabled(true);
|
||||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
this.showDynamicTags = preferences.getBoolean("show_dynamic_tags",false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -280,36 +289,6 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
|
||||||
lastseen.setText(UIHelper.lastseen(getApplicationContext(),
|
lastseen.setText(UIHelper.lastseen(getApplicationContext(),
|
||||||
contact.lastseen.time));
|
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) {
|
if (contact.getPresences().size() > 1) {
|
||||||
contactJidTv.setText(contact.getJid() + " ("
|
contactJidTv.setText(contact.getJid() + " ("
|
||||||
+ contact.getPresences().size() + ")");
|
+ contact.getPresences().size() + ")");
|
||||||
|
@ -379,6 +358,20 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
|
||||||
} else {
|
} else {
|
||||||
keys.setVisibility(View.GONE);
|
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) {
|
private void prepareContactBadge(QuickContactBadge badge, Contact contact) {
|
||||||
|
|
|
@ -43,21 +43,16 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal" >
|
android:orientation="vertical" >
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/details_contactstatus"
|
android:id="@+id/tags"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="@color/secondarytext"
|
android:layout_marginTop="4dp"
|
||||||
android:textSize="?attr/TextSizeBody" />
|
android:layout_marginBottom="4dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
<TextView
|
</LinearLayout>
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text=" · "
|
|
||||||
android:textColor="@color/secondarytext"
|
|
||||||
android:textSize="?attr/TextSizeBody" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/details_lastseen"
|
android:id="@+id/details_lastseen"
|
||||||
|
|
Loading…
Reference in a new issue