mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
add status field to profile
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<org.thoughtcrime.securesms.ProfileStatusItem
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/conversation_list_item_background"
|
||||
android:focusable="true"
|
||||
android:padding="16dp">
|
||||
|
||||
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
|
||||
android:id="@+id/status_text"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="start|center_vertical"
|
||||
style="@style/Signal.Text.Body"
|
||||
android:textColor="?attr/emoji_text_color"/>
|
||||
|
||||
</org.thoughtcrime.securesms.ProfileStatusItem>
|
||||
@@ -41,6 +41,7 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
||||
private int itemDataMemberCount;
|
||||
private DcChatlist itemDataSharedChats;
|
||||
private DcContact itemDataContact;
|
||||
private String itemDataStatusText;
|
||||
private boolean isMailingList;
|
||||
private final Set<Integer> selectedMembers;
|
||||
|
||||
@@ -50,8 +51,9 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
||||
|
||||
static class ItemData {
|
||||
static final int TYPE_PRIMARY_SETTING = 1;
|
||||
static final int TYPE_MEMBER = 2;
|
||||
static final int TYPE_SHARED_CHAT = 3;
|
||||
static final int TYPE_STATUS = 2;
|
||||
static final int TYPE_MEMBER = 3;
|
||||
static final int TYPE_SHARED_CHAT = 4;
|
||||
int type;
|
||||
int contactId;
|
||||
int chatlistIndex;
|
||||
@@ -121,6 +123,10 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
||||
item.hideItemDivider();
|
||||
return new ViewHolder(item);
|
||||
}
|
||||
else if (viewType == ItemData.TYPE_STATUS) {
|
||||
final ProfileStatusItem item = (ProfileStatusItem)layoutInflater.inflate(R.layout.profile_status_item, parent, false);
|
||||
return new ViewHolder(item);
|
||||
}
|
||||
else {
|
||||
final ProfileSettingsItem item = (ProfileSettingsItem)layoutInflater.inflate(R.layout.profile_settings_item, parent, false);
|
||||
return new ViewHolder(item);
|
||||
@@ -170,6 +176,11 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
||||
locale, Collections.emptySet(), false);
|
||||
conversationListItem.setOnClickListener(view -> clickListener.onSharedChatClicked(chatId));
|
||||
}
|
||||
else if(holder.itemView instanceof ProfileStatusItem) {
|
||||
ProfileStatusItem item = (ProfileStatusItem) holder.itemView;
|
||||
item.setOnLongClickListener(view -> {clickListener.onStatusLongClicked(); return true;});
|
||||
item.set(itemData.get(i).label);
|
||||
}
|
||||
else if(holder.itemView instanceof ProfileSettingsItem) {
|
||||
int settingsId = itemData.get(i).settingsId;
|
||||
ProfileSettingsItem profileSettingsItem = (ProfileSettingsItem) holder.itemView;
|
||||
@@ -185,6 +196,7 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
||||
|
||||
public interface ItemClickListener {
|
||||
void onSettingsClicked(int settingsId);
|
||||
void onStatusLongClicked();
|
||||
void onSharedChatClicked(int chatId);
|
||||
void onMemberClicked(int contactId);
|
||||
void onMemberLongClicked(int contactId);
|
||||
@@ -222,6 +234,9 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
||||
txt = context.getString(R.string.contact);
|
||||
}
|
||||
break;
|
||||
case ItemData.TYPE_STATUS:
|
||||
txt = context.getString(R.string.pref_default_status_label);
|
||||
break;
|
||||
default:
|
||||
txt = context.getString(R.string.menu_settings);
|
||||
break;
|
||||
@@ -245,6 +260,11 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
||||
return selectedMembers.size();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getStatusText() {
|
||||
return itemDataStatusText;
|
||||
}
|
||||
|
||||
public void clearSelection() {
|
||||
selectedMembers.clear();
|
||||
notifyDataSetChanged();
|
||||
@@ -255,6 +275,7 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
||||
itemDataMemberCount = 0;
|
||||
itemDataSharedChats = null;
|
||||
itemDataContact = null;
|
||||
itemDataStatusText = "";
|
||||
isMailingList = false;
|
||||
|
||||
if (memberList!=null) {
|
||||
@@ -272,6 +293,11 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
||||
else if (sharedChats!=null && dcContact!=null) {
|
||||
itemDataContact = dcContact;
|
||||
itemData.add(new ItemData(ItemData.TYPE_PRIMARY_SETTING, SETTING_NEW_CHAT, context.getString(R.string.send_message)));
|
||||
|
||||
itemDataStatusText = dcContact.getStatus();
|
||||
if (!itemDataStatusText.isEmpty()) {
|
||||
itemData.add(new ItemData(ItemData.TYPE_STATUS, 0, itemDataStatusText));
|
||||
}
|
||||
itemDataSharedChats = sharedChats;
|
||||
int sharedChatsCnt = sharedChats.getCnt();
|
||||
for (int i = 0; i < sharedChatsCnt; i++) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
@@ -144,6 +145,22 @@ public class ProfileSettingsFragment extends Fragment
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusLongClicked() {
|
||||
Context context = getContext();
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle(R.string.pref_default_status_label)
|
||||
.setItems(new CharSequence[]{
|
||||
context.getString(R.string.menu_copy_to_clipboard)
|
||||
},
|
||||
(dialogInterface, i) -> {
|
||||
Util.writeTextToClipboard(context, adapter.getStatusText());
|
||||
Toast.makeText(context, context.getString(R.string.copied_to_clipboard), Toast.LENGTH_SHORT).show();
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMemberLongClicked(int contactId) {
|
||||
if (contactId>DcContact.DC_CONTACT_ID_LAST_SPECIAL || contactId==DcContact.DC_CONTACT_ID_SELF) {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiTextView;
|
||||
|
||||
public class ProfileStatusItem extends LinearLayout {
|
||||
|
||||
private EmojiTextView statusTextView;
|
||||
|
||||
public ProfileStatusItem(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public ProfileStatusItem(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
statusTextView = findViewById(R.id.status_text);
|
||||
}
|
||||
|
||||
public void set(String status) {
|
||||
statusTextView.setText(status==null? "" : status);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user