Fix button sizes for messages

This commit is contained in:
Thomas 2022-10-20 12:18:53 +02:00
parent 9ad5177486
commit 4b3236e97e
7 changed files with 57 additions and 16 deletions

View file

@ -32,7 +32,7 @@ public class CustomEmoji extends ReplacementSpan {
Context mContext = viewWeakReference.get().getContext(); Context mContext = viewWeakReference.get().getContext();
this.viewWeakReference = viewWeakReference; this.viewWeakReference = viewWeakReference;
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(mContext); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
scale = sharedpreferences.getFloat(mContext.getString(R.string.SET_FONT_SCALE), 1.0f); scale = sharedpreferences.getFloat(mContext.getString(R.string.SET_FONT_SCALE), 1.1f);
} }
@Override @Override

View file

@ -1188,7 +1188,7 @@ public class Helper {
public static MultipartBody.Part getMultipartBodyWithWM(Context context, String waterMark, @NonNull String paramName, @NonNull Attachment attachment) { public static MultipartBody.Part getMultipartBodyWithWM(Context context, String waterMark, @NonNull String paramName, @NonNull Attachment attachment) {
File files = new File(attachment.local_path); File files = new File(attachment.local_path);
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
float scale = sharedpreferences.getFloat(context.getString(R.string.SET_FONT_SCALE), 1.0f); float scale = sharedpreferences.getFloat(context.getString(R.string.SET_FONT_SCALE), 1.1f);
float textSize = 15; float textSize = 15;
Paint mPaint = new Paint(); Paint mPaint = new Paint();
mPaint.setTextSize(textSize); mPaint.setTextSize(textSize);

View file

@ -226,6 +226,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
} else if (getItemViewType(position) == TYPE_POLL) { } else if (getItemViewType(position) == TYPE_POLL) {
holderStatus.bindingNotification.status.typeOfNotification.setImageResource(R.drawable.ic_baseline_poll_24); holderStatus.bindingNotification.status.typeOfNotification.setImageResource(R.drawable.ic_baseline_poll_24);
} }
StatusesVM statusesVM = new ViewModelProvider((ViewModelStoreOwner) context).get(StatusesVM.class); StatusesVM statusesVM = new ViewModelProvider((ViewModelStoreOwner) context).get(StatusesVM.class);
SearchVM searchVM = new ViewModelProvider((ViewModelStoreOwner) context).get(SearchVM.class); SearchVM searchVM = new ViewModelProvider((ViewModelStoreOwner) context).get(SearchVM.class);
if (notification.status != null) { if (notification.status != null) {
@ -272,6 +273,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
} }
} else { } else {
holderStatus.bindingNotification.containerTransparent.setVisibility(View.VISIBLE); holderStatus.bindingNotification.containerTransparent.setVisibility(View.VISIBLE);
holderStatus.bindingNotification.status.mediaContainer.setVisibility(View.GONE);
String title = ""; String title = "";
MastodonHelper.loadPPMastodon(holderStatus.binding.avatar, notification.account); MastodonHelper.loadPPMastodon(holderStatus.binding.avatar, notification.account);
if (getItemViewType(position) == TYPE_FAVOURITE) { if (getItemViewType(position) == TYPE_FAVOURITE) {

View file

@ -915,17 +915,34 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
if (theme_text_header_2_line != -1) { if (theme_text_header_2_line != -1) {
holder.binding.username.setTextColor(theme_text_header_2_line); holder.binding.username.setTextColor(theme_text_header_2_line);
} }
//final float scale = context.getResources().getDisplayMetrics().density;
final float scale = sharedpreferences.getFloat(context.getString(R.string.SET_FONT_SCALE), 1.1f);
if (statusToDeal.account.locked) { if (statusToDeal.account.locked) {
final float scale = context.getResources().getDisplayMetrics().density;
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_baseline_lock_24); Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_baseline_lock_24);
assert img != null; assert img != null;
img.setBounds(0, 0, (int) (16 * scale + 0.5f), (int) (16 * scale + 0.5f)); img.setBounds(0, 0, (int) (Helper.convertDpToPixel(16, context) * scale + 0.5f), (int) (Helper.convertDpToPixel(16, context) * scale + 0.5f));
holder.binding.username.setCompoundDrawables(null, null, img, null); holder.binding.username.setCompoundDrawables(null, null, img, null);
} else { } else {
holder.binding.username.setCompoundDrawables(null, null, null, null); holder.binding.username.setCompoundDrawables(null, null, null, null);
} }
float normalSize = Helper.convertDpToPixel(28, context);
holder.binding.actionButtonReply.getLayoutParams().width = (int) (normalSize * scale);
holder.binding.actionButtonReply.getLayoutParams().height = (int) (normalSize * scale);
holder.binding.actionButtonReply.requestLayout();
holder.binding.actionButtonBoost.setImageSize((int) (normalSize * scale));
holder.binding.actionButtonFavorite.setImageSize((int) (normalSize * scale));
holder.binding.actionButtonBookmark.setImageSize((int) (normalSize * scale));
holder.binding.statusAddCustomEmoji.getLayoutParams().width = (int) (normalSize * scale);
holder.binding.statusAddCustomEmoji.getLayoutParams().height = (int) (normalSize * scale);
holder.binding.statusAddCustomEmoji.requestLayout();
holder.binding.statusEmoji.getLayoutParams().width = (int) (normalSize * scale);
holder.binding.statusEmoji.getLayoutParams().height = (int) (normalSize * scale);
holder.binding.actionButtonMore.getLayoutParams().width = (int) (normalSize * scale);
holder.binding.actionButtonMore.getLayoutParams().height = (int) (normalSize * scale);
holder.binding.actionButtonMore.requestLayout();
holder.binding.actionShare.getLayoutParams().width = (int) (normalSize * scale);
holder.binding.actionShare.getLayoutParams().height = (int) (normalSize * scale);
holder.binding.actionShare.requestLayout();
if (statusToDeal.account.bot) { if (statusToDeal.account.bot) {
holder.binding.botIcon.setVisibility(View.VISIBLE); holder.binding.botIcon.setVisibility(View.VISIBLE);
@ -1416,7 +1433,6 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
if (ownvotes != null && ownvotes.contains(j)) { if (ownvotes != null && ownvotes.contains(j)) {
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_baseline_check_24); Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_baseline_check_24);
assert img != null; assert img != null;
final float scale = context.getResources().getDisplayMetrics().density;
img.setColorFilter(ContextCompat.getColor(context, R.color.cyanea_accent_reference), PorterDuff.Mode.SRC_IN); img.setColorFilter(ContextCompat.getColor(context, R.color.cyanea_accent_reference), PorterDuff.Mode.SRC_IN);
img.setBounds(0, 0, (int) (20 * scale + 0.5f), (int) (20 * scale + 0.5f)); img.setBounds(0, 0, (int) (20 * scale + 0.5f), (int) (20 * scale + 0.5f));
pollItemBinding.pollItemText.setCompoundDrawables(null, null, img, null); pollItemBinding.pollItemText.setCompoundDrawables(null, null, img, null);

View file

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#FFFFFF"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M2,20h20v-4L2,16v4zM4,17h2v2L4,19v-2zM2,4v4h20L22,4L2,4zM6,7L4,7L4,5h2v2zM2,14h20v-4L2,10v4zM4,11h2v2L4,13v-2z" />
</vector>

View file

@ -41,7 +41,7 @@
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginEnd="12dp" android:layout_marginEnd="12dp"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:src="@drawable/ic_baseline_cached_24" android:src="@drawable/ic_baseline_storage_24"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible" /> tools:visibility="visible" />

View file

@ -548,14 +548,16 @@
android:clipChildren="false" android:clipChildren="false"
android:clipToPadding="false"> android:clipToPadding="false">
<androidx.appcompat.widget.AppCompatImageButton <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/action_button_reply" android:id="@+id/action_button_reply"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="28dp" android:layout_width="28dp"
android:layout_height="28dp" android:layout_height="28dp"
android:contentDescription="@string/reply" android:contentDescription="@string/reply"
android:layout_marginStart="6dp" android:layout_gravity="center"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:clickable="true"
android:focusable="true"
android:layout_marginStart="6dp"
app:srcCompat="@drawable/ic_reply" /> app:srcCompat="@drawable/ic_reply" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
@ -619,12 +621,13 @@
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/cache_indicator" android:id="@+id/cache_indicator"
android:layout_width="28dp" android:layout_width="20dp"
android:layout_height="28dp" android:layout_height="20dp"
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
android:layout_gravity="center"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:contentDescription="@string/cached_messages" android:contentDescription="@string/cached_messages"
android:src="@drawable/ic_baseline_cached_24" android:src="@drawable/ic_baseline_storage_24"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible" /> tools:visibility="visible" />
@ -640,6 +643,10 @@
android:contentDescription="@string/add_reaction" android:contentDescription="@string/add_reaction"
android:padding="3dp" android:padding="3dp"
android:src="@drawable/ic_baseline_emoji_emotions_24" android:src="@drawable/ic_baseline_emoji_emotions_24"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:clickable="true"
android:focusable="true"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible" /> tools:visibility="visible" />
@ -650,6 +657,10 @@
android:layout_marginStart="6dp" android:layout_marginStart="6dp"
android:contentDescription="@string/add_reaction" android:contentDescription="@string/add_reaction"
android:padding="3dp" android:padding="3dp"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:clickable="true"
android:focusable="true"
android:src="@drawable/ic_baseline_add_reaction_24" android:src="@drawable/ic_baseline_add_reaction_24"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible" /> tools:visibility="visible" />
@ -659,13 +670,15 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" /> android:layout_weight="1" />
<androidx.appcompat.widget.AppCompatImageButton <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/action_button_more" android:id="@+id/action_button_more"
style="@style/Widget.AppCompat.Button.Borderless"
android:contentDescription="@string/display_options" android:contentDescription="@string/display_options"
android:layout_width="28dp" android:layout_width="28dp"
android:layout_height="28dp" android:layout_height="28dp"
android:layout_gravity="center"
android:clickable="true"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:focusable="true"
app:srcCompat="@drawable/ic_more_horiz" /> app:srcCompat="@drawable/ic_more_horiz" />
</androidx.appcompat.widget.LinearLayoutCompat> </androidx.appcompat.widget.LinearLayoutCompat>