-
+
-
+
@@ -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
- Fix: artist name on card theme
- Fix: dialog navigation icons colors
- Fix: album cover edit with last.fm for above Android 8.0
- Fix: adaptive controls for material theme
- Added: Now playing theme settings
- Added: home artists cover style(Settings-> Personalize-> Home artist grid)
- Added: now playing cover sliding style(Settings-> Now playing-> Now playing album
cover style)
- Added: now playing album cover style chooser(Settings->Now playing-> Album cover
theme)
- Added: extra controls toggle for mini player(Settings-> Now playing-> Extra controls)
- Added: faq links in about
- Added: volume toggle for lock screen to support small screen
- Added: on-click artist icon to artist details in album details screen
- Added: albums and artists list style(Settings->Personalize-> Artist grid or Album
grid)
- Added: toggle home banner(Settings->Personalize-> Home banner)
- Improved: home page UI
- Updated: internal libs
- 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
- Fix: offer dialog showing
- Added: zero volume pause
- Added: more album cover skipping styles
- Added: new animations(WIP)
- Added: more tab titles toggle
- Improved: home screen
- 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 super Bitmap> 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 super Bitmap> 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, Bitmap> 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 super BitmapPaletteWrapper> 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 super BitmapPaletteWrapper> 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 super BitmapPaletteWrapper> 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 super BitmapPaletteWrapper> 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 super BitmapPaletteWrapper> 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