diff options
Diffstat (limited to 'app/src/main')
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<RecyclerVi customThemeWrapper.getCommentVerticalBarColor7(), }; - mCommentIcon = activity.getDrawable(R.drawable.ic_comment_grey_24dp); + mCommentIcon = AppCompatResources.getDrawable(activity, R.drawable.ic_comment_grey_24dp); if (mCommentIcon != null) { - DrawableCompat.setTint(mCommentIcon, mPostIconAndInfoColor); + mCommentIcon.setTint(mPostIconAndInfoColor); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java index 2f3f9923..62c3e0d1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java @@ -24,11 +24,11 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.content.res.AppCompatResources; import androidx.constraintlayout.widget.Barrier; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintSet; import androidx.core.content.ContextCompat; -import androidx.core.graphics.drawable.DrawableCompat; import androidx.paging.PagingDataAdapter; import androidx.recyclerview.widget.DiffUtil; import androidx.recyclerview.widget.ItemTouchHelper; @@ -314,9 +314,9 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy mPostIconAndInfoColor = customThemeWrapper.getPostIconAndInfoColor(); mDividerColor = customThemeWrapper.getDividerColor(); - mCommentIcon = activity.getDrawable(R.drawable.ic_comment_grey_24dp); + mCommentIcon = AppCompatResources.getDrawable(activity, R.drawable.ic_comment_grey_24dp); if (mCommentIcon != null) { - DrawableCompat.setTint(mCommentIcon, mPostIconAndInfoColor); + mCommentIcon.setTint(mPostIconAndInfoColor); } mScale = resources.getDisplayMetrics().density; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java index b2687f93..6e374626 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java @@ -27,9 +27,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; @@ -401,9 +401,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler mPostIconAndInfoColor = customThemeWrapper.getPostIconAndInfoColor(); mCommentColor = customThemeWrapper.getCommentColor(); - mCommentIcon = activity.getDrawable(R.drawable.ic_comment_grey_24dp); + mCommentIcon = AppCompatResources.getDrawable(activity, R.drawable.ic_comment_grey_24dp); if (mCommentIcon != null) { - DrawableCompat.setTint(mCommentIcon, mPostIconAndInfoColor); + mCommentIcon.setTint(mPostIconAndInfoColor); } mExoCreator = exoCreator; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java index 1a25e34e..54a9ae87 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -24,11 +24,11 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.content.res.AppCompatResources; import androidx.constraintlayout.widget.Barrier; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintSet; import androidx.core.content.ContextCompat; -import androidx.core.graphics.drawable.DrawableCompat; import androidx.paging.PagingDataAdapter; import androidx.recyclerview.widget.DiffUtil; import androidx.recyclerview.widget.ItemTouchHelper; @@ -335,9 +335,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie mPostIconAndInfoColor = customThemeWrapper.getPostIconAndInfoColor(); mDividerColor = customThemeWrapper.getDividerColor(); - mCommentIcon = activity.getDrawable(R.drawable.ic_comment_grey_24dp); + mCommentIcon = AppCompatResources.getDrawable(activity, R.drawable.ic_comment_grey_24dp); if (mCommentIcon != null) { - DrawableCompat.setTint(mCommentIcon, mPostIconAndInfoColor); + mCommentIcon.setTint(mPostIconAndInfoColor); } mScale = resources.getDisplayMetrics().density; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/NavigationWrapper.java b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/NavigationWrapper.java index 466cab02..1d702c19 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/NavigationWrapper.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/NavigationWrapper.java @@ -1,7 +1,7 @@ package ml.docilealligator.infinityforreddit.customviews; +import android.annotation.SuppressLint; import android.content.res.ColorStateList; -import android.graphics.drawable.Drawable; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -9,7 +9,7 @@ import android.widget.ImageView; import android.widget.LinearLayout; import androidx.appcompat.view.menu.MenuItemImpl; -import androidx.core.graphics.drawable.DrawableCompat; +import androidx.core.view.MenuItemCompat; import com.google.android.material.bottomappbar.BottomAppBar; import com.google.android.material.floatingactionbutton.FloatingActionButton; @@ -65,15 +65,12 @@ public class NavigationWrapper { } } + @SuppressLint("RestrictedApi") private void applyMenuItemTheme(Menu menu, int bottomAppBarIconColor) { 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, bottomAppBarIconColor); - item.setIcon(drawable); - } + MenuItemCompat.setIconTintList(item, ColorStateList.valueOf(bottomAppBarIconColor)); } } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ThemePreviewPostsFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ThemePreviewPostsFragment.java index 49aa1ea7..5b0d9de7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ThemePreviewPostsFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ThemePreviewPostsFragment.java @@ -13,8 +13,8 @@ import android.widget.ProgressBar; import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.appcompat.content.res.AppCompatResources; import androidx.cardview.widget.CardView; -import androidx.core.graphics.drawable.DrawableCompat; import androidx.fragment.app.Fragment; import com.bumptech.glide.Glide; @@ -24,10 +24,10 @@ import com.libRG.CustomTextView; import butterknife.BindView; import butterknife.ButterKnife; import jp.wasabeef.glide.transformations.RoundedCornersTransformation; +import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.activities.CustomThemePreviewActivity; import ml.docilealligator.infinityforreddit.customtheme.CustomTheme; import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView; -import ml.docilealligator.infinityforreddit.R; /** * A simple {@link Fragment} subclass. @@ -134,9 +134,9 @@ public class ThemePreviewPostsFragment extends Fragment { scoreTextView.setTextColor(customTheme.postIconAndInfoColor); downvoteButton.setColorFilter(customTheme.postIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); commentsCountTextView.setTextColor(customTheme.postIconAndInfoColor); - Drawable commentIcon = activity.getDrawable(R.drawable.ic_comment_grey_24dp); + Drawable commentIcon = AppCompatResources.getDrawable(activity, R.drawable.ic_comment_grey_24dp); if (commentIcon != null) { - DrawableCompat.setTint(commentIcon, customTheme.postIconAndInfoColor); + commentIcon.setTint(customTheme.postIconAndInfoColor); } commentsCountTextView.setCompoundDrawablesWithIntrinsicBounds(commentIcon, null, null, null); saveButton.setColorFilter(customTheme.postIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java index d1cc9976..20e9d00c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java @@ -10,6 +10,7 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.ColorStateList; import android.content.res.Configuration; import android.graphics.Canvas; import android.graphics.drawable.ColorDrawable; @@ -30,10 +31,10 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.content.res.AppCompatResources; import androidx.appcompat.view.menu.MenuItemImpl; -import androidx.core.content.ContextCompat; import androidx.core.content.res.ResourcesCompat; -import androidx.core.graphics.drawable.DrawableCompat; +import androidx.core.view.MenuItemCompat; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.ConcatAdapter; import androidx.recyclerview.widget.ItemTouchHelper; @@ -693,9 +694,9 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic } private Drawable getMenuItemIcon(int drawableId) { - Drawable icon = ContextCompat.getDrawable(activity, drawableId); + Drawable icon = AppCompatResources.getDrawable(activity, drawableId); if (icon != null) { - DrawableCompat.setTint(icon, mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor()); + icon.setTint(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor()); } return icon; @@ -1182,11 +1183,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic 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, mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor()); - item.setIcon(drawable); - } + MenuItemCompat.setIconTintList(item, ColorStateList + .valueOf(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor())); } Utils.setTitleWithCustomFontToMenuItem(activity.typeface, item, null); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CrashReportsFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CrashReportsFragment.java index 90ba39c5..730e7a7a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CrashReportsFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CrashReportsFragment.java @@ -2,7 +2,7 @@ package ml.docilealligator.infinityforreddit.settings; import android.annotation.SuppressLint; import android.content.Context; -import android.graphics.drawable.Drawable; +import android.content.res.ColorStateList; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; @@ -14,7 +14,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.appcompat.view.menu.MenuItemImpl; -import androidx.core.graphics.drawable.DrawableCompat; +import androidx.core.view.MenuItemCompat; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.RecyclerView; @@ -79,11 +79,8 @@ public class CrashReportsFragment extends Fragment { for (int i = 0; i < size; i++) { MenuItem item = menu.getItem(i); if (((MenuItemImpl) item).requestsActionButton()) { - Drawable drawable = item.getIcon(); - if (drawable != null) { - DrawableCompat.setTint(drawable, mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor()); - item.setIcon(drawable); - } + MenuItemCompat.setIconTintList(item, ColorStateList + .valueOf(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor())); } Utils.setTitleWithCustomFontToMenuItem(activity.typeface, item, null); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java index 07a60e03..0819daac 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java @@ -28,10 +28,9 @@ import android.widget.TextView; import android.widget.Toast; import androidx.annotation.Nullable; +import androidx.appcompat.content.res.AppCompatResources; import androidx.appcompat.widget.Toolbar; import androidx.coordinatorlayout.widget.CoordinatorLayout; -import androidx.core.content.ContextCompat; -import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.text.HtmlCompat; import com.bumptech.glide.Glide; @@ -398,14 +397,11 @@ public final class Utils { @Nullable public static Drawable getTintedDrawable(Context context, int drawableId, int color) { - Drawable drawable = ContextCompat.getDrawable(context, drawableId); + final Drawable drawable = AppCompatResources.getDrawable(context, drawableId); if (drawable != null) { - Drawable wrappedDrawable = DrawableCompat.wrap(drawable).mutate(); - DrawableCompat.setTint(wrappedDrawable, color); - return wrappedDrawable; + drawable.setTint(color); } - - return null; + return drawable; } public static void uploadImageToReddit(Context context, Executor executor, Retrofit oauthRetrofit, |