Fix blog post padding on Android 4

This commit is contained in:
Torsten Grote
2021-08-17 09:43:04 +02:00
parent 8e91322869
commit 2fe052d77e
2 changed files with 12 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ import androidx.annotation.UiThread;
import androidx.core.view.ViewCompat; import androidx.core.view.ViewCompat;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import static android.os.Build.VERSION.SDK_INT;
import static android.view.View.GONE; import static android.view.View.GONE;
import static android.view.View.VISIBLE; import static android.view.View.VISIBLE;
import static org.briarproject.briar.android.activity.BriarActivity.GROUP_ID; import static org.briarproject.briar.android.activity.BriarActivity.GROUP_ID;
@@ -44,6 +45,7 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
private final TextView text; private final TextView text;
private final ViewGroup commentContainer; private final ViewGroup commentContainer;
private final boolean fullText, authorClickable; private final boolean fullText, authorClickable;
private final int padding;
private final OnBlogPostClickListener listener; private final OnBlogPostClickListener listener;
@@ -61,6 +63,8 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
reblogButton = v.findViewById(R.id.commentView); reblogButton = v.findViewById(R.id.commentView);
text = v.findViewById(R.id.textView); text = v.findViewById(R.id.textView);
commentContainer = v.findViewById(R.id.commentContainer); commentContainer = v.findViewById(R.id.commentContainer);
padding = ctx.getResources()
.getDimensionPixelSize(R.dimen.listitem_vertical_margin);
} }
void hideReblogButton() { void hideReblogButton() {
@@ -129,6 +133,12 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
} else { } else {
reblogger.setVisibility(GONE); reblogger.setVisibility(GONE);
} }
// Apply Android 4 padding fix after setting up author/reblogger views
if (SDK_INT < 21) {
reblogger.setPadding(padding, padding, padding, padding);
author.setPadding(padding, padding, padding, padding);
}
} }
private void onBindComment(BlogCommentItem item, boolean authorClickable) { private void onBindComment(BlogCommentItem item, boolean authorClickable) {

View File

@@ -27,7 +27,9 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="@dimen/listitem_vertical_margin" android:paddingStart="@dimen/listitem_vertical_margin"
android:paddingLeft="@dimen/listitem_vertical_margin"
android:paddingEnd="@dimen/listitem_vertical_margin" android:paddingEnd="@dimen/listitem_vertical_margin"
android:paddingRight="@dimen/listitem_vertical_margin"
android:paddingBottom="@dimen/listitem_vertical_margin" android:paddingBottom="@dimen/listitem_vertical_margin"
android:textColor="?android:attr/textColorSecondary" android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/text_size_small" android:textSize="@dimen/text_size_small"