mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge pull request #3269 from deltachat/adb/issue-3199
tweak account selection style
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package org.thoughtcrime.securesms.accounts;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -12,7 +10,6 @@ import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.b44t.messenger.DcAccounts;
|
||||
import com.b44t.messenger.DcContact;
|
||||
import com.b44t.messenger.DcContext;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
@@ -41,7 +38,7 @@ public class AccountSelectionListAdapter extends RecyclerView.Adapter
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
public abstract void bind(@NonNull GlideRequests glideRequests, int accountId, DcContact self, String name, String addr, int unreadCount, boolean selected, boolean isMuted, AccountSelectionListFragment fragment);
|
||||
public abstract void bind(@NonNull GlideRequests glideRequests, int accountId, DcContext dcContext, boolean selected, AccountSelectionListFragment fragment);
|
||||
public abstract void unbind(@NonNull GlideRequests glideRequests);
|
||||
}
|
||||
|
||||
@@ -61,8 +58,8 @@ public class AccountSelectionListAdapter extends RecyclerView.Adapter
|
||||
return (AccountSelectionListItem) itemView;
|
||||
}
|
||||
|
||||
public void bind(@NonNull GlideRequests glideRequests, int accountId, DcContact self, String name, String addr, int unreadCount, boolean selected, boolean isMuted, AccountSelectionListFragment fragment) {
|
||||
getView().bind(glideRequests, accountId, self, name, addr, unreadCount, selected, isMuted, fragment);
|
||||
public void bind(@NonNull GlideRequests glideRequests, int accountId, DcContext dcContext, boolean selected, AccountSelectionListFragment fragment) {
|
||||
getView().bind(glideRequests, accountId, dcContext, selected, fragment);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,31 +89,12 @@ public class AccountSelectionListAdapter extends RecyclerView.Adapter
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
|
||||
|
||||
int id = accountList[i];
|
||||
DcContact dcContact = null;
|
||||
String name;
|
||||
String addr = null;
|
||||
int unreadCount = 0;
|
||||
DcContext dcContext = accounts.getAccount(id);
|
||||
|
||||
if (id == DcContact.DC_CONTACT_ID_ADD_ACCOUNT) {
|
||||
name = context.getString(R.string.add_account);
|
||||
} else {
|
||||
dcContact = dcContext.getContact(DcContact.DC_CONTACT_ID_SELF);
|
||||
name = dcContext.getConfig("displayname");
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
name = dcContact.getAddr();
|
||||
}
|
||||
if (!dcContext.isChatmail()) {
|
||||
addr = dcContact.getAddr();
|
||||
}
|
||||
unreadCount = dcContext.getFreshMsgs().length;
|
||||
}
|
||||
|
||||
ViewHolder holder = (ViewHolder) viewHolder;
|
||||
holder.unbind(glideRequests);
|
||||
holder.bind(glideRequests, id, dcContact, name, addr, unreadCount, id == selectedAccountId, dcContext.isMuted(), fragment);
|
||||
holder.bind(glideRequests, id, dcContext, id == selectedAccountId, fragment);
|
||||
}
|
||||
|
||||
public interface ItemClickListener {
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.accounts;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
@@ -13,6 +14,7 @@ import androidx.annotation.NonNull;
|
||||
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.b44t.messenger.DcContact;
|
||||
import com.b44t.messenger.DcContext;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.components.AvatarImageView;
|
||||
@@ -28,7 +30,6 @@ public class AccountSelectionListItem extends LinearLayout {
|
||||
private TextView addrView;
|
||||
private TextView nameView;
|
||||
private ImageView unreadIndicator;
|
||||
private ImageView checkbox;
|
||||
|
||||
private int accountId;
|
||||
|
||||
@@ -48,13 +49,31 @@ public class AccountSelectionListItem extends LinearLayout {
|
||||
this.addrView = findViewById(R.id.addr);
|
||||
this.nameView = findViewById(R.id.name);
|
||||
this.unreadIndicator = findViewById(R.id.unread_indicator);
|
||||
this.checkbox = findViewById(R.id.checkbox);
|
||||
|
||||
ViewUtil.setTextViewGravityStart(this.nameView, getContext());
|
||||
}
|
||||
|
||||
public void bind(@NonNull GlideRequests glideRequests, int accountId, DcContact self, String name, String addr, int unreadCount, boolean selected, boolean isMuted, AccountSelectionListFragment fragment) {
|
||||
public void bind(@NonNull GlideRequests glideRequests, int accountId, DcContext dcContext, boolean selected, AccountSelectionListFragment fragment) {
|
||||
this.accountId = accountId;
|
||||
DcContact self = null;
|
||||
String name;
|
||||
String addr = null;
|
||||
int unreadCount = 0;
|
||||
boolean isMuted = dcContext.isMuted();
|
||||
|
||||
if (accountId == DcContact.DC_CONTACT_ID_ADD_ACCOUNT) {
|
||||
name = getContext().getString(R.string.add_account);
|
||||
} else {
|
||||
self = dcContext.getContact(DcContact.DC_CONTACT_ID_SELF);
|
||||
name = dcContext.getConfig("displayname");
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
name = self.getAddr();
|
||||
}
|
||||
if (!dcContext.isChatmail()) {
|
||||
addr = self.getAddr();
|
||||
}
|
||||
unreadCount = dcContext.getFreshMsgs().length;
|
||||
}
|
||||
|
||||
Recipient recipient;
|
||||
if (accountId != DcContact.DC_CONTACT_ID_ADD_ACCOUNT) {
|
||||
@@ -66,14 +85,13 @@ public class AccountSelectionListItem extends LinearLayout {
|
||||
|
||||
nameView.setCompoundDrawablesWithIntrinsicBounds(isMuted? R.drawable.ic_volume_off_grey600_18dp : 0, 0, 0, 0);
|
||||
|
||||
setSelected(selected);
|
||||
if (selected) {
|
||||
addrView.setTypeface(null, Typeface.BOLD);
|
||||
nameView.setTypeface(null, Typeface.BOLD);
|
||||
checkbox.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
addrView.setTypeface(null, Typeface.NORMAL);
|
||||
nameView.setTypeface(null, accountId == DcContact.DC_CONTACT_ID_ADD_ACCOUNT? Typeface.BOLD : Typeface.NORMAL);
|
||||
checkbox.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
updateUnreadIndicator(unreadCount, isMuted);
|
||||
|
||||
@@ -30,17 +30,6 @@
|
||||
tools:src="@color/blue_600"
|
||||
android:contentDescription="@null" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/checkbox"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginStart="22dp"
|
||||
android:layout_marginTop="22dp"
|
||||
app:layout_constraintStart_toStartOf="@id/contact_photo_image"
|
||||
app:layout_constraintTop_toTopOf="@id/contact_photo_image"
|
||||
android:src="@drawable/ic_circle_checkbox"
|
||||
android:contentDescription="@null" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<LinearLayout android:layout_width="0dp"
|
||||
|
||||
Reference in New Issue
Block a user