diff --git a/app/app.iml b/app/app.iml index 9b13850b..e373c162 100644 --- a/app/app.iml +++ b/app/app.iml @@ -29,9 +29,9 @@ - + - + @@ -43,9 +43,9 @@ - + - + @@ -131,39 +131,33 @@ + + - - - - + - - - - - - + @@ -172,82 +166,83 @@ - - - - - - + + + + - - - - - - - - - - - - + + + + + + + + + + + - - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - + + + + + - - - + + + + + - + - - - + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index fa1183bd..0210b37f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 28 - buildToolsVersion '28.0.2' + buildToolsVersion '28.0.3' defaultConfig { minSdkVersion 21 targetSdkVersion 28 @@ -11,12 +11,11 @@ android { vectorDrawables.useSupportLibrary = true applicationId "code.name.monkey.retromusic" - versionCode 232 - versionName '2.0.210' + versionCode 242 + versionName '2.1.000' multiDexEnabled true - buildConfigField("String", "LASTFM_API_KEY", "\"${getProperty(getProperties('../public.properties'), 'LASTFM_API_KEY')}\"") buildConfigField("String", "GOOGLE_PLAY_LICENSE_KEY", "\"${getProperty(getProperties('../public.properties'), 'GOOGLE_PLAY_LICENSE_KEY')}\"") } signingConfigs { @@ -46,12 +45,14 @@ android { flavorDimensions "default" + productFlavors { normal { versionCode defaultConfig.versionCode + 10000 versionName defaultConfig.versionName + "_" + getDate() dimension "default" } + } packagingOptions { @@ -73,16 +74,7 @@ android { resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9' } - /*configurations.all { - resolutionStrategy.eachDependency { DependencyResolveDetails details -> - def requested = details.requested - if (requested.group == 'com.android.support') { - if (!(requested.name.startsWith("multidex") || requested.name.startsWith("mediarouter"))) { - details.useVersion $supportLibVersion - } - } - } - }*/ + } def getProperties(String fileName) { @@ -119,28 +111,30 @@ dependencies { implementation "com.google.android.material:material:$supportLibVersion" //For casting - implementation 'androidx.mediarouter:mediarouter:1.0.0-beta01' + implementation 'androidx.mediarouter:mediarouter:1.0.0' implementation 'com.google.android.gms:play-services-cast-framework:16.0.2' implementation "com.squareup.retrofit2:retrofit:2.4.0" implementation "com.squareup.retrofit2:converter-gson:2.4.0" implementation "com.squareup.retrofit2:adapter-rxjava2:2.4.0" + implementation "com.jakewharton:butterknife:$butterKnife" annotationProcessor "com.jakewharton:butterknife-compiler:$butterKnife" + implementation "com.afollestad.material-dialogs:core:$materialDialog" implementation "com.afollestad.material-dialogs:commons:$materialDialog" implementation 'com.afollestad:material-cab:0.1.12' implementation 'com.github.bumptech.glide:glide:3.8.0' implementation 'com.github.bumptech.glide:okhttp3-integration:1.5.0' implementation 'io.reactivex.rxjava2:rxandroid:2.0.2' - implementation 'io.reactivex.rxjava2:rxjava:2.1.9' + implementation 'io.reactivex.rxjava2:rxjava:2.1.17' implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0' implementation 'com.squareup.okhttp3:okhttp:3.11.0' implementation('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.11.0@aar') { transitive = true } implementation 'com.github.ksoichiro:android-observablescrollview:1.6.0' - implementation 'com.simplecityapps:recyclerview-fastscroll:1.0.18' + implementation 'com.github.kabouzeid:RecyclerView-FastScroll:1.0.16-kmod' implementation 'com.anjlab.android.iab.v3:library:1.0.44' /*UI Library*/ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index fefc07f8..c2486cfd 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -95,7 +95,6 @@ - @@ -133,7 +132,6 @@ - @@ -142,25 +140,27 @@ - - - - - - - - - - + + + + + + + + + + - + + --> @@ -220,8 +220,7 @@ - - + - + android:resource="@xml/automotive_app_desc" /> + --> + + + \ No newline at end of file diff --git a/app/src/main/assets/contributors.json b/app/src/main/assets/contributors.json index 92ff17bd..ad828efd 100644 --- a/app/src/main/assets/contributors.json +++ b/app/src/main/assets/contributors.json @@ -5,6 +5,12 @@ "link": "https://t.me/FlixbusLennart", "profile_image": "https://i.imgur.com/Q5Nsx1R.jpg" }, + { + "name": "Vitor Monteriro", + "summary": "Telegram contributor", + "link": "https://t.me/mluizvitor", + "profile_image": "https://i.imgur.com/vvpE4nn.jpg" + }, { "name": "Elvan Putra", "summary": "Design contributor", @@ -14,7 +20,7 @@ { "name": "Gaming Inc.", "summary": "Discord server maintainer", - "link": "https://t.me/Gaming_Inc", + "link": "https://discord.gg/qTecXXn", "profile_image": "https://i.imgur.com/5wXLrS2.jpg" }, { @@ -25,7 +31,7 @@ }, { "name": "Gaurav Singh", - "summary": "Moderator", + "summary": "Telegram and Design contributor", "link": "https://t.me/Allstargaurav", "profile_image": "https://i.imgur.com/EertxDu.jpg" } diff --git a/app/src/main/assets/retro-changelog.html b/app/src/main/assets/retro-changelog.html index 518b9e30..7d031805 100644 --- a/app/src/main/assets/retro-changelog.html +++ b/app/src/main/assets/retro-changelog.html @@ -1 +1 @@ -

You can view the changelog dialog again at any time from the about section.

Version 2.0.200

  1. Fix: artist name on card theme
  2. Fix: dialog navigation icons colors
  3. Fix: album cover edit with last.fm for above Android 8.0
  4. Fix: adaptive controls for material theme
  5. Added: Now playing theme settings
  6. Added: home artists cover style(Settings-> Personalize-> Home artist grid)
  7. Added: now playing cover sliding style(Settings-> Now playing-> Now playing album cover style)
  8. Added: now playing album cover style chooser(Settings->Now playing-> Album cover theme)
  9. Added: extra controls toggle for mini player(Settings-> Now playing-> Extra controls)
  10. Added: faq links in about
  11. Added: volume toggle for lock screen to support small screen
  12. Added: on-click artist icon to artist details in album details screen
  13. Added: albums and artists list style(Settings->Personalize-> Artist grid or Album grid)
  14. Added: toggle home banner(Settings->Personalize-> Home banner)
  15. Improved: home page UI
  16. Updated: internal libs
  17. Updated: synced translations

FAQ's

*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 +

You can view the changelog dialog again at any time from the about section.

Version 2.0.300

  1. Fix: offer dialog showing
  2. Added: zero volume pause
  3. Added: more album cover skipping styles
  4. Added: new animations(WIP)
  5. Added: more tab titles toggle
  6. Improved: home screen
  7. Updated: internal libraries

FAQ's

*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/RetroApplication.java b/app/src/main/java/code/name/monkey/retromusic/RetroApplication.java index 1cc53c5b..6740ad8e 100644 --- a/app/src/main/java/code/name/monkey/retromusic/RetroApplication.java +++ b/app/src/main/java/code/name/monkey/retromusic/RetroApplication.java @@ -1,5 +1,6 @@ package code.name.monkey.retromusic; +import android.content.Context; import android.os.Build; import com.anjlab.android.iab.v3.BillingProcessor; @@ -24,6 +25,10 @@ public class RetroApplication extends MultiDexApplication { return app; } + public static Context getContext() { + return app.getApplicationContext(); + } + public static boolean isProVersion() { return BuildConfig.DEBUG || app.billingProcessor.isPurchased(PRO_VERSION_PRODUCT_ID); } diff --git a/app/src/main/java/code/name/monkey/retromusic/appshortcuts/AppShortcutIconGenerator.java b/app/src/main/java/code/name/monkey/retromusic/appshortcuts/AppShortcutIconGenerator.java index 2c0c0869..40db1bfc 100644 --- a/app/src/main/java/code/name/monkey/retromusic/appshortcuts/AppShortcutIconGenerator.java +++ b/app/src/main/java/code/name/monkey/retromusic/appshortcuts/AppShortcutIconGenerator.java @@ -22,7 +22,7 @@ import code.name.monkey.retromusic.util.RetroUtil; @RequiresApi(Build.VERSION_CODES.N_MR1) public final class AppShortcutIconGenerator { public static Icon generateThemedIcon(Context context, int iconId) { - if (PreferenceUtil.getInstance(context).coloredAppShortcuts()){ + if (PreferenceUtil.getInstance().coloredAppShortcuts()){ return generateUserThemedIcon(context, iconId); } else { return generateDefaultThemedIcon(context, iconId); diff --git a/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetBig.java b/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetBig.java index 95686dde..11145dbd 100644 --- a/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetBig.java +++ b/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetBig.java @@ -7,10 +7,16 @@ import android.content.Intent; import android.graphics.Bitmap; import android.graphics.Point; import android.graphics.drawable.Drawable; -import androidx.annotation.Nullable; import android.text.TextUtils; import android.view.View; import android.widget.RemoteViews; + +import com.bumptech.glide.Glide; +import com.bumptech.glide.request.animation.GlideAnimation; +import com.bumptech.glide.request.target.SimpleTarget; +import com.bumptech.glide.request.target.Target; + +import androidx.annotation.Nullable; import code.name.monkey.appthemehelper.util.MaterialValueHelper; import code.name.monkey.retromusic.Constants; import code.name.monkey.retromusic.R; @@ -19,153 +25,150 @@ import code.name.monkey.retromusic.glide.SongGlideRequest; import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.service.MusicService; import code.name.monkey.retromusic.ui.activities.MainActivity; +import code.name.monkey.retromusic.ui.activities.NowPayingActivity; import code.name.monkey.retromusic.util.RetroUtil; -import com.bumptech.glide.Glide; -import com.bumptech.glide.request.animation.GlideAnimation; -import com.bumptech.glide.request.target.SimpleTarget; -import com.bumptech.glide.request.target.Target; public class AppWidgetBig extends BaseAppWidget { - public static final String NAME = "app_widget_big"; + public static final String NAME = "app_widget_big"; - private static AppWidgetBig mInstance; - private Target target; // for cancellation + private static AppWidgetBig mInstance; + private Target target; // for cancellation - public static synchronized AppWidgetBig getInstance() { - if (mInstance == null) { - mInstance = new AppWidgetBig(); - } - return mInstance; - } - - /** - * Initialize given widgets to default state, where we launch Music on default click and hide - * actions if service not running. - */ - protected void defaultAppWidget(final Context context, final int[] appWidgetIds) { - final RemoteViews appWidgetView = new RemoteViews(context.getPackageName(), - R.layout.app_widget_big); - - appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE); - appWidgetView.setImageViewResource(R.id.image, R.drawable.default_album_art); - appWidgetView.setImageViewBitmap(R.id.button_next, createBitmap( - RetroUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_next_white_24dp, - MaterialValueHelper.getPrimaryTextColor(context, false)), 1f)); - appWidgetView.setImageViewBitmap(R.id.button_prev, createBitmap( - RetroUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_previous_white_24dp, - MaterialValueHelper.getPrimaryTextColor(context, false)), 1f)); - appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, createBitmap( - RetroUtil.getTintedVectorDrawable(context, R.drawable.ic_play_arrow_white_24dp, - MaterialValueHelper.getPrimaryTextColor(context, false)), 1f)); - - linkButtons(context, appWidgetView); - pushUpdate(context, appWidgetIds, appWidgetView); - } - - /** - * Update all active widget instances by pushing changes - */ - public void performUpdate(final MusicService service, final int[] appWidgetIds) { - final RemoteViews appWidgetView = new RemoteViews(service.getPackageName(), - R.layout.app_widget_big); - - final boolean isPlaying = service.isPlaying(); - final Song song = service.getCurrentSong(); - - // Set the titles and artwork - if (TextUtils.isEmpty(song.title) && TextUtils.isEmpty(song.artistName)) { - appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE); - } else { - appWidgetView.setViewVisibility(R.id.media_titles, View.VISIBLE); - appWidgetView.setTextViewText(R.id.title, song.title); - appWidgetView.setTextViewText(R.id.text, getSongArtistAndAlbum(song)); - } - - // Set correct drawable for pause state - int playPauseRes = - isPlaying ? R.drawable.ic_pause_white_24dp : R.drawable.ic_play_arrow_white_24dp; - appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, createBitmap( - RetroUtil.getTintedVectorDrawable(service, playPauseRes, - MaterialValueHelper.getPrimaryTextColor(service, false)), 1f)); - - // Set prev/next button drawables - appWidgetView.setImageViewBitmap(R.id.button_next, createBitmap( - RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_next_white_24dp, - MaterialValueHelper.getPrimaryTextColor(service, false)), 1f)); - appWidgetView.setImageViewBitmap(R.id.button_prev, createBitmap( - RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_previous_white_24dp, - MaterialValueHelper.getPrimaryTextColor(service, false)), 1f)); - - // Link actions buttons to intents - linkButtons(service, appWidgetView); - - // Load the album cover async and push the update on completion - Point p = RetroUtil.getScreenSize(service); - final int widgetImageSize = Math.min(p.x, p.y); - final Context appContext = service.getApplicationContext(); - service.runOnUiThread(new Runnable() { - @Override - public void run() { - if (target != null) { - Glide.clear(target); + public static synchronized AppWidgetBig getInstance() { + if (mInstance == null) { + mInstance = new AppWidgetBig(); } - target = SongGlideRequest.Builder.from(Glide.with(appContext), song) - .checkIgnoreMediaStore(appContext) - .asBitmap().build() - .into(new SimpleTarget(widgetImageSize, widgetImageSize) { - @Override - public void onResourceReady(Bitmap resource, - GlideAnimation glideAnimation) { - update(resource); - } + return mInstance; + } - @Override - public void onLoadFailed(Exception e, Drawable errorDrawable) { - super.onLoadFailed(e, errorDrawable); - update(null); - } + /** + * Initialize given widgets to default state, where we launch Music on default click and hide + * actions if service not running. + */ + protected void defaultAppWidget(final Context context, final int[] appWidgetIds) { + final RemoteViews appWidgetView = new RemoteViews(context.getPackageName(), + R.layout.app_widget_big); - private void update(@Nullable Bitmap bitmap) { - if (bitmap == null) { - appWidgetView.setImageViewResource(R.id.image, R.drawable.default_album_art); - } else { - appWidgetView.setImageViewBitmap(R.id.image, bitmap); + appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE); + appWidgetView.setImageViewResource(R.id.image, R.drawable.default_album_art); + appWidgetView.setImageViewBitmap(R.id.button_next, createBitmap( + RetroUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_next_white_24dp, + MaterialValueHelper.getPrimaryTextColor(context, false)), 1f)); + appWidgetView.setImageViewBitmap(R.id.button_prev, createBitmap( + RetroUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_previous_white_24dp, + MaterialValueHelper.getPrimaryTextColor(context, false)), 1f)); + appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, createBitmap( + RetroUtil.getTintedVectorDrawable(context, R.drawable.ic_play_arrow_white_24dp, + MaterialValueHelper.getPrimaryTextColor(context, false)), 1f)); + + linkButtons(context, appWidgetView); + pushUpdate(context, appWidgetIds, appWidgetView); + } + + /** + * Update all active widget instances by pushing changes + */ + public void performUpdate(final MusicService service, final int[] appWidgetIds) { + final RemoteViews appWidgetView = new RemoteViews(service.getPackageName(), + R.layout.app_widget_big); + + final boolean isPlaying = service.isPlaying(); + final Song song = service.getCurrentSong(); + + // Set the titles and artwork + if (TextUtils.isEmpty(song.title) && TextUtils.isEmpty(song.artistName)) { + appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE); + } else { + appWidgetView.setViewVisibility(R.id.media_titles, View.VISIBLE); + appWidgetView.setTextViewText(R.id.title, song.title); + appWidgetView.setTextViewText(R.id.text, getSongArtistAndAlbum(song)); + } + + // Set correct drawable for pause state + int playPauseRes = + isPlaying ? R.drawable.ic_pause_white_24dp : R.drawable.ic_play_arrow_white_24dp; + appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, createBitmap( + RetroUtil.getTintedVectorDrawable(service, playPauseRes, + MaterialValueHelper.getPrimaryTextColor(service, false)), 1f)); + + // Set prev/next button drawables + appWidgetView.setImageViewBitmap(R.id.button_next, createBitmap( + RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_next_white_24dp, + MaterialValueHelper.getPrimaryTextColor(service, false)), 1f)); + appWidgetView.setImageViewBitmap(R.id.button_prev, createBitmap( + RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_previous_white_24dp, + MaterialValueHelper.getPrimaryTextColor(service, false)), 1f)); + + // Link actions buttons to intents + linkButtons(service, appWidgetView); + + // Load the album cover async and push the update on completion + Point p = RetroUtil.getScreenSize(service); + final int widgetImageSize = Math.min(p.x, p.y); + final Context appContext = service.getApplicationContext(); + service.runOnUiThread(new Runnable() { + @Override + public void run() { + if (target != null) { + Glide.clear(target); } - pushUpdate(appContext, appWidgetIds, appWidgetView); - } - }); - } - }); - } + target = SongGlideRequest.Builder.from(Glide.with(appContext), song) + .checkIgnoreMediaStore(appContext) + .asBitmap().build() + .into(new SimpleTarget(widgetImageSize, widgetImageSize) { + @Override + public void onResourceReady(Bitmap resource, + GlideAnimation glideAnimation) { + update(resource); + } - /** - * Link up various button actions using {@link PendingIntent}. - */ - private void linkButtons(final Context context, final RemoteViews views) { - Intent action; - PendingIntent pendingIntent; + @Override + public void onLoadFailed(Exception e, Drawable errorDrawable) { + super.onLoadFailed(e, errorDrawable); + update(null); + } - final ComponentName serviceName = new ComponentName(context, MusicService.class); + private void update(@Nullable Bitmap bitmap) { + if (bitmap == null) { + appWidgetView.setImageViewResource(R.id.image, R.drawable.default_album_art); + } else { + appWidgetView.setImageViewBitmap(R.id.image, bitmap); + } + pushUpdate(appContext, appWidgetIds, appWidgetView); + } + }); + } + }); + } - // Home - action = new Intent(context, MainActivity.class); - action.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); - pendingIntent = PendingIntent.getActivity(context, 0, action, 0); - views.setOnClickPendingIntent(R.id.clickable_area, pendingIntent); + /** + * Link up various button actions using {@link PendingIntent}. + */ + private void linkButtons(final Context context, final RemoteViews views) { + Intent action; + PendingIntent pendingIntent; - // Previous track - pendingIntent = buildPendingIntent(context, Constants.ACTION_REWIND, serviceName); - views.setOnClickPendingIntent(R.id.button_prev, pendingIntent); + final ComponentName serviceName = new ComponentName(context, MusicService.class); - // Play and pause - pendingIntent = buildPendingIntent(context, Constants.ACTION_TOGGLE_PAUSE, serviceName); - views.setOnClickPendingIntent(R.id.button_toggle_play_pause, pendingIntent); + // Home + action = new Intent(context, NowPayingActivity.class); + action.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); + pendingIntent = PendingIntent.getActivity(context, 0, action, 0); + views.setOnClickPendingIntent(R.id.clickable_area, pendingIntent); - // Next track - pendingIntent = buildPendingIntent(context, Constants.ACTION_SKIP, serviceName); - views.setOnClickPendingIntent(R.id.button_next, pendingIntent); + // Previous track + pendingIntent = buildPendingIntent(context, Constants.ACTION_REWIND, serviceName); + views.setOnClickPendingIntent(R.id.button_prev, pendingIntent); + + // Play and pause + pendingIntent = buildPendingIntent(context, Constants.ACTION_TOGGLE_PAUSE, serviceName); + views.setOnClickPendingIntent(R.id.button_toggle_play_pause, pendingIntent); + + // Next track + pendingIntent = buildPendingIntent(context, Constants.ACTION_SKIP, serviceName); + views.setOnClickPendingIntent(R.id.button_next, pendingIntent); - } + } } diff --git a/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetCard.java b/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetCard.java index 48f91200..f995c47f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetCard.java +++ b/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetCard.java @@ -26,6 +26,7 @@ import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper; import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.service.MusicService; import code.name.monkey.retromusic.ui.activities.MainActivity; +import code.name.monkey.retromusic.ui.activities.NowPayingActivity; import code.name.monkey.retromusic.util.RetroUtil; public class AppWidgetCard extends BaseAppWidget { @@ -175,7 +176,7 @@ public class AppWidgetCard extends BaseAppWidget { final ComponentName serviceName = new ComponentName(context, MusicService.class); // Home - action = new Intent(context, MainActivity.class); + action = new Intent(context, NowPayingActivity.class); action.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); pendingIntent = PendingIntent.getActivity(context, 0, action, 0); views.setOnClickPendingIntent(R.id.image, pendingIntent); diff --git a/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetClassic.java b/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetClassic.java index 2e7f7b8b..9d8afa32 100644 --- a/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetClassic.java +++ b/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetClassic.java @@ -20,6 +20,7 @@ import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper; import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.service.MusicService; import code.name.monkey.retromusic.ui.activities.MainActivity; +import code.name.monkey.retromusic.ui.activities.NowPayingActivity; import code.name.monkey.retromusic.util.RetroUtil; import com.bumptech.glide.Glide; import com.bumptech.glide.request.animation.GlideAnimation; @@ -160,7 +161,7 @@ public class AppWidgetClassic extends BaseAppWidget { final ComponentName serviceName = new ComponentName(context, MusicService.class); // Home - action = new Intent(context, MainActivity.class); + action = new Intent(context, NowPayingActivity.class); action.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); pendingIntent = PendingIntent.getActivity(context, 0, action, 0); views.setOnClickPendingIntent(R.id.image, pendingIntent); diff --git a/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetSmall.java b/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetSmall.java index 3dd0f670..376254f8 100644 --- a/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetSmall.java +++ b/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetSmall.java @@ -20,6 +20,7 @@ import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper; import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.service.MusicService; import code.name.monkey.retromusic.ui.activities.MainActivity; +import code.name.monkey.retromusic.ui.activities.NowPayingActivity; import code.name.monkey.retromusic.util.RetroUtil; import com.bumptech.glide.Glide; import com.bumptech.glide.request.animation.GlideAnimation; @@ -165,7 +166,7 @@ public class AppWidgetSmall extends BaseAppWidget { final ComponentName serviceName = new ComponentName(context, MusicService.class); // Home - action = new Intent(context, MainActivity.class); + action = new Intent(context, NowPayingActivity.class); action.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); pendingIntent = PendingIntent.getActivity(context, 0, action, 0); views.setOnClickPendingIntent(R.id.image, pendingIntent); diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/AddToPlaylistDialog.java b/app/src/main/java/code/name/monkey/retromusic/dialogs/AddToPlaylistDialog.java index 77484b0a..4741ef29 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/AddToPlaylistDialog.java +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/AddToPlaylistDialog.java @@ -1,16 +1,18 @@ package code.name.monkey.retromusic.dialogs; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.recyclerview.widget.DefaultItemAnimator; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; +import java.util.ArrayList; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.recyclerview.widget.DefaultItemAnimator; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; @@ -22,8 +24,6 @@ import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.ui.adapter.playlist.AddToPlaylist; import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment; -import java.util.ArrayList; - /** * @author Karim Abou Zeid (kabouzeid), Aidan Follestad (afollestad) */ @@ -35,8 +35,6 @@ public class AddToPlaylistDialog extends RoundedBottomSheetDialogFragment { @BindView(R.id.title) TextView title; - ArrayList playlists; - @NonNull public static AddToPlaylistDialog create(Song song) { ArrayList list = new ArrayList<>(); @@ -75,14 +73,10 @@ public class AddToPlaylistDialog extends RoundedBottomSheetDialogFragment { @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - title.setTextColor(ThemeStore.textColorPrimary(getContext())); final ArrayList songs = getArguments().getParcelableArrayList("songs"); - playlists = PlaylistLoader.getAllPlaylists(getActivity()).blockingFirst(); - - AddToPlaylist playlistAdapter = new AddToPlaylist(getActivity(), playlists, - R.layout.item_playlist, songs, getDialog()); - + final ArrayList playlists = PlaylistLoader.getAllPlaylists(getActivity()).blockingFirst(); + final AddToPlaylist playlistAdapter = new AddToPlaylist(getActivity(), playlists, R.layout.item_playlist, songs, getDialog()); playlist.setLayoutManager(new LinearLayoutManager(getContext())); playlist.setItemAnimator(new DefaultItemAnimator()); playlist.setAdapter(playlistAdapter); diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/BlacklistFolderChooserDialog.java b/app/src/main/java/code/name/monkey/retromusic/dialogs/BlacklistFolderChooserDialog.java index 4917337d..0bd45f81 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/BlacklistFolderChooserDialog.java +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/BlacklistFolderChooserDialog.java @@ -26,7 +26,7 @@ import code.name.monkey.retromusic.R; */ public class BlacklistFolderChooserDialog extends DialogFragment implements MaterialDialog.ListCallback { - String initialPath = Environment.getExternalStorageDirectory().getAbsolutePath(); + private String initialPath = Environment.getExternalStorageDirectory().getAbsolutePath(); private File parentFolder; private File[] parentContents; private boolean canGoUp = false; diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/ChangelogDialog.java b/app/src/main/java/code/name/monkey/retromusic/dialogs/ChangelogDialog.java deleted file mode 100644 index f8010fa9..00000000 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/ChangelogDialog.java +++ /dev/null @@ -1 +0,0 @@ -package code.name.monkey.retromusic.dialogs; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.graphics.Color; import android.os.Bundle; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.webkit.WebView; import com.afollestad.materialdialogs.internal.ThemeSingleton; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Objects; import butterknife.BindView; import butterknife.ButterKnife; import code.name.monkey.appthemehelper.util.ATHUtil; import code.name.monkey.appthemehelper.util.ColorUtil; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.util.PreferenceUtil; import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment; public class ChangelogDialog extends RoundedBottomSheetDialogFragment { @BindView(R.id.web_view) WebView webView; public static ChangelogDialog create() { return new ChangelogDialog(); } private static void setChangelogRead(@NonNull Context context) { try { PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); int currentVersion = pInfo.versionCode; PreferenceUtil.getInstance(context).setLastChangeLogVersion(currentVersion); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } } private static String colorToHex(int color) { return Integer.toHexString(color).substring(2); } @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View layout = inflater.inflate(R.layout.dialog_changelog, container, false); ButterKnife.bind(this, layout); return layout; } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); try { // Load from phonograph-changelog.html in the assets folder StringBuilder buf = new StringBuilder(); InputStream json = Objects.requireNonNull(getActivity()).getAssets().open ("retro-changelog.html"); BufferedReader in = new BufferedReader(new InputStreamReader(json, "UTF-8")); String str; while ((str = in.readLine()) != null) buf.append(str); in.close(); // Inject color values for WebView body background and links final String backgroundColor = colorToHex(ATHUtil.resolveColor(getActivity(), R.attr.md_background_color, Color.parseColor(ThemeSingleton.get().darkTheme ? "#424242" : "#ffffff"))); final String contentColor = ThemeSingleton.get().darkTheme ? "#ffffff" : "#000000"; webView.loadData(buf.toString() .replace("{style-placeholder}", String.format("body { background-color: %s; color: %s; }", backgroundColor, contentColor)) .replace("{link-color}", colorToHex(ThemeSingleton.get().positiveColor.getDefaultColor())) .replace("{link-color-active}", colorToHex(ColorUtil.lightenColor(ThemeSingleton.get().positiveColor.getDefaultColor()))) , "text/html", "UTF-8"); } catch (Throwable e) { webView.loadData("

Unable to load

" + e.getLocalizedMessage() + "

", "text/html", "UTF-8"); } setChangelogRead(getActivity()); } } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/ClearSmartPlaylistDialog.java b/app/src/main/java/code/name/monkey/retromusic/dialogs/ClearSmartPlaylistDialog.java index 39be79a6..735b0f9d 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/ClearSmartPlaylistDialog.java +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/ClearSmartPlaylistDialog.java @@ -2,13 +2,13 @@ package code.name.monkey.retromusic.dialogs; import android.app.Dialog; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.fragment.app.DialogFragment; import android.text.Html; import com.afollestad.materialdialogs.DialogAction; import com.afollestad.materialdialogs.MaterialDialog; +import androidx.annotation.NonNull; +import androidx.fragment.app.DialogFragment; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.model.smartplaylist.AbsSmartPlaylist; diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/CreatePlaylistDialog.java b/app/src/main/java/code/name/monkey/retromusic/dialogs/CreatePlaylistDialog.java index 9d6ffe0f..b1b7cf45 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/CreatePlaylistDialog.java +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/CreatePlaylistDialog.java @@ -20,6 +20,7 @@ import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import code.name.monkey.appthemehelper.ThemeStore; +import code.name.monkey.appthemehelper.util.MaterialUtil; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.util.PlaylistsUtil; @@ -80,18 +81,18 @@ public class CreatePlaylistDialog extends RoundedBottomSheetDialogFragment { public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); int accentColor = ThemeStore.accentColor(Objects.requireNonNull(getContext())); - actionCreate.setBackgroundTintList(ColorStateList.valueOf(accentColor)); - actionCancel.setStrokeColor(ColorStateList.valueOf(accentColor)); - actionCancel.setTextColor(accentColor); + MaterialUtil.setTint(actionCreate, true); + + MaterialUtil.setTint(actionCancel, false); + + MaterialUtil.setTint(textInputLayout, true); - textInputLayout.setBoxStrokeColor(accentColor); - textInputLayout.setDefaultHintTextColor(ColorStateList.valueOf(accentColor)); playlistName.setHintTextColor(ColorStateList.valueOf(accentColor)); playlistName.setTextColor(ThemeStore.textColorPrimary(getContext())); - title.setTextColor(ThemeStore.textColorPrimary(getContext())); + title.setTextColor(ThemeStore.textColorPrimary(getContext())); } @OnClick({R.id.action_cancel, R.id.action_create}) diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/DeletePlaylistDialog.java b/app/src/main/java/code/name/monkey/retromusic/dialogs/DeletePlaylistDialog.java index 76a2f288..a7681518 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/DeletePlaylistDialog.java +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/DeletePlaylistDialog.java @@ -1,6 +1,5 @@ package code.name.monkey.retromusic.dialogs; -import android.content.res.ColorStateList; import android.os.Bundle; import android.text.Html; import android.view.LayoutInflater; @@ -11,7 +10,6 @@ import android.widget.TextView; import com.google.android.material.button.MaterialButton; import java.util.ArrayList; -import java.util.Objects; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -19,6 +17,7 @@ import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import code.name.monkey.appthemehelper.ThemeStore; +import code.name.monkey.appthemehelper.util.MaterialUtil; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.model.Playlist; import code.name.monkey.retromusic.util.PlaylistsUtil; @@ -78,21 +77,10 @@ public class DeletePlaylistDialog extends RoundedBottomSheetDialogFragment { this.title.setText(content); this.title.setTextColor(ThemeStore.textColorPrimary(getContext())); - actionDelete.setText(R.string.action_delete); - int accentColor = ThemeStore.accentColor(Objects.requireNonNull(getContext())); - actionDelete.setIconTint(ColorStateList.valueOf(accentColor)); - actionCancel.setIconTint(ColorStateList.valueOf(accentColor)); - - int iconColor = ThemeStore.textColorSecondary(getContext()); - actionDelete.setStrokeColor(ColorStateList.valueOf(iconColor)); - actionCancel.setStrokeColor(ColorStateList.valueOf(iconColor)); - - - int textColor = ThemeStore.textColorPrimary(getContext()); - actionDelete.setTextColor(ColorStateList.valueOf(textColor)); - actionCancel.setTextColor(ColorStateList.valueOf(textColor)); + MaterialUtil.setTint(actionDelete, true); + MaterialUtil.setTint(actionCancel, false); } diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/DeleteSongsDialog.java b/app/src/main/java/code/name/monkey/retromusic/dialogs/DeleteSongsDialog.java index 57ee8cce..ca670503 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/DeleteSongsDialog.java +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/DeleteSongsDialog.java @@ -1,6 +1,5 @@ package code.name.monkey.retromusic.dialogs; -import android.content.res.ColorStateList; import android.os.Bundle; import android.text.Html; import android.view.LayoutInflater; @@ -11,7 +10,6 @@ import android.widget.TextView; import com.google.android.material.button.MaterialButton; import java.util.ArrayList; -import java.util.Objects; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -19,6 +17,7 @@ import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import code.name.monkey.appthemehelper.ThemeStore; +import code.name.monkey.appthemehelper.util.MaterialUtil; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.util.MusicUtil; @@ -72,12 +71,9 @@ public class DeleteSongsDialog extends RoundedBottomSheetDialogFragment { @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - title.setTextColor(ThemeStore.textColorPrimary(getContext())); - int accentColor = ThemeStore.accentColor(Objects.requireNonNull(getContext())); - actionDelete.setBackgroundTintList(ColorStateList.valueOf(accentColor)); - actionCancel.setStrokeColor(ColorStateList.valueOf(accentColor)); - actionCancel.setTextColor(accentColor); + MaterialUtil.setTint(actionDelete, true); + MaterialUtil.setTint(actionCancel, false); //noinspection unchecked,ConstantConditions final ArrayList songs = getArguments().getParcelableArrayList("songs"); diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/MainOptionsBottomSheetDialogFragment.java b/app/src/main/java/code/name/monkey/retromusic/dialogs/MainOptionsBottomSheetDialogFragment.java index 990b0e2a..76195632 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/MainOptionsBottomSheetDialogFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/MainOptionsBottomSheetDialogFragment.java @@ -1,6 +1,7 @@ package code.name.monkey.retromusic.dialogs; import android.content.res.ColorStateList; +import android.graphics.Bitmap; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -9,10 +10,15 @@ import android.widget.TextView; import com.google.android.material.button.MaterialButton; +import java.io.File; +import java.util.Calendar; import java.util.List; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatTextView; +import androidx.core.content.ContextCompat; +import butterknife.BindView; import butterknife.BindViews; import butterknife.ButterKnife; import butterknife.OnClick; @@ -21,8 +27,16 @@ import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.RetroApplication; import code.name.monkey.retromusic.ui.activities.MainActivity; import code.name.monkey.retromusic.ui.fragments.mainactivity.folders.FoldersFragment; +import code.name.monkey.retromusic.util.Compressor; import code.name.monkey.retromusic.util.NavigationUtil; +import code.name.monkey.retromusic.util.PreferenceUtil; +import code.name.monkey.retromusic.views.CircularImageView; import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment; +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.disposables.CompositeDisposable; +import io.reactivex.schedulers.Schedulers; + +import static code.name.monkey.retromusic.Constants.USER_PROFILE; public class MainOptionsBottomSheetDialogFragment extends RoundedBottomSheetDialogFragment { @@ -30,10 +44,20 @@ public class MainOptionsBottomSheetDialogFragment extends RoundedBottomSheetDial private static ButterKnife.Setter textColor = (view, value, index) -> view.setTextColor(ColorStateList.valueOf(value)); - @BindViews({R.id.action_folders, R.id.action_settings, R.id.action_about, R.id.action_buy_pro, R.id.action_rate, + @BindViews({R.id.action_folders, R.id.action_about, R.id.action_buy_pro, R.id.action_rate, R.id.action_sleep_timer}) List materialButtons; + @BindView(R.id.user_image_bottom) + CircularImageView userImageBottom; + + @BindView(R.id.title_welcome) + AppCompatTextView titleWelcome; + + @BindView(R.id.text) + AppCompatTextView text; + + private CompositeDisposable disposable = new CompositeDisposable(); public static MainOptionsBottomSheetDialogFragment newInstance(int selected_id) { Bundle bundle = new Bundle(); @@ -47,6 +71,11 @@ public class MainOptionsBottomSheetDialogFragment extends RoundedBottomSheetDial return new MainOptionsBottomSheetDialogFragment(); } + @Override + public void onDestroyView() { + super.onDestroyView(); + disposable.clear(); + } @Nullable @Override @@ -61,10 +90,13 @@ public class MainOptionsBottomSheetDialogFragment extends RoundedBottomSheetDial @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - + text.setTextColor(ThemeStore.textColorSecondary(getContext())); + titleWelcome.setTextColor(ThemeStore.textColorPrimary(getContext())); + titleWelcome.setText(String.format("%s %s!", getTimeOfTheDay(), PreferenceUtil.getInstance().getUserName())); + loadImageFromStorage(); } - @OnClick({R.id.action_folders, R.id.action_settings, R.id.action_sleep_timer, R.id.action_rate, + @OnClick({R.id.action_folders, R.id.user_info_container, R.id.action_settings, R.id.action_sleep_timer, R.id.action_rate, R.id.action_buy_pro, R.id.action_about}) void onClick(View view) { MainActivity mainActivity = (MainActivity) getActivity(); @@ -89,6 +121,9 @@ public class MainOptionsBottomSheetDialogFragment extends RoundedBottomSheetDial new SleepTimerDialog().show(getFragmentManager(), TAG); } break; + case R.id.user_info_container: + NavigationUtil.goToUserInfo(getActivity()); + break; case R.id.action_rate: NavigationUtil.goToPlayStore(mainActivity); break; @@ -96,5 +131,38 @@ public class MainOptionsBottomSheetDialogFragment extends RoundedBottomSheetDial dismiss(); } + private String getTimeOfTheDay() { + String message = getString(R.string.title_good_day); + Calendar c = Calendar.getInstance(); + int timeOfDay = c.get(Calendar.HOUR_OF_DAY); + if (timeOfDay >= 0 && timeOfDay < 6) { + message = getString(R.string.title_good_night); + } else if (timeOfDay >= 6 && timeOfDay < 12) { + message = getString(R.string.title_good_morning); + } else if (timeOfDay >= 12 && timeOfDay < 16) { + message = getString(R.string.title_good_afternoon); + } else if (timeOfDay >= 16 && timeOfDay < 20) { + message = getString(R.string.title_good_evening); + } else if (timeOfDay >= 20 && timeOfDay < 24) { + message = getString(R.string.title_good_night); + } + return message; + } + + private void loadImageFromStorage() { + //noinspection ConstantConditions + disposable.add(new Compressor(getContext()) + .setMaxHeight(300) + .setMaxWidth(300) + .setQuality(75) + .setCompressFormat(Bitmap.CompressFormat.WEBP) + .compressToBitmapAsFlowable( + new File(PreferenceUtil.getInstance().getProfileImage(), USER_PROFILE)) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(userImageBottom::setImageBitmap, + throwable -> userImageBottom.setImageDrawable(ContextCompat + .getDrawable(getContext(), R.drawable.ic_person_flat)))); + } } diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/RemoveFromPlaylistDialog.java b/app/src/main/java/code/name/monkey/retromusic/dialogs/RemoveFromPlaylistDialog.java index 0fcf841a..6f144747 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/RemoveFromPlaylistDialog.java +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/RemoveFromPlaylistDialog.java @@ -1,9 +1,6 @@ package code.name.monkey.retromusic.dialogs; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - import android.text.Html; import android.view.LayoutInflater; import android.view.View; @@ -12,9 +9,12 @@ import android.widget.TextView; import java.util.ArrayList; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; +import code.name.monkey.appthemehelper.ThemeStore; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.model.PlaylistSong; import code.name.monkey.retromusic.util.PlaylistsUtil; @@ -76,7 +76,7 @@ public class RemoveFromPlaylistDialog extends RoundedBottomSheetDialogFragment { final ArrayList songs = getArguments().getParcelableArrayList("songs"); int title; CharSequence content; - if (songs.size() > 1) { + if (songs != null && songs.size() > 1) { title = R.string.remove_songs_from_playlist_title; content = Html.fromHtml(getString(R.string.remove_x_songs_from_playlist, songs.size())); } else { @@ -85,5 +85,9 @@ public class RemoveFromPlaylistDialog extends RoundedBottomSheetDialogFragment { } this.remove.setText(content); this.title.setText(title); + + this.title.setTextColor(ThemeStore.textColorPrimary(getContext())); + this.remove.setTextColor(ThemeStore.textColorSecondary(getContext())); + this.cancel.setTextColor(ThemeStore.textColorSecondary(getContext())); } } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/RenamePlaylistDialog.java b/app/src/main/java/code/name/monkey/retromusic/dialogs/RenamePlaylistDialog.java index ff25c74b..19d32f6c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/RenamePlaylistDialog.java +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/RenamePlaylistDialog.java @@ -19,6 +19,7 @@ import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import code.name.monkey.appthemehelper.ThemeStore; +import code.name.monkey.appthemehelper.util.MaterialUtil; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.util.PlaylistsUtil; import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment; @@ -79,17 +80,13 @@ public class RenamePlaylistDialog extends RoundedBottomSheetDialogFragment { public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); int accentColor = ThemeStore.accentColor(Objects.requireNonNull(getContext())); - rename.setBackgroundTintList(ColorStateList.valueOf(accentColor)); - actionCancel.setStrokeColor(ColorStateList.valueOf(accentColor)); - actionCancel.setTextColor(accentColor); + MaterialUtil.setTint(rename,true); + MaterialUtil.setTint(actionCancel,false); + MaterialUtil.setTint(textInputLayout,false); + playlistName.setHintTextColor(ColorStateList.valueOf(accentColor)); - - textInputLayout.setBoxStrokeColor(accentColor); - textInputLayout.setDefaultHintTextColor(ColorStateList.valueOf(accentColor)); - - playlistName.setHintTextColor(accentColor); - playlistName.setTextColor(ThemeStore.textColorPrimary(getContext())); + title.setTextColor(ThemeStore.textColorPrimary(getContext())); long playlistId = 0; diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/ScanMediaFolderChooserDialog.java b/app/src/main/java/code/name/monkey/retromusic/dialogs/ScanMediaFolderChooserDialog.java index b2edfbb1..5419ce90 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/ScanMediaFolderChooserDialog.java +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/ScanMediaFolderChooserDialog.java @@ -1 +1 @@ -package code.name.monkey.retromusic.dialogs; import android.Manifest; import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.content.pm.PackageManager; import android.media.MediaScannerConnection; import android.os.Build; import android.os.Bundle; import android.os.Environment; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.app.ActivityCompat; import androidx.fragment.app.DialogFragment; import android.view.View; import android.widget.Toast; import com.afollestad.materialdialogs.MaterialDialog; import java.io.File; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.misc.UpdateToastMediaScannerCompletionListener; import code.name.monkey.retromusic.ui.fragments.mainactivity.folders.FoldersFragment; import code.name.monkey.retromusic.util.PreferenceUtil; /** * @author Aidan Follestad (afollestad), modified by Karim Abou Zeid */ public class ScanMediaFolderChooserDialog extends DialogFragment implements MaterialDialog.ListCallback { String initialPath = PreferenceUtil.getInstance(getContext()).getStartDirectory().getAbsolutePath(); private File parentFolder; private File[] parentContents; private boolean canGoUp = false; public static ScanMediaFolderChooserDialog create() { return new ScanMediaFolderChooserDialog(); } private static void scanPaths(@NonNull WeakReference activityWeakReference, @NonNull Context applicationContext, @Nullable String[] toBeScanned) { Activity activity = activityWeakReference.get(); if (toBeScanned == null || toBeScanned.length < 1) { Toast.makeText(applicationContext, R.string.nothing_to_scan, Toast.LENGTH_SHORT).show(); } else { MediaScannerConnection.scanFile(applicationContext, toBeScanned, null, activity != null ? new UpdateToastMediaScannerCompletionListener(activity, toBeScanned) : null); } } private String[] getContentsArray() { if (parentContents == null) { if (canGoUp) { return new String[]{".."}; } return new String[]{}; } String[] results = new String[parentContents.length + (canGoUp ? 1 : 0)]; if (canGoUp) { results[0] = ".."; } for (int i = 0; i < parentContents.length; i++) { results[canGoUp ? i + 1 : i] = parentContents[i].getName(); } return results; } private File[] listFiles() { File[] contents = parentFolder.listFiles(); List results = new ArrayList<>(); if (contents != null) { for (File fi : contents) { if (fi.isDirectory()) { results.add(fi); } } Collections.sort(results, new FolderSorter()); return results.toArray(new File[results.size()]); } return null; } @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ActivityCompat.checkSelfPermission( getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { return new MaterialDialog.Builder(getActivity()) .title(R.string.md_error_label) .content(R.string.md_storage_perm_error) .positiveText(android.R.string.ok) .build(); } if (savedInstanceState == null) { savedInstanceState = new Bundle(); } if (!savedInstanceState.containsKey("current_path")) { savedInstanceState.putString("current_path", initialPath); } parentFolder = new File(savedInstanceState.getString("current_path", File.pathSeparator)); checkIfCanGoUp(); parentContents = listFiles(); MaterialDialog.Builder builder = new MaterialDialog.Builder(getActivity()) .title(parentFolder.getAbsolutePath()) .items((CharSequence[]) getContentsArray()) .itemsCallback(this) .autoDismiss(false) .onPositive((dialog, which) -> { final Context applicationContext = getActivity().getApplicationContext(); final WeakReference activityWeakReference = new WeakReference<>(getActivity()); dismiss(); new FoldersFragment.ListPathsAsyncTask(getActivity(), paths -> scanPaths(activityWeakReference, applicationContext, paths)).execute(new FoldersFragment.ListPathsAsyncTask.LoadingInfo(parentFolder, FoldersFragment.AUDIO_FILE_FILTER)); }) .onNegative((materialDialog, dialogAction) -> dismiss()) .positiveText(R.string.action_scan_directory) .negativeText(android.R.string.cancel); return builder.build(); } @Override public void onSelection(MaterialDialog materialDialog, View view, int i, CharSequence s) { if (canGoUp && i == 0) { parentFolder = parentFolder.getParentFile(); if (parentFolder.getAbsolutePath().equals("/storage/emulated")) { parentFolder = parentFolder.getParentFile(); } checkIfCanGoUp(); } else { parentFolder = parentContents[canGoUp ? i - 1 : i]; canGoUp = true; if (parentFolder.getAbsolutePath().equals("/storage/emulated")) { parentFolder = Environment.getExternalStorageDirectory(); } } reload(); } private void checkIfCanGoUp() { canGoUp = parentFolder.getParent() != null; } private void reload() { parentContents = listFiles(); MaterialDialog dialog = (MaterialDialog) getDialog(); dialog.setTitle(parentFolder.getAbsolutePath()); dialog.setItems((CharSequence[]) getContentsArray()); } @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putString("current_path", parentFolder.getAbsolutePath()); } private static class FolderSorter implements Comparator { @Override public int compare(File lhs, File rhs) { return lhs.getName().compareTo(rhs.getName()); } } } \ No newline at end of file +package code.name.monkey.retromusic.dialogs; import android.Manifest; import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.content.pm.PackageManager; import android.media.MediaScannerConnection; import android.os.Build; import android.os.Bundle; import android.os.Environment; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.app.ActivityCompat; import androidx.fragment.app.DialogFragment; import android.view.View; import android.widget.Toast; import com.afollestad.materialdialogs.MaterialDialog; import java.io.File; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.misc.UpdateToastMediaScannerCompletionListener; import code.name.monkey.retromusic.ui.fragments.mainactivity.folders.FoldersFragment; import code.name.monkey.retromusic.util.PreferenceUtil; /** * @author Aidan Follestad (afollestad), modified by Karim Abou Zeid */ public class ScanMediaFolderChooserDialog extends DialogFragment implements MaterialDialog.ListCallback { String initialPath = PreferenceUtil.getInstance().getStartDirectory().getAbsolutePath(); private File parentFolder; private File[] parentContents; private boolean canGoUp = false; public static ScanMediaFolderChooserDialog create() { return new ScanMediaFolderChooserDialog(); } private static void scanPaths(@NonNull WeakReference activityWeakReference, @NonNull Context applicationContext, @Nullable String[] toBeScanned) { Activity activity = activityWeakReference.get(); if (toBeScanned == null || toBeScanned.length < 1) { Toast.makeText(applicationContext, R.string.nothing_to_scan, Toast.LENGTH_SHORT).show(); } else { MediaScannerConnection.scanFile(applicationContext, toBeScanned, null, activity != null ? new UpdateToastMediaScannerCompletionListener(activity, toBeScanned) : null); } } private String[] getContentsArray() { if (parentContents == null) { if (canGoUp) { return new String[]{".."}; } return new String[]{}; } String[] results = new String[parentContents.length + (canGoUp ? 1 : 0)]; if (canGoUp) { results[0] = ".."; } for (int i = 0; i < parentContents.length; i++) { results[canGoUp ? i + 1 : i] = parentContents[i].getName(); } return results; } private File[] listFiles() { File[] contents = parentFolder.listFiles(); List results = new ArrayList<>(); if (contents != null) { for (File fi : contents) { if (fi.isDirectory()) { results.add(fi); } } Collections.sort(results, new FolderSorter()); return results.toArray(new File[results.size()]); } return null; } @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ActivityCompat.checkSelfPermission( getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { return new MaterialDialog.Builder(getActivity()) .title(R.string.md_error_label) .content(R.string.md_storage_perm_error) .positiveText(android.R.string.ok) .build(); } if (savedInstanceState == null) { savedInstanceState = new Bundle(); } if (!savedInstanceState.containsKey("current_path")) { savedInstanceState.putString("current_path", initialPath); } parentFolder = new File(savedInstanceState.getString("current_path", File.pathSeparator)); checkIfCanGoUp(); parentContents = listFiles(); MaterialDialog.Builder builder = new MaterialDialog.Builder(getActivity()) .title(parentFolder.getAbsolutePath()) .items((CharSequence[]) getContentsArray()) .itemsCallback(this) .autoDismiss(false) .onPositive((dialog, which) -> { final Context applicationContext = getActivity().getApplicationContext(); final WeakReference activityWeakReference = new WeakReference<>(getActivity()); dismiss(); new FoldersFragment.ListPathsAsyncTask(getActivity(), paths -> scanPaths(activityWeakReference, applicationContext, paths)).execute(new FoldersFragment.ListPathsAsyncTask.LoadingInfo(parentFolder, FoldersFragment.AUDIO_FILE_FILTER)); }) .onNegative((materialDialog, dialogAction) -> dismiss()) .positiveText(R.string.action_scan_directory) .negativeText(android.R.string.cancel); return builder.build(); } @Override public void onSelection(MaterialDialog materialDialog, View view, int i, CharSequence s) { if (canGoUp && i == 0) { parentFolder = parentFolder.getParentFile(); if (parentFolder.getAbsolutePath().equals("/storage/emulated")) { parentFolder = parentFolder.getParentFile(); } checkIfCanGoUp(); } else { parentFolder = parentContents[canGoUp ? i - 1 : i]; canGoUp = true; if (parentFolder.getAbsolutePath().equals("/storage/emulated")) { parentFolder = Environment.getExternalStorageDirectory(); } } reload(); } private void checkIfCanGoUp() { canGoUp = parentFolder.getParent() != null; } private void reload() { parentContents = listFiles(); MaterialDialog dialog = (MaterialDialog) getDialog(); dialog.setTitle(parentFolder.getAbsolutePath()); dialog.setItems((CharSequence[]) getContentsArray()); } @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putString("current_path", parentFolder.getAbsolutePath()); } private static class FolderSorter implements Comparator { @Override public int compare(File lhs, File rhs) { return lhs.getName().compareTo(rhs.getName()); } } } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/SleepTimerDialog.java b/app/src/main/java/code/name/monkey/retromusic/dialogs/SleepTimerDialog.java index 29a43012..abfad350 100755 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/SleepTimerDialog.java +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/SleepTimerDialog.java @@ -5,7 +5,6 @@ import android.app.PendingIntent; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; -import android.content.res.ColorStateList; import android.graphics.PorterDuff; import android.graphics.drawable.ClipDrawable; import android.graphics.drawable.LayerDrawable; @@ -20,10 +19,8 @@ import android.widget.TextView; import android.widget.Toast; import com.google.android.material.button.MaterialButton; -import com.google.android.material.textfield.TextInputLayout; import java.util.Locale; -import java.util.Objects; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -31,6 +28,7 @@ import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import code.name.monkey.appthemehelper.ThemeStore; +import code.name.monkey.appthemehelper.util.MaterialUtil; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.service.MusicService; import code.name.monkey.retromusic.util.MusicUtil; @@ -89,17 +87,15 @@ public class SleepTimerDialog extends RoundedBottomSheetDialogFragment { @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - int accentColor = ThemeStore.accentColor(Objects.requireNonNull(getContext())); - setButton.setBackgroundTintList(ColorStateList.valueOf(accentColor)); - cancelButton.setStrokeColor(ColorStateList.valueOf(accentColor)); - cancelButton.setTextColor(accentColor); + MaterialUtil.setTint(setButton, true); + MaterialUtil.setTint(cancelButton, false); title.setTextColor(ThemeStore.textColorPrimary(getContext())); timerDisplay.setTextColor(ThemeStore.textColorSecondary(getContext())); timerUpdater = new TimerUpdater(); - seekArcProgress = PreferenceUtil.getInstance(getActivity()).getLastSleepTimerValue(); + seekArcProgress = PreferenceUtil.getInstance().getLastSleepTimerValue(); updateTimeDisplayTime(); seekArc.setProgress(seekArcProgress); setProgressBarColor(ThemeStore.accentColor(getContext())); @@ -122,7 +118,7 @@ public class SleepTimerDialog extends RoundedBottomSheetDialogFragment { @Override public void onStopTrackingTouch(SeekBar seekBar) { - PreferenceUtil.getInstance(getActivity()).setLastSleepTimerValue(seekArcProgress); + PreferenceUtil.getInstance().setLastSleepTimerValue(seekArcProgress); } }); } @@ -151,7 +147,7 @@ public class SleepTimerDialog extends RoundedBottomSheetDialogFragment { final int minutes = seekArcProgress; PendingIntent pi = makeTimerPendingIntent(PendingIntent.FLAG_CANCEL_CURRENT); final long nextSleepTimerElapsedTime = SystemClock.elapsedRealtime() + minutes * 60 * 1000; - PreferenceUtil.getInstance(getActivity()).setNextSleepTimerElapsedRealtime(nextSleepTimerElapsedTime); + PreferenceUtil.getInstance().setNextSleepTimerElapsedRealtime(nextSleepTimerElapsedTime); AlarmManager am = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE); if (am != null) { am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextSleepTimerElapsedTime, pi); @@ -178,7 +174,7 @@ public class SleepTimerDialog extends RoundedBottomSheetDialogFragment { private class TimerUpdater extends CountDownTimer { TimerUpdater() { //noinspection ConstantConditions - super(PreferenceUtil.getInstance(getActivity()).getNextSleepTimerElapsedRealTime() - SystemClock.elapsedRealtime(), 1000); + super(PreferenceUtil.getInstance().getNextSleepTimerElapsedRealTime() - SystemClock.elapsedRealtime(), 1000); } @Override diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/SongShareDialog.java b/app/src/main/java/code/name/monkey/retromusic/dialogs/SongShareDialog.java index 92a49a38..96b70347 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/SongShareDialog.java +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/SongShareDialog.java @@ -3,17 +3,17 @@ package code.name.monkey.retromusic.dialogs; import android.annotation.SuppressLint; import android.content.Intent; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; +import code.name.monkey.appthemehelper.ThemeStore; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.util.MusicUtil; @@ -21,8 +21,12 @@ import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment; public class SongShareDialog extends RoundedBottomSheetDialogFragment { + @BindView(R.id.option_1) + TextView audioFile; @BindView(R.id.option_2) - TextView currentSong; + TextView audioText; + @BindView(R.id.title) + TextView title; @NonNull public static SongShareDialog create(final Song song) { @@ -46,7 +50,11 @@ public class SongShareDialog extends RoundedBottomSheetDialogFragment { public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); final Song song = getArguments().getParcelable("song"); - currentSong.setText(getString(R.string.currently_listening_to_x_by_x, song.title, song.artistName)); + + audioFile.setText(getString(R.string.currently_listening_to_x_by_x, song.title, song.artistName)); + audioFile.setTextColor(ThemeStore.textColorSecondary(getContext())); + audioText.setTextColor(ThemeStore.textColorSecondary(getContext())); + title.setTextColor(ThemeStore.textColorPrimary(getContext())); } @OnClick({R.id.option_2, R.id.option_1}) @@ -55,15 +63,13 @@ public class SongShareDialog extends RoundedBottomSheetDialogFragment { final String currentlyListening = getString(R.string.currently_listening_to_x_by_x, song.title, song.artistName); switch (view.getId()) { case R.id.option_1: - startActivity( - Intent.createChooser( - MusicUtil.createShareSongFileIntent(song, getContext()), null)); + startActivity(Intent.createChooser( + MusicUtil.createShareSongFileIntent(song, getContext()), null)); break; case R.id.option_2: - getActivity().startActivity(Intent.createChooser( - new Intent().setAction(Intent.ACTION_SEND) - .putExtra(Intent.EXTRA_TEXT, currentlyListening) - .setType("text/plain"), null)); + getActivity().startActivity(Intent.createChooser(new Intent().setAction(Intent.ACTION_SEND) + .putExtra(Intent.EXTRA_TEXT, currentlyListening) + .setType("text/plain"), null)); break; } dismiss(); 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 d1505250..968fdd17 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 @@ -26,7 +26,7 @@ import code.name.monkey.retromusic.util.CustomArtistImageUtil; public class ArtistGlideRequest { private static final int DEFAULT_ANIMATION = android.R.anim.fade_in; - private static final DiskCacheStrategy DEFAULT_DISK_CACHE_STRATEGY = DiskCacheStrategy.SOURCE; + private static final DiskCacheStrategy DEFAULT_DISK_CACHE_STRATEGY = DiskCacheStrategy.ALL; private static final int DEFAULT_ERROR_IMAGE = R.drawable.default_artist_art; private static DrawableTypeRequest createBaseRequest(RequestManager requestManager, Artist artist, @@ -129,6 +129,7 @@ public class ArtistGlideRequest { builder.forceDownload) .asBitmap() .transcode(new BitmapPaletteTranscoder(context), BitmapPaletteWrapper.class) + .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY) .error(DEFAULT_ERROR_IMAGE) .animate(DEFAULT_ANIMATION) diff --git a/app/src/main/java/code/name/monkey/retromusic/glide/RetroMusicColoredTarget.java b/app/src/main/java/code/name/monkey/retromusic/glide/RetroMusicColoredTarget.java index 79fc23aa..c20dd0a1 100644 --- a/app/src/main/java/code/name/monkey/retromusic/glide/RetroMusicColoredTarget.java +++ b/app/src/main/java/code/name/monkey/retromusic/glide/RetroMusicColoredTarget.java @@ -37,7 +37,7 @@ public abstract class RetroMusicColoredTarget extends BitmapPaletteTarget { int primaryColor = getColor(resource.getPalette(), defaultColor); int dominantColor = getDominantColor(resource.getBitmap(), defaultColor); - onColorReady(PreferenceUtil.getInstance(RetroApplication.getInstance()).isDominantColor() ? + onColorReady(PreferenceUtil.getInstance().isDominantColor() ? dominantColor : primaryColor); } 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 727804d3..0d44984c 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 @@ -63,7 +63,7 @@ public class SongGlideRequest { } public Builder checkIgnoreMediaStore(Context context) { - return ignoreMediaStore(PreferenceUtil.getInstance(context).ignoreMediaStoreArtwork()); + return ignoreMediaStore(PreferenceUtil.getInstance().ignoreMediaStoreArtwork()); } Builder ignoreMediaStore(boolean ignoreMediaStore) { diff --git a/app/src/main/java/code/name/monkey/retromusic/helper/MusicPlayerRemote.java b/app/src/main/java/code/name/monkey/retromusic/helper/MusicPlayerRemote.java index 04bbe7ec..c804d06d 100644 --- a/app/src/main/java/code/name/monkey/retromusic/helper/MusicPlayerRemote.java +++ b/app/src/main/java/code/name/monkey/retromusic/helper/MusicPlayerRemote.java @@ -167,7 +167,7 @@ public class MusicPlayerRemote { public static void openQueue(final ArrayList queue, final int startPosition, final boolean startPlaying) { if (!tryToHandleOpenPlayingQueue(queue, startPosition, startPlaying) && musicService != null) { musicService.openQueue(queue, startPosition, startPlaying); - if (PreferenceUtil.getInstance(musicService).isShuffleModeOn()) + if (PreferenceUtil.getInstance().isShuffleModeOn()) setShuffleMode(MusicService.SHUFFLE_MODE_NONE); } } diff --git a/app/src/main/java/code/name/monkey/retromusic/helper/SortOrder.java b/app/src/main/java/code/name/monkey/retromusic/helper/SortOrder.java index da99cfc4..a88d3a18 100644 --- a/app/src/main/java/code/name/monkey/retromusic/helper/SortOrder.java +++ b/app/src/main/java/code/name/monkey/retromusic/helper/SortOrder.java @@ -19,155 +19,158 @@ import android.provider.MediaStore; */ public final class SortOrder { - /** - * This class is never instantiated - */ - public SortOrder() { - } + /** + * This class is never instantiated + */ + public SortOrder() { + } - /** - * Artist sort order entries. - */ - public interface ArtistSortOrder { + /** + * Artist sort order entries. + */ + public interface ArtistSortOrder { - /* Artist sort order A-Z */ - String ARTIST_A_Z = MediaStore.Audio.Artists.DEFAULT_SORT_ORDER; + /* Artist sort order A-Z */ + String ARTIST_A_Z = MediaStore.Audio.Artists.DEFAULT_SORT_ORDER; - /* Artist sort order Z-A */ - String ARTIST_Z_A = ARTIST_A_Z + " DESC"; + /* Artist sort order Z-A */ + String ARTIST_Z_A = ARTIST_A_Z + " DESC"; - /* Artist sort order number of songs */ - String ARTIST_NUMBER_OF_SONGS = MediaStore.Audio.Artists.NUMBER_OF_TRACKS - + " DESC"; + /* Artist sort order number of songs */ + String ARTIST_NUMBER_OF_SONGS = MediaStore.Audio.Artists.NUMBER_OF_TRACKS + + " DESC"; - /* Artist sort order number of albums */ - String ARTIST_NUMBER_OF_ALBUMS = MediaStore.Audio.Artists.NUMBER_OF_ALBUMS - + " DESC"; - } + /* Artist sort order number of albums */ + String ARTIST_NUMBER_OF_ALBUMS = MediaStore.Audio.Artists.NUMBER_OF_ALBUMS + + " DESC"; + } - /** - * Album sort order entries. - */ - public interface AlbumSortOrder { + /** + * Album sort order entries. + */ + public interface AlbumSortOrder { - /* Album sort order A-Z */ - String ALBUM_A_Z = MediaStore.Audio.Albums.DEFAULT_SORT_ORDER; + /* Album sort order A-Z */ + String ALBUM_A_Z = MediaStore.Audio.Albums.DEFAULT_SORT_ORDER; - /* Album sort order Z-A */ - String ALBUM_Z_A = ALBUM_A_Z + " DESC"; + /* Album sort order Z-A */ + String ALBUM_Z_A = ALBUM_A_Z + " DESC"; - /* Album sort order songs */ - String ALBUM_NUMBER_OF_SONGS = MediaStore.Audio.Albums.NUMBER_OF_SONGS - + " DESC"; + /* Album sort order songs */ + String ALBUM_NUMBER_OF_SONGS = MediaStore.Audio.Albums.NUMBER_OF_SONGS + + " DESC"; - /* Album sort order artist */ - String ALBUM_ARTIST = MediaStore.Audio.Artists.DEFAULT_SORT_ORDER - + ", " + MediaStore.Audio.Albums.DEFAULT_SORT_ORDER; + /* Album sort order artist */ + String ALBUM_ARTIST = MediaStore.Audio.Artists.DEFAULT_SORT_ORDER + + ", " + MediaStore.Audio.Albums.DEFAULT_SORT_ORDER; - /* Album sort order year */ - String ALBUM_YEAR = MediaStore.Audio.Media.YEAR + " DESC"; - } + /* Album sort order year */ + String ALBUM_YEAR = MediaStore.Audio.Media.YEAR + " DESC"; + } - /** - * Song sort order entries. - */ - public interface SongSortOrder { + /** + * Song sort order entries. + */ + public interface SongSortOrder { - /* Song sort order A-Z */ - String SONG_A_Z = MediaStore.Audio.Media.DEFAULT_SORT_ORDER; + /* Song sort order A-Z */ + String SONG_A_Z = MediaStore.Audio.Media.DEFAULT_SORT_ORDER; - /* Song sort order Z-A */ - String SONG_Z_A = SONG_A_Z + " DESC"; + /* Song sort order Z-A */ + String SONG_Z_A = SONG_A_Z + " DESC"; - /* Song sort order artist */ - String SONG_ARTIST = MediaStore.Audio.Artists.DEFAULT_SORT_ORDER; + /* Song sort order artist */ + String SONG_ARTIST = MediaStore.Audio.Artists.DEFAULT_SORT_ORDER; - /* Song sort order album */ - String SONG_ALBUM = MediaStore.Audio.Albums.DEFAULT_SORT_ORDER; + /* Song sort order album */ + String SONG_ALBUM = MediaStore.Audio.Albums.DEFAULT_SORT_ORDER; - /* Song sort order year */ - String SONG_YEAR = MediaStore.Audio.Media.YEAR + " DESC"; + /* Song sort order year */ + String SONG_YEAR = MediaStore.Audio.Media.YEAR + " DESC"; - /* Song sort order duration */ - String SONG_DURATION = MediaStore.Audio.Media.DURATION + " DESC"; + /* Song sort order duration */ + String SONG_DURATION = MediaStore.Audio.Media.DURATION + " DESC"; - /* Song sort order date */ - String SONG_DATE = MediaStore.Audio.Media.DATE_ADDED + " DESC"; - } + /* Song sort order date */ + String SONG_DATE = MediaStore.Audio.Media.DATE_ADDED + " DESC"; - /** - * Album song sort order entries. - */ - public interface AlbumSongSortOrder { + /* Song sort order date */ + String COMPOSER = MediaStore.Audio.Media.COMPOSER; + } - /* Album song sort order A-Z */ - String SONG_A_Z = MediaStore.Audio.Media.DEFAULT_SORT_ORDER; + /** + * Album song sort order entries. + */ + public interface AlbumSongSortOrder { - /* Album song sort order Z-A */ - String SONG_Z_A = SONG_A_Z + " DESC"; + /* Album song sort order A-Z */ + String SONG_A_Z = MediaStore.Audio.Media.DEFAULT_SORT_ORDER; - /* Album song sort order track list */ - String SONG_TRACK_LIST = MediaStore.Audio.Media.TRACK + ", " - + MediaStore.Audio.Media.DEFAULT_SORT_ORDER; + /* Album song sort order Z-A */ + String SONG_Z_A = SONG_A_Z + " DESC"; - /* Album song sort order duration */ - String SONG_DURATION = SongSortOrder.SONG_DURATION; - } + /* Album song sort order track list */ + String SONG_TRACK_LIST = MediaStore.Audio.Media.TRACK + ", " + + MediaStore.Audio.Media.DEFAULT_SORT_ORDER; - /** - * Artist song sort order entries. - */ - public interface ArtistSongSortOrder { + /* Album song sort order duration */ + String SONG_DURATION = SongSortOrder.SONG_DURATION; + } - /* Artist song sort order A-Z */ - String SONG_A_Z = MediaStore.Audio.Media.DEFAULT_SORT_ORDER; + /** + * Artist song sort order entries. + */ + public interface ArtistSongSortOrder { - /* Artist song sort order Z-A */ - String SONG_Z_A = SONG_A_Z + " DESC"; + /* Artist song sort order A-Z */ + String SONG_A_Z = MediaStore.Audio.Media.DEFAULT_SORT_ORDER; - /* Artist song sort order album */ - String SONG_ALBUM = MediaStore.Audio.Media.ALBUM; + /* Artist song sort order Z-A */ + String SONG_Z_A = SONG_A_Z + " DESC"; - /* Artist song sort order year */ - String SONG_YEAR = MediaStore.Audio.Media.YEAR + " DESC"; + /* Artist song sort order album */ + String SONG_ALBUM = MediaStore.Audio.Media.ALBUM; - /* Artist song sort order duration */ - String SONG_DURATION = MediaStore.Audio.Media.DURATION + " DESC"; + /* Artist song sort order year */ + String SONG_YEAR = MediaStore.Audio.Media.YEAR + " DESC"; - /* Artist song sort order date */ - String SONG_DATE = MediaStore.Audio.Media.DATE_ADDED + " DESC"; - } + /* Artist song sort order duration */ + String SONG_DURATION = MediaStore.Audio.Media.DURATION + " DESC"; - /** - * Artist album sort order entries. - */ - public interface ArtistAlbumSortOrder { + /* Artist song sort order date */ + String SONG_DATE = MediaStore.Audio.Media.DATE_ADDED + " DESC"; + } - /* Artist album sort order A-Z */ - String ALBUM_A_Z = MediaStore.Audio.Albums.DEFAULT_SORT_ORDER; + /** + * Artist album sort order entries. + */ + public interface ArtistAlbumSortOrder { - /* Artist album sort order Z-A */ - String ALBUM_Z_A = ALBUM_A_Z + " DESC"; + /* Artist album sort order A-Z */ + String ALBUM_A_Z = MediaStore.Audio.Albums.DEFAULT_SORT_ORDER; - /* Artist album sort order year */ - String ALBUM_YEAR = MediaStore.Audio.Media.YEAR - + " DESC"; + /* Artist album sort order Z-A */ + String ALBUM_Z_A = ALBUM_A_Z + " DESC"; - /* Artist album sort order year */ - String ALBUM_YEAR_ASC = MediaStore.Audio.Media.YEAR - + " ASC"; - } + /* Artist album sort order year */ + String ALBUM_YEAR = MediaStore.Audio.Media.YEAR + + " DESC"; - /** - * Genre sort order entries. - */ - public interface GenreSortOrder { + /* Artist album sort order year */ + String ALBUM_YEAR_ASC = MediaStore.Audio.Media.YEAR + + " ASC"; + } - /* Genre sort order A-Z */ - String GENRE_A_Z = MediaStore.Audio.Genres.DEFAULT_SORT_ORDER; + /** + * Genre sort order entries. + */ + public interface GenreSortOrder { - /* Genre sort order Z-A */ - String ALBUM_Z_A = GENRE_A_Z + " DESC"; - } + /* Genre sort order A-Z */ + String GENRE_A_Z = MediaStore.Audio.Genres.DEFAULT_SORT_ORDER; + + /* Genre sort order Z-A */ + String ALBUM_Z_A = GENRE_A_Z + " DESC"; + } } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/AlbumLoader.java b/app/src/main/java/code/name/monkey/retromusic/loaders/AlbumLoader.java index a848a4b7..20052668 100644 --- a/app/src/main/java/code/name/monkey/retromusic/loaders/AlbumLoader.java +++ b/app/src/main/java/code/name/monkey/retromusic/loaders/AlbumLoader.java @@ -97,8 +97,8 @@ public class AlbumLoader { } public static String getSongLoaderSortOrder(Context context) { - return PreferenceUtil.getInstance(context).getAlbumSortOrder() + ", " + - //PreferenceUtil.getInstance(context).getAlbumSongSortOrder() + "," + - PreferenceUtil.getInstance(context).getAlbumDetailSongSortOrder(); + return PreferenceUtil.getInstance().getAlbumSortOrder() + ", " + + //PreferenceUtil.getInstance().getAlbumSongSortOrder() + "," + + PreferenceUtil.getInstance().getAlbumDetailSongSortOrder(); } } diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/ArtistLoader.java b/app/src/main/java/code/name/monkey/retromusic/loaders/ArtistLoader.java index bab82011..94e08244 100644 --- a/app/src/main/java/code/name/monkey/retromusic/loaders/ArtistLoader.java +++ b/app/src/main/java/code/name/monkey/retromusic/loaders/ArtistLoader.java @@ -14,10 +14,10 @@ import io.reactivex.Observable; public class ArtistLoader { private static String getSongLoaderSortOrder(Context context) { - return PreferenceUtil.getInstance(context).getArtistSortOrder() + ", " + - PreferenceUtil.getInstance(context).getArtistAlbumSortOrder() + ", " + - PreferenceUtil.getInstance(context).getAlbumDetailSongSortOrder() + ", " + - PreferenceUtil.getInstance(context).getArtistDetailSongSortOrder(); + return PreferenceUtil.getInstance().getArtistSortOrder() + ", " + + PreferenceUtil.getInstance().getArtistAlbumSortOrder() + ", " + + PreferenceUtil.getInstance().getAlbumDetailSongSortOrder() + ", " + + PreferenceUtil.getInstance().getArtistDetailSongSortOrder(); } @NonNull diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/ArtistSongLoader.java b/app/src/main/java/code/name/monkey/retromusic/loaders/ArtistSongLoader.java index ecd0c10b..1f1064bf 100644 --- a/app/src/main/java/code/name/monkey/retromusic/loaders/ArtistSongLoader.java +++ b/app/src/main/java/code/name/monkey/retromusic/loaders/ArtistSongLoader.java @@ -28,7 +28,7 @@ public class ArtistSongLoader extends SongLoader { new String[]{ String.valueOf(artistId) }, - PreferenceUtil.getInstance(context).getArtistSongSortOrder() + PreferenceUtil.getInstance().getArtistSongSortOrder() ); } catch (SecurityException e) { return null; diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/GenreLoader.java b/app/src/main/java/code/name/monkey/retromusic/loaders/GenreLoader.java index 5f738cf7..49e0e4f7 100644 --- a/app/src/main/java/code/name/monkey/retromusic/loaders/GenreLoader.java +++ b/app/src/main/java/code/name/monkey/retromusic/loaders/GenreLoader.java @@ -79,7 +79,7 @@ public class GenreLoader { try { return context.getContentResolver().query( Genres.Members.getContentUri("external", genreId), - SongLoader.BASE_PROJECTION, SongLoader.BASE_SELECTION, null, PreferenceUtil.getInstance(context).getSongSortOrder()); + SongLoader.BASE_PROJECTION, SongLoader.BASE_SELECTION, null, PreferenceUtil.getInstance().getSongSortOrder()); } catch (SecurityException e) { return null; } @@ -124,7 +124,7 @@ public class GenreLoader { try { return context.getContentResolver().query( Genres.EXTERNAL_CONTENT_URI, - projection, null, null, PreferenceUtil.getInstance(context).getGenreSortOrder()); + projection, null, null, PreferenceUtil.getInstance().getGenreSortOrder()); } catch (SecurityException e) { return null; } diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/GenreSongsLoader.java b/app/src/main/java/code/name/monkey/retromusic/loaders/GenreSongsLoader.java index 5dd87c53..f7f03017 100644 --- a/app/src/main/java/code/name/monkey/retromusic/loaders/GenreSongsLoader.java +++ b/app/src/main/java/code/name/monkey/retromusic/loaders/GenreSongsLoader.java @@ -4,13 +4,12 @@ import android.content.Context; import android.database.Cursor; import android.provider.MediaStore; import android.provider.MediaStore.Audio.AudioColumns; -import androidx.annotation.NonNull; - -import code.name.monkey.retromusic.model.Song; import java.util.ArrayList; import java.util.List; +import androidx.annotation.NonNull; +import code.name.monkey.retromusic.model.Song; import io.reactivex.Observable; /** @@ -19,7 +18,7 @@ import io.reactivex.Observable; public class GenreSongsLoader { - public static Observable> getGenreSongsList(@NonNull Context context, @NonNull int genreId) { + public static Observable> getGenreSongsList(@NonNull Context context, int genreId) { return Observable.create(e -> { ArrayList list = new ArrayList<>(); Cursor cursor = makeGenreSongCursor(context, genreId); @@ -49,8 +48,9 @@ public class GenreSongsLoader { final String albumName = cursor.getString(8); final int artistId = cursor.getInt(9); final String artistName = cursor.getString(10); + final String composer = cursor.getString(11); - return new Song(id, title, trackNumber, year, duration, data, dateModified, albumId, albumName, artistId, artistName); + return new Song(id, title, trackNumber, year, duration, data, dateModified, albumId, albumName, artistId, artistName, composer); } private static Cursor makeGenreSongCursor(Context context, long genreId) { @@ -69,6 +69,7 @@ public class GenreSongsLoader { AudioColumns.ALBUM,// 8 AudioColumns.ARTIST_ID,// 9 AudioColumns.ARTIST,// 10 + AudioColumns.COMPOSER,// 11 }, SongLoader.BASE_SELECTION, null, MediaStore.Audio.Genres.Members.DEFAULT_SORT_ORDER); } catch (SecurityException e) { diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/LastAddedSongsLoader.java b/app/src/main/java/code/name/monkey/retromusic/loaders/LastAddedSongsLoader.java index 0e664c2d..7a7d37c5 100644 --- a/app/src/main/java/code/name/monkey/retromusic/loaders/LastAddedSongsLoader.java +++ b/app/src/main/java/code/name/monkey/retromusic/loaders/LastAddedSongsLoader.java @@ -4,12 +4,11 @@ import android.content.Context; import android.database.Cursor; import android.provider.MediaStore; +import java.util.ArrayList; + import code.name.monkey.retromusic.model.Album; import code.name.monkey.retromusic.model.Artist; import code.name.monkey.retromusic.model.Song; - -import java.util.ArrayList; - import code.name.monkey.retromusic.util.PreferenceUtil; import io.reactivex.Observable; import io.reactivex.annotations.NonNull; @@ -26,7 +25,7 @@ public class LastAddedSongsLoader { } public static Cursor makeLastAddedCursor(@NonNull final Context context) { - long cutoff = PreferenceUtil.getInstance(context).getLastAddedCutoff(); + long cutoff = PreferenceUtil.getInstance().getLastAddedCutoff(); return SongLoader.makeSongCursor( context, diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/PlaylistSongsLoader.java b/app/src/main/java/code/name/monkey/retromusic/loaders/PlaylistSongsLoader.java index 3c373b60..e4fb1492 100644 --- a/app/src/main/java/code/name/monkey/retromusic/loaders/PlaylistSongsLoader.java +++ b/app/src/main/java/code/name/monkey/retromusic/loaders/PlaylistSongsLoader.java @@ -5,14 +5,13 @@ import android.database.Cursor; import android.provider.MediaStore; import android.provider.MediaStore.Audio.AudioColumns; +import java.util.ArrayList; +import java.util.List; + import code.name.monkey.retromusic.model.AbsCustomPlaylist; import code.name.monkey.retromusic.model.Playlist; import code.name.monkey.retromusic.model.PlaylistSong; import code.name.monkey.retromusic.model.Song; - -import java.util.ArrayList; -import java.util.List; - import io.reactivex.Observable; import io.reactivex.annotations.NonNull; @@ -65,11 +64,12 @@ public class PlaylistSongsLoader { final int artistId = cursor.getInt(9); final String artistName = cursor.getString(10); final int idInPlaylist = cursor.getInt(11); + final String composer = cursor.getString(12); - return new PlaylistSong(id, title, trackNumber, year, duration, data, dateModified, albumId, albumName, artistId, artistName, playlistId, idInPlaylist); + return new PlaylistSong(id, title, trackNumber, year, duration, data, dateModified, albumId, albumName, artistId, artistName, playlistId, idInPlaylist, composer); } - public static Cursor makePlaylistSongCursor(@NonNull final Context context, final int playlistId) { + private static Cursor makePlaylistSongCursor(@NonNull final Context context, final int playlistId) { try { return context.getContentResolver().query( MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId), @@ -85,7 +85,8 @@ public class PlaylistSongsLoader { AudioColumns.ALBUM,// 8 AudioColumns.ARTIST_ID,// 9 AudioColumns.ARTIST,// 10 - MediaStore.Audio.Playlists.Members._ID // 11 + MediaStore.Audio.Playlists.Members._ID, // 11 + AudioColumns.COMPOSER,// 12 }, SongLoader.BASE_SELECTION, null, MediaStore.Audio.Playlists.Members.DEFAULT_SORT_ORDER); } catch (SecurityException e) { diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/SongLoader.java b/app/src/main/java/code/name/monkey/retromusic/loaders/SongLoader.java index b89672aa..96f19c8c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/loaders/SongLoader.java +++ b/app/src/main/java/code/name/monkey/retromusic/loaders/SongLoader.java @@ -5,16 +5,18 @@ import android.database.Cursor; import android.provider.BaseColumns; import android.provider.MediaStore; import android.provider.MediaStore.Audio.AudioColumns; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import java.util.ArrayList; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import code.name.monkey.retromusic.helper.ShuffleHelper; import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.providers.BlacklistStore; import code.name.monkey.retromusic.util.PreferenceUtil; import io.reactivex.Observable; +import io.reactivex.ObservableSource; +import io.reactivex.functions.Function; /** * Created by hemanths on 10/08/17. @@ -36,6 +38,7 @@ public class SongLoader { AudioColumns.ALBUM,// 8 AudioColumns.ARTIST_ID,// 9 AudioColumns.ARTIST,// 10 + AudioColumns.COMPOSER,// 11 }; @NonNull @@ -83,16 +86,17 @@ public class SongLoader { final String albumName = cursor.getString(8); final int artistId = cursor.getInt(9); final String artistName = cursor.getString(10); + final String composer = cursor.getString(11); return new Song(id, title, trackNumber, year, duration, data, dateModified, albumId, albumName, - artistId, artistName); + artistId, artistName, composer); } @Nullable public static Cursor makeSongCursor(@NonNull final Context context, @Nullable final String selection, final String[] selectionValues) { return makeSongCursor(context, selection, selectionValues, - PreferenceUtil.getInstance(context).getSongSortOrder()); + PreferenceUtil.getInstance().getSongSortOrder()); } @Nullable @@ -167,25 +171,28 @@ public class SongLoader { } public static Observable> suggestSongs(@NonNull Context context) { - return Observable.create(observer -> { - SongLoader.getAllSongs(context) - .subscribe(songs -> { - ArrayList list = new ArrayList<>(); - if (songs.isEmpty()) { - observer.onNext(new ArrayList<>()); - observer.onComplete(); - return; - } - ShuffleHelper.makeShuffleList(songs, -1); - if (songs.size() > 10) { - list.addAll(songs.subList(0, 10)); - } else { - list.addAll(songs); - } - observer.onNext(list); - observer.onComplete(); - }); - }); + return SongLoader.getAllSongs(context) + .flatMap((Function, ObservableSource>>) songs -> { + ArrayList list = new ArrayList<>(); + ShuffleHelper.makeShuffleList(songs, -1); + if (songs.size() > 10) { + list.addAll(songs.subList(0, 10)); + } + return Observable.just(list); + }); + /*.subscribe(songs -> { + ArrayList list = new ArrayList<>(); + if (songs.isEmpty()) { + return; + } + ShuffleHelper.makeShuffleList(songs, -1); + if (songs.size() > 10) { + list.addAll(songs.subList(0, 10)); + } else { + list.addAll(songs); + } + return; + });*/ } } diff --git a/app/src/main/java/code/name/monkey/retromusic/model/PlaylistSong.java b/app/src/main/java/code/name/monkey/retromusic/model/PlaylistSong.java index 80fecdff..18f162a7 100644 --- a/app/src/main/java/code/name/monkey/retromusic/model/PlaylistSong.java +++ b/app/src/main/java/code/name/monkey/retromusic/model/PlaylistSong.java @@ -4,17 +4,31 @@ import android.os.Parcel; import android.os.Parcelable; public class PlaylistSong extends Song { - public static final PlaylistSong EMPTY_PLAYLIST_SONG = new PlaylistSong(-1, "", -1, -1, -1, "", -1, -1, "", -1, "", -1, -1); + public static final PlaylistSong EMPTY_PLAYLIST_SONG = new PlaylistSong(-1, "", -1, -1, -1, "", -1, -1, "", -1, "", -1, -1, ""); + public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + public PlaylistSong createFromParcel(Parcel source) { + return new PlaylistSong(source); + } + public PlaylistSong[] newArray(int size) { + return new PlaylistSong[size]; + } + }; public final int playlistId; public final int idInPlayList; - public PlaylistSong(int id, String title, int trackNumber, int year, long duration, String data, int dateModified, int albumId, String albumName, int artistId, String artistName, final int playlistId, final int idInPlayList) { - super(id, title, trackNumber, year, duration, data, dateModified, albumId, albumName, artistId, artistName); + public PlaylistSong(int id, String title, int trackNumber, int year, long duration, String data, int dateModified, int albumId, String albumName, int artistId, String artistName, final int playlistId, final int idInPlayList, final String composer) { + super(id, title, trackNumber, year, duration, data, dateModified, albumId, albumName, artistId, artistName, composer); this.playlistId = playlistId; this.idInPlayList = idInPlayList; } + protected PlaylistSong(Parcel in) { + super(in); + this.playlistId = in.readInt(); + this.idInPlayList = in.readInt(); + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -45,7 +59,6 @@ public class PlaylistSong extends Song { '}'; } - @Override public int describeContents() { return 0; @@ -57,20 +70,4 @@ public class PlaylistSong extends Song { dest.writeInt(this.playlistId); dest.writeInt(this.idInPlayList); } - - protected PlaylistSong(Parcel in) { - super(in); - this.playlistId = in.readInt(); - this.idInPlayList = in.readInt(); - } - - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - public PlaylistSong createFromParcel(Parcel source) { - return new PlaylistSong(source); - } - - public PlaylistSong[] newArray(int size) { - return new PlaylistSong[size]; - } - }; } diff --git a/app/src/main/java/code/name/monkey/retromusic/model/Song.java b/app/src/main/java/code/name/monkey/retromusic/model/Song.java index ce7a63e1..3bc1bbf9 100644 --- a/app/src/main/java/code/name/monkey/retromusic/model/Song.java +++ b/app/src/main/java/code/name/monkey/retromusic/model/Song.java @@ -5,8 +5,16 @@ import android.os.Parcelable; public class Song implements Parcelable { - public static final Song EMPTY_SONG = new Song(-1, "", -1, -1, -1, "", -1, -1, "", -1, ""); + public static final Song EMPTY_SONG = new Song(-1, "", -1, -1, -1, "", -1, -1, "", -1, "", ""); + public static final Creator CREATOR = new Creator() { + public Song createFromParcel(Parcel source) { + return new Song(source); + } + public Song[] newArray(int size) { + return new Song[size]; + } + }; public final int id; public final String title; public final int trackNumber; @@ -18,8 +26,9 @@ public class Song implements Parcelable { public final String albumName; public final int artistId; public final String artistName; + public final String composer; - public Song(int id, String title, int trackNumber, int year, long duration, String data, long dateModified, int albumId, String albumName, int artistId, String artistName) { + public Song(int id, String title, int trackNumber, int year, long duration, String data, long dateModified, int albumId, String albumName, int artistId, String artistName, String composer) { this.id = id; this.title = title; this.trackNumber = trackNumber; @@ -31,6 +40,22 @@ public class Song implements Parcelable { this.albumName = albumName; this.artistId = artistId; this.artistName = artistName; + this.composer = composer; + } + + protected Song(Parcel in) { + this.id = in.readInt(); + this.title = in.readString(); + this.trackNumber = in.readInt(); + this.year = in.readInt(); + this.duration = in.readLong(); + this.data = in.readString(); + this.dateModified = in.readLong(); + this.albumId = in.readInt(); + this.albumName = in.readString(); + this.artistId = in.readInt(); + this.artistName = in.readString(); + this.composer = in.readString(); } @Override @@ -68,6 +93,7 @@ public class Song implements Parcelable { result = 31 * result + (albumName != null ? albumName.hashCode() : 0); result = 31 * result + artistId; result = 31 * result + (artistName != null ? artistName.hashCode() : 0); + result = 31 * result + (composer != null ? composer.hashCode() : 0); return result; } @@ -85,10 +111,10 @@ public class Song implements Parcelable { ", albumName='" + albumName + '\'' + ", artistId=" + artistId + ", artistName='" + artistName + '\'' + + ", composer='" + composer + '\'' + '}'; } - @Override public int describeContents() { return 0; @@ -107,29 +133,6 @@ public class Song implements Parcelable { dest.writeString(this.albumName); dest.writeInt(this.artistId); dest.writeString(this.artistName); + dest.writeString(this.composer); } - - protected Song(Parcel in) { - this.id = in.readInt(); - this.title = in.readString(); - this.trackNumber = in.readInt(); - this.year = in.readInt(); - this.duration = in.readLong(); - this.data = in.readString(); - this.dateModified = in.readLong(); - this.albumId = in.readInt(); - this.albumName = in.readString(); - this.artistId = in.readInt(); - this.artistName = in.readString(); - } - - public static final Creator CREATOR = new Creator() { - public Song createFromParcel(Parcel source) { - return new Song(source); - } - - public Song[] newArray(int size) { - return new Song[size]; - } - }; } diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/contract/HomeContract.java b/app/src/main/java/code/name/monkey/retromusic/mvp/contract/HomeContract.java index 59686c6b..b5dd863c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/mvp/contract/HomeContract.java +++ b/app/src/main/java/code/name/monkey/retromusic/mvp/contract/HomeContract.java @@ -2,10 +2,12 @@ package code.name.monkey.retromusic.mvp.contract; import java.util.ArrayList; +import code.name.monkey.retromusic.model.AbsCustomPlaylist; import code.name.monkey.retromusic.model.Album; import code.name.monkey.retromusic.model.Artist; import code.name.monkey.retromusic.model.Genre; import code.name.monkey.retromusic.model.Playlist; +import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.mvp.BasePresenter; import code.name.monkey.retromusic.mvp.BaseView; @@ -21,7 +23,9 @@ public interface HomeContract { void topAlbums(ArrayList albums); - void suggestions(ArrayList songs); + void suggestions(ArrayList songs); + + void playlists(ArrayList playlists); void geners(ArrayList songs); } diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/HomePresenter.java b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/HomePresenter.java index 35c9ffd1..3d6f435c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/HomePresenter.java +++ b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/HomePresenter.java @@ -1,7 +1,6 @@ package code.name.monkey.retromusic.mvp.presenter; import androidx.annotation.NonNull; -import code.name.monkey.retromusic.RetroApplication; import code.name.monkey.retromusic.mvp.Presenter; import code.name.monkey.retromusic.mvp.contract.HomeContract; import code.name.monkey.retromusic.util.PreferenceUtil; @@ -20,14 +19,11 @@ public class HomePresenter extends Presenter implements HomeContract.HomePresent loadRecentAlbums(); loadRecentArtists(); - loadTopAlbums(); loadTopArtists(); - - loadSuggestions(); - if (PreferenceUtil.getInstance(RetroApplication.getInstance()).isGenreShown()) loadGenres(); + if (PreferenceUtil.getInstance().isGenreShown()) loadGenres(); } @@ -40,9 +36,9 @@ public class HomePresenter extends Presenter implements HomeContract.HomePresent disposable.add(repository.getAllPlaylists() .observeOn(schedulerProvider.ui()) .subscribeOn(schedulerProvider.io()) - .subscribe(playlists -> { - if (!playlists.isEmpty()) { - view.suggestions(playlists); + .subscribe(playlist -> { + if (!playlist.isEmpty()) { + view.playlists(playlist); } }, throwable -> view.showEmptyView(), () -> view.completed())); @@ -107,7 +103,11 @@ public class HomePresenter extends Presenter implements HomeContract.HomePresent @Override public void loadSuggestions() { - + disposable.add(repository.getSuggestionSongs() + .observeOn(schedulerProvider.ui()) + .subscribeOn(schedulerProvider.io()) + .doOnSubscribe(disposable1 -> view.loading()) + .subscribe(songs -> view.suggestions(songs), throwable -> view.showEmptyView(), () -> view.completed())); } @Override diff --git a/app/src/main/java/code/name/monkey/retromusic/preferences/AlbumCoverStylePreferenceDialog.java b/app/src/main/java/code/name/monkey/retromusic/preferences/AlbumCoverStylePreferenceDialog.java index d8e0256c..00ba6286 100644 --- a/app/src/main/java/code/name/monkey/retromusic/preferences/AlbumCoverStylePreferenceDialog.java +++ b/app/src/main/java/code/name/monkey/retromusic/preferences/AlbumCoverStylePreferenceDialog.java @@ -44,7 +44,7 @@ public class AlbumCoverStylePreferenceDialog extends DialogFragment implements viewPager.setAdapter(new AlbumCoverStyleAdapter(getActivity())); viewPager.addOnPageChangeListener(this); viewPager.setPageMargin((int) ViewUtil.convertDpToPixel(32, getResources())); - viewPager.setCurrentItem(PreferenceUtil.getInstance(getActivity()).getAlbumCoverStyle().ordinal()); + viewPager.setCurrentItem(PreferenceUtil.getInstance().getAlbumCoverStyle().ordinal()); return new MaterialDialog.Builder(getActivity()) .title(R.string.pref_title_album_cover_style) @@ -67,7 +67,7 @@ public class AlbumCoverStylePreferenceDialog extends DialogFragment implements super.onDismiss(dialog); if (whichButtonClicked == DialogAction.POSITIVE) { AlbumCoverStyle nowPlayingScreen = AlbumCoverStyle.values()[viewPagerPosition]; - PreferenceUtil.getInstance(getActivity()).setAlbumCoverStyle(nowPlayingScreen); + PreferenceUtil.getInstance().setAlbumCoverStyle(nowPlayingScreen); } } diff --git a/app/src/main/java/code/name/monkey/retromusic/preferences/NowPlayingScreenPreferenceDialog.java b/app/src/main/java/code/name/monkey/retromusic/preferences/NowPlayingScreenPreferenceDialog.java index 83ab209a..e49bd8d2 100644 --- a/app/src/main/java/code/name/monkey/retromusic/preferences/NowPlayingScreenPreferenceDialog.java +++ b/app/src/main/java/code/name/monkey/retromusic/preferences/NowPlayingScreenPreferenceDialog.java @@ -48,7 +48,7 @@ public class NowPlayingScreenPreferenceDialog extends DialogFragment implements viewPager.setAdapter(new NowPlayingScreenAdapter(getActivity())); viewPager.addOnPageChangeListener(this); viewPager.setPageMargin((int) ViewUtil.convertDpToPixel(32, getResources())); - viewPager.setCurrentItem(PreferenceUtil.getInstance(getActivity()).getNowPlayingScreen().ordinal()); + viewPager.setCurrentItem(PreferenceUtil.getInstance().getNowPlayingScreen().ordinal()); return new MaterialDialog.Builder(getActivity()) .title(R.string.pref_title_now_playing_screen_appearance) @@ -76,7 +76,7 @@ public class NowPlayingScreenPreferenceDialog extends DialogFragment implements Toast.makeText(getContext(), result, Toast.LENGTH_SHORT).show(); NavigationUtil.goToProVersion(getActivity()); } else { - PreferenceUtil.getInstance(getActivity()).setNowPlayingScreen(nowPlayingScreen); + PreferenceUtil.getInstance().setNowPlayingScreen(nowPlayingScreen); } } } @@ -84,8 +84,8 @@ public class NowPlayingScreenPreferenceDialog extends DialogFragment implements private boolean isNowPlayingThemes(NowPlayingScreen nowPlayingScreen) { if (nowPlayingScreen.equals(NowPlayingScreen.BLUR_CARD)) { - PreferenceUtil.getInstance(getContext()).resetCarouselEffect(); - PreferenceUtil.getInstance(getContext()).resetCircularAlbumArt(); + PreferenceUtil.getInstance().resetCarouselEffect(); + PreferenceUtil.getInstance().resetCircularAlbumArt(); } return (nowPlayingScreen.equals(NowPlayingScreen.FULL) || diff --git a/app/src/main/java/code/name/monkey/retromusic/providers/BlacklistStore.java b/app/src/main/java/code/name/monkey/retromusic/providers/BlacklistStore.java index 3105c45c..8fd67d86 100644 --- a/app/src/main/java/code/name/monkey/retromusic/providers/BlacklistStore.java +++ b/app/src/main/java/code/name/monkey/retromusic/providers/BlacklistStore.java @@ -31,13 +31,13 @@ public class BlacklistStore extends SQLiteOpenHelper { public static synchronized BlacklistStore getInstance(@NonNull final Context context) { if (sInstance == null) { sInstance = new BlacklistStore(context.getApplicationContext()); - if (!PreferenceUtil.getInstance(context).initializedBlacklist()) { + if (!PreferenceUtil.getInstance().initializedBlacklist()) { // blacklisted by default sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_ALARMS)); sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_NOTIFICATIONS)); sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_RINGTONES)); - PreferenceUtil.getInstance(context).setInitializedBlacklist(); + PreferenceUtil.getInstance().setInitializedBlacklist(); } } return sInstance; diff --git a/app/src/main/java/code/name/monkey/retromusic/providers/MusicPlaybackQueueStore.java b/app/src/main/java/code/name/monkey/retromusic/providers/MusicPlaybackQueueStore.java index 5770072d..2dd3a7d0 100644 --- a/app/src/main/java/code/name/monkey/retromusic/providers/MusicPlaybackQueueStore.java +++ b/app/src/main/java/code/name/monkey/retromusic/providers/MusicPlaybackQueueStore.java @@ -41,7 +41,7 @@ public class MusicPlaybackQueueStore extends SQLiteOpenHelper { public static final String DATABASE_NAME = "music_playback_state.db"; public static final String PLAYING_QUEUE_TABLE_NAME = "playing_queue"; public static final String ORIGINAL_PLAYING_QUEUE_TABLE_NAME = "original_playing_queue"; - private static final int VERSION = 3; + private static final int VERSION = 4; @Nullable private static MusicPlaybackQueueStore sInstance = null; @@ -110,6 +110,9 @@ public class MusicPlaybackQueueStore extends SQLiteOpenHelper { builder.append(" INT NOT NULL,"); builder.append(AudioColumns.ARTIST); + builder.append(" STRING NOT NULL,"); + + builder.append(AudioColumns.COMPOSER); builder.append(" STRING NOT NULL);"); db.execSQL(builder.toString()); @@ -173,6 +176,7 @@ public class MusicPlaybackQueueStore extends SQLiteOpenHelper { values.put(AudioColumns.ALBUM, song.albumName); values.put(AudioColumns.ARTIST_ID, song.artistId); values.put(AudioColumns.ARTIST, song.artistName); + values.put(AudioColumns.COMPOSER, song.composer); database.insert(tableName, null, values); } diff --git a/app/src/main/java/code/name/monkey/retromusic/providers/RepositoryImpl.java b/app/src/main/java/code/name/monkey/retromusic/providers/RepositoryImpl.java index 8f6692df..5caffbc7 100644 --- a/app/src/main/java/code/name/monkey/retromusic/providers/RepositoryImpl.java +++ b/app/src/main/java/code/name/monkey/retromusic/providers/RepositoryImpl.java @@ -52,8 +52,8 @@ public class RepositoryImpl implements Repository { } @Override - public Observable> getSuggestionSongs() { - return HomeLoader.getRecentAndTopThings(context); + public Observable> getSuggestionSongs() { + return SongLoader.suggestSongs(context); } @Override diff --git a/app/src/main/java/code/name/monkey/retromusic/providers/interfaces/Repository.java b/app/src/main/java/code/name/monkey/retromusic/providers/interfaces/Repository.java index 0c15edd0..6d108550 100644 --- a/app/src/main/java/code/name/monkey/retromusic/providers/interfaces/Repository.java +++ b/app/src/main/java/code/name/monkey/retromusic/providers/interfaces/Repository.java @@ -18,7 +18,7 @@ public interface Repository { Observable> getAllSongs(); - Observable> getSuggestionSongs(); + Observable> getSuggestionSongs(); Observable getSong(int id); diff --git a/app/src/main/java/code/name/monkey/retromusic/rest/service/LastFMService.java b/app/src/main/java/code/name/monkey/retromusic/rest/service/LastFMService.java index 95af6488..984d1214 100644 --- a/app/src/main/java/code/name/monkey/retromusic/rest/service/LastFMService.java +++ b/app/src/main/java/code/name/monkey/retromusic/rest/service/LastFMService.java @@ -1,12 +1,9 @@ package code.name.monkey.retromusic.rest.service; import androidx.annotation.Nullable; - -import code.name.monkey.retromusic.BuildConfig; import code.name.monkey.retromusic.rest.model.LastFmAlbum; import code.name.monkey.retromusic.rest.model.LastFmArtist; import code.name.monkey.retromusic.rest.model.LastFmTrack; - import io.reactivex.Observable; import retrofit2.Call; import retrofit2.http.GET; @@ -14,18 +11,16 @@ import retrofit2.http.Header; import retrofit2.http.Query; - public interface LastFMService { - String API_KEY = "bd9c6ea4d55ec9ed3af7d276e5ece304"; - //String API_KEY = BuildConfig.LASTFM_API_KEY; - //String BASE_QUERY_PARAMETERS = "?format=json&autocorrect=1&api_key=" + API_KEY; + String API_KEY_BAK = "bd9c6ea4d55ec9ed3af7d276e5ece304"; + String API_KEY = "c679c8d3efa84613dc7dcb2e8d42da4c"; String BASE_QUERY_PARAMETERS = "?format=json&autocorrect=1&api_key=" + API_KEY; String METHOD_TRACK = "track.getInfo"; @GET(BASE_QUERY_PARAMETERS + "&method=album.getinfo") Observable getAlbumInfo(@Query("album") String albumName, @Query("artist") String artistName, @Nullable @Query("lang") String language); - @GET("?api_key=" + BuildConfig.LASTFM_API_KEY + "&format=json&autocorrect=1" + "&method=" + METHOD_TRACK) + @GET("?api_key=" + API_KEY + "&format=json&autocorrect=1" + "&method=" + METHOD_TRACK) Observable getTrackInfo(@Query("artist") String artist, @Query("track") String track); @GET(BASE_QUERY_PARAMETERS + "&method=artist.getinfo") diff --git a/app/src/main/java/code/name/monkey/retromusic/service/MultiPlayer.java b/app/src/main/java/code/name/monkey/retromusic/service/MultiPlayer.java index 729a93d6..d725f40b 100644 --- a/app/src/main/java/code/name/monkey/retromusic/service/MultiPlayer.java +++ b/app/src/main/java/code/name/monkey/retromusic/service/MultiPlayer.java @@ -115,7 +115,7 @@ public class MultiPlayer implements Playback, MediaPlayer.OnErrorListener, Media if (path == null) { return; } - if (PreferenceUtil.getInstance(context).gaplessPlayback()) { + if (PreferenceUtil.getInstance().gaplessPlayback()) { mNextMediaPlayer = new MediaPlayer(); mNextMediaPlayer.setWakeMode(context, PowerManager.PARTIAL_WAKE_LOCK); mNextMediaPlayer.setAudioSessionId(getAudioSessionId()); diff --git a/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java b/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java index 24b96494..02ca8437 100644 --- a/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java +++ b/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java @@ -27,8 +27,6 @@ import android.os.PowerManager; import android.os.Process; import android.preference.PreferenceManager; import android.provider.MediaStore; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import android.support.v4.media.MediaMetadataCompat; import android.support.v4.media.session.MediaSessionCompat; import android.support.v4.media.session.PlaybackStateCompat; @@ -37,7 +35,6 @@ import android.telephony.TelephonyManager; import android.util.Log; import android.widget.Toast; -import code.name.monkey.retromusic.service.notification.PlayingNotificationOreo; import com.bumptech.glide.BitmapRequestBuilder; import com.bumptech.glide.Glide; import com.bumptech.glide.request.animation.GlideAnimation; @@ -48,6 +45,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.appwidgets.AppWidgetBig; import code.name.monkey.retromusic.appwidgets.AppWidgetCard; @@ -66,6 +65,7 @@ import code.name.monkey.retromusic.providers.MusicPlaybackQueueStore; import code.name.monkey.retromusic.providers.SongPlayCountStore; import code.name.monkey.retromusic.service.notification.PlayingNotification; import code.name.monkey.retromusic.service.notification.PlayingNotificationImpl24; +import code.name.monkey.retromusic.service.notification.PlayingNotificationOreo; import code.name.monkey.retromusic.service.playback.Playback; import code.name.monkey.retromusic.util.MusicUtil; import code.name.monkey.retromusic.util.PreferenceUtil; @@ -295,7 +295,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP getContentResolver().registerContentObserver( MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, true, mediaStoreObserver); - PreferenceUtil.getInstance(this).registerOnSharedPreferenceChangedListener(this); + PreferenceUtil.getInstance().registerOnSharedPreferenceChangedListener(this); restoreState(); @@ -446,7 +446,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP quit(); releaseResources(); getContentResolver().unregisterContentObserver(mediaStoreObserver); - PreferenceUtil.getInstance(this).unregisterOnSharedPreferenceChangedListener(this); + PreferenceUtil.getInstance().unregisterOnSharedPreferenceChangedListener(this); wakeLock.release(); sendBroadcast(new Intent("code.name.monkey.retromusic.RETRO_MUSIC_MUSIC_SERVICE_DESTROYED")); @@ -627,7 +627,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP } public void initNotification() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && !PreferenceUtil.getInstance(this).classicNotification()) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && !PreferenceUtil.getInstance().classicNotification()) { playingNotification = new PlayingNotificationImpl24(); } else { playingNotification = new PlayingNotificationOreo(); @@ -672,12 +672,12 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP metaData.putLong(MediaMetadataCompat.METADATA_KEY_NUM_TRACKS, getPlayingQueue().size()); } - if (PreferenceUtil.getInstance(this).albumArtOnLockscreen()) { + if (PreferenceUtil.getInstance().albumArtOnLockscreen()) { final Point screenSize = RetroUtil.getScreenSize(MusicService.this); final BitmapRequestBuilder request = SongGlideRequest.Builder.from(Glide.with(MusicService.this), song) .checkIgnoreMediaStore(MusicService.this) .asBitmap().build(); - if (PreferenceUtil.getInstance(this).blurredAlbumArt()) { + if (PreferenceUtil.getInstance().blurredAlbumArt()) { request.transform(new BlurTransformation.Builder(MusicService.this).build()); } runOnUiThread(new Runnable() { @@ -1090,16 +1090,12 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP final Song song = getCurrentSong(); intent.putExtra("id", song.id); - intent.putExtra("artist", song.artistName); intent.putExtra("album", song.albumName); intent.putExtra("track", song.title); - intent.putExtra("duration", song.duration); intent.putExtra("position", (long) getSongProgressMillis()); - intent.putExtra("playing", isPlaying()); - intent.putExtra("scrobbling_source", RETRO_MUSIC_PACKAGE_NAME); sendStickyBroadcast(intent); @@ -1196,7 +1192,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP } private void registerHeadsetEvents() { - if (!headsetReceiverRegistered && PreferenceUtil.getInstance(this).getHeadsetPlugged()) { + if (!headsetReceiverRegistered && PreferenceUtil.getInstance().getHeadsetPlugged()) { registerReceiver(headsetReceiver, headsetReceiverIntentFilter); headsetReceiverRegistered = true; } @@ -1252,7 +1248,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP switch (msg.what) { case DUCK: - if (PreferenceUtil.getInstance(service).audioDucking()) { + if (PreferenceUtil.getInstance().audioDucking()) { currentDuckVolume -= .05f; if (currentDuckVolume > .2f) { sendEmptyMessageDelayed(DUCK, 10); @@ -1266,7 +1262,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP break; case UNDUCK: - if (PreferenceUtil.getInstance(service).audioDucking()) { + if (PreferenceUtil.getInstance().audioDucking()) { currentDuckVolume += .03f; if (currentDuckVolume < 1f) { sendEmptyMessageDelayed(UNDUCK, 10); @@ -1444,4 +1440,4 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP sendPublicIntent(PLAY_STATE_CHANGED); // for musixmatch synced lyrics } } -} +} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotification.java b/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotification.java index b4a59d5a..eb8eb89d 100644 --- a/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotification.java +++ b/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotification.java @@ -1,81 +1,82 @@ package code.name.monkey.retromusic.service.notification; -import static android.content.Context.NOTIFICATION_SERVICE; - import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.os.Build; + import androidx.annotation.RequiresApi; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.service.MusicService; +import static android.content.Context.NOTIFICATION_SERVICE; + public abstract class PlayingNotification { - protected static final float NOTIFICATION_CONTROLS_SIZE_MULTIPLIER = 1.0f; + protected static final float NOTIFICATION_CONTROLS_SIZE_MULTIPLIER = 1.0f; static final String NOTIFICATION_CHANNEL_ID = "playing_notification"; - private static final int NOTIFICATION_ID = 1; - private static final int NOTIFY_MODE_FOREGROUND = 1; - private static final int NOTIFY_MODE_BACKGROUND = 0; - protected MusicService service; - boolean stopped; - private int notifyMode = NOTIFY_MODE_BACKGROUND; - private NotificationManager notificationManager; + private static final int NOTIFICATION_ID = 1; + private static final int NOTIFY_MODE_FOREGROUND = 1; + private static final int NOTIFY_MODE_BACKGROUND = 0; + protected MusicService service; + boolean stopped; + private int notifyMode = NOTIFY_MODE_BACKGROUND; + private NotificationManager notificationManager; - public synchronized void init(MusicService service) { - this.service = service; - notificationManager = (NotificationManager) service.getSystemService(NOTIFICATION_SERVICE); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - createNotificationChannel(); - } - } - - public abstract void update(); - - public synchronized void stop() { - stopped = true; - service.stopForeground(true); - notificationManager.cancel(NOTIFICATION_ID); - } - - void updateNotifyModeAndPostNotification(Notification notification) { - int newNotifyMode; - if (service.isPlaying()) { - newNotifyMode = NOTIFY_MODE_FOREGROUND; - } else { - newNotifyMode = NOTIFY_MODE_BACKGROUND; + public synchronized void init(MusicService service) { + this.service = service; + notificationManager = (NotificationManager) service.getSystemService(NOTIFICATION_SERVICE); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + createNotificationChannel(); + } } - if (notifyMode != newNotifyMode && newNotifyMode == NOTIFY_MODE_BACKGROUND) { - service.stopForeground(false); + public abstract void update(); + + public synchronized void stop() { + stopped = true; + service.stopForeground(true); + notificationManager.cancel(NOTIFICATION_ID); } - if (newNotifyMode == NOTIFY_MODE_FOREGROUND) { - service.startForeground(NOTIFICATION_ID, notification); - } else if (newNotifyMode == NOTIFY_MODE_BACKGROUND) { - notificationManager.notify(NOTIFICATION_ID, notification); + void updateNotifyModeAndPostNotification(Notification notification) { + int newNotifyMode; + if (service.isPlaying()) { + newNotifyMode = NOTIFY_MODE_FOREGROUND; + } else { + newNotifyMode = NOTIFY_MODE_BACKGROUND; + } + + if (notifyMode != newNotifyMode && newNotifyMode == NOTIFY_MODE_BACKGROUND) { + service.stopForeground(false); + } + + if (newNotifyMode == NOTIFY_MODE_FOREGROUND) { + service.startForeground(NOTIFICATION_ID, notification); + } else if (newNotifyMode == NOTIFY_MODE_BACKGROUND) { + notificationManager.notify(NOTIFICATION_ID, notification); + } + + notifyMode = newNotifyMode; } - notifyMode = newNotifyMode; - } + @RequiresApi(26) + private void createNotificationChannel() { + NotificationChannel notificationChannel = notificationManager + .getNotificationChannel(NOTIFICATION_CHANNEL_ID); + if (notificationChannel == null) { + notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, + service.getString(R.string.playing_notification_name), + NotificationManager.IMPORTANCE_LOW); + notificationChannel + .setDescription(service.getString(R.string.playing_notification_description)); + notificationChannel.enableLights(false); + notificationChannel.enableVibration(false); + notificationChannel.setShowBadge(false); - @RequiresApi(26) - private void createNotificationChannel() { - NotificationChannel notificationChannel = notificationManager - .getNotificationChannel(NOTIFICATION_CHANNEL_ID); - if (notificationChannel == null) { - notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, - service.getString(R.string.playing_notification_name), - NotificationManager.IMPORTANCE_LOW); - notificationChannel - .setDescription(service.getString(R.string.playing_notification_description)); - notificationChannel.enableLights(false); - notificationChannel.enableVibration(false); - notificationChannel.setShowBadge(false); - - notificationManager.createNotificationChannel(notificationChannel); + notificationManager.createNotificationChannel(notificationChannel); + } } - } } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationImpl.java b/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationImpl.java index c2ab5de4..772029db 100644 --- a/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationImpl.java +++ b/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationImpl.java @@ -9,8 +9,6 @@ import android.content.Intent; import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.drawable.Drawable; -import androidx.annotation.Nullable; -import androidx.core.app.NotificationCompat; import android.text.TextUtils; import android.view.View; import android.widget.RemoteViews; @@ -20,6 +18,8 @@ import com.bumptech.glide.request.animation.GlideAnimation; import com.bumptech.glide.request.target.SimpleTarget; import com.bumptech.glide.request.target.Target; +import androidx.annotation.Nullable; +import androidx.core.app.NotificationCompat; import code.name.monkey.appthemehelper.util.ColorUtil; import code.name.monkey.appthemehelper.util.MaterialValueHelper; import code.name.monkey.retromusic.R; @@ -28,6 +28,7 @@ import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper; import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.service.MusicService; import code.name.monkey.retromusic.ui.activities.MainActivity; +import code.name.monkey.retromusic.ui.activities.NowPayingActivity; import code.name.monkey.retromusic.util.PreferenceUtil; import code.name.monkey.retromusic.util.RetroColorUtil; import code.name.monkey.retromusic.util.RetroUtil; @@ -76,7 +77,7 @@ public class PlayingNotificationImpl extends PlayingNotification { linkButtons(notificationLayout, notificationLayoutBig); - Intent action = new Intent(service, MainActivity.class); + Intent action = new Intent(service, NowPayingActivity.class); action.putExtra("expand", true); action.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); @@ -114,7 +115,7 @@ public class PlayingNotificationImpl extends PlayingNotification { public void onResourceReady(BitmapPaletteWrapper resource, GlideAnimation glideAnimation) { update(resource.getBitmap(), - PreferenceUtil.getInstance(service).isDominantColor() ? + PreferenceUtil.getInstance().isDominantColor() ? RetroColorUtil.getDominantColor(resource.getBitmap(), Color.TRANSPARENT) : RetroColorUtil.getColor(resource.getPalette(), Color.TRANSPARENT)); } @@ -135,7 +136,7 @@ public class PlayingNotificationImpl extends PlayingNotification { .setImageViewResource(R.id.image, R.drawable.default_album_art); } - if (!PreferenceUtil.getInstance(service).coloredNotification()) { + if (!PreferenceUtil.getInstance().coloredNotification()) { bgColor = Color.WHITE; } setBackgroundColor(bgColor); diff --git a/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationImpl24.java b/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationImpl24.java index d52c897f..a361d23a 100644 --- a/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationImpl24.java +++ b/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationImpl24.java @@ -1,10 +1,5 @@ package code.name.monkey.retromusic.service.notification; -import static code.name.monkey.retromusic.Constants.ACTION_QUIT; -import static code.name.monkey.retromusic.Constants.ACTION_REWIND; -import static code.name.monkey.retromusic.Constants.ACTION_SKIP; -import static code.name.monkey.retromusic.Constants.ACTION_TOGGLE_PAUSE; - import android.app.PendingIntent; import android.content.ComponentName; import android.content.Intent; @@ -13,131 +8,137 @@ import android.graphics.BitmapFactory; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.os.Build; -import androidx.core.app.NotificationCompat; -import androidx.media.app.NotificationCompat.MediaStyle; import android.text.Html; -import code.name.monkey.retromusic.Constants; -import code.name.monkey.retromusic.R; -import code.name.monkey.retromusic.RetroApplication; -import code.name.monkey.retromusic.glide.SongGlideRequest; -import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper; -import code.name.monkey.retromusic.model.Song; -import code.name.monkey.retromusic.service.MusicService; -import code.name.monkey.retromusic.ui.activities.MainActivity; -import code.name.monkey.retromusic.util.PreferenceUtil; -import code.name.monkey.retromusic.util.RetroColorUtil; + import com.bumptech.glide.Glide; import com.bumptech.glide.request.animation.GlideAnimation; import com.bumptech.glide.request.target.SimpleTarget; +import androidx.core.app.NotificationCompat; +import androidx.media.app.NotificationCompat.MediaStyle; +import code.name.monkey.retromusic.Constants; +import code.name.monkey.retromusic.R; +import code.name.monkey.retromusic.glide.SongGlideRequest; +import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper; +import code.name.monkey.retromusic.model.Song; +import code.name.monkey.retromusic.service.MusicService; +import code.name.monkey.retromusic.ui.activities.NowPayingActivity; +import code.name.monkey.retromusic.util.PreferenceUtil; +import code.name.monkey.retromusic.util.RetroColorUtil; + +import static code.name.monkey.retromusic.Constants.ACTION_QUIT; +import static code.name.monkey.retromusic.Constants.ACTION_REWIND; +import static code.name.monkey.retromusic.Constants.ACTION_SKIP; +import static code.name.monkey.retromusic.Constants.ACTION_TOGGLE_PAUSE; + public class PlayingNotificationImpl24 extends PlayingNotification { - @Override - public synchronized void update() { - stopped = false; + @Override + public synchronized void update() { + stopped = false; - final Song song = service.getCurrentSong(); - final boolean isPlaying = service.isPlaying(); + final Song song = service.getCurrentSong(); + final boolean isPlaying = service.isPlaying(); - final int playButtonResId = isPlaying ? R.drawable.ic_pause_white_24dp : - R.drawable.ic_play_arrow_white_24dp; + final int playButtonResId = isPlaying ? R.drawable.ic_pause_white_24dp : + R.drawable.ic_play_arrow_white_24dp; - Intent action = new Intent(service, MainActivity.class); - action.putExtra("expand", true); - action.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); - final PendingIntent clickIntent = PendingIntent - .getActivity(service, 0, action, PendingIntent.FLAG_UPDATE_CURRENT); + Intent action = new Intent(service, NowPayingActivity.class); + action.putExtra("expand", true); + action.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); + final PendingIntent clickIntent = PendingIntent + .getActivity(service, 0, action, PendingIntent.FLAG_UPDATE_CURRENT); - final ComponentName serviceName = new ComponentName(service, MusicService.class); - Intent intent = new Intent(Constants.ACTION_QUIT); - intent.setComponent(serviceName); - final PendingIntent deleteIntent = PendingIntent.getService(service, 0, intent, 0); + final ComponentName serviceName = new ComponentName(service, MusicService.class); + Intent intent = new Intent(Constants.ACTION_QUIT); + intent.setComponent(serviceName); + final PendingIntent deleteIntent = PendingIntent.getService(service, 0, intent, 0); - final int bigNotificationImageSize = service.getResources() - .getDimensionPixelSize(R.dimen.notification_big_image_size); - service.runOnUiThread(() -> SongGlideRequest.Builder.from(Glide.with(service), song) - .checkIgnoreMediaStore(service) - .generatePalette(service).build() - .into(new SimpleTarget(bigNotificationImageSize, - bigNotificationImageSize) { - @Override - public void onResourceReady(BitmapPaletteWrapper resource, - GlideAnimation glideAnimation) { - update(resource.getBitmap(), - PreferenceUtil.getInstance(RetroApplication.getInstance()).isDominantColor() ? - RetroColorUtil.getDominantColor(resource.getBitmap(), Color.TRANSPARENT) : - RetroColorUtil.getColor(resource.getPalette(), Color.TRANSPARENT)); - } + final int bigNotificationImageSize = service.getResources() + .getDimensionPixelSize(R.dimen.notification_big_image_size); + service.runOnUiThread(() -> SongGlideRequest.Builder.from(Glide.with(service), song) + .checkIgnoreMediaStore(service) + .generatePalette(service).build() + .into(new SimpleTarget(bigNotificationImageSize, + bigNotificationImageSize) { + @Override + public void onResourceReady(BitmapPaletteWrapper resource, + GlideAnimation glideAnimation) { + update(resource.getBitmap(), + PreferenceUtil.getInstance().isDominantColor() ? + RetroColorUtil.getDominantColor(resource.getBitmap(), Color.TRANSPARENT) : + RetroColorUtil.getColor(resource.getPalette(), Color.TRANSPARENT)); + } - @Override - public void onLoadFailed(Exception e, Drawable errorDrawable) { - update(null, Color.TRANSPARENT); - } + @Override + public void onLoadFailed(Exception e, Drawable errorDrawable) { + update(null, Color.TRANSPARENT); + } - void update(Bitmap bitmap, int color) { - if (bitmap == null) { - bitmap = BitmapFactory - .decodeResource(service.getResources(), R.drawable.default_album_art); - } - NotificationCompat.Action playPauseAction = new NotificationCompat.Action( - playButtonResId, - service.getString(R.string.action_play_pause), - retrievePlaybackAction(ACTION_TOGGLE_PAUSE)); + void update(Bitmap bitmap, int color) { + if (bitmap == null) { + bitmap = BitmapFactory + .decodeResource(service.getResources(), R.drawable.default_album_art); + } + NotificationCompat.Action playPauseAction = new NotificationCompat.Action( + playButtonResId, + service.getString(R.string.action_play_pause), + retrievePlaybackAction(ACTION_TOGGLE_PAUSE)); - NotificationCompat.Action closeAction = new NotificationCompat.Action( - R.drawable.ic_close_white_24dp, - service.getString(R.string.close_notification), - retrievePlaybackAction(ACTION_QUIT)); + NotificationCompat.Action closeAction = new NotificationCompat.Action( + R.drawable.ic_close_white_24dp, + service.getString(R.string.close_notification), + retrievePlaybackAction(ACTION_QUIT)); - NotificationCompat.Action previousAction = new NotificationCompat.Action( - R.drawable.ic_skip_previous_white_24dp, - service.getString(R.string.action_previous), - retrievePlaybackAction(ACTION_REWIND)); + NotificationCompat.Action previousAction = new NotificationCompat.Action( + R.drawable.ic_skip_previous_white_24dp, + service.getString(R.string.action_previous), + retrievePlaybackAction(ACTION_REWIND)); - NotificationCompat.Action nextAction = new NotificationCompat.Action( - R.drawable.ic_skip_next_white_24dp, - service.getString(R.string.action_next), - retrievePlaybackAction(ACTION_SKIP)); + NotificationCompat.Action nextAction = new NotificationCompat.Action( + R.drawable.ic_skip_next_white_24dp, + service.getString(R.string.action_next), + retrievePlaybackAction(ACTION_SKIP)); - NotificationCompat.Builder builder = new NotificationCompat.Builder(service, - NOTIFICATION_CHANNEL_ID) - .setSmallIcon(R.drawable.ic_notification) - .setLargeIcon(bitmap) - .setContentIntent(clickIntent) - .setDeleteIntent(deleteIntent) - .setContentTitle(Html.fromHtml("" + song.title + "")) - .setContentText(song.artistName) - .setSubText(Html.fromHtml("" + song.albumName + "")) - .setOngoing(isPlaying) - .setShowWhen(false) - .addAction(previousAction) - .addAction(playPauseAction) - .addAction(nextAction) - .addAction(closeAction); + NotificationCompat.Builder builder = new NotificationCompat.Builder(service, + NOTIFICATION_CHANNEL_ID) + .setSmallIcon(R.drawable.ic_notification) + .setLargeIcon(bitmap) + .setContentIntent(clickIntent) + .setDeleteIntent(deleteIntent) + .setContentTitle(Html.fromHtml("" + song.title + "")) + .setContentText(song.artistName) + .setSubText(Html.fromHtml("" + song.albumName + "")) + .setOngoing(isPlaying) + .setShowWhen(false) + .addAction(previousAction) + .addAction(playPauseAction) + .addAction(nextAction) + .addAction(closeAction); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - builder.setStyle(new MediaStyle() - .setMediaSession(service.getMediaSession().getSessionToken()) - .setShowActionsInCompactView(0, 1, 2, 3, 4)) - .setVisibility(NotificationCompat.VISIBILITY_PUBLIC); - if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O && PreferenceUtil - .getInstance(service).coloredNotification()) { - builder.setColor(color); - } - } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + builder.setStyle(new MediaStyle() + .setMediaSession(service.getMediaSession().getSessionToken()) + .setShowActionsInCompactView(0, 1, 2, 3, 4)) + .setVisibility(NotificationCompat.VISIBILITY_PUBLIC); + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O && + PreferenceUtil.getInstance().coloredNotification()) { + builder.setColor(color); + } + } - if (stopped) { - return; // notification has been stopped before loading was finished - } - updateNotifyModeAndPostNotification(builder.build()); - } - })); - } + if (stopped) { + return; // notification has been stopped before loading was finished + } + updateNotifyModeAndPostNotification(builder.build()); + } + })); + } - private PendingIntent retrievePlaybackAction(final String action) { - final ComponentName serviceName = new ComponentName(service, MusicService.class); - Intent intent = new Intent(action); - intent.setComponent(serviceName); - return PendingIntent.getService(service, 0, intent, 0); - } + private PendingIntent retrievePlaybackAction(final String action) { + final ComponentName serviceName = new ComponentName(service, MusicService.class); + Intent intent = new Intent(action); + intent.setComponent(serviceName); + return PendingIntent.getService(service, 0, intent, 0); + } } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationOreo.java b/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationOreo.java index e0eea837..fdbf1a3c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationOreo.java +++ b/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationOreo.java @@ -1,11 +1,5 @@ package code.name.monkey.retromusic.service.notification; -import static code.name.monkey.retromusic.Constants.ACTION_QUIT; -import static code.name.monkey.retromusic.Constants.ACTION_REWIND; -import static code.name.monkey.retromusic.Constants.ACTION_SKIP; -import static code.name.monkey.retromusic.Constants.ACTION_TOGGLE_PAUSE; -import static code.name.monkey.retromusic.util.RetroUtil.createBitmap; - import android.app.PendingIntent; import android.content.ComponentName; import android.content.Context; @@ -14,9 +8,15 @@ import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.drawable.Drawable; +import android.widget.RemoteViews; + +import com.bumptech.glide.Glide; +import com.bumptech.glide.request.animation.GlideAnimation; +import com.bumptech.glide.request.target.SimpleTarget; +import com.bumptech.glide.request.target.Target; + import androidx.annotation.Nullable; import androidx.core.app.NotificationCompat; -import android.widget.RemoteViews; import code.name.monkey.appthemehelper.util.ColorUtil; import code.name.monkey.appthemehelper.util.MaterialValueHelper; import code.name.monkey.retromusic.R; @@ -24,223 +24,225 @@ import code.name.monkey.retromusic.glide.SongGlideRequest; import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper; import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.service.MusicService; -import code.name.monkey.retromusic.ui.activities.MainActivity; +import code.name.monkey.retromusic.ui.activities.NowPayingActivity; import code.name.monkey.retromusic.util.PreferenceUtil; import code.name.monkey.retromusic.util.RetroUtil; import code.name.monkey.retromusic.util.color.MediaNotificationProcessor; -import com.bumptech.glide.Glide; -import com.bumptech.glide.request.animation.GlideAnimation; -import com.bumptech.glide.request.target.SimpleTarget; -import com.bumptech.glide.request.target.Target; + +import static code.name.monkey.retromusic.Constants.ACTION_QUIT; +import static code.name.monkey.retromusic.Constants.ACTION_REWIND; +import static code.name.monkey.retromusic.Constants.ACTION_SKIP; +import static code.name.monkey.retromusic.Constants.ACTION_TOGGLE_PAUSE; +import static code.name.monkey.retromusic.util.RetroUtil.createBitmap; /** * @author Hemanth S (h4h13). */ public class PlayingNotificationOreo extends PlayingNotification { - private Target target; + private Target target; - private RemoteViews getCombinedRemoteViews(boolean collapsed, Song song) { - RemoteViews remoteViews = new RemoteViews(service.getPackageName(), - collapsed ? R.layout.layout_notification_collapsed : R.layout.layout_notification_expanded); + private RemoteViews getCombinedRemoteViews(boolean collapsed, Song song) { + RemoteViews remoteViews = new RemoteViews(service.getPackageName(), + collapsed ? R.layout.layout_notification_collapsed : R.layout.layout_notification_expanded); - remoteViews.setTextViewText(R.id.appName, - service.getString(R.string.app_name) + " • " + song.albumName); - remoteViews.setTextViewText(R.id.title, song.title); - remoteViews.setTextViewText(R.id.subtitle, song.artistName); + remoteViews.setTextViewText(R.id.appName, + service.getString(R.string.app_name) + " • " + song.albumName); + remoteViews.setTextViewText(R.id.title, song.title); + remoteViews.setTextViewText(R.id.subtitle, song.artistName); - TypedArray typedArray = service - .obtainStyledAttributes(new int[]{android.R.attr.selectableItemBackground}); - int selectableItemBackground = typedArray.getResourceId(0, 0); - typedArray.recycle(); + TypedArray typedArray = service + .obtainStyledAttributes(new int[]{android.R.attr.selectableItemBackground}); + int selectableItemBackground = typedArray.getResourceId(0, 0); + typedArray.recycle(); - remoteViews.setInt(R.id.content, "setBackgroundResource", selectableItemBackground); + remoteViews.setInt(R.id.content, "setBackgroundResource", selectableItemBackground); - linkButtons(remoteViews); + linkButtons(remoteViews); - //setNotificationContent(remoteViews, ColorUtil.isColorLight(backgroundColor)); - return remoteViews; - } - - @Override - public void update() { - stopped = false; - final Song song = service.getCurrentSong(); - final boolean isPlaying = service.isPlaying(); - - final RemoteViews notificationLayout = getCombinedRemoteViews(true, song); - final RemoteViews notificationLayoutBig = getCombinedRemoteViews(false, song); - - Intent action = new Intent(service, MainActivity.class); - action.putExtra("expand", true); - action.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); - - final PendingIntent clickIntent = PendingIntent - .getActivity(service, 0, action, PendingIntent.FLAG_UPDATE_CURRENT); - final PendingIntent deleteIntent = buildPendingIntent(service, ACTION_QUIT, null); - - final NotificationCompat.Builder builder = new NotificationCompat.Builder(service, - NOTIFICATION_CHANNEL_ID) - .setSmallIcon(R.drawable.ic_notification) - .setContentIntent(clickIntent) - .setDeleteIntent(deleteIntent) - .setCategory(NotificationCompat.CATEGORY_SERVICE) - .setPriority(NotificationCompat.PRIORITY_MAX) - .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) - .setCustomContentView(notificationLayout) - .setCustomBigContentView(notificationLayoutBig) - .setOngoing(isPlaying); - - final int bigNotificationImageSize = service.getResources() - .getDimensionPixelSize(R.dimen.notification_big_image_size); - service.runOnUiThread(new Runnable() { - @Override - public void run() { - if (target != null) { - Glide.clear(target); - } - target = SongGlideRequest.Builder.from(Glide.with(service), song) - .checkIgnoreMediaStore(service) - .generatePalette(service).build() - .into(new SimpleTarget(bigNotificationImageSize, - bigNotificationImageSize) { - @Override - public void onResourceReady(BitmapPaletteWrapper resource, - GlideAnimation glideAnimation) { - - MediaNotificationProcessor mediaNotificationProcessor = new MediaNotificationProcessor( - service, service, (i, i2) -> update(resource.getBitmap(), i, i2)); - mediaNotificationProcessor.processNotification(resource.getBitmap()); - - } - - @Override - public void onLoadFailed(Exception e, Drawable errorDrawable) { - super.onLoadFailed(e, errorDrawable); - update(null, Color.WHITE, Color.BLACK); - } - - private void update(@Nullable Bitmap bitmap, int bgColor, int textColor) { - if (bitmap != null) { - notificationLayout.setImageViewBitmap(R.id.largeIcon, bitmap); - notificationLayoutBig.setImageViewBitmap(R.id.largeIcon, bitmap); - } else { - notificationLayout - .setImageViewResource(R.id.largeIcon, R.drawable.default_album_art); - notificationLayoutBig - .setImageViewResource(R.id.largeIcon, R.drawable.default_album_art); - } - - if (!PreferenceUtil.getInstance(service).coloredNotification()) { - bgColor = Color.WHITE; - } - setBackgroundColor(bgColor); - setNotificationContent(ColorUtil.isColorLight(bgColor)); - - if (stopped) { - return; // notification has been stopped before loading was finished - } - updateNotifyModeAndPostNotification(builder.build()); - } - - private void setBackgroundColor(int color) { - - notificationLayout.setInt(R.id.image, "setBackgroundColor", color); - notificationLayoutBig.setInt(R.id.image, "setBackgroundColor", color); - - notificationLayout.setInt(R.id.foregroundImage, "setColorFilter", color); - notificationLayoutBig.setInt(R.id.foregroundImage, "setColorFilter", color); - } - - private void setNotificationContent(boolean dark) { - int primary = MaterialValueHelper.getPrimaryTextColor(service, dark); - int secondary = MaterialValueHelper.getSecondaryTextColor(service, dark); - - Bitmap close = createBitmap( - RetroUtil - .getTintedVectorDrawable(service, R.drawable.ic_close_white_24dp, primary), - NOTIFICATION_CONTROLS_SIZE_MULTIPLIER); - Bitmap prev = createBitmap( - RetroUtil - .getTintedVectorDrawable(service, R.drawable.ic_skip_previous_white_24dp, - primary), NOTIFICATION_CONTROLS_SIZE_MULTIPLIER); - Bitmap next = createBitmap( - RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_next_white_24dp, - primary), NOTIFICATION_CONTROLS_SIZE_MULTIPLIER); - Bitmap playPause = createBitmap(RetroUtil.getTintedVectorDrawable(service, - isPlaying ? R.drawable.ic_pause_white_24dp - : R.drawable.ic_play_arrow_white_24dp, primary), - NOTIFICATION_CONTROLS_SIZE_MULTIPLIER); - - notificationLayout.setTextColor(R.id.title, primary); - notificationLayout.setTextColor(R.id.subtitle, secondary); - notificationLayout.setTextColor(R.id.appName, secondary); - - notificationLayout.setImageViewBitmap(R.id.action_prev, prev); - notificationLayout.setImageViewBitmap(R.id.action_next, next); - notificationLayout.setImageViewBitmap(R.id.action_play_pause, playPause); - - notificationLayoutBig.setTextColor(R.id.title, primary); - notificationLayoutBig.setTextColor(R.id.subtitle, secondary); - notificationLayoutBig.setTextColor(R.id.appName, secondary); - - notificationLayoutBig.setImageViewBitmap(R.id.action_quit, close); - notificationLayoutBig.setImageViewBitmap(R.id.action_prev, prev); - notificationLayoutBig.setImageViewBitmap(R.id.action_next, next); - notificationLayoutBig.setImageViewBitmap(R.id.action_play_pause, playPause); - - notificationLayout.setImageViewBitmap(R.id.smallIcon, - createBitmap(RetroUtil - .getTintedVectorDrawable(service, R.drawable.ic_notification, secondary), - 0.6f)); - notificationLayoutBig.setImageViewBitmap(R.id.smallIcon, - createBitmap(RetroUtil - .getTintedVectorDrawable(service, R.drawable.ic_notification, secondary), - 0.6f)); - - notificationLayout.setInt(R.id.arrow, "setColorFilter", secondary); - notificationLayoutBig.setInt(R.id.arrow, "setColorFilter", secondary); - - } - }); - } - }); - - if (stopped) { - return; // notification has been stopped before loading was finished + //setNotificationContent(remoteViews, ColorUtil.isColorLight(backgroundColor)); + return remoteViews; + } + + @Override + public void update() { + stopped = false; + final Song song = service.getCurrentSong(); + final boolean isPlaying = service.isPlaying(); + + final RemoteViews notificationLayout = getCombinedRemoteViews(true, song); + final RemoteViews notificationLayoutBig = getCombinedRemoteViews(false, song); + + Intent action = new Intent(service, NowPayingActivity.class); + action.putExtra("expand", true); + action.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); + + final PendingIntent clickIntent = PendingIntent + .getActivity(service, 0, action, PendingIntent.FLAG_UPDATE_CURRENT); + final PendingIntent deleteIntent = buildPendingIntent(service, ACTION_QUIT, null); + + final NotificationCompat.Builder builder = new NotificationCompat.Builder(service, + NOTIFICATION_CHANNEL_ID) + .setSmallIcon(R.drawable.ic_notification) + .setContentIntent(clickIntent) + .setDeleteIntent(deleteIntent) + .setCategory(NotificationCompat.CATEGORY_SERVICE) + .setPriority(NotificationCompat.PRIORITY_MAX) + .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) + .setCustomContentView(notificationLayout) + .setCustomBigContentView(notificationLayoutBig) + .setOngoing(isPlaying); + + final int bigNotificationImageSize = service.getResources() + .getDimensionPixelSize(R.dimen.notification_big_image_size); + service.runOnUiThread(new Runnable() { + @Override + public void run() { + if (target != null) { + Glide.clear(target); + } + target = SongGlideRequest.Builder.from(Glide.with(service), song) + .checkIgnoreMediaStore(service) + .generatePalette(service).build() + .into(new SimpleTarget(bigNotificationImageSize, + bigNotificationImageSize) { + @Override + public void onResourceReady(BitmapPaletteWrapper resource, + GlideAnimation glideAnimation) { + + MediaNotificationProcessor mediaNotificationProcessor = new MediaNotificationProcessor( + service, service, (i, i2) -> update(resource.getBitmap(), i, i2)); + mediaNotificationProcessor.processNotification(resource.getBitmap()); + + } + + @Override + public void onLoadFailed(Exception e, Drawable errorDrawable) { + super.onLoadFailed(e, errorDrawable); + update(null, Color.WHITE, Color.BLACK); + } + + private void update(@Nullable Bitmap bitmap, int bgColor, int textColor) { + if (bitmap != null) { + notificationLayout.setImageViewBitmap(R.id.largeIcon, bitmap); + notificationLayoutBig.setImageViewBitmap(R.id.largeIcon, bitmap); + } else { + notificationLayout + .setImageViewResource(R.id.largeIcon, R.drawable.default_album_art); + notificationLayoutBig + .setImageViewResource(R.id.largeIcon, R.drawable.default_album_art); + } + + if (!PreferenceUtil.getInstance().coloredNotification()) { + bgColor = Color.WHITE; + } + setBackgroundColor(bgColor); + setNotificationContent(ColorUtil.isColorLight(bgColor)); + + if (stopped) { + return; // notification has been stopped before loading was finished + } + updateNotifyModeAndPostNotification(builder.build()); + } + + private void setBackgroundColor(int color) { + + notificationLayout.setInt(R.id.image, "setBackgroundColor", color); + notificationLayoutBig.setInt(R.id.image, "setBackgroundColor", color); + + notificationLayout.setInt(R.id.foregroundImage, "setColorFilter", color); + notificationLayoutBig.setInt(R.id.foregroundImage, "setColorFilter", color); + } + + private void setNotificationContent(boolean dark) { + int primary = MaterialValueHelper.getPrimaryTextColor(service, dark); + int secondary = MaterialValueHelper.getSecondaryTextColor(service, dark); + + Bitmap close = createBitmap( + RetroUtil + .getTintedVectorDrawable(service, R.drawable.ic_close_white_24dp, primary), + NOTIFICATION_CONTROLS_SIZE_MULTIPLIER); + Bitmap prev = createBitmap( + RetroUtil + .getTintedVectorDrawable(service, R.drawable.ic_skip_previous_white_24dp, + primary), NOTIFICATION_CONTROLS_SIZE_MULTIPLIER); + Bitmap next = createBitmap( + RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_next_white_24dp, + primary), NOTIFICATION_CONTROLS_SIZE_MULTIPLIER); + Bitmap playPause = createBitmap(RetroUtil.getTintedVectorDrawable(service, + isPlaying ? R.drawable.ic_pause_white_24dp + : R.drawable.ic_play_arrow_white_24dp, primary), + NOTIFICATION_CONTROLS_SIZE_MULTIPLIER); + + notificationLayout.setTextColor(R.id.title, primary); + notificationLayout.setTextColor(R.id.subtitle, secondary); + notificationLayout.setTextColor(R.id.appName, secondary); + + notificationLayout.setImageViewBitmap(R.id.action_prev, prev); + notificationLayout.setImageViewBitmap(R.id.action_next, next); + notificationLayout.setImageViewBitmap(R.id.action_play_pause, playPause); + + notificationLayoutBig.setTextColor(R.id.title, primary); + notificationLayoutBig.setTextColor(R.id.subtitle, secondary); + notificationLayoutBig.setTextColor(R.id.appName, secondary); + + notificationLayoutBig.setImageViewBitmap(R.id.action_quit, close); + notificationLayoutBig.setImageViewBitmap(R.id.action_prev, prev); + notificationLayoutBig.setImageViewBitmap(R.id.action_next, next); + notificationLayoutBig.setImageViewBitmap(R.id.action_play_pause, playPause); + + notificationLayout.setImageViewBitmap(R.id.smallIcon, + createBitmap(RetroUtil + .getTintedVectorDrawable(service, R.drawable.ic_notification, secondary), + 0.6f)); + notificationLayoutBig.setImageViewBitmap(R.id.smallIcon, + createBitmap(RetroUtil + .getTintedVectorDrawable(service, R.drawable.ic_notification, secondary), + 0.6f)); + + notificationLayout.setInt(R.id.arrow, "setColorFilter", secondary); + notificationLayoutBig.setInt(R.id.arrow, "setColorFilter", secondary); + + } + }); + } + }); + + if (stopped) { + return; // notification has been stopped before loading was finished + } + updateNotifyModeAndPostNotification(builder.build()); } - updateNotifyModeAndPostNotification(builder.build()); - } - private PendingIntent buildPendingIntent(Context context, final String action, - final ComponentName serviceName) { - Intent intent = new Intent(action); - intent.setComponent(serviceName); - return PendingIntent.getService(context, 0, intent, 0); - } + private PendingIntent buildPendingIntent(Context context, final String action, + final ComponentName serviceName) { + Intent intent = new Intent(action); + intent.setComponent(serviceName); + return PendingIntent.getService(context, 0, intent, 0); + } - private void linkButtons(final RemoteViews notificationLayout) { - PendingIntent pendingIntent; + private void linkButtons(final RemoteViews notificationLayout) { + PendingIntent pendingIntent; - final ComponentName serviceName = new ComponentName(service, MusicService.class); + final ComponentName serviceName = new ComponentName(service, MusicService.class); - // Previous track - pendingIntent = buildPendingIntent(service, ACTION_REWIND, serviceName); - notificationLayout.setOnClickPendingIntent(R.id.action_prev, pendingIntent); + // Previous track + pendingIntent = buildPendingIntent(service, ACTION_REWIND, serviceName); + notificationLayout.setOnClickPendingIntent(R.id.action_prev, pendingIntent); - // Play and pause - pendingIntent = buildPendingIntent(service, ACTION_TOGGLE_PAUSE, serviceName); - notificationLayout.setOnClickPendingIntent(R.id.action_play_pause, pendingIntent); + // Play and pause + pendingIntent = buildPendingIntent(service, ACTION_TOGGLE_PAUSE, serviceName); + notificationLayout.setOnClickPendingIntent(R.id.action_play_pause, pendingIntent); - // Next track - pendingIntent = buildPendingIntent(service, ACTION_SKIP, serviceName); - notificationLayout.setOnClickPendingIntent(R.id.action_next, pendingIntent); + // Next track + pendingIntent = buildPendingIntent(service, ACTION_SKIP, serviceName); + notificationLayout.setOnClickPendingIntent(R.id.action_next, pendingIntent); - // Close - pendingIntent = buildPendingIntent(service, ACTION_QUIT, serviceName); - notificationLayout.setOnClickPendingIntent(R.id.action_quit, pendingIntent); - } + // Close + pendingIntent = buildPendingIntent(service, ACTION_QUIT, serviceName); + notificationLayout.setOnClickPendingIntent(R.id.action_quit, pendingIntent); + } } diff --git a/app/src/main/java/code/name/monkey/retromusic/transform/CascadingPageTransformer.java b/app/src/main/java/code/name/monkey/retromusic/transform/CascadingPageTransformer.java index 2658cfcc..2f18ae9b 100644 --- a/app/src/main/java/code/name/monkey/retromusic/transform/CascadingPageTransformer.java +++ b/app/src/main/java/code/name/monkey/retromusic/transform/CascadingPageTransformer.java @@ -13,7 +13,6 @@ import androidx.viewpager.widget.ViewPager; * * * * * * * * * * *.Yang Web site:www.ocnyang.com *******************************************************************/ - public class CascadingPageTransformer implements ViewPager.PageTransformer { /** * 偏移量 diff --git a/app/src/main/java/code/name/monkey/retromusic/transform/DepthTransformation.java b/app/src/main/java/code/name/monkey/retromusic/transform/DepthTransformation.java new file mode 100644 index 00000000..6796f9cf --- /dev/null +++ b/app/src/main/java/code/name/monkey/retromusic/transform/DepthTransformation.java @@ -0,0 +1,30 @@ +package code.name.monkey.retromusic.transform; + +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.viewpager.widget.ViewPager; + +public class DepthTransformation implements ViewPager.PageTransformer { + @Override + public void transformPage(@NonNull View page, float position) { + if (position < -1) { // [-Infinity,-1) + // This page is way off-screen to the left. + page.setAlpha(0); + } else if (position <= 0) { // [-1,0] + page.setAlpha(1); + page.setTranslationX(0); + page.setScaleX(1); + page.setScaleY(1); + } else if (position <= 1) { // (0,1] + page.setTranslationX(-position * page.getWidth()); + page.setAlpha(1 - Math.abs(position)); + page.setScaleX(1 - Math.abs(position)); + page.setScaleY(1 - Math.abs(position)); + } else { // (1,+Infinity] + // This page is way off-screen to the right. + page.setAlpha(0); + + } + } +} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/transform/HingeTransformation.java b/app/src/main/java/code/name/monkey/retromusic/transform/HingeTransformation.java new file mode 100644 index 00000000..cedc2e65 --- /dev/null +++ b/app/src/main/java/code/name/monkey/retromusic/transform/HingeTransformation.java @@ -0,0 +1,35 @@ +package code.name.monkey.retromusic.transform; + +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.viewpager.widget.ViewPager; + +public class HingeTransformation implements ViewPager.PageTransformer { + @Override + public void transformPage(@NonNull View page, float position) { + + page.setTranslationX(-position * page.getWidth()); + page.setPivotX(0); + page.setPivotY(0); + + + if (position < -1) { // [-Infinity,-1) + // This page is way off-screen to the left. + page.setAlpha(0); + + } else if (position <= 0) { // [-1,0] + page.setRotation(90 * Math.abs(position)); + page.setAlpha(1 - Math.abs(position)); + + } else if (position <= 1) { // (0,1] + page.setRotation(0); + page.setAlpha(1); + + } else { // (1,+Infinity] + // This page is way off-screen to the right. + page.setAlpha(0); + + } + } +} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/transform/HorizontalFlipTransformation.java b/app/src/main/java/code/name/monkey/retromusic/transform/HorizontalFlipTransformation.java new file mode 100644 index 00000000..dfd12a89 --- /dev/null +++ b/app/src/main/java/code/name/monkey/retromusic/transform/HorizontalFlipTransformation.java @@ -0,0 +1,39 @@ +package code.name.monkey.retromusic.transform; + +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.viewpager.widget.ViewPager; + +public class HorizontalFlipTransformation implements ViewPager.PageTransformer { + @Override + public void transformPage(@NonNull View page, float position) { + + page.setTranslationX(-position * page.getWidth()); + page.setCameraDistance(20000); + + if (position < 0.5 && position > -0.5) { + page.setVisibility(View.VISIBLE); + } else { + page.setVisibility(View.INVISIBLE); + } + + + if (position < -1) { // [-Infinity,-1) + // This page is way off-screen to the left. + page.setAlpha(0); + + } else if (position <= 0) { // [-1,0] + page.setAlpha(1); + page.setRotationX(180 * (1 - Math.abs(position) + 1)); + + } else if (position <= 1) { // (0,1] + page.setAlpha(1); + page.setRotationX(-180 * (1 - Math.abs(position) + 1)); + + } else { // (1,+Infinity] + // This page is way off-screen to the right. + page.setAlpha(0); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/transform/VerticalFlipTransformation.java b/app/src/main/java/code/name/monkey/retromusic/transform/VerticalFlipTransformation.java new file mode 100644 index 00000000..2d7430bf --- /dev/null +++ b/app/src/main/java/code/name/monkey/retromusic/transform/VerticalFlipTransformation.java @@ -0,0 +1,42 @@ +package code.name.monkey.retromusic.transform; + +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.viewpager.widget.ViewPager; + +public class VerticalFlipTransformation implements ViewPager.PageTransformer { + @Override + public void transformPage(@NonNull View page, float position) { + + page.setTranslationX(-position * page.getWidth()); + page.setCameraDistance(100000); + + if (position < 0.5 && position > -0.5) { + page.setVisibility(View.VISIBLE); + } else { + page.setVisibility(View.INVISIBLE); + } + + + if (position < -1) { // [-Infinity,-1) + // This page is way off-screen to the left. + page.setAlpha(0); + + } else if (position <= 0) { // [-1,0] + page.setAlpha(1); + page.setRotationY(180 * (1 - Math.abs(position) + 1)); + + } else if (position <= 1) { // (0,1] + page.setAlpha(1); + page.setRotationY(-180 * (1 - Math.abs(position) + 1)); + + } else { // (1,+Infinity] + // This page is way off-screen to the right. + page.setAlpha(0); + + } + + + } +} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/AboutActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/AboutActivity.java index c5ae8eb5..fab16387 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/AboutActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/AboutActivity.java @@ -10,6 +10,7 @@ import android.view.View; import android.widget.TextView; import com.afollestad.materialdialogs.MaterialDialog; +import com.google.android.material.appbar.AppBarLayout; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; @@ -28,9 +29,9 @@ import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import code.name.monkey.appthemehelper.ThemeStore; +import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper; import code.name.monkey.retromusic.Constants; import code.name.monkey.retromusic.R; -import code.name.monkey.retromusic.dialogs.ChangelogDialog; import code.name.monkey.retromusic.model.Contributor; import code.name.monkey.retromusic.ui.activities.base.AbsBaseActivity; import code.name.monkey.retromusic.ui.adapter.ContributorAdapter; @@ -50,12 +51,12 @@ import static code.name.monkey.retromusic.Constants.TRANSLATE; public class AboutActivity extends AbsBaseActivity { + @BindView(R.id.app_bar) + AppBarLayout appBarLayout; + @BindView(R.id.toolbar) Toolbar toolbar; - @BindView(R.id.app_bar) - View background; - @BindView(R.id.app_version) TextView appVersion; @@ -73,7 +74,6 @@ public class AboutActivity extends AbsBaseActivity { setStatusbarColorAuto(); setNavigationbarColorAuto(); - setTaskDescriptionColorAuto(); setLightNavigationBar(true); loadContributors(); @@ -92,16 +92,15 @@ public class AboutActivity extends AbsBaseActivity { } private void setUpToolbar() { - title.setTextColor(ThemeStore.textColorPrimary(this)); - int primaryColor = ThemeStore.primaryColor(this); - toolbar.setBackgroundColor(primaryColor); - toolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp); - toolbar.setNavigationOnClickListener(v -> onBackPressed()); - setTitle(null); + appBarLayout.setBackgroundColor(ThemeStore.primaryColor(this)); + toolbar.setBackgroundColor(ThemeStore.primaryColor(this)); setSupportActionBar(toolbar); + //noinspection ConstantConditions + //getSupportActionBar().setDisplayHomeAsUpEnabled(true); + setTitle(null); + ToolbarContentTintHelper.colorBackButton(toolbar, ThemeStore.accentColor(this)); } - private void openUrl(String url) { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); @@ -166,7 +165,7 @@ public class AboutActivity extends AbsBaseActivity { if (position == 0) { openUrl(TELEGRAM_CHANGE_LOG); } else { - ChangelogDialog.create().show(getSupportFragmentManager(), "change-log"); + NavigationUtil.gotoWhatNews(AboutActivity.this); } } }) diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/AlbumDetailsActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/AlbumDetailsActivity.java index bf7ac040..455898ff 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/AlbumDetailsActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/AlbumDetailsActivity.java @@ -1,41 +1,42 @@ package code.name.monkey.retromusic.ui.activities; import android.content.Intent; +import android.graphics.Color; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import com.google.android.material.appbar.AppBarLayout; -import com.google.android.material.appbar.CollapsingToolbarLayout; -import com.google.android.material.floatingactionbutton.FloatingActionButton; -import androidx.core.content.ContextCompat; -import androidx.core.util.Pair; -import androidx.appcompat.widget.AppCompatTextView; -import androidx.recyclerview.widget.DefaultItemAnimator; -import androidx.recyclerview.widget.GridLayoutManager; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; -import androidx.appcompat.widget.Toolbar; +import android.transition.Slide; +import android.view.Gravity; import android.view.Menu; import android.view.MenuItem; import android.view.SubMenu; import android.view.View; import android.view.ViewGroup; -import android.view.ViewStub; +import android.view.animation.AnimationUtils; import android.widget.ImageView; import android.widget.TextView; import com.bumptech.glide.Glide; -import com.bumptech.glide.request.RequestListener; -import com.bumptech.glide.request.target.Target; +import com.google.android.material.appbar.AppBarLayout; +import com.google.android.material.appbar.CollapsingToolbarLayout; +import com.google.android.material.button.MaterialButton; import java.util.ArrayList; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatTextView; +import androidx.appcompat.widget.Toolbar; +import androidx.core.app.ActivityCompat; +import androidx.core.util.Pair; +import androidx.recyclerview.widget.DefaultItemAnimator; +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import code.name.monkey.appthemehelper.ThemeStore; -import code.name.monkey.appthemehelper.util.ATHUtil; import code.name.monkey.appthemehelper.util.ColorUtil; +import code.name.monkey.appthemehelper.util.MaterialUtil; import code.name.monkey.appthemehelper.util.TintHelper; import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper; import code.name.monkey.retromusic.R; @@ -44,7 +45,6 @@ import code.name.monkey.retromusic.dialogs.DeleteSongsDialog; import code.name.monkey.retromusic.glide.ArtistGlideRequest; import code.name.monkey.retromusic.glide.RetroMusicColoredTarget; import code.name.monkey.retromusic.glide.SongGlideRequest; -import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper; import code.name.monkey.retromusic.helper.MusicPlayerRemote; import code.name.monkey.retromusic.helper.SortOrder.AlbumSongSortOrder; import code.name.monkey.retromusic.loaders.ArtistLoader; @@ -85,7 +85,7 @@ public class AlbumDetailsActivity extends AbsSlidingMusicPanelActivity implement AppCompatTextView songTitle; @BindView(R.id.action_shuffle_all) - FloatingActionButton shuffleButton; + MaterialButton shuffleButton; @BindView(R.id.collapsing_toolbar) @Nullable @@ -108,35 +108,49 @@ public class AlbumDetailsActivity extends AbsSlidingMusicPanelActivity implement TextView moreTitle; @BindView(R.id.artist_image) + @Nullable ImageView artistImage; private AlbumDetailsPresenter albumDetailsPresenter; - private Album album; + private SimpleSongAdapter adapter; + private Album album; @Override protected View createContentView() { return wrapSlidingMusicPanel(R.layout.activity_album); } + void setupWindowTransition() { + Slide slide = new Slide(Gravity.BOTTOM); + slide.setInterpolator( + AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)); + getWindow().setEnterTransition(slide); + } + @Override protected void onCreate(Bundle savedInstanceState) { - setDrawUnderStatusBar(true); + setDrawUnderStatusBar(); + setupWindowTransition(); super.onCreate(savedInstanceState); ButterKnife.bind(this); - setBottomBarVisibility(View.GONE); - + toggleBottomNavigationView(true); setLightNavigationBar(true); setNavigationbarColorAuto(); - supportPostponeEnterTransition(); - setupToolbarMarginHeight(); + ActivityCompat.postponeEnterTransition(this); + adapter = new SimpleSongAdapter(this, new ArrayList<>(), R.layout.item_song); + recyclerView.setLayoutManager(new LinearLayoutManager(this)); + recyclerView.setItemAnimator(new DefaultItemAnimator()); + recyclerView.setNestedScrollingEnabled(false); + recyclerView.setAdapter(adapter); + + setupToolbarMarginHeight(); int albumId = getIntent().getIntExtra(EXTRA_ALBUM_ID, -1); albumDetailsPresenter = new AlbumDetailsPresenter(this, albumId); - } private void setupToolbarMarginHeight() { @@ -153,7 +167,7 @@ public class AlbumDetailsActivity extends AbsSlidingMusicPanelActivity implement getSupportActionBar().setTitle(null); - if (toolbar != null && !PreferenceUtil.getInstance(this).getFullScreenMode()) { + if (toolbar != null && !PreferenceUtil.getInstance().getFullScreenMode()) { ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams(); params.topMargin = RetroUtil.getStatusBarHeight(this); toolbar.setLayoutParams(params); @@ -166,21 +180,20 @@ public class AlbumDetailsActivity extends AbsSlidingMusicPanelActivity implement int color; switch (state) { case COLLAPSED: - setLightStatusbar(!ATHUtil.isWindowBackgroundDark(AlbumDetailsActivity.this)); - color = ATHUtil.resolveColor(AlbumDetailsActivity.this, R.attr.iconColor); + setLightStatusbar(ColorUtil.isColorLight(ThemeStore.primaryColor(AlbumDetailsActivity.this))); + color = ThemeStore.primaryColor(AlbumDetailsActivity.this); break; default: case EXPANDED: case IDLE: setLightStatusbar(false); - color = ContextCompat.getColor(AlbumDetailsActivity.this, R.color.md_white_1000); + color = Color.TRANSPARENT; break; } - ToolbarContentTintHelper.colorizeToolbar(toolbar, color, AlbumDetailsActivity.this); + ToolbarContentTintHelper.setToolbarContentColorBasedOnToolbarColor(AlbumDetailsActivity.this, toolbar, color); } }); } - } @OnClick({R.id.action_shuffle_all, R.id.artist_image}) @@ -193,8 +206,8 @@ public class AlbumDetailsActivity extends AbsSlidingMusicPanelActivity implement artistPairs); break; case R.id.action_shuffle_all: - if (album.songs != null) { - MusicPlayerRemote.openAndShuffleQueue(album.songs, true); + if (getAlbum().songs != null) { + MusicPlayerRemote.openAndShuffleQueue(getAlbum().songs, true); } break; } @@ -224,7 +237,7 @@ public class AlbumDetailsActivity extends AbsSlidingMusicPanelActivity implement @Override public void completed() { - supportStartPostponedEnterTransition(); + ActivityCompat.startPostponedEnterTransition(this); } @Override @@ -241,31 +254,24 @@ public class AlbumDetailsActivity extends AbsSlidingMusicPanelActivity implement MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(this, album.songs)))); loadAlbumCover(); - - adapter = new SimpleSongAdapter(this, this.album.songs, R.layout.item_song); - - recyclerView.setLayoutManager(new LinearLayoutManager(this)); - recyclerView.setItemAnimator(new DefaultItemAnimator()); - recyclerView.setAdapter(adapter); - recyclerView.setNestedScrollingEnabled(false); - loadMoreFrom(album); - + adapter.swapDataSet(album.songs); } private void loadMoreFrom(Album album) { - - ArtistGlideRequest.Builder.from(Glide.with(this), - ArtistLoader.getArtist(this, album.getArtistId()).blockingFirst()) - .forceDownload(false) - .generatePalette(this).build() - .dontAnimate() - .into(new RetroMusicColoredTarget(artistImage) { - @Override - public void onColorReady(int color) { - //setColors(color); - } - }); + if (artistImage != null) { + ArtistGlideRequest.Builder.from(Glide.with(this), + ArtistLoader.getArtist(this, album.getArtistId()).blockingFirst()) + .forceDownload(false) + .generatePalette(this).build() + .dontAnimate() + .into(new RetroMusicColoredTarget(artistImage) { + @Override + public void onColorReady(int color) { + //setColors(color); + } + }); + } ArrayList albums = ArtistLoader.getArtist(this, album.getArtistId()) .blockingFirst().albums; @@ -278,11 +284,11 @@ public class AlbumDetailsActivity extends AbsSlidingMusicPanelActivity implement } moreTitle.setText(String.format("More from %s", album.getArtistName())); - AlbumAdapter albumAdapter = new HorizontalAlbumAdapter(this, albums, - false, null); - moreRecyclerView - .setLayoutManager(new GridLayoutManager(this, 1, GridLayoutManager.HORIZONTAL, false)); + AlbumAdapter albumAdapter = new HorizontalAlbumAdapter(this, albums, false, null); + moreRecyclerView.setLayoutManager(new GridLayoutManager(this, 1, GridLayoutManager.HORIZONTAL, false)); moreRecyclerView.setAdapter(albumAdapter); + + ActivityCompat.startPostponedEnterTransition(this); } public Album getAlbum() { @@ -294,22 +300,6 @@ public class AlbumDetailsActivity extends AbsSlidingMusicPanelActivity implement .checkIgnoreMediaStore(this) .generatePalette(this).build() .dontAnimate() - .listener(new RequestListener() { - @Override - public boolean onException(Exception e, Object model, Target target, - boolean isFirstResource) { - supportStartPostponedEnterTransition(); - return false; - } - - @Override - public boolean onResourceReady(BitmapPaletteWrapper resource, Object model, - Target target, boolean isFromMemoryCache, - boolean isFirstResource) { - supportStartPostponedEnterTransition(); - return false; - } - }) .into(new RetroMusicColoredTarget(image) { @Override public void onColorReady(int color) { @@ -320,14 +310,15 @@ public class AlbumDetailsActivity extends AbsSlidingMusicPanelActivity implement private void setColors(int color) { int themeColor = - PreferenceUtil.getInstance(this).getAdaptiveColor() ? color : ThemeStore.accentColor(this); + PreferenceUtil.getInstance().getAdaptiveColor() ? color : ThemeStore.accentColor(this); songTitle.setTextColor(themeColor); moreTitle.setTextColor(themeColor); - TintHelper.setTintAuto(shuffleButton, themeColor, true); + MaterialUtil.setTint(shuffleButton, true, themeColor); //findViewById(R.id.root).setBackgroundColor(ThemeStore.primaryColor(this)); } + @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_album_detail, menu); @@ -390,7 +381,7 @@ public class AlbumDetailsActivity extends AbsSlidingMusicPanelActivity implement } private String getSavedSortOrder() { - return PreferenceUtil.getInstance(this).getAlbumDetailSongSortOrder(); + return PreferenceUtil.getInstance().getAlbumDetailSongSortOrder(); } private void setUpSortOrderMenu(@NonNull SubMenu sortOrder) { @@ -411,7 +402,7 @@ public class AlbumDetailsActivity extends AbsSlidingMusicPanelActivity implement } private void setSaveSortOrder(String sortOrder) { - PreferenceUtil.getInstance(this).setAlbumDetailSongSortOrder(sortOrder); + PreferenceUtil.getInstance().setAlbumDetailSongSortOrder(sortOrder); reload(); } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/ArtistDetailActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/ArtistDetailActivity.java index 12e74ccf..70755c67 100755 --- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/ArtistDetailActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/ArtistDetailActivity.java @@ -2,41 +2,45 @@ package code.name.monkey.retromusic.ui.activities; import android.content.Intent; import android.content.res.ColorStateList; +import android.graphics.Color; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import com.google.android.material.appbar.AppBarLayout; -import com.google.android.material.appbar.CollapsingToolbarLayout; -import com.google.android.material.floatingactionbutton.FloatingActionButton; -import androidx.core.content.ContextCompat; -import androidx.appcompat.widget.AppCompatTextView; -import androidx.recyclerview.widget.DefaultItemAnimator; -import androidx.recyclerview.widget.GridLayoutManager; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; -import androidx.appcompat.widget.Toolbar; import android.text.Html; import android.text.Spanned; +import android.transition.Slide; +import android.view.Gravity; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; +import android.view.animation.AnimationUtils; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; import com.bumptech.glide.Glide; +import com.google.android.material.appbar.AppBarLayout; +import com.google.android.material.appbar.CollapsingToolbarLayout; +import com.google.android.material.button.MaterialButton; import java.util.ArrayList; import java.util.Locale; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatTextView; +import androidx.appcompat.widget.Toolbar; +import androidx.core.app.ActivityCompat; +import androidx.recyclerview.widget.DefaultItemAnimator; +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import code.name.monkey.appthemehelper.ThemeStore; -import code.name.monkey.appthemehelper.util.ATHUtil; import code.name.monkey.appthemehelper.util.ColorUtil; +import code.name.monkey.appthemehelper.util.MaterialUtil; import code.name.monkey.appthemehelper.util.TintHelper; import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper; import code.name.monkey.retromusic.R; @@ -105,7 +109,7 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement TextView text; @BindView(R.id.action_shuffle_all) - FloatingActionButton shuffleButton; + MaterialButton shuffleButton; @BindView(R.id.gradient_background) @Nullable @@ -130,6 +134,15 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement private AlbumAdapter albumAdapter; private boolean forceDownload; + void setupWindowTransistion() { + Slide slide = new Slide(Gravity.BOTTOM); + slide.setInterpolator( + AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)); + getWindow().setEnterTransition(slide); + + } + + @Override protected View createContentView() { return wrapSlidingMusicPanel(R.layout.activity_artist_details); @@ -137,17 +150,16 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement @Override protected void onCreate(Bundle bundle) { - setDrawUnderStatusBar(true); + setDrawUnderStatusBar(); + setupWindowTransistion(); super.onCreate(bundle); ButterKnife.bind(this); - setBottomBarVisibility(View.GONE); - + toggleBottomNavigationView(true); setNavigationbarColorAuto(); setLightNavigationBar(true); - supportPostponeEnterTransition(); - + ActivityCompat.postponeEnterTransition(this); lastFMRestClient = new LastFMRestClient(this); @@ -159,7 +171,7 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement private void setUpViews() { setupRecyclerView(); - setupToolbar(); + setupToolbarMarginHeight(); setupContainerHeight(); } @@ -171,49 +183,47 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement } } - private void setupToolbar() { + private void setupToolbarMarginHeight() { + int primaryColor = ThemeStore.primaryColor(this); + TintHelper.setTintAuto(contentContainer, primaryColor, true); + if (collapsingToolbarLayout != null) { + collapsingToolbarLayout.setContentScrimColor(primaryColor); + collapsingToolbarLayout.setStatusBarScrimColor(ColorUtil.darkenColor(primaryColor)); + } + toolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp); setSupportActionBar(toolbar); //noinspection ConstantConditions getSupportActionBar().setTitle(null); - if (toolbar != null && !PreferenceUtil.getInstance(this).getFullScreenMode()) { - ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) toolbar - .getLayoutParams(); + + if (toolbar != null && !PreferenceUtil.getInstance().getFullScreenMode()) { + ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams(); params.topMargin = RetroUtil.getStatusBarHeight(this); toolbar.setLayoutParams(params); } - int primaryColor = ThemeStore.primaryColor(this); - TintHelper.setTintAuto(contentContainer, primaryColor, true); - if (appBarLayout != null) { - appBarLayout.setBackgroundColor(primaryColor); appBarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() { @Override - public void onStateChanged(AppBarLayout appBarLayout, - AppBarStateChangeListener.State state) { + public void onStateChanged(AppBarLayout appBarLayout, State state) { int color; switch (state) { case COLLAPSED: - setLightStatusbar(!ATHUtil.isWindowBackgroundDark(ArtistDetailActivity.this)); - color = ATHUtil.resolveColor(ArtistDetailActivity.this, R.attr.iconColor); + setLightStatusbar(ColorUtil.isColorLight(ThemeStore.primaryColor(appBarLayout.getContext()))); + color = ThemeStore.primaryColor(appBarLayout.getContext()); break; default: case EXPANDED: case IDLE: setLightStatusbar(false); - color = ContextCompat.getColor(ArtistDetailActivity.this, R.color.md_white_1000); + color = Color.TRANSPARENT; break; } - ToolbarContentTintHelper.colorizeToolbar(toolbar, color, ArtistDetailActivity.this); + ToolbarContentTintHelper.setToolbarContentColorBasedOnToolbarColor(appBarLayout.getContext(), toolbar, color); } }); } - if (collapsingToolbarLayout != null) { - collapsingToolbarLayout.setContentScrimColor(primaryColor); - collapsingToolbarLayout.setStatusBarScrimColor(ColorUtil.darkenColor(primaryColor)); - } } private void setupRecyclerView() { @@ -270,7 +280,7 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement @Override public void completed() { - supportStartPostponedEnterTransition(); + ActivityCompat.startPostponedEnterTransition(this); } @Override @@ -367,14 +377,13 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement private void setColors(int color) { - int textColor = - PreferenceUtil.getInstance(this).getAdaptiveColor() ? color : ThemeStore.accentColor(this); + int textColor = PreferenceUtil.getInstance().getAdaptiveColor() ? color : ThemeStore.accentColor(this); albumTitle.setTextColor(textColor); songTitle.setTextColor(textColor); biographyTitle.setTextColor(textColor); - TintHelper.setTintAuto(shuffleButton, textColor, true); + MaterialUtil.setTint(shuffleButton, true, textColor); if (background != null) { background.setBackgroundTintList(ColorStateList.valueOf(color)); diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/GenreDetailsActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/GenreDetailsActivity.java index 024ff101..cdd57f7f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/GenreDetailsActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/GenreDetailsActivity.java @@ -1,13 +1,6 @@ package code.name.monkey.retromusic.ui.activities; import android.os.Bundle; -import androidx.annotation.NonNull; -import com.google.android.material.appbar.AppBarLayout; -import com.google.android.material.floatingactionbutton.FloatingActionButton; -import androidx.recyclerview.widget.DefaultItemAnimator; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; -import androidx.appcompat.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -17,22 +10,27 @@ import android.widget.ProgressBar; import android.widget.TextView; import com.afollestad.materialcab.MaterialCab; +import com.google.android.material.appbar.AppBarLayout; +import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView; import java.util.ArrayList; +import androidx.annotation.NonNull; +import androidx.appcompat.widget.Toolbar; +import androidx.recyclerview.widget.DefaultItemAnimator; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import code.name.monkey.appthemehelper.ThemeStore; -import code.name.monkey.appthemehelper.util.ATHUtil; import code.name.monkey.appthemehelper.util.TintHelper; import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.helper.MusicPlayerRemote; import code.name.monkey.retromusic.helper.menu.GenreMenuHelper; import code.name.monkey.retromusic.interfaces.CabHolder; -import code.name.monkey.retromusic.misc.AppBarStateChangeListener; import code.name.monkey.retromusic.model.Genre; import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.mvp.contract.GenreDetailsContract; @@ -83,14 +81,14 @@ public class GenreDetailsActivity extends AbsSlidingMusicPanelActivity implement @Override protected void onCreate(Bundle savedInstanceState) { - setDrawUnderStatusBar(true); + setDrawUnderStatusBar(); super.onCreate(savedInstanceState); ButterKnife.bind(this); - setBottomBarVisibility(View.GONE); setStatusbarColorAuto(); setNavigationbarColorAuto(); setTaskDescriptionColorAuto(); + toggleBottomNavigationView(true); setLightNavigationBar(true); @@ -113,29 +111,14 @@ public class GenreDetailsActivity extends AbsSlidingMusicPanelActivity implement private void setUpToolBar() { title.setText(genre.name); title.setTextColor(ThemeStore.textColorPrimary(this)); + int primaryColor = ThemeStore.primaryColor(this); + toolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp); toolbar.setBackgroundColor(primaryColor); appBarLayout.setBackgroundColor(primaryColor); - toolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp); + ToolbarContentTintHelper.colorBackButton(toolbar, ThemeStore.accentColor(this)); setTitle(null); setSupportActionBar(toolbar); - - appBarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() { - @Override - public void onStateChanged(AppBarLayout appBarLayout, AppBarStateChangeListener.State state) { - int color; - switch (state) { - default: - case COLLAPSED: - case EXPANDED: - case IDLE: - color = ATHUtil.resolveColor(GenreDetailsActivity.this, android.R.attr.textColorPrimary); - break; - } - ToolbarContentTintHelper.colorizeToolbar(toolbar, color, GenreDetailsActivity.this); - } - }); - TintHelper.setTintAuto(shuffleButton, ThemeStore.accentColor(this), true); } @@ -208,30 +191,6 @@ public class GenreDetailsActivity extends AbsSlidingMusicPanelActivity implement songAdapter.swapDataSet(songs); } - public void showHeartAnimation() { - shuffleButton.clearAnimation(); - - shuffleButton.setScaleX(0.9f); - shuffleButton.setScaleY(0.9f); - shuffleButton.setVisibility(View.VISIBLE); - shuffleButton.setPivotX(shuffleButton.getWidth() / 2); - shuffleButton.setPivotY(shuffleButton.getHeight() / 2); - - shuffleButton.animate() - .setDuration(200) - .setInterpolator(new DecelerateInterpolator()) - .scaleX(1.1f) - .scaleY(1.1f) - .withEndAction(() -> shuffleButton.animate() - .setDuration(200) - .setInterpolator(new AccelerateInterpolator()) - .scaleX(1f) - .scaleY(1f) - .alpha(1f) - .start()) - .start(); - } - @NonNull @Override public MaterialCab openCab(final int menu, final MaterialCab.Callback callback) { diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/LicenseActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/LicenseActivity.java index cf8843f1..0a14f900 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/LicenseActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/LicenseActivity.java @@ -11,6 +11,7 @@ import android.widget.TextView; import butterknife.BindView; import butterknife.ButterKnife; import code.name.monkey.appthemehelper.ThemeStore; +import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.ui.activities.base.AbsBaseActivity; @@ -19,7 +20,7 @@ public class LicenseActivity extends AbsBaseActivity { WebView mLicense; @BindView(R.id.toolbar) - Toolbar mToolbar; + Toolbar toolbar; @BindView(R.id.app_bar) AppBarLayout mAppbar; @@ -50,11 +51,12 @@ public class LicenseActivity extends AbsBaseActivity { mLicense.loadUrl("file:///android_asset/index.html"); title.setTextColor(ThemeStore.textColorPrimary(this)); - mToolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp); - mToolbar.setNavigationOnClickListener(view -> onBackPressed()); - mToolbar.setBackgroundColor(ThemeStore.primaryColor(this)); + toolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp); + toolbar.setNavigationOnClickListener(view -> onBackPressed()); + toolbar.setBackgroundColor(ThemeStore.primaryColor(this)); mAppbar.setBackgroundColor(ThemeStore.primaryColor(this)); setTitle(null); - setSupportActionBar(mToolbar); + setSupportActionBar(toolbar); + ToolbarContentTintHelper.colorBackButton(toolbar, ThemeStore.accentColor(this)); } } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/LockScreenActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/LockScreenActivity.java index 47dd9dbc..5aa1a30c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/LockScreenActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/LockScreenActivity.java @@ -30,7 +30,7 @@ public class LockScreenActivity extends AbsMusicServiceActivity { | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); - setDrawUnderStatusBar(true); + setDrawUnderStatusBar(); setContentView(R.layout.activity_lock_screen_old_style); hideStatusBar(); diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/LyricsActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/LyricsActivity.java index 334b61a7..c3a5e681 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/LyricsActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/LyricsActivity.java @@ -92,11 +92,11 @@ public class LyricsActivity extends AbsMusicServiceActivity implements loadLrcFile(); actionsLayout.setOnCheckedChangeListener((group, checkedId) -> selectLyricsTye(checkedId)); - actionsLayout.check(PreferenceUtil.getInstance(this).getLastLyricsType()); + actionsLayout.check(PreferenceUtil.getInstance().getLastLyricsType()); } private void selectLyricsTye(int group) { - PreferenceUtil.getInstance(this).setLastLyricsType(group); + PreferenceUtil.getInstance().setLastLyricsType(group); RadioButton radioButton = actionsLayout.findViewById(group); if (radioButton != null) { radioButton.setBackgroundTintList(ColorStateList.valueOf(ThemeStore.accentColor(this))); @@ -198,7 +198,7 @@ public class LyricsActivity extends AbsMusicServiceActivity implements .into(new RetroMusicColoredTarget(findViewById(R.id.image)) { @Override public void onColorReady(int color) { - if (PreferenceUtil.getInstance(LyricsActivity.this).getAdaptiveColor()) { + if (PreferenceUtil.getInstance( ).getAdaptiveColor()) { background.setBackgroundColor(color); } } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/MainActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/MainActivity.java index bcb4cd17..00049d74 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/MainActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/MainActivity.java @@ -33,7 +33,6 @@ import butterknife.BindView; import butterknife.ButterKnife; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.RetroApplication; -import code.name.monkey.retromusic.dialogs.ChangelogDialog; import code.name.monkey.retromusic.helper.MusicPlayerRemote; import code.name.monkey.retromusic.helper.SearchQueryHelper; import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks; @@ -45,12 +44,10 @@ import code.name.monkey.retromusic.service.MusicService; import code.name.monkey.retromusic.ui.activities.base.AbsSlidingMusicPanelActivity; import code.name.monkey.retromusic.ui.fragments.mainactivity.LibraryFragment; import code.name.monkey.retromusic.ui.fragments.mainactivity.home.BannerHomeFragment; -import code.name.monkey.retromusic.ui.fragments.mainactivity.home.HomeFragment; import code.name.monkey.retromusic.util.PreferenceUtil; import io.reactivex.disposables.CompositeDisposable; public class MainActivity extends AbsSlidingMusicPanelActivity implements SharedPreferences.OnSharedPreferenceChangeListener, BottomNavigationView.OnNavigationItemSelectedListener { - public static final int APP_INTRO_REQUEST = 2323; public static final int LIBRARY = 1; public static final int FOLDERS = 3; @@ -65,15 +62,15 @@ public class MainActivity extends AbsSlidingMusicPanelActivity implements Shared @BindView(R.id.parent_container) FrameLayout drawerLayout; + private boolean blockRequestPermissions; private CompositeDisposable disposable = new CompositeDisposable(); - private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action != null && action.equals(Intent.ACTION_SCREEN_OFF)) { - if (PreferenceUtil.getInstance(context).getLockScreen() && MusicPlayerRemote.isPlaying()) { + if (PreferenceUtil.getInstance().getLockScreen() && MusicPlayerRemote.isPlaying()) { Intent activity = new Intent(context, LockScreenActivity.class); activity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); activity.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); @@ -94,7 +91,7 @@ public class MainActivity extends AbsSlidingMusicPanelActivity implements Shared @Override protected void onCreate(Bundle savedInstanceState) { - setDrawUnderStatusBar(true); + setDrawUnderStatusBar(); super.onCreate(savedInstanceState); ButterKnife.bind(this); @@ -103,7 +100,8 @@ public class MainActivity extends AbsSlidingMusicPanelActivity implements Shared drawerLayout.setOnApplyWindowInsetsListener((view, windowInsets) -> windowInsets.replaceSystemWindowInsets(0, 0, 0, 0)); if (savedInstanceState == null) { - selectedFragment(PreferenceUtil.getInstance(this).getLastPage()); + selectedFragment(PreferenceUtil.getInstance().getLastPage()); + //setCurrentFragment(new LibraryFragment(), false, LibraryFragment.TAG); } else { restoreCurrentFragment(); } @@ -118,8 +116,8 @@ public class MainActivity extends AbsSlidingMusicPanelActivity implements Shared try { PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); int currentVersion = pInfo.versionCode; - if (currentVersion != PreferenceUtil.getInstance(this).getLastChangelogVersion()) { - ChangelogDialog.create().show(getSupportFragmentManager(), "CHANGE_LOG_DIALOG"); + if (currentVersion != PreferenceUtil.getInstance().getLastChangelogVersion()) { + startActivity(new Intent(this, WhatsNewActivity.class)); } } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); @@ -133,11 +131,11 @@ public class MainActivity extends AbsSlidingMusicPanelActivity implements Shared screenOnOff.addAction(Intent.ACTION_SCREEN_OFF); registerReceiver(broadcastReceiver, screenOnOff); - PreferenceUtil.getInstance(this).registerOnSharedPreferenceChangedListener(this); + PreferenceUtil.getInstance().registerOnSharedPreferenceChangedListener(this); if (getIntent().hasExtra("expand")) { if (getIntent().getBooleanExtra("expand", false)) { - expandPanel(); + //expandPanel(); getIntent().putExtra("expand", false); } } @@ -152,7 +150,7 @@ public class MainActivity extends AbsSlidingMusicPanelActivity implements Shared return; } unregisterReceiver(broadcastReceiver); - PreferenceUtil.getInstance(this).unregisterOnSharedPreferenceChangedListener(this); + PreferenceUtil.getInstance().unregisterOnSharedPreferenceChangedListener(this); } public void setCurrentFragment(@NonNull Fragment fragment, boolean isStackAdd, String tag) { @@ -327,9 +325,10 @@ public class MainActivity extends AbsSlidingMusicPanelActivity implements Shared .show(); } + @Override public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) { - PreferenceUtil.getInstance(this).setLastPage(menuItem.getItemId()); + PreferenceUtil.getInstance().setLastPage(menuItem.getItemId()); selectedFragment(menuItem.getItemId()); return true; } @@ -343,8 +342,7 @@ public class MainActivity extends AbsSlidingMusicPanelActivity implements Shared setCurrentFragment(LibraryFragment.newInstance(itemId), false, LibraryFragment.TAG); break; case R.id.action_home: - setCurrentFragment(PreferenceUtil.getInstance(this).toggleHomeBanner() ? HomeFragment.newInstance() : - BannerHomeFragment.newInstance(), false, HomeFragment.TAG); + setCurrentFragment(BannerHomeFragment.newInstance(), false, BannerHomeFragment.TAG); break; } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/NowPayingActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/NowPayingActivity.java new file mode 100644 index 00000000..72a197da --- /dev/null +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/NowPayingActivity.java @@ -0,0 +1,162 @@ +package code.name.monkey.retromusic.ui.activities; + +import android.content.SharedPreferences; +import android.graphics.Color; +import android.os.Bundle; +import android.transition.Slide; +import android.view.Gravity; +import android.view.animation.AnimationUtils; + +import androidx.fragment.app.Fragment; +import code.name.monkey.appthemehelper.ThemeStore; +import code.name.monkey.appthemehelper.util.ColorUtil; +import code.name.monkey.retromusic.R; +import code.name.monkey.retromusic.helper.MusicPlayerRemote; +import code.name.monkey.retromusic.ui.activities.base.AbsMusicServiceActivity; +import code.name.monkey.retromusic.ui.fragments.NowPlayingScreen; +import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerFragment; +import code.name.monkey.retromusic.ui.fragments.player.adaptive.AdaptiveFragment; +import code.name.monkey.retromusic.ui.fragments.player.blur.BlurPlayerFragment; +import code.name.monkey.retromusic.ui.fragments.player.card.CardFragment; +import code.name.monkey.retromusic.ui.fragments.player.cardblur.CardBlurFragment; +import code.name.monkey.retromusic.ui.fragments.player.color.ColorFragment; +import code.name.monkey.retromusic.ui.fragments.player.fit.FitFragment; +import code.name.monkey.retromusic.ui.fragments.player.flat.FlatPlayerFragment; +import code.name.monkey.retromusic.ui.fragments.player.full.FullPlayerFragment; +import code.name.monkey.retromusic.ui.fragments.player.hmm.HmmPlayerFragment; +import code.name.monkey.retromusic.ui.fragments.player.material.MaterialFragment; +import code.name.monkey.retromusic.ui.fragments.player.normal.PlayerFragment; +import code.name.monkey.retromusic.ui.fragments.player.plain.PlainPlayerFragment; +import code.name.monkey.retromusic.ui.fragments.player.simple.SimplePlayerFragment; +import code.name.monkey.retromusic.util.PreferenceUtil; + +public class NowPayingActivity extends AbsMusicServiceActivity implements AbsPlayerFragment.Callbacks, SharedPreferences.OnSharedPreferenceChangeListener { + + private NowPlayingScreen currentNowPlayingScreen; + private AbsPlayerFragment playerFragment; + + void setupWindowTransition() { + Slide slide = new Slide(Gravity.BOTTOM); + slide.setInterpolator( + AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)); + getWindow().setEnterTransition(slide); + //getWindow().setExitTransition(slide); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + setLightNavigationBar(true); + setupWindowTransition(); + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_now_playng); + chooseFragmentForTheme(); + } + + private boolean isOneOfTheseThemes() { + return currentNowPlayingScreen == NowPlayingScreen.FLAT + || currentNowPlayingScreen == NowPlayingScreen.PLAIN + || currentNowPlayingScreen == NowPlayingScreen.SIMPLE + || currentNowPlayingScreen == NowPlayingScreen.NORMAL + || currentNowPlayingScreen == NowPlayingScreen.ADAPTIVE + || currentNowPlayingScreen == NowPlayingScreen.TINY + || currentNowPlayingScreen == NowPlayingScreen.MATERIAL; + } + + @Override + public void onPaletteColorChanged() { + int paletteColor = playerFragment.getPaletteColor(); + if ((currentNowPlayingScreen == NowPlayingScreen.FLAT || currentNowPlayingScreen == NowPlayingScreen.NORMAL) && PreferenceUtil.getInstance().getAdaptiveColor()) { + setNavigationbarColor(Color.TRANSPARENT); + setLightStatusbar(ColorUtil.isColorLight(paletteColor)); + } else if (currentNowPlayingScreen == NowPlayingScreen.COLOR) { + setLightStatusbar(ColorUtil.isColorLight(paletteColor)); + } else if (currentNowPlayingScreen == NowPlayingScreen.BLUR || currentNowPlayingScreen == NowPlayingScreen.BLUR_CARD) { + setLightStatusbar(false); + } else { + setLightStatusbar(isOneOfTheseThemes() && ColorUtil.isColorLight(ThemeStore.primaryColor(this))); + } + } + + @Override + protected void onResume() { + super.onResume(); + if (currentNowPlayingScreen != PreferenceUtil.getInstance().getNowPlayingScreen()) { + postRecreate(); + } + PreferenceUtil.getInstance().registerOnSharedPreferenceChangedListener(this); + } + + @Override + protected void onPause() { + super.onPause(); + PreferenceUtil.getInstance().unregisterOnSharedPreferenceChangedListener(this); + } + + @Override + public void onQueueChanged() { + super.onQueueChanged(); + if (MusicPlayerRemote.getPlayingQueue().isEmpty()) { + finish(); + } + } + + private void chooseFragmentForTheme() { + currentNowPlayingScreen = PreferenceUtil.getInstance().getNowPlayingScreen(); + + Fragment fragment; // must implement AbsPlayerFragment + switch (currentNowPlayingScreen) { + case MATERIAL: + fragment = new MaterialFragment(); + break; + case FIT: + fragment = new FitFragment(); + break; + case BLUR: + fragment = new BlurPlayerFragment(); + break; + case FLAT: + fragment = new FlatPlayerFragment(); + break; + case PLAIN: + fragment = new PlainPlayerFragment(); + break; + case FULL: + fragment = new FullPlayerFragment(); + break; + case COLOR: + fragment = new ColorFragment(); + break; + case CARD: + fragment = new CardFragment(); + break; + case SIMPLE: + fragment = new SimplePlayerFragment(); + break; + case TINY: + fragment = new HmmPlayerFragment(); + break; + case BLUR_CARD: + fragment = new CardBlurFragment(); + break; + case ADAPTIVE: + fragment = new AdaptiveFragment(); + break; + case NORMAL: + default: + fragment = new PlayerFragment(); + break; + } + getSupportFragmentManager().beginTransaction().replace(R.id.player_fragment_container, fragment).commit(); + getSupportFragmentManager().executePendingTransactions(); + + playerFragment = (AbsPlayerFragment) getSupportFragmentManager() + .findFragmentById(R.id.player_fragment_container); + } + + @Override + public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { + if (key.equals(PreferenceUtil.ALBUM_COVER_STYLE) || key.equals(PreferenceUtil.ALBUM_COVER_TRANSFORM)) { + recreate(); + } + } +} diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/PlayingQueueActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/PlayingQueueActivity.java index 22560a6c..da40ad7c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/PlayingQueueActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/PlayingQueueActivity.java @@ -12,6 +12,7 @@ import butterknife.BindString; import butterknife.BindView; import butterknife.ButterKnife; import code.name.monkey.appthemehelper.ThemeStore; +import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.helper.MusicPlayerRemote; import code.name.monkey.retromusic.ui.activities.base.AbsMusicServiceActivity; @@ -22,19 +23,19 @@ import code.name.monkey.retromusic.util.MusicUtil; public class PlayingQueueActivity extends AbsMusicServiceActivity { @BindView(R.id.toolbar) - Toolbar mToolbar; + Toolbar toolbar; @BindDrawable(R.drawable.ic_keyboard_backspace_black_24dp) - Drawable mClose; + Drawable close; @BindView(R.id.player_queue_sub_header) - TextView mPlayerQueueSubHeader; + TextView textView; @BindString(R.string.queue) String queue; @BindView(R.id.app_bar) - AppBarLayout mAppBarLayout; + AppBarLayout appBarLayout; @BindView(R.id.title) TextView title; @@ -64,13 +65,15 @@ public class PlayingQueueActivity extends AbsMusicServiceActivity { private void setupToolbar() { title.setTextColor(ThemeStore.textColorPrimary(this)); - mPlayerQueueSubHeader.setText(getUpNextAndQueueTime()); - mPlayerQueueSubHeader.setTextColor(ThemeStore.accentColor(this)); - mAppBarLayout.setBackgroundColor(ThemeStore.primaryColor(this)); - mToolbar.setBackgroundColor(ThemeStore.primaryColor(this)); - mToolbar.setNavigationIcon(mClose); - setSupportActionBar(mToolbar); + textView.setText(getUpNextAndQueueTime()); + textView.setTextColor(ThemeStore.accentColor(this)); + + appBarLayout.setBackgroundColor(ThemeStore.primaryColor(this)); + toolbar.setBackgroundColor(ThemeStore.primaryColor(this)); + toolbar.setNavigationIcon(close); + setSupportActionBar(toolbar); setTitle(null); - mToolbar.setNavigationOnClickListener(v -> onBackPressed()); + toolbar.setNavigationOnClickListener(v -> onBackPressed()); + ToolbarContentTintHelper.colorBackButton(toolbar, ThemeStore.accentColor(this)); } } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/PlaylistDetailActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/PlaylistDetailActivity.java index f557748e..dbc03e39 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/PlaylistDetailActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/PlaylistDetailActivity.java @@ -28,6 +28,7 @@ import butterknife.ButterKnife; import butterknife.OnClick; import code.name.monkey.appthemehelper.ThemeStore; import code.name.monkey.appthemehelper.util.TintHelper; +import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.helper.MusicPlayerRemote; import code.name.monkey.retromusic.helper.menu.PlaylistMenuHelper; @@ -80,16 +81,15 @@ public class PlaylistDetailActivity extends AbsSlidingMusicPanelActivity impleme @Override protected void onCreate(Bundle savedInstanceState) { - setDrawUnderStatusBar(true); + setDrawUnderStatusBar(); super.onCreate(savedInstanceState); ButterKnife.bind(this); - setBottomBarVisibility(View.GONE); setStatusbarColorAuto(); setNavigationbarColorAuto(); setTaskDescriptionColorAuto(); setLightNavigationBar(true); - + toggleBottomNavigationView(true); playlist = getIntent().getExtras().getParcelable(EXTRA_PLAYLIST); @@ -106,7 +106,7 @@ public class PlaylistDetailActivity extends AbsSlidingMusicPanelActivity impleme shuffleButton.setScaleX(0.9f); shuffleButton.setScaleY(0.9f); - shuffleButton.setVisibility(View.VISIBLE); + shuffleButton.show(); shuffleButton.setPivotX(shuffleButton.getWidth() / 2); shuffleButton.setPivotY(shuffleButton.getHeight() / 2); @@ -185,6 +185,8 @@ public class PlaylistDetailActivity extends AbsSlidingMusicPanelActivity impleme setTitle(null); setSupportActionBar(toolbar); toolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp); + + ToolbarContentTintHelper.colorBackButton(toolbar, ThemeStore.accentColor(this)); } @Override diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/ProVersionActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/ProVersionActivity.java index b6ac1748..dfd277cf 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/ProVersionActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/ProVersionActivity.java @@ -3,10 +3,6 @@ package code.name.monkey.retromusic.ui.activities; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import com.google.android.material.appbar.AppBarLayout; -import androidx.appcompat.widget.Toolbar; import android.util.Log; import android.view.MenuItem; import android.view.View; @@ -15,13 +11,20 @@ import android.widget.Toast; import com.anjlab.android.iab.v3.BillingProcessor; import com.anjlab.android.iab.v3.TransactionDetails; +import com.google.android.material.appbar.AppBarLayout; +import com.google.android.material.button.MaterialButton; import java.lang.ref.WeakReference; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.Toolbar; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import code.name.monkey.appthemehelper.ThemeStore; +import code.name.monkey.appthemehelper.util.MaterialUtil; +import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper; import code.name.monkey.retromusic.BuildConfig; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.RetroApplication; @@ -39,10 +42,10 @@ public class ProVersionActivity extends AbsBaseActivity implements Toolbar toolbar; @BindView(R.id.restore_button) - View restoreButton; + MaterialButton restoreButton; @BindView(R.id.purchase_button) - View purchaseButton; + MaterialButton purchaseButton; @BindView(R.id.app_bar) AppBarLayout appBar; @@ -57,7 +60,7 @@ public class ProVersionActivity extends AbsBaseActivity implements protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_pro_version); - setDrawUnderStatusBar(true); + setDrawUnderStatusBar(); ButterKnife.bind(this); setStatusbarColorAuto(); @@ -73,14 +76,17 @@ public class ProVersionActivity extends AbsBaseActivity implements toolbar.setNavigationOnClickListener(v -> onBackPressed()); title.setTextColor(ThemeStore.textColorPrimary(this)); setSupportActionBar(toolbar); - //noinspection ConstantConditions - getSupportActionBar().setTitle(null); + setTitle(null); + ToolbarContentTintHelper.colorBackButton(toolbar, ThemeStore.accentColor(this)); restoreButton.setEnabled(false); purchaseButton.setEnabled(false); billingProcessor = new BillingProcessor(this, BuildConfig.GOOGLE_PLAY_LICENSE_KEY, this); + MaterialUtil.setTint(restoreButton, false); + MaterialUtil.setTint(purchaseButton, true); + } private void restorePurchase() { diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/SearchActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/SearchActivity.java index 0049d533..9c31fb00 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/SearchActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/SearchActivity.java @@ -60,7 +60,7 @@ public class SearchActivity extends AbsMusicServiceActivity implements OnQueryTe @Override protected void onCreate(Bundle savedInstanceState) { - setDrawUnderStatusBar(true); + setDrawUnderStatusBar(); super.onCreate(savedInstanceState); setContentView(R.layout.activity_search); diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/SettingsActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/SettingsActivity.java index a9918d3c..d09a7ccf 100755 --- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/SettingsActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/SettingsActivity.java @@ -24,6 +24,7 @@ import butterknife.BindView; import butterknife.ButterKnife; import code.name.monkey.appthemehelper.ThemeStore; import code.name.monkey.appthemehelper.util.ColorUtil; +import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager; import code.name.monkey.retromusic.ui.activities.base.AbsBaseActivity; @@ -32,6 +33,8 @@ import code.name.monkey.retromusic.util.PreferenceUtil; public class SettingsActivity extends AbsBaseActivity implements ColorChooserDialog.ColorCallback, SharedPreferences.OnSharedPreferenceChangeListener { + private static final String TAG = "SettingsActivity"; + @BindView(R.id.toolbar) Toolbar toolbar; @@ -44,6 +47,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia @BindView(R.id.detail_content_frame) @Nullable FrameLayout detailsFrame; + private FragmentManager fragmentManager = getSupportFragmentManager(); @Override @@ -80,7 +84,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia setStatusbarColorAuto(); setNavigationbarColorAuto(); - setTaskDescriptionColorAuto(); + setLightNavigationBar(true); setupToolbar(); @@ -92,17 +96,15 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia } private void setupToolbar() { - title.setTextColor(ThemeStore.textColorPrimary(this)); - int primaryColor = ThemeStore.primaryColor(this); - toolbar.setBackgroundColor(primaryColor); - appBarLayout.setBackgroundColor(primaryColor); - setTitle(null); + toolbar.setBackgroundColor(ThemeStore.primaryColor(this)); + appBarLayout.setBackgroundColor(ThemeStore.primaryColor(this)); setSupportActionBar(toolbar); - toolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp); + setTitle(null); toolbar.setNavigationOnClickListener(v -> onBackPressed()); + title.setTextColor(ThemeStore.textColorPrimary(this)); + ToolbarContentTintHelper.colorBackButton(toolbar, ThemeStore.accentColor(this)); } - public void setupFragment(Fragment fragment, @StringRes int titleName) { FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction() @@ -120,7 +122,6 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia } } - @Override public void onBackPressed() { if (fragmentManager.getBackStackEntryCount() == 0) { @@ -145,20 +146,18 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia appBarLayout.setElevation(v); } - @Override public void onPause() { super.onPause(); - PreferenceUtil.getInstance(this).unregisterOnSharedPreferenceChangedListener(this); + PreferenceUtil.getInstance().unregisterOnSharedPreferenceChangedListener(this); } @Override public void onResume() { super.onResume(); - PreferenceUtil.getInstance(this).registerOnSharedPreferenceChangedListener(this); + PreferenceUtil.getInstance().registerOnSharedPreferenceChangedListener(this); } - private static final String TAG = "SettingsActivity"; @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { Log.i(TAG, "onSharedPreferenceChanged: "); diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/SupportDevelopmentActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/SupportDevelopmentActivity.java index e95e55e5..ce75e28b 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/SupportDevelopmentActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/SupportDevelopmentActivity.java @@ -1,6 +1,7 @@ package code.name.monkey.retromusic.ui.activities; import android.content.Intent; +import android.content.res.ColorStateList; import android.graphics.Paint; import android.os.AsyncTask; import android.os.Bundle; @@ -18,6 +19,7 @@ import com.anjlab.android.iab.v3.BillingProcessor; import com.anjlab.android.iab.v3.SkuDetails; import com.anjlab.android.iab.v3.TransactionDetails; import com.google.android.material.appbar.AppBarLayout; +import com.google.android.material.button.MaterialButton; import org.json.JSONException; import org.json.JSONObject; @@ -39,6 +41,7 @@ import butterknife.ButterKnife; import butterknife.OnClick; import code.name.monkey.appthemehelper.ThemeStore; import code.name.monkey.appthemehelper.util.ATHUtil; +import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper; import code.name.monkey.retromusic.BuildConfig; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.ui.activities.base.AbsBaseActivity; @@ -56,26 +59,30 @@ public class SupportDevelopmentActivity extends AbsBaseActivity implements Billi private static final int DONATION_PRODUCT_IDS = R.array.donation_ids; @BindView(R.id.progress) - ProgressBar mProgressBar; + ProgressBar progressBar; @BindView(R.id.progress_container) - View mProgressContainer; + View progressContainer; @BindView(R.id.list) - RecyclerView mListView; + RecyclerView recyclerView; @BindView(R.id.toolbar) - Toolbar mToolbar; + Toolbar toolbar; @BindView(R.id.app_bar) - AppBarLayout mAppBarLayout; + AppBarLayout appBarLayout; @BindView(R.id.root) - ViewGroup mViewGroup; + ViewGroup viewGroup; @BindView(R.id.title) TextView title; - private BillingProcessor mBillingProcessor; + + @BindView(R.id.donate) + MaterialButton materialButton; + + private BillingProcessor billingProcessor; private AsyncTask skuDetailsLoadAsyncTask; private static List getDetails() { @@ -107,7 +114,7 @@ public class SupportDevelopmentActivity extends AbsBaseActivity implements Billi private void donate(int i) { final String[] ids = getResources().getStringArray(DONATION_PRODUCT_IDS); - mBillingProcessor.purchase(this, ids[i]); + billingProcessor.purchase(this, ids[i]); } @OnClick(R.id.donate) @@ -129,9 +136,8 @@ public class SupportDevelopmentActivity extends AbsBaseActivity implements Billi setupToolbar(); - mBillingProcessor - = new BillingProcessor(this, BuildConfig.GOOGLE_PLAY_LICENSE_KEY, this); - MDTintHelper.setTint(mProgressBar, ThemeStore.accentColor(this)); + billingProcessor = new BillingProcessor(this, BuildConfig.GOOGLE_PLAY_LICENSE_KEY, this); + MDTintHelper.setTint(progressBar, ThemeStore.accentColor(this)); ((TextView) findViewById(R.id.donation)).setTextColor(ThemeStore.accentColor(this)); } @@ -139,12 +145,16 @@ public class SupportDevelopmentActivity extends AbsBaseActivity implements Billi private void setupToolbar() { title.setTextColor(ThemeStore.textColorPrimary(this)); int primaryColor = ThemeStore.primaryColor(this); - mAppBarLayout.setBackgroundColor(primaryColor); - mToolbar.setBackgroundColor(primaryColor); - mToolbar.setNavigationOnClickListener(view -> onBackPressed()); - mToolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp); - setSupportActionBar(mToolbar); + appBarLayout.setBackgroundColor(primaryColor); + toolbar.setBackgroundColor(primaryColor); + + toolbar.setNavigationOnClickListener(view -> onBackPressed()); + toolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp); + setSupportActionBar(toolbar); setTitle(null); + + materialButton.setBackgroundTintList(ColorStateList.valueOf(ThemeStore.accentColor(this))); + ToolbarContentTintHelper.colorBackButton(toolbar, ThemeStore.accentColor(this)); } @Override @@ -179,15 +189,15 @@ public class SupportDevelopmentActivity extends AbsBaseActivity implements Billi @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { - if (!mBillingProcessor.handleActivityResult(requestCode, resultCode, data)) { + if (!billingProcessor.handleActivityResult(requestCode, resultCode, data)) { super.onActivityResult(requestCode, resultCode, data); } } @Override public void onDestroy() { - if (mBillingProcessor != null) { - mBillingProcessor.release(); + if (billingProcessor != null) { + billingProcessor.release(); } if (skuDetailsLoadAsyncTask != null) { skuDetailsLoadAsyncTask.cancel(true); @@ -208,8 +218,8 @@ public class SupportDevelopmentActivity extends AbsBaseActivity implements Billi SupportDevelopmentActivity dialog = donationDialogWeakReference.get(); if (dialog == null) return; - dialog.mProgressContainer.setVisibility(View.VISIBLE); - dialog.mListView.setVisibility(View.GONE); + dialog.progressContainer.setVisibility(View.VISIBLE); + dialog.recyclerView.setVisibility(View.GONE); } @Override @@ -217,7 +227,7 @@ public class SupportDevelopmentActivity extends AbsBaseActivity implements Billi SupportDevelopmentActivity dialog = donationDialogWeakReference.get(); if (dialog != null) { final String[] ids = dialog.getResources().getStringArray(DONATION_PRODUCT_IDS); - return dialog.mBillingProcessor.getPurchaseListingDetails(new ArrayList<>(Arrays.asList(ids))); + return dialog.billingProcessor.getPurchaseListingDetails(new ArrayList<>(Arrays.asList(ids))); } cancel(false); return null; @@ -230,16 +240,16 @@ public class SupportDevelopmentActivity extends AbsBaseActivity implements Billi if (dialog == null) return; if (skuDetails == null || skuDetails.isEmpty()) { - dialog.mProgressContainer.setVisibility(View.GONE); + dialog.progressContainer.setVisibility(View.GONE); return; } //noinspection ConstantConditions - dialog.mProgressContainer.setVisibility(View.GONE); - dialog.mListView.setItemAnimator(new DefaultItemAnimator()); - dialog.mListView.setLayoutManager(new GridLayoutManager(dialog, 2)); - dialog.mListView.setAdapter(new SkuDetailsAdapter(dialog, skuDetails)); - dialog.mListView.setVisibility(View.VISIBLE); + dialog.progressContainer.setVisibility(View.GONE); + dialog.recyclerView.setItemAnimator(new DefaultItemAnimator()); + dialog.recyclerView.setLayoutManager(new GridLayoutManager(dialog, 2)); + dialog.recyclerView.setAdapter(new SkuDetailsAdapter(dialog, skuDetails)); + dialog.recyclerView.setVisibility(View.VISIBLE); } @@ -300,7 +310,7 @@ public class SupportDevelopmentActivity extends AbsBaseActivity implements Billi viewHolder.price.setText(skuDetails.priceText); viewHolder.image.setImageResource(getIcon(i)); - final boolean purchased = donationsDialog.mBillingProcessor.isPurchased(skuDetails.productId); + final boolean purchased = donationsDialog.billingProcessor.isPurchased(skuDetails.productId); int titleTextColor = purchased ? ATHUtil.resolveColor(donationsDialog, android.R.attr.textColorHint) : ThemeStore.textColorPrimary(donationsDialog); int contentTextColor = purchased ? titleTextColor : ThemeStore.textColorSecondary(donationsDialog); diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/UserInfoActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/UserInfoActivity.java index a14180ad..1ae0c81e 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/UserInfoActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/UserInfoActivity.java @@ -31,6 +31,7 @@ import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import code.name.monkey.appthemehelper.ThemeStore; +import code.name.monkey.appthemehelper.util.TintHelper; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.ui.activities.base.AbsBaseActivity; import code.name.monkey.retromusic.util.Compressor; @@ -95,20 +96,20 @@ public class UserInfoActivity extends AbsBaseActivity { title.setTextColor(ThemeStore.textColorPrimary(this)); nameLayout.setBoxStrokeColor(ThemeStore.accentColor(this)); - name.setText(PreferenceUtil.getInstance(this).getUserName()); + name.setText(PreferenceUtil.getInstance().getUserName()); - if (!PreferenceUtil.getInstance(this).getProfileImage().isEmpty()) { - loadImageFromStorage(PreferenceUtil.getInstance(this).getProfileImage()); + if (!PreferenceUtil.getInstance().getProfileImage().isEmpty()) { + loadImageFromStorage(PreferenceUtil.getInstance().getProfileImage()); } - if (!PreferenceUtil.getInstance(this).getBannerImage().isEmpty()) { - loadBannerFromStorage(PreferenceUtil.getInstance(this).getBannerImage()); + if (!PreferenceUtil.getInstance().getBannerImage().isEmpty()) { + loadBannerFromStorage(PreferenceUtil.getInstance().getBannerImage()); } } private void setupToolbar() { toolbar.setBackgroundColor(ThemeStore.primaryColor(this)); appBarLayout.setBackgroundColor(ThemeStore.primaryColor(this)); - nextButton.setBackgroundTintList(ColorStateList.valueOf(ThemeStore.accentColor(this))); + TintHelper.setTintAuto(nextButton, ThemeStore.accentColor(this), true); } @OnClick({R.id.next, R.id.banner_select}) @@ -124,7 +125,7 @@ public class UserInfoActivity extends AbsBaseActivity { return; } //noinspection ConstantConditions - PreferenceUtil.getInstance(this).setUserName(nameString); + PreferenceUtil.getInstance().setUserName(nameString); setResult(RESULT_OK); //((UserInfoActivity) getActivity()).setFragment(new ChooseThemeFragment(), true); finish(); @@ -144,7 +145,7 @@ public class UserInfoActivity extends AbsBaseActivity { selectBannerImage(); break; case 1: - PreferenceUtil.getInstance(this).setBannerImagePath(""); + PreferenceUtil.getInstance().setBannerImagePath(""); break; } }).show(); @@ -152,7 +153,7 @@ public class UserInfoActivity extends AbsBaseActivity { private void selectBannerImage() { //noinspection ConstantConditions - if (PreferenceUtil.getInstance(this).getBannerImage().isEmpty()) { + if (PreferenceUtil.getInstance().getBannerImage().isEmpty()) { Intent pickImageIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); pickImageIntent.setType("image/*"); pickImageIntent.putExtra("crop", "true"); @@ -165,7 +166,7 @@ public class UserInfoActivity extends AbsBaseActivity { startActivityForResult(Intent.createChooser(pickImageIntent, "Select Picture"), PICK_BANNER_REQUEST); } else { - PreferenceUtil.getInstance(this).setBannerImagePath(""); + PreferenceUtil.getInstance().setBannerImagePath(""); image.setImageResource(android.R.color.transparent); } } @@ -183,7 +184,7 @@ public class UserInfoActivity extends AbsBaseActivity { pickNewPhoto(); break; case 1: - PreferenceUtil.getInstance(this).saveProfileImage(""); + PreferenceUtil.getInstance().saveProfileImage(""); break; } }).show(); @@ -211,7 +212,7 @@ public class UserInfoActivity extends AbsBaseActivity { try { Bitmap bitmap = ImageUtil.getResizedBitmap(Media.getBitmap(getContentResolver(), uri), PROFILE_ICON_SIZE); String profileImagePath = saveToInternalStorage(bitmap, USER_PROFILE); - PreferenceUtil.getInstance(this).saveProfileImage(profileImagePath); + PreferenceUtil.getInstance().saveProfileImage(profileImagePath); loadImageFromStorage(profileImagePath); } catch (IOException e) { @@ -224,7 +225,7 @@ public class UserInfoActivity extends AbsBaseActivity { try { Bitmap bitmap = Media.getBitmap(getContentResolver(), uri); String profileImagePath = saveToInternalStorage(bitmap, USER_BANNER); - PreferenceUtil.getInstance(this).setBannerImagePath(profileImagePath); + PreferenceUtil.getInstance().setBannerImagePath(profileImagePath); loadBannerFromStorage(profileImagePath); } catch (IOException e) { e.printStackTrace(); diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/WhatsNewActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/WhatsNewActivity.java new file mode 100644 index 00000000..cb98165b --- /dev/null +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/WhatsNewActivity.java @@ -0,0 +1,98 @@ +package code.name.monkey.retromusic.ui.activities; + +import android.content.Context; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.os.Bundle; +import android.webkit.WebView; +import android.widget.TextView; + +import com.afollestad.materialdialogs.internal.ThemeSingleton; +import com.google.android.material.appbar.AppBarLayout; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; + +import androidx.annotation.NonNull; +import androidx.appcompat.widget.Toolbar; +import butterknife.BindView; +import butterknife.ButterKnife; +import code.name.monkey.appthemehelper.ThemeStore; +import code.name.monkey.appthemehelper.util.ColorUtil; +import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper; +import code.name.monkey.retromusic.R; +import code.name.monkey.retromusic.ui.activities.base.AbsBaseActivity; +import code.name.monkey.retromusic.util.PreferenceUtil; + +public class WhatsNewActivity extends AbsBaseActivity { + @BindView(R.id.web_view) + WebView webView; + + @BindView(R.id.title) + TextView title; + + @BindView(R.id.toolbar) + Toolbar toolbar; + + @BindView(R.id.app_bar) + AppBarLayout appBarLayout; + + + private static void setChangelogRead(@NonNull Context context) { + try { + PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); + int currentVersion = pInfo.versionCode; + PreferenceUtil.getInstance().setLastChangeLogVersion(currentVersion); + } catch (PackageManager.NameNotFoundException e) { + e.printStackTrace(); + } + } + + private static String colorToHex(int color) { + return Integer.toHexString(color).substring(2); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_whats_new); + ButterKnife.bind(this); + + setStatusbarColorAuto(); + setNavigationbarColorAuto(); + setTaskDescriptionColorAuto(); + + toolbar.setBackgroundColor(ThemeStore.primaryColor(this)); + appBarLayout.setBackgroundColor(ThemeStore.primaryColor(this)); + setSupportActionBar(toolbar); + setTitle(null); + toolbar.setNavigationOnClickListener(v -> onBackPressed()); + title.setTextColor(ThemeStore.textColorPrimary(this)); + ToolbarContentTintHelper.colorBackButton(toolbar, ThemeStore.accentColor(this)); + + try { + // Load from phonograph-changelog.html in the assets folder + StringBuilder buf = new StringBuilder(); + InputStream json = getAssets().open("retro-changelog.html"); + BufferedReader in = new BufferedReader(new InputStreamReader(json, "UTF-8")); + String str; + while ((str = in.readLine()) != null) + buf.append(str); + in.close(); + + // Inject color values for WebView body background and links + final String backgroundColor = colorToHex(ThemeStore.primaryColor(this)); + final String contentColor = ThemeSingleton.get().darkTheme ? "#ffffff" : "#000000"; + webView.loadData(buf.toString() + .replace("{style-placeholder}", + String.format("body { background-color: %s; color: %s; }", backgroundColor, contentColor)) + .replace("{link-color}", colorToHex(ThemeSingleton.get().positiveColor.getDefaultColor())) + .replace("{link-color-active}", colorToHex(ColorUtil.lightenColor(ThemeSingleton.get().positiveColor.getDefaultColor()))) + , "text/html", "UTF-8"); + } catch (Throwable e) { + webView.loadData("

Unable to load

" + e.getLocalizedMessage() + "

", "text/html", "UTF-8"); + } + setChangelogRead(this); + } +} diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsBaseActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsBaseActivity.java index a552415d..1c679cff 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsBaseActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsBaseActivity.java @@ -9,13 +9,16 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.provider.Settings; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import com.google.android.material.snackbar.Snackbar; -import androidx.core.app.ActivityCompat; import android.view.KeyEvent; import android.view.View; +import android.view.ViewGroup; +import com.google.android.material.snackbar.Snackbar; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.core.app.ActivityCompat; +import androidx.core.view.ViewCompat; import code.name.monkey.appthemehelper.ThemeStore; import code.name.monkey.retromusic.R; import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper; @@ -32,7 +35,6 @@ public abstract class AbsBaseActivity extends AbsThemeActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setVolumeControlStream(AudioManager.STREAM_MUSIC); permissions = getPermissionsToRequest(); @@ -59,7 +61,6 @@ public abstract class AbsBaseActivity extends AbsThemeActivity { onHasPermissionsChanged(hasPermissions); } } - } protected void onHasPermissionsChanged(boolean hasPermissions) { diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsSlidingMusicPanelActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsSlidingMusicPanelActivity.java index c4f2aac7..7b9a5301 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsSlidingMusicPanelActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsSlidingMusicPanelActivity.java @@ -1,22 +1,15 @@ package code.name.monkey.retromusic.ui.activities.base; -import android.animation.ValueAnimator; import android.annotation.SuppressLint; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; -import android.view.animation.PathInterpolator; import com.google.android.gms.cast.framework.CastSession; import com.google.android.material.bottomnavigation.BottomNavigationView; -import com.sothree.slidinguppanel.SlidingUpPanelLayout; -import com.sothree.slidinguppanel.SlidingUpPanelLayout.PanelState; -import androidx.annotation.ColorInt; -import androidx.annotation.FloatRange; import androidx.annotation.LayoutRes; -import androidx.fragment.app.Fragment; import butterknife.BindView; import butterknife.ButterKnife; import code.name.monkey.appthemehelper.ThemeStore; @@ -27,169 +20,69 @@ import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.cast.CastHelper; import code.name.monkey.retromusic.helper.MusicPlayerRemote; import code.name.monkey.retromusic.ui.fragments.MiniPlayerFragment; -import code.name.monkey.retromusic.ui.fragments.NowPlayingScreen; -import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerFragment; -import code.name.monkey.retromusic.ui.fragments.player.adaptive.AdaptiveFragment; -import code.name.monkey.retromusic.ui.fragments.player.blur.BlurPlayerFragment; -import code.name.monkey.retromusic.ui.fragments.player.card.CardFragment; -import code.name.monkey.retromusic.ui.fragments.player.cardblur.CardBlurFragment; -import code.name.monkey.retromusic.ui.fragments.player.color.ColorFragment; -import code.name.monkey.retromusic.ui.fragments.player.flat.FlatPlayerFragment; -import code.name.monkey.retromusic.ui.fragments.player.full.FullPlayerFragment; -import code.name.monkey.retromusic.ui.fragments.player.hmm.HmmPlayerFragment; -import code.name.monkey.retromusic.ui.fragments.player.material.MaterialFragment; -import code.name.monkey.retromusic.ui.fragments.player.normal.PlayerFragment; -import code.name.monkey.retromusic.ui.fragments.player.plain.PlainPlayerFragment; -import code.name.monkey.retromusic.ui.fragments.player.simple.SimplePlayerFragment; -import code.name.monkey.retromusic.util.NavigationUtil; import code.name.monkey.retromusic.util.PreferenceUtil; -import code.name.monkey.retromusic.util.ViewUtil; -public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivity implements SlidingUpPanelLayout.PanelSlideListener, PlayerFragment.Callbacks { +public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivity { public static final String TAG = AbsSlidingMusicPanelActivity.class.getSimpleName(); - @BindView(R.id.sliding_layout) - SlidingUpPanelLayout slidingUpPanelLayout; - @BindView(R.id.bottom_navigation) BottomNavigationView bottomNavigationView; - private int navigationbarColor; - private int taskColor; - private boolean lightStatusBar; - private boolean lightNavigationBar; - private NowPlayingScreen currentNowPlayingScreen; - private AbsPlayerFragment playerFragment; - private MiniPlayerFragment miniPlayerFragment; - private ValueAnimator navigationBarColorAnimator; + @BindView(R.id.parentPanel) + ViewGroup parentPanel; + @BindView(R.id.mini_player_container) + ViewGroup miniPlayerContainer; + + private MiniPlayerFragment miniPlayerFragment; + + protected AbsSlidingMusicPanelActivity() { + } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(createContentView()); ButterKnife.bind(this); - - choosFragmentForTheme(); - - //noinspection ConstantConditions - miniPlayerFragment.getView().setOnClickListener(v -> { - CastSession castSession = getCastSession(); - if (castSession != null) { - NavigationUtil.gotoExpandedController(AbsSlidingMusicPanelActivity.this); - } else { - expandPanel(); - } - } - ); - - slidingUpPanelLayout.getViewTreeObserver() - .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - slidingUpPanelLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this); - - if (getPanelState() == PanelState.EXPANDED) { - onPanelSlide(slidingUpPanelLayout, 1); - onPanelExpanded(slidingUpPanelLayout); - } else if (getPanelState() == PanelState.COLLAPSED) { - onPanelCollapsed(slidingUpPanelLayout); - } else { - playerFragment.onHide(); - } - } - }); - - slidingUpPanelLayout.addPanelSlideListener(this); + setLightStatusbar(true); + setLightNavigationBar(true); setupBottomView(); + miniPlayerFragment = (MiniPlayerFragment) getSupportFragmentManager().findFragmentById(R.id.mini_player_fragment); } - private void choosFragmentForTheme() { - currentNowPlayingScreen = PreferenceUtil.getInstance(this).getNowPlayingScreen(); + private void setupBottomView() { + bottomNavigationView.setBackgroundColor(ThemeStore.primaryColor(this)); + bottomNavigationView.setSelectedItemId(PreferenceUtil.getInstance().getLastPage()); - Fragment fragment; // must implement AbsPlayerFragment - switch (currentNowPlayingScreen) { - case MATERIAL: - fragment = new MaterialFragment(); - break; - case BLUR: - fragment = new BlurPlayerFragment(); - break; - case FLAT: - fragment = new FlatPlayerFragment(); - break; - case PLAIN: - fragment = new PlainPlayerFragment(); - break; - case FULL: - fragment = new FullPlayerFragment(); - break; - case COLOR: - fragment = new ColorFragment(); - break; - case CARD: - fragment = new CardFragment(); - break; - case SIMPLE: - fragment = new SimplePlayerFragment(); - break; - case TINY: - fragment = new HmmPlayerFragment(); - break; - case BLUR_CARD: - fragment = new CardBlurFragment(); - break; - case ADAPTIVE: - fragment = new AdaptiveFragment(); - break; + int iconColor = ATHUtil.resolveColor(this, R.attr.iconColor); + int accentColor = ThemeStore.accentColor(this); + NavigationViewUtil.setItemIconColors(bottomNavigationView, ColorUtil.withAlpha(iconColor, 0.5f), accentColor); + NavigationViewUtil.setItemTextColors(bottomNavigationView, ColorUtil.withAlpha(iconColor, 0.5f), accentColor); - case NORMAL: - default: - fragment = new PlayerFragment(); - break; - } - getSupportFragmentManager().beginTransaction().replace(R.id.player_fragment_container, fragment) - .commit(); - getSupportFragmentManager().executePendingTransactions(); - - playerFragment = (AbsPlayerFragment) getSupportFragmentManager() - .findFragmentById(R.id.player_fragment_container); - miniPlayerFragment = (MiniPlayerFragment) getSupportFragmentManager() - .findFragmentById(R.id.mini_player_fragment); + bottomNavigationView.setLabelVisibilityMode(PreferenceUtil.getInstance().getTabTitleMode()); + //bottomNavigationView.getMenu().removeItem(R.id.action_playlist); } - @Override - protected void onResume() { - super.onResume(); - if (currentNowPlayingScreen != PreferenceUtil.getInstance(this).getNowPlayingScreen()) { - postRecreate(); + public void setBottomBarVisibility(int gone) { + if (bottomNavigationView != null) { + bottomNavigationView.setVisibility(gone); } } - @Override - public void onDestroy() { - super.onDestroy(); - if (navigationBarColorAnimator != null) { - navigationBarColorAnimator.cancel(); // just in case - } - } - protected abstract View createContentView(); @Override public void onServiceConnected() { super.onServiceConnected(); - if (!MusicPlayerRemote.getPlayingQueue().isEmpty()) { - slidingUpPanelLayout.getViewTreeObserver() - .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - slidingUpPanelLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this); - hideBottomBar(false); - } - }); - }// don't call hideBottomBar(true) here as it causes a bug with the SlidingUpPanelLayout + if (!MusicPlayerRemote.getPlayingQueue().isEmpty()) + parentPanel.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + parentPanel.getViewTreeObserver().removeOnGlobalLayoutListener(this); + hideBottomBar(false); + } + }); } @Override @@ -198,146 +91,10 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi hideBottomBar(MusicPlayerRemote.getPlayingQueue().isEmpty()); } - @Override - public void onPanelSlide(View panel, @FloatRange(from = 0, to = 1) float slideOffset) { - bottomNavigationView.setTranslationY(slideOffset * 400); - setMiniPlayerAlphaProgress(slideOffset); - } - - @Override - public void onPanelStateChanged(View panel, PanelState previousState, PanelState newState) { - switch (newState) { - case COLLAPSED: - onPanelCollapsed(panel); - break; - case EXPANDED: - onPanelExpanded(panel); - break; - case ANCHORED: - collapsePanel(); // this fixes a bug where the panel would get stuck for some reason - break; - } - } - - public void onPanelCollapsed(View panel) { - // restore values - super.setLightStatusbar(lightStatusBar); - super.setTaskDescriptionColor(taskColor); - super.setNavigationbarColor(navigationbarColor); - super.setLightNavigationBar(lightNavigationBar); - - playerFragment.setMenuVisibility(false); - playerFragment.setUserVisibleHint(false); - playerFragment.onHide(); - } - - public void onPanelExpanded(View panel) { - // setting fragments values - int playerFragmentColor = playerFragment.getPaletteColor(); - super.setTaskDescriptionColor(playerFragmentColor); - - if (currentNowPlayingScreen == NowPlayingScreen.COLOR) { - super.setNavigationbarColor(playerFragmentColor); - } else { - super.setNavigationbarColor(ThemeStore.primaryColor(this)); - } - - setLightStatusBar(); - - playerFragment.setMenuVisibility(true); - playerFragment.setUserVisibleHint(true); - playerFragment.onShow(); - } - - private void setLightStatusBar() { - super.setLightStatusbar(PreferenceUtil.getInstance(this).getAdaptiveColor() && - ColorUtil.isColorLight(ThemeStore.primaryColor(this)) && - (currentNowPlayingScreen == NowPlayingScreen.FLAT - || currentNowPlayingScreen == NowPlayingScreen.PLAIN - || currentNowPlayingScreen == NowPlayingScreen.SIMPLE - || currentNowPlayingScreen == NowPlayingScreen.NORMAL - || currentNowPlayingScreen == NowPlayingScreen.ADAPTIVE - || currentNowPlayingScreen == NowPlayingScreen.TINY - || currentNowPlayingScreen == NowPlayingScreen.MATERIAL)); - } - - @Override - public void setLightStatusbar(boolean enabled) { - lightStatusBar = enabled; - if (getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) { - super.setLightStatusbar(enabled); - } - } - - @Override - public void setLightNavigationBar(boolean enabled) { - lightNavigationBar = enabled; - /*if (getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) { - super.setLightNavigationBar(enabled); - }*/ - } - - @Override - public void setTaskDescriptionColor(@ColorInt int color) { - taskColor = color; - if (getPanelState() == null || getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) { - super.setTaskDescriptionColor(color); - } - } - - @Override - public void setNavigationbarColor(int color) { - navigationbarColor = color; - if (getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) { - if (navigationBarColorAnimator != null) { - navigationBarColorAnimator.cancel(); - } - super.setNavigationbarColor(color); - } - } - - @Override - public void onPaletteColorChanged() { - int playerFragmentColor = playerFragment.getPaletteColor(); - - if (getPanelState() == PanelState.EXPANDED) { - super.setTaskDescriptionColor(playerFragmentColor); - if (currentNowPlayingScreen == NowPlayingScreen.COLOR) { - super.setNavigationbarColor(playerFragmentColor); - } - } - } - - private void setMiniPlayerAlphaProgress(@FloatRange(from = 0, to = 1) float progress) { - if (miniPlayerFragment == null) { - return; - } - float alpha = 1 - progress; - miniPlayerFragment.getView().setAlpha(alpha); - // necessary to make the views below clickable - miniPlayerFragment.getView().setVisibility(alpha == 0 ? View.GONE : View.VISIBLE); - - } - public void hideBottomBar(final boolean hide) { - - int heightOfBar = - getResources().getDimensionPixelSize(R.dimen.mini_player_height); - int heightOfBarWithTabs = - getResources().getDimensionPixelSize(R.dimen.mini_player_height_expanded); - - if (hide) { - slidingUpPanelLayout.setPanelHeight(0); - collapsePanel(); - } else { - if (!MusicPlayerRemote.getPlayingQueue().isEmpty()) { - slidingUpPanelLayout.setPanelHeight(bottomNavigationView.getVisibility() == View.VISIBLE ? - heightOfBarWithTabs : heightOfBar); - } - } + miniPlayerContainer.setVisibility(hide ? View.GONE : View.VISIBLE); } - protected View wrapSlidingMusicPanel(@LayoutRes int resId) { @SuppressLint("InflateParams") View slidingMusicPanelLayout = getLayoutInflater().inflate(R.layout.sliding_music_panel_layout, null); @@ -348,51 +105,13 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi @Override public void onBackPressed() { - if (!handleBackPress()) { + if (handleBackPress()) { super.onBackPressed(); } } public boolean handleBackPress() { - if (slidingUpPanelLayout.getPanelHeight() != 0 && playerFragment.onBackPressed()) { - return true; - } - if (getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) { - collapsePanel(); - return true; - } - return false; - } - - private void animateNavigationBarColor(int color) { - if (navigationBarColorAnimator != null) { - navigationBarColorAnimator.cancel(); - } - navigationBarColorAnimator = ValueAnimator.ofArgb(getWindow().getNavigationBarColor(), color) - .setDuration(ViewUtil.RETRO_MUSIC_ANIM_TIME); - navigationBarColorAnimator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f)); - navigationBarColorAnimator.addUpdateListener(animation -> { - int playerFragmentColorDark = ColorUtil.darkenColor((Integer) animation.getAnimatedValue()); - - //bottomNavigationView.setBackgroundColor(playerFragmentColorDark); - miniPlayerFragment.setColor(playerFragmentColorDark); - AbsSlidingMusicPanelActivity.super.setNavigationbarColor(playerFragmentColorDark); - - View view = getWindow().getDecorView().getRootView(); - view.setBackgroundColor(playerFragmentColorDark); - - if (view.findViewById(R.id.toolbar) != null) { - view.findViewById(R.id.toolbar).setBackgroundColor(playerFragmentColorDark); - } - if (view.findViewById(R.id.app_bar) != null) { - view.findViewById(R.id.app_bar).setBackgroundColor(playerFragmentColorDark); - } - if (view.findViewById(R.id.status_bar) != null) { - view.findViewById(R.id.status_bar) - .setBackgroundColor(ColorUtil.darkenColor(playerFragmentColorDark)); - } - }); - navigationBarColorAnimator.start(); + return true; } @Override @@ -400,31 +119,6 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi return findViewById(R.id.content_container); } - public SlidingUpPanelLayout getSlidingUpPanelLayout() { - return slidingUpPanelLayout; - } - - public MiniPlayerFragment getMiniPlayerFragment() { - return miniPlayerFragment; - } - - public AbsPlayerFragment getPlayerFragment() { - return playerFragment; - } - - - public SlidingUpPanelLayout.PanelState getPanelState() { - return slidingUpPanelLayout == null ? null : slidingUpPanelLayout.getPanelState(); - } - - public void collapsePanel() { - slidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); - } - - public void expandPanel() { - slidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED); - } - @Override public void hideCastMiniController() { super.hideCastMiniController(); @@ -436,16 +130,6 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi MusicPlayerRemote.setZeroVolume(); } - private void setupBottomView() { - bottomNavigationView.setBackgroundColor(ThemeStore.primaryColor(this)); - bottomNavigationView.setSelectedItemId(PreferenceUtil.getInstance(this).getLastPage()); - int iconColor = ATHUtil.resolveColor(this, R.attr.iconColor); - int accentColor = ThemeStore.accentColor(this); - NavigationViewUtil.setItemIconColors(bottomNavigationView, ColorUtil.withAlpha(iconColor, 0.5f), accentColor); - NavigationViewUtil.setItemTextColors(bottomNavigationView, ColorUtil.withAlpha(iconColor, 0.5f), accentColor); - bottomNavigationView.setLabelVisibilityMode(PreferenceUtil.getInstance(this).getTabTitleMode()); - } - @Override public void onPlayingMetaChanged() { super.onPlayingMetaChanged(); @@ -457,17 +141,12 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi CastHelper.startCasting(castSession, MusicPlayerRemote.getCurrentSong()); } - public void setBottomBarVisibility(int gone) { - if (bottomNavigationView != null) { - //TransitionManager.beginDelayedTransition(bottomNavigationView); - bottomNavigationView.setVisibility(gone); - hideBottomBar(false); - } + public void toggleBottomNavigationView(boolean toggle) { + bottomNavigationView.setVisibility(toggle ? View.GONE : View.VISIBLE); } public BottomNavigationView getBottomNavigationView() { return bottomNavigationView; } - } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsThemeActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsThemeActivity.java index 9f12828d..86a0f540 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsThemeActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsThemeActivity.java @@ -5,12 +5,12 @@ import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Bundle; import android.os.Handler; -import androidx.annotation.ColorInt; -import androidx.core.content.ContextCompat; import android.view.KeyEvent; import android.view.View; import android.view.WindowManager; +import androidx.annotation.ColorInt; +import androidx.core.content.ContextCompat; import code.name.monkey.appthemehelper.ATH; import code.name.monkey.appthemehelper.ATHActivity; import code.name.monkey.appthemehelper.ThemeStore; @@ -29,7 +29,7 @@ public abstract class AbsThemeActivity extends ATHActivity implements Runnable { @Override protected void onCreate(Bundle savedInstanceState) { - setTheme(PreferenceUtil.getInstance(this).getGeneralTheme()); + setTheme(PreferenceUtil.getInstance().getGeneralTheme()); hideStatusBar(); super.onCreate(savedInstanceState); MaterialDialogsUtil.updateMaterialDialogsThemeSingleton(this); @@ -41,7 +41,7 @@ public abstract class AbsThemeActivity extends ATHActivity implements Runnable { } private void toggleScreenOn() { - if (PreferenceUtil.getInstance(this).isScreenOnEnabled()) { + if (PreferenceUtil.getInstance().isScreenOnEnabled()) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } else { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); @@ -61,7 +61,7 @@ public abstract class AbsThemeActivity extends ATHActivity implements Runnable { } public void hideStatusBar() { - hideStatusBar(PreferenceUtil.getInstance(this).getFullScreenMode()); + hideStatusBar(PreferenceUtil.getInstance().getFullScreenMode()); } private void hideStatusBar(boolean fullscreen) { @@ -73,14 +73,14 @@ public abstract class AbsThemeActivity extends ATHActivity implements Runnable { private void changeBackgroundShape() { - Drawable background = PreferenceUtil.getInstance(this).isRoundCorners() ? + Drawable background = PreferenceUtil.getInstance().isRoundCorners() ? ContextCompat.getDrawable(this, R.drawable.round_window) : ContextCompat.getDrawable(this, R.drawable.square_window); background = TintHelper.createTintedDrawable(background, ThemeStore.primaryColor(this)); getWindow().setBackgroundDrawable(background); } - protected void setDrawUnderStatusBar(boolean drawUnderStatusbar) { + public void setDrawUnderStatusBar() { if (VersionUtils.hasLollipop()) { RetroUtil.setAllowDrawUnderStatusBar(getWindow()); } else if (VersionUtils.hasKitKat()) { @@ -88,6 +88,14 @@ public abstract class AbsThemeActivity extends ATHActivity implements Runnable { } } + public void setDrawUnderNavigationBar() { + if (VersionUtils.hasLollipop()) { + RetroUtil.setAllowDrawUnderNavigationBar(getWindow()); + } else if (VersionUtils.hasKitKat()) { + RetroUtil.setStatusBarTranslucent(getWindow()); + } + } + /** * This will set the color of the view with the id "status_bar" on KitKat and Lollipop. On * Lollipop if no such view is found it will set the statusbar color using the native method. @@ -104,6 +112,9 @@ public abstract class AbsThemeActivity extends ATHActivity implements Runnable { } else { statusBar.setBackgroundColor(color); } + } else if (VersionUtils.hasMarshmallow()) { + getWindow().setStatusBarColor(color); + setLightStatusbarAuto(color); } else if (Build.VERSION.SDK_INT >= 21) { getWindow().setStatusBarColor(ColorUtil.darkenColor(color)); setLightStatusbarAuto(color); @@ -171,7 +182,7 @@ public abstract class AbsThemeActivity extends ATHActivity implements Runnable { View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; - if (PreferenceUtil.getInstance(this).getFullScreenMode()) { + if (PreferenceUtil.getInstance().getFullScreenMode()) { getWindow().getDecorView().setSystemUiVisibility(flags); } } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/tageditor/AbsTagEditorActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/tageditor/AbsTagEditorActivity.java index da8e746d..2e0d0340 100755 --- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/tageditor/AbsTagEditorActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/tageditor/AbsTagEditorActivity.java @@ -345,6 +345,15 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity { } } + @Nullable + protected String getComposer() { + try { + return getAudioFile(songPaths.get(0)).getTagOrCreateAndSetDefault().getFirst(FieldKey.COMPOSER); + } catch (Exception ignored) { + return null; + } + } + @Nullable protected Bitmap getAlbumArt() { try { diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/tageditor/AlbumTagEditorActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/tageditor/AlbumTagEditorActivity.java index 00839dee..a909cf2b 100755 --- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/tageditor/AlbumTagEditorActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/tageditor/AlbumTagEditorActivity.java @@ -39,6 +39,7 @@ import butterknife.ButterKnife; import code.name.monkey.appthemehelper.ThemeStore; import code.name.monkey.appthemehelper.util.ATHUtil; import code.name.monkey.appthemehelper.util.TintHelper; +import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.glide.palette.BitmapPaletteTranscoder; import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper; @@ -50,6 +51,7 @@ import code.name.monkey.retromusic.util.ImageUtil; import code.name.monkey.retromusic.util.LastFMUtil; import code.name.monkey.retromusic.util.RetroColorUtil; import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.disposables.CompositeDisposable; import io.reactivex.schedulers.Schedulers; @@ -92,11 +94,12 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text private Bitmap albumArtBitmap; private boolean deleteAlbumArt; private LastFMRestClient lastFMRestClient; + private CompositeDisposable disposable = new CompositeDisposable(); private void setupToolbar() { - title.setTextColor(ThemeStore.textColorPrimary(this)); - // toolbar.setBackgroundColor(ThemeStore.primaryColor(this)); + title.setTextColor(Color.WHITE); toolbar.setNavigationOnClickListener(v -> onBackPressed()); + ToolbarContentTintHelper.setToolbarContentColorBasedOnToolbarColor(this, toolbar, Color.TRANSPARENT); setTitle(null); setSupportActionBar(toolbar); TintHelper.setTintAuto(content, ThemeStore.primaryColor(this), true); @@ -104,7 +107,7 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text @Override protected void onCreate(Bundle savedInstanceState) { - setDrawUnderStatusBar(true); + setDrawUnderStatusBar(); super.onCreate(savedInstanceState); ButterKnife.bind(this); ButterKnife.apply(textInputLayouts, textColor, ThemeStore.accentColor((this))); @@ -128,7 +131,6 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text year.addTextChangedListener(this); } - private void fillViewsWithFileTags() { albumTitle.setText(getAlbumTitle()); albumArtist.setText(getAlbumArtistName()); @@ -154,11 +156,17 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text return; } - lastFMRestClient.getApiService() + disposable.add(lastFMRestClient.getApiService() .getAlbumInfo(albumTitleStr, albumArtistNameStr, null) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.computation()) - .subscribe(this::extractDetails); + .subscribe(this::extractDetails)); + } + + @Override + protected void onPause() { + super.onPause(); + disposable.clear(); } private void extractDetails(@NonNull LastFmAlbum lastFmAlbum) { diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/tageditor/SongTagEditorActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/tageditor/SongTagEditorActivity.java index 95c96c5d..8621dc4f 100755 --- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/tageditor/SongTagEditorActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/tageditor/SongTagEditorActivity.java @@ -2,14 +2,13 @@ package code.name.monkey.retromusic.ui.activities.tageditor; import android.net.Uri; import android.os.Bundle; -import androidx.annotation.NonNull; -import com.google.android.material.appbar.AppBarLayout; -import androidx.appcompat.widget.Toolbar; import android.text.Editable; import android.text.TextWatcher; import android.widget.EditText; import android.widget.TextView; +import com.google.android.material.appbar.AppBarLayout; + import org.jaudiotagger.tag.FieldKey; import java.util.ArrayList; @@ -17,6 +16,8 @@ import java.util.EnumMap; import java.util.List; import java.util.Map; +import androidx.annotation.NonNull; +import androidx.appcompat.widget.Toolbar; import butterknife.BindView; import butterknife.ButterKnife; import code.name.monkey.appthemehelper.ThemeStore; @@ -60,6 +61,9 @@ public class SongTagEditorActivity extends AbsTagEditorActivity implements TextW @BindView(R.id.album_artist) EditText albumArtist; + @BindView(R.id.composer) + EditText composer; + private void setupToolbar() { appBarLayout.setBackgroundColor(ThemeStore.primaryColor(this)); toolbar.setBackgroundColor(ThemeStore.primaryColor(this)); @@ -90,7 +94,7 @@ public class SongTagEditorActivity extends AbsTagEditorActivity implements TextW year.addTextChangedListener(this); trackNumber.addTextChangedListener(this); lyrics.addTextChangedListener(this); - + composer.addTextChangedListener(this); } private void fillViewsWithFileTags() { @@ -102,6 +106,7 @@ public class SongTagEditorActivity extends AbsTagEditorActivity implements TextW year.setText(getSongYear()); trackNumber.setText(getTrackNumber()); lyrics.setText(getLyrics()); + composer.setText(getComposer()); } @Override @@ -135,6 +140,7 @@ public class SongTagEditorActivity extends AbsTagEditorActivity implements TextW fieldKeyValueMap.put(FieldKey.TRACK, trackNumber.getText().toString()); fieldKeyValueMap.put(FieldKey.LYRICS, lyrics.getText().toString()); fieldKeyValueMap.put(FieldKey.ALBUM_ARTIST, albumArtist.getText().toString()); + fieldKeyValueMap.put(FieldKey.COMPOSER, composer.getText().toString()); writeValuesToFiles(fieldKeyValueMap, null); } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/adapter/CollageSongAdapter.java b/app/src/main/java/code/name/monkey/retromusic/ui/adapter/CollageSongAdapter.java index fba5e4ca..8ea4da89 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/adapter/CollageSongAdapter.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/adapter/CollageSongAdapter.java @@ -1,9 +1,6 @@ package code.name.monkey.retromusic.ui.adapter; import android.app.Activity; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -14,10 +11,14 @@ import com.bumptech.glide.Glide; import java.util.ArrayList; import java.util.List; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.recyclerview.widget.RecyclerView; import butterknife.BindViews; import butterknife.ButterKnife; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.glide.SongGlideRequest; +import code.name.monkey.retromusic.helper.MusicPlayerRemote; import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.ui.adapter.CollageSongAdapter.CollageSongViewHolder; import code.name.monkey.retromusic.ui.adapter.base.MediaEntryViewHolder; @@ -37,10 +38,7 @@ public class CollageSongAdapter extends RecyclerView.Adapter 9) { for (int i = 0; i < dataSet.subList(0, 9).size(); i++) { if (holder.imageViews != null) { @@ -83,7 +81,7 @@ public class CollageSongAdapter extends RecyclerView.Adapter { - + MusicPlayerRemote.playNext(dataSet.get(startPosition)); }); } } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/adapter/GenreAdapter.java b/app/src/main/java/code/name/monkey/retromusic/ui/adapter/GenreAdapter.java index e7f217e9..1b9ac20e 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/adapter/GenreAdapter.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/adapter/GenreAdapter.java @@ -1,9 +1,6 @@ package code.name.monkey.retromusic.ui.adapter; import android.app.Activity; -import android.graphics.PorterDuff; -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -11,7 +8,8 @@ import android.view.ViewGroup; import java.util.ArrayList; import java.util.Locale; -import code.name.monkey.appthemehelper.util.ATHUtil; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.model.Genre; import code.name.monkey.retromusic.ui.adapter.base.MediaEntryViewHolder; @@ -36,13 +34,14 @@ public class GenreAdapter extends RecyclerView.Adapter return mGenres; } + @NonNull @Override - public GenreAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + public GenreAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { return new ViewHolder(LayoutInflater.from(mActivity).inflate(mItemLayoutRes, parent, false)); } @Override - public void onBindViewHolder(GenreAdapter.ViewHolder holder, int position) { + public void onBindViewHolder(@NonNull GenreAdapter.ViewHolder holder, int position) { Genre genre = mGenres.get(position); if (holder.title != null) { holder.title.setText(genre.name); @@ -52,11 +51,9 @@ public class GenreAdapter extends RecyclerView.Adapter mActivity.getString(R.string.songs) : mActivity.getString(R.string.song))); } - if (holder.image != null) { - holder.image.setImageResource(R.drawable.ic_recent_actors_white_24dp); - } - if (holder.shortSeparator != null) { - holder.shortSeparator.setVisibility(View.VISIBLE); + + if (holder.separator != null) { + holder.separator.setVisibility(View.VISIBLE); } } @@ -76,11 +73,8 @@ public class GenreAdapter extends RecyclerView.Adapter if (menu != null) { menu.setVisibility(View.GONE); } - if (image != null) { - int iconPadding = mActivity.getResources().getDimensionPixelSize(R.dimen.list_item_image_icon_padding); - image.setPadding(iconPadding, iconPadding, iconPadding, iconPadding); - image.setColorFilter(ATHUtil.resolveColor(mActivity, R.attr.iconColor), PorterDuff.Mode.SRC_IN); - } + assert imageContainer != null; + imageContainer.setVisibility(View.GONE); } @Override diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/adapter/album/AlbumAdapter.java b/app/src/main/java/code/name/monkey/retromusic/ui/adapter/album/AlbumAdapter.java index e45bfe57..0825fc39 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/adapter/album/AlbumAdapter.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/adapter/album/AlbumAdapter.java @@ -205,7 +205,7 @@ public class AlbumAdapter extends AbsMultiSelectAdapter { private Activity activity; diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/adapter/playlist/PlaylistAdapter.java b/app/src/main/java/code/name/monkey/retromusic/ui/adapter/playlist/PlaylistAdapter.java index 972f800e..945800fe 100755 --- a/app/src/main/java/code/name/monkey/retromusic/ui/adapter/playlist/PlaylistAdapter.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/adapter/playlist/PlaylistAdapter.java @@ -2,11 +2,6 @@ package code.name.monkey.retromusic.ui.adapter.playlist; import android.graphics.Bitmap; import android.graphics.PorterDuff; -import androidx.annotation.LayoutRes; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.PopupMenu; import android.util.Log; import android.view.LayoutInflater; import android.view.MenuItem; @@ -20,6 +15,11 @@ import java.util.List; import java.util.Locale; import java.util.concurrent.ExecutionException; +import androidx.annotation.LayoutRes; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.PopupMenu; import butterknife.ButterKnife; import code.name.monkey.appthemehelper.util.ATHUtil; import code.name.monkey.retromusic.R; @@ -41,9 +41,6 @@ import code.name.monkey.retromusic.util.NavigationUtil; import code.name.monkey.retromusic.util.RetroUtil; import io.reactivex.Observable; -/** - * Created by BlackFootSanji on 9/19/2016. - */ public class PlaylistAdapter extends AbsMultiSelectAdapter { public static final String TAG = PlaylistAdapter.class.getSimpleName(); diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/adapter/song/PlayingQueueAdapter.java b/app/src/main/java/code/name/monkey/retromusic/ui/adapter/song/PlayingQueueAdapter.java index ffdf3b86..2ade982c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/adapter/song/PlayingQueueAdapter.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/adapter/song/PlayingQueueAdapter.java @@ -15,11 +15,9 @@ import java.util.ArrayList; import androidx.annotation.LayoutRes; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.helper.MusicPlayerRemote; -import code.name.monkey.retromusic.interfaces.CabHolder; import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.util.MusicUtil; import code.name.monkey.retromusic.util.ViewUtil; @@ -34,8 +32,8 @@ public class PlayingQueueAdapter extends SongAdapter implements DraggableItemAda private int current; public PlayingQueueAdapter(AppCompatActivity activity, ArrayList dataSet, int current, - @LayoutRes int itemLayoutRes, boolean usePalette, @Nullable CabHolder cabHolder) { - super(activity, dataSet, itemLayoutRes, usePalette, cabHolder); + @LayoutRes int itemLayoutRes) { + super(activity, dataSet, itemLayoutRes, false, null); this.current = current; } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/adapter/song/SongAdapter.java b/app/src/main/java/code/name/monkey/retromusic/ui/adapter/song/SongAdapter.java index 29a4180b..0a477167 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/adapter/song/SongAdapter.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/adapter/song/SongAdapter.java @@ -198,7 +198,7 @@ public class SongAdapter extends AbsMultiSelectAdapter NavigationUtil.gotoNowPlayingActivity(getContext(), Pair.create(v, getString(R.string.transition_mini_player)))); setUpMiniPlayer(); if (RetroUtil.isTablet(getResources())) { @@ -87,9 +88,9 @@ public class MiniPlayerFragment extends AbsMusicServiceFragment implements Music previous.setVisibility(View.VISIBLE); playingQueue.setVisibility(View.VISIBLE); } else { - next.setVisibility(PreferenceUtil.getInstance(getContext()).isExtraMiniExtraControls() ? View.VISIBLE : View.GONE); - playingQueue.setVisibility(PreferenceUtil.getInstance(getContext()).isExtraMiniExtraControls() ? View.GONE : View.VISIBLE); - previous.setVisibility(PreferenceUtil.getInstance(getContext()).isExtraMiniExtraControls() ? View.VISIBLE : View.GONE); + next.setVisibility(PreferenceUtil.getInstance().isExtraMiniExtraControls() ? View.VISIBLE : View.GONE); + playingQueue.setVisibility(PreferenceUtil.getInstance().isExtraMiniExtraControls() ? View.GONE : View.VISIBLE); + previous.setVisibility(PreferenceUtil.getInstance().isExtraMiniExtraControls() ? View.VISIBLE : View.GONE); } } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/NowPlayingScreen.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/NowPlayingScreen.java index b5b232db..e20b20dc 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/NowPlayingScreen.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/NowPlayingScreen.java @@ -18,7 +18,8 @@ public enum NowPlayingScreen { SIMPLE(R.string.simple, R.drawable.np_simple, 8), BLUR_CARD(R.string.blur_card, R.drawable.np_blur_card, 9), ADAPTIVE(R.string.adaptive, R.drawable.np_adaptive, 10), - MATERIAL(R.string.material, R.drawable.np_material, 11); + MATERIAL(R.string.material, R.drawable.np_material, 11), + FIT(R.string.fit, R.drawable.np_adaptive, 12); @StringRes public final int titleRes; diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/PlayingQueueFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/PlayingQueueFragment.java index ebea9479..d3cc29b9 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/PlayingQueueFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/PlayingQueueFragment.java @@ -56,9 +56,7 @@ public class PlayingQueueFragment extends AbsMusicServiceFragment { (AppCompatActivity) getActivity(), MusicPlayerRemote.getPlayingQueue(), MusicPlayerRemote.getPosition(), - R.layout.item_queue, - false, - null); + R.layout.item_queue); mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(mPlayingQueueAdapter); mLayoutManager = new LinearLayoutManager(getContext()); diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/VolumeFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/VolumeFragment.java index 5ede2e6c..a314fd92 100755 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/VolumeFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/VolumeFragment.java @@ -1,10 +1,8 @@ package code.name.monkey.retromusic.ui.fragments; import android.content.Context; -import android.content.res.ColorStateList; import android.graphics.Color; import android.graphics.PorterDuff; -import android.graphics.drawable.ColorDrawable; import android.media.AudioManager; import android.os.Bundle; import android.view.LayoutInflater; @@ -20,9 +18,11 @@ import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import butterknife.Unbinder; -import code.name.monkey.appthemehelper.ThemeStore; +import code.name.monkey.appthemehelper.util.ATHUtil; import code.name.monkey.appthemehelper.util.TintHelper; import code.name.monkey.retromusic.R; +import code.name.monkey.retromusic.helper.MusicPlayerRemote; +import code.name.monkey.retromusic.util.PreferenceUtil; import code.name.monkey.retromusic.volume.AudioVolumeObserver; import code.name.monkey.retromusic.volume.OnAudioVolumeChangedListener; @@ -31,10 +31,13 @@ public class VolumeFragment extends Fragment implements SeekBar.OnSeekBarChangeL @BindView(R.id.volume_seekbar) SeekBar volumeSeekbar; + @BindView(R.id.volume_down) ImageView volumeDown; + @BindView(R.id.container) ViewGroup viewGroup; + @BindView(R.id.volume_up) ImageView volumeUp; @@ -58,7 +61,7 @@ public class VolumeFragment extends Fragment implements SeekBar.OnSeekBarChangeL public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); //noinspection ConstantConditions - setTintable(ThemeStore.textColorSecondary(getContext())); + setTintable(ATHUtil.resolveColor(getContext(), R.attr.iconColor)); } @Override @@ -108,8 +111,9 @@ public class VolumeFragment extends Fragment implements SeekBar.OnSeekBarChangeL if (audioManager != null) { audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, i, 0); } - volumeDown.setImageResource( - i == 0 ? R.drawable.ic_volume_off_white_24dp : R.drawable.ic_volume_down_white_24dp); + setPauseWhenZeroVolume(i < 1); + volumeDown.setImageResource(i == 0 ? R.drawable.ic_volume_off_white_24dp : R.drawable.ic_volume_down_white_24dp); + } @Override @@ -139,10 +143,6 @@ public class VolumeFragment extends Fragment implements SeekBar.OnSeekBarChangeL } } - public void setColor(int color) { - volumeSeekbar.setProgressTintList(ColorStateList.valueOf(color)); - } - public void tintWhiteColor() { setProgressBarColor(Color.WHITE); } @@ -160,4 +160,13 @@ public class VolumeFragment extends Fragment implements SeekBar.OnSeekBarChangeL public void removeThumb() { volumeSeekbar.setThumb(null); } + + private void setPauseWhenZeroVolume(boolean pauseWhenZeroVolume) { + if (PreferenceUtil.getInstance().pauseOnZeroVolume() && pauseWhenZeroVolume) + if (MusicPlayerRemote.isPlaying()) { + MusicPlayerRemote.pauseSong(); + } else { + MusicPlayerRemote.resumePlaying(); + } + } } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsLibraryPagerRecyclerViewFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsLibraryPagerRecyclerViewFragment.java index 69032277..4f96cbe4 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsLibraryPagerRecyclerViewFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsLibraryPagerRecyclerViewFragment.java @@ -1,20 +1,20 @@ package code.name.monkey.retromusic.ui.fragments.base; import android.os.Bundle; -import androidx.annotation.LayoutRes; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.annotation.StringRes; -import com.google.android.material.appbar.AppBarLayout; -import com.google.android.material.appbar.AppBarLayout.OnOffsetChangedListener; -import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; +import com.google.android.material.appbar.AppBarLayout; +import com.google.android.material.appbar.AppBarLayout.OnOffsetChangedListener; import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView; +import androidx.annotation.LayoutRes; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.StringRes; +import androidx.recyclerview.widget.RecyclerView; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.Unbinder; diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsMainActivityFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsMainActivityFragment.java index 3eb9cd03..84be8d67 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsMainActivityFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsMainActivityFragment.java @@ -6,6 +6,7 @@ import android.view.View; import code.name.monkey.appthemehelper.ThemeStore; import code.name.monkey.appthemehelper.util.ColorUtil; +import code.name.monkey.appthemehelper.util.VersionUtils; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.dialogs.MainOptionsBottomSheetDialogFragment; import code.name.monkey.retromusic.ui.activities.MainActivity; @@ -46,7 +47,11 @@ public abstract class AbsMainActivityFragment extends AbsMusicServiceFragment { public void setStatusbarColorAuto(View view) { // we don't want to use statusbar color because we are doing the color darkening on our own to support KitKat //noinspection ConstantConditions - setStatusbarColor(view, ColorUtil.darkenColor(ThemeStore.primaryColor(getContext()))); + if (VersionUtils.hasMarshmallow()) { + setStatusbarColor(view, ThemeStore.primaryColor(getContext())); + } else { + setStatusbarColor(view, ColorUtil.darkenColor(ThemeStore.primaryColor(getContext()))); + } } protected void showMainMenu() { diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsMusicServiceFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsMusicServiceFragment.java index 83db0426..71b9d11c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsMusicServiceFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsMusicServiceFragment.java @@ -2,10 +2,11 @@ package code.name.monkey.retromusic.ui.fragments.base; import android.content.Context; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; import android.view.View; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; import code.name.monkey.retromusic.interfaces.MusicServiceEventListener; import code.name.monkey.retromusic.ui.activities.base.AbsMusicServiceActivity; @@ -17,6 +18,10 @@ public class AbsMusicServiceFragment extends Fragment implements MusicServiceEve private AbsMusicServiceActivity activity; + @Nullable + public AbsMusicServiceActivity getPlayerActivity() { + return activity; + } @Override public void onAttach(Context context) { diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsPlayerControlsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsPlayerControlsFragment.java index d5a8d090..8948f591 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsPlayerControlsFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsPlayerControlsFragment.java @@ -1,5 +1,9 @@ package code.name.monkey.retromusic.ui.fragments.base; +import android.view.View; +import android.view.animation.AccelerateInterpolator; +import android.view.animation.DecelerateInterpolator; + import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper; /** @@ -20,4 +24,29 @@ public abstract class AbsPlayerControlsFragment extends AbsMusicServiceFragment protected abstract void setUpProgressSlider(); public abstract void setDark(int color); + + public void showBouceAnimation(View view) { + view.clearAnimation(); + + view.setScaleX(0.9f); + view.setScaleY(0.9f); + view.setVisibility(View.VISIBLE); + view.setPivotX(view.getWidth() / 2); + view.setPivotY(view.getHeight() / 2); + + view.animate() + .setDuration(200) + .setInterpolator(new DecelerateInterpolator()) + .scaleX(1.1f) + .scaleY(1.1f) + .withEndAction(() -> view.animate() + .setDuration(200) + .setInterpolator(new AccelerateInterpolator()) + .scaleX(1f) + .scaleY(1f) + .alpha(1f) + .start()) + .start(); + } + } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsPlayerFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsPlayerFragment.java index 802de39a..4baa5881 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsPlayerFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsPlayerFragment.java @@ -34,6 +34,7 @@ import code.name.monkey.retromusic.util.MusicUtil; import code.name.monkey.retromusic.util.NavigationUtil; import code.name.monkey.retromusic.util.PreferenceUtil; import code.name.monkey.retromusic.util.RetroUtil; +import code.name.monkey.retromusic.views.FitSystemWindowsLayout; public abstract class AbsPlayerFragment extends AbsMusicServiceFragment implements Toolbar.OnMenuItemClickListener, PaletteColorHolder { public static final String TAG = AbsPlayerFragment.class.getSimpleName(); @@ -51,6 +52,14 @@ public abstract class AbsPlayerFragment extends AbsMusicServiceFragment implemen } } + protected void addSafeArea(View view) { + FitSystemWindowsLayout safeArea = view.findViewById(R.id.safeArea); + if (safeArea != null) { + if (PreferenceUtil.getInstance().getFullScreenMode()) safeArea.setFit(false); + else safeArea.setFit(true); + } + } + @Override public void onDetach() { super.onDetach(); @@ -117,6 +126,9 @@ public abstract class AbsPlayerFragment extends AbsMusicServiceFragment implemen case R.id.action_set_as_ringtone: MusicUtil.setRingtone(getActivity(), song.id); return true; + case R.id.action_settings: + NavigationUtil.goToSettings(getActivity()); + return true; case R.id.action_go_to_genre: MediaMetadataRetriever retriever = new MediaMetadataRetriever(); Uri trackUri = ContentUris.withAppendedId(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, song.id); @@ -148,23 +160,19 @@ public abstract class AbsPlayerFragment extends AbsMusicServiceFragment implemen @Override public void onServiceConnected() { updateIsFavorite(); - //updateLyrics(); } @Override public void onPlayingMetaChanged() { updateIsFavorite(); - //updateLyrics(); } @Override public void onDestroyView() { - if (updateIsFavoriteTask != null && !updateIsFavoriteTask.isCancelled()) { updateIsFavoriteTask.cancel(true); } super.onDestroyView(); - } @SuppressLint("StaticFieldLeak") @@ -209,8 +217,9 @@ public abstract class AbsPlayerFragment extends AbsMusicServiceFragment implemen public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); view.setBackgroundColor(ThemeStore.primaryColor(getActivity())); - if (PreferenceUtil.getInstance(getContext()).getFullScreenMode()) { - view.findViewById(R.id.status_bar).setVisibility(View.GONE); + if (PreferenceUtil.getInstance().getFullScreenMode()) { + if (view.findViewById(R.id.status_bar) != null) + view.findViewById(R.id.status_bar).setVisibility(View.GONE); } } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/AlbumsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/AlbumsFragment.java index 478fa149..eb70040a 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/AlbumsFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/AlbumsFragment.java @@ -40,7 +40,7 @@ public class AlbumsFragment extends AbsLibraryPagerRecyclerViewCustomGridSizeFra notifyLayoutResChanged(itemLayoutRes); if (itemLayoutRes != R.layout.item_list) { //noinspection ConstantConditions - itemLayoutRes = PreferenceUtil.getInstance(getContext()).getAlbumGridStyle(getContext()); + itemLayoutRes = PreferenceUtil.getInstance().getAlbumGridStyle(getContext()); } ArrayList dataSet = getAdapter() == null ? new ArrayList<>() : getAdapter().getDataSet(); return new AlbumAdapter(getLibraryFragment().getMainActivity(), dataSet, itemLayoutRes, loadUsePalette(), getLibraryFragment()); @@ -54,7 +54,7 @@ public class AlbumsFragment extends AbsLibraryPagerRecyclerViewCustomGridSizeFra @Override public boolean loadUsePalette() { //noinspection ConstantConditions - return PreferenceUtil.getInstance(getActivity()).albumColoredFooters(); + return PreferenceUtil.getInstance().albumColoredFooters(); } @Override @@ -76,43 +76,43 @@ public class AlbumsFragment extends AbsLibraryPagerRecyclerViewCustomGridSizeFra @Override protected String loadSortOrder() { //noinspection ConstantConditions - return PreferenceUtil.getInstance(getActivity()).getAlbumSortOrder(); + return PreferenceUtil.getInstance().getAlbumSortOrder(); } @Override protected void saveSortOrder(String sortOrder) { //noinspection ConstantConditions - PreferenceUtil.getInstance(getActivity()).setAlbumSortOrder(sortOrder); + PreferenceUtil.getInstance().setAlbumSortOrder(sortOrder); } @Override protected int loadGridSize() { //noinspection ConstantConditions - return PreferenceUtil.getInstance(getActivity()).getAlbumGridSize(getActivity()); + return PreferenceUtil.getInstance().getAlbumGridSize(getActivity()); } @Override protected void saveGridSize(int gridSize) { //noinspection ConstantConditions - PreferenceUtil.getInstance(getActivity()).setAlbumGridSize(gridSize); + PreferenceUtil.getInstance().setAlbumGridSize(gridSize); } @Override protected int loadGridSizeLand() { //noinspection ConstantConditions - return PreferenceUtil.getInstance(getActivity()).getAlbumGridSizeLand(getActivity()); + return PreferenceUtil.getInstance().getAlbumGridSizeLand(getActivity()); } @Override protected void saveGridSizeLand(int gridSize) { //noinspection ConstantConditions - PreferenceUtil.getInstance(getActivity()).setAlbumGridSizeLand(gridSize); + PreferenceUtil.getInstance().setAlbumGridSizeLand(gridSize); } @Override protected void saveUsePalette(boolean usePalette) { //noinspection ConstantConditions - PreferenceUtil.getInstance(getActivity()).setAlbumColoredFooters(usePalette); + PreferenceUtil.getInstance().setAlbumColoredFooters(usePalette); } @Override @@ -132,7 +132,7 @@ public class AlbumsFragment extends AbsLibraryPagerRecyclerViewCustomGridSizeFra if (menuVisible) { //noinspection ConstantConditions getLibraryFragment().setTitle( - PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library + PreferenceUtil.getInstance().tabTitles() ? R.string.library : R.string.albums); } } @@ -142,7 +142,7 @@ public class AlbumsFragment extends AbsLibraryPagerRecyclerViewCustomGridSizeFra super.onResume(); //noinspection ConstantConditions getLibraryFragment().setTitle( - PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library : R.string.albums); + PreferenceUtil.getInstance().tabTitles() ? R.string.library : R.string.albums); if (getAdapter().getDataSet().isEmpty()) { presenter.subscribe(); } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/ArtistsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/ArtistsFragment.java index b780f23f..5ef3f6b9 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/ArtistsFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/ArtistsFragment.java @@ -49,7 +49,7 @@ public class ArtistsFragment extends int itemLayoutRes = getItemLayoutRes(); notifyLayoutResChanged(itemLayoutRes); if (itemLayoutRes != R.layout.item_list) { - itemLayoutRes = PreferenceUtil.getInstance(getContext()).getArtistGridStyle(getContext()); + itemLayoutRes = PreferenceUtil.getInstance().getArtistGridStyle(getContext()); } ArrayList dataSet = getAdapter() == null ? new ArrayList<>() : getAdapter().getDataSet(); @@ -69,32 +69,32 @@ public class ArtistsFragment extends @Override protected int loadGridSize() { - return PreferenceUtil.getInstance(getActivity()).getArtistGridSize(getActivity()); + return PreferenceUtil.getInstance().getArtistGridSize(getActivity()); } @Override protected void saveGridSize(int gridSize) { - PreferenceUtil.getInstance(getActivity()).setArtistGridSize(gridSize); + PreferenceUtil.getInstance().setArtistGridSize(gridSize); } @Override protected int loadGridSizeLand() { - return PreferenceUtil.getInstance(getActivity()).getArtistGridSizeLand(getActivity()); + return PreferenceUtil.getInstance().getArtistGridSizeLand(getActivity()); } @Override protected void saveGridSizeLand(int gridSize) { - PreferenceUtil.getInstance(getActivity()).setArtistGridSizeLand(gridSize); + PreferenceUtil.getInstance().setArtistGridSizeLand(gridSize); } @Override protected void saveUsePalette(boolean usePalette) { - PreferenceUtil.getInstance(getActivity()).setArtistColoredFooters(usePalette); + PreferenceUtil.getInstance().setArtistColoredFooters(usePalette); } @Override public boolean loadUsePalette() { - return PreferenceUtil.getInstance(getActivity()).artistColoredFooters(); + return PreferenceUtil.getInstance().artistColoredFooters(); } @Override @@ -111,12 +111,12 @@ public class ArtistsFragment extends @Override protected String loadSortOrder() { - return PreferenceUtil.getInstance(getActivity()).getArtistSortOrder(); + return PreferenceUtil.getInstance().getArtistSortOrder(); } @Override protected void saveSortOrder(String sortOrder) { - PreferenceUtil.getInstance(getActivity()).setArtistSortOrder(sortOrder); + PreferenceUtil.getInstance().setArtistSortOrder(sortOrder); } @Override @@ -130,7 +130,7 @@ public class ArtistsFragment extends super.setMenuVisibility(menuVisible); if (menuVisible) { getLibraryFragment().setTitle( - PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library + PreferenceUtil.getInstance().tabTitles() ? R.string.library : R.string.artists); } } @@ -139,7 +139,7 @@ public class ArtistsFragment extends public void onResume() { super.onResume(); getLibraryFragment().setTitle( - PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library : R.string.artists); + PreferenceUtil.getInstance().tabTitles() ? R.string.library : R.string.artists); if (getAdapter().getDataSet().isEmpty()) { presenter.subscribe(); } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/GenreFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/GenreFragment.java index 959ce19c..0ac8a9a1 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/GenreFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/GenreFragment.java @@ -41,14 +41,14 @@ public class GenreFragment extends public void setMenuVisibility(boolean menuVisible) { super.setMenuVisibility(menuVisible); if (menuVisible) { - getLibraryFragment().setTitle(PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library : R.string.genres); + getLibraryFragment().setTitle(PreferenceUtil.getInstance().tabTitles() ? R.string.library : R.string.genres); } } @Override public void onResume() { super.onResume(); - getLibraryFragment().setTitle(PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library : R.string.genres); + getLibraryFragment().setTitle(PreferenceUtil.getInstance().tabTitles() ? R.string.library : R.string.genres); if (getAdapter().getDataSet().isEmpty()) { mPresenter.subscribe(); } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/LibraryFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/LibraryFragment.java index 6abaaae3..d3d56ffa 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/LibraryFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/LibraryFragment.java @@ -62,7 +62,6 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde @BindView(R.id.fragment_container) View contentContainer; - private Unbinder unBinder; private MaterialCab cab; private FragmentManager fragmentManager; @@ -226,10 +225,20 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde if (activity == null) { return; } - ToolbarContentTintHelper.handleOnCreateOptionsMenu(getActivity(), toolbar, menu, - ATHToolbarActivity.getToolbarBackgroundColor(toolbar)); + ToolbarContentTintHelper.handleOnCreateOptionsMenu(getActivity(), toolbar, menu, ATHToolbarActivity.getToolbarBackgroundColor(toolbar)); } + @Override + public void onPrepareOptionsMenu(Menu menu) { + super.onPrepareOptionsMenu(menu); + Activity activity = getActivity(); + if (activity == null) { + return; + } + ToolbarContentTintHelper.handleOnPrepareOptionsMenu(activity, toolbar); + } + + private void setUpSortOrderMenu( @NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment, @NonNull SubMenu sortOrderMenu) { @@ -263,6 +272,8 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_YEAR)); sortOrderMenu.add(0, R.id.action_song_sort_order_date, 4, R.string.sort_order_date) .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_DATE)); + sortOrderMenu.add(0, R.id.action_song_sort_composer, 4, R.string.composer) + .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.COMPOSER)); } sortOrderMenu.setGroupCheckable(0, true, true); @@ -316,6 +327,9 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde case R.id.action_song_sort_order_date: sortOrder = SortOrder.SongSortOrder.SONG_DATE; break; + case R.id.action_song_sort_composer: + sortOrder = SortOrder.SongSortOrder.COMPOSER; + break; } } @@ -328,15 +342,6 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde return false; } - @Override - public void onPrepareOptionsMenu(Menu menu) { - super.onPrepareOptionsMenu(menu); - Activity activity = getActivity(); - if (activity == null) { - return; - } - ToolbarContentTintHelper.handleOnPrepareOptionsMenu(activity, toolbar); - } @SuppressWarnings("ConstantConditions") @Override @@ -469,4 +474,6 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde } return false; } + + } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/PlaylistsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/PlaylistsFragment.java index e9c298a6..19c2d8f2 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/PlaylistsFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/PlaylistsFragment.java @@ -54,14 +54,14 @@ public class PlaylistsFragment extends AbsLibraryPagerRecyclerViewFragment scanPaths(paths)) - .execute(new ListPathsAsyncTask.LoadingInfo(crumb.getFile(), AUDIO_FILE_FILTER)); + new ListPathsAsyncTask(getActivity(), paths -> scanPaths(paths)).execute(new ListPathsAsyncTask.LoadingInfo(crumb.getFile(), AUDIO_FILE_FILTER)); } return true; } @@ -435,7 +431,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements getFileComparator())); return true; case R.id.action_set_as_start_directory: - PreferenceUtil.getInstance(getActivity()).setStartDirectory(file); + PreferenceUtil.getInstance().setStartDirectory(file); Toast.makeText(getActivity(), String.format(getString(R.string.new_start_directory), file.getPath()), Toast.LENGTH_SHORT).show(); @@ -462,14 +458,10 @@ public class FoldersFragment extends AbsMainActivityFragment implements case R.id.action_details: case R.id.action_set_as_ringtone: case R.id.action_delete_from_device: - new ListSongsAsyncTask(getActivity(), null, (songs, extra) -> SongMenuHelper - .handleMenuClick(getActivity(), songs.get(0), itemId)).execute( - new ListSongsAsyncTask.LoadingInfo(toList(file), AUDIO_FILE_FILTER, - getFileComparator())); + new ListSongsAsyncTask(getActivity(), null, (songs, extra) -> SongMenuHelper.handleMenuClick(getActivity(), songs.get(0), itemId)).execute(new ListSongsAsyncTask.LoadingInfo(toList(file), AUDIO_FILE_FILTER, getFileComparator())); return true; case R.id.action_scan: - new ListPathsAsyncTask(getActivity(), this::scanPaths) - .execute(new ListPathsAsyncTask.LoadingInfo(file, AUDIO_FILE_FILTER)); + new ListPathsAsyncTask(getActivity(), this::scanPaths).execute(new ListPathsAsyncTask.LoadingInfo(file, AUDIO_FILE_FILTER)); return true; } return false; diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/home/BannerHomeFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/home/BannerHomeFragment.java index 8ab4c08c..d430a206 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/home/BannerHomeFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/home/BannerHomeFragment.java @@ -1,8 +1,8 @@ package code.name.monkey.retromusic.ui.fragments.mainactivity.home; import android.app.Activity; +import android.content.res.ColorStateList; import android.graphics.Bitmap; -import android.graphics.PorterDuff; import android.os.Bundle; import android.util.DisplayMetrics; import android.view.Display; @@ -41,16 +41,17 @@ import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.helper.MusicPlayerRemote; import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks; import code.name.monkey.retromusic.loaders.SongLoader; -import code.name.monkey.retromusic.misc.AppBarStateChangeListener; import code.name.monkey.retromusic.model.Album; import code.name.monkey.retromusic.model.Artist; import code.name.monkey.retromusic.model.Genre; import code.name.monkey.retromusic.model.Playlist; +import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.model.smartplaylist.HistoryPlaylist; import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist; import code.name.monkey.retromusic.model.smartplaylist.MyTopTracksPlaylist; import code.name.monkey.retromusic.mvp.contract.HomeContract; import code.name.monkey.retromusic.mvp.presenter.HomePresenter; +import code.name.monkey.retromusic.ui.adapter.CollageSongAdapter; import code.name.monkey.retromusic.ui.adapter.GenreAdapter; import code.name.monkey.retromusic.ui.adapter.album.AlbumFullWithAdapter; import code.name.monkey.retromusic.ui.adapter.artist.ArtistAdapter; @@ -69,16 +70,15 @@ import static code.name.monkey.retromusic.Constants.USER_PROFILE; public class BannerHomeFragment extends AbsMainActivityFragment implements MainActivityFragmentCallbacks, HomeContract.HomeView { - public static final String TAG = "HomeFragment"; - Unbinder unbinder; - - @BindView(R.id.home_toolbar) + public static final String TAG = "BannerHomeFragment"; + @BindView(R.id.toolbar) Toolbar toolbar; @BindView(R.id.app_bar) AppBarLayout appbar; @BindView(R.id.image) + @Nullable ImageView imageView; @BindView(R.id.user_image) @@ -123,18 +123,27 @@ public class BannerHomeFragment extends AbsMainActivityFragment implements MainA @BindView(R.id.title) TextView title; + @BindView(R.id.suggestion_songs) + RecyclerView suggestionsSongs; + @BindView(R.id.suggestion_container) + LinearLayout suggestionsContainer; + + @BindView(R.id.search_icon) + ImageView searchIcon; + + private Unbinder unbinder; private HomePresenter homePresenter; private CompositeDisposable disposable; - public static HomeFragment newInstance() { + public static BannerHomeFragment newInstance() { Bundle args = new Bundle(); - HomeFragment fragment = new HomeFragment(); + BannerHomeFragment fragment = new BannerHomeFragment(); fragment.setArguments(args); return fragment; } - private void getTimeOfTheDay() { + private void getTimeOfTheDay(boolean b) { Calendar c = Calendar.getInstance(); int timeOfDay = c.get(Calendar.HOUR_OF_DAY); @@ -150,22 +159,24 @@ public class BannerHomeFragment extends AbsMainActivityFragment implements MainA } else if (timeOfDay >= 20 && timeOfDay < 24) { images = getResources().getStringArray(R.array.night); } + String day = images[new Random().nextInt(images.length)]; loadTimeImage(day); } + private void loadTimeImage(String day) { //noinspection ConstantConditions - if (PreferenceUtil.getInstance(getActivity()).getBannerImage().isEmpty()) { - if (imageView != null) { + if (imageView != null) { + if (PreferenceUtil.getInstance().getBannerImage().isEmpty()) { Glide.with(getActivity()).load(day) .asBitmap() .placeholder(R.drawable.material_design_default) .diskCacheStrategy(DiskCacheStrategy.SOURCE) .into(imageView); + } else { + loadBannerFromStorage(); } - } else { - loadBannerFromStorage(); } } @@ -175,7 +186,7 @@ public class BannerHomeFragment extends AbsMainActivityFragment implements MainA .setQuality(100) .setCompressFormat(Bitmap.CompressFormat.WEBP) .compressToBitmapAsFlowable( - new File(PreferenceUtil.getInstance(getContext()).getBannerImage(), USER_BANNER)) + new File(PreferenceUtil.getInstance().getBannerImage(), USER_BANNER)) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(imageView::setImageBitmap)); @@ -189,7 +200,7 @@ public class BannerHomeFragment extends AbsMainActivityFragment implements MainA .setQuality(75) .setCompressFormat(Bitmap.CompressFormat.WEBP) .compressToBitmapAsFlowable( - new File(PreferenceUtil.getInstance(getContext()).getProfileImage(), USER_PROFILE)) + new File(PreferenceUtil.getInstance().getProfileImage(), USER_PROFILE)) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(imageView::setImageBitmap, @@ -209,7 +220,8 @@ public class BannerHomeFragment extends AbsMainActivityFragment implements MainA @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_home, container, false); + View view = inflater.inflate(PreferenceUtil.getInstance().toggleHomeBanner() ? R.layout.fragment_banner_home : R.layout.fragment_home, + container, false); unbinder = ButterKnife.bind(this, view); return view; } @@ -217,47 +229,28 @@ public class BannerHomeFragment extends AbsMainActivityFragment implements MainA @Override public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - //setStatusbarColorAuto(view); - getMainActivity().getSlidingUpPanelLayout().setShadowHeight(8); setupToolbar(); loadImageFromStorage(userImage); homePresenter.subscribe(); - getTimeOfTheDay(); + getTimeOfTheDay(PreferenceUtil.getInstance().toggleHomeBanner()); } @SuppressWarnings("ConstantConditions") private void setupToolbar() { - appbar.addOnOffsetChangedListener(new AppBarStateChangeListener() { - @Override - public void onStateChanged(AppBarLayout appBarLayout, AppBarStateChangeListener.State state) { - int color; - switch (state) { - case COLLAPSED: - getMainActivity().setLightStatusbar(!ATHUtil.isWindowBackgroundDark(getContext())); - color = ThemeStore.textColorPrimary(getContext()); - break; - default: - case EXPANDED: - case IDLE: - getMainActivity().setLightStatusbar(false); - color = ContextCompat.getColor(getContext(), R.color.md_white_1000); - break; - } - title.setTextColor(color); - toolbar.getNavigationIcon().setColorFilter(color, PorterDuff.Mode.SRC_IN); - } - }); - int primaryColor = ThemeStore.primaryColor(getContext()); - TintHelper.setTintAuto(container, primaryColor, true); - toolbarLayout.setStatusBarScrimColor(primaryColor); - toolbarLayout.setContentScrimColor(primaryColor); + + toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp); + toolbar.setBackgroundColor(primaryColor); + appbar.setBackgroundColor(primaryColor); + appbar.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> + getMainActivity().setLightStatusbar(!ATHUtil.isWindowBackgroundDark(getContext()))); getActivity().setTitle(null); getMainActivity().setSupportActionBar(toolbar); - toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp); toolbar.setNavigationOnClickListener(v -> showMainMenu()); + title.setTextColor(ThemeStore.textColorPrimary(getContext())); + searchIcon.setImageTintList(ColorStateList.valueOf(ThemeStore.accentColor(getContext()))); } @Override @@ -299,7 +292,7 @@ public class BannerHomeFragment extends AbsMainActivityFragment implements MainA recentArtistRV.setLayoutManager(new GridLayoutManager(getMainActivity(), 1, GridLayoutManager.HORIZONTAL, false)); ArtistAdapter artistAdapter = new ArtistAdapter(getMainActivity(), artists, - PreferenceUtil.getInstance(getContext()).getHomeGridStyle(getContext()), false, null); + PreferenceUtil.getInstance().getHomeGridStyle(getContext()), false, null); recentArtistRV.setAdapter(artistAdapter); } @@ -318,7 +311,7 @@ public class BannerHomeFragment extends AbsMainActivityFragment implements MainA topArtistRV.setLayoutManager(new GridLayoutManager(getMainActivity(), 1, GridLayoutManager.HORIZONTAL, false)); ArtistAdapter artistAdapter = new ArtistAdapter(getMainActivity(), artists, - PreferenceUtil.getInstance(getContext()).getHomeGridStyle(getContext()), false, null); + PreferenceUtil.getInstance().getHomeGridStyle(getContext()), false, null); topArtistRV.setAdapter(artistAdapter); } @@ -332,6 +325,21 @@ public class BannerHomeFragment extends AbsMainActivityFragment implements MainA topAlbumRV.setAdapter(artistAdapter); } + @Override + public void suggestions(ArrayList songs) { + if (!songs.isEmpty()) { + suggestionsContainer.setVisibility(View.VISIBLE); + CollageSongAdapter artistAdapter = new CollageSongAdapter(getMainActivity(), songs); + suggestionsSongs.setLayoutManager(new LinearLayoutManager(getMainActivity())); + suggestionsSongs.setAdapter(artistAdapter); + } + } + + @Override + public void playlists(ArrayList playlists) { + + } + private DisplayMetrics getDisplayMetrics() { Display display = getMainActivity().getWindowManager().getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); @@ -340,12 +348,6 @@ public class BannerHomeFragment extends AbsMainActivityFragment implements MainA return metrics; } - @Override - public void suggestions(ArrayList playlists) { - - } - - @Override public void geners(ArrayList genres) { genreContainer.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/home/HomeFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/home/HomeFragment.java deleted file mode 100644 index 360d5d58..00000000 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/home/HomeFragment.java +++ /dev/null @@ -1,305 +0,0 @@ -package code.name.monkey.retromusic.ui.fragments.mainactivity.home; - -import android.animation.AnimatorSet; -import android.app.Activity; -import android.content.res.ColorStateList; -import android.graphics.Bitmap; -import android.os.Bundle; -import android.util.DisplayMetrics; -import android.view.Display; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; - -import com.google.android.material.appbar.AppBarLayout; - -import java.io.File; -import java.util.ArrayList; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.widget.Toolbar; -import androidx.core.content.ContextCompat; -import androidx.core.widget.NestedScrollView; -import androidx.recyclerview.widget.GridLayoutManager; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; -import butterknife.BindView; -import butterknife.ButterKnife; -import butterknife.OnClick; -import butterknife.Unbinder; -import code.name.monkey.appthemehelper.ThemeStore; -import code.name.monkey.appthemehelper.util.ATHUtil; -import code.name.monkey.appthemehelper.util.TintHelper; -import code.name.monkey.retromusic.R; -import code.name.monkey.retromusic.helper.MusicPlayerRemote; -import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks; -import code.name.monkey.retromusic.loaders.SongLoader; -import code.name.monkey.retromusic.model.Album; -import code.name.monkey.retromusic.model.Artist; -import code.name.monkey.retromusic.model.Genre; -import code.name.monkey.retromusic.model.Playlist; -import code.name.monkey.retromusic.model.smartplaylist.HistoryPlaylist; -import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist; -import code.name.monkey.retromusic.model.smartplaylist.MyTopTracksPlaylist; -import code.name.monkey.retromusic.mvp.contract.HomeContract; -import code.name.monkey.retromusic.mvp.presenter.HomePresenter; -import code.name.monkey.retromusic.ui.adapter.GenreAdapter; -import code.name.monkey.retromusic.ui.adapter.album.AlbumFullWithAdapter; -import code.name.monkey.retromusic.ui.adapter.artist.ArtistAdapter; -import code.name.monkey.retromusic.ui.fragments.base.AbsMainActivityFragment; -import code.name.monkey.retromusic.util.Compressor; -import code.name.monkey.retromusic.util.NavigationUtil; -import code.name.monkey.retromusic.util.PreferenceUtil; -import code.name.monkey.retromusic.views.CircularImageView; -import code.name.monkey.retromusic.views.MetalRecyclerViewPager; -import io.reactivex.android.schedulers.AndroidSchedulers; -import io.reactivex.disposables.CompositeDisposable; -import io.reactivex.schedulers.Schedulers; - -import static code.name.monkey.retromusic.Constants.USER_PROFILE; - -public class HomeFragment extends AbsMainActivityFragment implements MainActivityFragmentCallbacks, HomeContract.HomeView { - public static final String TAG = "HomeFragment"; - private final AnimatorSet animatorSet = new AnimatorSet(); - - Unbinder unbinder; - - @BindView(R.id.toolbar) - Toolbar toolbar; - - @BindView(R.id.app_bar) - AppBarLayout appbar; - - @BindView(R.id.user_image) - CircularImageView userImage; - - @BindView(R.id.recycler_view) - RecyclerView recentArtistRV; - - @BindView(R.id.recent_album) - RecyclerView recentAlbumRV; - - @BindView(R.id.top_artist) - RecyclerView topArtistRV; - - @BindView(R.id.top_album) - MetalRecyclerViewPager topAlbumRV; - - @BindView(R.id.recent_artist_container) - View recentArtistContainer; - - @BindView(R.id.recent_albums_container) - View recentAlbumsContainer; - - @BindView(R.id.top_artist_container) - View topArtistContainer; - - @BindView(R.id.top_albums_container) - View topAlbumContainer; - - @BindView(R.id.genres) - RecyclerView genresRecyclerView; - - @BindView(R.id.genre_container) - LinearLayout genreContainer; - - @BindView(R.id.content_container) - NestedScrollView contentContainer; - - @BindView(R.id.title) - TextView title; - - @BindView(R.id.search_icon) - ImageView searchIcon; - - private HomePresenter homePresenter; - private CompositeDisposable disposable; - - public static BannerHomeFragment newInstance() { - Bundle args = new Bundle(); - BannerHomeFragment fragment = new BannerHomeFragment(); - fragment.setArguments(args); - return fragment; - } - - private void loadImageFromStorage(ImageView imageView) { - //noinspection ConstantConditions - disposable.add(new Compressor(getContext()) - .setMaxHeight(300) - .setMaxWidth(300) - .setQuality(75) - .setCompressFormat(Bitmap.CompressFormat.WEBP) - .compressToBitmapAsFlowable( - new File(PreferenceUtil.getInstance(getContext()).getProfileImage(), USER_PROFILE)) - .subscribeOn(Schedulers.computation()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(imageView::setImageBitmap, - throwable -> imageView.setImageDrawable(ContextCompat - .getDrawable(getContext(), R.drawable.ic_person_flat)))); - } - - @Override - public void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - disposable = new CompositeDisposable(); - //noinspection ConstantConditions - homePresenter = new HomePresenter(this); - } - - @Nullable - @Override - public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, - @Nullable Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_banner_home, container, false); - unbinder = ButterKnife.bind(this, view); - return view; - } - - @Override - public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - setStatusbarColorAuto(view); - setupToolbar(); - loadImageFromStorage(userImage); - homePresenter.subscribe(); - } - - @SuppressWarnings("ConstantConditions") - private void setupToolbar() { - //noinspection ConstantConditions - int primaryColor = ThemeStore.primaryColor(getContext()); - TintHelper.setTintAuto(contentContainer, primaryColor, true); - - toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp); - toolbar.setBackgroundColor(primaryColor); - appbar.setBackgroundColor(primaryColor); - appbar.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> - getMainActivity().setLightStatusbar(!ATHUtil.isWindowBackgroundDark(getContext()))); - - getActivity().setTitle(null); - getMainActivity().setSupportActionBar(toolbar); - toolbar.setNavigationOnClickListener(v -> showMainMenu()); - title.setTextColor(ThemeStore.textColorPrimary(getContext())); - searchIcon.setImageTintList(ColorStateList.valueOf(ThemeStore.accentColor(getContext()))); - } - - @Override - public boolean handleBackPress() { - return false; - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - unbinder.unbind(); - disposable.clear(); - homePresenter.unsubscribe(); - } - - @Override - public void loading() { - - } - - @Override - public void showEmptyView() { - - } - - @Override - public void completed() { - - } - - @Override - public void showData(ArrayList homes) { - //homeAdapter.swapDataSet(homes); - } - - @Override - public void recentArtist(ArrayList artists) { - recentArtistContainer.setVisibility(View.VISIBLE); - recentArtistRV.setLayoutManager(new GridLayoutManager(getMainActivity(), 1, GridLayoutManager.HORIZONTAL, false)); - ArtistAdapter artistAdapter = new ArtistAdapter(getMainActivity(), artists, PreferenceUtil.getInstance(getContext()).getHomeGridStyle(getContext()), false, null); - recentArtistRV.setAdapter(artistAdapter); - } - - @Override - public void recentAlbum(ArrayList albums) { - recentAlbumsContainer.setVisibility(View.VISIBLE); - AlbumFullWithAdapter artistAdapter = new AlbumFullWithAdapter(getMainActivity(), getDisplayMetrics()); - artistAdapter.swapData(albums); - recentAlbumRV.setAdapter(artistAdapter); - } - - @Override - public void topArtists(ArrayList artists) { - topArtistContainer.setVisibility(View.VISIBLE); - topArtistRV.setLayoutManager(new GridLayoutManager(getMainActivity(), 1, GridLayoutManager.HORIZONTAL, false)); - ArtistAdapter artistAdapter = new ArtistAdapter(getMainActivity(), artists, PreferenceUtil.getInstance(getContext()).getHomeGridStyle(getContext()), false, null); - topArtistRV.setAdapter(artistAdapter); - } - - @Override - public void topAlbums(ArrayList albums) { - topAlbumContainer.setVisibility(View.VISIBLE); - AlbumFullWithAdapter artistAdapter = new AlbumFullWithAdapter(getMainActivity(), getDisplayMetrics()); - artistAdapter.swapData(albums); - topAlbumRV.setAdapter(artistAdapter); - } - - private DisplayMetrics getDisplayMetrics() { - Display display = getMainActivity().getWindowManager().getDefaultDisplay(); - DisplayMetrics metrics = new DisplayMetrics(); - display.getMetrics(metrics); - return metrics; - } - - @Override - public void suggestions(ArrayList playlists) { - - } - - - @Override - public void geners(ArrayList genres) { - genreContainer.setVisibility(View.VISIBLE); - genresRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); - //noinspection ConstantConditions - GenreAdapter genreAdapter = new GenreAdapter(getActivity(), genres, R.layout.item_list); - genresRecyclerView.setAdapter(genreAdapter); - } - - @OnClick({R.id.last_added, R.id.top_played, R.id.action_shuffle, R.id.history, R.id.user_image, R.id.search}) - void startUserInfo(View view) { - Activity activity = getActivity(); - if (activity != null) { - switch (view.getId()) { - case R.id.action_shuffle: - MusicPlayerRemote - .openAndShuffleQueue(SongLoader.getAllSongs(activity).blockingFirst(), true); - break; - case R.id.last_added: - NavigationUtil.goToPlaylistNew(activity, new LastAddedPlaylist(activity)); - break; - case R.id.top_played: - NavigationUtil.goToPlaylistNew(activity, new MyTopTracksPlaylist(activity)); - break; - case R.id.history: - NavigationUtil.goToPlaylistNew(activity, new HistoryPlaylist(activity)); - break; - case R.id.user_image: - NavigationUtil.goToUserInfo(getActivity()); - break; - case R.id.search: - NavigationUtil.goToSearch(activity); - break; - } - } - } - -} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/PlayerAlbumCoverFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/PlayerAlbumCoverFragment.java index 39fbe688..280c3e60 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/PlayerAlbumCoverFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/PlayerAlbumCoverFragment.java @@ -61,14 +61,14 @@ public class PlayerAlbumCoverFragment extends AbsMusicServiceFragment implements viewPager.addOnPageChangeListener(this); //noinspection ConstantConditions - if (PreferenceUtil.getInstance(getContext()).carouselEffect() && - !((PreferenceUtil.getInstance(getContext()).getNowPlayingScreen() == NowPlayingScreen.FULL))) { + if (PreferenceUtil.getInstance().carouselEffect() && + !((PreferenceUtil.getInstance().getNowPlayingScreen() == NowPlayingScreen.FULL) || (PreferenceUtil.getInstance().getNowPlayingScreen() == NowPlayingScreen.FIT))) { viewPager.setClipToPadding(false); viewPager.setPadding(96, 0, 96, 0); viewPager.setPageMargin(18); viewPager.setPageTransformer(false, new CarousalPagerTransformer(getContext())); } else { - viewPager.setPageTransformer(true, PreferenceUtil.getInstance(getContext()).getAlbumCoverTransform(getContext())); + viewPager.setPageTransformer(true, PreferenceUtil.getInstance().getAlbumCoverTransform(getContext())); } } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/adaptive/AdaptiveFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/adaptive/AdaptiveFragment.java index aa4dff49..af92b48f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/adaptive/AdaptiveFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/adaptive/AdaptiveFragment.java @@ -107,6 +107,11 @@ public class AdaptiveFragment extends AbsPlayerFragment implements Callbacks { @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_adaptive_player, container, false); unbinder = ButterKnife.bind(this, view); + if (getPlayerActivity() != null) { + getPlayerActivity().setDrawUnderNavigationBar(); + getPlayerActivity().setNavigationbarColorAuto(); + addSafeArea(view); + } return view; } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/adaptive/AdaptivePlaybackControlsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/adaptive/AdaptivePlaybackControlsFragment.java index ce723748..e1be14a7 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/adaptive/AdaptivePlaybackControlsFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/adaptive/AdaptivePlaybackControlsFragment.java @@ -3,19 +3,17 @@ package code.name.monkey.retromusic.ui.fragments.player.adaptive; import android.animation.ObjectAnimator; import android.graphics.PorterDuff; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.widget.AppCompatSeekBar; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.animation.AccelerateInterpolator; -import android.view.animation.DecelerateInterpolator; import android.view.animation.LinearInterpolator; import android.widget.ImageButton; import android.widget.SeekBar; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatSeekBar; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; @@ -38,21 +36,29 @@ import code.name.monkey.retromusic.views.PlayPauseDrawable; public class AdaptivePlaybackControlsFragment extends AbsPlayerControlsFragment { @BindView(R.id.player_play_pause_button) - ImageButton playPauseButton; + ImageButton playPauseFab; + @BindView(R.id.player_prev_button) ImageButton prevButton; + @BindView(R.id.player_next_button) ImageButton nextButton; + @BindView(R.id.player_repeat_button) ImageButton repeatButton; + @BindView(R.id.player_shuffle_button) ImageButton shuffleButton; + @BindView(R.id.player_progress_slider) AppCompatSeekBar progressSlider; + @BindView(R.id.player_song_total_time) TextView songTotalTime; + @BindView(R.id.player_song_current_progress) TextView songCurrentProgress; + @BindView(R.id.volume_fragment_container) View volumeContainer; @@ -108,7 +114,7 @@ public class AdaptivePlaybackControlsFragment extends AbsPlayerControlsFragment @Override public void onServiceConnected() { - updatePlayPauseDrawableState(false); + updatePlayPauseDrawableState(); updateRepeatState(); updateShuffleState(); @@ -116,7 +122,7 @@ public class AdaptivePlaybackControlsFragment extends AbsPlayerControlsFragment @Override public void onPlayStateChanged() { - updatePlayPauseDrawableState(true); + updatePlayPauseDrawableState(); } @Override @@ -145,8 +151,8 @@ public class AdaptivePlaybackControlsFragment extends AbsPlayerControlsFragment updatePrevNextColor(); updatePlayPauseColor(); - TintHelper.setTintAuto(playPauseButton, MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(dark)), false); - TintHelper.setTintAuto(playPauseButton, dark, true); + TintHelper.setTintAuto(playPauseFab, MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(dark)), false); + TintHelper.setTintAuto(playPauseFab, dark, true); TintHelper.setTintAuto(progressSlider, dark, false); } @@ -154,29 +160,21 @@ public class AdaptivePlaybackControlsFragment extends AbsPlayerControlsFragment //playPauseButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN); } - private void setUpPlayPauseButton() { - playPauseDrawable = new PlayPauseDrawable(getActivity()); - playPauseButton.setImageDrawable(playPauseDrawable); - updatePlayPauseColor(); - playPauseButton.setOnClickListener(new PlayPauseButtonOnClickHandler()); - playPauseButton.post(() -> { - if (playPauseButton != null) { - playPauseButton.setPivotX(playPauseButton.getWidth() / 2); - playPauseButton.setPivotY(playPauseButton.getHeight() / 2); - } - }); + private void setUpPlayPauseFab() { + playPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler()); } - protected void updatePlayPauseDrawableState(boolean animate) { + protected void updatePlayPauseDrawableState() { if (MusicPlayerRemote.isPlaying()) { - playPauseDrawable.setPause(animate); + playPauseFab.setImageResource(R.drawable.ic_pause_white_24dp); } else { - playPauseDrawable.setPlay(animate); + playPauseFab.setImageResource(R.drawable.ic_play_arrow_white_24dp); } } + private void setUpMusicControllers() { - setUpPlayPauseButton(); + setUpPlayPauseFab(); setUpPrevNext(); setUpRepeatButton(); setUpShuffleButton(); @@ -249,8 +247,6 @@ public class AdaptivePlaybackControlsFragment extends AbsPlayerControlsFragment @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { - - MusicPlayerRemote.seekTo(progress); onUpdateProgressViews(MusicPlayerRemote.getSongProgressMillis(), MusicPlayerRemote.getSongDurationMillis()); @@ -259,29 +255,6 @@ public class AdaptivePlaybackControlsFragment extends AbsPlayerControlsFragment }); } - public void showBouceAnimation() { - playPauseButton.clearAnimation(); - - playPauseButton.setScaleX(0.9f); - playPauseButton.setScaleY(0.9f); - playPauseButton.setVisibility(View.VISIBLE); - playPauseButton.setPivotX(playPauseButton.getWidth() / 2); - playPauseButton.setPivotY(playPauseButton.getHeight() / 2); - - playPauseButton.animate() - .setDuration(200) - .setInterpolator(new DecelerateInterpolator()) - .scaleX(1.1f) - .scaleY(1.1f) - .withEndAction(() -> playPauseButton.animate() - .setDuration(200) - .setInterpolator(new AccelerateInterpolator()) - .scaleX(1f) - .scaleY(1f) - .alpha(1f) - .start()) - .start(); - } @OnClick(R.id.player_play_pause_button) void showAnimation() { @@ -290,7 +263,7 @@ public class AdaptivePlaybackControlsFragment extends AbsPlayerControlsFragment } else { MusicPlayerRemote.resumePlaying(); } - showBouceAnimation(); + showBouceAnimation(playPauseFab); } @Override @@ -306,8 +279,7 @@ public class AdaptivePlaybackControlsFragment extends AbsPlayerControlsFragment songCurrentProgress.setText(MusicUtil.getReadableDurationString(progress)); } - public void hideVolumeIfAvailable() { - volumeContainer.setVisibility( - PreferenceUtil.getInstance(getContext()).getVolumeToggle() ? View.VISIBLE : View.GONE); + private void hideVolumeIfAvailable() { + volumeContainer.setVisibility(PreferenceUtil.getInstance().getVolumeToggle() ? View.VISIBLE : View.GONE); } } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/blur/BlurPlaybackControlsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/blur/BlurPlaybackControlsFragment.java index 8cca5889..eec9433c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/blur/BlurPlaybackControlsFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/blur/BlurPlaybackControlsFragment.java @@ -4,11 +4,6 @@ import android.animation.ObjectAnimator; import android.graphics.Color; import android.graphics.PorterDuff; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.core.content.ContextCompat; -import androidx.appcompat.widget.AppCompatSeekBar; -import androidx.appcompat.widget.AppCompatTextView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -18,11 +13,14 @@ import android.widget.ImageButton; import android.widget.SeekBar; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatSeekBar; +import androidx.appcompat.widget.AppCompatTextView; +import androidx.core.content.ContextCompat; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.Unbinder; -import code.name.monkey.appthemehelper.util.ColorUtil; -import code.name.monkey.appthemehelper.util.MaterialValueHelper; import code.name.monkey.appthemehelper.util.TintHelper; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.helper.MusicPlayerRemote; @@ -35,35 +33,44 @@ import code.name.monkey.retromusic.ui.fragments.VolumeFragment; import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerControlsFragment; import code.name.monkey.retromusic.util.MusicUtil; import code.name.monkey.retromusic.util.PreferenceUtil; -import code.name.monkey.retromusic.views.PlayPauseDrawable; public class BlurPlaybackControlsFragment extends AbsPlayerControlsFragment { @BindView(R.id.player_play_pause_button) ImageButton playPauseFab; + @BindView(R.id.player_prev_button) ImageButton prevButton; + @BindView(R.id.player_next_button) ImageButton nextButton; + @BindView(R.id.player_repeat_button) ImageButton repeatButton; + @BindView(R.id.player_shuffle_button) ImageButton shuffleButton; + @BindView(R.id.player_progress_slider) AppCompatSeekBar progressSlider; + @BindView(R.id.player_song_total_time) TextView songTotalTime; + @BindView(R.id.player_song_current_progress) TextView songCurrentProgress; + @BindView(R.id.title) - AppCompatTextView title; + AppCompatTextView songTitle; + @BindView(R.id.text) TextView text; + @BindView(R.id.volume_fragment_container) View mVolumeContainer; + private Unbinder unbinder; - private PlayPauseDrawable playerFabPlayPauseDrawable; private int lastPlaybackControlsColor; private int lastDisabledPlaybackControlsColor; private MusicProgressViewUpdateHelper progressViewUpdateHelper; @@ -89,10 +96,12 @@ public class BlurPlaybackControlsFragment extends AbsPlayerControlsFragment { unbinder = ButterKnife.bind(this, view); setUpMusicControllers(); - mVolumeContainer.setVisibility(PreferenceUtil.getInstance(getContext()).getVolumeToggle() ? View.VISIBLE : View.GONE); + mVolumeContainer.setVisibility(PreferenceUtil.getInstance().getVolumeToggle() ? View.VISIBLE : View.GONE); VolumeFragment mVolumeFragment = (VolumeFragment) getChildFragmentManager().findFragmentById(R.id.volume_fragment); - mVolumeFragment.tintWhiteColor(); + if (mVolumeFragment != null) { + mVolumeFragment.tintWhiteColor(); + } } @Override @@ -103,7 +112,7 @@ public class BlurPlaybackControlsFragment extends AbsPlayerControlsFragment { private void updateSong() { Song song = MusicPlayerRemote.getCurrentSong(); - title.setText(song.title); + songTitle.setText(song.title); text.setText(song.artistName); } @@ -121,7 +130,7 @@ public class BlurPlaybackControlsFragment extends AbsPlayerControlsFragment { @Override public void onServiceConnected() { - updatePlayPauseDrawableState(false); + updatePlayPauseDrawableState(); updateRepeatState(); updateShuffleState(); updateSong(); @@ -135,7 +144,7 @@ public class BlurPlaybackControlsFragment extends AbsPlayerControlsFragment { @Override public void onPlayStateChanged() { - updatePlayPauseDrawableState(true); + updatePlayPauseDrawableState(); } @Override @@ -153,7 +162,10 @@ public class BlurPlaybackControlsFragment extends AbsPlayerControlsFragment { lastPlaybackControlsColor = Color.WHITE; lastDisabledPlaybackControlsColor = ContextCompat.getColor(getContext(), R.color.md_grey_500); - setProgressBarColor(Color.WHITE); + songTitle.setTextColor(lastPlaybackControlsColor); + text.setTextColor(lastDisabledPlaybackControlsColor); + + setProgressBarColor(); songCurrentProgress.setTextColor(lastPlaybackControlsColor); songTotalTime.setTextColor(lastPlaybackControlsColor); @@ -163,35 +175,25 @@ public class BlurPlaybackControlsFragment extends AbsPlayerControlsFragment { updatePrevNextColor(); } - public void setProgressBarColor(int newColor) { - TintHelper.setTintAuto(progressSlider, newColor, false); + private void setProgressBarColor() { + TintHelper.setTintAuto(progressSlider, Color.WHITE, false); } private void setUpPlayPauseFab() { - final int fabColor = Color.WHITE; - TintHelper.setTintAuto(playPauseFab, fabColor, true); - - playerFabPlayPauseDrawable = new PlayPauseDrawable(getActivity()); - - playPauseFab.setImageDrawable(playerFabPlayPauseDrawable); // Note: set the drawable AFTER TintHelper.setTintAuto() was called - playPauseFab.setColorFilter(MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(fabColor)), PorterDuff.Mode.SRC_IN); + TintHelper.setTintAuto(playPauseFab, Color.WHITE, true); + TintHelper.setTintAuto(playPauseFab, Color.BLACK, false); playPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler()); - playPauseFab.post(() -> { - if (playPauseFab != null) { - playPauseFab.setPivotX(playPauseFab.getWidth() / 2); - playPauseFab.setPivotY(playPauseFab.getHeight() / 2); - } - }); } - protected void updatePlayPauseDrawableState(boolean animate) { + protected void updatePlayPauseDrawableState() { if (MusicPlayerRemote.isPlaying()) { - playerFabPlayPauseDrawable.setPause(animate); + playPauseFab.setImageResource(R.drawable.ic_pause_white_24dp); } else { - playerFabPlayPauseDrawable.setPlay(animate); + playPauseFab.setImageResource(R.drawable.ic_play_arrow_white_24dp); } } + private void setUpMusicControllers() { setUpPlayPauseFab(); setUpPrevNext(); @@ -294,8 +296,4 @@ public class BlurPlaybackControlsFragment extends AbsPlayerControlsFragment { songTotalTime.setText(MusicUtil.getReadableDurationString(total)); songCurrentProgress.setText(MusicUtil.getReadableDurationString(progress)); } - - public void hideVolumeIfAvailable() { - mVolumeContainer.setVisibility(View.GONE); - } } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/blur/BlurPlayerFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/blur/BlurPlayerFragment.java index 1db54d4c..700969e8 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/blur/BlurPlayerFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/blur/BlurPlayerFragment.java @@ -4,29 +4,25 @@ import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.preference.PreferenceManager; -import androidx.annotation.ColorInt; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatActivity; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; -import androidx.appcompat.widget.Toolbar; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; -import android.widget.TextView; import com.bumptech.glide.Glide; import com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator; import com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator; -import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager; -import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils; +import androidx.annotation.ColorInt; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.Unbinder; -import code.name.monkey.appthemehelper.util.ColorUtil; import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.glide.BlurTransformation; @@ -43,8 +39,7 @@ import code.name.monkey.retromusic.ui.fragments.player.normal.PlayerFragment; * @author Hemanth S (h4h13). */ -public class BlurPlayerFragment extends AbsPlayerFragment implements - PlayerAlbumCoverFragment.Callbacks { +public class BlurPlayerFragment extends AbsPlayerFragment implements PlayerAlbumCoverFragment.Callbacks { @BindView(R.id.player_toolbar) Toolbar toolbar; @@ -59,10 +54,6 @@ public class BlurPlayerFragment extends AbsPlayerFragment implements @BindView(R.id.recycler_view) RecyclerView recyclerView; - @Nullable - @BindView(R.id.title) - TextView title; - private int lastColor; private BlurPlaybackControlsFragment playbackControlsFragment; private Unbinder unbinder; @@ -114,18 +105,7 @@ public class BlurPlayerFragment extends AbsPlayerFragment implements playbackControlsFragment.setDark(color); lastColor = color; getCallbacks().onPaletteColorChanged(); - ToolbarContentTintHelper.colorizeToolbar(toolbar, Color.WHITE, getActivity()); - - if (title != null && playingQueueAdapter != null) { - if (ColorUtil.isColorLight(color)) { - title.setTextColor(Color.BLACK); - playingQueueAdapter.usePalette(false); - } else { - title.setTextColor(Color.WHITE); - playingQueueAdapter.usePalette(true); - } - } } @Override @@ -160,12 +140,18 @@ public class BlurPlayerFragment extends AbsPlayerFragment implements @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_blur, container, false); unbinder = ButterKnife.bind(this, view); + if (getPlayerActivity() != null) { + getPlayerActivity().setDrawUnderNavigationBar(); + getPlayerActivity().setNavigationbarColor(Color.TRANSPARENT); + addSafeArea(view); + } return view; } @Override public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); + setUpSubFragments(); setUpPlayerToolbar(); } @@ -177,7 +163,9 @@ public class BlurPlayerFragment extends AbsPlayerFragment implements PlayerAlbumCoverFragment playerAlbumCoverFragment = (PlayerAlbumCoverFragment) getChildFragmentManager() .findFragmentById(R.id.player_album_cover_fragment); - playerAlbumCoverFragment.setCallbacks(this); + if (playerAlbumCoverFragment != null) { + playerAlbumCoverFragment.setCallbacks(this); + } } private void setUpPlayerToolbar() { @@ -238,9 +226,7 @@ public class BlurPlayerFragment extends AbsPlayerFragment implements (AppCompatActivity) getActivity(), MusicPlayerRemote.getPlayingQueue(), MusicPlayerRemote.getPosition(), - R.layout.item_song, - false, - null); + R.layout.item_song); layoutManager = new LinearLayoutManager(getContext()); recyclerView.setLayoutManager(layoutManager); diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/card/CardFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/card/CardFragment.java index 589959c5..3cc691e6 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/card/CardFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/card/CardFragment.java @@ -2,13 +2,6 @@ package code.name.monkey.retromusic.ui.fragments.player.card; import android.graphics.Color; import android.os.Bundle; -import androidx.annotation.ColorInt; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatActivity; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; -import androidx.appcompat.widget.Toolbar; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -19,6 +12,13 @@ import com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemA import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager; import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils; +import androidx.annotation.ColorInt; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.Unbinder; @@ -42,8 +42,10 @@ public class CardFragment extends AbsPlayerFragment implements PlayerAlbumCoverF RecyclerView recyclerView; @Nullable + @BindView(R.id.title) TextView title; + private RecyclerView.Adapter wrappedAdapter; private RecyclerViewDragDropManager recyclerViewDragDropManager; private PlayingQueueAdapter playingQueueAdapter; @@ -158,6 +160,11 @@ public class CardFragment extends AbsPlayerFragment implements PlayerAlbumCoverF @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_card_player, container, false); unbinder = ButterKnife.bind(this, view); + if (getPlayerActivity() != null) { + getPlayerActivity().setDrawUnderNavigationBar(); + getPlayerActivity().setNavigationbarColor(Color.TRANSPARENT); + addSafeArea(view); + } return view; } @@ -212,9 +219,7 @@ public class CardFragment extends AbsPlayerFragment implements PlayerAlbumCoverF (AppCompatActivity) getActivity(), MusicPlayerRemote.getPlayingQueue(), MusicPlayerRemote.getPosition(), - R.layout.item_song, - false, - null); + R.layout.item_song); wrappedAdapter = recyclerViewDragDropManager.createWrappedAdapter(playingQueueAdapter); layoutManager = new LinearLayoutManager(getContext()); diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/card/CardPlaybackControlsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/card/CardPlaybackControlsFragment.java index bb6059f4..0abcaff0 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/card/CardPlaybackControlsFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/card/CardPlaybackControlsFragment.java @@ -3,22 +3,20 @@ package code.name.monkey.retromusic.ui.fragments.player.card; import android.animation.ObjectAnimator; import android.graphics.PorterDuff; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.widget.AppCompatSeekBar; -import androidx.appcompat.widget.AppCompatTextView; -import androidx.cardview.widget.CardView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.animation.AccelerateInterpolator; -import android.view.animation.DecelerateInterpolator; import android.view.animation.LinearInterpolator; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.SeekBar; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatSeekBar; +import androidx.appcompat.widget.AppCompatTextView; +import androidx.cardview.widget.CardView; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; @@ -42,34 +40,47 @@ import code.name.monkey.retromusic.views.PlayPauseDrawable; public class CardPlaybackControlsFragment extends AbsPlayerControlsFragment { @BindView(R.id.player_play_pause_button) - ImageButton playPauseButton; + ImageButton playPauseFab; + @BindView(R.id.player_prev_button) ImageButton prevButton; + @BindView(R.id.player_next_button) ImageButton nextButton; + @BindView(R.id.player_repeat_button) ImageButton repeatButton; + @BindView(R.id.player_shuffle_button) ImageButton shuffleButton; + @BindView(R.id.player_progress_slider) AppCompatSeekBar progressSlider; + @BindView(R.id.player_song_total_time) TextView songTotalTime; + @BindView(R.id.player_song_current_progress) TextView songCurrentProgress; + @BindView(R.id.title) AppCompatTextView title; + @BindView(R.id.text) TextView text; + @BindView(R.id.volume_fragment_container) View volumeContainer; + @BindView(R.id.menu) View menuView; + @BindView(R.id.image_text_container) CardView colorContainer; @BindView(R.id.image) ImageView playImageView; + @BindView(R.id.playback_controls) View playbackControls; @@ -94,7 +105,7 @@ public class CardPlaybackControlsFragment extends AbsPlayerControlsFragment { } @Override - public void onViewCreated(View view, Bundle savedInstanceState) { + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); unbinder = ButterKnife.bind(this, view); setUpMusicControllers(); @@ -144,7 +155,7 @@ public class CardPlaybackControlsFragment extends AbsPlayerControlsFragment { @Override public void onServiceConnected() { - updatePlayPauseDrawableState(false); + updatePlayPauseDrawableState(); updateRepeatState(); updateShuffleState(); updateSong(); @@ -158,7 +169,7 @@ public class CardPlaybackControlsFragment extends AbsPlayerControlsFragment { @Override public void onPlayStateChanged() { - updatePlayPauseDrawableState(true); + updatePlayPauseDrawableState(); } @Override @@ -188,37 +199,28 @@ public class CardPlaybackControlsFragment extends AbsPlayerControlsFragment { updatePlayPauseColor(); updateProgressTextColor(); - TintHelper.setTintAuto(playPauseButton, MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(dark)), false); - TintHelper.setTintAuto(playPauseButton, dark, true); + TintHelper.setTintAuto(playPauseFab, MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(dark)), false); + TintHelper.setTintAuto(playPauseFab, dark, true); } private void updatePlayPauseColor() { //playPauseButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN); } - private void setUpPlayPauseButton() { - playPauseDrawable = new PlayPauseDrawable(getActivity()); - playPauseButton.setImageDrawable(playPauseDrawable); - updatePlayPauseColor(); - playPauseButton.setOnClickListener(new PlayPauseButtonOnClickHandler()); - playPauseButton.post(() -> { - if (playPauseButton != null) { - playPauseButton.setPivotX(playPauseButton.getWidth() / 2); - playPauseButton.setPivotY(playPauseButton.getHeight() / 2); - } - }); + private void setUpPlayPauseFab() { + playPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler()); } - protected void updatePlayPauseDrawableState(boolean animate) { + protected void updatePlayPauseDrawableState() { if (MusicPlayerRemote.isPlaying()) { - playPauseDrawable.setPause(animate); + playPauseFab.setImageResource(R.drawable.ic_pause_white_24dp); } else { - playPauseDrawable.setPlay(animate); + playPauseFab.setImageResource(R.drawable.ic_play_arrow_white_24dp); } } private void setUpMusicControllers() { - setUpPlayPauseButton(); + setUpPlayPauseFab(); setUpPrevNext(); setUpRepeatButton(); setUpShuffleButton(); @@ -303,30 +305,6 @@ public class CardPlaybackControlsFragment extends AbsPlayerControlsFragment { }); } - public void showBouceAnimation() { - playPauseButton.clearAnimation(); - - playPauseButton.setScaleX(0.9f); - playPauseButton.setScaleY(0.9f); - playPauseButton.setVisibility(View.VISIBLE); - playPauseButton.setPivotX(playPauseButton.getWidth() / 2); - playPauseButton.setPivotY(playPauseButton.getHeight() / 2); - - playPauseButton.animate() - .setDuration(200) - .setInterpolator(new DecelerateInterpolator()) - .scaleX(1.1f) - .scaleY(1.1f) - .withEndAction(() -> playPauseButton.animate() - .setDuration(200) - .setInterpolator(new AccelerateInterpolator()) - .scaleX(1f) - .scaleY(1f) - .alpha(1f) - .start()) - .start(); - } - @OnClick(R.id.player_play_pause_button) void showAnimation() { if (MusicPlayerRemote.isPlaying()) { @@ -334,7 +312,7 @@ public class CardPlaybackControlsFragment extends AbsPlayerControlsFragment { } else { MusicPlayerRemote.resumePlaying(); } - showBouceAnimation(); + showBouceAnimation(playPauseFab); } @Override @@ -350,9 +328,7 @@ public class CardPlaybackControlsFragment extends AbsPlayerControlsFragment { songCurrentProgress.setText(MusicUtil.getReadableDurationString(progress)); } - public void hideVolumeIfAvailable() { - volumeContainer.setVisibility(PreferenceUtil.getInstance(getContext()).getVolumeToggle() ? View.VISIBLE : View.GONE); + private void hideVolumeIfAvailable() { + volumeContainer.setVisibility(PreferenceUtil.getInstance().getVolumeToggle() ? View.VISIBLE : View.GONE); } - - } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/cardblur/CardBlurFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/cardblur/CardBlurFragment.java index adf4b7eb..d44fe5aa 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/cardblur/CardBlurFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/cardblur/CardBlurFragment.java @@ -25,7 +25,6 @@ import code.name.monkey.retromusic.glide.RetroMusicColoredTarget; import code.name.monkey.retromusic.glide.SongGlideRequest; import code.name.monkey.retromusic.helper.MusicPlayerRemote; import code.name.monkey.retromusic.model.Song; -import code.name.monkey.retromusic.ui.fragments.VolumeFragment; import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerFragment; import code.name.monkey.retromusic.ui.fragments.player.PlayerAlbumCoverFragment; import code.name.monkey.retromusic.ui.fragments.player.normal.PlayerFragment; @@ -93,6 +92,9 @@ public class CardBlurFragment extends AbsPlayerFragment implements lastColor = color; getCallbacks().onPaletteColorChanged(); ToolbarContentTintHelper.colorizeToolbar(toolbar, Color.WHITE, getActivity()); + + toolbar.setTitleTextColor(Color.WHITE); + toolbar.setSubtitleTextColor(Color.WHITE); } @Override @@ -120,6 +122,11 @@ public class CardBlurFragment extends AbsPlayerFragment implements @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_card_blur_player, container, false); unbinder = ButterKnife.bind(this, view); + if (getPlayerActivity() != null) { + getPlayerActivity().setDrawUnderNavigationBar(); + getPlayerActivity().setNavigationbarColor(Color.TRANSPARENT); + addSafeArea(view); + } return view; } @@ -136,9 +143,10 @@ public class CardBlurFragment extends AbsPlayerFragment implements PlayerAlbumCoverFragment playerAlbumCoverFragment = (PlayerAlbumCoverFragment) getChildFragmentManager().findFragmentById(R.id.player_album_cover_fragment); - playerAlbumCoverFragment.setCallbacks(this); - playerAlbumCoverFragment.removeEffect(); - + if (playerAlbumCoverFragment != null) { + playerAlbumCoverFragment.setCallbacks(this); + playerAlbumCoverFragment.removeEffect(); + } } @@ -147,23 +155,29 @@ public class CardBlurFragment extends AbsPlayerFragment implements toolbar.setNavigationOnClickListener(v -> getActivity().onBackPressed()); toolbar.setOnMenuItemClickListener(this); - /* for (int i = 0; i < toolbar.getMenu().size(); i++) { - MenuItem menuItem = toolbar.getMenu().getItem(i); - menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); - }*/ ToolbarContentTintHelper.colorizeToolbar(toolbar, Color.WHITE, getActivity()); + toolbar.setTitleTextColor(Color.WHITE); + toolbar.setSubtitleTextColor(Color.WHITE); } @Override public void onServiceConnected() { updateIsFavorite(); updateBlur(); + updateSong(); } @Override public void onPlayingMetaChanged() { updateIsFavorite(); updateBlur(); + updateSong(); + } + + private void updateSong() { + Song song = MusicPlayerRemote.getCurrentSong(); + toolbar.setTitle(song.title); + toolbar.setSubtitle(song.artistName); } private void updateBlur() { diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/cardblur/CardBlurPlaybackControlsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/cardblur/CardBlurPlaybackControlsFragment.java index 19f2a032..0b6acbc2 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/cardblur/CardBlurPlaybackControlsFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/cardblur/CardBlurPlaybackControlsFragment.java @@ -30,13 +30,11 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote; import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper; import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler; import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener; -import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.service.MusicService; import code.name.monkey.retromusic.ui.fragments.VolumeFragment; import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerControlsFragment; import code.name.monkey.retromusic.util.MusicUtil; import code.name.monkey.retromusic.util.PreferenceUtil; -import code.name.monkey.retromusic.views.PlayPauseDrawable; public class CardBlurPlaybackControlsFragment extends AbsPlayerControlsFragment { @BindView(R.id.player_play_pause_button) @@ -66,23 +64,12 @@ public class CardBlurPlaybackControlsFragment extends AbsPlayerControlsFragment @BindView(R.id.volume_fragment_container) View volumeContainer; - @BindView(R.id.text) - TextView text; - - @BindView(R.id.title) - TextView title; private Unbinder unbinder; - private PlayPauseDrawable playerFabPlayPauseDrawable; private int lastPlaybackControlsColor; private int lastDisabledPlaybackControlsColor; private MusicProgressViewUpdateHelper progressViewUpdateHelper; - private void updateSong() { - Song song = MusicPlayerRemote.getCurrentSong(); - title.setText(song.title); - text.setText(song.artistName); - } @Override public void onCreate(Bundle savedInstanceState) { @@ -104,7 +91,6 @@ public class CardBlurPlaybackControlsFragment extends AbsPlayerControlsFragment unbinder = ButterKnife.bind(this, view); setUpMusicControllers(); hideVolumeIfAvailable(); - title.setSelected(true); } @Override @@ -127,22 +113,15 @@ public class CardBlurPlaybackControlsFragment extends AbsPlayerControlsFragment @Override public void onServiceConnected() { - updatePlayPauseDrawableState(false); + updatePlayPauseDrawableState(); updateRepeatState(); - updateSong(); updateShuffleState(); - } - @Override - public void onPlayingMetaChanged() { - super.onPlayingMetaChanged(); - updateSong(); - } @Override public void onPlayStateChanged() { - updatePlayPauseDrawableState(true); + updatePlayPauseDrawableState(); } @Override @@ -157,10 +136,6 @@ public class CardBlurPlaybackControlsFragment extends AbsPlayerControlsFragment @Override public void setDark(int dark) { - - title.setTextColor(Color.WHITE); - text.setTextColor(Color.WHITE); - lastPlaybackControlsColor = Color.WHITE; lastDisabledPlaybackControlsColor = ColorUtil.withAlpha(Color.WHITE, 0.3f); @@ -172,28 +147,16 @@ public class CardBlurPlaybackControlsFragment extends AbsPlayerControlsFragment private void setUpPlayPauseFab() { - final int fabColor = Color.WHITE; - TintHelper.setTintAuto(playPauseFab, fabColor, true); - - playerFabPlayPauseDrawable = new PlayPauseDrawable(getActivity()); - - playPauseFab.setImageDrawable(playerFabPlayPauseDrawable); // Note: set the drawable AFTER TintHelper.setTintAuto() was called - playPauseFab.setColorFilter(MaterialValueHelper.getPrimaryTextColor(getContext(), - ColorUtil.isColorLight(fabColor)), PorterDuff.Mode.SRC_IN); + TintHelper.setTintAuto(playPauseFab, Color.WHITE, true); + TintHelper.setTintAuto(playPauseFab, Color.BLACK, false); playPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler()); - playPauseFab.post(() -> { - if (playPauseFab != null) { - playPauseFab.setPivotX(playPauseFab.getWidth() / 2); - playPauseFab.setPivotY(playPauseFab.getHeight() / 2); - } - }); } - protected void updatePlayPauseDrawableState(boolean animate) { + protected void updatePlayPauseDrawableState() { if (MusicPlayerRemote.isPlaying()) { - playerFabPlayPauseDrawable.setPause(animate); + playPauseFab.setImageResource(R.drawable.ic_pause_white_24dp); } else { - playerFabPlayPauseDrawable.setPlay(animate); + playPauseFab.setImageResource(R.drawable.ic_play_arrow_white_24dp); } } @@ -341,8 +304,6 @@ public class CardBlurPlaybackControlsFragment extends AbsPlayerControlsFragment } public void hideVolumeIfAvailable() { - volumeContainer.setVisibility(PreferenceUtil.getInstance(getContext()).getVolumeToggle() ? View.VISIBLE : View.GONE); + volumeContainer.setVisibility(PreferenceUtil.getInstance().getVolumeToggle() ? View.VISIBLE : View.GONE); } - - } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/color/ColorFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/color/ColorFragment.java index 7ba69f05..f9e78b08 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/color/ColorFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/color/ColorFragment.java @@ -136,6 +136,10 @@ public class ColorFragment extends AbsPlayerFragment { @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_color_player, container, false); unbinder = ButterKnife.bind(this, view); + if (getPlayerActivity() != null) { + getPlayerActivity().setDrawUnderNavigationBar(); + addSafeArea(view); + } return view; } @@ -233,7 +237,11 @@ public class ColorFragment extends AbsPlayerFragment { this.backgroundColor = backgroundColor; + if (getPlayerActivity() != null) { + getPlayerActivity().setLightNavigationBar(ColorUtil.isColorLight(backgroundColor)); + } getCallbacks().onPaletteColorChanged(); + } private void colorize(int i) { @@ -241,7 +249,7 @@ public class ColorFragment extends AbsPlayerFragment { valueAnimator.cancel(); } - valueAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), Color.TRANSPARENT, i); + valueAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), backgroundColor, i); valueAnimator.addUpdateListener(animation -> { if (colorBackground != null) { colorBackground.setBackgroundColor((Integer) animation.getAnimatedValue()); diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/color/ColorPlaybackControlsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/color/ColorPlaybackControlsFragment.java index fd775db1..b98dc4f5 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/color/ColorPlaybackControlsFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/color/ColorPlaybackControlsFragment.java @@ -4,30 +4,28 @@ import android.animation.ObjectAnimator; import android.graphics.Color; import android.graphics.PorterDuff; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.widget.AppCompatSeekBar; -import androidx.appcompat.widget.AppCompatTextView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.animation.AccelerateInterpolator; import android.view.animation.DecelerateInterpolator; import android.view.animation.LinearInterpolator; import android.widget.ImageButton; import android.widget.SeekBar; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatSeekBar; +import androidx.appcompat.widget.AppCompatTextView; import butterknife.BindView; import butterknife.ButterKnife; -import butterknife.OnClick; import butterknife.Unbinder; import code.name.monkey.appthemehelper.util.ColorUtil; -import code.name.monkey.appthemehelper.util.MaterialValueHelper; import code.name.monkey.appthemehelper.util.TintHelper; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.helper.MusicPlayerRemote; import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper; +import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler; import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener; import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.service.MusicService; @@ -35,35 +33,43 @@ import code.name.monkey.retromusic.ui.fragments.VolumeFragment; import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerControlsFragment; import code.name.monkey.retromusic.util.MusicUtil; import code.name.monkey.retromusic.util.PreferenceUtil; -import code.name.monkey.retromusic.views.PlayPauseDrawable; public class ColorPlaybackControlsFragment extends AbsPlayerControlsFragment { @BindView(R.id.player_play_pause_button) ImageButton playPauseFab; + @BindView(R.id.player_prev_button) ImageButton prevButton; + @BindView(R.id.player_next_button) ImageButton nextButton; + @BindView(R.id.player_repeat_button) ImageButton repeatButton; + @BindView(R.id.player_shuffle_button) ImageButton shuffleButton; + @BindView(R.id.player_progress_slider) AppCompatSeekBar progressSlider; + @BindView(R.id.player_song_total_time) TextView songTotalTime; + @BindView(R.id.player_song_current_progress) TextView songCurrentProgress; + @BindView(R.id.title) AppCompatTextView title; + @BindView(R.id.text) TextView text; + @BindView(R.id.volume_fragment_container) View volumeContainer; private Unbinder unbinder; - private PlayPauseDrawable playerFabPlayPauseDrawable; private int lastPlaybackControlsColor; private int lastDisabledPlaybackControlsColor; private MusicProgressViewUpdateHelper progressViewUpdateHelper; @@ -85,12 +91,24 @@ public class ColorPlaybackControlsFragment extends AbsPlayerControlsFragment { } @Override - public void onViewCreated(View view, Bundle savedInstanceState) { + public void onResume() { + super.onResume(); + progressViewUpdateHelper.start(); + } + + @Override + public void onPause() { + super.onPause(); + progressViewUpdateHelper.stop(); + } + + @Override + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); unbinder = ButterKnife.bind(this, view); setUpMusicControllers(); - if (PreferenceUtil.getInstance(getContext()).getVolumeToggle()) { + if (PreferenceUtil.getInstance().getVolumeToggle()) { volumeContainer.setVisibility(View.VISIBLE); } else { volumeContainer.setVisibility(View.GONE); @@ -109,24 +127,11 @@ public class ColorPlaybackControlsFragment extends AbsPlayerControlsFragment { Song song = MusicPlayerRemote.getCurrentSong(); title.setText(song.title); text.setText(song.artistName); - - } - - @Override - public void onResume() { - super.onResume(); - progressViewUpdateHelper.start(); - } - - @Override - public void onPause() { - super.onPause(); - progressViewUpdateHelper.stop(); } @Override public void onServiceConnected() { - updatePlayPauseDrawableState(false); + updatePlayPauseDrawableState(); updateRepeatState(); updateShuffleState(); updateSong(); @@ -140,7 +145,7 @@ public class ColorPlaybackControlsFragment extends AbsPlayerControlsFragment { @Override public void onPlayStateChanged() { - updatePlayPauseDrawableState(true); + updatePlayPauseDrawableState(); } @Override @@ -182,27 +187,21 @@ public class ColorPlaybackControlsFragment extends AbsPlayerControlsFragment { private void setUpPlayPauseFab() { - playerFabPlayPauseDrawable = new PlayPauseDrawable(getActivity()); - - playPauseFab.setImageDrawable(playerFabPlayPauseDrawable); // Note: set the drawable AFTER TintHelper.setTintAuto() was called - playPauseFab.setColorFilter(MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(Color.BLACK)), PorterDuff.Mode.SRC_IN); - //playPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler()); - playPauseFab.post(() -> { - if (playPauseFab != null) { - playPauseFab.setPivotX(playPauseFab.getWidth() / 2); - playPauseFab.setPivotY(playPauseFab.getHeight() / 2); - } - }); + TintHelper.setTintAuto(playPauseFab, Color.WHITE, true); + TintHelper.setTintAuto(playPauseFab, Color.BLACK, false); + playPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler()); } - protected void updatePlayPauseDrawableState(boolean animate) { + + protected void updatePlayPauseDrawableState() { if (MusicPlayerRemote.isPlaying()) { - playerFabPlayPauseDrawable.setPause(animate); + playPauseFab.setImageResource(R.drawable.ic_pause_white_24dp); } else { - playerFabPlayPauseDrawable.setPlay(animate); + playPauseFab.setImageResource(R.drawable.ic_play_arrow_white_24dp); } } + private void setUpMusicControllers() { setUpPlayPauseFab(); setUpPrevNext(); @@ -293,40 +292,6 @@ public class ColorPlaybackControlsFragment extends AbsPlayerControlsFragment { }); } - public void showBouceAnimation() { - playPauseFab.clearAnimation(); - - playPauseFab.setScaleX(0.9f); - playPauseFab.setScaleY(0.9f); - playPauseFab.setVisibility(View.VISIBLE); - playPauseFab.setPivotX(playPauseFab.getWidth() / 2); - playPauseFab.setPivotY(playPauseFab.getHeight() / 2); - - playPauseFab.animate() - .setDuration(200) - .setInterpolator(new DecelerateInterpolator()) - .scaleX(1.1f) - .scaleY(1.1f) - .withEndAction(() -> playPauseFab.animate() - .setDuration(200) - .setInterpolator(new AccelerateInterpolator()) - .scaleX(1f) - .scaleY(1f) - .alpha(1f) - .start()) - .start(); - } - - @OnClick(R.id.player_play_pause_button) - void showAnimation() { - if (MusicPlayerRemote.isPlaying()) { - MusicPlayerRemote.pauseSong(); - } else { - MusicPlayerRemote.resumePlaying(); - } - showBouceAnimation(); - } - @Override public void onUpdateProgressViews(int progress, int total) { progressSlider.setMax(total); @@ -341,8 +306,6 @@ public class ColorPlaybackControlsFragment extends AbsPlayerControlsFragment { } public void hideVolumeIfAvailable() { - volumeContainer.setVisibility(PreferenceUtil.getInstance(getContext()).getVolumeToggle() ? View.VISIBLE : View.GONE); + volumeContainer.setVisibility(PreferenceUtil.getInstance().getVolumeToggle() ? View.VISIBLE : View.GONE); } - - } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/fit/FitFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/fit/FitFragment.java new file mode 100644 index 00000000..12ec30b8 --- /dev/null +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/fit/FitFragment.java @@ -0,0 +1,154 @@ +package code.name.monkey.retromusic.ui.fragments.player.fit; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.ColorInt; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.Toolbar; +import butterknife.BindView; +import butterknife.ButterKnife; +import butterknife.Unbinder; +import code.name.monkey.appthemehelper.util.ATHUtil; +import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper; +import code.name.monkey.retromusic.R; +import code.name.monkey.retromusic.helper.MusicPlayerRemote; +import code.name.monkey.retromusic.model.Song; +import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerFragment; +import code.name.monkey.retromusic.ui.fragments.player.PlayerAlbumCoverFragment; + + +public class FitFragment extends AbsPlayerFragment implements PlayerAlbumCoverFragment.Callbacks { + + @BindView(R.id.player_toolbar) + Toolbar toolbar; + + private int lastColor; + private FitPlaybackControlsFragment playbackControlsFragment; + private Unbinder unbinder; + + public FitFragment() { + } + + public static FitFragment newInstance() { + Bundle args = new Bundle(); + FitFragment fragment = new FitFragment(); + fragment.setArguments(args); + return fragment; + } + + @Override + @ColorInt + public int getPaletteColor() { + return lastColor; + } + + @Override + public void onShow() { + playbackControlsFragment.show(); + } + + @Override + public void onHide() { + playbackControlsFragment.hide(); + onBackPressed(); + } + + @Override + public boolean onBackPressed() { + return false; + } + + @Override + public Toolbar getToolbar() { + return toolbar; + } + + @Override + public int toolbarIconColor() { + return ATHUtil.resolveColor(getContext(), R.attr.iconColor); + } + + @Override + public void onColorChanged(int color) { + playbackControlsFragment.setDark(color); + lastColor = color; + getCallbacks().onPaletteColorChanged(); + + ToolbarContentTintHelper.colorizeToolbar(toolbar, ATHUtil.resolveColor(getContext(), R.attr.iconColor), getActivity()); + + } + + @Override + protected void toggleFavorite(Song song) { + super.toggleFavorite(song); + if (song.id == MusicPlayerRemote.getCurrentSong().id) { + updateIsFavorite(); + } + } + + @Override + public void onFavoriteToggled() { + toggleFavorite(MusicPlayerRemote.getCurrentSong()); + } + + + @Override + public void onDestroyView() { + super.onDestroyView(); + unbinder.unbind(); + } + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_fit, container, false); + unbinder = ButterKnife.bind(this, view); + if (getPlayerActivity() != null) { + getPlayerActivity().setDrawUnderStatusBar(); + getPlayerActivity().setNavigationbarColorAuto(); + } + return view; + } + + @Override + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + setUpSubFragments(); + setUpPlayerToolbar(); + } + + private void setUpSubFragments() { + playbackControlsFragment = (FitPlaybackControlsFragment) getChildFragmentManager().findFragmentById(R.id.playback_controls_fragment); + + PlayerAlbumCoverFragment playerAlbumCoverFragment = (PlayerAlbumCoverFragment) getChildFragmentManager().findFragmentById(R.id.player_album_cover_fragment); + if (playerAlbumCoverFragment != null) { + playerAlbumCoverFragment.setCallbacks(this); + playerAlbumCoverFragment.removeEffect(); + } + } + + private void setUpPlayerToolbar() { + toolbar.inflateMenu(R.menu.menu_player); + toolbar.setNavigationOnClickListener(v -> getActivity().onBackPressed()); + toolbar.setOnMenuItemClickListener(this); + + ToolbarContentTintHelper.colorizeToolbar(toolbar, + ATHUtil.resolveColor(getContext(), R.attr.iconColor), getActivity()); + } + + @Override + public void onServiceConnected() { + updateIsFavorite(); + + } + + @Override + public void onPlayingMetaChanged() { + updateIsFavorite(); + } +} diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/fit/FitPlaybackControlsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/fit/FitPlaybackControlsFragment.java new file mode 100644 index 00000000..271ebe61 --- /dev/null +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/fit/FitPlaybackControlsFragment.java @@ -0,0 +1,344 @@ +package code.name.monkey.retromusic.ui.fragments.player.fit; + +import android.animation.ObjectAnimator; +import android.graphics.PorterDuff; +import android.graphics.drawable.ClipDrawable; +import android.graphics.drawable.LayerDrawable; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.animation.AccelerateInterpolator; +import android.view.animation.DecelerateInterpolator; +import android.view.animation.LinearInterpolator; +import android.widget.ImageButton; +import android.widget.SeekBar; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatSeekBar; +import androidx.appcompat.widget.AppCompatTextView; +import butterknife.BindView; +import butterknife.ButterKnife; +import butterknife.OnClick; +import butterknife.Unbinder; +import code.name.monkey.appthemehelper.ThemeStore; +import code.name.monkey.appthemehelper.util.ATHUtil; +import code.name.monkey.appthemehelper.util.ColorUtil; +import code.name.monkey.appthemehelper.util.MaterialValueHelper; +import code.name.monkey.appthemehelper.util.TintHelper; +import code.name.monkey.retromusic.R; +import code.name.monkey.retromusic.helper.MusicPlayerRemote; +import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper; +import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler; +import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener; +import code.name.monkey.retromusic.model.Song; +import code.name.monkey.retromusic.service.MusicService; +import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerControlsFragment; +import code.name.monkey.retromusic.util.MusicUtil; +import code.name.monkey.retromusic.util.PreferenceUtil; + +public class FitPlaybackControlsFragment extends AbsPlayerControlsFragment { + + @BindView(R.id.player_play_pause_button) + ImageButton playPauseFab; + + @BindView(R.id.player_prev_button) + ImageButton prevButton; + + @BindView(R.id.player_next_button) + ImageButton nextButton; + + @BindView(R.id.player_repeat_button) + ImageButton repeatButton; + + @BindView(R.id.player_shuffle_button) + ImageButton shuffleButton; + + @BindView(R.id.player_progress_slider) + AppCompatSeekBar progressSlider; + + @BindView(R.id.player_song_total_time) + TextView songTotalTime; + + @BindView(R.id.player_song_current_progress) + TextView songCurrentProgress; + + @BindView(R.id.title) + AppCompatTextView title; + + @BindView(R.id.text) + TextView text; + + @BindView(R.id.volume_fragment_container) + View mVolumeContainer; + + private Unbinder unbinder; + private int lastPlaybackControlsColor; + private int lastDisabledPlaybackControlsColor; + private MusicProgressViewUpdateHelper progressViewUpdateHelper; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + progressViewUpdateHelper = new MusicProgressViewUpdateHelper(this); + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_fit_playback_controls, container, false); + unbinder = ButterKnife.bind(this, view); + return view; + } + + @Override + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + unbinder = ButterKnife.bind(this, view); + setUpMusicControllers(); + + if (PreferenceUtil.getInstance().getVolumeToggle()) { + mVolumeContainer.setVisibility(View.VISIBLE); + } else { + mVolumeContainer.setVisibility(View.GONE); + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + unbinder.unbind(); + } + + private void updateSong() { + Song song = MusicPlayerRemote.getCurrentSong(); + title.setText(song.title); + text.setText(song.artistName); + } + + @Override + public void onResume() { + super.onResume(); + progressViewUpdateHelper.start(); + } + + @Override + public void onPause() { + super.onPause(); + progressViewUpdateHelper.stop(); + } + + @Override + public void onServiceConnected() { + updatePlayPauseDrawableState(); + updateRepeatState(); + updateShuffleState(); + updateSong(); + } + + @Override + public void onPlayingMetaChanged() { + super.onPlayingMetaChanged(); + updateSong(); + } + + @Override + public void onPlayStateChanged() { + updatePlayPauseDrawableState(); + } + + @Override + public void onRepeatModeChanged() { + updateRepeatState(); + } + + @Override + public void onShuffleModeChanged() { + updateShuffleState(); + } + + @Override + public void setDark(int dark) { + int color = ATHUtil.resolveColor(getActivity(), android.R.attr.colorBackground); + if (ColorUtil.isColorLight(color)) { + lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(getActivity(), true); + lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(getActivity(), true); + } else { + lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(getActivity(), false); + lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(getActivity(), false); + } + + if (PreferenceUtil.getInstance().getAdaptiveColor()) { + setFabColor(dark); + } else { + setFabColor(ThemeStore.accentColor(getContext())); + } + + updateRepeatState(); + updateShuffleState(); + updatePrevNextColor(); + } + + private void setFabColor(int i) { + TintHelper.setTintAuto(playPauseFab, MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(i)), false); + TintHelper.setTintAuto(playPauseFab, i, true); + //setProgressBarColor(i); + } + + private void setProgressBarColor(int newColor) { + LayerDrawable ld = (LayerDrawable) progressSlider.getProgressDrawable(); + ClipDrawable clipDrawable = (ClipDrawable) ld.findDrawableByLayerId(android.R.id.progress); + clipDrawable.setColorFilter(newColor, PorterDuff.Mode.SRC_IN); + } + + private void setUpPlayPauseFab() { + playPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler()); + } + + protected void updatePlayPauseDrawableState() { + if (MusicPlayerRemote.isPlaying()) { + playPauseFab.setImageResource(R.drawable.ic_pause_white_24dp); + } else { + playPauseFab.setImageResource(R.drawable.ic_play_arrow_white_24dp); + } + } + + private void setUpMusicControllers() { + setUpPlayPauseFab(); + setUpPrevNext(); + setUpRepeatButton(); + setUpShuffleButton(); + setUpProgressSlider(); + } + + private void setUpPrevNext() { + updatePrevNextColor(); + nextButton.setOnClickListener(v -> MusicPlayerRemote.playNextSong()); + prevButton.setOnClickListener(v -> MusicPlayerRemote.back()); + } + + private void updatePrevNextColor() { + nextButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN); + prevButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN); + } + + private void setUpShuffleButton() { + shuffleButton.setOnClickListener(v -> MusicPlayerRemote.toggleShuffleMode()); + } + + @Override + protected void updateShuffleState() { + switch (MusicPlayerRemote.getShuffleMode()) { + case MusicService.SHUFFLE_MODE_SHUFFLE: + shuffleButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN); + break; + default: + shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN); + break; + } + } + + private void setUpRepeatButton() { + repeatButton.setOnClickListener(v -> MusicPlayerRemote.cycleRepeatMode()); + } + + @Override + protected void updateRepeatState() { + switch (MusicPlayerRemote.getRepeatMode()) { + case MusicService.REPEAT_MODE_NONE: + repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp); + repeatButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN); + break; + case MusicService.REPEAT_MODE_ALL: + repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp); + repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN); + break; + case MusicService.REPEAT_MODE_THIS: + repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp); + repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN); + break; + } + } + + @Override + protected void show() { + playPauseFab.animate() + .scaleX(1f) + .scaleY(1f) + .rotation(360f) + .setInterpolator(new DecelerateInterpolator()) + .start(); + } + + @Override + protected void hide() { + if (playPauseFab != null) { + playPauseFab.setScaleX(0f); + playPauseFab.setScaleY(0f); + playPauseFab.setRotation(0f); + } + } + + @Override + protected void setUpProgressSlider() { + progressSlider.setOnSeekBarChangeListener(new SimpleOnSeekbarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + if (fromUser) { + MusicPlayerRemote.seekTo(progress); + onUpdateProgressViews(MusicPlayerRemote.getSongProgressMillis(), + MusicPlayerRemote.getSongDurationMillis()); + } + } + }); + } + + public void showBouceAnimation() { + playPauseFab.clearAnimation(); + + playPauseFab.setScaleX(0.9f); + playPauseFab.setScaleY(0.9f); + playPauseFab.setVisibility(View.VISIBLE); + playPauseFab.setPivotX(playPauseFab.getWidth() / 2); + playPauseFab.setPivotY(playPauseFab.getHeight() / 2); + + playPauseFab.animate() + .setDuration(200) + .setInterpolator(new DecelerateInterpolator()) + .scaleX(1.1f) + .scaleY(1.1f) + .withEndAction(() -> playPauseFab.animate() + .setDuration(200) + .setInterpolator(new AccelerateInterpolator()) + .scaleX(1f) + .scaleY(1f) + .alpha(1f) + .start()) + .start(); + } + + @OnClick(R.id.player_play_pause_button) + void showAnimation() { + if (MusicPlayerRemote.isPlaying()) { + MusicPlayerRemote.pauseSong(); + } else { + MusicPlayerRemote.resumePlaying(); + } + showBouceAnimation(); + } + + @Override + public void onUpdateProgressViews(int progress, int total) { + progressSlider.setMax(total); + + ObjectAnimator animator = ObjectAnimator.ofInt(progressSlider, "progress", progress); + animator.setDuration(1500); + animator.setInterpolator(new LinearInterpolator()); + animator.start(); + + songTotalTime.setText(MusicUtil.getReadableDurationString(total)); + songCurrentProgress.setText(MusicUtil.getReadableDurationString(progress)); + } +} diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/flat/FlatPlaybackControlsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/flat/FlatPlaybackControlsFragment.java index 62078ff3..2f766f3f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/flat/FlatPlaybackControlsFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/flat/FlatPlaybackControlsFragment.java @@ -3,8 +3,6 @@ package code.name.monkey.retromusic.ui.fragments.player.flat; import android.animation.ObjectAnimator; import android.graphics.PorterDuff; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -15,6 +13,8 @@ import android.widget.ImageView; import android.widget.SeekBar; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.Unbinder; @@ -40,25 +40,35 @@ public class FlatPlaybackControlsFragment extends AbsMusicServiceFragment implem @BindView(R.id.text) TextView mText; + @BindView(R.id.title) TextView mTitle; + @BindView(R.id.playback_controls) ViewGroup viewGroup; + @BindView(R.id.player_song_total_time) TextView mSongTotalTime; + @BindView(R.id.player_song_current_progress) TextView mPlayerSongCurrentProgress; + @BindView(R.id.player_repeat_button) ImageButton mPlayerRepeatButton; + @BindView(R.id.player_shuffle_button) ImageButton mPlayerShuffleButton; + @BindView(R.id.player_play_pause_button) - ImageView mPlayerPlayPauseFab; - Unbinder unbinder; + ImageView playPauseFab; + @BindView(R.id.player_progress_slider) SeekBar progressSlider; + @BindView(R.id.volume_fragment_container) View mVolumeContainer; + + Unbinder unbinder; private int lastPlaybackControlsColor; private int lastDisabledPlaybackControlsColor; private MusicProgressViewUpdateHelper progressViewUpdateHelper; @@ -84,7 +94,7 @@ public class FlatPlaybackControlsFragment extends AbsMusicServiceFragment implem super.onViewCreated(view, savedInstanceState); setUpMusicControllers(); - mVolumeContainer.setVisibility(PreferenceUtil.getInstance(getContext()).getVolumeToggle() ? View.VISIBLE : View.GONE); + mVolumeContainer.setVisibility(PreferenceUtil.getInstance().getVolumeToggle() ? View.VISIBLE : View.GONE); } @Override @@ -114,7 +124,7 @@ public class FlatPlaybackControlsFragment extends AbsMusicServiceFragment implem public void show() { - mPlayerPlayPauseFab.animate() + playPauseFab.animate() .scaleX(1f) .scaleY(1f) .setInterpolator(new DecelerateInterpolator()) @@ -123,10 +133,10 @@ public class FlatPlaybackControlsFragment extends AbsMusicServiceFragment implem public void hide() { - if (mPlayerPlayPauseFab != null) { - mPlayerPlayPauseFab.setScaleX(0f); - mPlayerPlayPauseFab.setScaleY(0f); - mPlayerPlayPauseFab.setRotation(0f); + if (playPauseFab != null) { + playPauseFab.setScaleX(0f); + playPauseFab.setScaleY(0f); + playPauseFab.setRotation(0f); } } @@ -141,7 +151,7 @@ public class FlatPlaybackControlsFragment extends AbsMusicServiceFragment implem lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(getActivity(), false); } int accentColor = ThemeStore.accentColor(getContext()); - boolean b = PreferenceUtil.getInstance(getContext()).getAdaptiveColor(); + boolean b = PreferenceUtil.getInstance().getAdaptiveColor(); updateTextColors(b ? dark : accentColor); setProgressBarColor(b ? dark : accentColor); @@ -163,8 +173,8 @@ public class FlatPlaybackControlsFragment extends AbsMusicServiceFragment implem int colorPrimary = MaterialValueHelper.getPrimaryTextColor(getContext(), isDark); int colorSecondary = MaterialValueHelper.getSecondaryTextColor(getContext(), ColorUtil.isColorLight(darkColor)); - TintHelper.setTintAuto(mPlayerPlayPauseFab, colorPrimary, false); - TintHelper.setTintAuto(mPlayerPlayPauseFab, color, true); + TintHelper.setTintAuto(playPauseFab, colorPrimary, false); + TintHelper.setTintAuto(playPauseFab, color, true); mTitle.setBackgroundColor(color); mTitle.setTextColor(colorPrimary); @@ -180,7 +190,7 @@ public class FlatPlaybackControlsFragment extends AbsMusicServiceFragment implem @Override public void onServiceConnected() { - updatePlayPauseDrawableState(false); + updatePlayPauseDrawableState(); updateRepeatState(); updateShuffleState(); updateSong(); @@ -194,30 +204,19 @@ public class FlatPlaybackControlsFragment extends AbsMusicServiceFragment implem @Override public void onPlayStateChanged() { - updatePlayPauseDrawableState(true); - } - - protected void updatePlayPauseDrawableState(boolean animate) { - if (MusicPlayerRemote.isPlaying()) { - playerFabPlayPauseDrawable.setPause(animate); - } else { - playerFabPlayPauseDrawable.setPlay(animate); - } + updatePlayPauseDrawableState(); } private void setUpPlayPauseFab() { - playerFabPlayPauseDrawable = new PlayPauseDrawable(getActivity()); + playPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler()); + } - mPlayerPlayPauseFab.setImageDrawable( - playerFabPlayPauseDrawable); // Note: set the drawable AFTER TintHelper.setTintAuto() was called - //playPauseFab.setColorFilter(MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(fabColor)), PorterDuff.Mode.SRC_IN); - mPlayerPlayPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler()); - mPlayerPlayPauseFab.post(() -> { - if (mPlayerPlayPauseFab != null) { - mPlayerPlayPauseFab.setPivotX(mPlayerPlayPauseFab.getWidth() / 2); - mPlayerPlayPauseFab.setPivotY(mPlayerPlayPauseFab.getHeight() / 2); - } - }); + protected void updatePlayPauseDrawableState() { + if (MusicPlayerRemote.isPlaying()) { + playPauseFab.setImageResource(R.drawable.ic_pause_white_24dp); + } else { + playPauseFab.setImageResource(R.drawable.ic_play_arrow_white_24dp); + } } private void setUpMusicControllers() { diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/flat/FlatPlayerFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/flat/FlatPlayerFragment.java index cc16a8e6..eff1154e 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/flat/FlatPlayerFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/flat/FlatPlayerFragment.java @@ -4,14 +4,14 @@ import android.animation.ArgbEvaluator; import android.animation.ValueAnimator; import android.graphics.drawable.GradientDrawable; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.widget.Toolbar; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.Toolbar; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.Unbinder; @@ -52,7 +52,9 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbumCoverFragment playerAlbumCoverFragment = (PlayerAlbumCoverFragment) getChildFragmentManager().findFragmentById(R.id.player_album_cover_fragment); - playerAlbumCoverFragment.setCallbacks(this); + if (playerAlbumCoverFragment != null) { + playerAlbumCoverFragment.setCallbacks(this); + } } private void setUpPlayerToolbar() { @@ -86,6 +88,11 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_flat_player, container, false); unbinder = ButterKnife.bind(this, view); + if (getPlayerActivity() != null) { + getPlayerActivity().setDrawUnderNavigationBar(); + //getPlayerActivity().setNavigationbarColorAuto(); + addSafeArea(view); + } return view; } @@ -126,7 +133,7 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements @Override public int toolbarIconColor() { boolean isLight = ColorUtil.isColorLight(lastColor); - return PreferenceUtil.getInstance(getContext()).getAdaptiveColor() ? + return PreferenceUtil.getInstance().getAdaptiveColor() ? MaterialValueHelper.getPrimaryTextColor(getContext(), isLight) : ATHUtil.resolveColor(getContext(), R.attr.iconColor); } @@ -140,11 +147,11 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements boolean isLight = ColorUtil.isColorLight(color); //TransitionManager.beginDelayedTransition(mToolbar); - int iconColor = PreferenceUtil.getInstance(getContext()).getAdaptiveColor() ? + int iconColor = PreferenceUtil.getInstance().getAdaptiveColor() ? MaterialValueHelper.getPrimaryTextColor(getContext(), isLight) : ATHUtil.resolveColor(getContext(), R.attr.iconColor); ToolbarContentTintHelper.colorizeToolbar(toolbar, iconColor, getActivity()); - if (PreferenceUtil.getInstance(getContext()).getAdaptiveColor()) { + if (PreferenceUtil.getInstance().getAdaptiveColor()) { colorize(color); } } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/full/FullPlaybackControlsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/full/FullPlaybackControlsFragment.java index 7016b48b..b7a527f2 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/full/FullPlaybackControlsFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/full/FullPlaybackControlsFragment.java @@ -102,12 +102,12 @@ public class FullPlaybackControlsFragment extends AbsPlayerControlsFragment { } @Override - public void onViewCreated(View view, Bundle savedInstanceState) { + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); setUpMusicControllers(); - mVolumeContainer.setVisibility(PreferenceUtil.getInstance(getContext()).getVolumeToggle() ? View.VISIBLE : View.GONE); + mVolumeContainer.setVisibility(PreferenceUtil.getInstance().getVolumeToggle() ? View.VISIBLE : View.GONE); VolumeFragment volumeFragment = (VolumeFragment) getChildFragmentManager().findFragmentById(R.id.volume_fragment); volumeFragment.tintWhiteColor(); @@ -160,7 +160,7 @@ public class FullPlaybackControlsFragment extends AbsPlayerControlsFragment { lastPlaybackControlsColor = Color.WHITE; lastDisabledPlaybackControlsColor = ContextCompat.getColor(getContext(), R.color.md_grey_500); - if (PreferenceUtil.getInstance(getContext()).getAdaptiveColor()) { + if (PreferenceUtil.getInstance().getAdaptiveColor()) { setProgressBarColor(dark); } else { int accentColor = ThemeStore.accentColor(getContext()); diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/full/FullPlayerFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/full/FullPlayerFragment.java index 89481c6b..9f91fedd 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/full/FullPlayerFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/full/FullPlayerFragment.java @@ -42,6 +42,11 @@ public class FullPlayerFragment extends AbsPlayerFragment implements PlayerAlbum @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_full, container, false); unbinder = ButterKnife.bind(this, view); + if (getPlayerActivity() != null) { + getPlayerActivity().setDrawUnderNavigationBar(); + getPlayerActivity().setNavigationbarColor(Color.TRANSPARENT); + addSafeArea(view); + } return view; } @@ -59,8 +64,11 @@ public class FullPlayerFragment extends AbsPlayerFragment implements PlayerAlbum PlayerAlbumCoverFragment playerAlbumCoverFragment = (PlayerAlbumCoverFragment) getChildFragmentManager().findFragmentById(R.id.player_album_cover_fragment); - playerAlbumCoverFragment.setCallbacks(this); - playerAlbumCoverFragment.removeSlideEffect(); + if (playerAlbumCoverFragment != null) { + playerAlbumCoverFragment.setCallbacks(this); + playerAlbumCoverFragment.removeSlideEffect(); + } + } @Override diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/hmm/HmmPlaybackControlsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/hmm/HmmPlaybackControlsFragment.java index 5b01251d..17884afc 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/hmm/HmmPlaybackControlsFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/hmm/HmmPlaybackControlsFragment.java @@ -57,7 +57,7 @@ public class HmmPlaybackControlsFragment extends AbsPlayerControlsFragment { } @Override - public void onViewCreated(View view, Bundle savedInstanceState) { + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); setUpMusicControllers(); } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/hmm/HmmPlayerFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/hmm/HmmPlayerFragment.java index 38ce92f5..ba5b0a93 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/hmm/HmmPlayerFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/hmm/HmmPlayerFragment.java @@ -2,10 +2,8 @@ package code.name.monkey.retromusic.ui.fragments.player.hmm; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; +import android.graphics.Color; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.widget.Toolbar; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -15,6 +13,9 @@ import android.widget.TextView; import com.afollestad.materialdialogs.internal.MDTintHelper; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.Toolbar; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.Unbinder; @@ -98,6 +99,11 @@ public class HmmPlayerFragment extends AbsPlayerFragment implements @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_hmm_player, container, false); unBinder = ButterKnife.bind(this, view); + if (getPlayerActivity() != null) { + getPlayerActivity().setDrawUnderNavigationBar(); + getPlayerActivity().setNavigationbarColor(Color.TRANSPARENT); + addSafeArea(view); + } return view; } @@ -197,7 +203,7 @@ public class HmmPlayerFragment extends AbsPlayerFragment implements @Override public void onColorChanged(int color) { - lastColor = PreferenceUtil.getInstance(getContext()).getAdaptiveColor() ? color : + lastColor = PreferenceUtil.getInstance().getAdaptiveColor() ? color : ThemeStore.accentColor(getContext()); getCallbacks().onPaletteColorChanged(); hmmPlaybackControlsFragment.setDark(lastColor); diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/lockscreen/LockScreenPlayerControlsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/lockscreen/LockScreenPlayerControlsFragment.java index 5d9efe7c..b66d2e24 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/lockscreen/LockScreenPlayerControlsFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/lockscreen/LockScreenPlayerControlsFragment.java @@ -93,7 +93,7 @@ public class LockScreenPlayerControlsFragment extends AbsPlayerControlsFragment setUpMusicControllers(); //noinspection ConstantConditions - volumeContainer.setVisibility(PreferenceUtil.getInstance(getContext()).getVolumeToggle() + volumeContainer.setVisibility(PreferenceUtil.getInstance().getVolumeToggle() ? View.VISIBLE : View.GONE); } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/material/MaterialControlsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/material/MaterialControlsFragment.java index 899d50c5..5649185b 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/material/MaterialControlsFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/material/MaterialControlsFragment.java @@ -95,7 +95,7 @@ public class MaterialControlsFragment extends AbsPlayerControlsFragment { unbinder = ButterKnife.bind(this, view); setUpMusicControllers(); - if (PreferenceUtil.getInstance(getContext()).getVolumeToggle()) { + if (PreferenceUtil.getInstance().getVolumeToggle()) { mVolumeContainer.setVisibility(View.VISIBLE); } else { mVolumeContainer.setVisibility(View.GONE); @@ -169,7 +169,7 @@ public class MaterialControlsFragment extends AbsPlayerControlsFragment { updateRepeatState(); updateShuffleState(); - if (PreferenceUtil.getInstance(getContext()).getAdaptiveColor()) { + if (PreferenceUtil.getInstance().getAdaptiveColor()) { lastPlaybackControlsColor = dark; text.setTextColor(dark); } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/material/MaterialFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/material/MaterialFragment.java index 385a1088..9ce0c216 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/material/MaterialFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/material/MaterialFragment.java @@ -1,14 +1,14 @@ package code.name.monkey.retromusic.ui.fragments.player.material; import android.os.Bundle; -import androidx.annotation.ColorInt; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.widget.Toolbar; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import androidx.annotation.ColorInt; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.Toolbar; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.Unbinder; @@ -108,6 +108,11 @@ public class MaterialFragment extends AbsPlayerFragment implements PlayerAlbumCo @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_material, container, false); unbinder = ButterKnife.bind(this, view); + if (getPlayerActivity() != null) { + getPlayerActivity().setDrawUnderNavigationBar(); + getPlayerActivity().setNavigationbarColorAuto(); + addSafeArea(view); + } return view; } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/normal/PlayerFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/normal/PlayerFragment.java index fd78de18..0dd5a7b3 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/normal/PlayerFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/normal/PlayerFragment.java @@ -4,18 +4,19 @@ import android.animation.ArgbEvaluator; import android.animation.ValueAnimator; import android.graphics.drawable.GradientDrawable; import android.os.Bundle; -import androidx.annotation.ColorInt; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.widget.Toolbar; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import androidx.annotation.ColorInt; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.Toolbar; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.Unbinder; import code.name.monkey.appthemehelper.util.ATHUtil; +import code.name.monkey.appthemehelper.util.ColorUtil; import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.helper.MusicPlayerRemote; @@ -102,10 +103,9 @@ public class PlayerFragment extends AbsPlayerFragment implements PlayerAlbumCove lastColor = color; getCallbacks().onPaletteColorChanged(); - ToolbarContentTintHelper.colorizeToolbar(toolbar, - ATHUtil.resolveColor(getContext(), R.attr.iconColor), getActivity()); + ToolbarContentTintHelper.colorizeToolbar(toolbar, ATHUtil.resolveColor(getContext(), R.attr.iconColor), getActivity()); - if (PreferenceUtil.getInstance(getContext()).getAdaptiveColor()) { + if (PreferenceUtil.getInstance().getAdaptiveColor()) { colorize(color); } } @@ -136,6 +136,11 @@ public class PlayerFragment extends AbsPlayerFragment implements PlayerAlbumCove @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_player, container, false); unbinder = ButterKnife.bind(this, view); + if (getPlayerActivity() != null) { + getPlayerActivity().setDrawUnderNavigationBar(); + //getPlayerActivity().setNavigationbarColorAuto(); + addSafeArea(view); + } return view; } @@ -153,7 +158,9 @@ public class PlayerFragment extends AbsPlayerFragment implements PlayerAlbumCove PlayerAlbumCoverFragment playerAlbumCoverFragment = (PlayerAlbumCoverFragment) getChildFragmentManager() .findFragmentById(R.id.player_album_cover_fragment); - playerAlbumCoverFragment.setCallbacks(this); + if (playerAlbumCoverFragment != null) { + playerAlbumCoverFragment.setCallbacks(this); + } } private void setUpPlayerToolbar() { diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/normal/PlayerPlaybackControlsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/normal/PlayerPlaybackControlsFragment.java index 8de82bef..28eb7789 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/normal/PlayerPlaybackControlsFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/normal/PlayerPlaybackControlsFragment.java @@ -5,10 +5,6 @@ import android.graphics.PorterDuff; import android.graphics.drawable.ClipDrawable; import android.graphics.drawable.LayerDrawable; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.widget.AppCompatSeekBar; -import androidx.appcompat.widget.AppCompatTextView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -19,6 +15,10 @@ import android.widget.ImageButton; import android.widget.SeekBar; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatSeekBar; +import androidx.appcompat.widget.AppCompatTextView; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; @@ -31,13 +31,13 @@ import code.name.monkey.appthemehelper.util.TintHelper; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.helper.MusicPlayerRemote; import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper; +import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler; import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener; import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.service.MusicService; import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerControlsFragment; import code.name.monkey.retromusic.util.MusicUtil; import code.name.monkey.retromusic.util.PreferenceUtil; -import code.name.monkey.retromusic.views.PlayPauseDrawable; public class PlayerPlaybackControlsFragment extends AbsPlayerControlsFragment { @@ -75,7 +75,6 @@ public class PlayerPlaybackControlsFragment extends AbsPlayerControlsFragment { View mVolumeContainer; private Unbinder unbinder; - private PlayPauseDrawable playerFabPlayPauseDrawable; private int lastPlaybackControlsColor; private int lastDisabledPlaybackControlsColor; private MusicProgressViewUpdateHelper progressViewUpdateHelper; @@ -100,7 +99,7 @@ public class PlayerPlaybackControlsFragment extends AbsPlayerControlsFragment { unbinder = ButterKnife.bind(this, view); setUpMusicControllers(); - if (PreferenceUtil.getInstance(getContext()).getVolumeToggle()) { + if (PreferenceUtil.getInstance().getVolumeToggle()) { mVolumeContainer.setVisibility(View.VISIBLE); } else { mVolumeContainer.setVisibility(View.GONE); @@ -133,7 +132,7 @@ public class PlayerPlaybackControlsFragment extends AbsPlayerControlsFragment { @Override public void onServiceConnected() { - updatePlayPauseDrawableState(false); + updatePlayPauseDrawableState(); updateRepeatState(); updateShuffleState(); updateSong(); @@ -147,7 +146,7 @@ public class PlayerPlaybackControlsFragment extends AbsPlayerControlsFragment { @Override public void onPlayStateChanged() { - updatePlayPauseDrawableState(true); + updatePlayPauseDrawableState(); } @Override @@ -171,7 +170,7 @@ public class PlayerPlaybackControlsFragment extends AbsPlayerControlsFragment { lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(getActivity(), false); } - if (PreferenceUtil.getInstance(getContext()).getAdaptiveColor()) { + if (PreferenceUtil.getInstance().getAdaptiveColor()) { setFabColor(dark); } else { setFabColor(ThemeStore.accentColor(getContext())); @@ -188,32 +187,21 @@ public class PlayerPlaybackControlsFragment extends AbsPlayerControlsFragment { setProgressBarColor(i); } - public void setProgressBarColor(int newColor) { + private void setProgressBarColor(int newColor) { LayerDrawable ld = (LayerDrawable) progressSlider.getProgressDrawable(); ClipDrawable clipDrawable = (ClipDrawable) ld.findDrawableByLayerId(android.R.id.progress); clipDrawable.setColorFilter(newColor, PorterDuff.Mode.SRC_IN); } private void setUpPlayPauseFab() { - playerFabPlayPauseDrawable = new PlayPauseDrawable(getActivity()); - - playPauseFab.setImageDrawable( - playerFabPlayPauseDrawable); // Note: set the drawable AFTER TintHelper.setTintAuto() was called - //playPauseFab.setColorFilter(MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(fabColor)), PorterDuff.Mode.SRC_IN); - //playPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler()); - playPauseFab.post(() -> { - if (playPauseFab != null) { - playPauseFab.setPivotX(playPauseFab.getWidth() / 2); - playPauseFab.setPivotY(playPauseFab.getHeight() / 2); - } - }); + playPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler()); } - protected void updatePlayPauseDrawableState(boolean animate) { + protected void updatePlayPauseDrawableState() { if (MusicPlayerRemote.isPlaying()) { - playerFabPlayPauseDrawable.setPause(animate); + playPauseFab.setImageResource(R.drawable.ic_pause_white_24dp); } else { - playerFabPlayPauseDrawable.setPlay(animate); + playPauseFab.setImageResource(R.drawable.ic_play_arrow_white_24dp); } } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/plain/PlainPlaybackControlsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/plain/PlainPlaybackControlsFragment.java index ea097afa..e1afe5e4 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/plain/PlainPlaybackControlsFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/plain/PlainPlaybackControlsFragment.java @@ -27,6 +27,7 @@ import code.name.monkey.appthemehelper.util.TintHelper; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.helper.MusicPlayerRemote; import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper; +import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler; import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener; import code.name.monkey.retromusic.service.MusicService; import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerControlsFragment; @@ -75,7 +76,7 @@ public class PlainPlaybackControlsFragment extends AbsPlayerControlsFragment { @Override public void onPlayStateChanged() { - updatePlayPauseDrawableState(true); + updatePlayPauseDrawableState(); } @Override @@ -90,7 +91,7 @@ public class PlainPlaybackControlsFragment extends AbsPlayerControlsFragment { @Override public void onServiceConnected() { - updatePlayPauseDrawableState(false); + updatePlayPauseDrawableState(); updateRepeatState(); updateShuffleState(); } @@ -130,10 +131,10 @@ public class PlainPlaybackControlsFragment extends AbsPlayerControlsFragment { } @Override - public void onViewCreated(View view, Bundle savedInstanceState) { + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); setUpMusicControllers(); - if (PreferenceUtil.getInstance(getContext()).getVolumeToggle()) { + if (PreferenceUtil.getInstance().getVolumeToggle()) { volumeContainer.setVisibility(View.VISIBLE); } else { volumeContainer.setVisibility(View.GONE); @@ -293,7 +294,7 @@ public class PlainPlaybackControlsFragment extends AbsPlayerControlsFragment { MaterialValueHelper.getPrimaryDisabledTextColor(getActivity(), false); } - int finalColor = PreferenceUtil.getInstance(getContext()).getAdaptiveColor() ? dark : ThemeStore.accentColor(getContext()); + int finalColor = PreferenceUtil.getInstance().getAdaptiveColor() ? dark : ThemeStore.accentColor(getContext()); setProgressBarColor(finalColor); @@ -310,24 +311,14 @@ public class PlainPlaybackControlsFragment extends AbsPlayerControlsFragment { } private void setUpPlayPauseFab() { - playerFabPlayPauseDrawable = new PlayPauseDrawable(getActivity()); - - playPauseFab.setImageDrawable(playerFabPlayPauseDrawable); // Note: set the drawable AFTER TintHelper.setTintAuto() was called - //playPauseFab.setColorFilter(MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(fabColor)), PorterDuff.Mode.SRC_IN); - //playPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler()); - playPauseFab.post(() -> { - if (playPauseFab != null) { - playPauseFab.setPivotX(playPauseFab.getWidth() / 2); - playPauseFab.setPivotY(playPauseFab.getHeight() / 2); - } - }); + playPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler()); } - protected void updatePlayPauseDrawableState(boolean animate) { + protected void updatePlayPauseDrawableState() { if (MusicPlayerRemote.isPlaying()) { - playerFabPlayPauseDrawable.setPause(animate); + playPauseFab.setImageResource(R.drawable.ic_pause_white_24dp); } else { - playerFabPlayPauseDrawable.setPlay(animate); + playPauseFab.setImageResource(R.drawable.ic_play_arrow_white_24dp); } } } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/plain/PlainPlayerFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/plain/PlainPlayerFragment.java index da5be59b..9d8b379f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/plain/PlainPlayerFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/plain/PlainPlayerFragment.java @@ -1,15 +1,16 @@ package code.name.monkey.retromusic.ui.fragments.player.plain; +import android.graphics.Color; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.widget.Toolbar; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.Toolbar; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.Unbinder; @@ -74,6 +75,11 @@ public class PlainPlayerFragment extends AbsPlayerFragment implements @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_plain_player, container, false); unbinder = ButterKnife.bind(this, view); + if (getPlayerActivity() != null) { + getPlayerActivity().setDrawUnderNavigationBar(); + getPlayerActivity().setNavigationbarColorAuto(); + addSafeArea(view); + } return view; } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/simple/SimplePlaybackControlsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/simple/SimplePlaybackControlsFragment.java index 75e78777..657b0155 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/simple/SimplePlaybackControlsFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/simple/SimplePlaybackControlsFragment.java @@ -2,8 +2,6 @@ package code.name.monkey.retromusic.ui.fragments.player.simple; import android.graphics.PorterDuff; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -12,6 +10,8 @@ import android.view.animation.DecelerateInterpolator; import android.widget.ImageButton; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; @@ -24,6 +24,7 @@ import code.name.monkey.appthemehelper.util.TintHelper; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.helper.MusicPlayerRemote; import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper; +import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler; import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.service.MusicService; import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerControlsFragment; @@ -39,20 +40,28 @@ public class SimplePlaybackControlsFragment extends AbsPlayerControlsFragment { @BindView(R.id.player_play_pause_button) ImageButton playPauseFab; + @BindView(R.id.player_prev_button) ImageButton prevButton; + @BindView(R.id.player_next_button) ImageButton nextButton; + @BindView(R.id.player_repeat_button) ImageButton repeatButton; + @BindView(R.id.player_shuffle_button) ImageButton shuffleButton; + @BindView(R.id.player_song_current_progress) TextView songCurrentProgress; + @BindView(R.id.volume_fragment_container) View volumeContainer; + @BindView(R.id.title) TextView title; + @BindView(R.id.text) TextView text; private Unbinder unbinder; @@ -64,7 +73,7 @@ public class SimplePlaybackControlsFragment extends AbsPlayerControlsFragment { @Override public void onPlayStateChanged() { - updatePlayPauseDrawableState(true); + updatePlayPauseDrawableState(); } @Override @@ -79,7 +88,7 @@ public class SimplePlaybackControlsFragment extends AbsPlayerControlsFragment { @Override public void onServiceConnected() { - updatePlayPauseDrawableState(false); + updatePlayPauseDrawableState(); updateRepeatState(); updateShuffleState(); updateSong(); @@ -119,11 +128,11 @@ public class SimplePlaybackControlsFragment extends AbsPlayerControlsFragment { } @Override - public void onViewCreated(View view, Bundle savedInstanceState) { + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); setUpMusicControllers(); volumeContainer.setVisibility( - PreferenceUtil.getInstance(getContext()).getVolumeToggle() ? View.VISIBLE : View.GONE); + PreferenceUtil.getInstance().getVolumeToggle() ? View.VISIBLE : View.GONE); } private void setUpMusicControllers() { @@ -277,47 +286,27 @@ public class SimplePlaybackControlsFragment extends AbsPlayerControlsFragment { .getPrimaryDisabledTextColor(getActivity(), false); } - if (PreferenceUtil.getInstance(getContext()).getAdaptiveColor()) { - TintHelper.setTintAuto(playPauseFab, - MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(dark)), - false); - TintHelper.setTintAuto(playPauseFab, dark, true); - text.setTextColor(dark); - } else { - int accentColor = ThemeStore.accentColor(getContext()); - text.setTextColor(accentColor); - TintHelper.setTintAuto(playPauseFab, - MaterialValueHelper - .getPrimaryTextColor(getContext(), ColorUtil.isColorLight(accentColor)), - false); - TintHelper.setTintAuto(playPauseFab, accentColor, true); - } + int finalColor = PreferenceUtil.getInstance().getAdaptiveColor() ? dark : ThemeStore.accentColor(getContext()); + text.setTextColor(finalColor); + TintHelper.setTintAuto(playPauseFab, MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(finalColor)), false); + TintHelper.setTintAuto(playPauseFab, finalColor, true); + updateRepeatState(); updateShuffleState(); updatePrevNextColor(); } - private void setUpPlayPauseFab() { - playerFabPlayPauseDrawable = new PlayPauseDrawable(getActivity()); - playPauseFab.setImageDrawable( - playerFabPlayPauseDrawable); // Note: set the drawable AFTER TintHelper.setTintAuto() was called - //playPauseFab.setColorFilter(MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(fabColor)), PorterDuff.Mode.SRC_IN); - //playPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler()); - playPauseFab.post(() -> { - if (playPauseFab != null) { - playPauseFab.setPivotX(playPauseFab.getWidth() / 2); - playPauseFab.setPivotY(playPauseFab.getHeight() / 2); - } - }); + private void setUpPlayPauseFab() { + playPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler()); } - protected void updatePlayPauseDrawableState(boolean animate) { + protected void updatePlayPauseDrawableState() { if (MusicPlayerRemote.isPlaying()) { - playerFabPlayPauseDrawable.setPause(animate); + playPauseFab.setImageResource(R.drawable.ic_pause_white_24dp); } else { - playerFabPlayPauseDrawable.setPlay(animate); + playPauseFab.setImageResource(R.drawable.ic_play_arrow_white_24dp); } } } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/simple/SimplePlayerFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/simple/SimplePlayerFragment.java index 4ba7c132..657c8277 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/simple/SimplePlayerFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/simple/SimplePlayerFragment.java @@ -1,13 +1,13 @@ package code.name.monkey.retromusic.ui.fragments.player.simple; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.widget.Toolbar; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.Toolbar; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.Unbinder; @@ -46,6 +46,11 @@ public class SimplePlayerFragment extends AbsPlayerFragment implements @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_simple_player, container, false); unbinder = ButterKnife.bind(this, view); + if (getPlayerActivity() != null) { + getPlayerActivity().setDrawUnderNavigationBar(); + getPlayerActivity().setNavigationbarColorAuto(); + addSafeArea(view); + } return view; } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/AudioSettings.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/AudioSettings.java index 1ae62cd8..28485335 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/AudioSettings.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/AudioSettings.java @@ -19,7 +19,7 @@ public class AudioSettings extends AbsSettingsFragment { @Override public void invalidateSettings() { Preference findPreference = findPreference("equalizer"); - if (!hasEqualizer() && !PreferenceUtil.getInstance(getContext()).getSelectedEqualizer().equals("retro")) { + if (!hasEqualizer() && !PreferenceUtil.getInstance().getSelectedEqualizer().equals("retro")) { findPreference.setEnabled(false); findPreference.setSummary(getResources().getString(R.string.no_equalizer)); } else { diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/MainSettingsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/MainSettingsFragment.java index c14807de..0843b248 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/MainSettingsFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/MainSettingsFragment.java @@ -74,7 +74,7 @@ public class MainSettingsFragment extends Fragment { text.setTextColor(ThemeStore.textColorSecondary(getContext())); titleWelcome.setTextColor(ThemeStore.textColorPrimary(getContext())); - titleWelcome.setText(String.format("%s %s!", getTimeOfTheDay(), PreferenceUtil.getInstance(getContext()).getUserName())); + titleWelcome.setText(String.format("%s %s!", getTimeOfTheDay(), PreferenceUtil.getInstance().getUserName())); loadImageFromStorage(); } @@ -151,7 +151,7 @@ public class MainSettingsFragment extends Fragment { .setQuality(75) .setCompressFormat(Bitmap.CompressFormat.WEBP) .compressToBitmapAsFlowable( - new File(PreferenceUtil.getInstance(getContext()).getProfileImage(), USER_PROFILE)) + new File(PreferenceUtil.getInstance().getProfileImage(), USER_PROFILE)) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(userImageBottom::setImageBitmap, diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/NotificationSettingsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/NotificationSettingsFragment.java index 9a61f0e3..1739f4b5 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/NotificationSettingsFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/NotificationSettingsFragment.java @@ -20,10 +20,10 @@ public class NotificationSettingsFragment extends AbsSettingsFragment { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { classicNotification.setVisible(false); } else { - classicNotification.setChecked(PreferenceUtil.getInstance(getActivity()).classicNotification()); + classicNotification.setChecked(PreferenceUtil.getInstance().classicNotification()); classicNotification.setOnPreferenceChangeListener((preference, newValue) -> { // Save preference - PreferenceUtil.getInstance(getActivity()).setClassicNotification((Boolean) newValue); + PreferenceUtil.getInstance().setClassicNotification((Boolean) newValue); final MusicService service = MusicPlayerRemote.musicService; if (service != null) { diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/NowPlayingSettingsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/NowPlayingSettingsFragment.java index 77ec51c3..cf3b8805 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/NowPlayingSettingsFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/NowPlayingSettingsFragment.java @@ -41,21 +41,21 @@ public class NowPlayingSettingsFragment extends AbsSettingsFragment implements private void updateNowPlayingScreenSummary() { //noinspection ConstantConditions - findPreference("now_playing_screen_id").setSummary(PreferenceUtil.getInstance(getActivity()).getNowPlayingScreen().titleRes); + findPreference("now_playing_screen_id").setSummary(PreferenceUtil.getInstance().getNowPlayingScreen().titleRes); } @Override public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); //noinspection ConstantConditions - PreferenceUtil.getInstance(getContext()).registerOnSharedPreferenceChangedListener(this); + PreferenceUtil.getInstance().registerOnSharedPreferenceChangedListener(this); } @Override public void onDestroyView() { super.onDestroyView(); //noinspection ConstantConditions - PreferenceUtil.getInstance(getContext()).unregisterOnSharedPreferenceChangedListener(this); + PreferenceUtil.getInstance().unregisterOnSharedPreferenceChangedListener(this); } @Override @@ -75,6 +75,6 @@ public class NowPlayingSettingsFragment extends AbsSettingsFragment implements } private void updateAlbumCoverStyleSummary() { - findPreference("album_cover_style_id").setSummary(PreferenceUtil.getInstance(getActivity()).getAlbumCoverStyle().titleRes); + findPreference("album_cover_style_id").setSummary(PreferenceUtil.getInstance().getAlbumCoverStyle().titleRes); } } diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/PersonaizeSettingsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/PersonaizeSettingsFragment.java index b1eb09d9..0bb677f3 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/PersonaizeSettingsFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/PersonaizeSettingsFragment.java @@ -43,14 +43,14 @@ public class PersonaizeSettingsFragment extends AbsSettingsFragment implements S public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); //noinspection ConstantConditions - PreferenceUtil.getInstance(getContext()).registerOnSharedPreferenceChangedListener(this); + PreferenceUtil.getInstance().registerOnSharedPreferenceChangedListener(this); } @Override public void onDestroyView() { super.onDestroyView(); //noinspection ConstantConditions - PreferenceUtil.getInstance(getContext()).unregisterOnSharedPreferenceChangedListener(this); + PreferenceUtil.getInstance().unregisterOnSharedPreferenceChangedListener(this); } @Override diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/ThemeSettingsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/ThemeSettingsFragment.java index 9d89f89c..daedb735 100644 --- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/ThemeSettingsFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/ThemeSettingsFragment.java @@ -31,7 +31,7 @@ public class ThemeSettingsFragment extends AbsSettingsFragment { final ATEColorPreference primaryColorPref = (ATEColorPreference) findPreference( "primary_color"); //noinspection ConstantConditions - primaryColorPref.setVisible(PreferenceUtil.getInstance(getActivity()).getGeneralTheme() == R.style.Theme_RetroMusic_Color); + primaryColorPref.setVisible(PreferenceUtil.getInstance().getGeneralTheme() == R.style.Theme_RetroMusic_Color); final int primaryColor = ThemeStore.primaryColor(getActivity()); primaryColorPref.setColor(primaryColor, ColorUtil.darkenColor(primaryColor)); primaryColorPref.setOnPreferenceClickListener(preference -> { @@ -123,10 +123,10 @@ public class ThemeSettingsFragment extends AbsSettingsFragment { if (!VersionUtils.hasNougatMR()) { colorAppShortcuts.setVisible(false); } else { - colorAppShortcuts.setChecked(PreferenceUtil.getInstance(getActivity()).coloredAppShortcuts()); + colorAppShortcuts.setChecked(PreferenceUtil.getInstance().coloredAppShortcuts()); colorAppShortcuts.setOnPreferenceChangeListener((preference, newValue) -> { // Save preference - PreferenceUtil.getInstance(getActivity()).setColoredAppShortcuts((Boolean) newValue); + PreferenceUtil.getInstance().setColoredAppShortcuts((Boolean) newValue); // Update app shortcuts new DynamicShortcutManager(getActivity()).updateDynamicShortcuts(); diff --git a/app/src/main/java/code/name/monkey/retromusic/util/NavigationUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/NavigationUtil.java index 6ea39059..790ffbc6 100755 --- a/app/src/main/java/code/name/monkey/retromusic/util/NavigationUtil.java +++ b/app/src/main/java/code/name/monkey/retromusic/util/NavigationUtil.java @@ -2,6 +2,7 @@ package code.name.monkey.retromusic.util; import android.app.Activity; import android.content.ActivityNotFoundException; +import android.content.Context; import android.content.Intent; import android.media.audiofx.AudioEffect; import android.widget.Toast; @@ -17,12 +18,12 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote; import code.name.monkey.retromusic.model.Genre; import code.name.monkey.retromusic.model.Playlist; import code.name.monkey.retromusic.ui.activities.AboutActivity; -import code.name.monkey.retromusic.ui.activities.AlbumDetailsActivity; import code.name.monkey.retromusic.ui.activities.ArtistDetailActivity; import code.name.monkey.retromusic.ui.activities.EqualizerActivity; import code.name.monkey.retromusic.ui.activities.GenreDetailsActivity; import code.name.monkey.retromusic.ui.activities.LicenseActivity; import code.name.monkey.retromusic.ui.activities.LyricsActivity; +import code.name.monkey.retromusic.ui.activities.NowPayingActivity; import code.name.monkey.retromusic.ui.activities.PlayingQueueActivity; import code.name.monkey.retromusic.ui.activities.PlaylistDetailActivity; import code.name.monkey.retromusic.ui.activities.ProVersionActivity; @@ -30,6 +31,8 @@ import code.name.monkey.retromusic.ui.activities.SearchActivity; import code.name.monkey.retromusic.ui.activities.SettingsActivity; import code.name.monkey.retromusic.ui.activities.SupportDevelopmentActivity; import code.name.monkey.retromusic.ui.activities.UserInfoActivity; +import code.name.monkey.retromusic.ui.activities.WhatsNewActivity; +import code.name.monkey.retromusic.ui.activities.AlbumDetailsActivity; import static code.name.monkey.retromusic.Constants.RATE_ON_GOOGLE_PLAY; import static code.name.monkey.retromusic.ui.activities.GenreDetailsActivity.EXTRA_GENRE_ID; @@ -63,7 +66,7 @@ public class NavigationUtil { } public static void openEqualizer(@NonNull final Activity activity) { - if (PreferenceUtil.getInstance(activity).getSelectedEqualizer().equals("system")) { + if (PreferenceUtil.getInstance().getSelectedEqualizer().equals("system")) { stockEqalizer(activity); } else { ActivityCompat.startActivity(activity, new Intent(activity, EqualizerActivity.class), null); @@ -139,4 +142,14 @@ public class NavigationUtil { public static void gotoExpandedController(Activity activity) { ActivityCompat.startActivity(activity, new Intent(activity, ExpandedCastControlsActivity.class), null); } + + public static void gotoWhatNews(Activity activity) { + ActivityCompat.startActivity(activity, new Intent(activity, WhatsNewActivity.class), null); + } + + public static void gotoNowPlayingActivity(Context context, @Nullable Pair... sharedElements) { + ActivityCompat.startActivity(context, new Intent(context, NowPayingActivity.class), + ActivityOptionsCompat.makeSceneTransitionAnimation((Activity) context, sharedElements).toBundle()); + + } } 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 326009ca..0422344c 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 @@ -26,7 +26,11 @@ import code.name.monkey.retromusic.RetroApplication; import code.name.monkey.retromusic.helper.SortOrder; import code.name.monkey.retromusic.model.CategoryInfo; import code.name.monkey.retromusic.transform.CascadingPageTransformer; +import code.name.monkey.retromusic.transform.DepthTransformation; +import code.name.monkey.retromusic.transform.HingeTransformation; +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.ui.activities.MainActivity; import code.name.monkey.retromusic.ui.fragments.AlbumCoverStyle; import code.name.monkey.retromusic.ui.fragments.NowPlayingScreen; @@ -106,6 +110,8 @@ public final class PreferenceUtil { private static final String SONG_GRID_STYLE = "song_grid_style"; private static final String TOGGLE_ANIMATIONS = "toggle_animations"; private static final String LAST_KNOWN_LYRICS_TYPE = "LAST_KNOWN_LYRICS_TYPE"; + private static final String ALBUM_DETAIL_STYLE = "album_detail_style"; + private static final String PAUSE_ON_ZERO_VOLUME = "pause_on_zero_volume"; private static PreferenceUtil sInstance; private final SharedPreferences mPreferences; @@ -113,9 +119,9 @@ public final class PreferenceUtil { mPreferences = PreferenceManager.getDefaultSharedPreferences(context); } - public static PreferenceUtil getInstance(@NonNull final Context context) { + public static PreferenceUtil getInstance() { if (sInstance == null) { - sInstance = new PreferenceUtil(context.getApplicationContext()); + sInstance = new PreferenceUtil(RetroApplication.getContext()); } return sInstance; } @@ -137,15 +143,6 @@ public final class PreferenceUtil { } } - public int getAlbumDetailsPageStyle() { - - TypedArray typedArray = RetroApplication.getInstance(). - getResources().obtainTypedArray(R.array.pref_album_detail_style_values); - int layout = typedArray.getResourceId(mPreferences.getInt("album_detail_style", 0), -1); - typedArray.recycle(); - return layout; - } - public final String getArtistSortOrder() { return mPreferences.getString(ARTIST_SORT_ORDER, SortOrder.ArtistSortOrder.ARTIST_A_Z); } @@ -734,6 +731,21 @@ public final class PreferenceUtil { return layoutRes; } + public String getAlbumDetailsStyle() { + return mPreferences.getString(ALBUM_DETAIL_STYLE, "0"); + } + + public int getAlbumDetailsStyle(Context context) { + int pos = Integer.parseInt(Objects.requireNonNull(mPreferences.getString(ALBUM_DETAIL_STYLE, "0"))); + TypedArray typedArray = context.getResources().obtainTypedArray(R.array.pref_album_details_style_layout); + int layoutRes = typedArray.getResourceId(pos, -1); + typedArray.recycle(); + if (layoutRes == -1) { + return R.layout.activity_album; + } + return layoutRes; + } + public void setArtistGridStyle(int viewAs) { mPreferences.edit().putInt(ARTIST_GRID_STYLE, viewAs).apply(); } @@ -754,6 +766,10 @@ public final class PreferenceUtil { return mPreferences.getBoolean(TOGGLE_ANIMATIONS, false); } + public boolean pauseOnZeroVolume() { + return mPreferences.getBoolean(PAUSE_ON_ZERO_VOLUME, false); + } + public ViewPager.PageTransformer getAlbumCoverTransform(Context context) { int style = Integer.parseInt(Objects.requireNonNull(mPreferences.getString(ALBUM_COVER_TRANSFORM, "0"))); @@ -763,6 +779,14 @@ public final class PreferenceUtil { return new NormalPageTransformer(); case 1: return new CascadingPageTransformer(); + case 2: + return new DepthTransformation(); + case 3: + return new HorizontalFlipTransformation(); + case 4: + return new VerticalFlipTransformation(); + case 5: + return new HingeTransformation(); } } diff --git a/app/src/main/java/code/name/monkey/retromusic/util/RetroUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/RetroUtil.java index 6ff051d3..9f04ec9c 100755 --- a/app/src/main/java/code/name/monkey/retromusic/util/RetroUtil.java +++ b/app/src/main/java/code/name/monkey/retromusic/util/RetroUtil.java @@ -10,6 +10,7 @@ import android.content.res.Resources; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.Canvas; +import android.graphics.Color; import android.graphics.Point; import android.graphics.drawable.Drawable; import android.net.ConnectivityManager; @@ -21,6 +22,7 @@ import android.provider.BaseColumns; import android.provider.MediaStore; import android.util.DisplayMetrics; import android.view.Display; +import android.view.Surface; import android.view.View; import android.view.ViewGroup; import android.view.Window; @@ -100,10 +102,6 @@ public class RetroUtil { WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } - public static void setAllowDrawUnderStatusBar(@NonNull Window window) { - window.getDecorView().setSystemUiVisibility( - View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - } public static boolean isMarshMellow() { return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M; @@ -223,7 +221,7 @@ public class RetroUtil { } public static boolean isAllowedToDownloadMetadata(final Context context) { - switch (PreferenceUtil.getInstance(context).autoDownloadImagesPolicy()) { + switch (PreferenceUtil.getInstance().autoDownloadImagesPolicy()) { case "always": return true; case "only_wifi": @@ -308,4 +306,102 @@ public class RetroUtil { } return result; } + + public static int getNavigationBarHeight(Context context) { + int result = 0; + int resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android"); + if (resourceId > 0) { + result = context.getResources().getDimensionPixelSize(resourceId); + } + return result; + } + + + public static void setAllowDrawUnderNavigationBar(Window window) { + window.setNavigationBarColor(Color.TRANSPARENT); + window.getDecorView().setSystemUiVisibility(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION : + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + ); + } + + public static void setAllowDrawUnderStatusBar(@NonNull Window window) { + window.getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + } + + public static int getSoftButtonsBarSizePort(Activity activity) { + // getRealMetrics is only available with API 17 and + + DisplayMetrics metrics = new DisplayMetrics(); + activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); + int usableHeight = metrics.heightPixels; + activity.getWindowManager().getDefaultDisplay().getRealMetrics(metrics); + int realHeight = metrics.heightPixels; + if (realHeight > usableHeight) + return realHeight - usableHeight; + else + return 0; + } + + public static boolean hasNavBar(Resources resources) { + int id = resources.getIdentifier("config_showNavigationBar", "bool", "android"); + if (id > 0) + return resources.getBoolean(id); + else + return false; + } + + public static int getNavigationBarHeight(Resources resources) { + if (!hasNavBar(resources)) + return 0; + + int orientation = resources.getConfiguration().orientation; + + //Only phone between 0-599 has navigationbar can move + boolean isSmartphone = resources.getConfiguration().smallestScreenWidthDp < 600; + if (isSmartphone && Configuration.ORIENTATION_LANDSCAPE == orientation) + return 0; + + int id = resources + .getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_height_landscape", "dimen", "android"); + if (id > 0) + return resources.getDimensionPixelSize(id); + + return 0; + } + + public static int getNavigationBarWidth(Resources resources) { + if (!hasNavBar(resources)) + return 0; + + int orientation = resources.getConfiguration().orientation; + + //Only phone between 0-599 has navigationbar can move + boolean isSmartphone = resources.getConfiguration().smallestScreenWidthDp < 600; + + if (orientation == Configuration.ORIENTATION_LANDSCAPE && isSmartphone) { + int id = resources.getIdentifier("navigation_bar_width", "dimen", "android"); + if (id > 0) + return resources.getDimensionPixelSize(id); + } + + return 0; + } + + public static boolean isNavigationBarLeftSide() { + Display display = ((WindowManager) RetroApplication.getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); + int screenOrientation = display.getRotation(); + return screenOrientation == Surface.ROTATION_180; + } + + public static boolean isNavigationBarRightSide() { + Display display = ((WindowManager) RetroApplication.getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); + int screenOrientation = display.getRotation(); + return screenOrientation == Surface.ROTATION_90; + } } diff --git a/app/src/main/java/code/name/monkey/retromusic/util/ViewUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/ViewUtil.java index f4400c85..fcc3c8c9 100644 --- a/app/src/main/java/code/name/monkey/retromusic/util/ViewUtil.java +++ b/app/src/main/java/code/name/monkey/retromusic/util/ViewUtil.java @@ -10,8 +10,10 @@ import android.view.ViewGroup; import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView; +import code.name.monkey.appthemehelper.util.ATHUtil; import code.name.monkey.appthemehelper.util.ColorUtil; import code.name.monkey.appthemehelper.util.MaterialValueHelper; +import code.name.monkey.retromusic.R; public class ViewUtil { diff --git a/app/src/main/java/code/name/monkey/retromusic/views/FitSystemWindowsLayout.java b/app/src/main/java/code/name/monkey/retromusic/views/FitSystemWindowsLayout.java new file mode 100644 index 00000000..06c9d7e3 --- /dev/null +++ b/app/src/main/java/code/name/monkey/retromusic/views/FitSystemWindowsLayout.java @@ -0,0 +1,77 @@ +package code.name.monkey.retromusic.views; + +import android.annotation.TargetApi; +import android.content.Context; +import android.graphics.Rect; +import android.os.Build; +import android.util.AttributeSet; +import android.view.WindowInsets; +import android.widget.FrameLayout; + +public class FitSystemWindowsLayout extends FrameLayout { + private boolean mFit = false; + + public FitSystemWindowsLayout(final Context context) { + super(context); + } + + public FitSystemWindowsLayout(final Context context, final AttributeSet attrs) { + super(context, attrs); + } + + public FitSystemWindowsLayout(final Context context, final AttributeSet attrs, final int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + public boolean isFit() { + return mFit; + } + + public void setFit(final boolean fit) { + if (mFit == fit) { + return; + } + + mFit = fit; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { + requestApplyInsets(); + } else { + //noinspection deprecation + requestFitSystemWindows(); + } + } + + @SuppressWarnings("deprecation") + @Override + protected boolean fitSystemWindows(final Rect insets) { + if (mFit) { + setPadding( + insets.left, + insets.top, + insets.right, + insets.bottom + ); + return true; + } else { + setPadding(0, 0, 0, 0); + return false; + } + } + + @TargetApi(Build.VERSION_CODES.KITKAT_WATCH) + @Override + public WindowInsets onApplyWindowInsets(final WindowInsets insets) { + if (mFit) { + setPadding( + insets.getSystemWindowInsetLeft(), + insets.getSystemWindowInsetTop(), + insets.getSystemWindowInsetRight(), + insets.getSystemWindowInsetBottom() + ); + return insets.consumeSystemWindowInsets(); + } else { + setPadding(0, 0, 0, 0); + return insets; + } + } +} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/views/RoundedBottomSheetDialogFragment.java b/app/src/main/java/code/name/monkey/retromusic/views/RoundedBottomSheetDialogFragment.java index 96b1a138..aa14d979 100644 --- a/app/src/main/java/code/name/monkey/retromusic/views/RoundedBottomSheetDialogFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/views/RoundedBottomSheetDialogFragment.java @@ -2,10 +2,11 @@ package code.name.monkey.retromusic.views; import android.annotation.SuppressLint; import android.app.Dialog; -import android.os.Build; +import android.content.res.ColorStateList; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; import android.os.Bundle; import android.view.View; -import android.view.ViewTreeObserver; import android.view.Window; import android.widget.FrameLayout; @@ -13,13 +14,14 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior; import com.google.android.material.bottomsheet.BottomSheetDialog; import com.google.android.material.bottomsheet.BottomSheetDialogFragment; +import java.util.Objects; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.core.content.ContextCompat; import code.name.monkey.appthemehelper.ThemeStore; -import code.name.monkey.appthemehelper.util.ATHUtil; -import code.name.monkey.appthemehelper.util.ColorUtil; import code.name.monkey.retromusic.R; -import code.name.monkey.retromusic.util.PreferenceUtil; +import code.name.monkey.retromusic.ui.activities.base.AbsBaseActivity; /** * Created by yu on 2016/11/10. @@ -27,12 +29,12 @@ import code.name.monkey.retromusic.util.PreferenceUtil; @SuppressLint("RestrictedApi") public class RoundedBottomSheetDialogFragment extends BottomSheetDialogFragment { - @Override + /* @Override public int getTheme() { //noinspection ConstantConditions - if (PreferenceUtil.getInstance(getContext()).getGeneralTheme() == R.style.Theme_RetroMusic_Light) { + if (PreferenceUtil.getInstance().getGeneralTheme() == R.style.Theme_RetroMusic_Light) { return R.style.BottomSheetDialogTheme; - } else if (PreferenceUtil.getInstance(getContext()).getGeneralTheme() == R.style.Theme_RetroMusic_Color) { + } else if (PreferenceUtil.getInstance().getGeneralTheme() == R.style.Theme_RetroMusic_Color) { int color = ThemeStore.primaryColor(getContext()); if (ColorUtil.isColorLight(color)) { return R.style.BottomSheetDialogTheme; @@ -42,40 +44,40 @@ public class RoundedBottomSheetDialogFragment extends BottomSheetDialogFragment } else { return R.style.BottomSheetDialogTheme; } - } + }*/ @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - BottomSheetDialog dialog = (BottomSheetDialog) getDialog(); - FrameLayout bottomSheet = (FrameLayout) dialog.findViewById(R.id.design_bottom_sheet); + view.getViewTreeObserver().addOnGlobalLayoutListener(() -> { + BottomSheetDialog dialog = (BottomSheetDialog) getDialog(); + FrameLayout bottomSheet = dialog.findViewById(R.id.design_bottom_sheet); + + if (bottomSheet != null) { BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomSheet); behavior.setState(BottomSheetBehavior.STATE_EXPANDED); - //behavior.setPeekHeight(0); } }); + view.setBackground(ContextCompat.getDrawable(view.getContext(), R.drawable.bg_bottom_sheet_dialog_fragment)); + view.setBackgroundTintList(ColorStateList.valueOf(ThemeStore.primaryColor(view.getContext()))); + ((AbsBaseActivity) Objects.requireNonNull(getActivity())).setNavigationbarColorAuto(); } @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { //noinspection ConstantConditions - return new BottomSheetDialog(getContext(), getTheme()); + return new BottomSheetDialog(getContext()); } @Override public void onStart() { super.onStart(); - if (getDialog() != null && getDialog().getWindow() != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + if (getDialog() != null && getDialog().getWindow() != null) { Window window = getDialog().getWindow(); - window.findViewById(com.google.android.material.R.id.container).setFitsSystemWindows(false); - // dark navigation bar icons - View decorView = window.getDecorView(); - if (!ATHUtil.isWindowBackgroundDark(getContext())) - decorView.setSystemUiVisibility(decorView.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + window.setNavigationBarColor(ThemeStore.primaryColor(getContext())); + window.findViewById(com.google.android.material.R.id.container).setFitsSystemWindows(true); } } } \ No newline at end of file diff --git a/app/src/main/res/anim/slide_in_left.xml b/app/src/main/res/anim/slide_in_left.xml deleted file mode 100644 index 5b01fc74..00000000 --- a/app/src/main/res/anim/slide_in_left.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable-hdpi/default_album_art.webp b/app/src/main/res/drawable-hdpi/default_album_art.webp index e613740a..31557bc7 100644 Binary files a/app/src/main/res/drawable-hdpi/default_album_art.webp and b/app/src/main/res/drawable-hdpi/default_album_art.webp differ diff --git a/app/src/main/res/drawable-hdpi/default_artist_art.webp b/app/src/main/res/drawable-hdpi/default_artist_art.webp index 80da81cb..7b63339e 100644 Binary files a/app/src/main/res/drawable-hdpi/default_artist_art.webp and b/app/src/main/res/drawable-hdpi/default_artist_art.webp differ diff --git a/app/src/main/res/drawable-hdpi/ic_notification.png b/app/src/main/res/drawable-hdpi/ic_notification.png old mode 100644 new mode 100755 diff --git a/app/src/main/res/drawable-mdpi/default_album_art.webp b/app/src/main/res/drawable-mdpi/default_album_art.webp index ce3c5b38..e0faff68 100644 Binary files a/app/src/main/res/drawable-mdpi/default_album_art.webp and b/app/src/main/res/drawable-mdpi/default_album_art.webp differ diff --git a/app/src/main/res/drawable-mdpi/default_artist_art.webp b/app/src/main/res/drawable-mdpi/default_artist_art.webp index f51df8bb..1af6b65c 100644 Binary files a/app/src/main/res/drawable-mdpi/default_artist_art.webp and b/app/src/main/res/drawable-mdpi/default_artist_art.webp differ diff --git a/app/src/main/res/drawable-mdpi/ic_notification.png b/app/src/main/res/drawable-mdpi/ic_notification.png old mode 100644 new mode 100755 diff --git a/app/src/main/res/drawable-xhdpi/default_album_art.webp b/app/src/main/res/drawable-xhdpi/default_album_art.webp index d2c2aab3..3e65bf37 100644 Binary files a/app/src/main/res/drawable-xhdpi/default_album_art.webp and b/app/src/main/res/drawable-xhdpi/default_album_art.webp differ diff --git a/app/src/main/res/drawable-xhdpi/default_artist_art.webp b/app/src/main/res/drawable-xhdpi/default_artist_art.webp index 3d4cd642..5057fbaf 100644 Binary files a/app/src/main/res/drawable-xhdpi/default_artist_art.webp and b/app/src/main/res/drawable-xhdpi/default_artist_art.webp differ diff --git a/app/src/main/res/drawable-xhdpi/ic_notification.png b/app/src/main/res/drawable-xhdpi/ic_notification.png old mode 100644 new mode 100755 diff --git a/app/src/main/res/drawable-xxhdpi/default_album_art.webp b/app/src/main/res/drawable-xxhdpi/default_album_art.webp index 059faa03..b9e49f47 100644 Binary files a/app/src/main/res/drawable-xxhdpi/default_album_art.webp and b/app/src/main/res/drawable-xxhdpi/default_album_art.webp differ diff --git a/app/src/main/res/drawable-xxhdpi/default_artist_art.webp b/app/src/main/res/drawable-xxhdpi/default_artist_art.webp index cbdfae6d..eee9b249 100644 Binary files a/app/src/main/res/drawable-xxhdpi/default_artist_art.webp and b/app/src/main/res/drawable-xxhdpi/default_artist_art.webp differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_notification.png b/app/src/main/res/drawable-xxhdpi/ic_notification.png old mode 100644 new mode 100755 diff --git a/app/src/main/res/drawable-xxxhdpi/default_album_art.webp b/app/src/main/res/drawable-xxxhdpi/default_album_art.webp index df892f92..5281065f 100644 Binary files a/app/src/main/res/drawable-xxxhdpi/default_album_art.webp and b/app/src/main/res/drawable-xxxhdpi/default_album_art.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/default_artist_art.webp b/app/src/main/res/drawable-xxxhdpi/default_artist_art.webp index 2eab1f63..4f74e964 100644 Binary files a/app/src/main/res/drawable-xxxhdpi/default_artist_art.webp and b/app/src/main/res/drawable-xxxhdpi/default_artist_art.webp differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_notification.png b/app/src/main/res/drawable-xxxhdpi/ic_notification.png new file mode 100755 index 00000000..1878124f Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_notification.png differ diff --git a/app/src/main/res/drawable/bg_bottom_sheet_dialog_fragment.xml b/app/src/main/res/drawable/bg_bottom_sheet_dialog_fragment.xml index e460a9b6..bf699428 100644 --- a/app/src/main/res/drawable/bg_bottom_sheet_dialog_fragment.xml +++ b/app/src/main/res/drawable/bg_bottom_sheet_dialog_fragment.xml @@ -1,9 +1,8 @@ + - - \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_access_time_white_24dp.xml b/app/src/main/res/drawable/ic_access_time_white_24dp.xml index 5562133e..cdb5063a 100644 --- a/app/src/main/res/drawable/ic_access_time_white_24dp.xml +++ b/app/src/main/res/drawable/ic_access_time_white_24dp.xml @@ -2,8 +2,8 @@ + android:viewportWidth="24" + android:viewportHeight="24"> + android:viewportWidth="24" + android:viewportHeight="24"> - + android:pathData="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 14.5c-2.49 0-4.5-2.01-4.5-4.5S9.51 7.5 12 7.5s4.5 2.01 4.5 4.5-2.01 4.5-4.5 4.5zm0-5.5c-0.55 0-1 0.45-1 1s0.45 1 1 1 1-0.45 1-1-0.45-1-1-1z" /> \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_albums_white_24dp.xml b/app/src/main/res/drawable/ic_albums_white_24dp.xml new file mode 100644 index 00000000..f60d32d7 --- /dev/null +++ b/app/src/main/res/drawable/ic_albums_white_24dp.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_app_shortcut_last_added.xml b/app/src/main/res/drawable/ic_app_shortcut_last_added.xml index b80363f4..1c286449 100644 --- a/app/src/main/res/drawable/ic_app_shortcut_last_added.xml +++ b/app/src/main/res/drawable/ic_app_shortcut_last_added.xml @@ -2,8 +2,8 @@ + android:viewportWidth="176" + android:viewportHeight="176"> - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_artist_white_24dp.xml b/app/src/main/res/drawable/ic_artist_white_24dp.xml index 87433a4b..ca9417a7 100644 --- a/app/src/main/res/drawable/ic_artist_white_24dp.xml +++ b/app/src/main/res/drawable/ic_artist_white_24dp.xml @@ -1,9 +1,14 @@ + + android:viewportWidth="24" + android:viewportHeight="24"> + + android:pathData="M 10 4 C 7.79 4 6 5.79 6 8 C 6 10.21 7.79 12 10 12 C 12.21 12 14 10.21 14 8 C 14 5.79 12.21 4 10 4 z M 10 14 C 7.33 14 2 15.34 2 18 L 2 19 C 2 19.55 2.45 20 3 20 L 12.007812 20 A 5 5 0 0 1 11 17 A 5 5 0 0 1 11.867188 14.1875 C 11.186145 14.077427 10.532166 14 10 14 z" /> + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_audiotrack_black_24dp.xml b/app/src/main/res/drawable/ic_audiotrack_black_24dp.xml index 54dbfa78..e8bf1b5f 100644 --- a/app/src/main/res/drawable/ic_audiotrack_black_24dp.xml +++ b/app/src/main/res/drawable/ic_audiotrack_black_24dp.xml @@ -2,11 +2,9 @@ - - + android:viewportWidth="24" + android:viewportHeight="24"> + android:pathData="M12 5v8.55c-0.94-0.54-2.1-0.75-3.33-0.32-1.34 0.48 -2.37 1.67-2.61 3.07-0.46 2.74 1.86 5.08 4.59 4.65 1.96-0.31 3.35-2.11 3.35-4.1V7h2c1.1 0 2-0.9 2-2s-0.9-2-2-2h-2c-1.1 0-2 0.9-2 2z" /> \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_bug_report_white_24dp.xml b/app/src/main/res/drawable/ic_bug_report_white_24dp.xml index d2c0c38c..089ff0f3 100644 --- a/app/src/main/res/drawable/ic_bug_report_white_24dp.xml +++ b/app/src/main/res/drawable/ic_bug_report_white_24dp.xml @@ -1,9 +1,11 @@ + + android:viewportWidth="24" + android:viewportHeight="24"> + - + android:pathData="M19 8h-1.81c-0.45-0.78-1.07-1.45-1.82-1.96l0.93-0.93c0.39-0.39 0.39 -1.02 0-1.41-0.39-0.39-1.02-0.39-1.41 0l-1.47 1.47C12.96 5.06 12.49 5 12 5s-0.96 0.06 -1.41 0.17 L9.11 3.7c-0.39-0.39-1.02-0.39-1.41 0-0.39 0.39 -0.39 1.02 0 1.41l0.92 0.93 C7.88 6.55 7.26 7.22 6.81 8H5c-0.55 0-1 0.45-1 1s0.45 1 1 1h1.09c-0.05 0.33 -0.09 0.66 -0.09 1v1H5c-0.55 0-1 0.45-1 1s0.45 1 1 1h1v1c0 0.34 0.04 0.67 0.09 1H5c-0.55 0-1 0.45-1 1s0.45 1 1 1h1.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H19c0.55 0 1-0.45 1-1s-0.45-1-1-1h-1.09c0.05-0.33 0.09 -0.66 0.09 -1v-1h1c0.55 0 1-0.45 1-1s-0.45-1-1-1h-1v-1c0-0.34-0.04-0.67-0.09-1H19c0.55 0 1-0.45 1-1s-0.45-1-1-1zm-6 8h-2c-0.55 0-1-0.45-1-1s0.45-1 1-1h2c0.55 0 1 0.45 1 1s-0.45 1-1 1zm0-4h-2c-0.55 0-1-0.45-1-1s0.45-1 1-1h2c0.55 0 1 0.45 1 1s-0.45 1-1 1z" /> + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_card_giftcard_white_24dp.xml b/app/src/main/res/drawable/ic_card_giftcard_white_24dp.xml index 2d7e2a83..cd000632 100644 --- a/app/src/main/res/drawable/ic_card_giftcard_white_24dp.xml +++ b/app/src/main/res/drawable/ic_card_giftcard_white_24dp.xml @@ -1,9 +1,11 @@ + + android:viewportWidth="24" + android:viewportHeight="24"> + - + android:pathData="M20 6h-2.18c0.11-0.31 0.18 -0.65 0.18 -1 0-1.66-1.34-3-3-3-1.05 0-1.96 0.54 -2.5 1.35l-0.5 0.67 -0.5-0.68C10.96 2.54 10.05 2 9 2 7.34 2 6 3.34 6 5c0 0.35 0.07 0.69 0.18 1H4c-1.11 0-1.99 0.89 -1.99 2L2 19c0 1.11 0.89 2 2 2h16c1.11 0 2-0.89 2-2V8c0-1.11-0.89-2-2-2zm-5-2c0.55 0 1 0.45 1 1s-0.45 1-1 1-1-0.45-1-1 0.45-1 1-1zM9 4c0.55 0 1 0.45 1 1s-0.45 1-1 1-1-0.45-1-1 0.45-1 1-1zm11 15H4v-2h16v2zm0-5H4V9c0-0.55 0.45 -1 1-1h4.08L7.6 10.02c-0.33 0.45 -0.23 1.08 0.22 1.4 0.44 0.32 1.07 0.22 1.39-0.22L12 7.4l2.79 3.8c0.32 0.44 0.95 0.54 1.39 0.22 0.45-0.32 0.55 -0.95 0.22 -1.4L14.92 8H19c0.55 0 1 0.45 1 1v5z" /> + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_delete_white_24dp.xml b/app/src/main/res/drawable/ic_delete_white_24dp.xml index 3a2050bf..fe21e632 100644 --- a/app/src/main/res/drawable/ic_delete_white_24dp.xml +++ b/app/src/main/res/drawable/ic_delete_white_24dp.xml @@ -1,9 +1,11 @@ + + android:viewportWidth="24" + android:viewportHeight="24"> + - + android:pathData="M6 19c0 1.1 0.9 2 2 2h8c1.1 0 2-0.9 2-2V9c0-1.1-0.9-2-2-2H8c-1.1 0-2 0.9-2 2v10zM18 4h-2.5l-0.71-0.71c-0.18-0.18-0.44-0.29-0.7-0.29H9.91c-0.26 0-0.52 0.11 -0.7 0.29 L8.5 4H6c-0.55 0-1 0.45-1 1s0.45 1 1 1h12c0.55 0 1-0.45 1-1s-0.45-1-1-1z" /> + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_edit_white_24dp.xml b/app/src/main/res/drawable/ic_edit_white_24dp.xml index 7a19f313..b60897ee 100644 --- a/app/src/main/res/drawable/ic_edit_white_24dp.xml +++ b/app/src/main/res/drawable/ic_edit_white_24dp.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/app/src/main/res/drawable/ic_flag_white_24dp.xml b/app/src/main/res/drawable/ic_flag_white_24dp.xml index a5658d37..245bc0f4 100644 --- a/app/src/main/res/drawable/ic_flag_white_24dp.xml +++ b/app/src/main/res/drawable/ic_flag_white_24dp.xml @@ -1,9 +1,12 @@ + - - + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_folder_white_24dp.xml b/app/src/main/res/drawable/ic_folder_white_24dp.xml index 13fb2774..f9590fd9 100644 --- a/app/src/main/res/drawable/ic_folder_white_24dp.xml +++ b/app/src/main/res/drawable/ic_folder_white_24dp.xml @@ -1,9 +1,11 @@ + - - + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_home_white_24dp.xml b/app/src/main/res/drawable/ic_home_white_24dp.xml index 1d64d019..1091e7a0 100644 --- a/app/src/main/res/drawable/ic_home_white_24dp.xml +++ b/app/src/main/res/drawable/ic_home_white_24dp.xml @@ -1,9 +1,11 @@ + - - + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_image_white_24dp.xml b/app/src/main/res/drawable/ic_image_white_24dp.xml index e7895e8b..85e5b4d1 100644 --- a/app/src/main/res/drawable/ic_image_white_24dp.xml +++ b/app/src/main/res/drawable/ic_image_white_24dp.xml @@ -1,9 +1,11 @@ + - - + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_instagram.xml b/app/src/main/res/drawable/ic_instagram.xml index 9256b833..d0d4b2c3 100644 --- a/app/src/main/res/drawable/ic_instagram.xml +++ b/app/src/main/res/drawable/ic_instagram.xml @@ -1,8 +1,10 @@ - + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_keyboard_backspace_black_24dp.xml b/app/src/main/res/drawable/ic_keyboard_backspace_black_24dp.xml index f71b9298..60e7cafb 100644 --- a/app/src/main/res/drawable/ic_keyboard_backspace_black_24dp.xml +++ b/app/src/main/res/drawable/ic_keyboard_backspace_black_24dp.xml @@ -7,6 +7,6 @@ \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_library_add_white_24dp.xml b/app/src/main/res/drawable/ic_library_add_white_24dp.xml index d1a6c780..b3313a88 100644 --- a/app/src/main/res/drawable/ic_library_add_white_24dp.xml +++ b/app/src/main/res/drawable/ic_library_add_white_24dp.xml @@ -1,9 +1,11 @@ + - - + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_library_music_white_24dp.xml b/app/src/main/res/drawable/ic_library_music_white_24dp.xml index d166ec3d..355309b2 100644 --- a/app/src/main/res/drawable/ic_library_music_white_24dp.xml +++ b/app/src/main/res/drawable/ic_library_music_white_24dp.xml @@ -1,9 +1,12 @@ + - - + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_pause_white_24dp.xml b/app/src/main/res/drawable/ic_pause_white_24dp.xml index bc3d2e0c..f1286d80 100644 --- a/app/src/main/res/drawable/ic_pause_white_24dp.xml +++ b/app/src/main/res/drawable/ic_pause_white_24dp.xml @@ -2,11 +2,10 @@ + android:viewportWidth="24" + android:viewportHeight="24"> - + android:pathData="M8 19c1.1 0 2-0.9 2-2V7c0-1.1-0.9-2-2-2s-2 0.9-2 2v10c0 1.1 0.9 2 2 2zm6-12v10c0 1.1 0.9 2 2 2s2-0.9 2-2V7c0-1.1-0.9-2-2-2s-2 0.9-2 2z" /> \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_pause_white_big.xml b/app/src/main/res/drawable/ic_pause_white_big.xml index e3892586..17522ff1 100644 --- a/app/src/main/res/drawable/ic_pause_white_big.xml +++ b/app/src/main/res/drawable/ic_pause_white_big.xml @@ -2,11 +2,10 @@ - - + android:viewportWidth="24" + android:viewportHeight="24"> + android:pathData="M8 19c1.1 0 2-0.9 2-2V7c0-1.1-0.9-2-2-2s-2 0.9-2 2v10c0 1.1 0.9 2 2 2zm6-12v10c0 1.1 0.9 2 2 2s2-0.9 2-2V7c0-1.1-0.9-2-2-2s-2 0.9-2 2z" /> + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_play_arrow_white_24dp.xml b/app/src/main/res/drawable/ic_play_arrow_white_24dp.xml index 3a75768e..fb3b758d 100644 --- a/app/src/main/res/drawable/ic_play_arrow_white_24dp.xml +++ b/app/src/main/res/drawable/ic_play_arrow_white_24dp.xml @@ -2,11 +2,10 @@ + android:viewportWidth="24" + android:viewportHeight="24"> - + android:pathData="M8 6.82v10.36c0 0.79 0.87 1.27 1.54 0.84 l8.14-5.18c0.62-0.39 0.62 -1.29 0-1.69L9.54 5.98C8.87 5.55 8 6.03 8 6.82z" /> \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_play_arrow_white_big.xml b/app/src/main/res/drawable/ic_play_arrow_white_big.xml index 34f71d45..22124ee1 100644 --- a/app/src/main/res/drawable/ic_play_arrow_white_big.xml +++ b/app/src/main/res/drawable/ic_play_arrow_white_big.xml @@ -2,11 +2,9 @@ - - + android:viewportWidth="24" + android:viewportHeight="24"> + android:pathData="M8 6.82v10.36c0 0.79 0.87 1.27 1.54 0.84 l8.14-5.18c0.62-0.39 0.62 -1.29 0-1.69L9.54 5.98C8.87 5.55 8 6.03 8 6.82z" /> \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_play_circle_filled_white_24dp.xml b/app/src/main/res/drawable/ic_play_circle_filled_white_24dp.xml index 4dcc3f3d..d353caac 100644 --- a/app/src/main/res/drawable/ic_play_circle_filled_white_24dp.xml +++ b/app/src/main/res/drawable/ic_play_circle_filled_white_24dp.xml @@ -1,9 +1,11 @@ + - - + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_playlist_add_white_24dp.xml b/app/src/main/res/drawable/ic_playlist_add_white_24dp.xml index 2c9a92a8..3134b131 100644 --- a/app/src/main/res/drawable/ic_playlist_add_white_24dp.xml +++ b/app/src/main/res/drawable/ic_playlist_add_white_24dp.xml @@ -2,11 +2,10 @@ + android:viewportWidth="24" + android:viewportHeight="24"> - + android:pathData="M13 10H3c-0.55 0-1 0.45-1 1s0.45 1 1 1h10c0.55 0 1-0.45 1-1s-0.45-1-1-1zm0-4H3c-0.55 0-1 0.45-1 1s0.45 1 1 1h10c0.55 0 1-0.45 1-1s-0.45-1-1-1zm5 8v-3c0-0.55-0.45-1-1-1s-1 0.45-1 1v3h-3c-0.55 0-1 0.45-1 1s0.45 1 1 1h3v3c0 0.55 0.45 1 1 1s1-0.45 1-1v-3h3c0.55 0 1-0.45 1-1s-0.45-1-1-1h-3zM3 16h6c0.55 0 1-0.45 1-1s-0.45-1-1-1H3c-0.55 0-1 0.45-1 1s0.45 1 1 1z" /> \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_playlist_play_white_24dp.xml b/app/src/main/res/drawable/ic_playlist_play_white_24dp.xml index 47a35405..ab10bd46 100644 --- a/app/src/main/res/drawable/ic_playlist_play_white_24dp.xml +++ b/app/src/main/res/drawable/ic_playlist_play_white_24dp.xml @@ -2,20 +2,10 @@ + android:viewportWidth="24" + android:viewportHeight="24"> - - - - + android:pathData="M5 10h10c0.55 0 1 0.45 1 1s-0.45 1-1 1H5c-0.55 0-1-0.45-1-1s0.45-1 1-1zm0-4h10c0.55 0 1 0.45 1 1s-0.45 1-1 1H5c-0.55 0-1-0.45-1-1s0.45-1 1-1zm0 8h6c0.55 0 1 0.45 1 1s-0.45 1-1 1H5c-0.55 0-1-0.45-1-1s0.45-1 1-1zm9 0.88v4.23c0 0.39 0.42 0.63 0.76 0.43l3.53-2.12c0.32-0.19 0.32 -0.66 0-0.86l-3.53-2.12c-0.34-0.19-0.76 0.05 -0.76 0.44 z" /> \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_queue_music_white_24dp.xml b/app/src/main/res/drawable/ic_queue_music_white_24dp.xml index 84323beb..51346ea3 100644 --- a/app/src/main/res/drawable/ic_queue_music_white_24dp.xml +++ b/app/src/main/res/drawable/ic_queue_music_white_24dp.xml @@ -1,9 +1,12 @@ + + - + android:pathData="M14 6H4c-0.55 0-1 0.45-1 1s0.45 1 1 1h10c0.55 0 1-0.45 1-1s-0.45-1-1-1zm0 4H4c-0.55 0-1 0.45-1 1s0.45 1 1 1h10c0.55 0 1-0.45 1-1s-0.45-1-1-1zM4 16h6c0.55 0 1-0.45 1-1s-0.45-1-1-1H4c-0.55 0-1 0.45-1 1s0.45 1 1 1zM19 6c-1.1 0-2 0.9-2 2v6.18c-0.31-0.11-0.65-0.18-1-0.18-1.84 0-3.28 1.64-2.95 3.54 0.21 1.21 1.2 2.2 2.41 2.41 1.9 0.33 3.54-1.11 3.54-2.95V8h2c0.55 0 1-0.45 1-1s-0.45-1-1-1h-2z" /> + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_recent_actors_white_24dp.xml b/app/src/main/res/drawable/ic_recent_actors_white_24dp.xml index 66d84251..c4ba7018 100644 --- a/app/src/main/res/drawable/ic_recent_actors_white_24dp.xml +++ b/app/src/main/res/drawable/ic_recent_actors_white_24dp.xml @@ -1,9 +1,11 @@ + + android:viewportWidth="24" + android:viewportHeight="24"> + - + android:pathData="M21 6v12c0 0.55 0.45 1 1 1s1-0.45 1-1V6c0-0.55-0.45-1-1-1s-1 0.45-1 1zm-3 13c0.55 0 1-0.45 1-1V6c0-0.55-0.45-1-1-1s-1 0.45-1 1v12c0 0.55 0.45 1 1 1zM14 5H2c-0.55 0-1 0.45-1 1v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V6c0-0.55-0.45-1-1-1zM8 7.75c1.24 0 2.25 1.01 2.25 2.25S9.24 12.25 8 12.25 5.75 11.24 5.75 10 6.76 7.75 8 7.75zM12.5 17h-9v-0.75c0-1.5 3-2.25 4.5-2.25s4.5 0.75 4.5 2.25V17z" /> + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_retro_music_note_burst_mode_white_24dp.xml b/app/src/main/res/drawable/ic_retro_music_note_burst_mode_white_24dp.xml new file mode 100644 index 00000000..ec16e95b --- /dev/null +++ b/app/src/main/res/drawable/ic_retro_music_note_burst_mode_white_24dp.xml @@ -0,0 +1,18 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_round_delete_white_24dp.xml b/app/src/main/res/drawable/ic_round_delete_white_24dp.xml deleted file mode 100644 index 07411721..00000000 --- a/app/src/main/res/drawable/ic_round_delete_white_24dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/layout-land/activity_album.xml b/app/src/main/res/layout-land/activity_album.xml index 58e6b6a9..ebe73cf3 100644 --- a/app/src/main/res/layout-land/activity_album.xml +++ b/app/src/main/res/layout-land/activity_album.xml @@ -53,7 +53,8 @@ android:layout_width="52dp" android:layout_height="52dp" android:layout_marginStart="8dp" - android:layout_weight="0" /> + android:layout_weight="0" + app:civ_border="false" /> - - @@ -92,49 +96,8 @@ - - - - - - - + - @@ -143,14 +106,20 @@ android:layout_height="72dp" android:background="@drawable/shadow_down_strong" /> - + android:text="@string/shuffle" + android:textAllCaps="false" + app:backgroundTint="@color/md_red_500" + app:cornerRadius="25dp" + app:icon="@drawable/ic_shuffle_white_24dp" + app:iconGravity="start" + app:iconPadding="12dp" + app:layout_dodgeInsetEdges="all" /> diff --git a/app/src/main/res/layout-land/activity_artist_details.xml b/app/src/main/res/layout-land/activity_artist_details.xml index ce4b9263..f7a50681 100644 --- a/app/src/main/res/layout-land/activity_artist_details.xml +++ b/app/src/main/res/layout-land/activity_artist_details.xml @@ -26,6 +26,21 @@ + + + android:orientation="vertical" + android:padding="16dp"> - + android:maxLines="2" + android:textAppearance="@style/TextAppearance.AppCompat.Title" + tools:ignore="MissingPrefix" + tools:text="Title" /> - - - - - - - + android:layout_gravity="center" + android:ellipsize="marquee" + android:focusable="true" + android:focusableInTouchMode="true" + android:freezesText="true" + android:marqueeRepeatLimit="marquee_forever" + android:scrollHorizontally="true" + android:singleLine="true" + android:textAppearance="@style/TextAppearance.AppCompat.Subhead" + tools:ignore="MissingPrefix" + tools:text="Title" /> + - - - - - - - - - - + diff --git a/app/src/main/res/layout-land/fragment_banner_home.xml b/app/src/main/res/layout-land/fragment_banner_home.xml index 1abe8b2c..1e5c9277 100644 --- a/app/src/main/res/layout-land/fragment_banner_home.xml +++ b/app/src/main/res/layout-land/fragment_banner_home.xml @@ -1,76 +1,105 @@ - + android:layout_height="match_parent"> - - - - - - - + android:orientation="horizontal"> + app:layout_scrollFlags="scroll|exitUntilCollapsed" + app:statusBarScrim="?attr/colorPrimary"> - + - + - - + + + + + + + + + + + + + + + + + + + + + + + - - \ No newline at end of file + + diff --git a/app/src/main/res/layout-land/fragment_blur.xml b/app/src/main/res/layout-land/fragment_blur.xml index f88af17b..44cc2d43 100644 --- a/app/src/main/res/layout-land/fragment_blur.xml +++ b/app/src/main/res/layout-land/fragment_blur.xml @@ -11,8 +11,7 @@ android:id="@+id/gradient_background" android:layout_width="match_parent" android:layout_height="match_parent" - android:scaleType="centerCrop" - /> + android:scaleType="centerCrop" /> - - - - - - + android:layout_height="match_parent"> - + + \ No newline at end of file diff --git a/app/src/main/res/layout-land/fragment_card_blur_player.xml b/app/src/main/res/layout-land/fragment_card_blur_player.xml index 770a0cd7..4212ab17 100644 --- a/app/src/main/res/layout-land/fragment_card_blur_player.xml +++ b/app/src/main/res/layout-land/fragment_card_blur_player.xml @@ -21,97 +21,66 @@ - - + android:layout_height="match_parent"> - + android:layout_height="match_parent" + android:orientation="vertical"> - - + + + + + + + + + + + - - - - - - - - - - - - - - - + android:layout_marginEnd="196dp"> + android:layout_height="match_parent" + tools:layout="@layout/fragment_card_blur_player_playback_controls" /> - - - - - - - - + \ No newline at end of file diff --git a/app/src/main/res/layout-land/fragment_card_player.xml b/app/src/main/res/layout-land/fragment_card_player.xml index 4d0706d1..eb6af438 100644 --- a/app/src/main/res/layout-land/fragment_card_player.xml +++ b/app/src/main/res/layout-land/fragment_card_player.xml @@ -20,61 +20,61 @@ android:layout_height="match_parent" tools:layout="@layout/fragment_album_cover" /> - + android:layout_height="match_parent"> - - - - - - - - - - - - + android:orientation="vertical"> - + android:layout_height="wrap_content" + android:layout_weight="0"> - + - - + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-land/fragment_color_player.xml b/app/src/main/res/layout-land/fragment_color_player.xml index 67f346c8..66a54e8c 100644 --- a/app/src/main/res/layout-land/fragment_color_player.xml +++ b/app/src/main/res/layout-land/fragment_color_player.xml @@ -14,17 +14,10 @@ - - - - - - + android:layout_height="match_parent"> - + + \ No newline at end of file diff --git a/app/src/main/res/layout-land/fragment_flat_player.xml b/app/src/main/res/layout-land/fragment_flat_player.xml index 4a309d0b..11d37656 100644 --- a/app/src/main/res/layout-land/fragment_flat_player.xml +++ b/app/src/main/res/layout-land/fragment_flat_player.xml @@ -15,17 +15,10 @@ - - - - - - + android:layout_height="match_parent"> - + \ No newline at end of file diff --git a/app/src/main/res/layout-land/fragment_home.xml b/app/src/main/res/layout-land/fragment_home.xml index 8d9dd9bd..637cb1fc 100644 --- a/app/src/main/res/layout-land/fragment_home.xml +++ b/app/src/main/res/layout-land/fragment_home.xml @@ -1,103 +1,90 @@ - + android:layout_height="match_parent" + android:orientation="vertical"> - - + + + + + + + android:layout_weight="0" + android:elevation="0dp" + app:elevation="0dp" + tools:ignore="UnusedAttribute"> - + app:layout_scrollFlags="scroll|enterAlways" + app:titleEnabled="false"> - - - - - - - - - + + style="@style/BigTitleTextAppearance" + android:text="@string/app_name" /> - - - - + + + - - - + android:layout_marginStart="@dimen/horizontal_margin" + android:layout_marginEnd="@dimen/horizontal_margin" + android:layout_weight="1" + android:background="@drawable/bg_circular_top_corners" + android:elevation="@dimen/card_elevation" + app:behavior_overlapTop="24dp" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> + + + + + + + + + + - - - - - diff --git a/app/src/main/res/layout-land/fragment_material.xml b/app/src/main/res/layout-land/fragment_material.xml index 24b06479..94257bbb 100644 --- a/app/src/main/res/layout-land/fragment_material.xml +++ b/app/src/main/res/layout-land/fragment_material.xml @@ -9,17 +9,10 @@ - - - - - - + android:layout_height="match_parent"> + android:layout_height="match_parent" + android:orientation="vertical"> - + diff --git a/app/src/main/res/layout-land/fragment_plain_player.xml b/app/src/main/res/layout-land/fragment_plain_player.xml index 01d40e1a..fb1a0482 100644 --- a/app/src/main/res/layout-land/fragment_plain_player.xml +++ b/app/src/main/res/layout-land/fragment_plain_player.xml @@ -9,17 +9,11 @@ - - - - - - + android:layout_height="match_parent"> - + \ No newline at end of file diff --git a/app/src/main/res/layout-land/fragment_player.xml b/app/src/main/res/layout-land/fragment_player.xml index 5b1bd00a..4b3025df 100755 --- a/app/src/main/res/layout-land/fragment_player.xml +++ b/app/src/main/res/layout-land/fragment_player.xml @@ -14,17 +14,10 @@ - - - - - - + android:layout_height="match_parent"> - + \ No newline at end of file diff --git a/app/src/main/res/layout-land/fragment_simple_player.xml b/app/src/main/res/layout-land/fragment_simple_player.xml index be4bc75d..da4ec270 100644 --- a/app/src/main/res/layout-land/fragment_simple_player.xml +++ b/app/src/main/res/layout-land/fragment_simple_player.xml @@ -16,17 +16,10 @@ - - - - - - + android:layout_height="match_parent"> - + \ No newline at end of file diff --git a/app/src/main/res/layout-land/pager_item.xml b/app/src/main/res/layout-land/pager_item.xml index b2e07304..fb6f6a5b 100644 --- a/app/src/main/res/layout-land/pager_item.xml +++ b/app/src/main/res/layout-land/pager_item.xml @@ -7,7 +7,7 @@ android:layout_height="wrap_content" android:orientation="vertical"> - - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-sw600dp/pager_item.xml b/app/src/main/res/layout-sw600dp/pager_item.xml index c798fd10..fc99b93b 100644 --- a/app/src/main/res/layout-sw600dp/pager_item.xml +++ b/app/src/main/res/layout-sw600dp/pager_item.xml @@ -7,7 +7,7 @@ android:layout_height="wrap_content" android:orientation="vertical"> - - + @@ -64,9 +64,9 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" - android:paddingEnd="28dp" android:paddingStart="28dp" - android:paddingTop="16dp"> + android:paddingTop="16dp" + android:paddingEnd="28dp"> - - @@ -118,61 +121,26 @@ - - - - - - - + - + android:text="@string/shuffle" + android:textAllCaps="false" + app:backgroundTint="@color/md_red_500" + app:cornerRadius="25dp" + app:icon="@drawable/ic_shuffle_white_24dp" + app:iconGravity="start" + app:iconPadding="12dp" + app:layout_dodgeInsetEdges="all" /> + + app:layout_behavior="@string/appbar_scrolling_view_behavior" + tools:background="@color/md_red_500"> + - + android:maxLines="2" + android:textAppearance="@style/TextAppearance.AppCompat.Title" + tools:ignore="MissingPrefix" + tools:text="Title" /> - - - - - - - + android:layout_gravity="center" + android:ellipsize="marquee" + android:focusable="true" + android:focusableInTouchMode="true" + android:freezesText="true" + android:marqueeRepeatLimit="marquee_forever" + android:scrollHorizontally="true" + android:singleLine="true" + android:textAppearance="@style/TextAppearance.AppCompat.Subhead" + tools:ignore="MissingPrefix" + tools:text="Title" /> + - - - - - - - - - - - + @@ -176,4 +101,18 @@ android:layout_height="72dp" android:background="@drawable/shadow_down_strong" /> + diff --git a/app/src/main/res/layout-xlarge-land/fragment_blur.xml b/app/src/main/res/layout-xlarge-land/fragment_blur.xml index 357afeaa..c23ccd2d 100644 --- a/app/src/main/res/layout-xlarge-land/fragment_blur.xml +++ b/app/src/main/res/layout-xlarge-land/fragment_blur.xml @@ -11,8 +11,7 @@ android:id="@+id/gradient_background" android:layout_width="match_parent" android:layout_height="match_parent" - android:scaleType="centerCrop" - /> + android:scaleType="centerCrop" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout-xlarge-land/fragment_player.xml b/app/src/main/res/layout-xlarge-land/fragment_player.xml index 8eb1c5f7..6bcf4013 100644 --- a/app/src/main/res/layout-xlarge-land/fragment_player.xml +++ b/app/src/main/res/layout-xlarge-land/fragment_player.xml @@ -14,56 +14,57 @@ - + android:layout_height="match_parent"> - - - - - - - - - - - + android:orientation="vertical"> - - + android:layout_gravity="center_horizontal" + android:layout_weight="1" + android:orientation="vertical"> - - + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-xlarge/activity_album.xml b/app/src/main/res/layout-xlarge/activity_album.xml index 9d817805..15cb3b01 100644 --- a/app/src/main/res/layout-xlarge/activity_album.xml +++ b/app/src/main/res/layout-xlarge/activity_album.xml @@ -89,16 +89,17 @@ android:paddingStart="16dp" android:paddingEnd="16dp"> - - - - - - - - + @@ -169,11 +130,20 @@ android:layout_height="72dp" android:background="@drawable/shadow_down_strong" /> - + android:text="@string/shuffle" + android:textAllCaps="false" + app:backgroundTint="@color/md_red_500" + app:cornerRadius="25dp" + app:icon="@drawable/ic_shuffle_white_24dp" + app:iconGravity="start" + app:iconPadding="12dp" + app:layout_dodgeInsetEdges="all" /> + \ No newline at end of file diff --git a/app/src/main/res/layout-xlarge/activity_artist_details.xml b/app/src/main/res/layout-xlarge/activity_artist_details.xml index 3d362b16..04b500de 100644 --- a/app/src/main/res/layout-xlarge/activity_artist_details.xml +++ b/app/src/main/res/layout-xlarge/activity_artist_details.xml @@ -42,8 +42,8 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="fill_vertical" - android:layout_marginEnd="96dp" android:layout_marginStart="96dp" + android:layout_marginEnd="96dp" android:fillViewport="true" android:overScrollMode="never" app:layout_behavior="@string/appbar_scrolling_view_behavior"> @@ -54,120 +54,46 @@ android:layout_height="match_parent" android:background="@drawable/bg_bottom_sheet_dialog_fragment" android:elevation="@dimen/card_elevation" - android:orientation="vertical"> + android:orientation="vertical" + tools:background="@color/md_red_500"> + + android:orientation="vertical" + android:padding="12dp"> - + android:maxLines="2" + android:textAppearance="@style/TextAppearance.AppCompat.Title" + tools:ignore="MissingPrefix" + tools:text="Title" /> - - - - - - - + android:layout_gravity="center" + android:ellipsize="marquee" + android:focusable="true" + android:focusableInTouchMode="true" + android:freezesText="true" + android:marqueeRepeatLimit="marquee_forever" + android:scrollHorizontally="true" + android:singleLine="true" + android:textAppearance="@style/TextAppearance.AppCompat.Subhead" + tools:ignore="MissingPrefix" + tools:text="Title" /> + - - - - - - - - - - + @@ -178,4 +104,18 @@ android:layout_height="72dp" android:background="@drawable/shadow_down_strong" /> + diff --git a/app/src/main/res/layout-xlarge/fragment_album_card_cover.xml b/app/src/main/res/layout-xlarge/fragment_album_card_cover.xml index 19eccd88..192194ff 100644 --- a/app/src/main/res/layout-xlarge/fragment_album_card_cover.xml +++ b/app/src/main/res/layout-xlarge/fragment_album_card_cover.xml @@ -1,32 +1,32 @@ - - + android:layout_height="match_parent"> - + - - + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-xlarge/fragment_blur.xml b/app/src/main/res/layout-xlarge/fragment_blur.xml index 31978e34..1b2a631d 100644 --- a/app/src/main/res/layout-xlarge/fragment_blur.xml +++ b/app/src/main/res/layout-xlarge/fragment_blur.xml @@ -1,88 +1,87 @@ - - + android:clickable="true" + android:focusable="true"> - - - - - - - - - - - - - - - - - - - - - - + android:scaleType="centerCrop" /> - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-xlarge/fragment_card_blur_player.xml b/app/src/main/res/layout-xlarge/fragment_card_blur_player.xml deleted file mode 100644 index bef72c37..00000000 --- a/app/src/main/res/layout-xlarge/fragment_card_blur_player.xml +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout-xlarge/fragment_player.xml b/app/src/main/res/layout-xlarge/fragment_player.xml index 66874ad5..3f556ce8 100644 --- a/app/src/main/res/layout-xlarge/fragment_player.xml +++ b/app/src/main/res/layout-xlarge/fragment_player.xml @@ -14,59 +14,58 @@ - + android:layout_height="match_parent"> - + android:layout_height="match_parent" + android:layout_gravity="center_horizontal" + android:gravity="center_horizontal" + android:orientation="vertical"> - - - + - + + + + + + + + - - - - - - - - - - - - + android:layout_weight="0"> + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/abs_playlists.xml b/app/src/main/res/layout/abs_playlists.xml index e3926d20..12e3ecc7 100644 --- a/app/src/main/res/layout/abs_playlists.xml +++ b/app/src/main/res/layout/abs_playlists.xml @@ -8,7 +8,9 @@ - diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index cb73e72f..df498cd7 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -1,7 +1,6 @@ @@ -16,20 +15,21 @@ + app:layout_collapseMode="pin" + app:navigationIcon="@drawable/ic_keyboard_backspace_black_24dp" + app:title="@null"> + style="@style/BigTitleTextAppearance" + android:text="@string/action_about" /> + + + android:transitionName="@string/transition_album_art" /> - + - - - - - + android:layout_height="72dp" /> - + android:text="@string/shuffle" + android:textAllCaps="false" + app:backgroundTint="@color/md_red_500" + app:cornerRadius="25dp" + app:icon="@drawable/ic_shuffle_white_24dp" + app:iconGravity="start" + app:iconPadding="12dp" + app:layout_dodgeInsetEdges="all" /> + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_album_content.xml b/app/src/main/res/layout/activity_album_content.xml new file mode 100644 index 00000000..744d40e4 --- /dev/null +++ b/app/src/main/res/layout/activity_album_content.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_album_small.xml b/app/src/main/res/layout/activity_album_small.xml new file mode 100644 index 00000000..19dcd3dc --- /dev/null +++ b/app/src/main/res/layout/activity_album_small.xml @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_album_style_2.xml b/app/src/main/res/layout/activity_album_style_2.xml index 113f2748..e5258762 100644 --- a/app/src/main/res/layout/activity_album_style_2.xml +++ b/app/src/main/res/layout/activity_album_style_2.xml @@ -79,7 +79,7 @@ - - + - - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_artist_details.xml b/app/src/main/res/layout/activity_artist_details.xml index e93b3154..c6cd7022 100755 --- a/app/src/main/res/layout/activity_artist_details.xml +++ b/app/src/main/res/layout/activity_artist_details.xml @@ -64,111 +64,56 @@ + android:orientation="vertical" + android:padding="16dp"> - + android:maxLines="2" + android:textAppearance="@style/TextAppearance.AppCompat.Title" + tools:ignore="MissingPrefix" + tools:text="Title" /> - - - - - - - - + android:ellipsize="marquee" + android:focusable="true" + android:focusableInTouchMode="true" + android:freezesText="true" + android:marqueeRepeatLimit="marquee_forever" + android:scrollHorizontally="true" + android:singleLine="true" + android:textAppearance="@style/TextAppearance.AppCompat.Subhead" + tools:ignore="MissingPrefix" + tools:text="Title" /> - + - - - - - - - - - - + android:layout_height="72dp" /> + + diff --git a/app/src/main/res/layout/activity_donation.xml b/app/src/main/res/layout/activity_donation.xml index 056077ea..216de1ed 100644 --- a/app/src/main/res/layout/activity_donation.xml +++ b/app/src/main/res/layout/activity_donation.xml @@ -65,10 +65,7 @@ android:layout_height="wrap_content" android:gravity="end|center_vertical" android:orientation="horizontal" - android:paddingLeft="@dimen/md_dialog_frame_margin" - android:paddingTop="@dimen/md_content_padding_top" - android:paddingRight="@dimen/md_dialog_frame_margin" - android:paddingBottom="@dimen/md_content_padding_top"> + android:padding="12dp"> - - + android:layout_margin="8dp" + android:text="@string/donate" + android:textAllCaps="false" /> - + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_error_handler.xml b/app/src/main/res/layout/activity_error_handler.xml index 634f1a32..4ede7c92 100644 --- a/app/src/main/res/layout/activity_error_handler.xml +++ b/app/src/main/res/layout/activity_error_handler.xml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_lock_screen_old_style.xml b/app/src/main/res/layout/activity_lock_screen_old_style.xml index b67c6a17..8589b8a2 100644 --- a/app/src/main/res/layout/activity_lock_screen_old_style.xml +++ b/app/src/main/res/layout/activity_lock_screen_old_style.xml @@ -29,7 +29,7 @@ android:layout_height="wrap_content" android:layout_weight="0"> - - + - - + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main_content.xml b/app/src/main/res/layout/activity_main_content.xml index 064a9d6d..1d249e3e 100644 --- a/app/src/main/res/layout/activity_main_content.xml +++ b/app/src/main/res/layout/activity_main_content.xml @@ -1,12 +1,5 @@ - - - - - \ No newline at end of file + android:layout_height="match_parent" /> diff --git a/app/src/main/res/layout/activity_main_drawer_layout.xml b/app/src/main/res/layout/activity_main_drawer_layout.xml index fbc83987..43b0347a 100644 --- a/app/src/main/res/layout/activity_main_drawer_layout.xml +++ b/app/src/main/res/layout/activity_main_drawer_layout.xml @@ -3,13 +3,11 @@ android:id="@+id/parent_container" android:layout_width="match_parent" android:layout_height="match_parent" - android:fitsSystemWindows="true" android:orientation="vertical"> + android:layout_height="match_parent" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_now_playng.xml b/app/src/main/res/layout/activity_now_playng.xml new file mode 100644 index 00000000..37fa1e3e --- /dev/null +++ b/app/src/main/res/layout/activity_now_playng.xml @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_pro_version.xml b/app/src/main/res/layout/activity_pro_version.xml index 3cd321fe..ede3e79f 100644 --- a/app/src/main/res/layout/activity_pro_version.xml +++ b/app/src/main/res/layout/activity_pro_version.xml @@ -45,7 +45,7 @@ + android:text="@string/buy_retro_music_pro" /> diff --git a/app/src/main/res/layout/activity_pro_version_content.xml b/app/src/main/res/layout/activity_pro_version_content.xml index acdc790a..b6543d9b 100644 --- a/app/src/main/res/layout/activity_pro_version_content.xml +++ b/app/src/main/res/layout/activity_pro_version_content.xml @@ -5,180 +5,151 @@ android:layout_height="wrap_content" android:orientation="vertical"> - + android:orientation="vertical"> + android:gravity="center_vertical" + android:orientation="horizontal"> - + + - - - - - + android:padding="16dp" + android:text="@string/base_color_theme" + android:textAppearance="@style/TextAppearance.AppCompat.Subhead" + android:textColor="@color/md_white_1000" /> + - + + + + - - - - - + android:padding="16dp" + android:text="@string/now_playing_themes" + android:textAppearance="@style/TextAppearance.AppCompat.Subhead" + android:textColor="@color/md_white_1000" /> + - + + + + + android:padding="16dp" + android:text="@string/carousal_effect_on_now_playing_screen" + android:textAppearance="@style/TextAppearance.AppCompat.Subhead" + android:textColor="@color/md_white_1000" /> + - + - - + - - - - - - + android:padding="16dp" + android:text="@string/window_corner_edges" + android:textAppearance="@style/TextAppearance.AppCompat.Subhead" + android:textColor="@color/md_white_1000" /> + - + + + + + android:padding="16dp" + android:text="@string/support_development" + android:textAppearance="@style/TextAppearance.AppCompat.Subhead" + android:textColor="@color/md_white_1000" /> + - + - - - - + android:layout_margin="8dp" + android:layout_weight="1" + android:text="@string/restore" + app:strokeColor="@color/md_red_500" + app:strokeWidth="1dp" /> - - - - - - - - + - - + diff --git a/app/src/main/res/layout/activity_search.xml b/app/src/main/res/layout/activity_search.xml index e003172a..22eae57e 100755 --- a/app/src/main/res/layout/activity_search.xml +++ b/app/src/main/res/layout/activity_search.xml @@ -22,7 +22,7 @@ android:id="@+id/search" android:layout_width="match_parent" android:layout_height="wrap_content" - app:cardCornerRadius="25dp" + app:cardCornerRadius="8dp" app:cardUseCompatPadding="true"> @@ -22,8 +21,8 @@ android:id="@+id/toolbar" style="@style/Toolbar48" app:layout_collapseMode="pin" - app:title="" - tools:ignore="UnusedAttribute"> + app:navigationIcon="@drawable/ic_keyboard_backspace_black_24dp" + app:title=""> + + diff --git a/app/src/main/res/layout/activity_song_tag_editor.xml b/app/src/main/res/layout/activity_song_tag_editor.xml index 96790c74..acb4f92b 100755 --- a/app/src/main/res/layout/activity_song_tag_editor.xml +++ b/app/src/main/res/layout/activity_song_tag_editor.xml @@ -143,6 +143,23 @@ + + + + + + @@ -17,19 +16,12 @@ android:id="@+id/toolbar" style="@style/Toolbar48"> - + style="@style/BigTitleTextAppearance" + android:text="@string/profile" /> - - - - - - - - - + android:layout_height="wrap_content" + app:cardCornerRadius="8dp" + app:cardUseCompatPadding="true"> - - + android:id="@+id/image_container" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + + + - + android:background="?roundSelector" + android:padding="16dp" + app:srcCompat="@drawable/ic_round_add_a_photo_white_24dp" /> - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/card_credit.xml b/app/src/main/res/layout/card_credit.xml index ac9765a9..c08d4499 100644 --- a/app/src/main/res/layout/card_credit.xml +++ b/app/src/main/res/layout/card_credit.xml @@ -1,40 +1,29 @@ - + + - + android:layout_height="wrap_content" /> - - - - - + - + android:layout_height="match_parent" + android:orientation="vertical"> - + + + app:cardCornerRadius="8dp" + app:cardPreventCornerOverlap="false" + app:cardUseCompatPadding="true"> - - - - - - - - - - - - - - - - - + android:padding="8dp"> - + android:background="?attr/rectSelector" + android:gravity="center_vertical" + android:minHeight="@dimen/md_listitem_height" + android:orientation="vertical" + android:paddingStart="12dp" + android:paddingTop="8dp" + android:paddingEnd="12dp" + android:paddingBottom="8dp" + tools:ignore="PrivateResource"> - + + + + + + android:background="?attr/rectSelector" + android:gravity="center_vertical" + android:minHeight="@dimen/md_listitem_height" + android:orientation="vertical" + android:paddingStart="12dp" + android:paddingTop="8dp" + android:paddingEnd="12dp" + android:paddingBottom="8dp" + tools:ignore="PrivateResource"> + + + + + + + + + + + + + + + - - - \ No newline at end of file + + \ No newline at end of file diff --git a/app/src/main/res/layout/card_retro_info.xml b/app/src/main/res/layout/card_retro_info.xml index 0cfad69a..4829a4f2 100644 --- a/app/src/main/res/layout/card_retro_info.xml +++ b/app/src/main/res/layout/card_retro_info.xml @@ -1,276 +1,279 @@ - + android:layout_height="match_parent" + android:orientation="vertical"> - + + - - + app:cardCornerRadius="8dp" + app:cardPreventCornerOverlap="false" + app:cardUseCompatPadding="true"> + android:orientation="vertical"> - + android:background="?attr/rectSelector" + android:clickable="true" + android:focusable="true" + android:minHeight="@dimen/md_listitem_height" + android:orientation="horizontal" + tools:ignore="PrivateResource"> + - + android:orientation="vertical" + android:paddingStart="12dp" + android:paddingTop="8dp" + android:paddingEnd="12dp" + android:paddingBottom="8dp"> - + + + + + - - - - - + android:background="?attr/rectSelector" + android:clickable="true" + android:focusable="true" + android:minHeight="@dimen/md_listitem_height" + android:orientation="horizontal" + tools:ignore="PrivateResource"> + - + android:orientation="vertical" + android:paddingStart="12dp" + android:paddingTop="8dp" + android:paddingEnd="12dp" + android:paddingBottom="8dp"> - + + + + + - - - - - + android:background="?attr/rectSelector" + android:clickable="true" + android:focusable="true" + android:minHeight="@dimen/md_listitem_height" + android:orientation="horizontal" + tools:ignore="PrivateResource"> + - + android:orientation="vertical" + android:paddingStart="12dp" + android:paddingTop="8dp" + android:paddingEnd="12dp" + android:paddingBottom="8dp"> - + + + + + - - - - - + android:background="?attr/rectSelector" + android:clickable="true" + android:focusable="true" + android:minHeight="@dimen/md_listitem_height" + android:orientation="horizontal" + tools:ignore="PrivateResource"> + - + android:orientation="vertical" + android:paddingStart="12dp" + android:paddingTop="8dp" + android:paddingEnd="12dp" + android:paddingBottom="8dp"> - + + + + + - - - - - + android:background="?attr/rectSelector" + android:clickable="true" + android:focusable="true" + android:minHeight="@dimen/md_listitem_height" + android:orientation="horizontal" + tools:ignore="PrivateResource"> + - + android:gravity="center_vertical" + android:orientation="vertical" + android:paddingStart="12dp" + android:paddingTop="8dp" + android:paddingEnd="12dp" + android:paddingBottom="8dp"> + + + + - - - - - + android:background="?attr/rectSelector" + android:clickable="true" + android:focusable="true" + android:minHeight="@dimen/md_listitem_height" + android:orientation="horizontal" + tools:ignore="PrivateResource"> - + + + android:gravity="center_vertical" + android:orientation="vertical" + android:paddingStart="12dp" + android:paddingTop="8dp" + android:paddingEnd="12dp" + android:paddingBottom="8dp"> + + + - - \ No newline at end of file + + \ No newline at end of file diff --git a/app/src/main/res/layout/card_social.xml b/app/src/main/res/layout/card_social.xml index d093ca7d..c158e40e 100644 --- a/app/src/main/res/layout/card_social.xml +++ b/app/src/main/res/layout/card_social.xml @@ -1,235 +1,235 @@ - + android:layout_height="match_parent" + android:orientation="vertical"> - + + - - - + app:cardCornerRadius="8dp" + app:cardPreventCornerOverlap="false" + app:cardUseCompatPadding="true"> + android:orientation="vertical"> - + android:background="?attr/rectSelector" + android:clickable="true" + android:focusable="true" + android:minHeight="@dimen/md_listitem_height" + android:orientation="horizontal" + tools:ignore="PrivateResource"> + - + android:orientation="vertical" + android:paddingStart="12dp" + android:paddingTop="8dp" + android:paddingEnd="12dp" + android:paddingBottom="8dp"> - + + + + + - - - - - + android:background="?attr/rectSelector" + android:clickable="true" + android:focusable="true" + android:minHeight="@dimen/md_listitem_height" + android:orientation="horizontal" + tools:ignore="PrivateResource"> - + + + android:orientation="vertical" + android:paddingStart="12dp" + android:paddingTop="8dp" + android:paddingEnd="12dp" + android:paddingBottom="8dp"> - + + + + - - - - - + android:background="?attr/rectSelector" + android:clickable="true" + android:focusable="true" + android:minHeight="@dimen/md_listitem_height" + android:orientation="horizontal" + tools:ignore="PrivateResource"> - + + + android:orientation="vertical" + android:paddingStart="12dp" + android:paddingTop="8dp" + android:paddingEnd="12dp" + android:paddingBottom="8dp"> - + + + + - - - - - + android:background="?attr/rectSelector" + android:clickable="true" + android:focusable="true" + android:minHeight="@dimen/md_listitem_height" + android:orientation="horizontal" + tools:ignore="PrivateResource"> - + + + android:orientation="vertical" + android:paddingStart="12dp" + android:paddingTop="8dp" + android:paddingEnd="12dp" + android:paddingBottom="8dp"> - + + + + - - - - - + android:background="?attr/rectSelector" + android:clickable="true" + android:focusable="true" + android:minHeight="@dimen/md_listitem_height" + android:orientation="horizontal" + tools:ignore="PrivateResource"> + - + android:orientation="vertical" + android:paddingStart="12dp" + android:paddingTop="8dp" + android:paddingEnd="12dp" + android:paddingBottom="8dp"> - + + + + + - - \ No newline at end of file + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_add_to_playlist.xml b/app/src/main/res/layout/dialog_add_to_playlist.xml index 2d4dc77e..d2f6f8cc 100644 --- a/app/src/main/res/layout/dialog_add_to_playlist.xml +++ b/app/src/main/res/layout/dialog_add_to_playlist.xml @@ -1,7 +1,6 @@ @@ -14,14 +13,9 @@ + android:text="@string/add_playlist_title" /> \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_create_playlist.xml b/app/src/main/res/layout/dialog_create_playlist.xml index 871f4f9e..48003e01 100644 --- a/app/src/main/res/layout/dialog_create_playlist.xml +++ b/app/src/main/res/layout/dialog_create_playlist.xml @@ -1,28 +1,28 @@ + android:orientation="vertical"> + style="@style/SubTitleTextAppearance" + android:padding="12dp" + android:text="@string/new_playlist_title" /> + + - + android:text="@string/remove_song_from_playlist_title" /> - - - - + android:orientation="vertical"> - + android:scaleType="centerCrop" + android:src="@drawable/diwali" /> - + + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> - + + + + + + + + + + + + - - - - - - \ No newline at end of file + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_remove_from_playlist.xml b/app/src/main/res/layout/dialog_remove_from_playlist.xml index 1dce5e3a..72840aad 100644 --- a/app/src/main/res/layout/dialog_remove_from_playlist.xml +++ b/app/src/main/res/layout/dialog_remove_from_playlist.xml @@ -1,22 +1,16 @@ - + android:text="@string/remove_song_from_playlist_title" /> - - diff --git a/app/src/main/res/layout/fragment_adaptive_player.xml b/app/src/main/res/layout/fragment_adaptive_player.xml index 0a4ffb64..5e9eab0d 100644 --- a/app/src/main/res/layout/fragment_adaptive_player.xml +++ b/app/src/main/res/layout/fragment_adaptive_player.xml @@ -9,64 +9,65 @@ - + android:layout_height="match_parent"> - - - - - - - - - - - - + android:orientation="vertical"> - + android:layout_height="wrap_content" + android:layout_weight="0"> - + - + - - - + android:layout_weight="1" + app:cardCornerRadius="8dp" + app:cardElevation="8dp" + app:cardUseCompatPadding="true"> + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_album_card_cover.xml b/app/src/main/res/layout/fragment_album_card_cover.xml index 054af9ac..41fbee7d 100644 --- a/app/src/main/res/layout/fragment_album_card_cover.xml +++ b/app/src/main/res/layout/fragment_album_card_cover.xml @@ -5,17 +5,17 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - + app:cardElevation="4dp"> - + android:background="@drawable/shadow_up_edited" /> + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_album_cover.xml b/app/src/main/res/layout/fragment_album_cover.xml index e7fee7b4..43f7b3c0 100644 --- a/app/src/main/res/layout/fragment_album_cover.xml +++ b/app/src/main/res/layout/fragment_album_cover.xml @@ -7,7 +7,7 @@ android:layout_gravity="center_vertical"> - - + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_album_full_card_cover.xml b/app/src/main/res/layout/fragment_album_full_card_cover.xml index 1622df64..dbbf9ec0 100644 --- a/app/src/main/res/layout/fragment_album_full_card_cover.xml +++ b/app/src/main/res/layout/fragment_album_full_card_cover.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_album_material_cover.xml b/app/src/main/res/layout/fragment_album_material_cover.xml index e205d35e..6ebf7a82 100644 --- a/app/src/main/res/layout/fragment_album_material_cover.xml +++ b/app/src/main/res/layout/fragment_album_material_cover.xml @@ -6,7 +6,7 @@ android:layout_height="match_parent" android:layout_gravity="center_vertical"> - - + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_banner_home.xml b/app/src/main/res/layout/fragment_banner_home.xml index d3da890a..3fc7f6b4 100644 --- a/app/src/main/res/layout/fragment_banner_home.xml +++ b/app/src/main/res/layout/fragment_banner_home.xml @@ -1,87 +1,159 @@ - + android:layout_height="match_parent"> - + android:layout_height="wrap_content" + android:elevation="0dp" + android:focusable="true" + app:elevation="0dp" + tools:ignore="UnusedAttribute"> - + android:layout_height="196dp" + app:contentScrim="?attr/colorPrimary" + app:layout_scrollFlags="scroll|exitUntilCollapsed" + app:statusBarScrim="?attr/colorPrimary" + app:titleEnabled="false"> - - - - - - - - - - - - - - - - - - - - + android:layout_height="match_parent" + android:scaleType="centerCrop" + app:layout_collapseMode="parallax" + tools:ignore="ContentDescription" /> + + + + + + + + + + + + + + + + + + + --> + - + - + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_blur.xml b/app/src/main/res/layout/fragment_blur.xml index d6e1c6b6..aa2e113a 100644 --- a/app/src/main/res/layout/fragment_blur.xml +++ b/app/src/main/res/layout/fragment_blur.xml @@ -11,8 +11,7 @@ android:id="@+id/gradient_background" android:layout_width="match_parent" android:layout_height="match_parent" - android:scaleType="centerCrop" - /> + android:scaleType="centerCrop" /> - - - + android:layout_height="match_parent"> - - - - - - - - - - - + android:orientation="vertical"> - - + android:layout_height="wrap_content" + android:layout_weight="0"> - + + - - - + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_blur_playback_controls.xml b/app/src/main/res/layout/fragment_blur_playback_controls.xml index 774ae056..3d3e4897 100644 --- a/app/src/main/res/layout/fragment_blur_playback_controls.xml +++ b/app/src/main/res/layout/fragment_blur_playback_controls.xml @@ -14,8 +14,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:maxHeight="3dp" - android:paddingEnd="24dp" android:paddingStart="24dp" + android:paddingEnd="24dp" android:progressDrawable="@drawable/color_progress_seek" tools:progress="20" /> @@ -24,8 +24,8 @@ android:layout_height="wrap_content" android:gravity="center_vertical" android:orientation="horizontal" - android:paddingEnd="16dp" - android:paddingStart="16dp"> + android:paddingStart="16dp" + android:paddingEnd="16dp"> diff --git a/app/src/main/res/layout/fragment_card_blur_player.xml b/app/src/main/res/layout/fragment_card_blur_player.xml index d0c2b608..24c4581b 100644 --- a/app/src/main/res/layout/fragment_card_blur_player.xml +++ b/app/src/main/res/layout/fragment_card_blur_player.xml @@ -21,64 +21,68 @@ - - - - - - - - - - - - - - - - - - - - + android:layout_height="match_parent"> - + android:layout_height="wrap_content" + android:orientation="vertical"> + + + + + + + + + + + + + + + + + - + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_card_player.xml b/app/src/main/res/layout/fragment_card_player.xml index 6b7b6a96..6f690791 100644 --- a/app/src/main/res/layout/fragment_card_player.xml +++ b/app/src/main/res/layout/fragment_card_player.xml @@ -20,64 +20,58 @@ android:layout_height="match_parent" tools:layout="@layout/fragment_album_full_cover" /> - - + android:layout_height="match_parent"> - - - - - - - - - - - - + android:orientation="vertical"> - + android:layout_height="wrap_content" + android:layout_weight="0"> - + + - - + - + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_color_player.xml b/app/src/main/res/layout/fragment_color_player.xml index 065331cc..c53409d9 100644 --- a/app/src/main/res/layout/fragment_color_player.xml +++ b/app/src/main/res/layout/fragment_color_player.xml @@ -15,107 +15,107 @@ - + android:layout_height="match_parent"> - - - - - - - - - - - - - - - - - - - - - - - - - - + android:orientation="vertical"> - + + + + + + + + + + + + + + + + + + + + - + android:layout_weight="1"> - + + + + - + - - + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_fit.xml b/app/src/main/res/layout/fragment_fit.xml new file mode 100644 index 00000000..d31f16c6 --- /dev/null +++ b/app/src/main/res/layout/fragment_fit.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_fit_playback_controls.xml b/app/src/main/res/layout/fragment_fit_playback_controls.xml new file mode 100644 index 00000000..b5eeb32d --- /dev/null +++ b/app/src/main/res/layout/fragment_fit_playback_controls.xml @@ -0,0 +1,190 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_flat_player.xml b/app/src/main/res/layout/fragment_flat_player.xml index 7989535f..ac369b74 100644 --- a/app/src/main/res/layout/fragment_flat_player.xml +++ b/app/src/main/res/layout/fragment_flat_player.xml @@ -15,56 +15,55 @@ - + android:layout_height="match_parent"> - + android:layout_height="match_parent" + android:orientation="vertical"> - - - - - - - - - - - - + android:layout_weight="0"> - + + - - - + android:layout_height="wrap_content"> + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_flat_player_playback_controls.xml b/app/src/main/res/layout/fragment_flat_player_playback_controls.xml index e43a6269..45da3457 100644 --- a/app/src/main/res/layout/fragment_flat_player_playback_controls.xml +++ b/app/src/main/res/layout/fragment_flat_player_playback_controls.xml @@ -114,7 +114,7 @@ android:layout_marginTop="8dp" android:background="?colorAccent" android:foreground="?attr/rectSelector" - android:padding="16dp" + android:padding="12dp" android:scaleType="fitCenter" tools:ignore="MissingPrefix" tools:src="@drawable/ic_pause_white_24dp" /> diff --git a/app/src/main/res/layout/fragment_folder.xml b/app/src/main/res/layout/fragment_folder.xml index 6d6edf11..c8275f35 100644 --- a/app/src/main/res/layout/fragment_folder.xml +++ b/app/src/main/res/layout/fragment_folder.xml @@ -68,7 +68,6 @@ android:layout_height="match_parent" android:layout_weight="1" android:background="@color/md_white_1000" - android:elevation="@dimen/card_elevation" app:layout_behavior="@string/appbar_scrolling_view_behavior"> + android:background="#30000000" /> - - + android:layout_height="match_parent"> - + android:orientation="vertical"> - + - + - - - - - - + + + + diff --git a/app/src/main/res/layout/fragment_hmm_player.xml b/app/src/main/res/layout/fragment_hmm_player.xml index b6904bd2..52823e59 100644 --- a/app/src/main/res/layout/fragment_hmm_player.xml +++ b/app/src/main/res/layout/fragment_hmm_player.xml @@ -32,96 +32,102 @@ android:progress="80" android:progressDrawable="@drawable/progress_drawable_vertical" /> - + android:layout_height="match_parent"> - + android:layout_height="match_parent" + android:orientation="vertical"> - - - - - - - - - - - - - - + android:layout_height="wrap_content"> - + + + + + + + + + + + + + + android:layout_gravity="bottom" + android:orientation="vertical"> - + - - - + - + + + - + android:gravity="center_vertical" + android:orientation="horizontal"> - - - + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 68bb91f1..1ebe17bb 100755 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -1,100 +1,89 @@ - + android:layout_height="match_parent" + android:orientation="vertical"> - + android:layout_height="match_parent"> - + android:layout_height="wrap_content" + android:layout_weight="0" + android:elevation="0dp" + app:elevation="0dp" + tools:ignore="UnusedAttribute"> - - - + app:layout_scrollFlags="scroll|enterAlways" + app:titleEnabled="false"> - + android:orientation="vertical"> - + - + + - + - + - + + + + + - - - - - - - - - + android:layout_height="wrap_content" + android:layout_weight="1" + android:background="@color/md_white_1000" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> - + + + + + + + + + - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_main_options.xml b/app/src/main/res/layout/fragment_main_options.xml index 327847aa..e5e0b345 100644 --- a/app/src/main/res/layout/fragment_main_options.xml +++ b/app/src/main/res/layout/fragment_main_options.xml @@ -1,102 +1,134 @@ - + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingStart="8dp" + android:paddingEnd="8dp" + tools:ignore="MissingPrefix"> + android:paddingBottom="16dp"> - + + + android:layout_weight="1" + android:orientation="vertical" + android:paddingBottom="8dp"> - + + + + + + - - - - - - - - - - + app:srcCompat="@drawable/ic_settings_white_24dp" /> - \ No newline at end of file + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_material.xml b/app/src/main/res/layout/fragment_material.xml index 570a649a..3d8a86d7 100644 --- a/app/src/main/res/layout/fragment_material.xml +++ b/app/src/main/res/layout/fragment_material.xml @@ -9,57 +9,56 @@ - + android:layout_height="match_parent"> - - - - - - - - - - - + android:orientation="vertical"> - + + + + + - + android:layout_weight="1"> - + + - - - + + + + + + diff --git a/app/src/main/res/layout/fragment_mini_player.xml b/app/src/main/res/layout/fragment_mini_player.xml index 868f3e6e..05a26f64 100644 --- a/app/src/main/res/layout/fragment_mini_player.xml +++ b/app/src/main/res/layout/fragment_mini_player.xml @@ -3,7 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="wrap_content" + android:layout_height="48dp" android:background="@android:color/transparent" android:clickable="true" android:focusable="false" @@ -92,5 +92,4 @@ app:mpb_progressStyle="horizontal" app:mpb_showProgressBackground="false" app:mpb_useIntrinsicPadding="false" /> - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_plain_player.xml b/app/src/main/res/layout/fragment_plain_player.xml index 6a210784..ef894b1c 100644 --- a/app/src/main/res/layout/fragment_plain_player.xml +++ b/app/src/main/res/layout/fragment_plain_player.xml @@ -9,91 +9,90 @@ - - - - - - + android:layout_height="match_parent"> - - - - - - - - - - - - + android:orientation="vertical"> - + + + + + + + + + + + + - + android:layout_weight="1"> - + + - - - + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_player.xml b/app/src/main/res/layout/fragment_player.xml index e62605dc..f562efe2 100644 --- a/app/src/main/res/layout/fragment_player.xml +++ b/app/src/main/res/layout/fragment_player.xml @@ -14,58 +14,56 @@ - - + android:layout_height="match_parent"> - - - - - - - - - - - + android:orientation="vertical"> - + + + + + - + android:layout_weight="1"> - + + - - - + + + + + + diff --git a/app/src/main/res/layout/fragment_player_playback_controls.xml b/app/src/main/res/layout/fragment_player_playback_controls.xml index 2caacdaf..01f50315 100755 --- a/app/src/main/res/layout/fragment_player_playback_controls.xml +++ b/app/src/main/res/layout/fragment_player_playback_controls.xml @@ -14,19 +14,19 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:maxHeight="3dp" - android:paddingEnd="24dp" android:paddingStart="24dp" + android:paddingEnd="24dp" android:progressDrawable="@drawable/color_progress_seek" + android:splitTrack="false" android:thumb="@drawable/switch_thumb_material" tools:progress="20" /> + android:paddingStart="16dp" + android:paddingEnd="16dp"> diff --git a/app/src/main/res/layout/fragment_simple_controls_fragment.xml b/app/src/main/res/layout/fragment_simple_controls_fragment.xml index cdfa5be5..4375c7f8 100644 --- a/app/src/main/res/layout/fragment_simple_controls_fragment.xml +++ b/app/src/main/res/layout/fragment_simple_controls_fragment.xml @@ -17,10 +17,10 @@ android:layout_height="match_parent" android:gravity="center_vertical" android:orientation="vertical" - android:paddingEnd="16dp" - android:paddingStart="16dp"> + android:paddingStart="16dp" + android:paddingEnd="16dp"> - - - - + android:layout_height="match_parent"> - - - - - - - - - - - + android:orientation="vertical"> - + + + + + - + android:layout_weight="1"> - + + - - - + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/home_section_content.xml b/app/src/main/res/layout/home_section_content.xml index cfcdbe64..8a812422 100644 --- a/app/src/main/res/layout/home_section_content.xml +++ b/app/src/main/res/layout/home_section_content.xml @@ -11,13 +11,14 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" - android:visibility="gone" - tools:visibility="visible"> + android:visibility="gone"> - + + android:visibility="gone" + tools:visibility="visible"> - + - @@ -87,7 +91,8 @@ android:orientation="vertical" android:visibility="gone"> - @@ -105,6 +110,31 @@ android:background="?attr/dividerColor" /> + + + + + + + + + + - diff --git a/app/src/main/res/layout/image.xml b/app/src/main/res/layout/image.xml index 6019ee7e..375c45f9 100644 --- a/app/src/main/res/layout/image.xml +++ b/app/src/main/res/layout/image.xml @@ -11,6 +11,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="centerCrop" + android:transitionName="@string/transition_album_art" tools:ignore="ContentDescription" /> + app:civ_border="false" /> + android:paddingTop="12dp" /> \ No newline at end of file diff --git a/app/src/main/res/layout/item_artist_sqaure.xml b/app/src/main/res/layout/item_artist_square.xml similarity index 78% rename from app/src/main/res/layout/item_artist_sqaure.xml rename to app/src/main/res/layout/item_artist_square.xml index aff14162..dfca1722 100644 --- a/app/src/main/res/layout/item_artist_sqaure.xml +++ b/app/src/main/res/layout/item_artist_square.xml @@ -1,11 +1,11 @@ - + android:scaleType="centerCrop" /> - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/item_card.xml b/app/src/main/res/layout/item_card.xml index ac685fb0..07106cf2 100644 --- a/app/src/main/res/layout/item_card.xml +++ b/app/src/main/res/layout/item_card.xml @@ -1,5 +1,5 @@ - - + diff --git a/app/src/main/res/layout/item_card_color.xml b/app/src/main/res/layout/item_card_color.xml index 3b27becc..69550357 100644 --- a/app/src/main/res/layout/item_card_color.xml +++ b/app/src/main/res/layout/item_card_color.xml @@ -1,60 +1,57 @@ - - - - - - - - - + android:layout_height="wrap_content" + app:cardCornerRadius="8dp" + app:cardUseCompatPadding="true" + tools:ignore="MissingPrefix"> - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:padding="12dp" - android:gravity="center_vertical" - android:orientation="vertical"> + - + - + + + + + + + + - - + diff --git a/app/src/main/res/layout/item_collage.xml b/app/src/main/res/layout/item_collage.xml index ccc565c2..f97d2a63 100644 --- a/app/src/main/res/layout/item_collage.xml +++ b/app/src/main/res/layout/item_collage.xml @@ -8,6 +8,7 @@ - - - + @@ -45,36 +46,36 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - - - + - - - + @@ -88,18 +89,18 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - - - + @@ -114,18 +115,18 @@ android:layout_height="wrap_content" android:layout_weight="1"> - - - + - - - + - - - + - - - + - - - + \ No newline at end of file diff --git a/app/src/main/res/layout/item_donation_option.xml b/app/src/main/res/layout/item_donation_option.xml index 95805a0b..1dadaba5 100644 --- a/app/src/main/res/layout/item_donation_option.xml +++ b/app/src/main/res/layout/item_donation_option.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - - + \ No newline at end of file diff --git a/app/src/main/res/layout/item_grid.xml b/app/src/main/res/layout/item_grid.xml index af128c49..bd51590a 100644 --- a/app/src/main/res/layout/item_grid.xml +++ b/app/src/main/res/layout/item_grid.xml @@ -1,68 +1,68 @@ - - - - - - - - - - + android:layout_height="wrap_content" + android:background="?rectSelector" + tools:ignore="MissingPrefix"> - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:paddingTop="8dp" - android:paddingBottom="8dp" - android:paddingStart="4dp" - android:paddingEnd="4dp" - android:gravity="center_vertical" - android:orientation="vertical"> + - + - + + + + + + + + + + - diff --git a/app/src/main/res/layout/item_image.xml b/app/src/main/res/layout/item_image.xml index c83bb402..4396c927 100644 --- a/app/src/main/res/layout/item_image.xml +++ b/app/src/main/res/layout/item_image.xml @@ -10,7 +10,7 @@ android:layout_height="wrap_content" android:orientation="vertical"> - - + @@ -33,6 +33,6 @@ android:layout_height="wrap_content" android:ellipsize="end" android:maxLines="1" - android:padding="12dp" + android:padding="10dp" android:textColor="?android:attr/textColorPrimary" /> \ No newline at end of file diff --git a/app/src/main/res/layout/item_list.xml b/app/src/main/res/layout/item_list.xml index 613778e0..2c148978 100755 --- a/app/src/main/res/layout/item_list.xml +++ b/app/src/main/res/layout/item_list.xml @@ -33,7 +33,7 @@ android:paddingLeft="16dp" android:paddingEnd="0dp"> - - + - - + android:background="?attr/rectSelector" + android:clickable="true" + android:focusable="true" + android:orientation="vertical"> + + \ No newline at end of file diff --git a/app/src/main/res/layout/pager_item.xml b/app/src/main/res/layout/pager_item.xml index bb1726a0..db2b6c8c 100644 --- a/app/src/main/res/layout/pager_item.xml +++ b/app/src/main/res/layout/pager_item.xml @@ -7,7 +7,7 @@ android:layout_height="wrap_content" android:orientation="vertical"> - - + @@ -51,10 +53,10 @@ android:layout_height="match_parent" android:ellipsize="end" android:maxLines="1" - android:padding="8dp" - android:textSize="16sp" + android:paddingStart="8dp" + android:paddingEnd="8dp" + android:textSize="14sp" tools:ignore="MissingPrefix" tools:text="My top tracks" /> - \ No newline at end of file diff --git a/app/src/main/res/layout/preference_dialog_now_playing_screen.xml b/app/src/main/res/layout/preference_dialog_now_playing_screen.xml index b1eb42d2..a62f2926 100644 --- a/app/src/main/res/layout/preference_dialog_now_playing_screen.xml +++ b/app/src/main/res/layout/preference_dialog_now_playing_screen.xml @@ -1,8 +1,8 @@ + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + android:paddingRight="72dp" /> \ No newline at end of file diff --git a/app/src/main/res/layout/preference_now_playing_screen_item.xml b/app/src/main/res/layout/preference_now_playing_screen_item.xml index 192fe502..12bfcd71 100644 --- a/app/src/main/res/layout/preference_now_playing_screen_item.xml +++ b/app/src/main/res/layout/preference_now_playing_screen_item.xml @@ -5,8 +5,7 @@ android:layout_height="wrap_content" android:orientation="vertical" tools:ignore="ContentDescription"> - - + \ No newline at end of file diff --git a/app/src/main/res/layout/sliding_music_panel_layout.xml b/app/src/main/res/layout/sliding_music_panel_layout.xml index 2e81699d..a5fb9619 100644 --- a/app/src/main/res/layout/sliding_music_panel_layout.xml +++ b/app/src/main/res/layout/sliding_music_panel_layout.xml @@ -2,54 +2,61 @@ - + android:orientation="vertical"> + android:layout_height="match_parent" + android:layout_weight="1" /> - + android:layout_height="wrap_content" + android:layout_weight="0" + android:background="@drawable/bg_circular_top_corners" + android:orientation="vertical"> + + android:layout_height="wrap_content" + android:visibility="gone"> - + + + - - - - - + android:layout_height="56dp" + android:elevation="0dp" + app:elevation="0dp" + app:itemIconTint="@drawable/bottom_navigation_item_colors" + app:itemTextAppearanceActive="@style/BottomSheetTextAppearance" + app:itemTextAppearanceInactive="@style/BottomSheetTextAppearance" + app:itemTextColor="@drawable/bottom_navigation_item_colors" + app:labelVisibilityMode="labeled" + app:menu="@menu/bottom_navigation_main" /> + + diff --git a/app/src/main/res/layout/sub_header.xml b/app/src/main/res/layout/sub_header.xml index 98ca93a4..d8a9fd1b 100644 --- a/app/src/main/res/layout/sub_header.xml +++ b/app/src/main/res/layout/sub_header.xml @@ -3,4 +3,4 @@ android:id="@+id/title" style="@style/SubTitleTextAppearance" android:layout_gravity="start" - android:gravity="start"/> \ No newline at end of file + android:gravity="start" /> \ No newline at end of file diff --git a/app/src/main/res/menu/menu_player.xml b/app/src/main/res/menu/menu_player.xml index 4d2f83b0..b5b07dd2 100755 --- a/app/src/main/res/menu/menu_player.xml +++ b/app/src/main/res/menu/menu_player.xml @@ -67,4 +67,8 @@ android:id="@+id/action_delete_from_device" android:orderInCategory="13" android:title="@string/action_delete_from_device" /> + diff --git a/app/src/main/res/transition/grid_exit.xml b/app/src/main/res/transition/grid_exit.xml new file mode 100644 index 00000000..ddc617e5 --- /dev/null +++ b/app/src/main/res/transition/grid_exit.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-de-rDE/strings.xml b/app/src/main/res/values-de-rDE/strings.xml index 1b9664b8..bbd88174 100644 --- a/app/src/main/res/values-de-rDE/strings.xml +++ b/app/src/main/res/values-de-rDE/strings.xml @@ -79,7 +79,7 @@ Beachte, dass diese Funktion sich auf die Akkulaufzeit auswirkt. Unschärfe Geringere Unschärfe benötigt weniger Rechenleistung. - Retro Music Pro kaufen + Retro Music Pro kaufen Abbrechen Karte Karte (Farbe) diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index fa933cc6..c1fa658f 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -69,7 +69,7 @@ Lista negra Desenfocar Tarjeta con desenfoque - Comprar RetroMusic Pro + Comprar RetroMusic Pro Cancelar temporizador actual Tarjeta Lista de cambios diff --git a/app/src/main/res/values-es-rUS/strings.xml b/app/src/main/res/values-es-rUS/strings.xml index 20480af9..0d18d299 100644 --- a/app/src/main/res/values-es-rUS/strings.xml +++ b/app/src/main/res/values-es-rUS/strings.xml @@ -79,7 +79,7 @@ Tenga en cuenta que habilitar esta función puede afectar la duración de la batería Cantidad de desenfoque Cantidad de desenfoque aplicado a los temas de desenfoque, más bajo es más rápido - Comprar Retro Music Pro + Comprar Retro Music Pro Cancelar Tarjeta Tarjeta coloreada diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 2fd08be3..b2580fd2 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -70,7 +70,7 @@ Lista negra Desenfoque Tarjeta con desenfoque - Comprar RetroMusic Pro + Comprar RetroMusic Pro Cancelar el temporizador actual Tarjeta Lista de Cambios diff --git a/app/src/main/res/values-eu-rES/strings.xml b/app/src/main/res/values-eu-rES/strings.xml index e052a283..cf262985 100644 --- a/app/src/main/res/values-eu-rES/strings.xml +++ b/app/src/main/res/values-eu-rES/strings.xml @@ -70,7 +70,7 @@ Lista negra Desenfocar Tarjeta con desenfoque - Comprar RetroMusic Pro + Comprar RetroMusic Pro Cancelar temporizador actual Tarjeta Lista de cambios diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 63e6189a..953c17ab 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -69,7 +69,7 @@ Liste noire Flou Carte Floue - Acheter RetroMusic Pro + Acheter RetroMusic Pro Annuler le minuteur en cours Carte Liste des changements diff --git a/app/src/main/res/values-hr/strings.xml b/app/src/main/res/values-hr/strings.xml index f89d865a..83399366 100644 --- a/app/src/main/res/values-hr/strings.xml +++ b/app/src/main/res/values-hr/strings.xml @@ -71,7 +71,7 @@ Crna lista Zamagljena Zamagljena Kartica - Kupi Retro Music Pro + Kupi Retro Music Pro Otkaži trenutni brojač Kartica Popis promjena diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 70ac5f08..876d6864 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -71,7 +71,7 @@ Feketelista Elhomályosít Elhomályosított Kártya - Vedd meg a Retro Music Pro-t + Vedd meg a Retro Music Pro-t Az aktuális időzítő törlése Kártya Változási napló diff --git a/app/src/main/res/values-id/strings.xml b/app/src/main/res/values-id/strings.xml index 3539b61c..7de327cf 100644 --- a/app/src/main/res/values-id/strings.xml +++ b/app/src/main/res/values-id/strings.xml @@ -68,7 +68,7 @@ https://play.google.com/store/apps/details?id=%s Daftar hitam Blur Kartu blur - Beli RetroMusic Pro + Beli RetroMusic Pro Batalkan timer saat ini Kartu Catatan perubahan diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 591290fc..6162abaa 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -70,7 +70,7 @@ Lista nera Sfocato Scheda sfocata - Acquista RetroMusic Pro + Acquista RetroMusic Pro Elimina timer corrente Scheda Changelog diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 24007458..97013fbd 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -70,7 +70,7 @@ 블랙리스트 흐림 효과 블러 카드 - RetroMusic Pro 구매 + RetroMusic Pro 구매 현재 타이머 취소 카드 변경 사항 diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index ce92ef87..bbc18c4f 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -71,7 +71,7 @@ Czarna lista Rozmycie Rozmyta Karta - Kup RetroMusic Pro + Kup RetroMusic Pro Anuluj aktualny licznik Karta Lista zmian diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 9a1979e1..beaadce5 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -80,7 +80,7 @@ https://play.google.com/store/apps/details?id=%s Tenha em mente que ativar este recurso pode afetar a duração da bateria Quantidade de desfoque Quantidade de desfoque aplicado para temas com desfoque, mais baixo é mais rápido. - Comprar Retro Music Pro + Comprar Retro Music Pro Cancelar Cartão Cartão Colorido diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index 0ff15c2a..c0bb7073 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -70,7 +70,7 @@ Lista neagră Blur Blur Card - Cumpărați RetroMusic Pro + Cumpărați RetroMusic Pro Anulează cronometrul curent Card Modificări diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 12813609..be79dc8a 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -71,7 +71,7 @@ https://play.google.com/store/apps/details?id=%s Исключения Размытая Размытая карточка - Купить RetroMusic Pro + Купить RetroMusic Pro Отменить текущий таймер Карточка Список изменений diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 6b3cbef1..5db88c8a 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -70,7 +70,7 @@ Kara liste Bulanık Bulanık Kart - RetroMusic Pro\'yu Satın Al + RetroMusic Pro\'yu Satın Al Mevcut zamanlayıcıyı iptal et Kart Değişiklik günlüğü diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index a75be2d2..849a4f97 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -70,7 +70,7 @@ 黑名单 模糊 模糊卡片 - 购买RetroMusic专业版 + 购买RetroMusic专业版 取消当前定时器 卡片 更新日志 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index c18ebe56..087b7d21 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -79,7 +79,7 @@ 請記住當您啟用此選項後或會影響電池壽命 模糊值 給模糊模式主題的值,每值愈低就愈快 - 購買Retro Music Pro + 購買Retro Music Pro 取消 卡片 彩色卡片 diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index d6bdb799..65d125c6 100755 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -1,15 +1,21 @@ - - @string/normal @string/cascading + @string/depth + @string/vertical_flip + @string/horizontal_flip + @string/hinge 0 1 + 2 + 3 + 4 + 5 @@ -75,7 +81,7 @@ @layout/item_artist - @layout/item_artist_sqaure + @layout/item_artist_square @@ -181,4 +187,20 @@ @id/cast_button_type_mute_toggle @id/cast_button_type_empty + + + @string/normal + @string/small + + + + @layout/activity_album + @layout/activity_album_small + + + + 0 + 1 + + \ No newline at end of file diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 98152fb3..fca3205a 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -45,4 +45,9 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml index 55627b4f..f69abf85 100755 --- a/app/src/main/res/values/donottranslate.xml +++ b/app/src/main/res/values/donottranslate.xml @@ -15,4 +15,5 @@ GitHub Social Buttons fonts/circular_std_black.otf + fonts/circular_std_book.otf \ No newline at end of file diff --git a/app/src/main/res/values/ids.xml b/app/src/main/res/values/ids.xml index afd6e385..fb61920f 100644 --- a/app/src/main/res/values/ids.xml +++ b/app/src/main/res/values/ids.xml @@ -16,6 +16,7 @@ + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 16a0bfb8..efe8903b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,5 +1,6 @@ + Small album Accent color The accent theme color, defaults to teal @@ -97,7 +98,7 @@ Blur amount Amount of blur applied for blur themes, lower is faster - Buy Retro Music Pro + Retro Music Pro Cancel @@ -366,7 +367,8 @@ Home banner Show genre tab Home artist grid - Now playing album cover style + Album cover skip + Album detail style Cascading Primary color @@ -542,4 +544,15 @@ Labeled Unlabeled Selected + + Depth + Vertical flip + Hinge + Horizontal flip + Pause playing on zero and plays after raise volume. Warning when you increase the volume it starts playing even your outside the app + Pause on zero + What\'s New + Composer + Suggestions + Fit diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index e584b516..83068e93 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -30,7 +30,6 @@ - + + diff --git a/app/src/main/res/values/styles_parents.xml b/app/src/main/res/values/styles_parents.xml index 5504b74c..5869b12e 100644 --- a/app/src/main/res/values/styles_parents.xml +++ b/app/src/main/res/values/styles_parents.xml @@ -16,7 +16,16 @@ @android:color/black @android:color/black - @style/Theme.Design.BottomSheetDialog + @style/BottomSheetDialog + + + true + @transition/grid_exit + @transition/grid_exit + + @transition/grid_exit + @transition/grid_exit + - + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/values.xml b/app/src/main/res/values/values.xml index 8af546e7..28555eca 100755 --- a/app/src/main/res/values/values.xml +++ b/app/src/main/res/values/values.xml @@ -1,6 +1,10 @@ album_art_transition + album_art_transition + album_art_transition artist_image_transition + artist_image_transition + artist_image_transition mini_player_transition \ No newline at end of file diff --git a/app/src/main/res/xml/pref_advanced.xml b/app/src/main/res/xml/pref_advanced.xml index 09bf345e..63079694 100755 --- a/app/src/main/res/xml/pref_advanced.xml +++ b/app/src/main/res/xml/pref_advanced.xml @@ -3,19 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> - - - - + android:key="pause_on_zero_volume" + android:summary="@string/pref_keep_pause_on_zero_volume_summary" + android:title="@string/pref_keep_pause_on_zero_volume_title" + app:iconSpaceReserved="false" /> diff --git a/app/src/main/res/xml/pref_audio.xml b/app/src/main/res/xml/pref_audio.xml index 549d354f..6edd6324 100755 --- a/app/src/main/res/xml/pref_audio.xml +++ b/app/src/main/res/xml/pref_audio.xml @@ -31,4 +31,18 @@ app:iconSpaceReserved="false" android:title="@string/equalizer" /> + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/pref_ui.xml b/app/src/main/res/xml/pref_ui.xml index 907dead6..0cd1f543 100644 --- a/app/src/main/res/xml/pref_ui.xml +++ b/app/src/main/res/xml/pref_ui.xml @@ -23,7 +23,6 @@ app:iconSpaceReserved="false" /> - + - + - + - + - + @@ -87,14 +87,12 @@ - - + - @@ -109,42 +107,43 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/appthemehelper/build.gradle b/appthemehelper/build.gradle index 8d3a7186..d5dc60e3 100644 --- a/appthemehelper/build.gradle +++ b/appthemehelper/build.gradle @@ -17,17 +17,16 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } - buildToolsVersion '28.0.2' productFlavors { } } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'androidx.appcompat:appcompat:1.0.0-rc01' - implementation 'com.google.android.material:material:1.0.0-rc01' - implementation 'androidx.preference:preference:1.0.0-rc01' - implementation 'androidx.cardview:cardview:1.0.0-rc01' + implementation 'androidx.appcompat:appcompat:1.0.0' + implementation 'com.google.android.material:material:1.0.0' + implementation 'androidx.preference:preference:1.0.0' + implementation 'androidx.cardview:cardview:1.0.0' // Used for the list preference classes implementation 'com.afollestad.material-dialogs:core:0.9.6.0' implementation 'com.afollestad.material-dialogs:commons:0.9.6.0' diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/ATH.java b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/ATH.java index f6f7957b..a563fae4 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/ATH.java +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/ATH.java @@ -1,122 +1,122 @@ package code.name.monkey.appthemehelper; -import static android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; - import android.annotation.SuppressLint; import android.app.Activity; import android.app.ActivityManager; import android.content.Context; import android.os.Build; +import android.view.View; + import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.Toolbar; -import android.view.View; import code.name.monkey.appthemehelper.util.ColorUtil; import code.name.monkey.appthemehelper.util.TintHelper; import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper; +import static android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; + /** * @author Karim Abou Zeid (kabouzeid) */ public final class ATH { - private ATH() { - } - - @SuppressLint("CommitPrefEdits") - public static boolean didThemeValuesChange(@NonNull Context context, long since) { - return ThemeStore.isConfigured(context) - && ThemeStore.prefs(context).getLong(ThemeStore.VALUES_CHANGED, -1) > since; - } - - public static void setStatusbarColorAuto(Activity activity) { - setStatusbarColor(activity, ThemeStore.statusBarColor(activity)); - } - - public static void setStatusbarColor(Activity activity, int color) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - activity.getWindow().setStatusBarColor(color); - setLightStatusbarAuto(activity, color); + private ATH() { } - } - public static void setLightStatusbarAuto(Activity activity, int bgColor) { - setLightStatusbar(activity, ColorUtil.isColorLight(bgColor)); - } - - public static void setLightStatusbar(Activity activity, boolean enabled) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - final View decorView = activity.getWindow().getDecorView(); - final int systemUiVisibility = decorView.getSystemUiVisibility(); - if (enabled) { - decorView.setSystemUiVisibility(systemUiVisibility | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); - } else { - decorView.setSystemUiVisibility(systemUiVisibility & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); - } + @SuppressLint("CommitPrefEdits") + public static boolean didThemeValuesChange(@NonNull Context context, long since) { + return ThemeStore.isConfigured(context) + && ThemeStore.prefs(context).getLong(ThemeStore.VALUES_CHANGED, -1) > since; } - } - public static void setLightNavigationbar(Activity activity, boolean enabled) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - final View decorView = activity.getWindow().getDecorView(); - int systemUiVisibility = decorView.getSystemUiVisibility(); - if (enabled) { - systemUiVisibility |= SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; - } else { - systemUiVisibility &= ~SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; - } - decorView.setSystemUiVisibility(systemUiVisibility); + public static void setStatusbarColorAuto(Activity activity) { + setStatusbarColor(activity, ThemeStore.statusBarColor(activity)); } - } - public static void setLightNavigationbarAuto(Activity activity, int bgColor) { - setLightNavigationbar(activity, ColorUtil.isColorLight(bgColor)); - } - - public static void setNavigationbarColorAuto(Activity activity) { - setNavigationbarColor(activity, ThemeStore.navigationBarColor(activity)); - } - - public static void setNavigationbarColor(Activity activity, int color) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - activity.getWindow().setNavigationBarColor(color); - setLightNavigationbarAuto(activity, color); + public static void setStatusbarColor(Activity activity, int color) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + activity.getWindow().setStatusBarColor(color); + setLightStatusbarAuto(activity, color); + } } - } - public static void setActivityToolbarColorAuto(Activity activity, @Nullable Toolbar toolbar) { - setActivityToolbarColor(activity, toolbar, ThemeStore.primaryColor(activity)); - } - - public static void setActivityToolbarColor(Activity activity, @Nullable Toolbar toolbar, - int color) { - if (toolbar == null) { - return; + public static void setLightStatusbarAuto(Activity activity, int bgColor) { + setLightStatusbar(activity, ColorUtil.isColorLight(bgColor)); } - toolbar.setBackgroundColor(color); - ToolbarContentTintHelper.setToolbarContentColorBasedOnToolbarColor(activity, toolbar, color); - } - public static void setTaskDescriptionColorAuto(@NonNull Activity activity) { - setTaskDescriptionColor(activity, ThemeStore.primaryColor(activity)); - } - - public static void setTaskDescriptionColor(@NonNull Activity activity, @ColorInt int color) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - // Task description requires fully opaque color - color = ColorUtil.stripAlpha(color); - // Sets color of entry in the system recents page - activity.setTaskDescription( - new ActivityManager.TaskDescription((String) activity.getTitle(), null, color)); + public static void setLightStatusbar(Activity activity, boolean enabled) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + final View decorView = activity.getWindow().getDecorView(); + final int systemUiVisibility = decorView.getSystemUiVisibility(); + if (enabled) { + decorView.setSystemUiVisibility(systemUiVisibility | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); + } else { + decorView.setSystemUiVisibility(systemUiVisibility & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); + } + } } - } - public static void setTint(@NonNull View view, @ColorInt int color) { - TintHelper.setTintAuto(view, color, false); - } + public static void setLightNavigationbar(Activity activity, boolean enabled) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + final View decorView = activity.getWindow().getDecorView(); + int systemUiVisibility = decorView.getSystemUiVisibility(); + if (enabled) { + systemUiVisibility |= SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; + } else { + systemUiVisibility &= ~SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; + } + decorView.setSystemUiVisibility(systemUiVisibility); + } + } - public static void setBackgroundTint(@NonNull View view, @ColorInt int color) { - TintHelper.setTintAuto(view, color, true); - } + public static void setLightNavigationbarAuto(Activity activity, int bgColor) { + setLightNavigationbar(activity, ColorUtil.isColorLight(bgColor)); + } + + public static void setNavigationbarColorAuto(Activity activity) { + setNavigationbarColor(activity, ThemeStore.navigationBarColor(activity)); + } + + public static void setNavigationbarColor(Activity activity, int color) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + activity.getWindow().setNavigationBarColor(color); + setLightNavigationbarAuto(activity, color); + } + } + + public static void setActivityToolbarColorAuto(Activity activity, @Nullable Toolbar toolbar) { + setActivityToolbarColor(activity, toolbar, ThemeStore.primaryColor(activity)); + } + + public static void setActivityToolbarColor(Activity activity, @Nullable Toolbar toolbar, + int color) { + if (toolbar == null) { + return; + } + toolbar.setBackgroundColor(color); + ToolbarContentTintHelper.setToolbarContentColorBasedOnToolbarColor(activity, toolbar, color); + } + + public static void setTaskDescriptionColorAuto(@NonNull Activity activity) { + setTaskDescriptionColor(activity, ThemeStore.primaryColor(activity)); + } + + public static void setTaskDescriptionColor(@NonNull Activity activity, @ColorInt int color) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + // Task description requires fully opaque color + color = ColorUtil.stripAlpha(color); + // Sets color of entry in the system recents page + activity.setTaskDescription(new ActivityManager.TaskDescription((String) activity.getTitle(), null, color)); + } + } + + public static void setTint(@NonNull View view, @ColorInt int color) { + TintHelper.setTintAuto(view, color, false); + } + + public static void setBackgroundTint(@NonNull View view, @ColorInt int color) { + TintHelper.setTintAuto(view, color, true); + } } \ No newline at end of file diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/ATHActivity.java b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/ATHActivity.java index 5849f131..67d3f4ce 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/ATHActivity.java +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/ATHActivity.java @@ -1,7 +1,9 @@ package code.name.monkey.appthemehelper; +import android.content.Intent; import android.os.Bundle; import android.os.Handler; + import androidx.annotation.StyleRes; import androidx.appcompat.app.AppCompatActivity; diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/MaterialUtil.java b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/MaterialUtil.java new file mode 100644 index 00000000..e7ccf0b2 --- /dev/null +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/MaterialUtil.java @@ -0,0 +1,56 @@ +package code.name.monkey.appthemehelper.util; + +import android.content.Context; +import android.content.res.ColorStateList; +import android.graphics.Typeface; + +import com.google.android.material.button.MaterialButton; +import com.google.android.material.textfield.TextInputLayout; + +import androidx.annotation.NonNull; +import androidx.core.content.res.ResourcesCompat; +import code.name.monkey.appthemehelper.R; +import code.name.monkey.appthemehelper.ThemeStore; + +public class MaterialUtil { + public static void setTint(@NonNull MaterialButton button, boolean background) { + setTint(button, background, ThemeStore.accentColor(button.getContext())); + } + + public static void setTint(@NonNull MaterialButton button, boolean background, int color) { + button.setPadding(48, 48, 48, 48); + button.setAllCaps(false); + final Context context = button.getContext(); + final ColorStateList colorState = ColorStateList.valueOf(color); + final ColorStateList textColor = ColorStateList.valueOf(MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(color))); + + + if (background) { + button.setBackgroundTintList(colorState); + button.setTextColor(textColor); + button.setIconTint(textColor); + } else { + button.setStrokeColor(colorState); + button.setTextColor(colorState); + button.setIconTint(colorState); + } + + Typeface font = ResourcesCompat.getFont(button.getContext(), R.font.product_sans); + button.setTypeface(font); + + } + + public static void setTint(TextInputLayout textInputLayout, boolean background) { + final Context context = textInputLayout.getContext(); + final int accentColor = ThemeStore.accentColor(context); + final ColorStateList colorState = ColorStateList.valueOf(accentColor); + + if (background) { + textInputLayout.setBackgroundTintList(colorState); + textInputLayout.setDefaultHintTextColor(colorState); + } else { + textInputLayout.setBoxStrokeColor(accentColor); + textInputLayout.setDefaultHintTextColor(colorState); + } + } +} diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/TintHelper.java b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/TintHelper.java index 089a8654..82911a91 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/TintHelper.java +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/TintHelper.java @@ -7,15 +7,6 @@ import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.graphics.drawable.RippleDrawable; import android.os.Build; -import androidx.annotation.CheckResult; -import androidx.annotation.ColorInt; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import com.google.android.material.floatingactionbutton.FloatingActionButton; -import androidx.core.content.ContextCompat; -import androidx.core.graphics.drawable.DrawableCompat; -import androidx.appcompat.widget.AppCompatEditText; -import androidx.appcompat.widget.SwitchCompat; import android.view.View; import android.widget.Button; import android.widget.CheckBox; @@ -27,10 +18,20 @@ import android.widget.SeekBar; import android.widget.Switch; import android.widget.TextView; -import code.name.monkey.appthemehelper.R; +import com.google.android.material.floatingactionbutton.FloatingActionButton; import java.lang.reflect.Field; +import androidx.annotation.CheckResult; +import androidx.annotation.ColorInt; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatEditText; +import androidx.appcompat.widget.SwitchCompat; +import androidx.core.content.ContextCompat; +import androidx.core.graphics.drawable.DrawableCompat; +import code.name.monkey.appthemehelper.R; + /** * @author afollestad, plusCubed */ @@ -154,8 +155,7 @@ public final class TintHelper { !background && view.getBackground() instanceof RippleDrawable) { // Ripples for the above views (e.g. when you tap and hold a switch or checkbox) RippleDrawable rd = (RippleDrawable) view.getBackground(); - @SuppressLint("PrivateResource") - final int unchecked = ContextCompat.getColor(view.getContext(), + @SuppressLint("PrivateResource") final int unchecked = ContextCompat.getColor(view.getContext(), isDark ? R.color.ripple_material_dark : R.color.ripple_material_light); final int checked = ColorUtil.adjustAlpha(color, 0.4f); final ColorStateList sl = new ColorStateList( @@ -187,6 +187,7 @@ public final class TintHelper { } } + public static void setTint(@NonNull RadioButton radioButton, @ColorInt int color, boolean useDarker) { ColorStateList sl = new ColorStateList(new int[][]{ new int[]{-android.R.attr.state_enabled}, diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/ToolbarContentTintHelper.java b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/ToolbarContentTintHelper.java index 06f172e4..a0bb894c 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/ToolbarContentTintHelper.java +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/ToolbarContentTintHelper.java @@ -6,11 +6,25 @@ import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; import android.os.Build; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewTreeObserver; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.ListView; +import android.widget.RadioButton; + +import java.lang.reflect.Field; +import java.util.ArrayList; + import androidx.annotation.CheckResult; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.core.graphics.drawable.DrawableCompat; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.WindowDecorActionBar; import androidx.appcompat.view.menu.ActionMenuItemView; @@ -24,528 +38,527 @@ import androidx.appcompat.widget.ActionMenuView; import androidx.appcompat.widget.AppCompatImageView; import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.ToolbarWidgetWrapper; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewTreeObserver; -import android.widget.CheckBox; -import android.widget.EditText; -import android.widget.ImageButton; -import android.widget.ImageView; -import android.widget.ListView; -import android.widget.RadioButton; +import androidx.core.graphics.drawable.DrawableCompat; import code.name.monkey.appthemehelper.R; import code.name.monkey.appthemehelper.ThemeStore; -import java.lang.reflect.Field; -import java.util.ArrayList; public final class ToolbarContentTintHelper { - private ToolbarContentTintHelper() { - } - /** - * Use this method to colorize toolbar icons to the desired target color - * - * @param toolbarView toolbar view being colored - * @param toolbarIconsColor the target color of toolbar icons - * @param activity reference to activity needed to register observers - */ - public static void colorizeToolbar(Toolbar toolbarView, int toolbarIconsColor, - Activity activity) { - final PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(toolbarIconsColor, - PorterDuff.Mode.MULTIPLY); + private ToolbarContentTintHelper() { + } - for (int i = 0; i < toolbarView.getChildCount(); i++) { - final View v = toolbarView.getChildAt(i); - - //Step 1 : Changing the color of back button (or open drawer button). - if (v instanceof ImageButton) { - //Action Bar back button - ((ImageButton) v).getDrawable().setColorFilter(colorFilter); - } - - if (v instanceof ActionMenuView) { - for (int j = 0; j < ((ActionMenuView) v).getChildCount(); j++) { - - //Step 2: Changing the color of any ActionMenuViews - icons that are not back button, nor text, nor overflow menu icon. - //Colorize the ActionViews -> all icons that are NOT: back button | overflow menu - final View innerView = ((ActionMenuView) v).getChildAt(j); - if (innerView instanceof ActionMenuItemView) { - for (int k = 0; k < ((ActionMenuItemView) innerView).getCompoundDrawables().length; - k++) { - if (((ActionMenuItemView) innerView).getCompoundDrawables()[k] != null) { - final int finalK = k; - - //Important to set the color filter in seperate thread, by adding it to the message queue - //Won't work otherwise. - innerView.post(new Runnable() { - @Override - public void run() { - ((ActionMenuItemView) innerView).getCompoundDrawables()[finalK] - .setColorFilter(colorFilter); - } - }); - } + public static void colorBackButton(Toolbar toolbar, @ColorInt int color) { + final PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY); + for (int i = 0; i < toolbar.getChildCount(); i++) { + final View backButton = toolbar.getChildAt(i); + if (backButton instanceof ImageButton) { + ((ImageButton) backButton).getDrawable().setColorFilter(colorFilter); } - } } - } - - //Step 3: Changing the color of title and subtitle. - toolbarView.setTitleTextColor(ThemeStore.textColorPrimary(activity)); - toolbarView.setSubtitleTextColor(ThemeStore.textColorSecondary(activity)); - - //Step 4: Changing the color of the Overflow Menu icon. - setOverflowButtonColor(activity, toolbarView, toolbarIconsColor); } - } - /** - * It's important to set overflowDescription atribute in styles, so we can grab the reference to - * the overflow icon. Check: res/values/styles.xml - */ - private static void setOverflowButtonColor(final Activity activity, - final PorterDuffColorFilter colorFilter) { - final String overflowDescription = activity - .getString(R.string.abc_action_menu_overflow_description); - final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); - final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver(); - viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - final ArrayList outViews = new ArrayList(); - decorView.findViewsWithText(outViews, overflowDescription, - View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION); - if (outViews.isEmpty()) { - return; + /** + * Use this method to colorize toolbar icons to the desired target color + * + * @param toolbarView toolbar view being colored + * @param toolbarIconsColor the target color of toolbar icons + * @param activity reference to activity needed to register observers + */ + public static void colorizeToolbar(Toolbar toolbarView, int toolbarIconsColor, + Activity activity) { + final PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(toolbarIconsColor, + PorterDuff.Mode.MULTIPLY); + + for (int i = 0; i < toolbarView.getChildCount(); i++) { + final View v = toolbarView.getChildAt(i); + + //Step 1 : Changing the color of back button (or open drawer button). + if (v instanceof ImageButton) { + //Action Bar back button + ((ImageButton) v).getDrawable().setColorFilter(colorFilter); + } + + if (v instanceof ActionMenuView) { + for (int j = 0; j < ((ActionMenuView) v).getChildCount(); j++) { + + //Step 2: Changing the color of any ActionMenuViews - icons that are not back button, nor text, nor overflow menu icon. + //Colorize the ActionViews -> all icons that are NOT: back button | overflow menu + final View innerView = ((ActionMenuView) v).getChildAt(j); + if (innerView instanceof ActionMenuItemView) { + for (int k = 0; k < ((ActionMenuItemView) innerView).getCompoundDrawables().length; + k++) { + if (((ActionMenuItemView) innerView).getCompoundDrawables()[k] != null) { + final int finalK = k; + + //Important to set the color filter in seperate thread, by adding it to the message queue + //Won't work otherwise. + innerView.post(new Runnable() { + @Override + public void run() { + ((ActionMenuItemView) innerView).getCompoundDrawables()[finalK] + .setColorFilter(colorFilter); + } + }); + } + } + } + } + } + + //Step 3: Changing the color of title and subtitle. + toolbarView.setTitleTextColor(ThemeStore.textColorPrimary(activity)); + toolbarView.setSubtitleTextColor(ThemeStore.textColorSecondary(activity)); + + //Step 4: Changing the color of the Overflow Menu icon. + setOverflowButtonColor(activity, toolbarView, toolbarIconsColor); } - final ActionMenuView overflowViewParent = (ActionMenuView) outViews.get(0).getParent(); - overflowViewParent.getOverflowIcon().setColorFilter(colorFilter); - removeOnGlobalLayoutListener(decorView, this); - } - }); - } - - private static void setOverflowButtonColor(final Activity activity, final Toolbar toolbar, - final int toolbarIconsColor) { - final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); - final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver(); - viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - - if (toolbar != null && toolbar.getOverflowIcon() != null) { - Drawable bg = DrawableCompat.wrap(toolbar.getOverflowIcon()); - DrawableCompat.setTint(bg, toolbarIconsColor); - } - removeOnGlobalLayoutListener(decorView, this); - } - }); - } - - private static void removeOnGlobalLayoutListener(View v, - ViewTreeObserver.OnGlobalLayoutListener listener) { - v.getViewTreeObserver().removeOnGlobalLayoutListener(listener); - } - - public static void setToolbarContentColorBasedOnToolbarColor(@NonNull Context context, - Toolbar toolbar, int toolbarColor) { - setToolbarContentColorBasedOnToolbarColor(context, toolbar, null, toolbarColor); - } - - public static void setToolbarContentColorBasedOnToolbarColor(@NonNull Context context, - Toolbar toolbar, @Nullable Menu menu, int toolbarColor) { - setToolbarContentColorBasedOnToolbarColor(context, toolbar, menu, toolbarColor, - ThemeStore.accentColor(context)); - } - - public static void setToolbarContentColorBasedOnToolbarColor(@NonNull Context context, - Toolbar toolbar, @Nullable Menu menu, int toolbarColor, final @ColorInt int menuWidgetColor) { - setToolbarContentColor(context, toolbar, menu, toolbarContentColor(context, toolbarColor), - toolbarTitleColor(context, toolbarColor), toolbarSubtitleColor(context, toolbarColor), - menuWidgetColor); - } - - public static void setToolbarContentColor(@NonNull Context context, Toolbar toolbar, - final @ColorInt int toolbarContentColor, final @ColorInt int primaryTextColor, - final @ColorInt int secondaryTextColor, final @ColorInt int menuWidgetColor) { - setToolbarContentColor(context, toolbar, null, toolbarContentColor, primaryTextColor, - secondaryTextColor, menuWidgetColor); - } - - @SuppressWarnings("unchecked") - public static void setToolbarContentColor(@NonNull Context context, Toolbar toolbar, - @Nullable Menu menu, final @ColorInt int toolbarContentColor, - final @ColorInt int titleTextColor, final @ColorInt int subtitleTextColor, - final @ColorInt int menuWidgetColor) { - if (toolbar == null) { - return; } - if (menu == null) { - menu = toolbar.getMenu(); + /** + * It's important to set overflowDescription atribute in styles, so we can grab the reference to + * the overflow icon. Check: res/values/styles.xml + */ + private static void setOverflowButtonColor(final Activity activity, + final PorterDuffColorFilter colorFilter) { + final String overflowDescription = activity + .getString(R.string.abc_action_menu_overflow_description); + final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); + final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver(); + viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + final ArrayList outViews = new ArrayList(); + decorView.findViewsWithText(outViews, overflowDescription, + View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION); + if (outViews.isEmpty()) { + return; + } + final ActionMenuView overflowViewParent = (ActionMenuView) outViews.get(0).getParent(); + overflowViewParent.getOverflowIcon().setColorFilter(colorFilter); + removeOnGlobalLayoutListener(decorView, this); + } + }); } - toolbar.setTitleTextColor(titleTextColor); - toolbar.setSubtitleTextColor(subtitleTextColor); + private static void setOverflowButtonColor(final Activity activity, final Toolbar toolbar, + final int toolbarIconsColor) { + final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); + final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver(); + viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { - if (toolbar.getNavigationIcon() != null) { - // Tint the toolbar navigation icon (e.g. back, drawer, etc.) - toolbar.setNavigationIcon( - TintHelper.createTintedDrawable(toolbar.getNavigationIcon(), toolbarContentColor)); + if (toolbar != null && toolbar.getOverflowIcon() != null) { + Drawable bg = DrawableCompat.wrap(toolbar.getOverflowIcon()); + DrawableCompat.setTint(bg, toolbarIconsColor); + } + removeOnGlobalLayoutListener(decorView, this); + } + }); } - InternalToolbarContentTintUtil.tintMenu(toolbar, menu, toolbarContentColor); - InternalToolbarContentTintUtil.applyOverflowMenuTint(context, toolbar, menuWidgetColor); - - if (context instanceof Activity) { - InternalToolbarContentTintUtil - .setOverflowButtonColor((Activity) context, toolbarContentColor); + private static void removeOnGlobalLayoutListener(View v, + ViewTreeObserver.OnGlobalLayoutListener listener) { + v.getViewTreeObserver().removeOnGlobalLayoutListener(listener); } - try { - // Tint immediate overflow menu items - final Field menuField = Toolbar.class.getDeclaredField("mMenuBuilderCallback"); - menuField.setAccessible(true); - final Field presenterField = Toolbar.class.getDeclaredField("mActionMenuPresenterCallback"); - presenterField.setAccessible(true); - final Field menuViewField = Toolbar.class.getDeclaredField("mMenuView"); - menuViewField.setAccessible(true); - - final MenuPresenter.Callback currentPresenterCb = (MenuPresenter.Callback) presenterField - .get(toolbar); - if (!(currentPresenterCb instanceof ATHMenuPresenterCallback)) { - final ATHMenuPresenterCallback newPresenterCb = new ATHMenuPresenterCallback(context, - menuWidgetColor, currentPresenterCb, toolbar); - final MenuBuilder.Callback currentMenuCb = (MenuBuilder.Callback) menuField.get(toolbar); - toolbar.setMenuCallbacks(newPresenterCb, currentMenuCb); - ActionMenuView menuView = (ActionMenuView) menuViewField.get(toolbar); - if (menuView != null) { - menuView.setMenuCallbacks(newPresenterCb, currentMenuCb); - } - } - - // OnMenuItemClickListener to tint submenu items - final Field menuItemClickListener = Toolbar.class - .getDeclaredField("mOnMenuItemClickListener"); - menuItemClickListener.setAccessible(true); - Toolbar.OnMenuItemClickListener currentClickListener = (Toolbar.OnMenuItemClickListener) menuItemClickListener - .get(toolbar); - if (!(currentClickListener instanceof ATHOnMenuItemClickListener)) { - final ATHOnMenuItemClickListener newClickListener = new ATHOnMenuItemClickListener(context, - menuWidgetColor, currentClickListener, toolbar); - toolbar.setOnMenuItemClickListener(newClickListener); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Nullable - public static Toolbar getSupportActionBarView(@Nullable ActionBar ab) { - if (ab == null || !(ab instanceof WindowDecorActionBar)) { - return null; - } - try { - WindowDecorActionBar decorAb = (WindowDecorActionBar) ab; - Field field = WindowDecorActionBar.class.getDeclaredField("mDecorToolbar"); - field.setAccessible(true); - ToolbarWidgetWrapper wrapper = (ToolbarWidgetWrapper) field.get(decorAb); - field = ToolbarWidgetWrapper.class.getDeclaredField("mToolbar"); - field.setAccessible(true); - return (Toolbar) field.get(wrapper); - } catch (Throwable t) { - throw new RuntimeException( - "Failed to retrieve Toolbar from AppCompat support ActionBar: " + t.getMessage(), t); - } - } - - public static void handleOnPrepareOptionsMenu(Activity activity, Toolbar toolbar) { - handleOnPrepareOptionsMenu(activity, toolbar, ThemeStore.accentColor(activity)); - } - - public static void handleOnPrepareOptionsMenu(Activity activity, Toolbar toolbar, - int widgetColor) { - InternalToolbarContentTintUtil.applyOverflowMenuTint(activity, toolbar, widgetColor); - } - - public static void handleOnCreateOptionsMenu(Context context, Toolbar toolbar, Menu menu, - int toolbarColor) { - setToolbarContentColorBasedOnToolbarColor(context, toolbar, menu, toolbarColor); - } - - public static void handleOnCreateOptionsMenu(Context context, Toolbar toolbar, Menu menu, - @ColorInt int toolbarContentColor, @ColorInt int titleTextColor, - @ColorInt int subtitleTextColor, @ColorInt int menuWidgetColor) { - setToolbarContentColor(context, toolbar, menu, toolbarContentColor, titleTextColor, - subtitleTextColor, menuWidgetColor); - } - - @CheckResult - @ColorInt - public static int toolbarContentColor(@NonNull Context context, @ColorInt int toolbarColor) { - if (ColorUtil.isColorLight(toolbarColor)) { - return toolbarSubtitleColor(context, toolbarColor); - } - return toolbarTitleColor(context, toolbarColor); - } - - @CheckResult - @ColorInt - public static int toolbarSubtitleColor(@NonNull Context context, @ColorInt int toolbarColor) { - return MaterialValueHelper.getSecondaryTextColor(context, ColorUtil.isColorLight(toolbarColor)); - } - - @CheckResult - @ColorInt - public static int toolbarTitleColor(@NonNull Context context, @ColorInt int toolbarColor) { - return MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(toolbarColor)); - } - - private static class ATHMenuPresenterCallback implements MenuPresenter.Callback { - - private Context mContext; - private int mColor; - private MenuPresenter.Callback mParentCb; - private Toolbar mToolbar; - - public ATHMenuPresenterCallback(Context context, final @ColorInt int color, - MenuPresenter.Callback parentCb, Toolbar toolbar) { - mContext = context; - mColor = color; - mParentCb = parentCb; - mToolbar = toolbar; + public static void setToolbarContentColorBasedOnToolbarColor(@NonNull Context context, + Toolbar toolbar, int toolbarColor) { + setToolbarContentColorBasedOnToolbarColor(context, toolbar, null, toolbarColor); } - @Override - public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { - if (mParentCb != null) { - mParentCb.onCloseMenu(menu, allMenusAreClosing); - } + public static void setToolbarContentColorBasedOnToolbarColor(@NonNull Context context, + Toolbar toolbar, @Nullable Menu menu, int toolbarColor) { + setToolbarContentColorBasedOnToolbarColor(context, toolbar, menu, toolbarColor, + ThemeStore.accentColor(context)); } - @Override - public boolean onOpenSubMenu(MenuBuilder subMenu) { - InternalToolbarContentTintUtil.applyOverflowMenuTint(mContext, mToolbar, mColor); - return mParentCb != null && mParentCb.onOpenSubMenu(subMenu); - } - } - - private static class ATHOnMenuItemClickListener implements Toolbar.OnMenuItemClickListener { - - private Context mContext; - private int mColor; - private Toolbar.OnMenuItemClickListener mParentListener; - private Toolbar mToolbar; - - public ATHOnMenuItemClickListener(Context context, final @ColorInt int color, - Toolbar.OnMenuItemClickListener parentCb, Toolbar toolbar) { - mContext = context; - mColor = color; - mParentListener = parentCb; - mToolbar = toolbar; + public static void setToolbarContentColorBasedOnToolbarColor(@NonNull Context context, + Toolbar toolbar, @Nullable Menu menu, int toolbarColor, final @ColorInt int menuWidgetColor) { + setToolbarContentColor(context, toolbar, menu, toolbarContentColor(context, toolbarColor), + toolbarTitleColor(context, toolbarColor), toolbarSubtitleColor(context, toolbarColor), + menuWidgetColor); } - @Override - public boolean onMenuItemClick(MenuItem item) { - InternalToolbarContentTintUtil.applyOverflowMenuTint(mContext, mToolbar, mColor); - return mParentListener != null && mParentListener.onMenuItemClick(item); - } - } - - public static class InternalToolbarContentTintUtil { - - private InternalToolbarContentTintUtil() { + public static void setToolbarContentColor(@NonNull Context context, Toolbar toolbar, + final @ColorInt int toolbarContentColor, final @ColorInt int primaryTextColor, + final @ColorInt int secondaryTextColor, final @ColorInt int menuWidgetColor) { + setToolbarContentColor(context, toolbar, null, toolbarContentColor, primaryTextColor, + secondaryTextColor, menuWidgetColor); } @SuppressWarnings("unchecked") - public static void tintMenu(@NonNull Toolbar toolbar, @Nullable Menu menu, - final @ColorInt int color) { - try { - final Field field = Toolbar.class.getDeclaredField("mCollapseIcon"); - field.setAccessible(true); - Drawable collapseIcon = (Drawable) field.get(toolbar); - if (collapseIcon != null) { - field.set(toolbar, TintHelper.createTintedDrawable(collapseIcon, color)); + public static void setToolbarContentColor(@NonNull Context context, Toolbar toolbar, + @Nullable Menu menu, final @ColorInt int toolbarContentColor, + final @ColorInt int titleTextColor, final @ColorInt int subtitleTextColor, + final @ColorInt int menuWidgetColor) { + if (toolbar == null) { + return; } - } catch (Exception e) { - e.printStackTrace(); - } - if (menu != null && menu.size() > 0) { - for (int i = 0; i < menu.size(); i++) { - final MenuItem item = menu.getItem(i); - if (item.getIcon() != null) { - item.setIcon(TintHelper.createTintedDrawable(item.getIcon(), color)); - } - // Search view theming - if (item.getActionView() != null && ( - item.getActionView() instanceof android.widget.SearchView || item - .getActionView() instanceof androidx.appcompat.widget.SearchView)) { - SearchViewTintUtil.setSearchViewContentColor(item.getActionView(), color); - } + if (menu == null) { + menu = toolbar.getMenu(); } - } - } - public static void applyOverflowMenuTint(final @NonNull Context context, final Toolbar toolbar, - final @ColorInt int color) { - if (toolbar == null) { - return; - } - toolbar.post(new Runnable() { - @Override - public void run() { - try { - Field f1 = Toolbar.class.getDeclaredField("mMenuView"); - f1.setAccessible(true); - ActionMenuView actionMenuView = (ActionMenuView) f1.get(toolbar); - Field f2 = ActionMenuView.class.getDeclaredField("mPresenter"); - f2.setAccessible(true); + toolbar.setTitleTextColor(titleTextColor); + toolbar.setSubtitleTextColor(subtitleTextColor); - // Actually ActionMenuPresenter - BaseMenuPresenter presenter = (BaseMenuPresenter) f2.get(actionMenuView); - Field f3 = presenter.getClass().getDeclaredField("mOverflowPopup"); - f3.setAccessible(true); - MenuPopupHelper overflowMenuPopupHelper = (MenuPopupHelper) f3.get(presenter); - setTintForMenuPopupHelper(context, overflowMenuPopupHelper, color); + if (toolbar.getNavigationIcon() != null) { + // Tint the toolbar navigation icon (e.g. back, drawer, etc.) + toolbar.setNavigationIcon( + TintHelper.createTintedDrawable(toolbar.getNavigationIcon(), toolbarContentColor)); + } - Field f4 = presenter.getClass().getDeclaredField("mActionButtonPopup"); - f4.setAccessible(true); - MenuPopupHelper subMenuPopupHelper = (MenuPopupHelper) f4.get(presenter); - setTintForMenuPopupHelper(context, subMenuPopupHelper, color); - } catch (Exception e) { + InternalToolbarContentTintUtil.tintMenu(toolbar, menu, toolbarContentColor); + InternalToolbarContentTintUtil.applyOverflowMenuTint(context, toolbar, menuWidgetColor); + + if (context instanceof Activity) { + InternalToolbarContentTintUtil + .setOverflowButtonColor((Activity) context, toolbarContentColor); + } + + try { + // Tint immediate overflow menu items + final Field menuField = Toolbar.class.getDeclaredField("mMenuBuilderCallback"); + menuField.setAccessible(true); + final Field presenterField = Toolbar.class.getDeclaredField("mActionMenuPresenterCallback"); + presenterField.setAccessible(true); + final Field menuViewField = Toolbar.class.getDeclaredField("mMenuView"); + menuViewField.setAccessible(true); + + final MenuPresenter.Callback currentPresenterCb = (MenuPresenter.Callback) presenterField + .get(toolbar); + if (!(currentPresenterCb instanceof ATHMenuPresenterCallback)) { + final ATHMenuPresenterCallback newPresenterCb = new ATHMenuPresenterCallback(context, + menuWidgetColor, currentPresenterCb, toolbar); + final MenuBuilder.Callback currentMenuCb = (MenuBuilder.Callback) menuField.get(toolbar); + toolbar.setMenuCallbacks(newPresenterCb, currentMenuCb); + ActionMenuView menuView = (ActionMenuView) menuViewField.get(toolbar); + if (menuView != null) { + menuView.setMenuCallbacks(newPresenterCb, currentMenuCb); + } + } + + // OnMenuItemClickListener to tint submenu items + final Field menuItemClickListener = Toolbar.class + .getDeclaredField("mOnMenuItemClickListener"); + menuItemClickListener.setAccessible(true); + Toolbar.OnMenuItemClickListener currentClickListener = (Toolbar.OnMenuItemClickListener) menuItemClickListener + .get(toolbar); + if (!(currentClickListener instanceof ATHOnMenuItemClickListener)) { + final ATHOnMenuItemClickListener newClickListener = new ATHOnMenuItemClickListener(context, + menuWidgetColor, currentClickListener, toolbar); + toolbar.setOnMenuItemClickListener(newClickListener); + } + } catch (Exception e) { e.printStackTrace(); - } } - }); } - public static void setTintForMenuPopupHelper(final @NonNull Context context, - @Nullable MenuPopupHelper menuPopupHelper, final @ColorInt int color) { - try { - if (menuPopupHelper != null) { - final ListView listView = ((ShowableListMenu) menuPopupHelper.getPopup()).getListView(); - listView.getViewTreeObserver() - .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Nullable + public static Toolbar getSupportActionBarView(@Nullable ActionBar ab) { + if (ab == null || !(ab instanceof WindowDecorActionBar)) { + return null; + } + try { + WindowDecorActionBar decorAb = (WindowDecorActionBar) ab; + Field field = WindowDecorActionBar.class.getDeclaredField("mDecorToolbar"); + field.setAccessible(true); + ToolbarWidgetWrapper wrapper = (ToolbarWidgetWrapper) field.get(decorAb); + field = ToolbarWidgetWrapper.class.getDeclaredField("mToolbar"); + field.setAccessible(true); + return (Toolbar) field.get(wrapper); + } catch (Throwable t) { + throw new RuntimeException( + "Failed to retrieve Toolbar from AppCompat support ActionBar: " + t.getMessage(), t); + } + } + + public static void handleOnPrepareOptionsMenu(Activity activity, Toolbar toolbar) { + handleOnPrepareOptionsMenu(activity, toolbar, ThemeStore.accentColor(activity)); + } + + public static void handleOnPrepareOptionsMenu(Activity activity, Toolbar toolbar, + int widgetColor) { + InternalToolbarContentTintUtil.applyOverflowMenuTint(activity, toolbar, widgetColor); + } + + public static void handleOnCreateOptionsMenu(Context context, Toolbar toolbar, Menu menu, + int toolbarColor) { + setToolbarContentColorBasedOnToolbarColor(context, toolbar, menu, toolbarColor); + } + + public static void handleOnCreateOptionsMenu(Context context, Toolbar toolbar, Menu menu, + @ColorInt int toolbarContentColor, @ColorInt int titleTextColor, + @ColorInt int subtitleTextColor, @ColorInt int menuWidgetColor) { + setToolbarContentColor(context, toolbar, menu, toolbarContentColor, titleTextColor, + subtitleTextColor, menuWidgetColor); + } + + @CheckResult + @ColorInt + public static int toolbarContentColor(@NonNull Context context, @ColorInt int toolbarColor) { + if (ColorUtil.isColorLight(toolbarColor)) { + return toolbarSubtitleColor(context, toolbarColor); + } + return toolbarTitleColor(context, toolbarColor); + } + + @CheckResult + @ColorInt + public static int toolbarSubtitleColor(@NonNull Context context, @ColorInt int toolbarColor) { + return MaterialValueHelper.getSecondaryTextColor(context, ColorUtil.isColorLight(toolbarColor)); + } + + @CheckResult + @ColorInt + public static int toolbarTitleColor(@NonNull Context context, @ColorInt int toolbarColor) { + return MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(toolbarColor)); + } + + private static class ATHMenuPresenterCallback implements MenuPresenter.Callback { + + private Context mContext; + private int mColor; + private MenuPresenter.Callback mParentCb; + private Toolbar mToolbar; + + public ATHMenuPresenterCallback(Context context, final @ColorInt int color, + MenuPresenter.Callback parentCb, Toolbar toolbar) { + mContext = context; + mColor = color; + mParentCb = parentCb; + mToolbar = toolbar; + } + + @Override + public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { + if (mParentCb != null) { + mParentCb.onCloseMenu(menu, allMenusAreClosing); + } + } + + @Override + public boolean onOpenSubMenu(MenuBuilder subMenu) { + InternalToolbarContentTintUtil.applyOverflowMenuTint(mContext, mToolbar, mColor); + return mParentCb != null && mParentCb.onOpenSubMenu(subMenu); + } + } + + private static class ATHOnMenuItemClickListener implements Toolbar.OnMenuItemClickListener { + + private Context mContext; + private int mColor; + private Toolbar.OnMenuItemClickListener mParentListener; + private Toolbar mToolbar; + + public ATHOnMenuItemClickListener(Context context, final @ColorInt int color, + Toolbar.OnMenuItemClickListener parentCb, Toolbar toolbar) { + mContext = context; + mColor = color; + mParentListener = parentCb; + mToolbar = toolbar; + } + + @Override + public boolean onMenuItemClick(MenuItem item) { + InternalToolbarContentTintUtil.applyOverflowMenuTint(mContext, mToolbar, mColor); + return mParentListener != null && mParentListener.onMenuItemClick(item); + } + } + + public static class InternalToolbarContentTintUtil { + + private InternalToolbarContentTintUtil() { + } + + @SuppressWarnings("unchecked") + public static void tintMenu(@NonNull Toolbar toolbar, @Nullable Menu menu, + final @ColorInt int color) { + try { + final Field field = Toolbar.class.getDeclaredField("mCollapseIcon"); + field.setAccessible(true); + Drawable collapseIcon = (Drawable) field.get(toolbar); + if (collapseIcon != null) { + field.set(toolbar, TintHelper.createTintedDrawable(collapseIcon, color)); + } + } catch (Exception e) { + e.printStackTrace(); + } + + if (menu != null && menu.size() > 0) { + for (int i = 0; i < menu.size(); i++) { + final MenuItem item = menu.getItem(i); + if (item.getIcon() != null) { + item.setIcon(TintHelper.createTintedDrawable(item.getIcon(), color)); + } + // Search view theming + if (item.getActionView() != null && ( + item.getActionView() instanceof android.widget.SearchView || item + .getActionView() instanceof androidx.appcompat.widget.SearchView)) { + SearchViewTintUtil.setSearchViewContentColor(item.getActionView(), color); + } + } + } + } + + public static void applyOverflowMenuTint(final @NonNull Context context, final Toolbar toolbar, + final @ColorInt int color) { + if (toolbar == null) { + return; + } + toolbar.post(new Runnable() { + @Override + public void run() { + try { + Field f1 = Toolbar.class.getDeclaredField("mMenuView"); + f1.setAccessible(true); + ActionMenuView actionMenuView = (ActionMenuView) f1.get(toolbar); + Field f2 = ActionMenuView.class.getDeclaredField("mPresenter"); + f2.setAccessible(true); + + // Actually ActionMenuPresenter + BaseMenuPresenter presenter = (BaseMenuPresenter) f2.get(actionMenuView); + Field f3 = presenter.getClass().getDeclaredField("mOverflowPopup"); + f3.setAccessible(true); + MenuPopupHelper overflowMenuPopupHelper = (MenuPopupHelper) f3.get(presenter); + setTintForMenuPopupHelper(context, overflowMenuPopupHelper, color); + + Field f4 = presenter.getClass().getDeclaredField("mActionButtonPopup"); + f4.setAccessible(true); + MenuPopupHelper subMenuPopupHelper = (MenuPopupHelper) f4.get(presenter); + setTintForMenuPopupHelper(context, subMenuPopupHelper, color); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + public static void setTintForMenuPopupHelper(final @NonNull Context context, + @Nullable MenuPopupHelper menuPopupHelper, final @ColorInt int color) { + try { + if (menuPopupHelper != null) { + final ListView listView = ((ShowableListMenu) menuPopupHelper.getPopup()).getListView(); + listView.getViewTreeObserver() + .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + try { + Field checkboxField = ListMenuItemView.class.getDeclaredField("mCheckBox"); + checkboxField.setAccessible(true); + Field radioButtonField = ListMenuItemView.class + .getDeclaredField("mRadioButton"); + radioButtonField.setAccessible(true); + + final boolean isDark = !ColorUtil.isColorLight( + ATHUtil.resolveColor(context, android.R.attr.windowBackground)); + + for (int i = 0; i < listView.getChildCount(); i++) { + View v = listView.getChildAt(i); + if (!(v instanceof ListMenuItemView)) { + continue; + } + ListMenuItemView iv = (ListMenuItemView) v; + + CheckBox check = (CheckBox) checkboxField.get(iv); + if (check != null) { + TintHelper.setTint(check, color, isDark); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + check.setBackground(null); + } + } + + RadioButton radioButton = (RadioButton) radioButtonField.get(iv); + if (radioButton != null) { + TintHelper.setTint(radioButton, color, isDark); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + radioButton.setBackground(null); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + listView.getViewTreeObserver().removeOnGlobalLayoutListener(this); + } else { + //noinspection deprecation + listView.getViewTreeObserver().removeGlobalOnLayoutListener(this); + } + } + }); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void setOverflowButtonColor(@NonNull Activity activity, + final @ColorInt int color) { + final String overflowDescription = activity + .getString(R.string.abc_action_menu_overflow_description); + final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); + final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver(); + viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { - try { - Field checkboxField = ListMenuItemView.class.getDeclaredField("mCheckBox"); - checkboxField.setAccessible(true); - Field radioButtonField = ListMenuItemView.class - .getDeclaredField("mRadioButton"); - radioButtonField.setAccessible(true); - - final boolean isDark = !ColorUtil.isColorLight( - ATHUtil.resolveColor(context, android.R.attr.windowBackground)); - - for (int i = 0; i < listView.getChildCount(); i++) { - View v = listView.getChildAt(i); - if (!(v instanceof ListMenuItemView)) { - continue; - } - ListMenuItemView iv = (ListMenuItemView) v; - - CheckBox check = (CheckBox) checkboxField.get(iv); - if (check != null) { - TintHelper.setTint(check, color, isDark); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - check.setBackground(null); - } - } - - RadioButton radioButton = (RadioButton) radioButtonField.get(iv); - if (radioButton != null) { - TintHelper.setTint(radioButton, color, isDark); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - radioButton.setBackground(null); - } - } + final ArrayList outViews = new ArrayList<>(); + decorView.findViewsWithText(outViews, overflowDescription, + View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION); + if (outViews.isEmpty()) { + return; } - } catch (Exception e) { - e.printStackTrace(); - } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - listView.getViewTreeObserver().removeOnGlobalLayoutListener(this); - } else { - //noinspection deprecation - listView.getViewTreeObserver().removeGlobalOnLayoutListener(this); - } + final AppCompatImageView overflow = (AppCompatImageView) outViews.get(0); + overflow.setImageDrawable(TintHelper.createTintedDrawable(overflow.getDrawable(), color)); + ViewUtil.removeOnGlobalLayoutListener(decorView, this); } - }); + }); + } + + public static final class SearchViewTintUtil { + + private SearchViewTintUtil() { + } + + private static void tintImageView(Object target, Field field, final @ColorInt int color) + throws Exception { + field.setAccessible(true); + final ImageView imageView = (ImageView) field.get(target); + if (imageView.getDrawable() != null) { + imageView + .setImageDrawable( + TintHelper.createTintedDrawable(imageView.getDrawable(), color)); + } + } + + public static void setSearchViewContentColor(View searchView, final @ColorInt int color) { + if (searchView == null) { + return; + } + final Class cls = searchView.getClass(); + try { + final Field mSearchSrcTextViewField = cls.getDeclaredField("mSearchSrcTextView"); + mSearchSrcTextViewField.setAccessible(true); + final EditText mSearchSrcTextView = (EditText) mSearchSrcTextViewField.get(searchView); + mSearchSrcTextView.setTextColor(color); + mSearchSrcTextView.setHintTextColor(ColorUtil.adjustAlpha(color, 0.5f)); + TintHelper.setCursorTint(mSearchSrcTextView, color); + + Field field = cls.getDeclaredField("mSearchButton"); + tintImageView(searchView, field, color); + field = cls.getDeclaredField("mGoButton"); + tintImageView(searchView, field, color); + field = cls.getDeclaredField("mCloseButton"); + tintImageView(searchView, field, color); + field = cls.getDeclaredField("mVoiceButton"); + tintImageView(searchView, field, color); + } catch (Exception e) { + e.printStackTrace(); + } + } } - } catch (Exception e) { - e.printStackTrace(); - } } - - public static void setOverflowButtonColor(@NonNull Activity activity, - final @ColorInt int color) { - final String overflowDescription = activity - .getString(R.string.abc_action_menu_overflow_description); - final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); - final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver(); - viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - final ArrayList outViews = new ArrayList<>(); - decorView.findViewsWithText(outViews, overflowDescription, - View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION); - if (outViews.isEmpty()) { - return; - } - final AppCompatImageView overflow = (AppCompatImageView) outViews.get(0); - overflow.setImageDrawable(TintHelper.createTintedDrawable(overflow.getDrawable(), color)); - ViewUtil.removeOnGlobalLayoutListener(decorView, this); - } - }); - } - - public static final class SearchViewTintUtil { - - private SearchViewTintUtil() { - } - - private static void tintImageView(Object target, Field field, final @ColorInt int color) - throws Exception { - field.setAccessible(true); - final ImageView imageView = (ImageView) field.get(target); - if (imageView.getDrawable() != null) { - imageView - .setImageDrawable( - TintHelper.createTintedDrawable(imageView.getDrawable(), color)); - } - } - - public static void setSearchViewContentColor(View searchView, final @ColorInt int color) { - if (searchView == null) { - return; - } - final Class cls = searchView.getClass(); - try { - final Field mSearchSrcTextViewField = cls.getDeclaredField("mSearchSrcTextView"); - mSearchSrcTextViewField.setAccessible(true); - final EditText mSearchSrcTextView = (EditText) mSearchSrcTextViewField.get(searchView); - mSearchSrcTextView.setTextColor(color); - mSearchSrcTextView.setHintTextColor(ColorUtil.adjustAlpha(color, 0.5f)); - TintHelper.setCursorTint(mSearchSrcTextView, color); - - Field field = cls.getDeclaredField("mSearchButton"); - tintImageView(searchView, field, color); - field = cls.getDeclaredField("mGoButton"); - tintImageView(searchView, field, color); - field = cls.getDeclaredField("mCloseButton"); - tintImageView(searchView, field, color); - field = cls.getDeclaredField("mVoiceButton"); - tintImageView(searchView, field, color); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - } } diff --git a/appthemehelper/src/main/res/font/product_sans.xml b/appthemehelper/src/main/res/font/product_sans.xml new file mode 100644 index 00000000..4ba80df6 --- /dev/null +++ b/appthemehelper/src/main/res/font/product_sans.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/appthemehelper/src/main/res/font/products_sans_regular.ttf b/appthemehelper/src/main/res/font/products_sans_regular.ttf new file mode 100755 index 00000000..c0442ee2 Binary files /dev/null and b/appthemehelper/src/main/res/font/products_sans_regular.ttf differ