Make avatar in top bar open details on click

This commit is contained in:
Arne 2023-10-22 07:08:32 +02:00
parent e5af40ed34
commit f763481533
3 changed files with 24 additions and 13 deletions

View file

@ -81,6 +81,7 @@ import androidx.databinding.DataBindingUtil;
import org.openintents.openpgp.util.OpenPgpApi;
import eu.siacs.conversations.services.AvatarService;
import eu.siacs.conversations.ui.util.AvatarWorkerTask;
import eu.siacs.conversations.utils.Compatibility;
import io.michaelrocks.libphonenumber.android.NumberParseException;
@ -1077,6 +1078,8 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
actionBar.setDisplayShowCustomEnabled(true);
TextView abtitle = findViewById(android.R.id.text1);
TextView absubtitle = findViewById(android.R.id.text2);
final View avatartoolbarround = view.findViewById(R.id.toolbar_avatar);
final View avatartoolbarsquare = view.findViewById(R.id.toolbar_avatar_square);
abtitle.setText(conversation.getName());
abtitle.setSelected(true);
if (conversation.getMode() == Conversation.MODE_SINGLE) {
@ -1140,10 +1143,10 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
absubtitle.setSelected(true);
}
if (xmppConnectionService.getBooleanPreference("set_round_avatars", R.bool.set_round_avatars)) {
AvatarWorkerTask.loadAvatar(conversation, findViewById(R.id.toolbar_avatar), R.dimen.muc_avatar_actionbar);
AvatarWorkerTask.loadAvatar(conversation, (ImageView) avatartoolbarround, R.dimen.muc_avatar_actionbar);
findViewById(R.id.toolbar_avatar).setVisibility(View.VISIBLE);
} else if (!xmppConnectionService.getBooleanPreference("set_round_avatars", R.bool.set_round_avatars)) {
AvatarWorkerTask.loadAvatar(conversation, findViewById(R.id.toolbar_avatar_square), R.dimen.muc_avatar_actionbar);
AvatarWorkerTask.loadAvatar(conversation, (ImageView) avatartoolbarsquare, R.dimen.muc_avatar_actionbar);
findViewById(R.id.toolbar_avatar_square).setVisibility(View.VISIBLE);
}
ActionBarUtil.setCustomActionBarOnClickListener(

View file

@ -8,6 +8,8 @@ import androidx.annotation.Nullable;
import java.lang.reflect.Field;
import eu.siacs.conversations.R;
public class ActionBarUtil {
public static void resetActionBarOnClickListeners(@NonNull View view) {
@ -48,12 +50,16 @@ public class ActionBarUtil {
@NonNull final View.OnClickListener onClickListener) {
final View title = view.findViewById(android.R.id.text1);
final View subtitle = view.findViewById(android.R.id.text2);
final View view_toolbar_avatar = view.findViewById(R.id.view_toolbar_avatar);
if (title != null) {
title.setOnClickListener(onClickListener);
}
if (subtitle != null) {
subtitle.setOnClickListener(onClickListener);
}
if (view_toolbar_avatar != null) {
view_toolbar_avatar.setOnClickListener(onClickListener);
}
}
private static @Nullable

View file

@ -6,6 +6,14 @@
android:gravity="start|center_vertical"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/view_toolbar_avatar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:onClick="onClick"
android:layout_centerVertical="true">
<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/toolbar_avatar"
android:layout_width="38dp"
@ -13,9 +21,7 @@
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:padding="1dp"
android:clickable="true"
android:scaleType="centerCrop"
android:layout_centerVertical="true"
app:riv_corner_radius="30dp"
android:visibility="gone"/>
@ -26,22 +32,18 @@
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:padding="1dp"
android:clickable="true"
android:layout_toRightOf="@+id/toolbar_avatar"
android:layout_toEndOf="@+id/toolbar_avatar"
android:scaleType="centerCrop"
android:layout_centerVertical="true"
app:riv_corner_radius="5dp"
android:visibility="gone"/>
</RelativeLayout>
<TextView
android:id="@android:id/text1"
style="@style/TextAppearance.Material3.ActionBar.Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:layout_toRightOf="@+id/toolbar_avatar_square"
android:layout_toEndOf="@+id/toolbar_avatar_square"
android:layout_toRightOf="@+id/view_toolbar_avatar"
android:layout_toEndOf="@+id/view_toolbar_avatar"
android:ellipsize="end"
android:gravity="start|center_vertical"
android:onClick="onClick"
@ -55,8 +57,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@android:id/text1"
android:layout_toRightOf="@+id/toolbar_avatar_square"
android:layout_toEndOf="@+id/toolbar_avatar_square"
android:layout_toRightOf="@+id/view_toolbar_avatar"
android:layout_toEndOf="@+id/view_toolbar_avatar"
android:clickable="true"
android:ellipsize="end"
android:gravity="start|center_vertical"