From 36a31a96dc09ac5ab4c987309658e3a7d228f29d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=C3=A1n=20Mac=20Gillicuddy?= Date: Sat, 25 Apr 2020 21:21:19 +0100 Subject: [PATCH] #3451 Delete CompatTextView - remove all references to CompatTextView (#3709) --- .../commons/media/MediaDetailFragment.java | 5 +- .../nrw/commons/ui/widget/CompatTextView.java | 101 ------------------ .../main/res/layout/detail_category_item.xml | 14 ++- .../main/res/layout/fragment_media_detail.xml | 12 +-- app/src/main/res/values/attrs.xml | 13 +-- 5 files changed, 16 insertions(+), 129 deletions(-) delete mode 100644 app/src/main/java/fr/free/nrw/commons/ui/widget/CompatTextView.java diff --git a/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.java b/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.java index a5ba47354..a3e22f3b7 100644 --- a/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.java +++ b/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.java @@ -48,7 +48,6 @@ import fr.free.nrw.commons.delete.DeleteHelper; import fr.free.nrw.commons.delete.ReasonBuilder; import fr.free.nrw.commons.depictions.WikidataItemDetailsActivity; import fr.free.nrw.commons.di.CommonsDaggerSupportFragment; -import fr.free.nrw.commons.ui.widget.CompatTextView; import fr.free.nrw.commons.ui.widget.HtmlTextView; import fr.free.nrw.commons.upload.structure.depictions.DepictedItem; import fr.free.nrw.commons.utils.ViewUtilWrapper; @@ -596,7 +595,7 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment { */ private View buildDepictLabel(String depictionName, String entityId, LinearLayout depictionContainer) { final View item = LayoutInflater.from(getContext()).inflate(R.layout.detail_category_item, depictionContainer, false); - final CompatTextView textView = item.findViewById(R.id.mediaDetailCategoryItemText); + final TextView textView = item.findViewById(R.id.mediaDetailCategoryItemText); textView.setText(depictionName); if (depictionLoaded) { @@ -613,7 +612,7 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment { private View buildCatLabel(final String catName, ViewGroup categoryContainer) { final View item = LayoutInflater.from(getContext()).inflate(R.layout.detail_category_item, categoryContainer, false); - final CompatTextView textView = item.findViewById(R.id.mediaDetailCategoryItemText); + final TextView textView = item.findViewById(R.id.mediaDetailCategoryItemText); textView.setText(catName); if (categoriesLoaded && categoriesPresent) { diff --git a/app/src/main/java/fr/free/nrw/commons/ui/widget/CompatTextView.java b/app/src/main/java/fr/free/nrw/commons/ui/widget/CompatTextView.java deleted file mode 100644 index 32cf888a1..000000000 --- a/app/src/main/java/fr/free/nrw/commons/ui/widget/CompatTextView.java +++ /dev/null @@ -1,101 +0,0 @@ -package fr.free.nrw.commons.ui.widget; - -/* - *Created by mikel on 07/08/2017. - */ - -import android.content.Context; -import android.content.res.TypedArray; -import android.graphics.drawable.Drawable; -import android.util.AttributeSet; - -import androidx.annotation.Nullable; -import androidx.appcompat.widget.AppCompatDrawableManager; -import androidx.appcompat.widget.AppCompatTextView; -import androidx.core.view.ViewCompat; - -import fr.free.nrw.commons.R; -import fr.free.nrw.commons.utils.UiUtils; - -/** - * a text view compatible with older versions of the platform - */ -public class CompatTextView extends AppCompatTextView { - - /** - * Constructs a new instance of CompatTextView - * - * @param context the view context - */ - public CompatTextView(Context context) { - super(context); - init(null); - } - - /** - * Constructs a new instance of CompatTextView - * - * @param context the view context - * @param attrs the set of attributes for the view - */ - public CompatTextView(Context context, AttributeSet attrs) { - super(context, attrs); - init(attrs); - } - - /** - * Constructs a new instance of CompatTextView - * - * @param context - * @param attrs - * @param defStyleAttr - */ - public CompatTextView(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - init(attrs); - } - - /** - * initializes the view - * - * @param attrs the attribute set of the view, which can be null - */ - private void init(@Nullable AttributeSet attrs) { - if (attrs != null) { - Context context = getContext(); - TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CompatTextView); - - // Obtain DrawableManager used to pull Drawables safely, and check if we're in RTL - AppCompatDrawableManager dm = AppCompatDrawableManager.get(); - boolean rtl = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL; - - // Grab the compat drawable padding from the XML - float drawablePadding = a.getDimension(R.styleable.CompatTextView_drawablePadding, 0); - - // Grab the compat drawable resources from the XML - int startDrawableRes = a.getResourceId(R.styleable.CompatTextView_drawableStart, 0); - int topDrawableRes = a.getResourceId(R.styleable.CompatTextView_drawableTop, 0); - int endDrawableRes = a.getResourceId(R.styleable.CompatTextView_drawableEnd, 0); - int bottomDrawableRes = a.getResourceId(R.styleable.CompatTextView_drawableBottom, 0); - - // Load the used drawables, fall back to whatever was set in an "android:" - Drawable[] currentDrawables = getCompoundDrawables(); - Drawable left = startDrawableRes != 0 - ? dm.getDrawable(context, startDrawableRes) : currentDrawables[0]; - Drawable right = endDrawableRes != 0 - ? dm.getDrawable(context, endDrawableRes) : currentDrawables[1]; - Drawable top = topDrawableRes != 0 - ? dm.getDrawable(context, topDrawableRes) : currentDrawables[2]; - Drawable bottom = bottomDrawableRes != 0 - ? dm.getDrawable(context, bottomDrawableRes) : currentDrawables[3]; - - // Account for RTL and apply the compound Drawables - Drawable start = rtl ? right : left; - Drawable end = rtl ? left : right; - setCompoundDrawablesWithIntrinsicBounds(start, top, end, bottom); - setCompoundDrawablePadding((int) UiUtils.convertDpToPixel(drawablePadding, getContext())); - - a.recycle(); - } - } -} diff --git a/app/src/main/res/layout/detail_category_item.xml b/app/src/main/res/layout/detail_category_item.xml index 181fdb1e0..95b6684f5 100644 --- a/app/src/main/res/layout/detail_category_item.xml +++ b/app/src/main/res/layout/detail_category_item.xml @@ -1,12 +1,10 @@ + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="wrap_content"> - diff --git a/app/src/main/res/layout/fragment_media_detail.xml b/app/src/main/res/layout/fragment_media_detail.xml index 8337f1b94..40264af8d 100644 --- a/app/src/main/res/layout/fragment_media_detail.xml +++ b/app/src/main/res/layout/fragment_media_detail.xml @@ -171,7 +171,7 @@ android:layout_height="match_parent" android:text="@string/media_detail_license" /> - @@ -199,7 +199,7 @@ android:layout_height="match_parent" android:text="@string/media_detail_coordinates" /> - diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 06d9ad6e2..b92408ebf 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -34,19 +34,10 @@ - - - - - - - - - - + - \ No newline at end of file +