From 27120026c25c1b07fa60e2b0ad2399fb880a76fc Mon Sep 17 00:00:00 2001 From: Thomas Date: Sat, 3 Dec 2022 17:47:59 +0100 Subject: [PATCH] Some improvements --- .../app/fedilab/android/BaseMainActivity.java | 6 ++- .../android/ui/drawer/StatusAdapter.java | 37 ++++++++++++----- app/src/main/res/layout/activity_proxy.xml | 2 +- app/src/main/res/layout/drawer_status.xml | 9 ++--- .../main/res/layout/drawer_status_compose.xml | 4 +- app/src/main/res/layout/layout_media.xml | 40 +++++++++++++++++-- 6 files changed, 75 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/BaseMainActivity.java index 3546aabe0..bf1cf1f04 100644 --- a/app/src/main/java/app/fedilab/android/BaseMainActivity.java +++ b/app/src/main/java/app/fedilab/android/BaseMainActivity.java @@ -82,6 +82,7 @@ import org.jsoup.nodes.Element; import java.io.File; import java.io.IOException; +import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -645,7 +646,10 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt if (currentAccount.mastodon_account.display_name == null || currentAccount.mastodon_account.display_name.isEmpty()) { currentAccount.mastodon_account.display_name = currentAccount.mastodon_account.acct; } - headerMainBinding.accountName.setText(currentAccount.mastodon_account.display_name); + headerMainBinding.accountName.setText( + currentAccount.mastodon_account.getSpanDisplayName(BaseMainActivity.this, + new WeakReference<>(headerMainBinding.accountName)), + TextView.BufferType.SPANNABLE); float scale = sharedpreferences.getFloat(getString(R.string.SET_FONT_SCALE), 1.1f); headerMainBinding.accountName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale); headerMainBinding.accountAcc.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale); diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java index b4cbe554c..ddfaeddf2 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java @@ -57,6 +57,7 @@ import android.view.inputmethod.InputMethodManager; import android.widget.CheckBox; import android.widget.GridView; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.RadioButton; import android.widget.RelativeLayout; import android.widget.TextView; @@ -1118,12 +1119,12 @@ public class StatusAdapter extends RecyclerView.Adapter holder.binding.mediaContainer.setVisibility(View.VISIBLE); holder.binding.displayMedia.setVisibility(View.GONE); LayoutMediaBinding layoutMediaBinding = LayoutMediaBinding.inflate(LayoutInflater.from(context), holder.binding.attachmentsList, false); - RelativeLayout.LayoutParams lp; + LinearLayout.LayoutParams lp; if (fullAttachement) { - lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, MediaHelper.returnMaxHeightForPreviews(context, statusToDeal.media_attachments)); + lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); layoutMediaBinding.media.setScaleType(ImageView.ScaleType.FIT_CENTER); } else { - lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, (int) Helper.convertDpToPixel(200, context)); + lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, (int) Helper.convertDpToPixel(200, context)); layoutMediaBinding.media.setScaleType(ImageView.ScaleType.CENTER_CROP); } if (statusToDeal.sensitive) { @@ -1232,14 +1233,17 @@ public class StatusAdapter extends RecyclerView.Adapter int mediaPosition = 1; for (Attachment attachment : statusToDeal.media_attachments) { LayoutMediaBinding layoutMediaBinding = LayoutMediaBinding.inflate(LayoutInflater.from(context), holder.binding.attachmentsList, false); - RelativeLayout.LayoutParams lp; + LinearLayout.LayoutParams lp; float focusX = 0.f; float focusY = 0.f; if (statusToDeal.media_attachments.get(0).meta != null && statusToDeal.media_attachments.get(0).meta.focus != null) { focusX = statusToDeal.media_attachments.get(0).meta.focus.x; focusY = statusToDeal.media_attachments.get(0).meta.focus.y; } - + layoutMediaBinding.count.setVisibility(View.VISIBLE); + if (!fullAttachement) { + layoutMediaBinding.count.setText(String.format(Locale.getDefault(), "%d/%d", mediaPosition, statusToDeal.media_attachments.size())); + } String finalUrl; if (attachment.url == null) { finalUrl = attachment.remote_url; @@ -1253,10 +1257,10 @@ public class StatusAdapter extends RecyclerView.Adapter return true; }); if (fullAttachement) { - lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, MediaHelper.returnMaxHeightForPreviews(context, statusToDeal.media_attachments)); + lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); layoutMediaBinding.media.setScaleType(ImageView.ScaleType.FIT_CENTER); } else { - lp = new RelativeLayout.LayoutParams((int) Helper.convertDpToPixel(200, context), (int) Helper.convertDpToPixel(200, context)); + lp = new LinearLayout.LayoutParams((int) Helper.convertDpToPixel(200, context), (int) Helper.convertDpToPixel(200, context)); layoutMediaBinding.media.setScaleType(ImageView.ScaleType.CENTER_CROP); } if (attachment.type != null && (attachment.type.equalsIgnoreCase("video") || attachment.type.equalsIgnoreCase("gifv"))) { @@ -1274,7 +1278,6 @@ public class StatusAdapter extends RecyclerView.Adapter } else { layoutMediaBinding.viewDescription.setVisibility(View.GONE); } - lp.setMargins(0, 0, (int) Helper.convertDpToPixel(5, context), 0); if (!mediaObfuscated(statusToDeal) || expand_media) { layoutMediaBinding.viewHide.setImageResource(R.drawable.ic_baseline_visibility_24); RequestBuilder requestBuilder = Glide.with(layoutMediaBinding.media.getContext()) @@ -1313,11 +1316,23 @@ public class StatusAdapter extends RecyclerView.Adapter statusToDeal.sensitive = !statusToDeal.sensitive; adapter.notifyItemChanged(holder.getBindingAdapterPosition()); }); - holder.binding.attachmentsList.addView(layoutMediaBinding.getRoot()); + if (fullAttachement) { + layoutMediaBinding.getRoot().setPadding(0, 0, 0, 10); + holder.binding.mediaContainer.addView(layoutMediaBinding.getRoot()); + } else { + layoutMediaBinding.getRoot().setPadding(0, 0, 10, 0); + holder.binding.attachmentsList.addView(layoutMediaBinding.getRoot()); + } + mediaPosition++; } - holder.binding.mediaContainer.setVisibility(View.GONE); - holder.binding.attachmentsListContainer.setVisibility(View.VISIBLE); + if (!fullAttachement) { + holder.binding.mediaContainer.setVisibility(View.GONE); + holder.binding.attachmentsListContainer.setVisibility(View.VISIBLE); + } else { + holder.binding.mediaContainer.setVisibility(View.VISIBLE); + holder.binding.attachmentsListContainer.setVisibility(View.GONE); + } } } } else { diff --git a/app/src/main/res/layout/activity_proxy.xml b/app/src/main/res/layout/activity_proxy.xml index 86d65d8ae..2913859bc 100644 --- a/app/src/main/res/layout/activity_proxy.xml +++ b/app/src/main/res/layout/activity_proxy.xml @@ -4,7 +4,7 @@ android:id="@+id/container" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_margin="@dimen/fab_margin" + android:padding="@dimen/fab_margin" android:fitsSystemWindows="true" android:orientation="vertical" tools:context=".activities.ProxyActivity"> diff --git a/app/src/main/res/layout/drawer_status.xml b/app/src/main/res/layout/drawer_status.xml index e15248891..9c22561f6 100644 --- a/app/src/main/res/layout/drawer_status.xml +++ b/app/src/main/res/layout/drawer_status.xml @@ -212,18 +212,16 @@ android:layout_marginEnd="6dp" tools:text="Warning: Lorem Ipsum below" /> - + android:textAppearance="@style/TextAppearance.AppCompat.Body2" /> diff --git a/app/src/main/res/layout/layout_media.xml b/app/src/main/res/layout/layout_media.xml index 86ca4d3ba..fa259a3b7 100644 --- a/app/src/main/res/layout/layout_media.xml +++ b/app/src/main/res/layout/layout_media.xml @@ -1,11 +1,15 @@ - - - \ No newline at end of file + + + \ No newline at end of file