mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
This commit is contained in:
parent
82bf2d757f
commit
36a31a96dc
5 changed files with 16 additions and 129 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<fr.free.nrw.commons.ui.widget.CompatTextView
|
||||
<TextView
|
||||
android:id="@+id/mediaDetailCategoryItemText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -17,8 +15,8 @@
|
|||
android:padding="@dimen/small_gap"
|
||||
android:textColor="?attr/mediaDetailsText"
|
||||
android:textSize="@dimen/description_text_size"
|
||||
app:drawablePadding="@dimen/tiny_gap"
|
||||
app:drawableStart="?attr/iconInfo24"
|
||||
android:drawablePadding="@dimen/tiny_gap"
|
||||
android:drawableStart="?attr/iconInfo24"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@
|
|||
android:layout_height="match_parent"
|
||||
android:text="@string/media_detail_license" />
|
||||
|
||||
<fr.free.nrw.commons.ui.widget.CompatTextView
|
||||
<TextView
|
||||
android:id="@+id/mediaDetailLicense"
|
||||
android:layout_width="@dimen/widget_margin"
|
||||
android:layout_height="match_parent"
|
||||
|
|
@ -182,8 +182,8 @@
|
|||
android:padding="@dimen/small_gap"
|
||||
android:textColor="?attr/mediaDetailsText"
|
||||
android:textSize="@dimen/description_text_size"
|
||||
app:drawablePadding="@dimen/tiny_gap"
|
||||
app:drawableStart="?attr/iconInfo24"
|
||||
android:drawablePadding="@dimen/tiny_gap"
|
||||
android:drawableStart="?attr/iconInfo24"
|
||||
tools:text="License link" />
|
||||
</LinearLayout>
|
||||
|
||||
|
|
@ -199,7 +199,7 @@
|
|||
android:layout_height="match_parent"
|
||||
android:text="@string/media_detail_coordinates" />
|
||||
|
||||
<fr.free.nrw.commons.ui.widget.CompatTextView
|
||||
<TextView
|
||||
android:id="@+id/mediaDetailCoordinates"
|
||||
android:layout_width="@dimen/widget_margin"
|
||||
android:layout_height="match_parent"
|
||||
|
|
@ -210,8 +210,8 @@
|
|||
android:padding="@dimen/small_gap"
|
||||
android:textColor="?attr/mediaDetailsText"
|
||||
android:textSize="@dimen/description_text_size"
|
||||
app:drawablePadding="@dimen/tiny_gap"
|
||||
app:drawableStart="?attr/iconMap24"
|
||||
android:drawablePadding="@dimen/tiny_gap"
|
||||
android:drawableStart="?attr/iconMap24"
|
||||
tools:text="Coordinates link" />
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
|||
|
|
@ -35,15 +35,6 @@
|
|||
<attr name="icon" format="reference"/>
|
||||
<attr name="aboutIconsColor" format="reference"/>
|
||||
|
||||
|
||||
<declare-styleable name="CompatTextView">
|
||||
<attr name="drawablePadding" format="dimension"/>
|
||||
<attr name="drawableStart" format="reference"/>
|
||||
<attr name="drawableTop" format="reference"/>
|
||||
<attr name="drawableEnd" format="reference"/>
|
||||
<attr name="drawableBottom" format="reference"/>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="Badge">
|
||||
<attr name="boundary" format="color"/>
|
||||
<attr name="camera" format="color"/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue