diff --git a/app/app.iml b/app/app.iml
index 55e5154f..9b13850b 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -133,6 +133,8 @@
+
+
diff --git a/app/build.gradle b/app/build.gradle
index 89bf1ced..fa1183bd 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -11,8 +11,8 @@ android {
vectorDrawables.useSupportLibrary = true
applicationId "code.name.monkey.retromusic"
- versionCode 222
- versionName '2.0.010'
+ versionCode 232
+ versionName '2.0.210'
multiDexEnabled true
@@ -130,10 +130,10 @@ dependencies {
implementation "com.afollestad.material-dialogs:core:$materialDialog"
implementation "com.afollestad.material-dialogs:commons:$materialDialog"
implementation 'com.afollestad:material-cab:0.1.12'
- implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
- implementation 'io.reactivex.rxjava2:rxjava:2.1.9'
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 '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') {
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index bd883a0f..fefc07f8 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,6 +1,5 @@
@@ -15,7 +14,6 @@
+ android:usesCleartextTraffic="true">
@@ -240,6 +238,9 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/assets/contributors.json b/app/src/main/assets/contributors.json
index e39cc677..92ff17bd 100644
--- a/app/src/main/assets/contributors.json
+++ b/app/src/main/assets/contributors.json
@@ -1,15 +1,21 @@
[
{
"name": "Lennart Glamann",
- "summary": "Moderator",
+ "summary": "Design contributor",
"link": "https://t.me/FlixbusLennart",
"profile_image": "https://i.imgur.com/Q5Nsx1R.jpg"
},
+ {
+ "name": "Elvan Putra",
+ "summary": "Design contributor",
+ "link": "https://t.me/ElvanMacko",
+ "profile_image": "https://i.imgur.com/w7rnEEw.jpg"
+ },
{
"name": "Gaming Inc.",
"summary": "Discord server maintainer",
"link": "https://t.me/Gaming_Inc",
- "profile_image": "https://cdn.discordapp.com/attachments/469540889883181077/471361944385880065/91_98910_29110_20180616_17122501.jpg"
+ "profile_image": "https://i.imgur.com/5wXLrS2.jpg"
},
{
"name": "Marko Ivanović",
@@ -21,6 +27,6 @@
"name": "Gaurav Singh",
"summary": "Moderator",
"link": "https://t.me/Allstargaurav",
- "profile_image": "https://cdn5.telesco.pe/file/Gnko_d39iKSqzKhsVK53sjUFz_sfLKe_OpxFE9kR-VUEjDbm6SOr8CT09tyI3zhDSuTowqOhNY4nogFx1Z8QbixyZLAWccl94JdX4dqkPrZyHMS9K7xUzq-wgZCoNIbO8_eAnGOy8Gmu3-uzLuQf2u3G7BRIxm5mzqwqGoeX7_V-fcs3Lr6Br7hPFeCHSm1U39I69E3R9ovs-kPfxCpze-riCjD-QhwwOEOfiudx9OmkmLJGvYugX2EpHSBFfNh6WFQEvBAvR6xPrXul3LxZEebH0xwz5HX-bmyuoxdGaW0J4ywDgiiu4I7cfUJe8lKqWwkPQRg8zTtYNiG3MZio7w.jpg"
+ "profile_image": "https://i.imgur.com/EertxDu.jpg"
}
]
\ No newline at end of file
diff --git a/app/src/main/assets/retro-changelog.html b/app/src/main/assets/retro-changelog.html
index 3352f7ec..518b9e30 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.00
- Fix: dialog cancel text
- Fix: album cover edit with last.fm
- Fix: same theme follows entire app
- Fix: playlist rename
- Fix: toggle tab titles
- Fix: adaptive controls for material theme
- Added: full card album style
- Added: extra controls toggle for mini player
- Added: album & grid style(play image)
- Added: new navigation(WIP)
- Added: faq links about
- Added: genre tab to library
- Added: volume toggle for lock screen to support small screen
- Added: on-click artist icon to artist details in album details screen
- Added: circle style for album and artist lists
- Added: now playing album cover style chooser
- Improved: sleep timer
- Improved: home page UI
- Improved: most of the dialog UI to follow theme(WIP)
- Removed: toggle home banner(WIP)
- Removed: home page genre
- Updated: internal libs
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.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
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 e06aca08..1cc53c5b 100644
--- a/app/src/main/java/code/name/monkey/retromusic/RetroApplication.java
+++ b/app/src/main/java/code/name/monkey/retromusic/RetroApplication.java
@@ -1,13 +1,13 @@
package code.name.monkey.retromusic;
import android.os.Build;
-import androidx.annotation.NonNull;
-import androidx.multidex.MultiDexApplication;
import com.anjlab.android.iab.v3.BillingProcessor;
import com.anjlab.android.iab.v3.TransactionDetails;
import com.bumptech.glide.Glide;
+import androidx.annotation.NonNull;
+import androidx.multidex.MultiDexApplication;
import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager;
import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
@@ -47,6 +47,7 @@ public class RetroApplication extends MultiDexApplication {
super.onCreate();
app = this;
+ setupErrorHandler();
// default theme
if (!ThemeStore.isConfigured(this, 1)) {
@@ -98,6 +99,7 @@ public class RetroApplication extends MultiDexApplication {
private void handleUncaughtException(Thread thread, Throwable throwable) {
throwable.printStackTrace();
+ deleteAppData();
//Intent intent = new Intent(this, ErrorHandlerActivity.class);
//intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//startActivity(intent);
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 74326cf2..48f91200 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
@@ -6,11 +6,17 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
-import androidx.annotation.Nullable;
-import androidx.palette.graphics.Palette;
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 androidx.palette.graphics.Palette;
import code.name.monkey.appthemehelper.util.MaterialValueHelper;
import code.name.monkey.retromusic.Constants;
import code.name.monkey.retromusic.R;
@@ -21,174 +27,170 @@ 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.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 AppWidgetCard extends BaseAppWidget {
- public static final String NAME = "app_widget_card";
+ public static final String NAME = "app_widget_card";
- private static AppWidgetCard mInstance;
- private static int imageSize = 0;
- private static float cardRadius = 0f;
- private Target target; // for cancellation
+ private static AppWidgetCard mInstance;
+ private static int imageSize = 0;
+ private static float cardRadius = 0f;
+ private Target target; // for cancellation
- public static synchronized AppWidgetCard getInstance() {
- if (mInstance == null) {
- mInstance = new AppWidgetCard();
- }
- 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_card);
-
- 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.getSecondaryTextColor(context, true)), 1f));
- appWidgetView.setImageViewBitmap(R.id.button_prev, createBitmap(
- RetroUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_previous_white_24dp,
- MaterialValueHelper.getSecondaryTextColor(context, true)), 1f));
- appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, createBitmap(
- RetroUtil.getTintedVectorDrawable(context, R.drawable.ic_play_arrow_white_24dp,
- MaterialValueHelper.getSecondaryTextColor(context, true)), 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_card);
-
- 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.getSecondaryTextColor(service, true)), 1f));
-
- // Set prev/next button drawables
- appWidgetView.setImageViewBitmap(R.id.button_next, createBitmap(
- RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_next_white_24dp,
- MaterialValueHelper.getSecondaryTextColor(service, true)), 1f));
- appWidgetView.setImageViewBitmap(R.id.button_prev, createBitmap(
- RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_previous_white_24dp,
- MaterialValueHelper.getSecondaryTextColor(service, true)), 1f));
-
- // Link actions buttons to intents
- linkButtons(service, appWidgetView);
-
- if (imageSize == 0) {
- imageSize = service.getResources().getDimensionPixelSize(R.dimen.app_widget_card_image_size);
- }
- if (cardRadius == 0f) {
- cardRadius = service.getResources().getDimension(R.dimen.app_widget_card_radius);
- }
-
- // Load the album cover async and push the update on completion
- service.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- if (target != null) {
- Glide.clear(target);
+ public static synchronized AppWidgetCard getInstance() {
+ if (mInstance == null) {
+ mInstance = new AppWidgetCard();
}
- target = SongGlideRequest.Builder.from(Glide.with(service), song)
- .checkIgnoreMediaStore(service)
- .generatePalette(service).build()
- .centerCrop()
- .into(new SimpleTarget(imageSize, imageSize) {
- @Override
- public void onResourceReady(BitmapPaletteWrapper resource,
- GlideAnimation super BitmapPaletteWrapper> glideAnimation) {
- Palette palette = resource.getPalette();
- update(resource.getBitmap(), palette.getVibrantColor(palette
- .getMutedColor(MaterialValueHelper.getSecondaryTextColor(service, true))));
- }
+ return mInstance;
+ }
- @Override
- public void onLoadFailed(Exception e, Drawable errorDrawable) {
- super.onLoadFailed(e, errorDrawable);
- update(null, MaterialValueHelper.getSecondaryTextColor(service, true));
- }
+ /**
+ * 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_card);
- private void update(@Nullable Bitmap bitmap, int color) {
- // 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, color), 1f));
+ 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.getSecondaryTextColor(context, true)), 1f));
+ appWidgetView.setImageViewBitmap(R.id.button_prev, createBitmap(
+ RetroUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_previous_white_24dp,
+ MaterialValueHelper.getSecondaryTextColor(context, true)), 1f));
+ appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, createBitmap(
+ RetroUtil.getTintedVectorDrawable(context, R.drawable.ic_play_arrow_white_24dp,
+ MaterialValueHelper.getSecondaryTextColor(context, true)), 1f));
- // Set prev/next button drawables
- appWidgetView.setImageViewBitmap(R.id.button_next, createBitmap(
- RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_next_white_24dp,
- color), 1f));
- appWidgetView.setImageViewBitmap(R.id.button_prev, createBitmap(
- RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_previous_white_24dp,
- color), 1f));
+ linkButtons(context, appWidgetView);
+ pushUpdate(context, appWidgetIds, appWidgetView);
+ }
- final Drawable image = getAlbumArtDrawable(service.getResources(), bitmap);
- final Bitmap roundedBitmap = createRoundedBitmap(image, imageSize, imageSize,
- cardRadius, 0, cardRadius, 0);
- appWidgetView.setImageViewBitmap(R.id.image, roundedBitmap);
+ /**
+ * 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_card);
- pushUpdate(service, appWidgetIds, appWidgetView);
- }
- });
- }
- });
- }
+ final boolean isPlaying = service.isPlaying();
+ final Song song = service.getCurrentSong();
- /**
- * Link up various button actions using {@link PendingIntent}.
- */
- private void linkButtons(final Context context, final RemoteViews views) {
- Intent action;
- PendingIntent pendingIntent;
+ // 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));
+ }
- final ComponentName serviceName = new ComponentName(context, MusicService.class);
+ // 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.getSecondaryTextColor(service, true)), 1f));
- // 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.image, pendingIntent);
- views.setOnClickPendingIntent(R.id.media_titles, pendingIntent);
+ // Set prev/next button drawables
+ appWidgetView.setImageViewBitmap(R.id.button_next, createBitmap(
+ RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_next_white_24dp,
+ MaterialValueHelper.getSecondaryTextColor(service, true)), 1f));
+ appWidgetView.setImageViewBitmap(R.id.button_prev, createBitmap(
+ RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_previous_white_24dp,
+ MaterialValueHelper.getSecondaryTextColor(service, true)), 1f));
- // Previous track
- pendingIntent = buildPendingIntent(context, Constants.ACTION_REWIND, serviceName);
- views.setOnClickPendingIntent(R.id.button_prev, pendingIntent);
+ // Link actions buttons to intents
+ linkButtons(service, appWidgetView);
- // Play and pause
- pendingIntent = buildPendingIntent(context, Constants.ACTION_TOGGLE_PAUSE, serviceName);
- views.setOnClickPendingIntent(R.id.button_toggle_play_pause, pendingIntent);
+ if (imageSize == 0) {
+ imageSize = service.getResources().getDimensionPixelSize(R.dimen.app_widget_card_image_size);
+ }
+ if (cardRadius == 0f) {
+ cardRadius = service.getResources().getDimension(R.dimen.app_widget_card_radius);
+ }
- // Next track
- pendingIntent = buildPendingIntent(context, Constants.ACTION_SKIP, serviceName);
- views.setOnClickPendingIntent(R.id.button_next, pendingIntent);
- }
+ // Load the album cover async and push the update on completion
+ 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()
+ .centerCrop()
+ .into(new SimpleTarget(imageSize, imageSize) {
+ @Override
+ public void onResourceReady(BitmapPaletteWrapper resource,
+ GlideAnimation super BitmapPaletteWrapper> glideAnimation) {
+ Palette palette = resource.getPalette();
+ update(resource.getBitmap(), palette.getVibrantColor(palette
+ .getMutedColor(MaterialValueHelper.getSecondaryTextColor(service, true))));
+ }
+
+ @Override
+ public void onLoadFailed(Exception e, Drawable errorDrawable) {
+ super.onLoadFailed(e, errorDrawable);
+ update(null, MaterialValueHelper.getSecondaryTextColor(service, true));
+ }
+
+ private void update(@Nullable Bitmap bitmap, int color) {
+ // 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, color), 1f));
+
+ // Set prev/next button drawables
+ appWidgetView.setImageViewBitmap(R.id.button_next, createBitmap(
+ RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_next_white_24dp,
+ color), 1f));
+ appWidgetView.setImageViewBitmap(R.id.button_prev, createBitmap(
+ RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_previous_white_24dp,
+ color), 1f));
+
+ final Drawable image = getAlbumArtDrawable(service.getResources(), bitmap);
+ final Bitmap roundedBitmap = createRoundedBitmap(image, imageSize, imageSize,
+ cardRadius, 0, cardRadius, 0);
+ appWidgetView.setImageViewBitmap(R.id.image, roundedBitmap);
+
+ pushUpdate(service, appWidgetIds, appWidgetView);
+ }
+ });
+ }
+ });
+ }
+
+ /**
+ * Link up various button actions using {@link PendingIntent}.
+ */
+ private void linkButtons(final Context context, final RemoteViews views) {
+ Intent action;
+ PendingIntent pendingIntent;
+
+ final ComponentName serviceName = new ComponentName(context, MusicService.class);
+
+ // 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.image, pendingIntent);
+ views.setOnClickPendingIntent(R.id.media_titles, 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/base/BaseAppWidget.java b/app/src/main/java/code/name/monkey/retromusic/appwidgets/base/BaseAppWidget.java
index b2944cb4..acb9476d 100644
--- a/app/src/main/java/code/name/monkey/retromusic/appwidgets/base/BaseAppWidget.java
+++ b/app/src/main/java/code/name/monkey/retromusic/appwidgets/base/BaseAppWidget.java
@@ -18,6 +18,7 @@ import android.graphics.drawable.Drawable;
import android.os.Build;
import android.text.TextUtils;
import android.widget.RemoteViews;
+
import code.name.monkey.retromusic.Constants;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.model.Song;
@@ -25,138 +26,138 @@ import code.name.monkey.retromusic.service.MusicService;
public abstract class BaseAppWidget extends AppWidgetProvider {
- public static final String NAME = "app_widget";
+ public static final String NAME = "app_widget";
- protected static Bitmap createBitmap(Drawable drawable, float sizeMultiplier) {
- Bitmap bitmap = Bitmap.createBitmap((int) (drawable.getIntrinsicWidth() * sizeMultiplier),
- (int) (drawable.getIntrinsicHeight() * sizeMultiplier), Bitmap.Config.ARGB_8888);
- Canvas c = new Canvas(bitmap);
- drawable.setBounds(0, 0, c.getWidth(), c.getHeight());
- drawable.draw(c);
- return bitmap;
- }
-
- protected static Bitmap createRoundedBitmap(Drawable drawable, int width, int height, float tl,
- float tr, float bl, float br) {
- if (drawable == null) {
- return null;
+ protected static Bitmap createBitmap(Drawable drawable, float sizeMultiplier) {
+ Bitmap bitmap = Bitmap.createBitmap((int) (drawable.getIntrinsicWidth() * sizeMultiplier),
+ (int) (drawable.getIntrinsicHeight() * sizeMultiplier), Bitmap.Config.ARGB_8888);
+ Canvas c = new Canvas(bitmap);
+ drawable.setBounds(0, 0, c.getWidth(), c.getHeight());
+ drawable.draw(c);
+ return bitmap;
}
- Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- Canvas c = new Canvas(bitmap);
- drawable.setBounds(0, 0, width, height);
- drawable.draw(c);
+ protected static Bitmap createRoundedBitmap(Drawable drawable, int width, int height, float tl,
+ float tr, float bl, float br) {
+ if (drawable == null) {
+ return null;
+ }
- Bitmap rounded = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+ Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+ Canvas c = new Canvas(bitmap);
+ drawable.setBounds(0, 0, width, height);
+ drawable.draw(c);
- Canvas canvas = new Canvas(rounded);
- Paint paint = new Paint();
- paint.setShader(
- new BitmapShader(bitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
- paint.setAntiAlias(true);
- canvas.drawPath(composeRoundedRectPath(new RectF(0, 0, width, height), tl, tr, bl, br), paint);
+ Bitmap rounded = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- return rounded;
- }
+ Canvas canvas = new Canvas(rounded);
+ Paint paint = new Paint();
+ paint.setShader(
+ new BitmapShader(bitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
+ paint.setAntiAlias(true);
+ canvas.drawPath(composeRoundedRectPath(new RectF(0, 0, width, height), tl, tr, bl, br), paint);
- protected static Path composeRoundedRectPath(RectF rect, float tl, float tr, float bl, float br) {
- Path path = new Path();
- tl = tl < 0 ? 0 : tl;
- tr = tr < 0 ? 0 : tr;
- bl = bl < 0 ? 0 : bl;
- br = br < 0 ? 0 : br;
-
- path.moveTo(rect.left + tl, rect.top);
- path.lineTo(rect.right - tr, rect.top);
- path.quadTo(rect.right, rect.top, rect.right, rect.top + tr);
- path.lineTo(rect.right, rect.bottom - br);
- path.quadTo(rect.right, rect.bottom, rect.right - br, rect.bottom);
- path.lineTo(rect.left + bl, rect.bottom);
- path.quadTo(rect.left, rect.bottom, rect.left, rect.bottom - bl);
- path.lineTo(rect.left, rect.top + tl);
- path.quadTo(rect.left, rect.top, rect.left + tl, rect.top);
- path.close();
-
- return path;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onUpdate(final Context context, final AppWidgetManager appWidgetManager,
- final int[] appWidgetIds) {
- defaultAppWidget(context, appWidgetIds);
- final Intent updateIntent = new Intent(Constants.APP_WIDGET_UPDATE);
- updateIntent.putExtra(Constants.EXTRA_APP_WIDGET_NAME, NAME);
- updateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
- updateIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
- context.sendBroadcast(updateIntent);
- }
-
- /**
- * Handle a change notification coming over from {@link MusicService}
- */
- public void notifyChange(final MusicService service, final String what) {
- if (hasInstances(service)) {
- if (Constants.META_CHANGED.equals(what) || Constants.PLAY_STATE_CHANGED.equals(what)) {
- performUpdate(service, null);
- }
+ return rounded;
}
- }
- protected void pushUpdate(final Context context, final int[] appWidgetIds,
- final RemoteViews views) {
- final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
- if (appWidgetIds != null) {
- appWidgetManager.updateAppWidget(appWidgetIds, views);
- } else {
- appWidgetManager.updateAppWidget(new ComponentName(context, getClass()), views);
+ protected static Path composeRoundedRectPath(RectF rect, float tl, float tr, float bl, float br) {
+ Path path = new Path();
+ tl = tl < 0 ? 0 : tl;
+ tr = tr < 0 ? 0 : tr;
+ bl = bl < 0 ? 0 : bl;
+ br = br < 0 ? 0 : br;
+
+ path.moveTo(rect.left + tl, rect.top);
+ path.lineTo(rect.right - tr, rect.top);
+ path.quadTo(rect.right, rect.top, rect.right, rect.top + tr);
+ path.lineTo(rect.right, rect.bottom - br);
+ path.quadTo(rect.right, rect.bottom, rect.right - br, rect.bottom);
+ path.lineTo(rect.left + bl, rect.bottom);
+ path.quadTo(rect.left, rect.bottom, rect.left, rect.bottom - bl);
+ path.lineTo(rect.left, rect.top + tl);
+ path.quadTo(rect.left, rect.top, rect.left + tl, rect.top);
+ path.close();
+
+ return path;
}
- }
- /**
- * Check against {@link AppWidgetManager} if there are any instances of this widget.
- */
- protected boolean hasInstances(final Context context) {
- final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
- final int[] mAppWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context,
- getClass()));
- return mAppWidgetIds.length > 0;
- }
-
- protected PendingIntent buildPendingIntent(Context context, final String action,
- final ComponentName serviceName) {
- Intent intent = new Intent(action);
- intent.setComponent(serviceName);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- return PendingIntent.getForegroundService(context, 0, intent, 0);
- } else {
- return PendingIntent.getService(context, 0, intent, 0);
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onUpdate(final Context context, final AppWidgetManager appWidgetManager,
+ final int[] appWidgetIds) {
+ defaultAppWidget(context, appWidgetIds);
+ final Intent updateIntent = new Intent(Constants.APP_WIDGET_UPDATE);
+ updateIntent.putExtra(Constants.EXTRA_APP_WIDGET_NAME, NAME);
+ updateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
+ updateIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
+ context.sendBroadcast(updateIntent);
}
- }
- abstract protected void defaultAppWidget(final Context context, final int[] appWidgetIds);
-
- abstract public void performUpdate(final MusicService service, final int[] appWidgetIds);
-
- protected Drawable getAlbumArtDrawable(final Resources resources, final Bitmap bitmap) {
- Drawable image;
- if (bitmap == null) {
- image = resources.getDrawable(R.drawable.default_album_art);
- } else {
- image = new BitmapDrawable(resources, bitmap);
+ /**
+ * Handle a change notification coming over from {@link MusicService}
+ */
+ public void notifyChange(final MusicService service, final String what) {
+ if (hasInstances(service)) {
+ if (Constants.META_CHANGED.equals(what) || Constants.PLAY_STATE_CHANGED.equals(what)) {
+ performUpdate(service, null);
+ }
+ }
}
- return image;
- }
- protected String getSongArtistAndAlbum(final Song song) {
- final StringBuilder builder = new StringBuilder();
- builder.append(song.artistName);
- if (!TextUtils.isEmpty(song.artistName) && !TextUtils.isEmpty(song.albumName)) {
- builder.append(" • ");
+ protected void pushUpdate(final Context context, final int[] appWidgetIds,
+ final RemoteViews views) {
+ final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
+ if (appWidgetIds != null) {
+ appWidgetManager.updateAppWidget(appWidgetIds, views);
+ } else {
+ appWidgetManager.updateAppWidget(new ComponentName(context, getClass()), views);
+ }
+ }
+
+ /**
+ * Check against {@link AppWidgetManager} if there are any instances of this widget.
+ */
+ protected boolean hasInstances(final Context context) {
+ final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
+ final int[] mAppWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context,
+ getClass()));
+ return mAppWidgetIds.length > 0;
+ }
+
+ protected PendingIntent buildPendingIntent(Context context, final String action,
+ final ComponentName serviceName) {
+ Intent intent = new Intent(action);
+ intent.setComponent(serviceName);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ return PendingIntent.getForegroundService(context, 0, intent, 0);
+ } else {
+ return PendingIntent.getService(context, 0, intent, 0);
+ }
+ }
+
+ abstract protected void defaultAppWidget(final Context context, final int[] appWidgetIds);
+
+ abstract public void performUpdate(final MusicService service, final int[] appWidgetIds);
+
+ protected Drawable getAlbumArtDrawable(final Resources resources, final Bitmap bitmap) {
+ Drawable image;
+ if (bitmap == null) {
+ image = resources.getDrawable(R.drawable.default_album_art);
+ } else {
+ image = new BitmapDrawable(resources, bitmap);
+ }
+ return image;
+ }
+
+ protected String getSongArtistAndAlbum(final Song song) {
+ final StringBuilder builder = new StringBuilder();
+ builder.append(song.artistName);
+ if (!TextUtils.isEmpty(song.artistName) && !TextUtils.isEmpty(song.albumName)) {
+ builder.append(" • ");
+ }
+ builder.append(song.albumName);
+ return builder.toString();
}
- builder.append(song.albumName);
- return builder.toString();
- }
}
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 6ae36080..76a2f288 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
@@ -71,21 +71,29 @@ public class DeletePlaylistDialog extends RoundedBottomSheetDialogFragment {
CharSequence content;
//noinspection ConstantConditions
if (playlists.size() > 1) {
- title = R.string.delete_playlists_title;
content = Html.fromHtml(getString(R.string.delete_x_playlists, playlists.size()));
} else {
- title = R.string.delete_playlist_title;
content = Html.fromHtml(getString(R.string.delete_playlist_x, playlists.get(0).name));
}
this.title.setText(content);
- this.actionDelete.setText(title);
-
this.title.setTextColor(ThemeStore.textColorPrimary(getContext()));
+
+ actionDelete.setText(R.string.action_delete);
+
int accentColor = ThemeStore.accentColor(Objects.requireNonNull(getContext()));
- actionDelete.setBackgroundTintList(ColorStateList.valueOf(accentColor));
- actionCancel.setStrokeColor(ColorStateList.valueOf(accentColor));
- actionCancel.setTextColor(accentColor);
+ 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));
+
}
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 befe3bc9..990b0e2a 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,7 +1,6 @@
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;
@@ -10,15 +9,10 @@ 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;
@@ -27,35 +21,19 @@ 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 {
private static final String TAG = "MainOptionsBottomSheetD";
private static ButterKnife.Setter textColor = (view, value, index) -> view.setTextColor(ColorStateList.valueOf(value));
- @BindView(R.id.user_image_bottom)
- CircularImageView userImageBottom;
- @BindView(R.id.title_welcome)
- AppCompatTextView titleWelcome;
-
- @BindView(R.id.text)
- AppCompatTextView text;
-
- @BindViews({R.id.action_folders, R.id.action_about, R.id.action_buy_pro, R.id.action_rate, R.id.action_sleep_timer})
+ @BindViews({R.id.action_folders, R.id.action_settings, R.id.action_about, R.id.action_buy_pro, R.id.action_rate,
+ R.id.action_sleep_timer})
List materialButtons;
- private CompositeDisposable disposable = new CompositeDisposable();
public static MainOptionsBottomSheetDialogFragment newInstance(int selected_id) {
Bundle bundle = new Bundle();
@@ -69,11 +47,6 @@ public class MainOptionsBottomSheetDialogFragment extends RoundedBottomSheetDial
return new MainOptionsBottomSheetDialogFragment();
}
- @Override
- public void onDestroyView() {
- super.onDestroyView();
- disposable.clear();
- }
@Nullable
@Override
@@ -88,14 +61,11 @@ 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(getContext()).getUserName()));
- loadImageFromStorage();
+
}
@OnClick({R.id.action_folders, R.id.action_settings, R.id.action_sleep_timer, R.id.action_rate,
- R.id.user_info_container, R.id.action_buy_pro, R.id.action_about})
+ R.id.action_buy_pro, R.id.action_about})
void onClick(View view) {
MainActivity mainActivity = (MainActivity) getActivity();
if (mainActivity == null) {
@@ -109,58 +79,22 @@ public class MainOptionsBottomSheetDialogFragment extends RoundedBottomSheetDial
NavigationUtil.goToSettings(mainActivity);
break;
case R.id.action_about:
- NavigationUtil.goToAbout(getActivity());
+ NavigationUtil.goToAbout(mainActivity);
break;
case R.id.action_buy_pro:
- NavigationUtil.goToProVersion(getActivity());
+ NavigationUtil.goToProVersion(mainActivity);
break;
case R.id.action_sleep_timer:
if (getFragmentManager() != null) {
new SleepTimerDialog().show(getFragmentManager(), TAG);
}
break;
- case R.id.user_info_container:
- NavigationUtil.goToUserInfo(getActivity());
- break;
case R.id.action_rate:
- NavigationUtil.goToPlayStore(getActivity());
+ NavigationUtil.goToPlayStore(mainActivity);
break;
}
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(getContext()).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/helper/MusicPlayerRemote.java b/app/src/main/java/code/name/monkey/retromusic/helper/MusicPlayerRemote.java
index 99aec003..04bbe7ec 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
@@ -251,17 +251,8 @@ public class MusicPlayerRemote {
}
public static int seekTo(int millis) {
- getCastSession();
if (musicService != null) {
- switch (playbackLocation) {
- case PlaybackLocation.LOCAL:
- return musicService.seek(millis);
- case PlaybackLocation.REMOTE:
- if (getCastSession() != null) {
- getCastSession().getRemoteMediaClient().seek(millis);
- }
- break;
- }
+ return musicService.seek(millis);
}
return -1;
}
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 4043c820..35c9ffd1 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;
@@ -25,8 +24,11 @@ public class HomePresenter extends Presenter implements HomeContract.HomePresent
loadTopAlbums();
loadTopArtists();
+
loadSuggestions();
+ if (PreferenceUtil.getInstance(RetroApplication.getInstance()).isGenreShown()) loadGenres();
+
}
@Override
diff --git a/app/src/main/java/code/name/monkey/retromusic/service/WearBrowserService.java b/app/src/main/java/code/name/monkey/retromusic/service/WearBrowserService.java
index f869e2b4..519f65e7 100644
--- a/app/src/main/java/code/name/monkey/retromusic/service/WearBrowserService.java
+++ b/app/src/main/java/code/name/monkey/retromusic/service/WearBrowserService.java
@@ -23,15 +23,23 @@ import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.service.media.MediaBrowserService;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.helper.MusicPlayerRemote;
+import code.name.monkey.retromusic.loaders.AlbumLoader;
+import code.name.monkey.retromusic.loaders.ArtistLoader;
+import code.name.monkey.retromusic.loaders.PlaylistLoader;
+import code.name.monkey.retromusic.loaders.PlaylistSongsLoader;
import code.name.monkey.retromusic.loaders.SongLoader;
+import code.name.monkey.retromusic.model.Album;
+import code.name.monkey.retromusic.model.Artist;
+import code.name.monkey.retromusic.model.Playlist;
import code.name.monkey.retromusic.model.Song;
import code.name.monkey.retromusic.util.RetroUtil;
@@ -52,7 +60,7 @@ public class WearBrowserService extends MediaBrowserService {
public static final int TYPE_PLAYLIST_ALL_SONGS = 7;
public static WearBrowserService sInstance;
- MediaSession mSession;
+ private MediaSession mSession;
private Context mContext;
private boolean mServiceStarted;
@@ -69,7 +77,6 @@ public class WearBrowserService extends MediaBrowserService {
setSessionToken(mSession.getSessionToken());
mSession.setCallback(new MediaSessionCallback());
mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS | MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
-
}
@Override
@@ -117,8 +124,12 @@ public class WearBrowserService extends MediaBrowserService {
}
}
- private void fillMediaItems(List mediaItems, String mediaId,
- String title, Uri icon, String subTitle, int playableOrBrowsable) {
+ private void fillMediaItems(List mediaItems,
+ String mediaId,
+ String title,
+ String subTitle,
+ Uri icon,
+ int playableOrBrowsable) {
mediaItems.add(new MediaBrowser.MediaItem(
new MediaDescription.Builder()
.setMediaId(mediaId)
@@ -134,8 +145,7 @@ public class WearBrowserService extends MediaBrowserService {
new MediaDescription.Builder()
.setMediaId(Integer.toString(TYPE_ARTIST))
.setTitle(getString(R.string.artists))
- .setIconUri(Uri.parse("android.resource://" +
- "naman14.timber/drawable/ic_empty_music2"))
+ .setIconBitmap(RetroUtil.createBitmap(ContextCompat.getDrawable(getApplicationContext(), R.drawable.default_artist_art), 1f))
.setSubtitle(getString(R.string.artists))
.build(), MediaBrowser.MediaItem.FLAG_BROWSABLE
));
@@ -144,8 +154,7 @@ public class WearBrowserService extends MediaBrowserService {
new MediaDescription.Builder()
.setMediaId(Integer.toString(TYPE_ALBUM))
.setTitle(getString(R.string.albums))
- .setIconUri(Uri.parse("android.resource://" +
- "naman14.timber/drawable/ic_empty_music2"))
+ .setIconBitmap(RetroUtil.createBitmap(ContextCompat.getDrawable(getApplicationContext(), R.drawable.default_album_art), 1f))
.setSubtitle(getString(R.string.albums))
.build(), MediaBrowser.MediaItem.FLAG_BROWSABLE
));
@@ -154,8 +163,7 @@ public class WearBrowserService extends MediaBrowserService {
new MediaDescription.Builder()
.setMediaId(Integer.toString(TYPE_SONG))
.setTitle(getString(R.string.songs))
- .setIconUri(Uri.parse("android.resource://" +
- "naman14.timber/drawable/ic_empty_music2"))
+ .setIconBitmap(RetroUtil.createBitmap(ContextCompat.getDrawable(getApplicationContext(), R.drawable.default_album_art), 1f))
.setSubtitle(getString(R.string.songs))
.build(), MediaBrowser.MediaItem.FLAG_BROWSABLE
));
@@ -165,8 +173,7 @@ public class WearBrowserService extends MediaBrowserService {
new MediaDescription.Builder()
.setMediaId(Integer.toString(TYPE_PLAYLIST))
.setTitle(getString(R.string.playlists))
- .setIconUri(Uri.parse("android.resource://" +
- "naman14.timber/drawable/ic_empty_music2"))
+ .setIconUri(Uri.parse("android.resource://code.name.monkey.retromusic/drawable/ic_queue_music_white_24dp"))
.setSubtitle(getString(R.string.playlists))
.build(), MediaBrowser.MediaItem.FLAG_BROWSABLE
));
@@ -177,6 +184,7 @@ public class WearBrowserService extends MediaBrowserService {
final List mediaItems = new ArrayList<>();
+
new AsyncTask() {
@Override
protected Void doInBackground(final Void... unused) {
@@ -185,64 +193,108 @@ public class WearBrowserService extends MediaBrowserService {
addMediaRoots(mediaItems);
} else {
switch (Integer.parseInt(Character.toString(parentId.charAt(0)))) {
- /*case TYPE_ARTIST:
- List artistList = ArtistLoader.getAllArtists(mContext);
+ case TYPE_ARTIST:
+ List artistList = ArtistLoader.getAllArtists(mContext).blockingFirst();
for (Artist artist : artistList) {
- String albumNmber = TimberUtils.makeLabel(mContext, R.plurals.Nalbums, artist.albumCount);
- String songCount = TimberUtils.makeLabel(mContext, R.plurals.Nsongs, artist.songCount);
- fillMediaItems(mediaItems, Integer.toString(TYPE_ARTIST_SONG_ALBUMS) + Long.toString(artist.id), artist.name, Uri.parse("android.resource://" +
- "naman14.timber/drawable/ic_empty_music2"), TimberUtils.makeCombinedString(mContext, albumNmber, songCount), MediaBrowser.MediaItem.FLAG_BROWSABLE);
+ String albumNmber = String.format("%d %s", artist.albums.size(), artist.albums.size() > 1 ? "Albums" : "Album");
+ String songCount = String.format("%d %s", artist.getSongs().size(), artist.getSongs().size() > 1 ? "Songs" : "Song");
+ fillMediaItems(mediaItems,
+ Integer.toString(TYPE_ARTIST_SONG_ALBUMS) + Long.toString(artist.getId()),
+ artist.getName(),
+ albumNmber + " • " + songCount,
+ Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_artist_art"),
+ MediaBrowser.MediaItem.FLAG_BROWSABLE);
+ }
+ break;
+
+ case TYPE_ARTIST_SONG_ALBUMS:
+ fillMediaItems(mediaItems,
+ Integer.toString(TYPE_ARTIST_ALL_SONGS) + Long.parseLong(parentId.substring(1)),
+ "All songs",
+ "All songs by artist",
+ Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_artist_art"),
+ MediaBrowser.MediaItem.FLAG_BROWSABLE);
+
+ List artistAlbums = ArtistLoader.getArtist(mContext, Integer.parseInt(parentId.substring(1))).blockingFirst().albums; //ArtistAlbumLoader.getAlbumsForArtist(mContext, Long.parseLong(parentId.substring(1)));
+ for (Album album : artistAlbums) {
+ String songCount = String.format("%d %s", album.songs.size(), album.songs.size() > 1 ? "Songs" : "Song");
+ fillMediaItems(mediaItems,
+ Integer.toString(TYPE_ALBUM_SONGS) + Long.toString(album.getId()),
+ album.getTitle(),
+ songCount,
+ Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_artist_art"),
+ MediaBrowser.MediaItem.FLAG_BROWSABLE);
}
break;
case TYPE_ALBUM:
- List albumList = AlbumLoader.getAllAlbums(mContext);
+ List albumList = AlbumLoader.getAllAlbums(mContext).blockingFirst();
for (Album album : albumList) {
- fillMediaItems(mediaItems, Integer.toString(TYPE_ALBUM_SONGS) + Long.toString(album.id), album.title, TimberUtils.getAlbumArtUri(album.id), album.artistName, MediaBrowser.MediaItem.FLAG_BROWSABLE);
+ fillMediaItems(mediaItems,
+ Integer.toString(TYPE_ALBUM_SONGS) + Long.toString(album.getId()),
+ album.getTitle(),
+ album.getArtistName(),
+ RetroUtil.getAlbumArtUri(album.getId()),
+ MediaBrowser.MediaItem.FLAG_BROWSABLE);
}
- break;*/
+ break;
case TYPE_SONG:
List songList = SongLoader.getAllSongs(mContext).blockingFirst();
for (Song song : songList) {
- fillMediaItems(mediaItems, String.valueOf(song.id), song.title, RetroUtil.getAlbumArtUri(song.albumId), song.artistName, MediaBrowser.MediaItem.FLAG_PLAYABLE);
+ fillMediaItems(mediaItems,
+ String.valueOf(song.id),
+ song.title,
+ song.artistName,
+ Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_album_art"),
+ MediaBrowser.MediaItem.FLAG_PLAYABLE);
}
break;
- /* case TYPE_ALBUM_SONGS:
- List albumSongList = AlbumSongLoader.getSongsForAlbum(mContext, Long.parseLong(parentId.substring(1)));
- for (Song song : albumSongList) {
- fillMediaItems(mediaItems, String.valueOf(song.id), song.title, TimberUtils.getAlbumArtUri(song.albumId), song.artistName, MediaBrowser.MediaItem.FLAG_PLAYABLE);
- }
- break;
- case TYPE_ARTIST_SONG_ALBUMS:
- fillMediaItems(mediaItems, Integer.toString(TYPE_ARTIST_ALL_SONGS) + Long.parseLong(parentId.substring(1)), "All songs", Uri.parse("android.resource://" +
- "naman14.timber/drawable/ic_empty_music2"), "All songs by artist", MediaBrowser.MediaItem.FLAG_BROWSABLE);
- List artistAlbums = ArtistAlbumLoader.getAlbumsForArtist(mContext, Long.parseLong(parentId.substring(1)));
- for (Album album : artistAlbums) {
- String songCount = TimberUtils.makeLabel(mContext, R.plurals.Nsongs, album.songCount);
- fillMediaItems(mediaItems, Integer.toString(TYPE_ALBUM_SONGS) + Long.toString(album.id), album.title, TimberUtils.getAlbumArtUri(album.id), songCount, MediaBrowser.MediaItem.FLAG_BROWSABLE);
+ case TYPE_ALBUM_SONGS:
+ List albumSongList = AlbumLoader.getAlbum(mContext, Integer.parseInt(parentId.substring(1))).blockingFirst().songs;
+ for (Song song : albumSongList) {
+ fillMediaItems(mediaItems,
+ String.valueOf(song.id),
+ song.title,
+ song.artistName,
+ Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_album_art"),
+ MediaBrowser.MediaItem.FLAG_PLAYABLE);
}
break;
case TYPE_ARTIST_ALL_SONGS:
- List artistSongs = ArtistSongLoader.getSongsForArtist(mContext, Long.parseLong(parentId.substring(1)));
+ List artistSongs = ArtistLoader.getArtist(mContext, Integer.parseInt(parentId.substring(1))).blockingFirst().getSongs();
for (Song song : artistSongs) {
- fillMediaItems(mediaItems, String.valueOf(song.id), song.title, TimberUtils.getAlbumArtUri(song.albumId), song.albumName, MediaBrowser.MediaItem.FLAG_PLAYABLE);
+ fillMediaItems(mediaItems,
+ String.valueOf(song.id),
+ song.title,
+ song.albumName,
+ Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_album_art"),
+ MediaBrowser.MediaItem.FLAG_PLAYABLE);
}
break;
case TYPE_PLAYLIST:
- List playlistList = PlaylistLoader.getPlaylists(mContext, false);
+ List playlistList = PlaylistLoader.getAllPlaylists(mContext).blockingFirst();
for (Playlist playlist : playlistList) {
- String songCount = TimberUtils.makeLabel(mContext, R.plurals.Nsongs, playlist.songCount);
- fillMediaItems(mediaItems, Integer.toString(TYPE_PLAYLIST_ALL_SONGS) + Long.toString(playlist.id), playlist.name,
- Uri.parse("android.resource://" +
- "naman14.timber/drawable/ic_empty_music2"), songCount, MediaBrowser.MediaItem.FLAG_BROWSABLE);
+ int size = PlaylistSongsLoader.getPlaylistSongList(mContext, playlist).blockingFirst().size();
+ String songCount = String.format("%d %s", size, size > 1 ? "Songs" : "Song");
+ fillMediaItems(mediaItems,
+ Integer.toString(TYPE_PLAYLIST_ALL_SONGS) + Long.toString(playlist.id),
+ playlist.name,
+ songCount,
+ Uri.parse("android.resource://code.name.monkey.retromusic/drawable/ic_queue_music_white_24dp"),
+ MediaBrowser.MediaItem.FLAG_BROWSABLE);
}
break;
case TYPE_PLAYLIST_ALL_SONGS:
- List playlistSongs = PlaylistSongLoader.getSongsInPlaylist(mContext, Long.parseLong(parentId.substring(1)));
+ List playlistSongs = PlaylistSongsLoader.getPlaylistSongList(mContext, Integer.parseInt(parentId.substring(1))).blockingFirst();
for (Song song : playlistSongs) {
- fillMediaItems(mediaItems, String.valueOf(song.id), song.title, TimberUtils.getAlbumArtUri(song.albumId), song.albumName, MediaBrowser.MediaItem.FLAG_PLAYABLE);
+ fillMediaItems(mediaItems,
+ String.valueOf(song.id),
+ song.title,
+ song.albumName,
+ Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_album_art"),
+ MediaBrowser.MediaItem.FLAG_PLAYABLE);
}
- break;*/
+ break;
}
}
@@ -309,7 +361,7 @@ public class WearBrowserService extends MediaBrowserService {
}
@Override
- public void onCustomAction(String action, Bundle extras) {
+ public void onCustomAction(@NonNull String action, Bundle extras) {
}
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/transform/CustPagerTransformer.java b/app/src/main/java/code/name/monkey/retromusic/transform/CarousalPagerTransformer.java
similarity index 83%
rename from app/src/main/java/code/name/monkey/retromusic/transform/CustPagerTransformer.java
rename to app/src/main/java/code/name/monkey/retromusic/transform/CarousalPagerTransformer.java
index 2c72de20..997f3fcf 100644
--- a/app/src/main/java/code/name/monkey/retromusic/transform/CustPagerTransformer.java
+++ b/app/src/main/java/code/name/monkey/retromusic/transform/CarousalPagerTransformer.java
@@ -1,23 +1,25 @@
package code.name.monkey.retromusic.transform;
import android.content.Context;
-import androidx.viewpager.widget.ViewPager;
import android.view.View;
+import androidx.annotation.NonNull;
+import androidx.viewpager.widget.ViewPager;
+
/**
* 实现ViewPager左右滑动时的时差
* Created by xmuSistone on 2016/9/18.
*/
-public class CustPagerTransformer implements ViewPager.PageTransformer {
+public class CarousalPagerTransformer implements ViewPager.PageTransformer {
private int maxTranslateOffsetX;
private ViewPager viewPager;
- public CustPagerTransformer(Context context) {
+ public CarousalPagerTransformer(Context context) {
this.maxTranslateOffsetX = dp2px(context, 180);
}
- public void transformPage(View view, float position) {
+ public void transformPage(@NonNull View view, float position) {
if (viewPager == null) {
viewPager = (ViewPager) view.getParent();
}
@@ -34,12 +36,10 @@ public class CustPagerTransformer implements ViewPager.PageTransformer {
}
}
- /**
- * dp和像素转换
- */
private int dp2px(Context context, float dipValue) {
float m = context.getResources().getDisplayMetrics().density;
return (int) (dipValue * m + 0.5f);
}
+
}
\ No newline at end of file
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
new file mode 100644
index 00000000..2658cfcc
--- /dev/null
+++ b/app/src/main/java/code/name/monkey/retromusic/transform/CascadingPageTransformer.java
@@ -0,0 +1,58 @@
+package code.name.monkey.retromusic.transform;
+
+import android.annotation.SuppressLint;
+import android.view.View;
+
+import androidx.annotation.NonNull;
+import androidx.viewpager.widget.ViewPager;
+
+/*******************************************************************
+ * * * * * * * * * * * Created by OCN.Yang
+ * * * * * * * Time:2017/12/7 19:32.
+ * * * * * * * Email address:ocnyang@gmail.com
+ * * * * * * * * * * *.Yang Web site:www.ocnyang.com
+ *******************************************************************/
+
+
+public class CascadingPageTransformer implements ViewPager.PageTransformer {
+ /**
+ * 偏移量
+ */
+ private int mScaleOffset = 40;
+
+
+ /**
+ * @param mScaleOffset 缩放偏移量 单位 px
+ */
+ public void setScaleOffset(int mScaleOffset) {
+ this.mScaleOffset = mScaleOffset;
+ }
+
+ @SuppressLint("NewApi")
+ public void transformPage(@NonNull View page, float position) {
+ if (position <= 0.0f) {//被滑动的那页 position 是-下标~ 0
+ page.setTranslationX(0f);
+ //旋转角度 45° * -0.1 = -4.5°
+ page.setRotation((45 * position));
+ //X轴偏移 li: 300/3 * -0.1 = -10
+ page.setTranslationX((page.getWidth() / 3 * position));
+ } else if (position <= 1f) {
+ float scale = (page.getWidth() - mScaleOffset * position) / (float) (page.getWidth());
+
+ page.setScaleX(scale);
+ page.setScaleY(scale);
+
+ page.setTranslationX((-page.getWidth() * position));
+ page.setTranslationY((mScaleOffset * 0.8f) * position);
+ } else {
+ //缩放比例
+ float scale = (page.getWidth() - mScaleOffset * position) / (float) (page.getWidth());
+
+ page.setScaleX(scale);
+ page.setScaleY(scale);
+
+ page.setTranslationX((-page.getWidth() * position));
+ page.setTranslationY((mScaleOffset * 0.7f) * position);
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/code/name/monkey/retromusic/transform/NormalPageTransformer.java b/app/src/main/java/code/name/monkey/retromusic/transform/NormalPageTransformer.java
index 76dd4873..c943d42c 100644
--- a/app/src/main/java/code/name/monkey/retromusic/transform/NormalPageTransformer.java
+++ b/app/src/main/java/code/name/monkey/retromusic/transform/NormalPageTransformer.java
@@ -1,8 +1,10 @@
package code.name.monkey.retromusic.transform;
-import androidx.viewpager.widget.ViewPager;
import android.view.View;
+import androidx.annotation.NonNull;
+import androidx.viewpager.widget.ViewPager;
+
/**
* @author Hemanth S (h4h13).
*/
@@ -12,7 +14,7 @@ public class NormalPageTransformer implements ViewPager.PageTransformer {
private static final float MIN_ALPHA = 0.5f;
@Override
- public void transformPage(View view, float position) {
+ public void transformPage(@NonNull View view, float position) {
int pageWidth = view.getWidth();
int pageHeight = view.getHeight();
diff --git a/app/src/main/java/code/name/monkey/retromusic/transform/ParallaxPagerTransformer.java b/app/src/main/java/code/name/monkey/retromusic/transform/ParallaxPagerTransformer.java
index a44310ac..3c26cefd 100644
--- a/app/src/main/java/code/name/monkey/retromusic/transform/ParallaxPagerTransformer.java
+++ b/app/src/main/java/code/name/monkey/retromusic/transform/ParallaxPagerTransformer.java
@@ -2,11 +2,12 @@ package code.name.monkey.retromusic.transform;
import android.annotation.TargetApi;
import android.os.Build;
-import androidx.annotation.NonNull;
-import androidx.viewpager.widget.ViewPager;
import android.util.Log;
import android.view.View;
+import androidx.annotation.NonNull;
+import androidx.viewpager.widget.ViewPager;
+
/**
* Created by xgc1986 on 2/Apr/2016
*/
@@ -26,7 +27,7 @@ public class ParallaxPagerTransformer implements ViewPager.PageTransformer {
View parallaxView = view.findViewById(id);
- if (view == null ) {
+ if (view == null) {
Log.w("ParallaxPager", "There is no view");
}
@@ -34,7 +35,7 @@ public class ParallaxPagerTransformer implements ViewPager.PageTransformer {
if (position > -1 && position < 1) {
float width = parallaxView.getWidth();
parallaxView.setTranslationX(-(position * width * speed));
- float sc = ((float)view.getWidth() - border)/ view.getWidth();
+ float sc = ((float) view.getWidth() - border) / view.getWidth();
if (position == 0) {
view.setScaleX(1);
view.setScaleY(1);
diff --git a/app/src/main/java/code/name/monkey/retromusic/transform/StackPagerTransformer.java b/app/src/main/java/code/name/monkey/retromusic/transform/StackPagerTransformer.java
new file mode 100644
index 00000000..3ff8c08b
--- /dev/null
+++ b/app/src/main/java/code/name/monkey/retromusic/transform/StackPagerTransformer.java
@@ -0,0 +1,28 @@
+package code.name.monkey.retromusic.transform;
+
+import android.view.View;
+
+import androidx.annotation.NonNull;
+import androidx.viewpager.widget.ViewPager;
+
+public class StackPagerTransformer implements ViewPager.PageTransformer {
+ private static final float MIN_SCALE = 0.75f;
+
+
+ @Override
+ public void transformPage(@NonNull View view, float position) {
+ if (position <= 0f) {
+ view.setTranslationX(0f);
+ view.setScaleX(1f);
+ view.setScaleY(1f);
+
+ } else if (position <= 1f) {
+
+ final float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
+ view.setPivotY(0.5f * view.getHeight());
+ view.setTranslationX(view.getWidth() * -position);
+ view.setScaleX(scaleFactor);
+ view.setScaleY(scaleFactor);
+ }
+ }
+}
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/MainActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/MainActivity.java
index a945de60..bcb4cd17 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/MainActivity.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/MainActivity.java
@@ -32,6 +32,7 @@ import androidx.fragment.app.FragmentTransaction;
import butterknife.BindView;
import butterknife.ButterKnife;
import code.name.monkey.retromusic.R;
+import code.name.monkey.retromusic.RetroApplication;
import code.name.monkey.retromusic.dialogs.ChangelogDialog;
import code.name.monkey.retromusic.helper.MusicPlayerRemote;
import code.name.monkey.retromusic.helper.SearchQueryHelper;
@@ -43,7 +44,6 @@ import code.name.monkey.retromusic.model.Song;
import code.name.monkey.retromusic.service.MusicService;
import code.name.monkey.retromusic.ui.activities.base.AbsSlidingMusicPanelActivity;
import code.name.monkey.retromusic.ui.fragments.mainactivity.LibraryFragment;
-import code.name.monkey.retromusic.ui.fragments.mainactivity.folders.FoldersFragment;
import code.name.monkey.retromusic.ui.fragments.mainactivity.home.BannerHomeFragment;
import code.name.monkey.retromusic.ui.fragments.mainactivity.home.HomeFragment;
import code.name.monkey.retromusic.util.PreferenceUtil;
@@ -82,7 +82,6 @@ public class MainActivity extends AbsSlidingMusicPanelActivity implements Shared
}
}
};
- private int insideFragment = R.id.action_song;
@Override
protected View createContentView() {
@@ -99,17 +98,20 @@ public class MainActivity extends AbsSlidingMusicPanelActivity implements Shared
super.onCreate(savedInstanceState);
ButterKnife.bind(this);
- setBottomBarVisibility(View.VISIBLE);
getBottomNavigationView().setOnNavigationItemSelectedListener(this);
drawerLayout.setOnApplyWindowInsetsListener((view, windowInsets) -> windowInsets.replaceSystemWindowInsets(0, 0, 0, 0));
if (savedInstanceState == null) {
- setCurrentFragment(PreferenceUtil.getInstance(this).getLastMusicChooser());
+ selectedFragment(PreferenceUtil.getInstance(this).getLastPage());
} else {
restoreCurrentFragment();
}
checkShowChangelog();
+
+ if (!RetroApplication.isProVersion() && !PreferenceManager.getDefaultSharedPreferences(this).getBoolean("shown", false)) {
+ showPromotionalOffer();
+ }
}
private void checkShowChangelog() {
@@ -153,7 +155,7 @@ public class MainActivity extends AbsSlidingMusicPanelActivity implements Shared
PreferenceUtil.getInstance(this).unregisterOnSharedPreferenceChangedListener(this);
}
- public void setCurrentFragment(@Nullable Fragment fragment, boolean isStackAdd, String tag) {
+ public void setCurrentFragment(@NonNull Fragment fragment, boolean isStackAdd, String tag) {
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
@@ -179,8 +181,7 @@ public class MainActivity extends AbsSlidingMusicPanelActivity implements Shared
String mimeType = intent.getType();
boolean handled = false;
- if (intent.getAction() != null && intent.getAction()
- .equals(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH)) {
+ if (intent.getAction() != null && intent.getAction().equals(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH)) {
final ArrayList songs = SearchQueryHelper.getSongs(this, intent.getExtras());
if (MusicPlayerRemote.getShuffleMode() == MusicService.SHUFFLE_MODE_SHUFFLE) {
@@ -291,7 +292,6 @@ public class MainActivity extends AbsSlidingMusicPanelActivity implements Shared
key.equals(PreferenceUtil.USER_NAME) ||
key.equals(PreferenceUtil.TOGGLE_FULL_SCREEN) ||
key.equals(PreferenceUtil.TOGGLE_VOLUME) ||
- key.equals(PreferenceUtil.TOGGLE_TAB_TITLES) ||
key.equals(PreferenceUtil.ROUND_CORNERS) ||
key.equals(PreferenceUtil.CAROUSEL_EFFECT) ||
key.equals(PreferenceUtil.NOW_PLAYING_SCREEN_ID) ||
@@ -305,7 +305,10 @@ public class MainActivity extends AbsSlidingMusicPanelActivity implements Shared
key.equals(PreferenceUtil.ARTIST_GRID_STYLE) ||
key.equals(PreferenceUtil.TOGGLE_HOME_BANNER) ||
key.equals(PreferenceUtil.TOGGLE_ADD_CONTROLS) ||
- key.equals(PreferenceUtil.ALBUM_COVER_STYLE)) postRecreate();
+ key.equals(PreferenceUtil.ALBUM_COVER_STYLE) ||
+ key.equals(PreferenceUtil.HOME_ARTIST_GRID_STYLE) ||
+ key.equals(PreferenceUtil.ALBUM_COVER_TRANSFORM) ||
+ key.equals(PreferenceUtil.TAB_TEXT_MODE)) postRecreate();
}
private void showPromotionalOffer() {
@@ -332,42 +335,18 @@ public class MainActivity extends AbsSlidingMusicPanelActivity implements Shared
}
private void selectedFragment(int itemId) {
- insideFragment = itemId;
switch (itemId) {
case R.id.action_album:
- setCurrentFragment(LIBRARY);
- break;
case R.id.action_artist:
- setCurrentFragment(LIBRARY);
- break;
case R.id.action_playlist:
- setCurrentFragment(LIBRARY);
- break;
case R.id.action_song:
- setCurrentFragment(LIBRARY);
+ setCurrentFragment(LibraryFragment.newInstance(itemId), false, LibraryFragment.TAG);
break;
- default:
case R.id.action_home:
- setCurrentFragment(HOME);
- break;
-
- }
- }
-
-
- public void setCurrentFragment(int key) {
- PreferenceUtil.getInstance(this).setLastMusicChooser(key);
- switch (key) {
- case LIBRARY:
- setCurrentFragment(LibraryFragment.newInstance(insideFragment), false, LibraryFragment.TAG);
- break;
- case FOLDERS:
- setCurrentFragment(FoldersFragment.newInstance(this), false, FoldersFragment.TAG);
- break;
- case HOME:
setCurrentFragment(PreferenceUtil.getInstance(this).toggleHomeBanner() ? HomeFragment.newInstance() :
BannerHomeFragment.newInstance(), false, HomeFragment.TAG);
break;
+
}
}
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/SettingsActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/SettingsActivity.java
index 69540d12..a9918d3c 100755
--- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/SettingsActivity.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/SettingsActivity.java
@@ -1,23 +1,25 @@
package code.name.monkey.retromusic.ui.activities;
+import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
-import androidx.annotation.ColorInt;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.annotation.StringRes;
-import com.google.android.material.appbar.AppBarLayout;
-import androidx.transition.TransitionManager;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-import androidx.appcompat.widget.Toolbar;
+import android.util.Log;
import android.view.MenuItem;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.afollestad.materialdialogs.color.ColorChooserDialog;
+import com.google.android.material.appbar.AppBarLayout;
+import androidx.annotation.ColorInt;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.annotation.StringRes;
+import androidx.appcompat.widget.Toolbar;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentTransaction;
+import androidx.transition.TransitionManager;
import butterknife.BindView;
import butterknife.ButterKnife;
import code.name.monkey.appthemehelper.ThemeStore;
@@ -28,7 +30,7 @@ import code.name.monkey.retromusic.ui.activities.base.AbsBaseActivity;
import code.name.monkey.retromusic.ui.fragments.settings.MainSettingsFragment;
import code.name.monkey.retromusic.util.PreferenceUtil;
-public class SettingsActivity extends AbsBaseActivity implements ColorChooserDialog.ColorCallback {
+public class SettingsActivity extends AbsBaseActivity implements ColorChooserDialog.ColorCallback, SharedPreferences.OnSharedPreferenceChangeListener {
@BindView(R.id.toolbar)
Toolbar toolbar;
@@ -102,8 +104,9 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
public void setupFragment(Fragment fragment, @StringRes int titleName) {
- FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction()
- .setCustomAnimations(R.animator.slide_up, 0, 0, R.animator.slide_down);
+ FragmentTransaction fragmentTransaction = fragmentManager
+ .beginTransaction()
+ .setCustomAnimations(R.anim.sliding_in_left, R.anim.sliding_out_right, android.R.anim.slide_in_left, android.R.anim.slide_out_right);
title.setText(titleName);
@@ -115,8 +118,6 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
fragmentTransaction.replace(R.id.detail_content_frame, fragment, fragment.getTag());
fragmentTransaction.commit();
}
-
-
}
@@ -143,4 +144,26 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
TransitionManager.beginDelayedTransition(appBarLayout);
appBarLayout.setElevation(v);
}
+
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ PreferenceUtil.getInstance(this).unregisterOnSharedPreferenceChangedListener(this);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ PreferenceUtil.getInstance(this).registerOnSharedPreferenceChangedListener(this);
+ }
+
+ private static final String TAG = "SettingsActivity";
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+ Log.i(TAG, "onSharedPreferenceChanged: ");
+ if (key.equals(PreferenceUtil.PROFILE_IMAGE_PATH)) {
+ recreate();
+ }
+ }
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/UserInfoActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/UserInfoActivity.java
index c41b27db..a14180ad 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/UserInfoActivity.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/UserInfoActivity.java
@@ -37,7 +37,6 @@ import code.name.monkey.retromusic.util.Compressor;
import code.name.monkey.retromusic.util.ImageUtil;
import code.name.monkey.retromusic.util.PreferenceUtil;
import code.name.monkey.retromusic.views.CircularImageView;
-import code.name.monkey.retromusic.views.IconImageView;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
@@ -63,12 +62,9 @@ public class UserInfoActivity extends AbsBaseActivity {
@BindView(R.id.user_image)
CircularImageView userImage;
- @BindView(R.id.image)
+ @BindView(R.id.banner_image)
ImageView image;
- @BindView(R.id.banner_select)
- IconImageView imageView;
-
@BindView(R.id.next)
FloatingActionButton nextButton;
@@ -171,11 +167,10 @@ public class UserInfoActivity extends AbsBaseActivity {
} else {
PreferenceUtil.getInstance(this).setBannerImagePath("");
image.setImageResource(android.R.color.transparent);
- imageView.setImageResource(R.drawable.ic_edit_white_24dp);
}
}
- @OnClick(R.id.image)
+ @OnClick(R.id.user_image)
public void onViewClicked() {
//noinspection ConstantConditions
new MaterialDialog.Builder(this)
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsCastActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsCastActivity.java
index bd279a0c..79c53ae7 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsCastActivity.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsCastActivity.java
@@ -2,9 +2,7 @@ package code.name.monkey.retromusic.ui.activities.base;
import android.os.Bundle;
import android.util.Log;
-import android.view.Menu;
-import com.google.android.gms.cast.framework.CastButtonFactory;
import com.google.android.gms.cast.framework.CastContext;
import com.google.android.gms.cast.framework.CastSession;
import com.google.android.gms.cast.framework.SessionManagerListener;
@@ -13,7 +11,6 @@ import com.google.android.gms.common.GoogleApiAvailability;
import java.io.IOException;
-import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.cast.WebServer;
public abstract class AbsCastActivity extends AbsBaseActivity {
@@ -134,14 +131,14 @@ public abstract class AbsCastActivity extends AbsBaseActivity {
castSession = castContext.getSessionManager().getCurrentCastSession();
}
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.menu_cast, menu);
- if (playServicesAvailable) {
- CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), menu, R.id.media_route_menu_item);
- }
- return true;
- }
+ /* @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.menu_cast, menu);
+ if (playServicesAvailable) {
+ CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), menu, R.id.media_route_menu_item);
+ }
+ return true;
+ }*/
public void showCastMiniController() {
//implement by overriding in activities
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsSlidingMusicPanelActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsSlidingMusicPanelActivity.java
index 6c860d81..c4f2aac7 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsSlidingMusicPanelActivity.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsSlidingMusicPanelActivity.java
@@ -10,7 +10,6 @@ import android.view.animation.PathInterpolator;
import com.google.android.gms.cast.framework.CastSession;
import com.google.android.material.bottomnavigation.BottomNavigationView;
-import com.google.android.material.bottomnavigation.LabelVisibilityMode;
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
import com.sothree.slidinguppanel.SlidingUpPanelLayout.PanelState;
@@ -167,7 +166,6 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
postRecreate();
}
}
-
@Override
public void onDestroy() {
super.onDestroy();
@@ -445,10 +443,7 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
int accentColor = ThemeStore.accentColor(this);
NavigationViewUtil.setItemIconColors(bottomNavigationView, ColorUtil.withAlpha(iconColor, 0.5f), accentColor);
NavigationViewUtil.setItemTextColors(bottomNavigationView, ColorUtil.withAlpha(iconColor, 0.5f), accentColor);
-
- if (!PreferenceUtil.getInstance(this).tabTitles()) {
- bottomNavigationView.setLabelVisibilityMode(LabelVisibilityMode.LABEL_VISIBILITY_UNLABELED);
- }
+ bottomNavigationView.setLabelVisibilityMode(PreferenceUtil.getInstance(this).getTabTitleMode());
}
@Override
@@ -473,4 +468,6 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
public BottomNavigationView getBottomNavigationView() {
return bottomNavigationView;
}
-}
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/MiniPlayerFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/MiniPlayerFragment.java
index 4d12d65b..c186655d 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/MiniPlayerFragment.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/MiniPlayerFragment.java
@@ -5,6 +5,9 @@ import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.ColorStateList;
import android.os.Bundle;
+import android.text.SpannableString;
+import android.text.SpannableStringBuilder;
+import android.text.style.ForegroundColorSpan;
import android.view.GestureDetector;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -21,11 +24,14 @@ import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import code.name.monkey.appthemehelper.ThemeStore;
+import code.name.monkey.appthemehelper.util.ColorUtil;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.helper.MusicPlayerRemote;
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper;
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler;
+import code.name.monkey.retromusic.model.Song;
import code.name.monkey.retromusic.ui.fragments.base.AbsMusicServiceFragment;
+import code.name.monkey.retromusic.util.NavigationUtil;
import code.name.monkey.retromusic.util.PreferenceUtil;
import code.name.monkey.retromusic.util.RetroUtil;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
@@ -44,6 +50,9 @@ public class MiniPlayerFragment extends AbsMusicServiceFragment implements Music
@BindView(R.id.action_prev)
View previous;
+ @BindView(R.id.action_playing_queue)
+ View playingQueue;
+
@BindView(R.id.progress_bar)
MaterialProgressBar progressBar;
@@ -68,17 +77,18 @@ public class MiniPlayerFragment extends AbsMusicServiceFragment implements Music
@Override
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
-
//noinspection ConstantConditions
- view.setBackgroundColor(ThemeStore.primaryColor(getContext()));
+ view.setBackgroundColor(ColorUtil.darkenColor(ThemeStore.primaryColor(getContext())));
view.setOnTouchListener(new FlingPlayBackController(getActivity()));
setUpMiniPlayer();
if (RetroUtil.isTablet(getResources())) {
next.setVisibility(View.VISIBLE);
previous.setVisibility(View.VISIBLE);
+ playingQueue.setVisibility(View.VISIBLE);
} else {
next.setVisibility(PreferenceUtil.getInstance(getContext()).isExtraMiniExtraControls() ? View.VISIBLE : View.GONE);
+ playingQueue.setVisibility(PreferenceUtil.getInstance(getContext()).isExtraMiniExtraControls() ? View.GONE : View.VISIBLE);
previous.setVisibility(PreferenceUtil.getInstance(getContext()).isExtraMiniExtraControls() ? View.VISIBLE : View.GONE);
}
}
@@ -101,7 +111,22 @@ public class MiniPlayerFragment extends AbsMusicServiceFragment implements Music
}
private void updateSongTitle() {
- miniPlayerTitle.setText(MusicPlayerRemote.getCurrentSong().title);
+ SpannableStringBuilder builder = new SpannableStringBuilder();
+
+ Song song = MusicPlayerRemote.getCurrentSong();
+ if (song == null) {
+ return;
+ }
+ SpannableString title = new SpannableString(song.title);
+ title.setSpan(new ForegroundColorSpan(ThemeStore.textColorPrimary(getContext())), 0, title.length(), 0);
+
+ SpannableString text = new SpannableString(song.artistName);
+ text.setSpan(new ForegroundColorSpan(ThemeStore.textColorSecondary(getContext())), 0, text.length(), 0);
+
+ builder.append(title).append(" • ").append(text);
+
+ miniPlayerTitle.setSelected(true);
+ miniPlayerTitle.setText(builder);
}
@Override
@@ -154,9 +179,12 @@ public class MiniPlayerFragment extends AbsMusicServiceFragment implements Music
getView().setBackgroundColor(playerFragmentColor);
}
- @OnClick({R.id.action_prev, R.id.action_next})
+ @OnClick({R.id.action_prev, R.id.action_playing_queue, R.id.action_next})
void onClicks(View view) {
switch (view.getId()) {
+ case R.id.action_playing_queue:
+ NavigationUtil.goToPlayingQueue(getActivity());
+ break;
case R.id.action_next:
MusicPlayerRemote.playNextSong();
break;
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/VolumeFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/VolumeFragment.java
index 8eb84bca..5ede2e6c 100755
--- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/VolumeFragment.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/VolumeFragment.java
@@ -4,17 +4,18 @@ import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.PorterDuff;
+import android.graphics.drawable.ColorDrawable;
import android.media.AudioManager;
import android.os.Bundle;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.SeekBar;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
@@ -155,4 +156,8 @@ public class VolumeFragment extends Fragment implements SeekBar.OnSeekBarChangeL
public void setTintable(int color) {
setProgressBarColor(color);
}
+
+ public void removeThumb() {
+ volumeSeekbar.setThumb(null);
+ }
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsMainActivityFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsMainActivityFragment.java
index 7bf4600f..3eb9cd03 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsMainActivityFragment.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsMainActivityFragment.java
@@ -21,11 +21,12 @@ public abstract class AbsMainActivityFragment extends AbsMusicServiceFragment {
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setHasOptionsMenu(true);
- //getMainActivity().setStatusbarColorAuto();
+
getMainActivity().setNavigationbarColorAuto();
getMainActivity().setLightNavigationBar(true);
getMainActivity().setTaskDescriptionColorAuto();
getMainActivity().hideStatusBar();
+ getMainActivity().setBottomBarVisibility(View.VISIBLE);
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/LibraryFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/LibraryFragment.java
index b98c92e7..6abaaae3 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/LibraryFragment.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/LibraryFragment.java
@@ -42,7 +42,6 @@ import code.name.monkey.retromusic.ui.activities.SettingsActivity;
import code.name.monkey.retromusic.ui.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment;
import code.name.monkey.retromusic.ui.fragments.base.AbsMainActivityFragment;
import code.name.monkey.retromusic.util.NavigationUtil;
-import code.name.monkey.retromusic.util.PreferenceUtil;
import code.name.monkey.retromusic.util.RetroColorUtil;
import code.name.monkey.retromusic.util.RetroUtil;
@@ -150,7 +149,7 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
getMainActivity().setLightStatusbar(!ATHUtil.isWindowBackgroundDark(getContext())));
getMainActivity().setTitle(null);
getMainActivity().setSupportActionBar(toolbar);
- toolbar.setNavigationOnClickListener(v -> showMainMenu( ));
+ toolbar.setNavigationOnClickListener(v -> showMainMenu());
}
private Fragment getCurrentFragment() {
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/folders/FoldersFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/folders/FoldersFragment.java
index 61cf1d15..b225beb1 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/folders/FoldersFragment.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/folders/FoldersFragment.java
@@ -200,6 +200,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
getMainActivity().setBottomBarVisibility(View.GONE);
+
if (savedInstanceState == null) {
//noinspection ConstantConditions
setCrumb(new BreadCrumbLayout.Crumb(
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/home/BannerHomeFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/home/BannerHomeFragment.java
index a78dd7f5..8ab4c08c 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/home/BannerHomeFragment.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/home/BannerHomeFragment.java
@@ -10,6 +10,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
+import android.widget.LinearLayout;
import android.widget.TextView;
import com.bumptech.glide.Glide;
@@ -27,6 +28,7 @@ import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.GridLayoutManager;
+import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -49,6 +51,7 @@ import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist;
import code.name.monkey.retromusic.model.smartplaylist.MyTopTracksPlaylist;
import code.name.monkey.retromusic.mvp.contract.HomeContract;
import code.name.monkey.retromusic.mvp.presenter.HomePresenter;
+import code.name.monkey.retromusic.ui.adapter.GenreAdapter;
import code.name.monkey.retromusic.ui.adapter.album.AlbumFullWithAdapter;
import code.name.monkey.retromusic.ui.adapter.artist.ArtistAdapter;
import code.name.monkey.retromusic.ui.fragments.base.AbsMainActivityFragment;
@@ -108,6 +111,12 @@ public class BannerHomeFragment extends AbsMainActivityFragment implements MainA
@BindView(R.id.top_albums_container)
View topAlbumContainer;
+ @BindView(R.id.genres)
+ RecyclerView genresRecyclerView;
+
+ @BindView(R.id.genre_container)
+ LinearLayout genreContainer;
+
@BindView(R.id.container)
View container;
@@ -290,7 +299,7 @@ public class BannerHomeFragment extends AbsMainActivityFragment implements MainA
recentArtistRV.setLayoutManager(new GridLayoutManager(getMainActivity(),
1, GridLayoutManager.HORIZONTAL, false));
ArtistAdapter artistAdapter = new ArtistAdapter(getMainActivity(), artists,
- R.layout.item_artist, false, null);
+ PreferenceUtil.getInstance(getContext()).getHomeGridStyle(getContext()), false, null);
recentArtistRV.setAdapter(artistAdapter);
}
@@ -309,7 +318,7 @@ public class BannerHomeFragment extends AbsMainActivityFragment implements MainA
topArtistRV.setLayoutManager(new GridLayoutManager(getMainActivity(),
1, GridLayoutManager.HORIZONTAL, false));
ArtistAdapter artistAdapter = new ArtistAdapter(getMainActivity(), artists,
- R.layout.item_artist, false, null);
+ PreferenceUtil.getInstance(getContext()).getHomeGridStyle(getContext()), false, null);
topArtistRV.setAdapter(artistAdapter);
}
@@ -339,9 +348,13 @@ public class BannerHomeFragment extends AbsMainActivityFragment implements MainA
@Override
public void geners(ArrayList genres) {
+ genreContainer.setVisibility(View.VISIBLE);
+ genresRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
+ //noinspection ConstantConditions
+ GenreAdapter genreAdapter = new GenreAdapter(getActivity(), genres, R.layout.item_list);
+ genresRecyclerView.setAdapter(genreAdapter);
}
-
@OnClick({R.id.last_added, R.id.top_played, R.id.action_shuffle, R.id.history,
R.id.user_image, R.id.search})
void startUserInfo(View view) {
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/home/HomeFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/home/HomeFragment.java
index 351b9d98..360d5d58 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/home/HomeFragment.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/home/HomeFragment.java
@@ -1,8 +1,8 @@
package code.name.monkey.retromusic.ui.fragments.mainactivity.home;
import android.animation.AnimatorSet;
-import android.animation.ObjectAnimator;
import android.app.Activity;
+import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.util.DisplayMetrics;
@@ -10,8 +10,8 @@ import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.view.animation.AccelerateInterpolator;
import android.widget.ImageView;
+import android.widget.LinearLayout;
import android.widget.TextView;
import com.google.android.material.appbar.AppBarLayout;
@@ -25,6 +25,7 @@ import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.core.widget.NestedScrollView;
import androidx.recyclerview.widget.GridLayoutManager;
+import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -46,6 +47,7 @@ import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist;
import code.name.monkey.retromusic.model.smartplaylist.MyTopTracksPlaylist;
import code.name.monkey.retromusic.mvp.contract.HomeContract;
import code.name.monkey.retromusic.mvp.presenter.HomePresenter;
+import code.name.monkey.retromusic.ui.adapter.GenreAdapter;
import code.name.monkey.retromusic.ui.adapter.album.AlbumFullWithAdapter;
import code.name.monkey.retromusic.ui.adapter.artist.ArtistAdapter;
import code.name.monkey.retromusic.ui.fragments.base.AbsMainActivityFragment;
@@ -65,6 +67,7 @@ public class HomeFragment extends AbsMainActivityFragment implements MainActivit
private final AnimatorSet animatorSet = new AnimatorSet();
Unbinder unbinder;
+
@BindView(R.id.toolbar)
Toolbar toolbar;
@@ -98,12 +101,21 @@ public class HomeFragment extends AbsMainActivityFragment implements MainActivit
@BindView(R.id.top_albums_container)
View topAlbumContainer;
+ @BindView(R.id.genres)
+ RecyclerView genresRecyclerView;
+
+ @BindView(R.id.genre_container)
+ LinearLayout genreContainer;
+
@BindView(R.id.content_container)
NestedScrollView contentContainer;
@BindView(R.id.title)
TextView title;
+ @BindView(R.id.search_icon)
+ ImageView searchIcon;
+
private HomePresenter homePresenter;
private CompositeDisposable disposable;
@@ -172,22 +184,7 @@ public class HomeFragment extends AbsMainActivityFragment implements MainActivit
getMainActivity().setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(v -> showMainMenu());
title.setTextColor(ThemeStore.textColorPrimary(getContext()));
- }
-
- private void toggleMenu(boolean backdropShown) {
- // Cancel the existing animations
- animatorSet.removeAllListeners();
- animatorSet.end();
- animatorSet.cancel();
-
-
- final int translateY = 300;
-
- ObjectAnimator animator = ObjectAnimator.ofFloat(contentContainer, "translationY", backdropShown ? translateY : 0);
- animator.setDuration(500);
- animator.setInterpolator(new AccelerateInterpolator());
- animatorSet.play(animator);
- animator.start();
+ searchIcon.setImageTintList(ColorStateList.valueOf(ThemeStore.accentColor(getContext())));
}
@Override
@@ -227,7 +224,7 @@ public class HomeFragment extends AbsMainActivityFragment implements MainActivit
public void recentArtist(ArrayList artists) {
recentArtistContainer.setVisibility(View.VISIBLE);
recentArtistRV.setLayoutManager(new GridLayoutManager(getMainActivity(), 1, GridLayoutManager.HORIZONTAL, false));
- ArtistAdapter artistAdapter = new ArtistAdapter(getMainActivity(), artists, R.layout.item_artist, false, null);
+ ArtistAdapter artistAdapter = new ArtistAdapter(getMainActivity(), artists, PreferenceUtil.getInstance(getContext()).getHomeGridStyle(getContext()), false, null);
recentArtistRV.setAdapter(artistAdapter);
}
@@ -243,9 +240,8 @@ public class HomeFragment extends AbsMainActivityFragment implements MainActivit
public void topArtists(ArrayList artists) {
topArtistContainer.setVisibility(View.VISIBLE);
topArtistRV.setLayoutManager(new GridLayoutManager(getMainActivity(), 1, GridLayoutManager.HORIZONTAL, false));
- ArtistAdapter artistAdapter = new ArtistAdapter(getMainActivity(), artists, R.layout.item_artist, false, null);
+ ArtistAdapter artistAdapter = new ArtistAdapter(getMainActivity(), artists, PreferenceUtil.getInstance(getContext()).getHomeGridStyle(getContext()), false, null);
topArtistRV.setAdapter(artistAdapter);
-
}
@Override
@@ -260,7 +256,6 @@ public class HomeFragment extends AbsMainActivityFragment implements MainActivit
Display display = getMainActivity().getWindowManager().getDefaultDisplay();
DisplayMetrics metrics = new DisplayMetrics();
display.getMetrics(metrics);
-
return metrics;
}
@@ -272,9 +267,13 @@ public class HomeFragment extends AbsMainActivityFragment implements MainActivit
@Override
public void geners(ArrayList genres) {
+ genreContainer.setVisibility(View.VISIBLE);
+ genresRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
+ //noinspection ConstantConditions
+ GenreAdapter genreAdapter = new GenreAdapter(getActivity(), genres, R.layout.item_list);
+ genresRecyclerView.setAdapter(genreAdapter);
}
-
@OnClick({R.id.last_added, R.id.top_played, R.id.action_shuffle, R.id.history, R.id.user_image, R.id.search})
void startUserInfo(View view) {
Activity activity = getActivity();
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/PlayerAlbumCoverFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/PlayerAlbumCoverFragment.java
index e88eef6e..39fbe688 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/PlayerAlbumCoverFragment.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/PlayerAlbumCoverFragment.java
@@ -12,8 +12,7 @@ import butterknife.ButterKnife;
import butterknife.Unbinder;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.helper.MusicPlayerRemote;
-import code.name.monkey.retromusic.transform.CustPagerTransformer;
-import code.name.monkey.retromusic.transform.NormalPageTransformer;
+import code.name.monkey.retromusic.transform.CarousalPagerTransformer;
import code.name.monkey.retromusic.transform.ParallaxPagerTransformer;
import code.name.monkey.retromusic.ui.adapter.album.AlbumCoverPagerAdapter;
import code.name.monkey.retromusic.ui.fragments.NowPlayingScreen;
@@ -67,9 +66,9 @@ public class PlayerAlbumCoverFragment extends AbsMusicServiceFragment implements
viewPager.setClipToPadding(false);
viewPager.setPadding(96, 0, 96, 0);
viewPager.setPageMargin(18);
- viewPager.setPageTransformer(false, new CustPagerTransformer(getContext()));
+ viewPager.setPageTransformer(false, new CarousalPagerTransformer(getContext()));
} else {
- viewPager.setPageTransformer(true, new NormalPageTransformer());
+ viewPager.setPageTransformer(true, PreferenceUtil.getInstance(getContext()).getAlbumCoverTransform(getContext()));
}
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/cardblur/CardBlurFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/cardblur/CardBlurFragment.java
index c3a44c9d..adf4b7eb 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/cardblur/CardBlurFragment.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/cardblur/CardBlurFragment.java
@@ -4,10 +4,6 @@ import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.preference.PreferenceManager;
-import androidx.annotation.ColorInt;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.appcompat.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -15,6 +11,10 @@ import android.widget.ImageView;
import com.bumptech.glide.Glide;
+import androidx.annotation.ColorInt;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.widget.Toolbar;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
@@ -25,6 +25,7 @@ import code.name.monkey.retromusic.glide.RetroMusicColoredTarget;
import code.name.monkey.retromusic.glide.SongGlideRequest;
import code.name.monkey.retromusic.helper.MusicPlayerRemote;
import code.name.monkey.retromusic.model.Song;
+import code.name.monkey.retromusic.ui.fragments.VolumeFragment;
import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerFragment;
import code.name.monkey.retromusic.ui.fragments.player.PlayerAlbumCoverFragment;
import code.name.monkey.retromusic.ui.fragments.player.normal.PlayerFragment;
@@ -137,6 +138,8 @@ public class CardBlurFragment extends AbsPlayerFragment implements
(PlayerAlbumCoverFragment) getChildFragmentManager().findFragmentById(R.id.player_album_cover_fragment);
playerAlbumCoverFragment.setCallbacks(this);
playerAlbumCoverFragment.removeEffect();
+
+
}
private void setUpPlayerToolbar() {
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/cardblur/CardBlurPlaybackControlsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/cardblur/CardBlurPlaybackControlsFragment.java
index 9a8b170b..19f2a032 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/cardblur/CardBlurPlaybackControlsFragment.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/player/cardblur/CardBlurPlaybackControlsFragment.java
@@ -5,9 +5,6 @@ import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.os.Bundle;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.appcompat.widget.AppCompatSeekBar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -18,6 +15,9 @@ import android.widget.ImageButton;
import android.widget.SeekBar;
import android.widget.TextView;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.widget.AppCompatSeekBar;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
@@ -41,26 +41,37 @@ import code.name.monkey.retromusic.views.PlayPauseDrawable;
public class CardBlurPlaybackControlsFragment extends AbsPlayerControlsFragment {
@BindView(R.id.player_play_pause_button)
ImageButton playPauseFab;
+
@BindView(R.id.player_prev_button)
ImageButton prevButton;
+
@BindView(R.id.player_next_button)
ImageButton nextButton;
+
@BindView(R.id.player_repeat_button)
ImageButton repeatButton;
+
@BindView(R.id.player_shuffle_button)
ImageButton shuffleButton;
+
@BindView(R.id.player_progress_slider)
AppCompatSeekBar progressSlider;
+
@BindView(R.id.player_song_total_time)
TextView songTotalTime;
+
@BindView(R.id.player_song_current_progress)
TextView songCurrentProgress;
+
@BindView(R.id.volume_fragment_container)
View volumeContainer;
+
@BindView(R.id.text)
TextView text;
+
@BindView(R.id.title)
TextView title;
+
private Unbinder unbinder;
private PlayPauseDrawable playerFabPlayPauseDrawable;
private int lastPlaybackControlsColor;
@@ -88,12 +99,12 @@ public class CardBlurPlaybackControlsFragment extends AbsPlayerControlsFragment
}
@Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
+ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
unbinder = ButterKnife.bind(this, view);
setUpMusicControllers();
hideVolumeIfAvailable();
-
+ title.setSelected(true);
}
@Override
@@ -198,7 +209,9 @@ public class CardBlurPlaybackControlsFragment extends AbsPlayerControlsFragment
private void setupVolumeControls() {
VolumeFragment volumeFragment = (VolumeFragment) getChildFragmentManager()
.findFragmentById(R.id.volume_fragment);
- volumeFragment.tintWhiteColor();
+ if (volumeFragment != null) {
+ volumeFragment.tintWhiteColor();
+ }
}
private void setUpPrevNext() {
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/MainSettingsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/MainSettingsFragment.java
index 04dc8070..c14807de 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/MainSettingsFragment.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/settings/MainSettingsFragment.java
@@ -1,16 +1,21 @@
package code.name.monkey.retromusic.ui.fragments.settings;
+import android.graphics.Bitmap;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import java.io.File;
+import java.util.Calendar;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
+import androidx.appcompat.widget.AppCompatTextView;
+import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import butterknife.BindView;
import butterknife.BindViews;
@@ -20,7 +25,16 @@ import butterknife.Unbinder;
import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.ui.activities.SettingsActivity;
+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.IconImageView;
+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 MainSettingsFragment extends Fragment {
@@ -31,12 +45,18 @@ public class MainSettingsFragment extends Fragment {
@BindView(R.id.container)
ViewGroup container;
-
+ @BindView(R.id.user_image_bottom)
+ CircularImageView userImageBottom;
+ @BindView(R.id.title_welcome)
+ AppCompatTextView titleWelcome;
+ @BindView(R.id.text)
+ AppCompatTextView text;
private Unbinder unbinder;
private ButterKnife.Action apply = (view, index) -> {
//noinspection ConstantConditions
((IconImageView) view).setColorFilter(ThemeStore.accentColor(getContext()), PorterDuff.Mode.SRC_IN);
};
+ private CompositeDisposable disposable = new CompositeDisposable();
@Nullable
@Override
@@ -48,15 +68,26 @@ public class MainSettingsFragment extends Fragment {
return layout;
}
+ @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(getContext()).getUserName()));
+ loadImageFromStorage();
+ }
+
@Override
public void onDestroyView() {
super.onDestroyView();
+ disposable.clear();
unbinder.unbind();
}
@OnClick({R.id.general_settings, R.id.audio_settings, R.id.now_playing_settings,
- R.id.image_settings, R.id.personalize_settings, R.id.notification_settings, R.id.other_settings})
+ R.id.user_info_container, R.id.image_settings, R.id.personalize_settings, R.id.notification_settings, R.id.other_settings})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.general_settings:
@@ -65,6 +96,9 @@ public class MainSettingsFragment extends Fragment {
case R.id.audio_settings:
inflateFragment(new AudioSettings(), R.string.pref_header_audio);
break;
+ case R.id.user_info_container:
+ NavigationUtil.goToUserInfo(getActivity());
+ break;
case R.id.now_playing_settings:
inflateFragment(new NowPlayingSettingsFragment(), R.string.now_playing);
break;
@@ -88,4 +122,41 @@ public class MainSettingsFragment extends Fragment {
((SettingsActivity) getActivity()).setupFragment(fragment, title);
}
}
+
+ 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(getContext()).getProfileImage(), USER_PROFILE))
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(userImageBottom::setImageBitmap,
+ throwable -> userImageBottom.setImageDrawable(ContextCompat
+ .getDrawable(getContext(), R.drawable.ic_person_flat))));
+ }
+
}
\ No newline at end of file
diff --git a/app/src/main/java/code/name/monkey/retromusic/util/MusicLibrary.java b/app/src/main/java/code/name/monkey/retromusic/util/MusicLibrary.java
new file mode 100644
index 00000000..2c892e9e
--- /dev/null
+++ b/app/src/main/java/code/name/monkey/retromusic/util/MusicLibrary.java
@@ -0,0 +1,123 @@
+package code.name.monkey.retromusic.util;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.support.v4.media.MediaBrowserCompat;
+import android.support.v4.media.MediaMetadataCompat;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.TreeMap;
+
+import code.name.monkey.retromusic.BuildConfig;
+
+public class MusicLibrary {
+ private static final TreeMap music = new TreeMap<>();
+ private static final HashMap albumRes = new HashMap<>();
+ private static final HashMap musicRes = new HashMap<>();
+
+ public static String getRoot() {
+ return "root";
+ }
+
+ public static String getSongUri(String mediaId) {
+ return "android.resource://" + BuildConfig.APPLICATION_ID + "/" + getMusicRes(mediaId);
+ }
+
+ private static String getAlbumArtUri(String albumArtResName) {
+ return "android.resource://" + BuildConfig.APPLICATION_ID + "/drawable/" + albumArtResName;
+ }
+
+ private static int getMusicRes(String mediaId) {
+ return musicRes.containsKey(mediaId) ? musicRes.get(mediaId) : 0;
+ }
+
+ private static int getAlbumRes(String mediaId) {
+ return albumRes.containsKey(mediaId) ? albumRes.get(mediaId) : 0;
+ }
+
+ public static Bitmap getAlbumBitmap(Context ctx, String mediaId) {
+ return BitmapFactory.decodeResource(ctx.getResources(), MusicLibrary.getAlbumRes(mediaId));
+ }
+
+ public static List getMediaItems() {
+ List result = new ArrayList<>();
+ for (MediaMetadataCompat metadata : music.values()) {
+ result.add(
+ new MediaBrowserCompat.MediaItem(
+ metadata.getDescription(), MediaBrowserCompat.MediaItem.FLAG_PLAYABLE));
+ }
+ return result;
+ }
+
+ public static String getPreviousSong(String currentMediaId) {
+ String prevMediaId = music.lowerKey(currentMediaId);
+ if (prevMediaId == null) {
+ prevMediaId = music.firstKey();
+ }
+ return prevMediaId;
+ }
+
+ public static String getNextSong(String currentMediaId) {
+ String nextMediaId = music.higherKey(currentMediaId);
+ if (nextMediaId == null) {
+ nextMediaId = music.firstKey();
+ }
+ return nextMediaId;
+ }
+
+ public static MediaMetadataCompat getMetadata(Context ctx, String mediaId) {
+ MediaMetadataCompat metadataWithoutBitmap = music.get(mediaId);
+ Bitmap albumArt = getAlbumBitmap(ctx, mediaId);
+
+ // Since MediaMetadataCompat is immutable, we need to create a copy to set the album art.
+ // We don't set it initially on all items so that they don't take unnecessary memory.
+ MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder();
+ for (String key :
+ new String[]{
+ MediaMetadataCompat.METADATA_KEY_MEDIA_ID,
+ MediaMetadataCompat.METADATA_KEY_ALBUM,
+ MediaMetadataCompat.METADATA_KEY_ARTIST,
+ MediaMetadataCompat.METADATA_KEY_GENRE,
+ MediaMetadataCompat.METADATA_KEY_TITLE
+ }) {
+ builder.putString(key, metadataWithoutBitmap.getString(key));
+ }
+ builder.putLong(
+ MediaMetadataCompat.METADATA_KEY_DURATION,
+ metadataWithoutBitmap.getLong(MediaMetadataCompat.METADATA_KEY_DURATION));
+ builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, albumArt);
+ return builder.build();
+ }
+
+ private static void createMediaMetadataCompat(
+ String mediaId,
+ String title,
+ String artist,
+ String album,
+ String genre,
+ long duration,
+ int musicResId,
+ int albumArtResId,
+ String albumArtResName) {
+ music.put(mediaId,
+ new MediaMetadataCompat.Builder()
+ .putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, mediaId)
+ .putString(MediaMetadataCompat.METADATA_KEY_ALBUM, album)
+ .putString(MediaMetadataCompat.METADATA_KEY_ARTIST, artist)
+ .putLong(MediaMetadataCompat.METADATA_KEY_DURATION, duration * 1000)
+ .putString(MediaMetadataCompat.METADATA_KEY_GENRE, genre)
+ .putString(
+ MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI,
+ getAlbumArtUri(albumArtResName))
+ .putString(
+ MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON_URI,
+ getAlbumArtUri(albumArtResName))
+ .putString(MediaMetadataCompat.METADATA_KEY_TITLE, title)
+ .build());
+ albumRes.put(mediaId, albumArtResId);
+ musicRes.put(mediaId, musicResId);
+ }
+}
diff --git a/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java
index 6afcbbca..326009ca 100644
--- a/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java
+++ b/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java
@@ -7,6 +7,7 @@ import android.content.SharedPreferences.Editor;
import android.content.res.TypedArray;
import android.preference.PreferenceManager;
+import com.google.android.material.bottomnavigation.LabelVisibilityMode;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
@@ -14,14 +15,18 @@ import com.google.gson.reflect.TypeToken;
import java.io.File;
import java.lang.reflect.Type;
import java.util.ArrayList;
+import java.util.Objects;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.StyleRes;
+import androidx.viewpager.widget.ViewPager;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.RetroApplication;
import code.name.monkey.retromusic.helper.SortOrder;
import code.name.monkey.retromusic.model.CategoryInfo;
+import code.name.monkey.retromusic.transform.CascadingPageTransformer;
+import code.name.monkey.retromusic.transform.NormalPageTransformer;
import code.name.monkey.retromusic.ui.activities.MainActivity;
import code.name.monkey.retromusic.ui.fragments.AlbumCoverStyle;
import code.name.monkey.retromusic.ui.fragments.NowPlayingScreen;
@@ -53,9 +58,12 @@ public final class PreferenceUtil {
public static final String ADAPTIVE_COLOR_APP = "adaptive_color_app";
public static final String TOGGLE_SEPARATE_LINE = "toggle_separate_line";
public static final String ALBUM_GRID_STYLE = "album_grid_style";
+ public static final String HOME_ARTIST_GRID_STYLE = "home_artist_grid_style";
public static final String ARTIST_GRID_STYLE = "artist_grid_style";
public static final String TOGGLE_ADD_CONTROLS = "toggle_add_controls";
public static final String ALBUM_COVER_STYLE = "album_cover_style";
+ public static final String ALBUM_COVER_TRANSFORM = "album_cover_transform";
+ public static final String TAB_TEXT_MODE = "tab_text_mode";
private static final String GENRE_SORT_ORDER = "genre_sort_order";
private static final String LIBRARY_CATEGORIES = "library_categories";
private static final String LAST_PAGE = "last_start_page";
@@ -93,13 +101,10 @@ public final class PreferenceUtil {
private static final String ALBUM_DETAIL_SONG_SORT_ORDER = "album_detail_song_sort_order";
private static final String ARTIST_DETAIL_SONG_SORT_ORDER = "artist_detail_song_sort_order";
private static final String LYRICS_OPTIONS = "lyrics_options";
- private static final String SAF_SDCARD_URI = "saf_sdcard_uri";
- private static final String DOCUMENT_TREE_URI = "document_tree_uri";
private static final String CHOOSE_EQUALIZER = "choose_equalizer";
private static final String TOGGLE_SHUFFLE = "toggle_shuffle";
private static final String SONG_GRID_STYLE = "song_grid_style";
private static final String TOGGLE_ANIMATIONS = "toggle_animations";
- private static final String TAG = "PreferenceUtil";
private static final String LAST_KNOWN_LYRICS_TYPE = "LAST_KNOWN_LYRICS_TYPE";
private static PreferenceUtil sInstance;
private final SharedPreferences mPreferences;
@@ -705,12 +710,21 @@ public final class PreferenceUtil {
return layoutRes;
}
- public void setAlbumGridStyle(int type) {
- mPreferences.edit().putInt(ALBUM_GRID_STYLE, type).apply();
+ @LayoutRes
+ public int getHomeGridStyle(Context context) {
+ int pos = Integer.parseInt(mPreferences.getString(HOME_ARTIST_GRID_STYLE, "0"));
+ TypedArray typedArray = context.getResources().obtainTypedArray(R.array.pref_home_grid_style_layout);
+ int layoutRes = typedArray.getResourceId(pos, -1);
+ typedArray.recycle();
+ if (layoutRes == -1) {
+ return R.layout.item_artist;
+ }
+ return layoutRes;
}
+
public int getArtistGridStyle(Context context) {
- int pos = Integer.parseInt(mPreferences.getString(ARTIST_GRID_STYLE, "0"));
+ int pos = Integer.parseInt(Objects.requireNonNull(mPreferences.getString(ARTIST_GRID_STYLE, "0")));
TypedArray typedArray = context.getResources().obtainTypedArray(R.array.pref_grid_style_layout);
int layoutRes = typedArray.getResourceId(pos, -1);
typedArray.recycle();
@@ -741,4 +755,30 @@ public final class PreferenceUtil {
}
+ public ViewPager.PageTransformer getAlbumCoverTransform(Context context) {
+ int style = Integer.parseInt(Objects.requireNonNull(mPreferences.getString(ALBUM_COVER_TRANSFORM, "0")));
+ switch (style) {
+ default:
+ case 0:
+ return new NormalPageTransformer();
+ case 1:
+ return new CascadingPageTransformer();
+ }
+ }
+
+ @LabelVisibilityMode
+ public int getTabTitleMode() {
+ int mode = Integer.parseInt(mPreferences.getString(TAB_TEXT_MODE, "1"));
+ switch (mode) {
+ default:
+ case 1:
+ return LabelVisibilityMode.LABEL_VISIBILITY_LABELED;
+ case 0:
+ return LabelVisibilityMode.LABEL_VISIBILITY_AUTO;
+ case 2:
+ return LabelVisibilityMode.LABEL_VISIBILITY_SELECTED;
+ case 3:
+ return LabelVisibilityMode.LABEL_VISIBILITY_UNLABELED;
+ }
+ }
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/util/RetroUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/RetroUtil.java
index 2b57147b..6ff051d3 100755
--- a/app/src/main/java/code/name/monkey/retromusic/util/RetroUtil.java
+++ b/app/src/main/java/code/name/monkey/retromusic/util/RetroUtil.java
@@ -19,12 +19,6 @@ import android.os.Build;
import android.os.ResultReceiver;
import android.provider.BaseColumns;
import android.provider.MediaStore;
-import androidx.annotation.ColorInt;
-import androidx.annotation.DrawableRes;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
-import androidx.core.content.ContextCompat;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.View;
@@ -40,6 +34,12 @@ import java.net.NetworkInterface;
import java.util.Collections;
import java.util.List;
+import androidx.annotation.ColorInt;
+import androidx.annotation.DrawableRes;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
+import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.appthemehelper.util.TintHelper;
import code.name.monkey.retromusic.RetroApplication;
@@ -55,8 +55,7 @@ public class RetroUtil {
}
public static Uri getAlbumArtUri(long paramInt) {
- return ContentUris
- .withAppendedId(Uri.parse("content://media/external/audio/albumart"), paramInt);
+ return ContentUris.withAppendedId(Uri.parse("content://media/external/audio/albumart"), paramInt);
}
public static String EncodeString(String string) {
diff --git a/app/src/main/java/code/name/monkey/retromusic/views/RoundedBottomSheetDialogFragment.java b/app/src/main/java/code/name/monkey/retromusic/views/RoundedBottomSheetDialogFragment.java
index aa5ccf3e..96b1a138 100644
--- a/app/src/main/java/code/name/monkey/retromusic/views/RoundedBottomSheetDialogFragment.java
+++ b/app/src/main/java/code/name/monkey/retromusic/views/RoundedBottomSheetDialogFragment.java
@@ -2,20 +2,23 @@ package code.name.monkey.retromusic.views;
import android.annotation.SuppressLint;
import android.app.Dialog;
+import android.os.Build;
import android.os.Bundle;
-import android.view.ViewGroup;
+import android.view.View;
+import android.view.ViewTreeObserver;
+import android.view.Window;
+import android.widget.FrameLayout;
+import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
-import java.util.Objects;
-
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import code.name.monkey.appthemehelper.ThemeStore;
+import code.name.monkey.appthemehelper.util.ATHUtil;
import code.name.monkey.appthemehelper.util.ColorUtil;
import code.name.monkey.retromusic.R;
-import code.name.monkey.retromusic.ui.activities.base.AbsThemeActivity;
import code.name.monkey.retromusic.util.PreferenceUtil;
/**
@@ -41,14 +44,38 @@ public class RoundedBottomSheetDialogFragment extends BottomSheetDialogFragment
}
}
+ @Override
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
+ @Override
+ public void onGlobalLayout() {
+ BottomSheetDialog dialog = (BottomSheetDialog) getDialog();
+ FrameLayout bottomSheet = (FrameLayout) dialog.findViewById(R.id.design_bottom_sheet);
+ BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomSheet);
+ behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
+ //behavior.setPeekHeight(0);
+ }
+ });
+ }
+
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
- AbsThemeActivity absThemeActivity = (AbsThemeActivity) getActivity();
- if (absThemeActivity != null) {
- absThemeActivity.setLightNavigationBar(true);
- }
//noinspection ConstantConditions
return new BottomSheetDialog(getContext(), getTheme());
}
+
+ @Override
+ public void onStart() {
+ super.onStart();
+ if (getDialog() != null && getDialog().getWindow() != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ Window window = getDialog().getWindow();
+ window.findViewById(com.google.android.material.R.id.container).setFitsSystemWindows(false);
+ // dark navigation bar icons
+ View decorView = window.getDecorView();
+ if (!ATHUtil.isWindowBackgroundDark(getContext()))
+ decorView.setSystemUiVisibility(decorView.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
+ }
+ }
}
\ No newline at end of file
diff --git a/app/src/main/res/anim/slide_in_left.xml b/app/src/main/res/anim/slide_in_left.xml
new file mode 100644
index 00000000..5b01fc74
--- /dev/null
+++ b/app/src/main/res/anim/slide_in_left.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/anim/sliding_in_left.xml b/app/src/main/res/anim/sliding_in_left.xml
new file mode 100644
index 00000000..5b01fc74
--- /dev/null
+++ b/app/src/main/res/anim/sliding_in_left.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/anim/sliding_out_right.xml b/app/src/main/res/anim/sliding_out_right.xml
new file mode 100644
index 00000000..964d042f
--- /dev/null
+++ b/app/src/main/res/anim/sliding_out_right.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/abs_history_playlist.xml b/app/src/main/res/drawable/abs_history_playlist.xml
index 59cbe320..c84f7165 100644
--- a/app/src/main/res/drawable/abs_history_playlist.xml
+++ b/app/src/main/res/drawable/abs_history_playlist.xml
@@ -2,5 +2,5 @@
-
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/abs_last_added_playlist.xml b/app/src/main/res/drawable/abs_last_added_playlist.xml
index 00f45bc1..c362ee34 100644
--- a/app/src/main/res/drawable/abs_last_added_playlist.xml
+++ b/app/src/main/res/drawable/abs_last_added_playlist.xml
@@ -2,5 +2,5 @@
-
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/abs_shuffle.xml b/app/src/main/res/drawable/abs_shuffle.xml
index ddd4e70a..b93fd3f4 100644
--- a/app/src/main/res/drawable/abs_shuffle.xml
+++ b/app/src/main/res/drawable/abs_shuffle.xml
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/abs_top_tracks_playlist.xml b/app/src/main/res/drawable/abs_top_tracks_playlist.xml
index 045a506d..68978070 100644
--- a/app/src/main/res/drawable/abs_top_tracks_playlist.xml
+++ b/app/src/main/res/drawable/abs_top_tracks_playlist.xml
@@ -2,5 +2,5 @@
-
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/card.xml b/app/src/main/res/drawable/card.xml
index ace882f3..51265cae 100644
--- a/app/src/main/res/drawable/card.xml
+++ b/app/src/main/res/drawable/card.xml
@@ -20,7 +20,7 @@
android:right="0dp"
android:top="0dp" />
-
+
-
@@ -31,14 +31,14 @@
android:right="0dp"
android:top="0dp" />
-
+
-
-
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/et_bg_circular_top_corners.xml b/app/src/main/res/drawable/et_bg_circular_top_corners.xml
deleted file mode 100644
index 35ea574f..00000000
--- a/app/src/main/res/drawable/et_bg_circular_top_corners.xml
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/app/src/main/res/drawable/gradient_1.xml b/app/src/main/res/drawable/gradient_1.xml
deleted file mode 100644
index 056d7bfd..00000000
--- a/app/src/main/res/drawable/gradient_1.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/drawable/gradient_3.xml b/app/src/main/res/drawable/gradient_3.xml
deleted file mode 100644
index 25b845f8..00000000
--- a/app/src/main/res/drawable/gradient_3.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/drawable/gradient_4.xml b/app/src/main/res/drawable/gradient_4.xml
deleted file mode 100644
index beebb803..00000000
--- a/app/src/main/res/drawable/gradient_4.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/drawable/gradient_5.xml b/app/src/main/res/drawable/gradient_5.xml
deleted file mode 100644
index cf540a29..00000000
--- a/app/src/main/res/drawable/gradient_5.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/drawable/gradient_6.xml b/app/src/main/res/drawable/gradient_6.xml
deleted file mode 100644
index a48fbb39..00000000
--- a/app/src/main/res/drawable/gradient_6.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/drawable/gradient_8.xml b/app/src/main/res/drawable/gradient_8.xml
deleted file mode 100644
index bb56a690..00000000
--- a/app/src/main/res/drawable/gradient_8.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/drawable/hemanth_s.webp b/app/src/main/res/drawable/hemanth_s.webp
deleted file mode 100644
index 7348b33f..00000000
Binary files a/app/src/main/res/drawable/hemanth_s.webp and /dev/null differ
diff --git a/app/src/main/res/drawable/ic_queue_music_white_24dp.xml b/app/src/main/res/drawable/ic_queue_music_white_24dp.xml
index 27472f3c..84323beb 100644
--- a/app/src/main/res/drawable/ic_queue_music_white_24dp.xml
+++ b/app/src/main/res/drawable/ic_queue_music_white_24dp.xml
@@ -3,7 +3,7 @@
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
-
+
diff --git a/app/src/main/res/drawable/ic_round_delete_white_24dp.xml b/app/src/main/res/drawable/ic_round_delete_white_24dp.xml
new file mode 100644
index 00000000..07411721
--- /dev/null
+++ b/app/src/main/res/drawable/ic_round_delete_white_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_skip_next_white_24dp.xml b/app/src/main/res/drawable/ic_skip_next_white_24dp.xml
index f81e98bb..29d493ba 100644
--- a/app/src/main/res/drawable/ic_skip_next_white_24dp.xml
+++ b/app/src/main/res/drawable/ic_skip_next_white_24dp.xml
@@ -2,8 +2,8 @@
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ android:shape="rectangle">
+ android:startColor="#00000000" />
\ No newline at end of file
diff --git a/app/src/main/res/layout-land/fragment_blur.xml b/app/src/main/res/layout-land/fragment_blur.xml
index d5b85ecb..f88af17b 100644
--- a/app/src/main/res/layout-land/fragment_blur.xml
+++ b/app/src/main/res/layout-land/fragment_blur.xml
@@ -12,7 +12,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
- tools:src="@drawable/hemanth_s" />
+ />
-
-
+
+
+
+
+