From 45bc2236597f6ca9c9434c2af35c857747773c90 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne <31027858+Isira-Seneviratne@users.noreply.github.com> Date: Fri, 9 Sep 2022 11:07:19 +0530 Subject: Remove unnecessary uses of DrawableCompat. (#1045) --- .../infinityforreddit/activities/BaseActivity.java | 10 +++------- .../adapters/CommentsRecyclerViewAdapter.java | 6 +++--- .../adapters/HistoryPostRecyclerViewAdapter.java | 6 +++--- .../adapters/PostDetailRecyclerViewAdapter.java | 6 +++--- .../adapters/PostRecyclerViewAdapter.java | 6 +++--- .../infinityforreddit/customviews/NavigationWrapper.java | 11 ++++------- .../fragments/ThemePreviewPostsFragment.java | 8 ++++---- .../fragments/ViewPostDetailFragment.java | 16 +++++++--------- .../infinityforreddit/settings/CrashReportsFragment.java | 11 ++++------- .../docilealligator/infinityforreddit/utils/Utils.java | 12 ++++-------- 10 files changed, 38 insertions(+), 54 deletions(-) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java index a839bc1e..5b5e74e0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java @@ -12,7 +12,6 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Color; import android.graphics.Typeface; -import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Bundle; import android.view.Menu; @@ -27,7 +26,7 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatDelegate; import androidx.appcompat.view.menu.MenuItemImpl; import androidx.appcompat.widget.Toolbar; -import androidx.core.graphics.drawable.DrawableCompat; +import androidx.core.view.MenuItemCompat; import androidx.recyclerview.widget.RecyclerView; import androidx.viewpager2.widget.ViewPager2; @@ -341,11 +340,8 @@ public abstract class BaseActivity extends AppCompatActivity implements CustomFo for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); if (((MenuItemImpl) item).requestsActionButton()) { - Drawable drawable = item.getIcon(); - if (drawable != null) { - DrawableCompat.setTint(drawable, customThemeWrapper.getToolbarPrimaryTextAndIconColor()); - item.setIcon(drawable); - } + MenuItemCompat.setIconTintList(item, ColorStateList + .valueOf(customThemeWrapper.getToolbarPrimaryTextAndIconColor())); } Utils.setTitleWithCustomFontToMenuItem(typeface, item, null); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java index 2182db71..2c5deded 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java @@ -23,9 +23,9 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.content.res.AppCompatResources; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintSet; -import androidx.core.graphics.drawable.DrawableCompat; import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.RecyclerView; @@ -305,9 +305,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter