mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-02-27 19:43:56 +01:00
Remove unnecessary uses of DrawableCompat. (#1045)
This commit is contained in:
parent
e0cf4ec485
commit
45bc223659
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user