1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-08 07:57:28 +00:00

Fix post view button colors wrong for some themes

This commit is contained in:
Ammar Githam 2021-05-15 11:47:30 +09:00
parent eb1e55470a
commit 5daec513ba

View File

@ -102,7 +102,6 @@ import static androidx.core.content.PermissionChecker.checkSelfPermission;
import static awais.instagrabber.fragments.HashTagFragment.ARG_HASHTAG; import static awais.instagrabber.fragments.HashTagFragment.ARG_HASHTAG;
import static awais.instagrabber.fragments.settings.PreferenceKeys.PREF_SHOWN_COUNT_TOOLTIP; import static awais.instagrabber.fragments.settings.PreferenceKeys.PREF_SHOWN_COUNT_TOOLTIP;
import static awais.instagrabber.utils.DownloadUtils.WRITE_PERMISSION; import static awais.instagrabber.utils.DownloadUtils.WRITE_PERMISSION;
import static awais.instagrabber.utils.Utils.getAttrValue;
import static awais.instagrabber.utils.Utils.settingsHelper; import static awais.instagrabber.utils.Utils.settingsHelper;
public class PostViewV2Fragment extends Fragment implements EditTextDialogFragment.EditTextDialogFragmentCallback { public class PostViewV2Fragment extends Fragment implements EditTextDialogFragment.EditTextDialogFragmentCallback {
@ -133,6 +132,9 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
private boolean isInFullScreenMode; private boolean isInFullScreenMode;
private StyledPlayerView playerView; private StyledPlayerView playerView;
private int playerViewOriginalHeight; private int playerViewOriginalHeight;
private Drawable originalRootBackground;
private ColorStateList originalLikeColorStateList;
private ColorStateList originalSaveColorStateList;
private final Observer<Object> backStackSavedStateObserver = result -> { private final Observer<Object> backStackSavedStateObserver = result -> {
if (result == null) return; if (result == null) return;
@ -143,7 +145,6 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
// clear result // clear result
backStackSavedStateResultLiveData.postValue(null); backStackSavedStateResultLiveData.postValue(null);
}; };
private Drawable originalRootBackground;
public void setOnDeleteListener(final OnDeleteListener onDeleteListener) { public void setOnDeleteListener(final OnDeleteListener onDeleteListener) {
if (onDeleteListener == null) return; if (onDeleteListener == null) return;
@ -443,6 +444,7 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
} }
private void setupLike() { private void setupLike() {
originalLikeColorStateList = bottom.like.getIconTint();
final boolean likableMedia = viewModel.hasPk() /*&& viewModel.getMedia().isCommentLikesEnabled()*/; final boolean likableMedia = viewModel.hasPk() /*&& viewModel.getMedia().isCommentLikesEnabled()*/;
if (!likableMedia) { if (!likableMedia) {
bottom.like.setVisibility(View.GONE); bottom.like.setVisibility(View.GONE);
@ -505,25 +507,25 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
private void setLikedResources(final boolean liked) { private void setLikedResources(final boolean liked) {
final int iconResource; final int iconResource;
final int tintResource; final ColorStateList tintColorStateList;
final Context context = getContext(); final Context context = getContext();
if (context == null) return; if (context == null) return;
final Resources resources = context.getResources(); final Resources resources = context.getResources();
if (resources == null) return; if (resources == null) return;
if (liked) { if (liked) {
iconResource = R.drawable.ic_like; iconResource = R.drawable.ic_like;
tintResource = resources.getColor(R.color.red_600); tintColorStateList = ColorStateList.valueOf(resources.getColor(R.color.red_600));
// textResId = R.string.unlike_without_count;
} else { } else {
iconResource = R.drawable.ic_not_liked; iconResource = R.drawable.ic_not_liked;
tintResource = getAttrValue(context, R.attr.colorPrimary); tintColorStateList = originalLikeColorStateList != null ? originalLikeColorStateList
// textResId = R.string.like_without_count; : ColorStateList.valueOf(resources.getColor(R.color.white));
} }
bottom.like.setIconResource(iconResource); bottom.like.setIconResource(iconResource);
bottom.like.setIconTint(ColorStateList.valueOf(tintResource)); bottom.like.setIconTint(tintColorStateList);
} }
private void setupSave() { private void setupSave() {
originalSaveColorStateList = bottom.save.getIconTint();
if (!viewModel.isLoggedIn() || !viewModel.hasPk() || !viewModel.getMedia().canViewerSave()) { if (!viewModel.isLoggedIn() || !viewModel.hasPk() || !viewModel.getMedia().canViewerSave()) {
bottom.save.setVisibility(View.GONE); bottom.save.setVisibility(View.GONE);
return; return;
@ -576,22 +578,21 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
private void setSavedResources(final boolean saved) { private void setSavedResources(final boolean saved) {
final int iconResource; final int iconResource;
final int tintResource; final ColorStateList tintColorStateList;
final Context context = getContext(); final Context context = getContext();
if (context == null) return; if (context == null) return;
final Resources resources = context.getResources(); final Resources resources = context.getResources();
if (resources == null) return; if (resources == null) return;
if (saved) { if (saved) {
iconResource = R.drawable.ic_bookmark; iconResource = R.drawable.ic_bookmark;
tintResource = resources.getColor(R.color.blue_700); tintColorStateList = ColorStateList.valueOf(resources.getColor(R.color.blue_700));
// textResId = R.string.saved;
} else { } else {
iconResource = R.drawable.ic_round_bookmark_border_24; iconResource = R.drawable.ic_round_bookmark_border_24;
tintResource = getAttrValue(context, R.attr.colorPrimary); tintColorStateList = originalSaveColorStateList != null ? originalSaveColorStateList
// textResId = R.string.save; : ColorStateList.valueOf(resources.getColor(R.color.white));
} }
bottom.save.setIconResource(iconResource); bottom.save.setIconResource(iconResource);
bottom.save.setIconTint(ColorStateList.valueOf(tintResource)); bottom.save.setIconTint(tintColorStateList);
} }
private void setupProfilePic(final User user) { private void setupProfilePic(final User user) {