diff --git a/app/build.gradle b/app/build.gradle index 88f03087..4d558ba8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,7 +25,7 @@ android { applicationId "code.name.monkey.retromusic" versionCode 416 - versionName '3.5.970' + versionName '3.5.010' multiDexEnabled true diff --git a/app/src/main/assets/retro-changelog.html b/app/src/main/assets/retro-changelog.html index 0727abdd..a98a38cb 100644 --- a/app/src/main/assets/retro-changelog.html +++ b/app/src/main/assets/retro-changelog.html @@ -1 +1 @@ -
If you see entire app white or dark or black select same theme in settings to fix
*If you face any UI related issues you clear app data and cache, if its not working try to uninstall and install again.
\ No newline at end of file +If you see entire app white or dark or black select same theme in settings to fix
*If you face any UI related issues you clear app data and cache, if its not working try to uninstall and install again.
\ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsThemeActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsThemeActivity.kt index 74bf61c5..24ca4b90 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsThemeActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsThemeActivity.kt @@ -8,6 +8,7 @@ import android.view.KeyEvent import android.view.View import android.view.WindowManager import androidx.annotation.ColorInt +import androidx.appcompat.app.AppCompatDelegate.setDefaultNightMode import androidx.core.content.ContextCompat import code.name.monkey.appthemehelper.ATH import code.name.monkey.appthemehelper.ThemeStore @@ -19,14 +20,14 @@ import code.name.monkey.appthemehelper.util.VersionUtils import code.name.monkey.retromusic.R import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.RetroUtil -import code.name.monkey.retromusic.util.ThemeManager +import code.name.monkey.retromusic.util.theme.ThemeManager abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable { private val handler = Handler() override fun onCreate(savedInstanceState: Bundle?) { - setTheme(ThemeManager.getThemeResValue(this)) + updateTheme() hideStatusBar() super.onCreate(savedInstanceState) setImmersiveFullscreen() @@ -34,6 +35,11 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable { toggleScreenOn() } + private fun updateTheme() { + setTheme(ThemeManager.getThemeResValue(this)) + setDefaultNightMode(ThemeManager.getNightMode(this)) + } + private fun toggleScreenOn() { if (PreferenceUtil.getInstance(this).isScreenOnEnabled) { window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/WriteTagsAsyncTask.java b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/WriteTagsAsyncTask.java index 29970c38..81a8a7a5 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/WriteTagsAsyncTask.java +++ b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/WriteTagsAsyncTask.java @@ -47,6 +47,7 @@ public class WriteTagsAsyncTask extends @NonNull @Override protected Dialog createDialog(@NonNull Context context) { + return new MaterialAlertDialogBuilder(context) .setTitle(R.string.saving_changes) .setCancelable(false) diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumAdapter.kt index d2edf716..4cdd335b 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumAdapter.kt @@ -180,23 +180,23 @@ open class AlbumAdapter( override fun onClick(v: View?) { super.onClick(v) if (isInQuickSelectMode) { - toggleChecked(adapterPosition) + toggleChecked(layoutPosition) } else { val activityOptions = ActivityOptions.makeSceneTransitionAnimation( activity, imageContainerCard ?: image, - "${activity.getString(R.string.transition_album_art)}_${dataSet[adapterPosition].id}" + "${activity.getString(R.string.transition_album_art)}_${dataSet[layoutPosition].id}" ) NavigationUtil.goToAlbumOptions( activity, - dataSet[adapterPosition].id, + dataSet[layoutPosition].id, activityOptions ) } } override fun onLongClick(v: View?): Boolean { - toggleChecked(adapterPosition) + toggleChecked(layoutPosition) return super.onLongClick(v) } } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/ThemeSettingsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/ThemeSettingsFragment.kt index 55855880..3e72b701 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/ThemeSettingsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/ThemeSettingsFragment.kt @@ -16,6 +16,7 @@ package code.name.monkey.retromusic.fragments.settings import android.os.Build import android.os.Bundle +import android.os.Handler import androidx.preference.Preference import androidx.preference.TwoStatePreference import code.name.monkey.appthemehelper.ACCENT_COLORS @@ -53,7 +54,9 @@ class ThemeSettingsFragment : AbsSettingsFragment() { requireActivity().setTheme(PreferenceUtil.getThemeResFromPrefValue(theme)) DynamicShortcutManager(requireContext()).updateDynamicShortcuts() } - requireActivity().recreate() + Handler().postDelayed({ + requireActivity().recreate() + }, 400) true } } @@ -75,7 +78,9 @@ class ThemeSettingsFragment : AbsSettingsFragment() { ThemeStore.editTheme(requireContext()).accentColor(color).commit() if (VersionUtils.hasNougatMR()) DynamicShortcutManager(requireContext()).updateDynamicShortcuts() - requireActivity().recreate() + Handler().postDelayed({ + requireActivity().recreate() + }, 400) } } return@setOnPreferenceClickListener true @@ -91,7 +96,9 @@ class ThemeSettingsFragment : AbsSettingsFragment() { requireActivity().setTheme(PreferenceUtil.getThemeResFromPrefValue("black")) DynamicShortcutManager(requireContext()).updateDynamicShortcuts() } - requireActivity().recreate() + Handler().postDelayed({ + requireActivity().recreate() + }, 400) true } @@ -102,7 +109,9 @@ class ThemeSettingsFragment : AbsSettingsFragment() { ThemeStore.prefs(requireContext()).edit().putBoolean("desaturated_color", desaturated) .apply() PreferenceUtil.getInstance(requireContext()).setDesaturatedColor(desaturated) - requireActivity().recreate() + Handler().postDelayed({ + requireActivity().recreate() + }, 400) true } diff --git a/app/src/main/java/code/name/monkey/retromusic/glide/AlbumGlideRequest.java b/app/src/main/java/code/name/monkey/retromusic/glide/AlbumGlideRequest.java index aed589d3..b42121d6 100644 --- a/app/src/main/java/code/name/monkey/retromusic/glide/AlbumGlideRequest.java +++ b/app/src/main/java/code/name/monkey/retromusic/glide/AlbumGlideRequest.java @@ -2,8 +2,6 @@ package code.name.monkey.retromusic.glide; import android.content.Context; import android.graphics.Bitmap; -import android.graphics.Color; -import android.graphics.drawable.ColorDrawable; import androidx.annotation.NonNull; @@ -86,7 +84,8 @@ public class AlbumGlideRequest { //noinspection unchecked return createBaseRequest(requestManager, song, ignoreMediaStore) .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY) - .error(new ColorDrawable(Color.RED)) + .placeholder(DEFAULT_ERROR_IMAGE) + .error(DEFAULT_ERROR_IMAGE) .animate(DEFAULT_ANIMATION) .signature(createSignature(song)); } @@ -95,7 +94,7 @@ public class AlbumGlideRequest { public static class BitmapBuilder { private final Builder builder; - public BitmapBuilder(Builder builder) { + BitmapBuilder(Builder builder) { this.builder = builder; } @@ -104,18 +103,18 @@ public class AlbumGlideRequest { return createBaseRequest(builder.requestManager, builder.song, builder.ignoreMediaStore) .asBitmap() .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY) - .error(new ColorDrawable(Color.GREEN)) + .placeholder(DEFAULT_ERROR_IMAGE) + .error(DEFAULT_ERROR_IMAGE) .animate(DEFAULT_ANIMATION) .signature(createSignature(builder.song)); } } public static class PaletteBuilder { - private static final String TAG = "PaletteBuilder"; - final Context context; + private final Context context; private final Builder builder; - public PaletteBuilder(Builder builder, Context context) { + PaletteBuilder(Builder builder, Context context) { this.builder = builder; this.context = context; } @@ -127,6 +126,7 @@ public class AlbumGlideRequest { .asBitmap() .transcode(new BitmapPaletteTranscoder(context), BitmapPaletteWrapper.class) .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY) + .placeholder(DEFAULT_ERROR_IMAGE) .error(DEFAULT_ERROR_IMAGE) .animate(DEFAULT_ANIMATION) .signature(createSignature(builder.song)); diff --git a/app/src/main/java/code/name/monkey/retromusic/glide/ArtistGlideRequest.java b/app/src/main/java/code/name/monkey/retromusic/glide/ArtistGlideRequest.java index 175c3442..025d3ad2 100644 --- a/app/src/main/java/code/name/monkey/retromusic/glide/ArtistGlideRequest.java +++ b/app/src/main/java/code/name/monkey/retromusic/glide/ArtistGlideRequest.java @@ -47,7 +47,7 @@ public class ArtistGlideRequest { private static final int DEFAULT_ERROR_IMAGE = R.drawable.default_artist_art; @NonNull - public static Key createSignature(@NonNull Artist artist) { + private static Key createSignature(@NonNull Artist artist) { return ArtistSignatureUtil.getInstance(App.Companion.getContext()).getArtistSignature(artist.getName()); } @@ -88,7 +88,7 @@ public class ArtistGlideRequest { //noinspection unchecked return createBaseRequest(requestManager, artist, noCustomImage, forceDownload) .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY) - .error(DEFAULT_ERROR_IMAGE) + .placeholder(DEFAULT_ERROR_IMAGE) .animate(DEFAULT_ANIMATION) .priority(Priority.LOW) .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) @@ -114,7 +114,7 @@ public class ArtistGlideRequest { private final Builder builder; - public BitmapBuilder(Builder builder) { + BitmapBuilder(Builder builder) { this.builder = builder; } @@ -124,7 +124,6 @@ public class ArtistGlideRequest { builder.forceDownload) .asBitmap() .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY) - .error(DEFAULT_ERROR_IMAGE) .animate(DEFAULT_ANIMATION) .priority(Priority.LOW) .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) @@ -138,7 +137,7 @@ public class ArtistGlideRequest { private final Builder builder; - public PaletteBuilder(Builder builder, Context context) { + PaletteBuilder(Builder builder, Context context) { this.builder = builder; this.context = context; } @@ -151,7 +150,6 @@ public class ArtistGlideRequest { .transcode(new BitmapPaletteTranscoder(context), BitmapPaletteWrapper.class) .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY) .placeholder(DEFAULT_ERROR_IMAGE) - .error(DEFAULT_ERROR_IMAGE) .animate(DEFAULT_ANIMATION) .priority(Priority.LOW) .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) diff --git a/app/src/main/java/code/name/monkey/retromusic/glide/SongGlideRequest.java b/app/src/main/java/code/name/monkey/retromusic/glide/SongGlideRequest.java index acc90640..7e703dcc 100644 --- a/app/src/main/java/code/name/monkey/retromusic/glide/SongGlideRequest.java +++ b/app/src/main/java/code/name/monkey/retromusic/glide/SongGlideRequest.java @@ -102,7 +102,7 @@ public class SongGlideRequest { //noinspection unchecked return createBaseRequest(requestManager, song, ignoreMediaStore) .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY) - .error(DEFAULT_ERROR_IMAGE) + .placeholder(DEFAULT_ERROR_IMAGE) .animate(DEFAULT_ANIMATION) .signature(createSignature(song)); } @@ -111,7 +111,7 @@ public class SongGlideRequest { public static class BitmapBuilder { private final Builder builder; - public BitmapBuilder(Builder builder) { + BitmapBuilder(Builder builder) { this.builder = builder; } @@ -120,7 +120,7 @@ public class SongGlideRequest { return createBaseRequest(builder.requestManager, builder.song, builder.ignoreMediaStore) .asBitmap() .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY) - .error(DEFAULT_ERROR_IMAGE) + .placeholder(DEFAULT_ERROR_IMAGE) .animate(DEFAULT_ANIMATION) .signature(createSignature(builder.song)); } @@ -130,7 +130,7 @@ public class SongGlideRequest { final Context context; private final Builder builder; - public PaletteBuilder(Builder builder, Context context) { + PaletteBuilder(Builder builder, Context context) { this.builder = builder; this.context = context; } @@ -141,7 +141,7 @@ public class SongGlideRequest { .asBitmap() .transcode(new BitmapPaletteTranscoder(context), BitmapPaletteWrapper.class) .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY) - .error(DEFAULT_ERROR_IMAGE) + .placeholder(DEFAULT_ERROR_IMAGE) .animate(DEFAULT_ANIMATION) .signature(createSignature(builder.song)); } diff --git a/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java index 5ed9fb34..924e9699 100644 --- a/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java +++ b/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java @@ -57,6 +57,7 @@ import code.name.monkey.retromusic.transform.HorizontalFlipTransformation; import code.name.monkey.retromusic.transform.NormalPageTransformer; import code.name.monkey.retromusic.transform.VerticalFlipTransformation; import code.name.monkey.retromusic.transform.VerticalStackTransformer; +import code.name.monkey.retromusic.util.theme.ThemeMode; public final class PreferenceUtil { @@ -527,11 +528,20 @@ public final class PreferenceUtil { } @NonNull - public String getGeneralThemeValue() { + public ThemeMode getGeneralThemeValue() { if (isBlackMode()) { - return "black"; + return ThemeMode.BLACK; } else { - return mPreferences.getString(GENERAL_THEME, "dark"); + String themeMode = mPreferences.getString(GENERAL_THEME, "dark"); + switch (themeMode) { + case "light": + return ThemeMode.LIGHT; + case "dark": + return ThemeMode.DARK; + case "auto": + default: + return ThemeMode.AUTO; + } } } diff --git a/app/src/main/java/code/name/monkey/retromusic/util/ThemeManager.kt b/app/src/main/java/code/name/monkey/retromusic/util/ThemeManager.kt deleted file mode 100644 index 4eaa224b..00000000 --- a/app/src/main/java/code/name/monkey/retromusic/util/ThemeManager.kt +++ /dev/null @@ -1,35 +0,0 @@ -package code.name.monkey.retromusic.util - -import android.content.Context -import android.content.res.Configuration.UI_MODE_NIGHT_MASK -import android.content.res.Configuration.UI_MODE_NIGHT_YES -import android.os.PowerManager -import androidx.annotation.StyleRes -import code.name.monkey.retromusic.R - -/** - * @author Paolo Valerdi - */ -object ThemeManager { - - @StyleRes - fun getThemeResValue(context: Context): Int = - when (PreferenceUtil.getInstance(context).generalThemeValue) { - "light" -> R.style.Theme_RetroMusic_Light - "dark" -> R.style.Theme_RetroMusic_Base - "auto" -> R.style.Theme_RetroMusic_FollowSystem - "black" -> R.style.Theme_RetroMusic_Black - else -> R.style.Theme_RetroMusic_FollowSystem - } - - private fun isSystemDarkModeEnabled(context: Context): Boolean { - val isBatterySaverEnabled = - (context.getSystemService(Context.POWER_SERVICE) as PowerManager?)?.isPowerSaveMode - ?: false - val isDarkModeEnabled = - (context.resources.configuration.uiMode and UI_MODE_NIGHT_MASK) == UI_MODE_NIGHT_YES - - return isBatterySaverEnabled or isDarkModeEnabled - } - -} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/util/theme/ThemeManager.kt b/app/src/main/java/code/name/monkey/retromusic/util/theme/ThemeManager.kt new file mode 100644 index 00000000..542fdbe5 --- /dev/null +++ b/app/src/main/java/code/name/monkey/retromusic/util/theme/ThemeManager.kt @@ -0,0 +1,50 @@ +package code.name.monkey.retromusic.util.theme + +import android.content.Context +import android.content.res.Configuration.UI_MODE_NIGHT_MASK +import android.content.res.Configuration.UI_MODE_NIGHT_YES +import android.os.PowerManager +import androidx.annotation.StyleRes +import androidx.appcompat.app.AppCompatDelegate +import code.name.monkey.retromusic.R +import code.name.monkey.retromusic.util.PreferenceUtil +import code.name.monkey.retromusic.util.theme.ThemeMode.* + +/** + * @author Paolo Valerdi + */ +object ThemeManager { + + @StyleRes + fun getThemeResValue( + context: Context + ): Int = when (context.generalThemeValue) { + LIGHT -> R.style.Theme_RetroMusic_Light + DARK -> R.style.Theme_RetroMusic_Base + BLACK -> R.style.Theme_RetroMusic_Black + AUTO -> R.style.Theme_RetroMusic_FollowSystem + } + + fun getNightMode( + context: Context + ): Int = when (context.generalThemeValue) { + LIGHT -> AppCompatDelegate.MODE_NIGHT_NO + DARK, + BLACK -> AppCompatDelegate.MODE_NIGHT_YES + AUTO -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM + } + + private fun isSystemDarkModeEnabled(context: Context): Boolean { + val isBatterySaverEnabled = + (context.getSystemService(Context.POWER_SERVICE) as PowerManager?)?.isPowerSaveMode + ?: false + val isDarkModeEnabled = + (context.resources.configuration.uiMode and UI_MODE_NIGHT_MASK) == UI_MODE_NIGHT_YES + + return isBatterySaverEnabled or isDarkModeEnabled + } + +} + +val Context.generalThemeValue: ThemeMode + get() = PreferenceUtil.getInstance(this).generalThemeValue \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/util/theme/ThemeMode.kt b/app/src/main/java/code/name/monkey/retromusic/util/theme/ThemeMode.kt new file mode 100644 index 00000000..88086741 --- /dev/null +++ b/app/src/main/java/code/name/monkey/retromusic/util/theme/ThemeMode.kt @@ -0,0 +1,8 @@ +package code.name.monkey.retromusic.util.theme + +enum class ThemeMode { + LIGHT, + DARK, + BLACK, + AUTO +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_full_player_controls.xml b/app/src/main/res/layout/fragment_full_player_controls.xml index b09c2b57..5537048b 100644 --- a/app/src/main/res/layout/fragment_full_player_controls.xml +++ b/app/src/main/res/layout/fragment_full_player_controls.xml @@ -13,57 +13,63 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="?attr/roundSelector" - android:padding="12dp" - app:layout_constraintBottom_toBottomOf="@+id/text" + android:padding="14dp" + app:layout_constraintBottom_toBottomOf="@+id/titleContainer" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintTop_toTopOf="parent" + app:layout_constraintTop_toTopOf="@id/titleContainer" app:srcCompat="@drawable/ic_more_vert_white_24dp" /> -