refactor: Use "compat" drawables where appropriate (#72)

Use AppCompatResources.getDrawable() and app:drawableStartCompat.
Resolves existing lint issues.
This commit is contained in:
Nik Clayton 2023-09-19 17:42:20 +02:00 committed by GitHub
parent c97c3a4156
commit 0bf459d385
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 7 additions and 73 deletions

View File

@ -128,72 +128,6 @@
column="9"/>
</issue>
<issue
id="UseCompatLoadingForDrawables"
message="Use `AppCompatResources.getDrawable()`"
errorLine1=" return ctx.getDrawable(R.drawable.avatar_default)!!"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="546"
column="32"/>
</issue>
<issue
id="UseCompatTextViewDrawableXml"
message="Use `app:drawableStartCompat` instead of `android:drawableStart`"
errorLine1=" android:drawableStart=&quot;@drawable/ic_briefcase&quot;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/layout/activity_account.xml"
line="287"
column="29"/>
</issue>
<issue
id="UseCompatTextViewDrawableXml"
message="Use `app:drawableStartCompat` instead of `android:drawableStart`"
errorLine1=" android:drawableStart=&quot;@drawable/ic_plus_24dp&quot;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/layout/activity_tab_preference.xml"
line="60"
column="17"/>
</issue>
<issue
id="UseCompatTextViewDrawableXml"
message="Use `app:drawableStartCompat` instead of `android:drawableStart`"
errorLine1=" android:drawableStart=&quot;@drawable/ic_person_add_24dp&quot;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/layout/item_follow.xml"
line="17"
column="9"/>
</issue>
<issue
id="UseCompatTextViewDrawableXml"
message="Use `app:drawableStartCompat` instead of `android:drawableStart`"
errorLine1=" android:drawableStart=&quot;@drawable/ic_reblog_18dp&quot;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/layout/item_status.xml"
line="20"
column="9"/>
</issue>
<issue
id="UseCompatTextViewDrawableXml"
message="Use `app:drawableStartCompat` instead of `android:drawableStart`"
errorLine1=" android:drawableStart=&quot;@drawable/ic_poll_24dp&quot;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/layout/view_poll_preview.xml"
line="15"
column="9"/>
</issue>
<issue
id="MissingQuantity"
message="For locale &quot;bn&quot; (Bangla) the following quantity should also be defined: `one` (e.g. &quot;সসে 1টি আপেল খেল, সেটা ভাল&quot;)"

View File

@ -543,7 +543,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
override fun placeholder(ctx: Context, tag: String?): Drawable {
if (tag == DrawerImageLoader.Tags.PROFILE.name || tag == DrawerImageLoader.Tags.PROFILE_DRAWER_ITEM.name) {
return ctx.getDrawable(R.drawable.avatar_default)!!
return AppCompatResources.getDrawable(ctx, R.drawable.avatar_default)!!
}
return super.placeholder(ctx, tag)

View File

@ -284,7 +284,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:drawablePadding="6dp"
android:drawableStart="@drawable/ic_briefcase"
app:drawableStartCompat="@drawable/ic_briefcase"
android:textSize="?attr/status_text_medium"
android:textColor="?colorOnPrimaryContainer"
app:layout_constraintStart_toStartOf="parent"

View File

@ -57,7 +57,7 @@
android:layout_height="48dp"
android:layout_gravity="bottom"
android:background="?attr/colorPrimary"
android:drawableStart="@drawable/ic_plus_24dp"
app:drawableStartCompat="@drawable/ic_plus_24dp"
android:drawablePadding="12dp"
android:ellipsize="end"
android:gravity="center_vertical"

View File

@ -14,7 +14,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:drawableStart="@drawable/ic_person_add_24dp"
app:drawableStartCompat="@drawable/ic_person_add_24dp"
android:drawablePadding="10dp"
android:ellipsize="end"
android:gravity="center_vertical"

View File

@ -17,7 +17,7 @@
android:layout_marginStart="14dp"
android:layout_marginTop="@dimen/status_reblogged_bar_padding_top"
android:layout_marginEnd="14dp"
android:drawableStart="@drawable/ic_reblog_18dp"
app:drawableStartCompat="@drawable/ic_reblog_18dp"
android:drawablePadding="6dp"
android:gravity="center_vertical"
android:importantForAccessibility="no"

View File

@ -12,7 +12,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_poll_24dp"
app:drawableStartCompat="@drawable/ic_poll_24dp"
android:drawablePadding="4dp"
android:gravity="center_vertical"
android:text="@string/create_poll_title"