diff --git a/src/main/java/org/thoughtcrime/securesms/accounts/AccountSelectionListFragment.java b/src/main/java/org/thoughtcrime/securesms/accounts/AccountSelectionListFragment.java
index ce003fbe9..70f4f6daf 100644
--- a/src/main/java/org/thoughtcrime/securesms/accounts/AccountSelectionListFragment.java
+++ b/src/main/java/org/thoughtcrime/securesms/accounts/AccountSelectionListFragment.java
@@ -9,6 +9,7 @@
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
+import android.widget.EditText;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -35,6 +36,7 @@
import org.thoughtcrime.securesms.util.ViewUtil;
import static com.b44t.messenger.DcContact.DC_CONTACT_ID_ADD_ACCOUNT;
+import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_PRIVATE_TAG;
public class AccountSelectionListFragment extends DialogFragment
{
@@ -113,9 +115,36 @@ private void onContextItemSelected(MenuItem item, int accountId) {
case R.id.menu_mute_notifications:
onToggleMute(accountId);
break;
+ case R.id.menu_set_tag:
+ onSetTag(accountId);
+ break;
}
}
+ private void onSetTag(int accountId) {
+ Activity activity = getActivity();
+ if (activity == null) return;
+ AccountSelectionListFragment.this.dismiss();
+
+ DcContext dcContext = DcHelper.getAccounts(activity).getAccount(accountId);
+ View view = View.inflate(activity, R.layout.single_line_input, null);
+ EditText inputField = view.findViewById(R.id.input_field);
+ inputField.setHint(R.string.profile_tag_hint);
+ inputField.setText(dcContext.getConfig(CONFIG_PRIVATE_TAG));
+
+ new AlertDialog.Builder(activity)
+ .setTitle(R.string.profile_tag)
+ .setMessage(R.string.profile_tag_explain)
+ .setView(view)
+ .setPositiveButton(android.R.string.ok, (d, b) -> {
+ String newTag = inputField.getText().toString().trim();
+ dcContext.setConfig(CONFIG_PRIVATE_TAG, newTag);
+ AccountManager.getInstance().showSwitchAccountMenu(activity);
+ })
+ .setNegativeButton(R.string.cancel, (d, b) -> AccountManager.getInstance().showSwitchAccountMenu(activity))
+ .show();
+ }
+
private void onDeleteAccount(int accountId) {
Activity activity = getActivity();
AccountSelectionListFragment.this.dismiss();
diff --git a/src/main/java/org/thoughtcrime/securesms/accounts/AccountSelectionListItem.java b/src/main/java/org/thoughtcrime/securesms/accounts/AccountSelectionListItem.java
index f18b24380..1f136cb18 100644
--- a/src/main/java/org/thoughtcrime/securesms/accounts/AccountSelectionListItem.java
+++ b/src/main/java/org/thoughtcrime/securesms/accounts/AccountSelectionListItem.java
@@ -1,5 +1,8 @@
package org.thoughtcrime.securesms.accounts;
+import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_DISPLAY_NAME;
+import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_PRIVATE_TAG;
+
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
@@ -27,7 +30,7 @@ public class AccountSelectionListItem extends LinearLayout {
private AvatarImageView contactPhotoImage;
private View addrContainer;
- private TextView addrView;
+ private TextView addrOrTagView;
private TextView nameView;
private ImageView unreadIndicator;
@@ -46,7 +49,7 @@ protected void onFinishInflate() {
super.onFinishInflate();
this.contactPhotoImage = findViewById(R.id.contact_photo_image);
this.addrContainer = findViewById(R.id.addr_container);
- this.addrView = findViewById(R.id.addr);
+ this.addrOrTagView = findViewById(R.id.addr_or_tag);
this.nameView = findViewById(R.id.name);
this.unreadIndicator = findViewById(R.id.unread_indicator);
@@ -57,7 +60,7 @@ public void bind(@NonNull GlideRequests glideRequests, int accountId, DcContext
this.accountId = accountId;
DcContact self = null;
String name;
- String addr = null;
+ String addrOrTag = null;
int unreadCount = 0;
boolean isMuted = dcContext.isMuted();
@@ -65,12 +68,13 @@ public void bind(@NonNull GlideRequests glideRequests, int accountId, DcContext
name = getContext().getString(R.string.add_account);
} else {
self = dcContext.getContact(DcContact.DC_CONTACT_ID_SELF);
- name = dcContext.getConfig("displayname");
+ name = dcContext.getConfig(CONFIG_DISPLAY_NAME);
if (TextUtils.isEmpty(name)) {
name = self.getAddr();
}
- if (!dcContext.isChatmail()) {
- addr = self.getAddr();
+ addrOrTag = dcContext.getConfig(CONFIG_PRIVATE_TAG);
+ if ("".equals(addrOrTag) && !dcContext.isChatmail()) {
+ addrOrTag = self.getAddr();
}
unreadCount = dcContext.getFreshMsgs().length;
}
@@ -87,15 +91,15 @@ public void bind(@NonNull GlideRequests glideRequests, int accountId, DcContext
setSelected(selected);
if (selected) {
- addrView.setTypeface(null, Typeface.BOLD);
+ addrOrTagView.setTypeface(null, Typeface.BOLD);
nameView.setTypeface(null, Typeface.BOLD);
} else {
- addrView.setTypeface(null, Typeface.NORMAL);
+ addrOrTagView.setTypeface(null, Typeface.NORMAL);
nameView.setTypeface(null, Typeface.NORMAL);
}
updateUnreadIndicator(unreadCount, isMuted);
- setText(name, addr);
+ setText(name, addrOrTag);
if (accountId != DcContact.DC_CONTACT_ID_ADD_ACCOUNT) {
fragment.registerForContextMenu(this);
@@ -125,11 +129,11 @@ private void updateUnreadIndicator(int unreadCount, boolean isMuted) {
}
}
- private void setText(String name, String addr) {
+ private void setText(String name, String addrOrTag) {
this.nameView.setText(name==null? "#" : name);
- if(addr != null) {
- this.addrView.setText(addr);
+ if(!TextUtils.isEmpty(addrOrTag)) {
+ this.addrOrTagView.setText(addrOrTag);
this.addrContainer.setVisibility(View.VISIBLE);
} else {
this.addrContainer.setVisibility(View.GONE);
diff --git a/src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java b/src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java
index a2b03f8ec..fd82ab58f 100644
--- a/src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java
+++ b/src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java
@@ -76,6 +76,7 @@ public class DcHelper {
public static final String CONFIG_PROXY_URL = "proxy_url";
public static final String CONFIG_VERIFIED_ONE_ON_ONE_CHATS = "verified_one_on_one_chats";
public static final String CONFIG_WEBXDC_REALTIME_ENABLED = "webxdc_realtime_enabled";
+ public static final String CONFIG_PRIVATE_TAG = "private_tag";
public static DcContext getContext(@NonNull Context context) {
return ApplicationContext.getInstance(context).dcContext;
diff --git a/src/main/res/layout/account_selection_list_item.xml b/src/main/res/layout/account_selection_list_item.xml
index c7bacf3b9..5adf88727 100644
--- a/src/main/res/layout/account_selection_list_item.xml
+++ b/src/main/res/layout/account_selection_list_item.xml
@@ -60,16 +60,16 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content">
-
+
diff --git a/src/main/res/menu/account_item_context.xml b/src/main/res/menu/account_item_context.xml
index ad85db760..32a27fae3 100644
--- a/src/main/res/menu/account_item_context.xml
+++ b/src/main/res/menu/account_item_context.xml
@@ -5,6 +5,9 @@
+
+
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index ae665f88e..40f3d5137 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -654,6 +654,9 @@
Accept invalid certificates
Switch Profile
Add Profile
+ Private Tag
+ eg. Work, Family
+ Tag that is visible only for you; helping you to differ between your profiles.
Delete Profile
Are you sure you want to delete your profile data?
All profile data of \"%s\" on this device will be deleted, including your end-to-end encryption setup, contacts, chats, messages and media. This action cannot be undone.