merged everything together correctly
This commit is contained in:
commit
70f33b4829
263 changed files with 2932 additions and 2411 deletions
4
app/proguard-rules.pro
vendored
4
app/proguard-rules.pro
vendored
|
|
@ -1,6 +1,6 @@
|
||||||
# Add project specific ProGuard rules here.
|
# Add project specific ProGuard rules here.
|
||||||
# By default, the flags in this file are appended to flags specified
|
# By default, the flags in this file are appended to flags specified
|
||||||
# in /Applications/android_sdk/tools/proguard/proguard-android.txt
|
# in /Users/aidanfollestad/Documents/android-sdk/tools/proguard/proguard-android.txt
|
||||||
# You can edit the include path and order by changing the proguardFiles
|
# You can edit the include path and order by changing the proguardFiles
|
||||||
# directive in build.gradle.
|
# directive in build.gradle.
|
||||||
#
|
#
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
# public *;
|
# public *;
|
||||||
#}
|
#}
|
||||||
|
|
||||||
-keep class !android.support.v7.internal.view.menu.**,** {*;}
|
-keep class !android.support.v7.internal.view.menu.**,** {*;}
|
||||||
-dontwarn
|
-dontwarn
|
||||||
-ignorewarnings
|
-ignorewarnings
|
||||||
-dontshrink
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.kabouzeid.gramophone" >
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
package="com.kabouzeid.gramophone">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
|
|
@ -12,10 +13,13 @@
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="@drawable/ic_launcher"
|
android:icon="@drawable/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/Theme.MaterialMusic.Light" >
|
android:theme="@style/Theme.MaterialMusic.Light"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
tools:ignore="UnusedAttribute">
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.activities.MainActivity"
|
android:name=".ui.activities.MainActivity"
|
||||||
android:label="@string/app_name" >
|
android:label="@string/app_name">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<action android:name="android.intent.action.MUSIC_PLAYER" />
|
<action android:name="android.intent.action.MUSIC_PLAYER" />
|
||||||
|
|
@ -75,26 +79,24 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.PICK" />
|
<action android:name="android.intent.action.PICK" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<category android:name="android.intent.category.OPENABLE" />
|
<category android:name="android.intent.category.OPENABLE" />
|
||||||
<data android:mimeType="vnd.android.cursor.dir/audio"/>
|
|
||||||
|
<data android:mimeType="vnd.android.cursor.dir/audio" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".ui.activities.AlbumDetailActivity" >
|
<activity android:name=".ui.activities.AlbumDetailActivity" />
|
||||||
</activity>
|
<activity android:name=".ui.activities.ArtistDetailActivity" />
|
||||||
<activity android:name=".ui.activities.ArtistDetailActivity" >
|
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.activities.MusicControllerActivity"
|
android:name=".ui.activities.MusicControllerActivity"
|
||||||
android:parentActivityName=".ui.activities.MainActivity" >
|
android:parentActivityName=".ui.activities.MainActivity" />
|
||||||
</activity>
|
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".service.MusicService"
|
android:name=".service.MusicService"
|
||||||
android:enabled="true" >
|
android:enabled="true" />
|
||||||
</service>
|
|
||||||
|
|
||||||
<receiver android:name=".service.MediaButtonIntentReceiver" >
|
<receiver android:name=".service.MediaButtonIntentReceiver">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MEDIA_BUTTON" />
|
<action android:name="android.intent.action.MEDIA_BUTTON" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
@ -107,18 +109,15 @@
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.activities.tageditor.SongTagEditorActivity"
|
android:name=".ui.activities.tageditor.SongTagEditorActivity"
|
||||||
android:label="@string/title_activity_tag_editor"
|
android:label="@string/title_activity_tag_editor"
|
||||||
android:windowSoftInputMode="adjustResize" >
|
android:windowSoftInputMode="adjustResize" />
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.activities.tageditor.AlbumTagEditorActivity"
|
android:name=".ui.activities.tageditor.AlbumTagEditorActivity"
|
||||||
android:label="@string/title_activity_album_tag_editor" >
|
android:label="@string/title_activity_album_tag_editor" />
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.activities.SearchActivity"
|
android:name=".ui.activities.SearchActivity"
|
||||||
android:label="@string/title_activity_search" >
|
android:label="@string/title_activity_search" />
|
||||||
</activity>
|
|
||||||
|
|
||||||
<receiver android:name=".appwidget.MusicPlayerWidget" >
|
<receiver android:name=".appwidget.MusicPlayerWidget">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
@ -130,12 +129,11 @@
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.activities.PlaylistDetailActivity"
|
android:name=".ui.activities.PlaylistDetailActivity"
|
||||||
android:label="@string/title_activity_playlist_detail" >
|
android:label="@string/title_activity_playlist_detail" />
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.activities.SettingsActivity"
|
android:name=".ui.activities.SettingsActivity"
|
||||||
android:label="@string/title_activity_settings" >
|
android:label="@string/title_activity_settings" />
|
||||||
</activity>
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,23 @@
|
||||||
package com.kabouzeid.gramophone;
|
package com.kabouzeid.gramophone;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
|
|
||||||
import com.android.volley.Request;
|
import com.android.volley.Request;
|
||||||
import com.android.volley.RequestQueue;
|
import com.android.volley.RequestQueue;
|
||||||
import com.android.volley.toolbox.Volley;
|
import com.android.volley.toolbox.Volley;
|
||||||
import com.crashlytics.android.Crashlytics;
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||||
import com.kabouzeid.gramophone.misc.AppKeys;
|
|
||||||
import com.squareup.otto.Bus;
|
import com.squareup.otto.Bus;
|
||||||
import com.squareup.otto.ThreadEnforcer;
|
import com.squareup.otto.ThreadEnforcer;
|
||||||
|
|
||||||
import io.fabric.sdk.android.Fabric;
|
import io.fabric.sdk.android.Fabric;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 25.11.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class App extends Application {
|
public class App extends Application {
|
||||||
public static final String TAG = App.class.getSimpleName();
|
public static final String TAG = App.class.getSimpleName();
|
||||||
public static Bus bus = new Bus(ThreadEnforcer.MAIN);
|
public static final Bus bus = new Bus(ThreadEnforcer.MAIN);
|
||||||
|
|
||||||
private RequestQueue requestQueue;
|
private RequestQueue requestQueue;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,17 +11,16 @@ import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.App;
|
import com.afollestad.materialdialogs.util.DialogUtils;
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.loader.AlbumLoader;
|
import com.kabouzeid.gramophone.loader.AlbumLoader;
|
||||||
import com.kabouzeid.gramophone.model.Album;
|
import com.kabouzeid.gramophone.model.Album;
|
||||||
import com.kabouzeid.gramophone.model.DataBaseChangedEvent;
|
import com.kabouzeid.gramophone.model.DataBaseChangedEvent;
|
||||||
import com.kabouzeid.gramophone.model.UiPreferenceChangedEvent;
|
import com.kabouzeid.gramophone.model.UIPreferenceChangedEvent;
|
||||||
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
||||||
import com.kabouzeid.gramophone.util.MusicUtil;
|
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||||
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||||
import com.kabouzeid.gramophone.util.Util;
|
|
||||||
import com.kabouzeid.gramophone.util.ViewUtil;
|
import com.kabouzeid.gramophone.util.ViewUtil;
|
||||||
import com.koushikdutta.async.future.Future;
|
import com.koushikdutta.async.future.Future;
|
||||||
import com.koushikdutta.async.future.FutureCallback;
|
import com.koushikdutta.async.future.FutureCallback;
|
||||||
|
|
@ -33,12 +32,13 @@ import com.squareup.otto.Subscribe;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 24.11.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class AlbumAdapter extends RecyclerView.Adapter<AlbumAdapter.ViewHolder> {
|
public class AlbumAdapter extends RecyclerView.Adapter<AlbumAdapter.ViewHolder> {
|
||||||
|
|
||||||
public static final String TAG = AlbumAdapter.class.getSimpleName();
|
public static final String TAG = AlbumAdapter.class.getSimpleName();
|
||||||
private Activity activity;
|
private final Activity activity;
|
||||||
private boolean usePalette;
|
private final boolean usePalette;
|
||||||
private List<Album> dataSet;
|
private List<Album> dataSet;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -100,10 +100,10 @@ public class AlbumAdapter extends RecyclerView.Adapter<AlbumAdapter.ViewHolder>
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||||
ImageView image;
|
final ImageView image;
|
||||||
TextView title;
|
final TextView title;
|
||||||
TextView artist;
|
final TextView artist;
|
||||||
View footer;
|
final View footer;
|
||||||
|
|
||||||
public ViewHolder(View itemView) {
|
public ViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
@ -122,7 +122,7 @@ public class AlbumAdapter extends RecyclerView.Adapter<AlbumAdapter.ViewHolder>
|
||||||
)};
|
)};
|
||||||
if (activity instanceof AbsFabActivity)
|
if (activity instanceof AbsFabActivity)
|
||||||
albumPairs = ((AbsFabActivity) activity).getSharedViewsWithFab(albumPairs);
|
albumPairs = ((AbsFabActivity) activity).getSharedViewsWithFab(albumPairs);
|
||||||
NavigationUtil.goToAlbum(activity, dataSet.get(getPosition()).id, albumPairs);
|
NavigationUtil.goToAlbum(activity, dataSet.get(getAdapterPosition()).id, albumPairs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -144,7 +144,7 @@ public class AlbumAdapter extends RecyclerView.Adapter<AlbumAdapter.ViewHolder>
|
||||||
if (vibrantSwatch != null) {
|
if (vibrantSwatch != null) {
|
||||||
title.setTextColor(vibrantSwatch.getTitleTextColor());
|
title.setTextColor(vibrantSwatch.getTitleTextColor());
|
||||||
artist.setTextColor(vibrantSwatch.getTitleTextColor());
|
artist.setTextColor(vibrantSwatch.getTitleTextColor());
|
||||||
ViewUtil.animateViewColor(footer, Util.resolveColor(activity, R.attr.default_bar_color), vibrantSwatch.getRgb());
|
ViewUtil.animateViewColor(footer, DialogUtils.resolveColor(activity, R.attr.default_bar_color), vibrantSwatch.getRgb());
|
||||||
} else {
|
} else {
|
||||||
paletteBlackAndWhite(title, artist, footer);
|
paletteBlackAndWhite(title, artist, footer);
|
||||||
}
|
}
|
||||||
|
|
@ -153,31 +153,19 @@ public class AlbumAdapter extends RecyclerView.Adapter<AlbumAdapter.ViewHolder>
|
||||||
}
|
}
|
||||||
|
|
||||||
private void paletteBlackAndWhite(final TextView title, final TextView artist, final View footer) {
|
private void paletteBlackAndWhite(final TextView title, final TextView artist, final View footer) {
|
||||||
title.setTextColor(Util.resolveColor(activity, R.attr.title_text_color));
|
title.setTextColor(DialogUtils.resolveColor(activity, R.attr.title_text_color));
|
||||||
artist.setTextColor(Util.resolveColor(activity, R.attr.caption_text_color));
|
artist.setTextColor(DialogUtils.resolveColor(activity, R.attr.caption_text_color));
|
||||||
int defaultBarColor = Util.resolveColor(activity, R.attr.default_bar_color);
|
int defaultBarColor = DialogUtils.resolveColor(activity, R.attr.default_bar_color);
|
||||||
ViewUtil.animateViewColor(footer, defaultBarColor, defaultBarColor);
|
ViewUtil.animateViewColor(footer, defaultBarColor, defaultBarColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetColors(final TextView title, final TextView artist, final View footer) {
|
private void resetColors(final TextView title, final TextView artist, final View footer) {
|
||||||
title.setTextColor(Util.resolveColor(activity, R.attr.title_text_color));
|
title.setTextColor(DialogUtils.resolveColor(activity, R.attr.title_text_color));
|
||||||
artist.setTextColor(Util.resolveColor(activity, R.attr.caption_text_color));
|
artist.setTextColor(DialogUtils.resolveColor(activity, R.attr.caption_text_color));
|
||||||
int defaultBarColor = Util.resolveColor(activity, R.attr.default_bar_color);
|
int defaultBarColor = DialogUtils.resolveColor(activity, R.attr.default_bar_color);
|
||||||
footer.setBackgroundColor(defaultBarColor);
|
footer.setBackgroundColor(defaultBarColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDetachedFromRecyclerView(RecyclerView recyclerView) {
|
|
||||||
super.onDetachedFromRecyclerView(recyclerView);
|
|
||||||
App.bus.unregister(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
|
|
||||||
super.onAttachedToRecyclerView(recyclerView);
|
|
||||||
App.bus.register(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onDataBaseEvent(DataBaseChangedEvent event) {
|
public void onDataBaseEvent(DataBaseChangedEvent event) {
|
||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
|
|
@ -188,14 +176,4 @@ public class AlbumAdapter extends RecyclerView.Adapter<AlbumAdapter.ViewHolder>
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onUIChangeEvent(UiPreferenceChangedEvent event) {
|
|
||||||
switch (event.getAction()) {
|
|
||||||
case UiPreferenceChangedEvent.ALBUM_OVERVIEW_PALETTE_CHANGED:
|
|
||||||
usePalette = (boolean) event.getValue();
|
|
||||||
notifyDataSetChanged();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,10 @@ import com.squareup.otto.Subscribe;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 29.12.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class ArtistAdapter extends RecyclerView.Adapter<ArtistAdapter.ViewHolder> {
|
public class ArtistAdapter extends RecyclerView.Adapter<ArtistAdapter.ViewHolder> {
|
||||||
protected Activity activity;
|
protected final Activity activity;
|
||||||
protected List<Artist> dataSet;
|
protected List<Artist> dataSet;
|
||||||
|
|
||||||
public ArtistAdapter(Activity activity) {
|
public ArtistAdapter(Activity activity) {
|
||||||
|
|
@ -80,9 +80,9 @@ public class ArtistAdapter extends RecyclerView.Adapter<ArtistAdapter.ViewHolder
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||||
TextView artistName;
|
final TextView artistName;
|
||||||
TextView artistInfo;
|
final TextView artistInfo;
|
||||||
ImageView artistImage;
|
final ImageView artistImage;
|
||||||
|
|
||||||
public ViewHolder(View itemView) {
|
public ViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
@ -100,7 +100,7 @@ public class ArtistAdapter extends RecyclerView.Adapter<ArtistAdapter.ViewHolder
|
||||||
)};
|
)};
|
||||||
if (activity instanceof AbsFabActivity)
|
if (activity instanceof AbsFabActivity)
|
||||||
artistPairs = ((AbsFabActivity) activity).getSharedViewsWithFab(artistPairs);
|
artistPairs = ((AbsFabActivity) activity).getSharedViewsWithFab(artistPairs);
|
||||||
NavigationUtil.goToArtist(activity, dataSet.get(getPosition()).id, artistPairs);
|
NavigationUtil.goToArtist(activity, dataSet.get(getAdapterPosition()).id, artistPairs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import com.koushikdutta.ion.Ion;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 24.11.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class ArtistAlbumAdapter extends RecyclerView.Adapter<ArtistAlbumAdapter.ViewHolder> {
|
public class ArtistAlbumAdapter extends RecyclerView.Adapter<ArtistAlbumAdapter.ViewHolder> {
|
||||||
public static final String TAG = AlbumAdapter.class.getSimpleName();
|
public static final String TAG = AlbumAdapter.class.getSimpleName();
|
||||||
|
|
@ -28,9 +28,9 @@ public class ArtistAlbumAdapter extends RecyclerView.Adapter<ArtistAlbumAdapter.
|
||||||
private static final int TYPE_MIDDLE = 2;
|
private static final int TYPE_MIDDLE = 2;
|
||||||
private static final int TYPE_LAST = 3;
|
private static final int TYPE_LAST = 3;
|
||||||
|
|
||||||
private Activity activity;
|
private final Activity activity;
|
||||||
private List<Album> dataSet;
|
private final List<Album> dataSet;
|
||||||
private int listMargin;
|
private final int listMargin;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
|
|
@ -75,9 +75,9 @@ public class ArtistAlbumAdapter extends RecyclerView.Adapter<ArtistAlbumAdapter.
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||||
ImageView albumArt;
|
final ImageView albumArt;
|
||||||
TextView title;
|
final TextView title;
|
||||||
TextView year;
|
final TextView year;
|
||||||
|
|
||||||
public ViewHolder(View itemView) {
|
public ViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
|
||||||
|
|
@ -1,52 +1,121 @@
|
||||||
package com.kabouzeid.gramophone.adapter;
|
package com.kabouzeid.gramophone.adapter;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.ThemeSingleton;
|
||||||
|
import com.afollestad.materialdialogs.util.DialogUtils;
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
|
import com.kabouzeid.gramophone.dialogs.ColorChooserDialog;
|
||||||
import com.kabouzeid.gramophone.model.NavigationDrawerItem;
|
import com.kabouzeid.gramophone.model.NavigationDrawerItem;
|
||||||
import com.kabouzeid.gramophone.util.Util;
|
import com.kabouzeid.gramophone.ui.fragments.NavigationDrawerFragment;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 23.11.14.
|
* @author Aidan Follestad (afollestad)
|
||||||
*/
|
*/
|
||||||
public class NavigationDrawerItemAdapter extends ArrayAdapter<NavigationDrawerItem> {
|
public class NavigationDrawerItemAdapter extends RecyclerView.Adapter<NavigationDrawerItemAdapter.ShortcutViewHolder> implements View.OnClickListener {
|
||||||
private int currentChecked = -1;
|
|
||||||
|
|
||||||
public NavigationDrawerItemAdapter(Context context, int resource, List<NavigationDrawerItem> objects) {
|
// per the Material design guidelines
|
||||||
super(context, resource, objects);
|
@SuppressWarnings("FieldCanBeLocal")
|
||||||
|
private final int ALPHA_ACTIVATED = 255;
|
||||||
|
@SuppressWarnings("FieldCanBeLocal")
|
||||||
|
private final int ALPHA_ICON = 138;
|
||||||
|
@SuppressWarnings("FieldCanBeLocal")
|
||||||
|
private final int ALPHA_TEXT = 222;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
int index = (Integer) v.getTag();
|
||||||
|
if (mCallback != null)
|
||||||
|
mCallback.onItemSelected(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ShortcutViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
|
public ShortcutViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
divider = itemView.findViewById(R.id.divider);
|
||||||
|
container = itemView.findViewById(R.id.container);
|
||||||
|
title = (TextView) itemView.findViewById(R.id.title);
|
||||||
|
icon = (ImageView) itemView.findViewById(R.id.icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
final TextView title;
|
||||||
|
final ImageView icon;
|
||||||
|
final View divider;
|
||||||
|
final View container;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int currentChecked = -1;
|
||||||
|
private int navIconColor;
|
||||||
|
private final ArrayList<NavigationDrawerItem> mItems;
|
||||||
|
private final Callback mCallback;
|
||||||
|
|
||||||
|
public interface Callback {
|
||||||
|
void onItemSelected(int index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NavigationDrawerItemAdapter(Context context, ArrayList<NavigationDrawerItem> objects, Callback callback) {
|
||||||
|
navIconColor = DialogUtils.resolveColor(context, R.attr.nav_drawer_icon_color);
|
||||||
|
if (DialogUtils.isColorDark(navIconColor))
|
||||||
|
navIconColor = ColorChooserDialog.shiftColorUp(navIconColor);
|
||||||
|
mItems = objects;
|
||||||
|
mCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChecked(int position) {
|
public void setChecked(int position) {
|
||||||
|
int oldPosition = currentChecked;
|
||||||
currentChecked = position;
|
currentChecked = position;
|
||||||
notifyDataSetChanged();
|
if (oldPosition != -1)
|
||||||
|
notifyItemChanged(oldPosition);
|
||||||
|
notifyItemChanged(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public ShortcutViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
NavigationDrawerItem item = getItem(position);
|
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_navigation_drawer, parent, false);
|
||||||
if (convertView == null) {
|
return new ShortcutViewHolder(view);
|
||||||
convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_navigation_drawer, parent, false);
|
}
|
||||||
}
|
|
||||||
TextView title = (TextView) convertView.findViewById(R.id.title);
|
@Override
|
||||||
ImageView icon = (ImageView) convertView.findViewById(R.id.album_art);
|
public void onBindViewHolder(ShortcutViewHolder holder, int position) {
|
||||||
title.setText(item.title);
|
NavigationDrawerItem item = mItems.get(position);
|
||||||
if (position == currentChecked) {
|
|
||||||
title.setTextColor(Util.resolveColor(getContext(), R.attr.colorAccent));
|
holder.title.setText(item.title);
|
||||||
icon.setImageDrawable(Util.getTintedDrawable(getContext().getResources(), item.imageRes, Util.resolveColor(getContext(), R.attr.colorAccent)));
|
holder.icon.setImageResource(item.imageRes);
|
||||||
|
holder.divider.setVisibility(position == NavigationDrawerFragment.ABOUT_INDEX ?
|
||||||
|
View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
|
final boolean selected = position == currentChecked;
|
||||||
|
final int iconColor = selected ? ThemeSingleton.get().positiveColor : navIconColor;
|
||||||
|
final int textColor = selected ? ThemeSingleton.get().positiveColor : navIconColor;
|
||||||
|
|
||||||
|
holder.title.setTextColor(textColor);
|
||||||
|
holder.title.setAlpha(selected ? ALPHA_ACTIVATED : ALPHA_TEXT);
|
||||||
|
holder.icon.setColorFilter(iconColor, PorterDuff.Mode.SRC_ATOP);
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
|
holder.icon.setImageAlpha(selected ? ALPHA_ACTIVATED : ALPHA_ICON);
|
||||||
} else {
|
} else {
|
||||||
title.setTextColor(Util.resolveColor(getContext(), R.attr.title_text_color));
|
// noinspection deprecation
|
||||||
icon.setImageDrawable(Util.getTintedDrawable(getContext().getResources(), item.imageRes, Util.resolveColor(getContext(), R.attr.themed_drawable_color)));
|
holder.icon.setAlpha(selected ? ALPHA_ACTIVATED : ALPHA_ICON);
|
||||||
}
|
}
|
||||||
View container = convertView.findViewById(R.id.container);
|
|
||||||
container.setActivated(position == currentChecked);
|
holder.container.setActivated(selected);
|
||||||
return convertView;
|
holder.container.setTag(position);
|
||||||
|
holder.container.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return mItems.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -29,7 +29,7 @@ public class PagerAdapter extends FragmentPagerAdapter {
|
||||||
|
|
||||||
private int mCurrentPage;
|
private int mCurrentPage;
|
||||||
|
|
||||||
private String[] titles;
|
private final String[] titles;
|
||||||
|
|
||||||
public PagerAdapter(final Context context, final FragmentManager fragmentManager) {
|
public PagerAdapter(final Context context, final FragmentManager fragmentManager) {
|
||||||
super(fragmentManager);
|
super(fragmentManager);
|
||||||
|
|
@ -68,16 +68,15 @@ public class PagerAdapter extends FragmentPagerAdapter {
|
||||||
if (mWeakFragment != null) {
|
if (mWeakFragment != null) {
|
||||||
mWeakFragment.clear();
|
mWeakFragment.clear();
|
||||||
}
|
}
|
||||||
mFragmentArray.put(position, new WeakReference<Fragment>(mFragment));
|
mFragmentArray.put(position, new WeakReference<>(mFragment));
|
||||||
return mFragment;
|
return mFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Fragment getItem(final int position) {
|
public Fragment getItem(final int position) {
|
||||||
final Holder mCurrentHolder = mHolderList.get(position);
|
final Holder mCurrentHolder = mHolderList.get(position);
|
||||||
final Fragment mFragment = Fragment.instantiate(mContext,
|
return Fragment.instantiate(mContext,
|
||||||
mCurrentHolder.mClassName, mCurrentHolder.mParams);
|
mCurrentHolder.mClassName, mCurrentHolder.mParams);
|
||||||
return mFragment;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -114,7 +113,7 @@ public class PagerAdapter extends FragmentPagerAdapter {
|
||||||
ARTIST(ArtistViewFragment.class),
|
ARTIST(ArtistViewFragment.class),
|
||||||
PLAYLIST(PlaylistViewFragment.class);
|
PLAYLIST(PlaylistViewFragment.class);
|
||||||
|
|
||||||
private Class<? extends Fragment> mFragmentClass;
|
private final Class<? extends Fragment> mFragmentClass;
|
||||||
|
|
||||||
MusicFragments(final Class<? extends Fragment> fragmentClass) {
|
MusicFragments(final Class<? extends Fragment> fragmentClass) {
|
||||||
mFragmentClass = fragmentClass;
|
mFragmentClass = fragmentClass;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package com.kabouzeid.gramophone.adapter;
|
package com.kabouzeid.gramophone.adapter;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.content.Intent;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
@ -10,31 +9,24 @@ import android.widget.ArrayAdapter;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.PopupMenu;
|
import android.widget.PopupMenu;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.util.DialogUtils;
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.helper.AddToPlaylistDialogHelper;
|
|
||||||
import com.kabouzeid.gramophone.helper.DeleteSongsDialogHelper;
|
|
||||||
import com.kabouzeid.gramophone.helper.MenuItemClickHelper;
|
import com.kabouzeid.gramophone.helper.MenuItemClickHelper;
|
||||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||||
import com.kabouzeid.gramophone.helper.SongDetailDialogHelper;
|
|
||||||
import com.kabouzeid.gramophone.loader.SongFilePathLoader;
|
|
||||||
import com.kabouzeid.gramophone.misc.AppKeys;
|
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
import com.kabouzeid.gramophone.model.Song;
|
||||||
import com.kabouzeid.gramophone.ui.activities.tageditor.SongTagEditorActivity;
|
|
||||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
|
||||||
import com.kabouzeid.gramophone.util.Util;
|
import com.kabouzeid.gramophone.util.Util;
|
||||||
|
|
||||||
import java.io.File;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 24.01.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class PlayingQueueAdapter extends ArrayAdapter<Song> {
|
public class PlayingQueueAdapter extends ArrayAdapter<Song> {
|
||||||
private Activity activity;
|
|
||||||
|
|
||||||
public PlayingQueueAdapter(Activity activity, List<Song> playList) {
|
private final ActionBarActivity activity;
|
||||||
|
|
||||||
|
public PlayingQueueAdapter(ActionBarActivity activity, ArrayList<Song> playList) {
|
||||||
super(activity, R.layout.item_list_playlist_song, playList);
|
super(activity, R.layout.item_list_playlist_song, playList);
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
}
|
}
|
||||||
|
|
@ -52,7 +44,7 @@ public class PlayingQueueAdapter extends ArrayAdapter<Song> {
|
||||||
title.setText(song.title);
|
title.setText(song.title);
|
||||||
if (MusicPlayerRemote.getPosition() == position) {
|
if (MusicPlayerRemote.getPosition() == position) {
|
||||||
playingIndicator.setVisibility(View.VISIBLE);
|
playingIndicator.setVisibility(View.VISIBLE);
|
||||||
playingIndicator.setImageDrawable(Util.getTintedDrawable(getContext().getResources(), R.drawable.ic_speaker_white_48dp, Util.resolveColor(getContext(), R.attr.themed_drawable_color)));
|
playingIndicator.setImageDrawable(Util.getTintedDrawable(getContext(), R.drawable.ic_speaker_white_48dp, DialogUtils.resolveColor(getContext(), R.attr.themed_drawable_color)));
|
||||||
} else {
|
} else {
|
||||||
playingIndicator.setVisibility(View.GONE);
|
playingIndicator.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
@ -65,7 +57,7 @@ public class PlayingQueueAdapter extends ArrayAdapter<Song> {
|
||||||
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
if(item.getItemId() == R.id.action_remove_from_playing_queue) {
|
if (item.getItemId() == R.id.action_remove_from_playing_queue) {
|
||||||
MusicPlayerRemote.removeFromQueue(position);
|
MusicPlayerRemote.removeFromQueue(position);
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.kabouzeid.gramophone.adapter;
|
package com.kabouzeid.gramophone.adapter;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.support.v4.util.Pair;
|
import android.support.v4.util.Pair;
|
||||||
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
@ -24,14 +24,15 @@ import com.squareup.otto.Subscribe;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 16.03.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class PlaylistAdapter extends RecyclerView.Adapter<PlaylistAdapter.ViewHolder> {
|
public class PlaylistAdapter extends RecyclerView.Adapter<PlaylistAdapter.ViewHolder> {
|
||||||
|
|
||||||
public static final String TAG = PlaylistAdapter.class.getSimpleName();
|
public static final String TAG = PlaylistAdapter.class.getSimpleName();
|
||||||
protected Activity activity;
|
protected final ActionBarActivity activity;
|
||||||
protected List<Playlist> dataSet;
|
protected List<Playlist> dataSet;
|
||||||
|
|
||||||
public PlaylistAdapter(Activity activity) {
|
public PlaylistAdapter(ActionBarActivity activity) {
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
loadDataSet();
|
loadDataSet();
|
||||||
}
|
}
|
||||||
|
|
@ -57,8 +58,8 @@ public class PlaylistAdapter extends RecyclerView.Adapter<PlaylistAdapter.ViewHo
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||||
public TextView playlistName;
|
public final TextView playlistName;
|
||||||
private ImageView menu;
|
private final ImageView menu;
|
||||||
|
|
||||||
public ViewHolder(View itemView) {
|
public ViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
@ -73,7 +74,8 @@ public class PlaylistAdapter extends RecyclerView.Adapter<PlaylistAdapter.ViewHo
|
||||||
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
return MenuItemClickHelper.handlePlaylistMenuClick(activity, dataSet.get(getAdapterPosition()), item);
|
return MenuItemClickHelper.handlePlaylistMenuClick(
|
||||||
|
activity, dataSet.get(getAdapterPosition()), item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
popupMenu.show();
|
popupMenu.show();
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
package com.kabouzeid.gramophone.adapter;
|
package com.kabouzeid.gramophone.adapter;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
@ -12,22 +12,23 @@ import android.widget.ImageView;
|
||||||
import android.widget.PopupMenu;
|
import android.widget.PopupMenu;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.util.DialogUtils;
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.helper.MenuItemClickHelper;
|
import com.kabouzeid.gramophone.helper.MenuItemClickHelper;
|
||||||
import com.kabouzeid.gramophone.model.SearchEntry;
|
import com.kabouzeid.gramophone.model.SearchEntry;
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
import com.kabouzeid.gramophone.model.Song;
|
||||||
import com.kabouzeid.gramophone.ui.activities.SearchActivity;
|
import com.kabouzeid.gramophone.ui.activities.SearchActivity;
|
||||||
import com.kabouzeid.gramophone.util.Util;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 27.02.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class SearchAdapter extends ArrayAdapter<SearchEntry>{
|
public class SearchAdapter extends ArrayAdapter<SearchEntry> {
|
||||||
private Activity activity;
|
|
||||||
|
|
||||||
public SearchAdapter(Activity activity, List<SearchEntry> objects) {
|
private final ActionBarActivity activity;
|
||||||
|
|
||||||
|
public SearchAdapter(ActionBarActivity activity, List<SearchEntry> objects) {
|
||||||
super(activity, R.layout.item_list_search, objects);
|
super(activity, R.layout.item_list_search, objects);
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
}
|
}
|
||||||
|
|
@ -50,7 +51,7 @@ public class SearchAdapter extends ArrayAdapter<SearchEntry>{
|
||||||
subTitle.setVisibility(View.GONE);
|
subTitle.setVisibility(View.GONE);
|
||||||
imageView.setVisibility(View.GONE);
|
imageView.setVisibility(View.GONE);
|
||||||
overflowButton.setVisibility(View.GONE);
|
overflowButton.setVisibility(View.GONE);
|
||||||
convertView.setBackgroundColor(Util.resolveColor(getContext(), R.attr.default_bar_color));
|
convertView.setBackgroundColor(DialogUtils.resolveColor(getContext(), R.attr.default_bar_color));
|
||||||
} else if (item instanceof Song) {
|
} else if (item instanceof Song) {
|
||||||
title.setTypeface(null, Typeface.NORMAL);
|
title.setTypeface(null, Typeface.NORMAL);
|
||||||
subTitle.setVisibility(View.VISIBLE);
|
subTitle.setVisibility(View.VISIBLE);
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
package com.kabouzeid.gramophone.adapter.songadapter;
|
package com.kabouzeid.gramophone.adapter.songadapter;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.content.Intent;
|
|
||||||
import android.support.v4.util.Pair;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
@ -13,32 +11,23 @@ import android.widget.PopupMenu;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.helper.AddToPlaylistDialogHelper;
|
|
||||||
import com.kabouzeid.gramophone.helper.DeleteSongsDialogHelper;
|
|
||||||
import com.kabouzeid.gramophone.helper.MenuItemClickHelper;
|
import com.kabouzeid.gramophone.helper.MenuItemClickHelper;
|
||||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||||
import com.kabouzeid.gramophone.helper.SongDetailDialogHelper;
|
|
||||||
import com.kabouzeid.gramophone.loader.SongFilePathLoader;
|
|
||||||
import com.kabouzeid.gramophone.misc.AppKeys;
|
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
import com.kabouzeid.gramophone.model.Song;
|
||||||
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
|
||||||
import com.kabouzeid.gramophone.ui.activities.tageditor.SongTagEditorActivity;
|
|
||||||
import com.kabouzeid.gramophone.util.MusicUtil;
|
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 27.11.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class AlbumSongAdapter extends RecyclerView.Adapter<AlbumSongAdapter.ViewHolder> {
|
public class AlbumSongAdapter extends RecyclerView.Adapter<AlbumSongAdapter.ViewHolder> {
|
||||||
|
|
||||||
public static final String TAG = AlbumSongAdapter.class.getSimpleName();
|
public static final String TAG = AlbumSongAdapter.class.getSimpleName();
|
||||||
|
protected final ActionBarActivity activity;
|
||||||
|
protected final ArrayList<Song> dataSet;
|
||||||
|
|
||||||
protected Activity activity;
|
public AlbumSongAdapter(ActionBarActivity activity, ArrayList<Song> objects) {
|
||||||
protected List<Song> dataSet;
|
|
||||||
|
|
||||||
public AlbumSongAdapter(Activity activity, List<Song> objects) {
|
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
dataSet = objects;
|
dataSet = objects;
|
||||||
}
|
}
|
||||||
|
|
@ -66,10 +55,10 @@ public class AlbumSongAdapter extends RecyclerView.Adapter<AlbumSongAdapter.View
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||||
TextView songTitle;
|
final TextView songTitle;
|
||||||
TextView trackNumber;
|
final TextView trackNumber;
|
||||||
TextView artistName;
|
final TextView artistName;
|
||||||
ImageView overflowButton;
|
final ImageView overflowButton;
|
||||||
|
|
||||||
public ViewHolder(View itemView) {
|
public ViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
package com.kabouzeid.gramophone.adapter.songadapter;
|
package com.kabouzeid.gramophone.adapter.songadapter;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
import android.support.v4.util.Pair;
|
import android.support.v4.util.Pair;
|
||||||
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
@ -22,12 +24,13 @@ import com.koushikdutta.ion.Ion;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 14.03.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class ArtistSongAdapter extends ArrayAdapter<Song> {
|
public class ArtistSongAdapter extends ArrayAdapter<Song> {
|
||||||
private Activity activity;
|
|
||||||
|
|
||||||
public ArtistSongAdapter(Activity activity, List<Song> songs) {
|
private final ActionBarActivity activity;
|
||||||
|
|
||||||
|
public ArtistSongAdapter(ActionBarActivity activity, List<Song> songs) {
|
||||||
super(activity, R.layout.item_list_song, songs);
|
super(activity, R.layout.item_list_song, songs);
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.kabouzeid.gramophone.adapter.songadapter;
|
package com.kabouzeid.gramophone.adapter.songadapter;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.support.v4.util.Pair;
|
import android.support.v4.util.Pair;
|
||||||
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
@ -22,17 +22,19 @@ import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||||
import com.kabouzeid.gramophone.util.PlaylistsUtil;
|
import com.kabouzeid.gramophone.util.PlaylistsUtil;
|
||||||
import com.koushikdutta.ion.Ion;
|
import com.koushikdutta.ion.Ion;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 27.11.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class PlaylistSongAdapter extends RecyclerView.Adapter<PlaylistSongAdapter.ViewHolder> {
|
public class PlaylistSongAdapter extends RecyclerView.Adapter<PlaylistSongAdapter.ViewHolder> {
|
||||||
public static final String TAG = AlbumSongAdapter.class.getSimpleName();
|
|
||||||
protected Activity activity;
|
|
||||||
protected List<PlaylistSong> dataSet;
|
|
||||||
|
|
||||||
public PlaylistSongAdapter(Activity activity, List<PlaylistSong> objects) {
|
public static final String TAG = AlbumSongAdapter.class.getSimpleName();
|
||||||
|
protected final ActionBarActivity activity;
|
||||||
|
protected final ArrayList<PlaylistSong> dataSet;
|
||||||
|
|
||||||
|
public PlaylistSongAdapter(ActionBarActivity activity, ArrayList<PlaylistSong> objects) {
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
dataSet = objects;
|
dataSet = objects;
|
||||||
}
|
}
|
||||||
|
|
@ -72,10 +74,10 @@ public class PlaylistSongAdapter extends RecyclerView.Adapter<PlaylistSongAdapte
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||||
TextView songTitle;
|
final TextView songTitle;
|
||||||
TextView songInfo;
|
final TextView songInfo;
|
||||||
ImageView overflowButton;
|
final ImageView overflowButton;
|
||||||
ImageView albumArt;
|
final ImageView albumArt;
|
||||||
|
|
||||||
public ViewHolder(View itemView) {
|
public ViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
@ -87,7 +89,8 @@ public class PlaylistSongAdapter extends RecyclerView.Adapter<PlaylistSongAdapte
|
||||||
itemView.setOnClickListener(new View.OnClickListener() {
|
itemView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
MusicPlayerRemote.openQueue((List<Song>) (List) dataSet, getAdapterPosition(), true);
|
//noinspection unchecked
|
||||||
|
MusicPlayerRemote.openQueue((ArrayList<Song>) (List) dataSet, getAdapterPosition(), true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
package com.kabouzeid.gramophone.adapter.songadapter;
|
package com.kabouzeid.gramophone.adapter.songadapter;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.support.v4.util.Pair;
|
import android.support.v4.util.Pair;
|
||||||
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
@ -12,6 +12,7 @@ import android.widget.ImageView;
|
||||||
import android.widget.PopupMenu;
|
import android.widget.PopupMenu;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.ThemeSingleton;
|
||||||
import com.kabouzeid.gramophone.App;
|
import com.kabouzeid.gramophone.App;
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.helper.MenuItemClickHelper;
|
import com.kabouzeid.gramophone.helper.MenuItemClickHelper;
|
||||||
|
|
@ -22,24 +23,24 @@ import com.kabouzeid.gramophone.model.Song;
|
||||||
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
||||||
import com.kabouzeid.gramophone.util.MusicUtil;
|
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||||
import com.kabouzeid.gramophone.util.Util;
|
|
||||||
import com.koushikdutta.ion.Ion;
|
import com.koushikdutta.ion.Ion;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 27.11.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class SongAdapter extends RecyclerView.Adapter<SongAdapter.ViewHolder> {
|
public class SongAdapter extends RecyclerView.Adapter<SongAdapter.ViewHolder> {
|
||||||
|
|
||||||
public static final String TAG = AlbumSongAdapter.class.getSimpleName();
|
public static final String TAG = AlbumSongAdapter.class.getSimpleName();
|
||||||
private static final int SHUFFLE_BUTTON = 0;
|
private static final int SHUFFLE_BUTTON = 0;
|
||||||
private static final int SONG = 1;
|
private static final int SONG = 1;
|
||||||
|
|
||||||
protected Activity activity;
|
protected final ActionBarActivity activity;
|
||||||
protected List<Song> dataSet;
|
protected ArrayList<Song> dataSet;
|
||||||
|
|
||||||
public SongAdapter(Activity activity) {
|
public SongAdapter(ActionBarActivity activity) {
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
loadDataSet();
|
loadDataSet();
|
||||||
}
|
}
|
||||||
|
|
@ -75,15 +76,14 @@ public class SongAdapter extends RecyclerView.Adapter<SongAdapter.ViewHolder> {
|
||||||
.error(R.drawable.default_album_art)
|
.error(R.drawable.default_album_art)
|
||||||
.intoImageView(holder.albumArt);
|
.intoImageView(holder.albumArt);
|
||||||
} else {
|
} else {
|
||||||
int accentColor = Util.resolveColor(activity, R.attr.colorAccent);
|
|
||||||
holder.songTitle.setText(activity.getResources().getString(R.string.shuffle_all).toUpperCase());
|
holder.songTitle.setText(activity.getResources().getString(R.string.shuffle_all).toUpperCase());
|
||||||
holder.songTitle.setTextColor(accentColor);
|
holder.songTitle.setTextColor(ThemeSingleton.get().positiveColor);
|
||||||
holder.songTitle.setTypeface(Typeface.create("sans-serif-medium", Typeface.NORMAL));
|
holder.songTitle.setTypeface(Typeface.create("sans-serif-medium", Typeface.NORMAL));
|
||||||
holder.songInfo.setVisibility(View.GONE);
|
holder.songInfo.setVisibility(View.GONE);
|
||||||
holder.overflowButton.setVisibility(View.GONE);
|
holder.overflowButton.setVisibility(View.GONE);
|
||||||
final int padding = activity.getResources().getDimensionPixelSize(R.dimen.default_item_margin) / 2;
|
final int padding = activity.getResources().getDimensionPixelSize(R.dimen.default_item_margin) / 2;
|
||||||
holder.albumArt.setPadding(padding, padding, padding, padding);
|
holder.albumArt.setPadding(padding, padding, padding, padding);
|
||||||
holder.albumArt.setColorFilter(accentColor);
|
holder.albumArt.setColorFilter(ThemeSingleton.get().positiveColor);
|
||||||
holder.albumArt.setImageResource(R.drawable.ic_shuffle_white_48dp);
|
holder.albumArt.setImageResource(R.drawable.ic_shuffle_white_48dp);
|
||||||
holder.separator.setVisibility(View.VISIBLE);
|
holder.separator.setVisibility(View.VISIBLE);
|
||||||
holder.short_separator.setVisibility(View.GONE);
|
holder.short_separator.setVisibility(View.GONE);
|
||||||
|
|
@ -96,12 +96,12 @@ public class SongAdapter extends RecyclerView.Adapter<SongAdapter.ViewHolder> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||||
TextView songTitle;
|
final TextView songTitle;
|
||||||
TextView songInfo;
|
final TextView songInfo;
|
||||||
ImageView overflowButton;
|
final ImageView overflowButton;
|
||||||
ImageView albumArt;
|
final ImageView albumArt;
|
||||||
View separator;
|
final View separator;
|
||||||
View short_separator;
|
final View short_separator;
|
||||||
|
|
||||||
public ViewHolder(View itemView) {
|
public ViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ import com.kabouzeid.gramophone.model.Album;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 25.11.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class AlbumAlphabeticComparator implements Comparator<Album> {
|
class AlbumAlphabeticComparator implements Comparator<Album> {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Album lhs, Album rhs) {
|
public int compare(Album lhs, Album rhs) {
|
||||||
return lhs.title.trim().compareToIgnoreCase(rhs.title.trim());
|
return lhs.title.trim().compareToIgnoreCase(rhs.title.trim());
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import com.kabouzeid.gramophone.model.Artist;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 29.12.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class ArtistAlphabeticComparator implements Comparator<Artist> {
|
public class ArtistAlphabeticComparator implements Comparator<Artist> {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import com.kabouzeid.gramophone.model.Song;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 28.12.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class SongAlphabeticComparator implements Comparator<Song> {
|
public class SongAlphabeticComparator implements Comparator<Song> {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import com.kabouzeid.gramophone.model.Song;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 25.11.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class SongTrackNumberComparator implements Comparator<Song> {
|
public class SongTrackNumberComparator implements Comparator<Song> {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.kabouzeid.gramophone.dialogs;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
|
import com.kabouzeid.gramophone.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Karim Abou Zeid (kabouzeid), Aidan Follestad (afollestad)
|
||||||
|
*/
|
||||||
|
public class AboutDialog extends DialogFragment {
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
return new MaterialDialog.Builder(getActivity())
|
||||||
|
.title(getActivity().getResources().getString(R.string.app_name) + " " + getCurrentVersionName(getActivity()))
|
||||||
|
.iconRes(R.drawable.ic_launcher)
|
||||||
|
.content(TextUtils.concat(getActivity().getResources().getText(R.string.credits_1),
|
||||||
|
getActivity().getResources().getText(R.string.credits_2),
|
||||||
|
getActivity().getResources().getText(R.string.credits_3),
|
||||||
|
getActivity().getResources().getText(R.string.credits_4))
|
||||||
|
)
|
||||||
|
.positiveText(getActivity().getResources().getString(android.R.string.ok))
|
||||||
|
.callback(new MaterialDialog.ButtonCallback() {
|
||||||
|
@Override
|
||||||
|
public void onPositive(MaterialDialog dialog) {
|
||||||
|
super.onPositive(dialog);
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getCurrentVersionName(final Context context) {
|
||||||
|
String versionName;
|
||||||
|
try {
|
||||||
|
versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
return versionName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
package com.kabouzeid.gramophone.dialogs;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
|
import com.kabouzeid.gramophone.R;
|
||||||
|
import com.kabouzeid.gramophone.loader.PlaylistLoader;
|
||||||
|
import com.kabouzeid.gramophone.model.Playlist;
|
||||||
|
import com.kabouzeid.gramophone.model.Song;
|
||||||
|
import com.kabouzeid.gramophone.util.PlaylistsUtil;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Karim Abou Zeid (kabouzeid), Aidan Follestad (afollestad)
|
||||||
|
*/
|
||||||
|
public class AddToPlaylistDialog extends DialogFragment {
|
||||||
|
|
||||||
|
public static AddToPlaylistDialog create(Song song) {
|
||||||
|
ArrayList<Song> list = new ArrayList<>();
|
||||||
|
list.add(song);
|
||||||
|
return create(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AddToPlaylistDialog create(ArrayList<Song> songs) {
|
||||||
|
AddToPlaylistDialog dialog = new AddToPlaylistDialog();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable("songs", songs);
|
||||||
|
dialog.setArguments(args);
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
final List<Playlist> playlists = PlaylistLoader.getAllPlaylists(getActivity());
|
||||||
|
CharSequence[] playlistNames = new CharSequence[playlists.size() + 1];
|
||||||
|
playlistNames[0] = getActivity().getResources().getString(R.string.action_new_playlist);
|
||||||
|
for (int i = 1; i < playlistNames.length; i++) {
|
||||||
|
playlistNames[i] = playlists.get(i - 1).name;
|
||||||
|
}
|
||||||
|
return new MaterialDialog.Builder(getActivity())
|
||||||
|
.items(playlistNames)
|
||||||
|
.itemsCallback(new MaterialDialog.ListCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSelection(MaterialDialog materialDialog, View view, int i, CharSequence charSequence) {
|
||||||
|
//noinspection unchecked
|
||||||
|
final ArrayList<Song> songs = (ArrayList<Song>) getArguments().getSerializable("songs");
|
||||||
|
if (i == 0) {
|
||||||
|
materialDialog.dismiss();
|
||||||
|
CreatePlaylistDialog.create(songs).show(getActivity().getSupportFragmentManager(), "ADD_TO_PLAYLIST");
|
||||||
|
} else {
|
||||||
|
materialDialog.dismiss();
|
||||||
|
PlaylistsUtil.addToPlaylist(getActivity(), songs, playlists.get(i - 1).id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,203 @@
|
||||||
|
package com.kabouzeid.gramophone.dialogs;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.app.DialogFragment;
|
||||||
|
import android.content.res.ColorStateList;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.graphics.drawable.RippleDrawable;
|
||||||
|
import android.graphics.drawable.ShapeDrawable;
|
||||||
|
import android.graphics.drawable.StateListDrawable;
|
||||||
|
import android.graphics.drawable.shapes.OvalShape;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.content.res.ResourcesCompat;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.GridView;
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
|
import com.afollestad.materialdialogs.ThemeSingleton;
|
||||||
|
import com.kabouzeid.gramophone.R;
|
||||||
|
import com.kabouzeid.gramophone.views.CircleView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Aidan Follestad (afollestad)
|
||||||
|
*/
|
||||||
|
public class ColorChooserDialog extends DialogFragment implements View.OnClickListener {
|
||||||
|
|
||||||
|
private ColorCallback mCallback;
|
||||||
|
private int[] mColors;
|
||||||
|
private GridView mGrid;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(Activity activity) {
|
||||||
|
super.onAttach(activity);
|
||||||
|
mCallback = (ColorCallback) activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (v.getTag() != null) {
|
||||||
|
final int index = (Integer) v.getTag();
|
||||||
|
getArguments().putInt("preselect", mColors[index]);
|
||||||
|
invalidateGrid();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ColorCallback {
|
||||||
|
void onColorSelection(int title, int color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ColorChooserDialog() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
MaterialDialog dialog = new MaterialDialog.Builder(getActivity())
|
||||||
|
.title(getArguments().getInt("title", 0))
|
||||||
|
.autoDismiss(false)
|
||||||
|
.customView(R.layout.dialog_color_chooser, false)
|
||||||
|
.neutralText(R.string.default_str)
|
||||||
|
.positiveText(R.string.select)
|
||||||
|
.callback(new MaterialDialog.ButtonCallback() {
|
||||||
|
@Override
|
||||||
|
public void onPositive(MaterialDialog dialog) {
|
||||||
|
super.onPositive(dialog);
|
||||||
|
final int title = getArguments().getInt("title", 0);
|
||||||
|
final int preselect = getArguments().getInt("preselect", -1);
|
||||||
|
mCallback.onColorSelection(title, preselect);
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNeutral(MaterialDialog dialog) {
|
||||||
|
super.onNeutral(dialog);
|
||||||
|
if (getArguments().getInt("title", 0) == R.string.primary_color) {
|
||||||
|
getArguments().putInt("preselect", getResources().getColor(R.color.indigo_500));
|
||||||
|
} else if (getArguments().getInt("title", 0) == R.string.accent_color) {
|
||||||
|
getArguments().putInt("preselect", getResources().getColor(R.color.pink_500));
|
||||||
|
}
|
||||||
|
invalidateGrid();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.build();
|
||||||
|
|
||||||
|
final boolean primary = getArguments().getInt("title", 0) == R.string.primary_color;
|
||||||
|
final TypedArray ta = getActivity().getResources().obtainTypedArray(
|
||||||
|
primary ? R.array.colors_primary : R.array.colors_accent);
|
||||||
|
mColors = new int[ta.length()];
|
||||||
|
for (int i = 0; i < ta.length(); i++)
|
||||||
|
mColors[i] = ta.getColor(i, 0);
|
||||||
|
ta.recycle();
|
||||||
|
mGrid = (GridView) dialog.getCustomView();
|
||||||
|
invalidateGrid();
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void invalidateGrid() {
|
||||||
|
if (mGrid.getAdapter() == null) {
|
||||||
|
mGrid.setAdapter(new ColorGridAdapter());
|
||||||
|
mGrid.setSelector(ResourcesCompat.getDrawable(getResources(), R.drawable.md_transparent, null));
|
||||||
|
} else ((BaseAdapter) mGrid.getAdapter()).notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ColorGridAdapter extends BaseAdapter implements View.OnClickListener {
|
||||||
|
|
||||||
|
public ColorGridAdapter() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return mColors.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getItem(int position) {
|
||||||
|
return mColors[position];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getItemId(int position) {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
if (convertView == null)
|
||||||
|
convertView = LayoutInflater.from(getActivity()).inflate(R.layout.griditem_color_chooser, parent, false);
|
||||||
|
final boolean dark = ThemeSingleton.get().darkTheme;
|
||||||
|
CircleView child = (CircleView) convertView;
|
||||||
|
child.setActivated(getArguments().getInt("preselect") == mColors[position]);
|
||||||
|
child.setBackgroundColor(mColors[position]);
|
||||||
|
child.setBorderColor(dark ? Color.WHITE : Color.BLACK);
|
||||||
|
child.setTag(position);
|
||||||
|
child.setOnClickListener(this);
|
||||||
|
|
||||||
|
Drawable selector = createSelector(mColors[position]);
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
int[][] states = new int[][]{
|
||||||
|
new int[]{android.R.attr.state_pressed}
|
||||||
|
};
|
||||||
|
int[] colors = new int[]{
|
||||||
|
shiftColorDown(mColors[position])
|
||||||
|
};
|
||||||
|
ColorStateList rippleColors = new ColorStateList(states, colors);
|
||||||
|
child.setForeground(new RippleDrawable(rippleColors, selector, null));
|
||||||
|
} else {
|
||||||
|
child.setForeground(selector);
|
||||||
|
}
|
||||||
|
return convertView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
final int index = (Integer) v.getTag();
|
||||||
|
getArguments().putInt("preselect", mColors[index]);
|
||||||
|
invalidateGrid();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int shiftColorDown(int color) {
|
||||||
|
float[] hsv = new float[3];
|
||||||
|
Color.colorToHSV(color, hsv);
|
||||||
|
hsv[2] *= 0.9f; // value component
|
||||||
|
return Color.HSVToColor(hsv);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int shiftColorUp(int color) {
|
||||||
|
float[] hsv = new float[3];
|
||||||
|
Color.colorToHSV(color, hsv);
|
||||||
|
hsv[2] *= 1.1f; // value component
|
||||||
|
return Color.HSVToColor(hsv);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int translucentColor(int color) {
|
||||||
|
final float factor = 0.7f;
|
||||||
|
int alpha = Math.round(Color.alpha(color) * factor);
|
||||||
|
int red = Color.red(color);
|
||||||
|
int green = Color.green(color);
|
||||||
|
int blue = Color.blue(color);
|
||||||
|
return Color.argb(alpha, red, green, blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Drawable createSelector(int color) {
|
||||||
|
ShapeDrawable darkerCircle = new ShapeDrawable(new OvalShape());
|
||||||
|
darkerCircle.getPaint().setColor(translucentColor(shiftColorDown(color)));
|
||||||
|
StateListDrawable stateListDrawable = new StateListDrawable();
|
||||||
|
stateListDrawable.addState(new int[]{android.R.attr.state_pressed}, darkerCircle);
|
||||||
|
return stateListDrawable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void show(Activity context, int title, int preselect) {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putInt("preselect", preselect);
|
||||||
|
args.putInt("title", title);
|
||||||
|
setArguments(args);
|
||||||
|
show(context.getFragmentManager(), "COLOR_SELECTOR");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.kabouzeid.gramophone.dialogs;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
|
import com.kabouzeid.gramophone.R;
|
||||||
|
import com.kabouzeid.gramophone.model.Song;
|
||||||
|
import com.kabouzeid.gramophone.util.PlaylistsUtil;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Karim Abou Zeid (kabouzeid), Aidan Follestad (afollestad)
|
||||||
|
*/
|
||||||
|
public class CreatePlaylistDialog extends DialogFragment {
|
||||||
|
|
||||||
|
public static CreatePlaylistDialog create() {
|
||||||
|
return create((Song) null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CreatePlaylistDialog create(Song song) {
|
||||||
|
ArrayList<Song> list = new ArrayList<>();
|
||||||
|
if (song != null)
|
||||||
|
list.add(song);
|
||||||
|
return create(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CreatePlaylistDialog create(ArrayList<Song> songs) {
|
||||||
|
CreatePlaylistDialog dialog = new CreatePlaylistDialog();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable("songs", songs);
|
||||||
|
dialog.setArguments(args);
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
return new MaterialDialog.Builder(getActivity())
|
||||||
|
.title(R.string.action_new_playlist)
|
||||||
|
.positiveText(android.R.string.ok)
|
||||||
|
.negativeText(android.R.string.cancel)
|
||||||
|
.input(null, null, new MaterialDialog.InputCallback() {
|
||||||
|
@Override
|
||||||
|
public void onInput(MaterialDialog materialDialog, CharSequence charSequence) {
|
||||||
|
if (getActivity() == null)
|
||||||
|
return;
|
||||||
|
if (!charSequence.toString().trim().equals("")) {
|
||||||
|
final int playlistId = PlaylistsUtil.createPlaylist(getActivity(), charSequence.toString());
|
||||||
|
if (playlistId != -1 && getActivity() != null) {
|
||||||
|
//noinspection unchecked
|
||||||
|
ArrayList<Song> songs = (ArrayList<Song>) getArguments().getSerializable("songs");
|
||||||
|
PlaylistsUtil.addToPlaylist(getActivity(), songs, playlistId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.kabouzeid.gramophone.dialogs;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
|
import com.kabouzeid.gramophone.R;
|
||||||
|
import com.kabouzeid.gramophone.util.PlaylistsUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Karim Abou Zeid (kabouzeid), Aidan Follestad (afollestad)
|
||||||
|
*/
|
||||||
|
public class DeletePlaylistDialog extends DialogFragment {
|
||||||
|
|
||||||
|
public static DeletePlaylistDialog create(long playlistId) {
|
||||||
|
DeletePlaylistDialog dialog = new DeletePlaylistDialog();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putLong("playlist_id", playlistId);
|
||||||
|
dialog.setArguments(args);
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
long playlistId = getArguments().getLong("playlist_id");
|
||||||
|
return new MaterialDialog.Builder(getActivity())
|
||||||
|
.title(getActivity().getResources().getString(R.string.delete_playlist) +
|
||||||
|
PlaylistsUtil.getNameForPlaylist(getActivity(), playlistId))
|
||||||
|
.positiveText(getActivity().getResources().getString(android.R.string.ok))
|
||||||
|
.negativeText(getActivity().getResources().getString(android.R.string.cancel))
|
||||||
|
.callback(new MaterialDialog.ButtonCallback() {
|
||||||
|
@Override
|
||||||
|
public void onPositive(MaterialDialog dialog) {
|
||||||
|
super.onPositive(dialog);
|
||||||
|
if (getActivity() == null)
|
||||||
|
return;
|
||||||
|
long playlistId = getArguments().getLong("playlist_id");
|
||||||
|
PlaylistsUtil.deletePlaylist(getActivity(), playlistId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNegative(MaterialDialog dialog) {
|
||||||
|
super.onNegative(dialog);
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
}).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
package com.kabouzeid.gramophone.dialogs;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
import android.support.v7.app.ActionBarActivity;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
|
import com.kabouzeid.gramophone.R;
|
||||||
|
import com.kabouzeid.gramophone.adapter.PlayingQueueAdapter;
|
||||||
|
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||||
|
import com.kabouzeid.gramophone.model.Song;
|
||||||
|
import com.mobeta.android.dslv.DragSortListView;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Karim Abou Zeid (kabouzeid), Aidan Follestad (afollestad)
|
||||||
|
*/
|
||||||
|
public class PlayingQueueDialog extends DialogFragment {
|
||||||
|
|
||||||
|
public static PlayingQueueDialog create() {
|
||||||
|
final ArrayList<Song> playingQueue = MusicPlayerRemote.getPlayingQueue();
|
||||||
|
if (playingQueue.isEmpty())
|
||||||
|
return null;
|
||||||
|
PlayingQueueDialog dialog = new PlayingQueueDialog();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable("queue", playingQueue);
|
||||||
|
dialog.setArguments(args);
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
MaterialDialog dialog = new MaterialDialog.Builder(getActivity())
|
||||||
|
.title(getActivity().getResources().getString(R.string.label_current_playing_queue))
|
||||||
|
.customView(R.layout.dialog_playlist, false)
|
||||||
|
.positiveText(getActivity().getResources().getString(R.string.save_as_playlist))
|
||||||
|
.callback(new MaterialDialog.ButtonCallback() {
|
||||||
|
@Override
|
||||||
|
public void onPositive(MaterialDialog dialog) {
|
||||||
|
super.onPositive(dialog);
|
||||||
|
if (getActivity() == null)
|
||||||
|
return;
|
||||||
|
//noinspection unchecked
|
||||||
|
ArrayList<Song> playingQueue = (ArrayList<Song>) getArguments().getSerializable("queue");
|
||||||
|
AddToPlaylistDialog.create(playingQueue).show(getActivity().getSupportFragmentManager(), "ADD_PLAYLIST");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.build();
|
||||||
|
|
||||||
|
//noinspection unchecked
|
||||||
|
final ArrayList<Song> playingQueue = (ArrayList<Song>) getArguments().getSerializable("queue");
|
||||||
|
final DragSortListView dragSortListView = (DragSortListView) dialog.getCustomView().findViewById(R.id.dragSortListView);
|
||||||
|
final PlayingQueueAdapter playingQueueAdapter =
|
||||||
|
new PlayingQueueAdapter((ActionBarActivity) getActivity(), playingQueue);
|
||||||
|
dragSortListView.setAdapter(playingQueueAdapter);
|
||||||
|
dragSortListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
MusicPlayerRemote.playSongAt(position);
|
||||||
|
playingQueueAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dragSortListView.setDropListener(new DragSortListView.DropListener() {
|
||||||
|
@Override
|
||||||
|
public void drop(int from, int to) {
|
||||||
|
MusicPlayerRemote.moveSong(from, to);
|
||||||
|
playingQueueAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.kabouzeid.gramophone.dialogs;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
|
import com.kabouzeid.gramophone.R;
|
||||||
|
import com.kabouzeid.gramophone.util.PlaylistsUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Karim Abou Zeid (kabouzeid), Aidan Follestad (afollestad)
|
||||||
|
*/
|
||||||
|
public class RenamePlaylistDialog extends DialogFragment {
|
||||||
|
|
||||||
|
public static RenamePlaylistDialog create(long playlistId) {
|
||||||
|
RenamePlaylistDialog dialog = new RenamePlaylistDialog();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putLong("playlist_id", playlistId);
|
||||||
|
dialog.setArguments(args);
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
long playlistId = getArguments().getLong("playlist_id");
|
||||||
|
return new MaterialDialog.Builder(getActivity())
|
||||||
|
.title(R.string.rename_playlist)
|
||||||
|
.positiveText(android.R.string.ok)
|
||||||
|
.negativeText(android.R.string.cancel)
|
||||||
|
.input(null, PlaylistsUtil.getNameForPlaylist(getActivity(), playlistId), new MaterialDialog.InputCallback() {
|
||||||
|
@Override
|
||||||
|
public void onInput(MaterialDialog materialDialog, CharSequence charSequence) {
|
||||||
|
if (!charSequence.toString().trim().equals("")) {
|
||||||
|
long playlistId = getArguments().getLong("playlist_id");
|
||||||
|
PlaylistsUtil.renamePlaylist(getActivity(), playlistId, charSequence.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
package com.kabouzeid.gramophone.helper;
|
package com.kabouzeid.gramophone.dialogs;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
@ -24,16 +29,30 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 19.01.15.
|
* @author Karim Abou Zeid (kabouzeid), Aidan Follestad (afollestad)
|
||||||
*/
|
*/
|
||||||
public class SongDetailDialogHelper {
|
public class SongDetailDialog extends DialogFragment {
|
||||||
public static final String TAG = SongDetailDialogHelper.class.getSimpleName();
|
|
||||||
|
public static final String TAG = SongDetailDialog.class.getSimpleName();
|
||||||
|
|
||||||
|
public static SongDetailDialog create(File songFile) {
|
||||||
|
SongDetailDialog dialog = new SongDetailDialog();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable("song_file", songFile);
|
||||||
|
dialog.setArguments(args);
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
final Activity context = getActivity();
|
||||||
|
final File songFile = (File) getArguments().getSerializable("song_file");
|
||||||
|
|
||||||
public static MaterialDialog getDialog(final Context context, final File songFile) {
|
|
||||||
MaterialDialog dialog = new MaterialDialog.Builder(context)
|
MaterialDialog dialog = new MaterialDialog.Builder(context)
|
||||||
.customView(R.layout.dialog_file_details, true)
|
.customView(R.layout.dialog_file_details, true)
|
||||||
.title(context.getResources().getString(R.string.label_details))
|
.title(context.getResources().getString(R.string.label_details))
|
||||||
.positiveText(context.getResources().getString(R.string.ok))
|
.positiveText(android.R.string.ok)
|
||||||
.callback(new MaterialDialog.ButtonCallback() {
|
.callback(new MaterialDialog.ButtonCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onPositive(MaterialDialog dialog) {
|
public void onPositive(MaterialDialog dialog) {
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
package com.kabouzeid.gramophone.helper;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
|
||||||
import com.kabouzeid.gramophone.R;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by karim on 05.02.15.
|
|
||||||
*/
|
|
||||||
public class AboutDeveloperDialogHelper {
|
|
||||||
public static final String TAG = AboutDeveloperDialogHelper.class.getSimpleName();
|
|
||||||
|
|
||||||
public static MaterialDialog getDialog(final Context context) {
|
|
||||||
MaterialDialog dialog = new MaterialDialog.Builder(context)
|
|
||||||
.title(context.getResources().getString(R.string.app_name) + " " + getCurrentVersionName(context))
|
|
||||||
.iconRes(R.drawable.ic_launcher)
|
|
||||||
.content(TextUtils.concat(context.getResources().getText(R.string.credits_1),
|
|
||||||
context.getResources().getText(R.string.credits_2),
|
|
||||||
context.getResources().getText(R.string.credits_3),
|
|
||||||
context.getResources().getText(R.string.credits_4))
|
|
||||||
)
|
|
||||||
.positiveText(context.getResources().getString(R.string.ok))
|
|
||||||
.callback(new MaterialDialog.ButtonCallback() {
|
|
||||||
@Override
|
|
||||||
public void onPositive(MaterialDialog dialog) {
|
|
||||||
super.onPositive(dialog);
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.build();
|
|
||||||
return dialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getCurrentVersionName(final Context context) {
|
|
||||||
String versionName = "";
|
|
||||||
try {
|
|
||||||
versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
|
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
|
||||||
Log.e(TAG, "Unable to get current app version number.", e);
|
|
||||||
}
|
|
||||||
return versionName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
package com.kabouzeid.gramophone.helper;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
|
||||||
import com.kabouzeid.gramophone.R;
|
|
||||||
import com.kabouzeid.gramophone.loader.PlaylistLoader;
|
|
||||||
import com.kabouzeid.gramophone.model.Playlist;
|
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
|
||||||
import com.kabouzeid.gramophone.util.PlaylistsUtil;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by karim on 17.03.15.
|
|
||||||
*/
|
|
||||||
public class AddToPlaylistDialogHelper {
|
|
||||||
public static MaterialDialog getDialog(final Context context, final Song song) {
|
|
||||||
List<Song> tmpSong = new ArrayList<>();
|
|
||||||
tmpSong.add(song);
|
|
||||||
return getDialog(context, tmpSong);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MaterialDialog getDialog(final Context context, final List<Song> songs) {
|
|
||||||
final List<Playlist> playlists = PlaylistLoader.getAllPlaylists(context);
|
|
||||||
CharSequence[] playlistNames = new CharSequence[playlists.size() + 1];
|
|
||||||
playlistNames[0] = context.getResources().getString(R.string.action_new_playlist);
|
|
||||||
for (int i = 1; i < playlistNames.length; i++) {
|
|
||||||
playlistNames[i] = playlists.get(i - 1).name;
|
|
||||||
}
|
|
||||||
return new MaterialDialog.Builder(context)
|
|
||||||
.items(playlistNames)
|
|
||||||
.itemsCallback(new MaterialDialog.ListCallback() {
|
|
||||||
@Override
|
|
||||||
public void onSelection(MaterialDialog materialDialog, View view, int i, CharSequence charSequence) {
|
|
||||||
if (i == 0) {
|
|
||||||
materialDialog.dismiss();
|
|
||||||
CreatePlaylistDialogHelper.getDialog(context, songs).show();
|
|
||||||
} else {
|
|
||||||
materialDialog.dismiss();
|
|
||||||
PlaylistsUtil.addToPlaylist(context, songs, playlists.get(i - 1).id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
package com.kabouzeid.gramophone.helper;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
|
||||||
import com.kabouzeid.gramophone.R;
|
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
|
||||||
import com.kabouzeid.gramophone.util.PlaylistsUtil;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by karim on 17.03.15.
|
|
||||||
*/
|
|
||||||
public class CreatePlaylistDialogHelper {
|
|
||||||
public static MaterialDialog getDialog(final Context context, final Song song) {
|
|
||||||
List<Song> tmpSong = new ArrayList<>();
|
|
||||||
tmpSong.add(song);
|
|
||||||
return getDialog(context, tmpSong);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MaterialDialog getDialog(final Context context, final List<Song> songs) {
|
|
||||||
return new MaterialDialog.Builder(context)
|
|
||||||
.title(R.string.action_new_playlist)
|
|
||||||
.positiveText(R.string.ok)
|
|
||||||
.negativeText(R.string.cancel)
|
|
||||||
.input("", "", new MaterialDialog.InputCallback() {
|
|
||||||
@Override
|
|
||||||
public void onInput(MaterialDialog materialDialog, CharSequence charSequence) {
|
|
||||||
if (!charSequence.toString().trim().equals("")) {
|
|
||||||
final int playlistId = PlaylistsUtil.createPlaylist(context, charSequence.toString());
|
|
||||||
if (playlistId != -1 && songs != null) {
|
|
||||||
PlaylistsUtil.addToPlaylist(context, songs, playlistId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MaterialDialog getDialog(final Context context) {
|
|
||||||
return getDialog(context, (List<Song>) null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
package com.kabouzeid.gramophone.helper;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
|
||||||
import com.kabouzeid.gramophone.R;
|
|
||||||
import com.kabouzeid.gramophone.util.PlaylistsUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by karim on 19.03.15.
|
|
||||||
*/
|
|
||||||
public class DeletePlaylistDialogHelper {
|
|
||||||
public static MaterialDialog getDialog(final Context context, final int playlistId) {
|
|
||||||
return new MaterialDialog.Builder(context)
|
|
||||||
.title(context.getResources().getString(R.string.delete_playlist) + PlaylistsUtil.getNameForPlaylist(context, playlistId))
|
|
||||||
.positiveText(context.getResources().getString(R.string.ok))
|
|
||||||
.negativeText(context.getResources().getString(R.string.cancel))
|
|
||||||
.callback(new MaterialDialog.ButtonCallback() {
|
|
||||||
@Override
|
|
||||||
public void onPositive(MaterialDialog dialog) {
|
|
||||||
super.onPositive(dialog);
|
|
||||||
dialog.dismiss();
|
|
||||||
PlaylistsUtil.deletePlaylist(context, playlistId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNegative(MaterialDialog dialog) {
|
|
||||||
super.onNegative(dialog);
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
}).build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -11,9 +11,10 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 23.03.15.
|
* @author Karim Abou Zeid (kabouzeid), Aidan Follestad (afollestad)
|
||||||
*/
|
*/
|
||||||
public class DeleteSongsDialogHelper {
|
public class DeleteSongsDialogHelper {
|
||||||
|
|
||||||
public static MaterialDialog getDialog(final Context context, final Song song) {
|
public static MaterialDialog getDialog(final Context context, final Song song) {
|
||||||
List<Song> tmpList = new ArrayList<>();
|
List<Song> tmpList = new ArrayList<>();
|
||||||
tmpList.add(song);
|
tmpList.add(song);
|
||||||
|
|
@ -27,7 +28,7 @@ public class DeleteSongsDialogHelper {
|
||||||
.title(title)
|
.title(title)
|
||||||
.content(context.getResources().getString(R.string.delete_warning))
|
.content(context.getResources().getString(R.string.delete_warning))
|
||||||
.positiveText(context.getResources().getString(R.string.delete))
|
.positiveText(context.getResources().getString(R.string.delete))
|
||||||
.negativeText(context.getResources().getString(R.string.cancel))
|
.negativeText(context.getResources().getString(android.R.string.cancel))
|
||||||
.callback(new MaterialDialog.ButtonCallback() {
|
.callback(new MaterialDialog.ButtonCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onPositive(MaterialDialog dialog) {
|
public void onPositive(MaterialDialog dialog) {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,15 @@
|
||||||
package com.kabouzeid.gramophone.helper;
|
package com.kabouzeid.gramophone.helper;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.support.v4.util.Pair;
|
import android.support.v4.util.Pair;
|
||||||
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
|
import com.kabouzeid.gramophone.dialogs.AddToPlaylistDialog;
|
||||||
|
import com.kabouzeid.gramophone.dialogs.DeletePlaylistDialog;
|
||||||
|
import com.kabouzeid.gramophone.dialogs.RenamePlaylistDialog;
|
||||||
|
import com.kabouzeid.gramophone.dialogs.SongDetailDialog;
|
||||||
import com.kabouzeid.gramophone.loader.SongFilePathLoader;
|
import com.kabouzeid.gramophone.loader.SongFilePathLoader;
|
||||||
import com.kabouzeid.gramophone.misc.AppKeys;
|
import com.kabouzeid.gramophone.misc.AppKeys;
|
||||||
import com.kabouzeid.gramophone.model.Playlist;
|
import com.kabouzeid.gramophone.model.Playlist;
|
||||||
|
|
@ -17,16 +21,17 @@ import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 11.04.15.
|
* @author Karim Abou Zeid (kabouzeid), Aidan Follestad (afollestad)
|
||||||
*/
|
*/
|
||||||
public class MenuItemClickHelper {
|
public class MenuItemClickHelper {
|
||||||
public static boolean handleSongMenuClick(Activity activity, Song song, MenuItem item){
|
|
||||||
|
public static boolean handleSongMenuClick(ActionBarActivity activity, Song song, MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.action_delete_from_disk:
|
case R.id.action_delete_from_disk:
|
||||||
DeleteSongsDialogHelper.getDialog(activity, song).show();
|
DeleteSongsDialogHelper.getDialog(activity, song).show();
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_add_to_playlist:
|
case R.id.action_add_to_playlist:
|
||||||
AddToPlaylistDialogHelper.getDialog(activity, song).show();
|
AddToPlaylistDialog.create(song).show(activity.getSupportFragmentManager(), "ADD_PLAYLIST");
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_play_next:
|
case R.id.action_play_next:
|
||||||
MusicPlayerRemote.playNext(song);
|
MusicPlayerRemote.playNext(song);
|
||||||
|
|
@ -42,31 +47,31 @@ public class MenuItemClickHelper {
|
||||||
case R.id.action_details:
|
case R.id.action_details:
|
||||||
String songFilePath = SongFilePathLoader.getSongFilePath(activity, song.id);
|
String songFilePath = SongFilePathLoader.getSongFilePath(activity, song.id);
|
||||||
File songFile = new File(songFilePath);
|
File songFile = new File(songFilePath);
|
||||||
SongDetailDialogHelper.getDialog(activity, songFile).show();
|
SongDetailDialog.create(songFile).show(activity.getSupportFragmentManager(), "SONG_DETAILS");
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_go_to_album:
|
case R.id.action_go_to_album:
|
||||||
Pair[] albumPairs = null;
|
Pair[] albumPairs = null;
|
||||||
if (activity instanceof AbsFabActivity)
|
if (activity instanceof AbsFabActivity)
|
||||||
albumPairs = ((AbsFabActivity) activity).getSharedViewsWithFab(albumPairs);
|
albumPairs = ((AbsFabActivity) activity).getSharedViewsWithFab(null);
|
||||||
NavigationUtil.goToAlbum(activity, song.albumId, albumPairs);
|
NavigationUtil.goToAlbum(activity, song.albumId, albumPairs);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_go_to_artist:
|
case R.id.action_go_to_artist:
|
||||||
Pair[] artistPairs = null;
|
Pair[] artistPairs = null;
|
||||||
if (activity instanceof AbsFabActivity)
|
if (activity instanceof AbsFabActivity)
|
||||||
artistPairs = ((AbsFabActivity) activity).getSharedViewsWithFab(artistPairs);
|
artistPairs = ((AbsFabActivity) activity).getSharedViewsWithFab(null);
|
||||||
NavigationUtil.goToArtist(activity, song.artistId, artistPairs);
|
NavigationUtil.goToArtist(activity, song.artistId, artistPairs);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean handlePlaylistMenuClick(Activity activity, Playlist playlist, MenuItem item){
|
public static boolean handlePlaylistMenuClick(ActionBarActivity activity, Playlist playlist, MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.action_rename_playlist:
|
case R.id.action_rename_playlist:
|
||||||
RenamePlaylistDialogHelper.getDialog(activity, playlist.id).show();
|
RenamePlaylistDialog.create(playlist.id).show(activity.getSupportFragmentManager(), "RENAME_PLAYLIST");
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_delete_playlist:
|
case R.id.action_delete_playlist:
|
||||||
DeletePlaylistDialogHelper.getDialog(activity, playlist.id).show();
|
DeletePlaylistDialog.create(playlist.id).show(activity.getSupportFragmentManager(), "DELETE_PLAYLIST");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -20,27 +20,26 @@ import com.kabouzeid.gramophone.model.Song;
|
||||||
import com.kabouzeid.gramophone.service.MusicService;
|
import com.kabouzeid.gramophone.service.MusicService;
|
||||||
import com.kabouzeid.gramophone.util.InternalStorageUtil;
|
import com.kabouzeid.gramophone.util.InternalStorageUtil;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 29.11.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class MusicPlayerRemote {
|
public class MusicPlayerRemote {
|
||||||
|
|
||||||
private static final String TAG = MusicPlayerRemote.class.getSimpleName();
|
private static final String TAG = MusicPlayerRemote.class.getSimpleName();
|
||||||
|
|
||||||
private static int position = -1;
|
private static int position = -1;
|
||||||
|
|
||||||
private static List<Song> playingQueue;
|
private static ArrayList<Song> playingQueue;
|
||||||
private static List<Song> restoredOriginalQueue;
|
private static ArrayList<Song> restoredOriginalQueue;
|
||||||
|
|
||||||
private static Context context;
|
private static Context context;
|
||||||
private static MusicService musicService;
|
private static MusicService musicService;
|
||||||
private static Intent musicServiceIntent;
|
private static Intent musicServiceIntent;
|
||||||
|
|
||||||
private static ServiceConnection musicConnection = new ServiceConnection() {
|
private static final ServiceConnection musicConnection = new ServiceConnection() {
|
||||||
@Override
|
@Override
|
||||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||||
MusicService.MusicBinder binder = (MusicService.MusicBinder) service;
|
MusicService.MusicBinder binder = (MusicService.MusicBinder) service;
|
||||||
|
|
@ -72,11 +71,10 @@ public class MusicPlayerRemote {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean playSongAt(final int position) {
|
public static void playSongAt(final int position) {
|
||||||
if (musicService != null) {
|
if (musicService != null) {
|
||||||
musicService.playSongAt(position);
|
musicService.playSongAt(position);
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void pauseSong() {
|
public static void pauseSong() {
|
||||||
|
|
@ -104,10 +102,7 @@ public class MusicPlayerRemote {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPlaying() {
|
public static boolean isPlaying() {
|
||||||
if (musicService != null) {
|
return musicService != null && musicService.isPlaying();
|
||||||
return musicService.isPlaying();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void resumePlaying() {
|
public static void resumePlaying() {
|
||||||
|
|
@ -127,7 +122,7 @@ public class MusicPlayerRemote {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openQueue(final List<Song> playingQueue, final int startPosition, final boolean startPlaying) {
|
public static void openQueue(final ArrayList<Song> playingQueue, final int startPosition, final boolean startPlaying) {
|
||||||
MusicPlayerRemote.playingQueue = playingQueue;
|
MusicPlayerRemote.playingQueue = playingQueue;
|
||||||
if (musicService != null) {
|
if (musicService != null) {
|
||||||
musicService.openQueue(MusicPlayerRemote.playingQueue, startPosition, startPlaying);
|
musicService.openQueue(MusicPlayerRemote.playingQueue, startPosition, startPlaying);
|
||||||
|
|
@ -159,7 +154,7 @@ public class MusicPlayerRemote {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Song> getPlayingQueue() {
|
public static ArrayList<Song> getPlayingQueue() {
|
||||||
if (musicService != null) {
|
if (musicService != null) {
|
||||||
playingQueue = musicService.getPlayingQueue();
|
playingQueue = musicService.getPlayingQueue();
|
||||||
}
|
}
|
||||||
|
|
@ -174,10 +169,7 @@ public class MusicPlayerRemote {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPlayerPrepared() {
|
public static boolean isPlayerPrepared() {
|
||||||
if (musicService != null) {
|
return musicService != null && musicService.isPlayerPrepared();
|
||||||
return musicService.isPlayerPrepared();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getSongDurationMillis() {
|
public static int getSongDurationMillis() {
|
||||||
|
|
@ -207,20 +199,16 @@ public class MusicPlayerRemote {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getInt(AppKeys.SP_SHUFFLE_MODE, 0);
|
return PreferenceManager.getDefaultSharedPreferences(context).getInt(AppKeys.SP_SHUFFLE_MODE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean cycleRepeatMode() {
|
public static void cycleRepeatMode() {
|
||||||
if (musicService != null) {
|
if (musicService != null) {
|
||||||
musicService.cycleRepeatMode();
|
musicService.cycleRepeatMode();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean toggleShuffleMode() {
|
public static void toggleShuffleMode() {
|
||||||
if (musicService != null) {
|
if (musicService != null) {
|
||||||
musicService.toggleShuffle();
|
musicService.toggleShuffle();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean setShuffleMode(final int shuffleMode) {
|
public static boolean setShuffleMode(final int shuffleMode) {
|
||||||
|
|
@ -242,7 +230,7 @@ public class MusicPlayerRemote {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void shuffleAllSongs(final Context context) {
|
public static void shuffleAllSongs(final Context context) {
|
||||||
List<Song> songs = SongLoader.getAllSongs(context);
|
ArrayList<Song> songs = SongLoader.getAllSongs(context);
|
||||||
MusicPlayerRemote.openQueue(songs, new Random().nextInt(songs.size()), true);
|
MusicPlayerRemote.openQueue(songs, new Random().nextInt(songs.size()), true);
|
||||||
forceSetShuffleMode(context, MusicService.SHUFFLE_MODE_SHUFFLE);
|
forceSetShuffleMode(context, MusicService.SHUFFLE_MODE_SHUFFLE);
|
||||||
}
|
}
|
||||||
|
|
@ -294,8 +282,8 @@ public class MusicPlayerRemote {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static void restorePreviousState() {
|
public static void restorePreviousState() {
|
||||||
try {
|
try {
|
||||||
List restoredQueue = (ArrayList<Song>) InternalStorageUtil.readObject(context, AppKeys.IS_PLAYING_QUEUE);
|
ArrayList<Song> restoredQueue = (ArrayList<Song>) InternalStorageUtil.readObject(context, AppKeys.IS_PLAYING_QUEUE);
|
||||||
List restoredOriginalQueue = (ArrayList<Song>) InternalStorageUtil.readObject(context, AppKeys.IS_ORIGINAL_PLAYING_QUEUE);
|
ArrayList<Song> restoredOriginalQueue = (ArrayList<Song>) InternalStorageUtil.readObject(context, AppKeys.IS_ORIGINAL_PLAYING_QUEUE);
|
||||||
int restoredPosition = (int) InternalStorageUtil.readObject(context, AppKeys.IS_POSITION_IN_QUEUE);
|
int restoredPosition = (int) InternalStorageUtil.readObject(context, AppKeys.IS_POSITION_IN_QUEUE);
|
||||||
|
|
||||||
if (musicService != null) {
|
if (musicService != null) {
|
||||||
|
|
@ -307,7 +295,7 @@ public class MusicPlayerRemote {
|
||||||
position = restoredPosition;
|
position = restoredPosition;
|
||||||
|
|
||||||
postToBus(MusicRemoteEvent.STATE_RESTORED);
|
postToBus(MusicRemoteEvent.STATE_RESTORED);
|
||||||
} catch (IOException | ClassNotFoundException | ClassCastException e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "error while restoring music service state", e);
|
Log.e(TAG, "error while restoring music service state", e);
|
||||||
playingQueue = new ArrayList<>();
|
playingQueue = new ArrayList<>();
|
||||||
position = -1;
|
position = -1;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.kabouzeid.gramophone.helper;
|
package com.kabouzeid.gramophone.helper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 27.12.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
|
|
@ -25,6 +25,7 @@ import com.koushikdutta.async.future.FutureCallback;
|
||||||
import com.koushikdutta.ion.Ion;
|
import com.koushikdutta.ion.Ion;
|
||||||
|
|
||||||
public class PlayingNotificationHelper {
|
public class PlayingNotificationHelper {
|
||||||
|
|
||||||
public static final String TAG = PlayingNotificationHelper.class.getSimpleName();
|
public static final String TAG = PlayingNotificationHelper.class.getSimpleName();
|
||||||
public static final int NOTIFICATION_ID = 1337;
|
public static final int NOTIFICATION_ID = 1337;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
package com.kabouzeid.gramophone.helper;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.AdapterView;
|
|
||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
|
||||||
import com.kabouzeid.gramophone.R;
|
|
||||||
import com.kabouzeid.gramophone.adapter.PlayingQueueAdapter;
|
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
|
||||||
import com.mobeta.android.dslv.DragSortListView;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by karim on 24.01.15.
|
|
||||||
*/
|
|
||||||
public class PlayingQueueDialogHelper {
|
|
||||||
public static MaterialDialog getDialog(final Activity activity) {
|
|
||||||
final List<Song> playingQueue = MusicPlayerRemote.getPlayingQueue();
|
|
||||||
if (playingQueue.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
MaterialDialog dialog = new MaterialDialog.Builder(activity)
|
|
||||||
.title(activity.getResources().getString(R.string.label_current_playing_queue))
|
|
||||||
.customView(R.layout.dialog_playlist, false)
|
|
||||||
.positiveText(activity.getResources().getString(R.string.save_as_playlist))
|
|
||||||
.callback(new MaterialDialog.ButtonCallback() {
|
|
||||||
@Override
|
|
||||||
public void onPositive(MaterialDialog dialog) {
|
|
||||||
super.onPositive(dialog);
|
|
||||||
dialog.dismiss();
|
|
||||||
AddToPlaylistDialogHelper.getDialog(activity, playingQueue).show();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.build();
|
|
||||||
final DragSortListView dragSortListView = (DragSortListView) dialog.getCustomView().findViewById(R.id.dragSortListView);
|
|
||||||
final PlayingQueueAdapter playingQueueAdapter = new PlayingQueueAdapter(activity, playingQueue);
|
|
||||||
dragSortListView.setAdapter(playingQueueAdapter);
|
|
||||||
dragSortListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
||||||
MusicPlayerRemote.playSongAt(position);
|
|
||||||
playingQueueAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dragSortListView.setDropListener(new DragSortListView.DropListener() {
|
|
||||||
@Override
|
|
||||||
public void drop(int from, int to) {
|
|
||||||
MusicPlayerRemote.moveSong(from, to);
|
|
||||||
playingQueueAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return dialog;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
package com.kabouzeid.gramophone.helper;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
|
||||||
import com.kabouzeid.gramophone.R;
|
|
||||||
import com.kabouzeid.gramophone.util.PlaylistsUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by karim on 19.03.15.
|
|
||||||
*/
|
|
||||||
public class RenamePlaylistDialogHelper {
|
|
||||||
public static MaterialDialog getDialog(final Context context, final int playlistId) {
|
|
||||||
return new MaterialDialog.Builder(context)
|
|
||||||
.title(R.string.rename_playlist)
|
|
||||||
.positiveText(R.string.ok)
|
|
||||||
.negativeText(R.string.cancel)
|
|
||||||
.input("", PlaylistsUtil.getNameForPlaylist(context, playlistId), new MaterialDialog.InputCallback() {
|
|
||||||
@Override
|
|
||||||
public void onInput(MaterialDialog materialDialog, CharSequence charSequence) {
|
|
||||||
if (!charSequence.toString().trim().equals("")) {
|
|
||||||
PlaylistsUtil.renamePlaylist(context, playlistId, charSequence.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -6,9 +6,10 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 24.01.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class ShuffleHelper {
|
public class ShuffleHelper {
|
||||||
|
|
||||||
public static void makeShuffleList(List<Song> listToShuffle, final int current) {
|
public static void makeShuffleList(List<Song> listToShuffle, final int current) {
|
||||||
if (current >= 0) {
|
if (current >= 0) {
|
||||||
Song song = listToShuffle.remove(current);
|
Song song = listToShuffle.remove(current);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
package com.kabouzeid.gramophone.interfaces;
|
package com.kabouzeid.gramophone.interfaces;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 23.12.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public interface KabViewsDisableAble {
|
public interface KabViewsDisableAble {
|
||||||
public void enableViews();
|
|
||||||
|
|
||||||
public void disableViews();
|
void enableViews();
|
||||||
|
|
||||||
public boolean areViewsEnabled();
|
void disableViews();
|
||||||
|
|
||||||
|
boolean areViewsEnabled();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
package com.kabouzeid.gramophone.lastfm;
|
package com.kabouzeid.gramophone.lastfm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 15.01.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class LastFMUtil {
|
public class LastFMUtil {
|
||||||
public static String BASE_URL = "ws.audioscrobbler.com";
|
public static final String BASE_URL = "ws.audioscrobbler.com";
|
||||||
public static String API_KEY = "bd9c6ea4d55ec9ed3af7d276e5ece304";
|
public static final String API_KEY = "bd9c6ea4d55ec9ed3af7d276e5ece304";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 01.01.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class LastFMAlbumImageUrlLoader {
|
public class LastFMAlbumImageUrlLoader {
|
||||||
public static final String TAG = LastFMAlbumImageUrlLoader.class.getSimpleName();
|
public static final String TAG = LastFMAlbumImageUrlLoader.class.getSimpleName();
|
||||||
|
|
@ -50,9 +50,9 @@ public class LastFMAlbumImageUrlLoader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static interface AlbumImageUrlLoaderCallback {
|
public interface AlbumImageUrlLoaderCallback {
|
||||||
public void onAlbumImageUrlLoaded(String url);
|
void onAlbumImageUrlLoaded(String url);
|
||||||
|
|
||||||
public void onError();
|
void onError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,12 @@ import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 24.12.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class LastFMAlbumInfoUtil {
|
public class LastFMAlbumInfoUtil {
|
||||||
public static final String TAG = LastFMAlbumInfoUtil.class.getSimpleName();
|
public static final String TAG = LastFMAlbumInfoUtil.class.getSimpleName();
|
||||||
|
|
||||||
private static String AUTO_CORRECT = "1";
|
private static final String AUTO_CORRECT = "1";
|
||||||
|
|
||||||
public static String getAlbumUrl(String album, String artist) {
|
public static String getAlbumUrl(String album, String artist) {
|
||||||
if (album != null) {
|
if (album != null) {
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 01.01.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class LastFMArtistBiographyLoader {
|
public class LastFMArtistBiographyLoader {
|
||||||
public static final String TAG = LastFMArtistBiographyLoader.class.getSimpleName();
|
public static final String TAG = LastFMArtistBiographyLoader.class.getSimpleName();
|
||||||
|
|
@ -55,7 +55,7 @@ public class LastFMArtistBiographyLoader {
|
||||||
app.addToVolleyRequestQueue(artistInfoJSONRequest);
|
app.addToVolleyRequestQueue(artistInfoJSONRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static interface ArtistBioLoaderCallback {
|
public interface ArtistBioLoaderCallback {
|
||||||
public void onArtistBioLoaded(String bio);
|
void onArtistBioLoaded(String bio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 01.01.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class LastFMArtistImageUrlLoader {
|
public class LastFMArtistImageUrlLoader {
|
||||||
public static final String TAG = LastFMArtistImageUrlLoader.class.getSimpleName();
|
public static final String TAG = LastFMArtistImageUrlLoader.class.getSimpleName();
|
||||||
|
|
@ -42,7 +42,7 @@ public class LastFMArtistImageUrlLoader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static interface ArtistImageUrlLoaderCallback {
|
public interface ArtistImageUrlLoaderCallback {
|
||||||
public void onArtistImageUrlLoaded(String url);
|
void onArtistImageUrlLoaded(String url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,13 @@ import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 24.12.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class LastFMArtistInfoUtil {
|
public class LastFMArtistInfoUtil {
|
||||||
public static final String TAG = LastFMArtistInfoUtil.class.getSimpleName();
|
|
||||||
|
|
||||||
private static String AUTO_CORRECT = "1";
|
public static final String TAG = LastFMArtistInfoUtil.class.getSimpleName();
|
||||||
|
@SuppressWarnings("FieldCanBeLocal")
|
||||||
|
private static final String AUTO_CORRECT = "1";
|
||||||
|
|
||||||
public static String getArtistUrl(String artist) {
|
public static String getArtistUrl(String artist) {
|
||||||
if (artist != null) {
|
if (artist != null) {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 01.01.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class LastFMArtistThumbnailUrlLoader {
|
public class LastFMArtistThumbnailUrlLoader {
|
||||||
public static final String TAG = LastFMArtistThumbnailUrlLoader.class.getSimpleName();
|
public static final String TAG = LastFMArtistThumbnailUrlLoader.class.getSimpleName();
|
||||||
|
|
@ -42,7 +42,7 @@ public class LastFMArtistThumbnailUrlLoader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static interface ArtistThumbnailUrlLoaderCallback {
|
public interface ArtistThumbnailUrlLoaderCallback {
|
||||||
public void onArtistThumbnailUrlLoaded(String url);
|
void onArtistThumbnailUrlLoaded(String url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 29.12.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class AlbumLoader {
|
public class AlbumLoader {
|
||||||
|
|
||||||
|
|
@ -39,11 +39,11 @@ public class AlbumLoader {
|
||||||
return albums;
|
return albums;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Cursor makeAlbumCursor(final Context context) {
|
public static Cursor makeAlbumCursor(final Context context) {
|
||||||
return makeAlbumCursor(context, null, null);
|
return makeAlbumCursor(context, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Cursor makeAlbumCursor(final Context context, final String selection, final String[] values) {
|
public static Cursor makeAlbumCursor(final Context context, final String selection, final String[] values) {
|
||||||
return context.getContentResolver().query(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI,
|
return context.getContentResolver().query(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI,
|
||||||
new String[]{
|
new String[]{
|
||||||
/* 0 */
|
/* 0 */
|
||||||
|
|
|
||||||
|
|
@ -11,22 +11,21 @@ import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 29.12.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class AlbumSongLoader {
|
public class AlbumSongLoader {
|
||||||
|
|
||||||
public static List<Song> getAlbumSongList(final Context context, final int albumId, Comparator<Song> comparator) {
|
public static ArrayList<Song> getAlbumSongList(final Context context, final int albumId, Comparator<Song> comparator) {
|
||||||
List<Song> songs = getAlbumSongList(context, albumId);
|
ArrayList<Song> songs = getAlbumSongList(context, albumId);
|
||||||
Collections.sort(songs, comparator);
|
Collections.sort(songs, comparator);
|
||||||
return songs;
|
return songs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Song> getAlbumSongList(final Context context, final int albumId) {
|
public static ArrayList<Song> getAlbumSongList(final Context context, final int albumId) {
|
||||||
Cursor cursor = makeAlbumSongCursor(context, albumId);
|
Cursor cursor = makeAlbumSongCursor(context, albumId);
|
||||||
List<Song> songs = new ArrayList<>();
|
ArrayList<Song> songs = new ArrayList<>();
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
final int id = cursor.getInt(0);
|
final int id = cursor.getInt(0);
|
||||||
|
|
@ -48,11 +47,7 @@ public class AlbumSongLoader {
|
||||||
return songs;
|
return songs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Cursor makeAlbumSongCursor(final Context context, final int albumId) {
|
public static Cursor makeAlbumSongCursor(final Context context, final int albumId) {
|
||||||
final StringBuilder selection = new StringBuilder();
|
|
||||||
selection.append(MediaStore.Audio.AudioColumns.IS_MUSIC + "=1");
|
|
||||||
selection.append(" AND " + MediaStore.Audio.AudioColumns.TITLE + " != ''");
|
|
||||||
selection.append(" AND " + MediaStore.Audio.AudioColumns.ALBUM_ID + "=" + albumId);
|
|
||||||
return context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
|
return context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
|
||||||
new String[]{
|
new String[]{
|
||||||
/* 0 */
|
/* 0 */
|
||||||
|
|
@ -69,6 +64,9 @@ public class AlbumSongLoader {
|
||||||
MediaStore.Audio.AudioColumns.TRACK,
|
MediaStore.Audio.AudioColumns.TRACK,
|
||||||
/* 6 */
|
/* 6 */
|
||||||
MediaStore.Audio.AudioColumns.ARTIST_ID
|
MediaStore.Audio.AudioColumns.ARTIST_ID
|
||||||
}, selection.toString(), null, PreferenceUtils.getInstance(context).getAlbumSongSortOrder());
|
}, (MediaStore.Audio.AudioColumns.IS_MUSIC + "=1") + " AND " +
|
||||||
|
MediaStore.Audio.AudioColumns.TITLE + " != ''" + " AND " +
|
||||||
|
MediaStore.Audio.AudioColumns.ALBUM_ID + "=" + albumId, null,
|
||||||
|
PreferenceUtils.getInstance(context).getAlbumSongSortOrder());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 04.01.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class ArtistAlbumLoader {
|
public class ArtistAlbumLoader {
|
||||||
public static List<Album> getArtistAlbumList(final Context context, final int artistId) {
|
public static List<Album> getArtistAlbumList(final Context context, final int artistId) {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 29.12.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class ArtistLoader {
|
public class ArtistLoader {
|
||||||
|
|
||||||
|
|
@ -37,11 +37,11 @@ public class ArtistLoader {
|
||||||
return artists;
|
return artists;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Cursor makeArtistCursor(final Context context) {
|
public static Cursor makeArtistCursor(final Context context) {
|
||||||
return makeArtistCursor(context, null, null);
|
return makeArtistCursor(context, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Cursor makeArtistCursor(final Context context, final String selection, final String[] values) {
|
public static Cursor makeArtistCursor(final Context context, final String selection, final String[] values) {
|
||||||
return context.getContentResolver().query(MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI,
|
return context.getContentResolver().query(MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI,
|
||||||
new String[]{
|
new String[]{
|
||||||
/* 0 */
|
/* 0 */
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,15 @@ import com.kabouzeid.gramophone.model.Song;
|
||||||
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 01.01.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class ArtistSongLoader {
|
public class ArtistSongLoader {
|
||||||
public static List<Song> getArtistSongList(final Context context, final int artistId) {
|
|
||||||
|
public static ArrayList<Song> getArtistSongList(final Context context, final int artistId) {
|
||||||
Cursor cursor = makeArtistSongCursor(context, artistId);
|
Cursor cursor = makeArtistSongCursor(context, artistId);
|
||||||
List<Song> songs = new ArrayList<>();
|
ArrayList<Song> songs = new ArrayList<>();
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
final int id = cursor.getInt(0);
|
final int id = cursor.getInt(0);
|
||||||
|
|
@ -40,10 +40,6 @@ public class ArtistSongLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Cursor makeArtistSongCursor(final Context context, final int artistId) {
|
public static Cursor makeArtistSongCursor(final Context context, final int artistId) {
|
||||||
final StringBuilder selection = new StringBuilder();
|
|
||||||
selection.append(MediaStore.Audio.AudioColumns.IS_MUSIC + "=1");
|
|
||||||
selection.append(" AND " + MediaStore.Audio.AudioColumns.TITLE + " != ''");
|
|
||||||
selection.append(" AND " + MediaStore.Audio.AudioColumns.ARTIST_ID + "=" + artistId);
|
|
||||||
return context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
|
return context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
|
||||||
new String[]{
|
new String[]{
|
||||||
/* 0 */
|
/* 0 */
|
||||||
|
|
@ -60,6 +56,9 @@ public class ArtistSongLoader {
|
||||||
MediaStore.Audio.AudioColumns.TRACK,
|
MediaStore.Audio.AudioColumns.TRACK,
|
||||||
/* 6 */
|
/* 6 */
|
||||||
MediaStore.Audio.AudioColumns.ALBUM_ID
|
MediaStore.Audio.AudioColumns.ALBUM_ID
|
||||||
}, selection.toString(), null, PreferenceUtils.getInstance(context).getArtistSongSortOrder());
|
}, (MediaStore.Audio.AudioColumns.IS_MUSIC + "=1") + " AND " +
|
||||||
|
MediaStore.Audio.AudioColumns.TITLE + " != ''" + " AND " +
|
||||||
|
MediaStore.Audio.AudioColumns.ARTIST_ID + "=" + artistId, null,
|
||||||
|
PreferenceUtils.getInstance(context).getArtistSongSortOrder());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,11 @@ import android.provider.MediaStore.Audio.AudioColumns;
|
||||||
import com.kabouzeid.gramophone.model.PlaylistSong;
|
import com.kabouzeid.gramophone.model.PlaylistSong;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class PlaylistSongLoader {
|
public class PlaylistSongLoader {
|
||||||
|
|
||||||
public static List<PlaylistSong> getPlaylistSongList(final Context context, final int playlistID) {
|
public static ArrayList<PlaylistSong> getPlaylistSongList(final Context context, final int playlistID) {
|
||||||
List<PlaylistSong> songs = new ArrayList<>();
|
ArrayList<PlaylistSong> songs = new ArrayList<>();
|
||||||
Cursor cursor = makePlaylistSongCursor(context, playlistID);
|
Cursor cursor = makePlaylistSongCursor(context, playlistID);
|
||||||
|
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 11.01.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class SongFilePathLoader {
|
public class SongFilePathLoader {
|
||||||
public static final String TAG = SongFilePathLoader.class.getSimpleName();
|
public static final String TAG = SongFilePathLoader.class.getSimpleName();
|
||||||
|
|
@ -46,11 +46,11 @@ public class SongFilePathLoader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Cursor makeSongFilePathCursor(final Context context) {
|
public static Cursor makeSongFilePathCursor(final Context context) {
|
||||||
return makeSongFilePathCursor(context, null);
|
return makeSongFilePathCursor(context, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Cursor makeSongFilePathCursor(final Context context, String selection) {
|
public static Cursor makeSongFilePathCursor(final Context context, String selection) {
|
||||||
return context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
|
return context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
|
||||||
new String[]{
|
new String[]{
|
||||||
/* 0 */
|
/* 0 */
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,14 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 29.12.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class SongLoader {
|
public class SongLoader {
|
||||||
private static final String BASE_SELECTION = MediaStore.Audio.AudioColumns.IS_MUSIC + "=1" + " AND " + MediaStore.Audio.AudioColumns.TITLE + " != ''";
|
private static final String BASE_SELECTION = MediaStore.Audio.AudioColumns.IS_MUSIC + "=1" + " AND " + MediaStore.Audio.AudioColumns.TITLE + " != ''";
|
||||||
|
|
||||||
public static List<Song> getAllSongs(Context context) {
|
public static ArrayList<Song> getAllSongs(Context context) {
|
||||||
Cursor cursor = makeSongCursor(context);
|
Cursor cursor = makeSongCursor(context);
|
||||||
List<Song> songs = new ArrayList<>();
|
ArrayList<Song> songs = new ArrayList<>();
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
final int id = cursor.getInt(0);
|
final int id = cursor.getInt(0);
|
||||||
|
|
@ -48,7 +48,7 @@ public class SongLoader {
|
||||||
|
|
||||||
public static Cursor makeSongCursor(final Context context, final String selection, final String[] values) {
|
public static Cursor makeSongCursor(final Context context, final String selection, final String[] values) {
|
||||||
String finalSelection = BASE_SELECTION;
|
String finalSelection = BASE_SELECTION;
|
||||||
if(selection != null){
|
if (selection != null) {
|
||||||
finalSelection += " AND " + selection;
|
finalSelection += " AND " + selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.kabouzeid.gramophone.misc;
|
package com.kabouzeid.gramophone.misc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 22.12.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public final class AppKeys {
|
public final class AppKeys {
|
||||||
public static final String CL_CURRENT_ACTIVITY = "Current activity";
|
public static final String CL_CURRENT_ACTIVITY = "Current activity";
|
||||||
|
|
|
||||||
|
|
@ -71,13 +71,13 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
|
||||||
|
|
||||||
|
|
||||||
public interface OnItemMovedListener {
|
public interface OnItemMovedListener {
|
||||||
public void onItemMoved(int from, int to);
|
void onItemMoved(int from, int to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OnDragStateChangedListener {
|
public interface OnDragStateChangedListener {
|
||||||
public void onDragStart();
|
void onDragStart();
|
||||||
|
|
||||||
public void onDragStop();
|
void onDragStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void debugLog(String log) {
|
private void debugLog(String log) {
|
||||||
|
|
@ -135,15 +135,14 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
|
||||||
|
|
||||||
debugLog("View top = " + view.getTop());
|
debugLog("View top = " + view.getTop());
|
||||||
if (selectedDragItemPos != -1) {
|
if (selectedDragItemPos != -1) {
|
||||||
int itemPos = rv.getChildPosition(view);
|
int itemPos = rv.getChildAdapterPosition(view);
|
||||||
debugLog("itemPos =" + itemPos);
|
debugLog("itemPos =" + itemPos);
|
||||||
|
|
||||||
if (!canDragOver(itemPos)) {
|
if (!canDragOver(itemPos)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Movement of finger
|
// float totalMovement = fingerY - fingerAnchorY;
|
||||||
float totalMovement = fingerY - fingerAnchorY;
|
|
||||||
|
|
||||||
if (itemPos == selectedDragItemPos) {
|
if (itemPos == selectedDragItemPos) {
|
||||||
view.setVisibility(View.INVISIBLE);
|
view.setVisibility(View.INVISIBLE);
|
||||||
|
|
@ -211,7 +210,7 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
|
||||||
if (view.getVisibility() != View.VISIBLE)
|
if (view.getVisibility() != View.VISIBLE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int itemPos = rv.getChildPosition(view);
|
int itemPos = rv.getChildAdapterPosition(view);
|
||||||
|
|
||||||
if (itemPos == selectedDragItemPos) //Don't check against itself!
|
if (itemPos == selectedDragItemPos) //Don't check against itself!
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -306,7 +305,7 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
|
||||||
fingerOffsetInViewY = fingerAnchorY - itemView.getTop();
|
fingerOffsetInViewY = fingerAnchorY - itemView.getTop();
|
||||||
fingerY = fingerAnchorY;
|
fingerY = fingerAnchorY;
|
||||||
|
|
||||||
selectedDragItemPos = rv.getChildPosition(itemView);
|
selectedDragItemPos = rv.getChildAdapterPosition(itemView);
|
||||||
debugLog("selectedDragItemPos = " + selectedDragItemPos);
|
debugLog("selectedDragItemPos = " + selectedDragItemPos);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -381,7 +380,7 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Paint bgColor = new Paint();
|
final Paint bgColor = new Paint();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
|
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
|
||||||
|
|
@ -393,12 +392,7 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RecyclerView.OnScrollListener scrollListener = new RecyclerView.OnScrollListener() {
|
final RecyclerView.OnScrollListener scrollListener = new RecyclerView.OnScrollListener() {
|
||||||
@Override
|
|
||||||
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
|
||||||
super.onScrollStateChanged(recyclerView, newState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
||||||
super.onScrolled(recyclerView, dx, dy);
|
super.onScrolled(recyclerView, dx, dy);
|
||||||
|
|
@ -407,15 +401,10 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @param position
|
|
||||||
* @return True if we can drag the item over this position, False if not.
|
|
||||||
*/
|
|
||||||
protected boolean canDragOver(int position) {
|
protected boolean canDragOver(int position) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private BitmapDrawable createFloatingBitmap(View v) {
|
private BitmapDrawable createFloatingBitmap(View v) {
|
||||||
floatingItemStatingBounds = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
|
floatingItemStatingBounds = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
|
||||||
floatingItemBounds = new Rect(floatingItemStatingBounds);
|
floatingItemBounds = new Rect(floatingItemStatingBounds);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.kabouzeid.gramophone.misc;
|
package com.kabouzeid.gramophone.misc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 20.12.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class SmallAnimatorListener implements com.nineoldandroids.animation.Animator.AnimatorListener {
|
public class SmallAnimatorListener implements com.nineoldandroids.animation.Animator.AnimatorListener {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCal
|
||||||
import com.github.ksoichiro.android.observablescrollview.ScrollState;
|
import com.github.ksoichiro.android.observablescrollview.ScrollState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 20.12.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class SmallObservableScrollViewCallbacks implements ObservableScrollViewCallbacks {
|
public class SmallObservableScrollViewCallbacks implements ObservableScrollViewCallbacks {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import android.view.GestureDetector;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 20.12.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class SmallOnGestureListener implements GestureDetector.OnGestureListener {
|
public class SmallOnGestureListener implements GestureDetector.OnGestureListener {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import android.annotation.TargetApi;
|
||||||
import android.transition.Transition;
|
import android.transition.Transition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 20.12.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
@TargetApi(21)
|
@TargetApi(21)
|
||||||
public class SmallTransitionListener implements Transition.TransitionListener {
|
public class SmallTransitionListener implements Transition.TransitionListener {
|
||||||
|
|
|
||||||
|
|
@ -8,16 +8,16 @@ import com.kabouzeid.gramophone.util.MusicUtil;
|
||||||
import com.koushikdutta.ion.Ion;
|
import com.koushikdutta.ion.Ion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 22.11.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class Album implements SearchEntry {
|
public class Album implements SearchEntry {
|
||||||
|
|
||||||
public int id;
|
public final int id;
|
||||||
public int artistId;
|
public int artistId;
|
||||||
public String title;
|
public final String title;
|
||||||
public String artistName;
|
public final String artistName;
|
||||||
public int songCount;
|
public final int songCount;
|
||||||
public int year;
|
public final int year;
|
||||||
|
|
||||||
public Album(final int id, final String title, final String artistName, final int artistId,
|
public Album(final int id, final String title, final String artistName, final int artistId,
|
||||||
final int songNumber, final int albumYear) {
|
final int songNumber, final int albumYear) {
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,13 @@ import com.kabouzeid.gramophone.lastfm.artist.LastFMArtistThumbnailUrlLoader;
|
||||||
import com.koushikdutta.ion.Ion;
|
import com.koushikdutta.ion.Ion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 29.12.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class Artist implements SearchEntry {
|
public class Artist implements SearchEntry {
|
||||||
public int id;
|
public final int id;
|
||||||
public String name;
|
public final String name;
|
||||||
public int albumCount;
|
public final int albumCount;
|
||||||
public int songCount;
|
public final int songCount;
|
||||||
|
|
||||||
public Artist(final int id, final String name, final int albumCount, final int songCount) {
|
public Artist(final int id, final String name, final int albumCount, final int songCount) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.kabouzeid.gramophone.model;
|
package com.kabouzeid.gramophone.model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 17.03.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class DataBaseChangedEvent {
|
public class DataBaseChangedEvent {
|
||||||
public static final int PLAYLISTS_CHANGED = 0;
|
public static final int PLAYLISTS_CHANGED = 0;
|
||||||
|
|
@ -10,7 +10,7 @@ public class DataBaseChangedEvent {
|
||||||
public static final int SONGS_CHANGED = 3;
|
public static final int SONGS_CHANGED = 3;
|
||||||
public static final int DATABASE_CHANGED = 4;
|
public static final int DATABASE_CHANGED = 4;
|
||||||
|
|
||||||
private int action;
|
private final int action;
|
||||||
|
|
||||||
public DataBaseChangedEvent(int action) {
|
public DataBaseChangedEvent(int action) {
|
||||||
this.action = action;
|
this.action = action;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.kabouzeid.gramophone.model;
|
package com.kabouzeid.gramophone.model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 19.12.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class MusicRemoteEvent {
|
public class MusicRemoteEvent {
|
||||||
public static final int PLAY = 0;
|
public static final int PLAY = 0;
|
||||||
|
|
@ -24,7 +24,7 @@ public class MusicRemoteEvent {
|
||||||
public static final int SHUFFLE_MODE_CHANGED = 13;
|
public static final int SHUFFLE_MODE_CHANGED = 13;
|
||||||
public static final int REPEAT_MODE_CHANGED = 14;
|
public static final int REPEAT_MODE_CHANGED = 14;
|
||||||
|
|
||||||
private int action;
|
private final int action;
|
||||||
|
|
||||||
public MusicRemoteEvent(int action) {
|
public MusicRemoteEvent(int action) {
|
||||||
this.action = action;
|
this.action = action;
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
package com.kabouzeid.gramophone.model;
|
package com.kabouzeid.gramophone.model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 23.11.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class NavigationDrawerItem {
|
public class NavigationDrawerItem {
|
||||||
public String title;
|
|
||||||
public int imageRes;
|
public final String title;
|
||||||
|
public final int imageRes;
|
||||||
|
|
||||||
public NavigationDrawerItem(String title, int imageRes) {
|
public NavigationDrawerItem(String title, int imageRes) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
package com.kabouzeid.gramophone.model;
|
package com.kabouzeid.gramophone.model;
|
||||||
|
|
||||||
public class Playlist {
|
public class Playlist {
|
||||||
public int id;
|
public final int id;
|
||||||
public String name;
|
public final String name;
|
||||||
|
|
||||||
public Playlist(final int id, final String name) {
|
public Playlist(final int id, final String name) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.kabouzeid.gramophone.model;
|
package com.kabouzeid.gramophone.model;
|
||||||
|
|
||||||
public class PlaylistSong extends Song {
|
public class PlaylistSong extends Song {
|
||||||
public int playlistId;
|
public final int playlistId;
|
||||||
public int idInPlayList;
|
public int idInPlayList;
|
||||||
|
|
||||||
public PlaylistSong(final int id, final int albumId, final int artistId, final String title, final String artistName,
|
public PlaylistSong(final int id, final int albumId, final int artistId, final String title, final String artistName,
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,12 @@ import android.content.Context;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 27.02.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public interface SearchEntry {
|
public interface SearchEntry {
|
||||||
public String getTitle();
|
String getTitle();
|
||||||
|
|
||||||
public String getSubTitle();
|
String getSubTitle();
|
||||||
|
|
||||||
public void loadImage(Context context, ImageView imageView);
|
void loadImage(Context context, ImageView imageView);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,18 +6,18 @@ import android.widget.ImageView;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 23.11.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class Song implements Serializable, SearchEntry {
|
public class Song implements Serializable, SearchEntry {
|
||||||
|
|
||||||
public int id;
|
public int id;
|
||||||
public int albumId;
|
public final int albumId;
|
||||||
public int artistId;
|
public final int artistId;
|
||||||
public String title;
|
public final String title;
|
||||||
public String artistName;
|
public final String artistName;
|
||||||
public String albumName;
|
public final String albumName;
|
||||||
public long duration;
|
public final long duration;
|
||||||
public int trackNumber;
|
public final int trackNumber;
|
||||||
|
|
||||||
public Song(final int id, final int albumId, final int artistId, final String title, final String artistName,
|
public Song(final int id, final int albumId, final int artistId, final String title, final String artistName,
|
||||||
final String albumName, final long duration, final int trackNumber) {
|
final String albumName, final long duration, final int trackNumber) {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
package com.kabouzeid.gramophone.model;
|
package com.kabouzeid.gramophone.model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 28.03.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class UiPreferenceChangedEvent {
|
public class UIPreferenceChangedEvent {
|
||||||
public static final int THEME_CHANGED = 0;
|
public static final int THEME_CHANGED = 0;
|
||||||
public static final int ALBUM_OVERVIEW_PALETTE_CHANGED = 1;
|
public static final int ALBUM_OVERVIEW_PALETTE_CHANGED = 1;
|
||||||
public static final int COLORED_NAVIGATION_BAR_ARTIST_CHANGED = 2;
|
public static final int COLORED_NAVIGATION_BAR_ARTIST_CHANGED = 2;
|
||||||
|
|
@ -11,10 +11,10 @@ public class UiPreferenceChangedEvent {
|
||||||
public static final int PLAYBACK_CONTROLLER_CARD_CHANGED = 4;
|
public static final int PLAYBACK_CONTROLLER_CARD_CHANGED = 4;
|
||||||
public static final int TOOLBAR_TRANSPARENT_CHANGED = 5;
|
public static final int TOOLBAR_TRANSPARENT_CHANGED = 5;
|
||||||
|
|
||||||
private int action;
|
private final int action;
|
||||||
private Object value;
|
private final Object value;
|
||||||
|
|
||||||
public UiPreferenceChangedEvent(int action, Object value) {
|
public UIPreferenceChangedEvent(int action, Object value) {
|
||||||
this.action = action;
|
this.action = action;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.kabouzeid.gramophone.prefs;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.preference.Preference;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.kabouzeid.gramophone.R;
|
||||||
|
import com.kabouzeid.gramophone.views.CircleView;
|
||||||
|
|
||||||
|
public class ColorChooserPreference extends Preference {
|
||||||
|
|
||||||
|
private View mView;
|
||||||
|
private int color;
|
||||||
|
private int border;
|
||||||
|
|
||||||
|
public ColorChooserPreference(Context context, AttributeSet attrs) {
|
||||||
|
this(context, attrs, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ColorChooserPreference(Context context) {
|
||||||
|
this(context, null, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ColorChooserPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
setLayoutResource(R.layout.preference_custom);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onBindView(@NonNull View view) {
|
||||||
|
super.onBindView(view);
|
||||||
|
mView = view;
|
||||||
|
invalidateColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColor(int color, int border) {
|
||||||
|
this.color = color;
|
||||||
|
this.border = border;
|
||||||
|
invalidateColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void invalidateColor() {
|
||||||
|
if (mView != null) {
|
||||||
|
CircleView circle = (CircleView) mView.findViewById(R.id.circle);
|
||||||
|
if (this.color != 0) {
|
||||||
|
circle.setVisibility(View.VISIBLE);
|
||||||
|
circle.setBackgroundColor(color);
|
||||||
|
circle.setBorderColor(border);
|
||||||
|
} else {
|
||||||
|
circle.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.kabouzeid.gramophone.prefs;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.preference.PreferenceCategory;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.ThemeSingleton;
|
||||||
|
import com.kabouzeid.gramophone.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uses the theme's primary color as the text color of the category.
|
||||||
|
*
|
||||||
|
* @author Aidan Follestad (afollestad)
|
||||||
|
*/
|
||||||
|
public class DynamicPreferenceCategory extends PreferenceCategory {
|
||||||
|
|
||||||
|
public DynamicPreferenceCategory(Context context, AttributeSet attrs) {
|
||||||
|
this(context, attrs, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DynamicPreferenceCategory(Context context) {
|
||||||
|
this(context, null, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DynamicPreferenceCategory(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
setLayoutResource(R.layout.preference_category_custom);
|
||||||
|
setSelectable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onBindView(@NonNull View view) {
|
||||||
|
super.onBindView(view);
|
||||||
|
((TextView) view.findViewById(android.R.id.title)).setTextColor(ThemeSingleton.get().positiveColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -81,9 +81,9 @@ public class AlbumJSONStore extends SQLiteOpenHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface AlbumJSONColumns {
|
public interface AlbumJSONColumns {
|
||||||
public static final String NAME = "AlbumJSON";
|
String NAME = "AlbumJSON";
|
||||||
public static final String ALBUMANDARTIST_NAME = "AlbumAndArtistName";
|
String ALBUMANDARTIST_NAME = "AlbumAndArtistName";
|
||||||
public static final String JSON = "JSON";
|
String JSON = "JSON";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -81,9 +81,9 @@ public class ArtistJSONStore extends SQLiteOpenHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ArtistJSONColumns {
|
public interface ArtistJSONColumns {
|
||||||
public static final String NAME = "ArtistJSON";
|
String NAME = "ArtistJSON";
|
||||||
public static final String ARTIST_NAME = "ArtistName";
|
String ARTIST_NAME = "ArtistName";
|
||||||
public static final String JSON = "JSON";
|
String JSON = "JSON";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@ import com.koushikdutta.ion.Ion;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class MusicService extends Service implements MediaPlayer.OnPreparedListener, MediaPlayer.OnErrorListener, MediaPlayer.OnCompletionListener, AudioManager.OnAudioFocusChangeListener {
|
public class MusicService extends Service implements MediaPlayer.OnPreparedListener, MediaPlayer.OnErrorListener, MediaPlayer.OnCompletionListener, AudioManager.OnAudioFocusChangeListener {
|
||||||
public static final String ACTION_TOGGLE_PLAYBACK = "com.kabouzeid.gramophone.action.TOGGLE_PLAYBACK";
|
public static final String ACTION_TOGGLE_PLAYBACK = "com.kabouzeid.gramophone.action.TOGGLE_PLAYBACK";
|
||||||
|
|
@ -66,8 +65,8 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private MediaPlayer player;
|
private MediaPlayer player;
|
||||||
private List<Song> playingQueue;
|
private ArrayList<Song> playingQueue;
|
||||||
private List<Song> originalPlayingQueue;
|
private ArrayList<Song> originalPlayingQueue;
|
||||||
private int currentSongId = -1;
|
private int currentSongId = -1;
|
||||||
private int position = -1;
|
private int position = -1;
|
||||||
private int shuffleMode;
|
private int shuffleMode;
|
||||||
|
|
@ -384,7 +383,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
||||||
playingNotificationHelper.buildNotification(playingQueue.get(position), isPlaying());
|
playingNotificationHelper.buildNotification(playingQueue.get(position), isPlaying());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateWidgets(){
|
private void updateWidgets() {
|
||||||
MusicPlayerWidget.updateWidgets(this, playingQueue.get(position), isPlaying());
|
MusicPlayerWidget.updateWidgets(this, playingQueue.get(position), isPlaying());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -425,7 +424,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
||||||
return getPosition() == getPlayingQueue().size() - 1;
|
return getPosition() == getPlayingQueue().size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Song> getPlayingQueue() {
|
public ArrayList<Song> getPlayingQueue() {
|
||||||
return playingQueue;
|
return playingQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -468,7 +467,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
||||||
savePosition();
|
savePosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openQueue(final List<Song> playingQueue, final int startPosition, final boolean startPlaying) {
|
public void openQueue(final ArrayList<Song> playingQueue, final int startPosition, final boolean startPlaying) {
|
||||||
if (playingQueue != null && !playingQueue.isEmpty() && startPosition >= 0 && startPosition < playingQueue.size()) {
|
if (playingQueue != null && !playingQueue.isEmpty() && startPosition >= 0 && startPosition < playingQueue.size()) {
|
||||||
originalPlayingQueue = playingQueue;
|
originalPlayingQueue = playingQueue;
|
||||||
this.playingQueue = new ArrayList<>(originalPlayingQueue);
|
this.playingQueue = new ArrayList<>(originalPlayingQueue);
|
||||||
|
|
@ -507,7 +506,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restorePreviousState(final List<Song> originalPlayingQueue, final List<Song> playingQueue, int position) {
|
public void restorePreviousState(final ArrayList<Song> originalPlayingQueue, final ArrayList<Song> playingQueue, int position) {
|
||||||
this.originalPlayingQueue = originalPlayingQueue;
|
this.originalPlayingQueue = originalPlayingQueue;
|
||||||
this.playingQueue = playingQueue;
|
this.playingQueue = playingQueue;
|
||||||
this.position = position;
|
this.position = position;
|
||||||
|
|
@ -765,6 +764,8 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAudioSessionId() {
|
public int getAudioSessionId() {
|
||||||
|
if (player == null)
|
||||||
|
return AudioEffect.ERROR_BAD_VALUE;
|
||||||
return player.getAudioSessionId();
|
return player.getAudioSessionId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.util.DialogUtils;
|
||||||
import com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView;
|
import com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView;
|
||||||
import com.kabouzeid.gramophone.App;
|
import com.kabouzeid.gramophone.App;
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
|
|
@ -28,7 +29,7 @@ import com.kabouzeid.gramophone.misc.AppKeys;
|
||||||
import com.kabouzeid.gramophone.misc.SmallObservableScrollViewCallbacks;
|
import com.kabouzeid.gramophone.misc.SmallObservableScrollViewCallbacks;
|
||||||
import com.kabouzeid.gramophone.model.Album;
|
import com.kabouzeid.gramophone.model.Album;
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
import com.kabouzeid.gramophone.model.Song;
|
||||||
import com.kabouzeid.gramophone.model.UiPreferenceChangedEvent;
|
import com.kabouzeid.gramophone.model.UIPreferenceChangedEvent;
|
||||||
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
||||||
import com.kabouzeid.gramophone.ui.activities.tageditor.AlbumTagEditorActivity;
|
import com.kabouzeid.gramophone.ui.activities.tageditor.AlbumTagEditorActivity;
|
||||||
import com.kabouzeid.gramophone.util.MusicUtil;
|
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||||
|
|
@ -41,7 +42,7 @@ import com.koushikdutta.ion.Ion;
|
||||||
import com.nineoldandroids.view.ViewHelper;
|
import com.nineoldandroids.view.ViewHelper;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
|
@ -52,10 +53,8 @@ import java.util.List;
|
||||||
* */
|
* */
|
||||||
|
|
||||||
public class AlbumDetailActivity extends AbsFabActivity {
|
public class AlbumDetailActivity extends AbsFabActivity {
|
||||||
|
|
||||||
public static final String TAG = AlbumDetailActivity.class.getSimpleName();
|
public static final String TAG = AlbumDetailActivity.class.getSimpleName();
|
||||||
|
|
||||||
private App app;
|
|
||||||
|
|
||||||
private Album album;
|
private Album album;
|
||||||
|
|
||||||
private ObservableRecyclerView recyclerView;
|
private ObservableRecyclerView recyclerView;
|
||||||
|
|
@ -64,12 +63,11 @@ public class AlbumDetailActivity extends AbsFabActivity {
|
||||||
private View songsBackgroundView;
|
private View songsBackgroundView;
|
||||||
private TextView albumTitleView;
|
private TextView albumTitleView;
|
||||||
private Toolbar toolbar;
|
private Toolbar toolbar;
|
||||||
private int toolbarHeight;
|
|
||||||
private int headerOffset;
|
private int headerOffset;
|
||||||
private int titleViewHeight;
|
private int titleViewHeight;
|
||||||
private int albumArtViewHeight;
|
private int albumArtViewHeight;
|
||||||
private int toolbarColor;
|
private int toolbarColor;
|
||||||
private SmallObservableScrollViewCallbacks observableScrollViewCallbacks = new SmallObservableScrollViewCallbacks() {
|
private final SmallObservableScrollViewCallbacks observableScrollViewCallbacks = new SmallObservableScrollViewCallbacks() {
|
||||||
@Override
|
@Override
|
||||||
public void onScrollChanged(int scrollY, boolean b, boolean b2) {
|
public void onScrollChanged(int scrollY, boolean b, boolean b2) {
|
||||||
scrollY += albumArtViewHeight + titleViewHeight;
|
scrollY += albumArtViewHeight + titleViewHeight;
|
||||||
|
|
@ -111,7 +109,7 @@ public class AlbumDetailActivity extends AbsFabActivity {
|
||||||
|
|
||||||
if (Util.hasLollipopSDK()) postponeEnterTransition();
|
if (Util.hasLollipopSDK()) postponeEnterTransition();
|
||||||
if (Util.hasLollipopSDK() && PreferenceUtils.getInstance(this).coloredNavigationBarAlbumEnabled())
|
if (Util.hasLollipopSDK() && PreferenceUtils.getInstance(this).coloredNavigationBarAlbumEnabled())
|
||||||
getWindow().setNavigationBarColor(Util.resolveColor(this, R.attr.default_bar_color));
|
getWindow().setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||||
|
|
||||||
Bundle intentExtras = getIntent().getExtras();
|
Bundle intentExtras = getIntent().getExtras();
|
||||||
int albumId = -1;
|
int albumId = -1;
|
||||||
|
|
@ -145,8 +143,8 @@ public class AlbumDetailActivity extends AbsFabActivity {
|
||||||
|
|
||||||
private void setUpObservableListViewParams() {
|
private void setUpObservableListViewParams() {
|
||||||
albumArtViewHeight = getResources().getDimensionPixelSize(R.dimen.header_image_height);
|
albumArtViewHeight = getResources().getDimensionPixelSize(R.dimen.header_image_height);
|
||||||
toolbarColor = Util.resolveColor(this, R.attr.default_bar_color);
|
toolbarColor = DialogUtils.resolveColor(this, R.attr.default_bar_color);
|
||||||
toolbarHeight = Util.getActionBarSize(this);
|
int toolbarHeight = Util.getActionBarSize(this);
|
||||||
titleViewHeight = getResources().getDimensionPixelSize(R.dimen.title_view_height);
|
titleViewHeight = getResources().getDimensionPixelSize(R.dimen.title_view_height);
|
||||||
headerOffset = toolbarHeight;
|
headerOffset = toolbarHeight;
|
||||||
headerOffset += getResources().getDimensionPixelSize(R.dimen.statusMargin);
|
headerOffset += getResources().getDimensionPixelSize(R.dimen.statusMargin);
|
||||||
|
|
@ -235,7 +233,7 @@ public class AlbumDetailActivity extends AbsFabActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpSongsAdapter() {
|
private void setUpSongsAdapter() {
|
||||||
final List<Song> songs = AlbumSongLoader.getAlbumSongList(this, album.id, new SongTrackNumberComparator());
|
final ArrayList<Song> songs = AlbumSongLoader.getAlbumSongList(this, album.id, new SongTrackNumberComparator());
|
||||||
final AlbumSongAdapter albumSongAdapter = new AlbumSongAdapter(this, songs);
|
final AlbumSongAdapter albumSongAdapter = new AlbumSongAdapter(this, songs);
|
||||||
recyclerView.setLayoutManager(new GridLayoutManager(this, 1));
|
recyclerView.setLayoutManager(new GridLayoutManager(this, 1));
|
||||||
recyclerView.setAdapter(albumSongAdapter);
|
recyclerView.setAdapter(albumSongAdapter);
|
||||||
|
|
@ -289,8 +287,7 @@ public class AlbumDetailActivity extends AbsFabActivity {
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_go_to_artist:
|
case R.id.action_go_to_artist:
|
||||||
Pair[] artistPairs = null;
|
Pair[] artistPairs = getSharedViewsWithFab(null);
|
||||||
artistPairs = getSharedViewsWithFab(artistPairs);
|
|
||||||
NavigationUtil.goToArtist(this, album.artistId, artistPairs);
|
NavigationUtil.goToArtist(this, album.artistId, artistPairs);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -298,9 +295,9 @@ public class AlbumDetailActivity extends AbsFabActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onUIPreferenceChanged(UiPreferenceChangedEvent event) {
|
public void onUIPreferenceChanged(UIPreferenceChangedEvent event) {
|
||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
case UiPreferenceChangedEvent.COLORED_NAVIGATION_BAR_ALBUM_CHANGED:
|
case UIPreferenceChangedEvent.COLORED_NAVIGATION_BAR_ALBUM_CHANGED:
|
||||||
setNavigationBarColored((boolean) event.getValue());
|
setNavigationBarColored((boolean) event.getValue());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
|
import com.afollestad.materialdialogs.util.DialogUtils;
|
||||||
import com.github.ksoichiro.android.observablescrollview.ObservableListView;
|
import com.github.ksoichiro.android.observablescrollview.ObservableListView;
|
||||||
import com.kabouzeid.gramophone.App;
|
import com.kabouzeid.gramophone.App;
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
|
|
@ -38,7 +39,7 @@ import com.kabouzeid.gramophone.misc.SmallObservableScrollViewCallbacks;
|
||||||
import com.kabouzeid.gramophone.model.Album;
|
import com.kabouzeid.gramophone.model.Album;
|
||||||
import com.kabouzeid.gramophone.model.Artist;
|
import com.kabouzeid.gramophone.model.Artist;
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
import com.kabouzeid.gramophone.model.Song;
|
||||||
import com.kabouzeid.gramophone.model.UiPreferenceChangedEvent;
|
import com.kabouzeid.gramophone.model.UIPreferenceChangedEvent;
|
||||||
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
||||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||||
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||||
|
|
@ -49,6 +50,7 @@ import com.koushikdutta.ion.Ion;
|
||||||
import com.nineoldandroids.view.ViewHelper;
|
import com.nineoldandroids.view.ViewHelper;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -73,7 +75,6 @@ public class ArtistDetailActivity extends AbsFabActivity {
|
||||||
private View songsBackgroundView;
|
private View songsBackgroundView;
|
||||||
private TextView artistNameTv;
|
private TextView artistNameTv;
|
||||||
private Toolbar toolbar;
|
private Toolbar toolbar;
|
||||||
private int toolbarHeight;
|
|
||||||
private int headerOffset;
|
private int headerOffset;
|
||||||
private int titleViewHeight;
|
private int titleViewHeight;
|
||||||
private int artistImageViewHeight;
|
private int artistImageViewHeight;
|
||||||
|
|
@ -84,7 +85,7 @@ public class ArtistDetailActivity extends AbsFabActivity {
|
||||||
|
|
||||||
private Spanned biography;
|
private Spanned biography;
|
||||||
|
|
||||||
private SmallObservableScrollViewCallbacks observableScrollViewCallbacks = new SmallObservableScrollViewCallbacks() {
|
private final SmallObservableScrollViewCallbacks observableScrollViewCallbacks = new SmallObservableScrollViewCallbacks() {
|
||||||
@Override
|
@Override
|
||||||
public void onScrollChanged(int scrollY, boolean b, boolean b2) {
|
public void onScrollChanged(int scrollY, boolean b, boolean b2) {
|
||||||
scrollY += artistImageViewHeight + titleViewHeight;
|
scrollY += artistImageViewHeight + titleViewHeight;
|
||||||
|
|
@ -127,7 +128,7 @@ public class ArtistDetailActivity extends AbsFabActivity {
|
||||||
|
|
||||||
if (Util.hasLollipopSDK()) postponeEnterTransition();
|
if (Util.hasLollipopSDK()) postponeEnterTransition();
|
||||||
if (Util.hasLollipopSDK() && PreferenceUtils.getInstance(this).coloredNavigationBarArtistEnabled())
|
if (Util.hasLollipopSDK() && PreferenceUtils.getInstance(this).coloredNavigationBarArtistEnabled())
|
||||||
getWindow().setNavigationBarColor(Util.resolveColor(this, R.attr.default_bar_color));
|
getWindow().setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||||
|
|
||||||
getIntentExtras();
|
getIntentExtras();
|
||||||
initViews();
|
initViews();
|
||||||
|
|
@ -153,8 +154,8 @@ public class ArtistDetailActivity extends AbsFabActivity {
|
||||||
|
|
||||||
private void setUpObservableListViewParams() {
|
private void setUpObservableListViewParams() {
|
||||||
artistImageViewHeight = getResources().getDimensionPixelSize(R.dimen.header_image_height);
|
artistImageViewHeight = getResources().getDimensionPixelSize(R.dimen.header_image_height);
|
||||||
toolbarColor = Util.resolveColor(this, R.attr.default_bar_color);
|
toolbarColor = DialogUtils.resolveColor(this, R.attr.default_bar_color);
|
||||||
toolbarHeight = Util.getActionBarSize(this);
|
int toolbarHeight = Util.getActionBarSize(this);
|
||||||
titleViewHeight = getResources().getDimensionPixelSize(R.dimen.title_view_height);
|
titleViewHeight = getResources().getDimensionPixelSize(R.dimen.title_view_height);
|
||||||
headerOffset = toolbarHeight;
|
headerOffset = toolbarHeight;
|
||||||
headerOffset += getResources().getDimensionPixelSize(R.dimen.statusMargin);
|
headerOffset += getResources().getDimensionPixelSize(R.dimen.statusMargin);
|
||||||
|
|
@ -193,7 +194,7 @@ public class ArtistDetailActivity extends AbsFabActivity {
|
||||||
songListView.setPadding(0, artistImageViewHeight + titleViewHeight, 0, 0);
|
songListView.setPadding(0, artistImageViewHeight + titleViewHeight, 0, 0);
|
||||||
songListView.addHeaderView(songListHeader);
|
songListView.addHeaderView(songListHeader);
|
||||||
|
|
||||||
final List<Song> songs = ArtistSongLoader.getArtistSongList(this, artist.id);
|
final ArrayList<Song> songs = ArtistSongLoader.getArtistSongList(this, artist.id);
|
||||||
ArtistSongAdapter songAdapter = new ArtistSongAdapter(this, songs);
|
ArtistSongAdapter songAdapter = new ArtistSongAdapter(this, songs);
|
||||||
songListView.setAdapter(songAdapter);
|
songListView.setAdapter(songAdapter);
|
||||||
|
|
||||||
|
|
@ -242,6 +243,7 @@ public class ArtistDetailActivity extends AbsFabActivity {
|
||||||
return new MaterialDialog.Builder(ArtistDetailActivity.this)
|
return new MaterialDialog.Builder(ArtistDetailActivity.this)
|
||||||
.title(artist.name)
|
.title(artist.name)
|
||||||
.content(biography)
|
.content(biography)
|
||||||
|
.positiveText(android.R.string.ok)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -297,15 +299,15 @@ public class ArtistDetailActivity extends AbsFabActivity {
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
private void resetColors() {
|
private void resetColors() {
|
||||||
int titleTextColor = Util.resolveColor(this, R.attr.title_text_color);
|
int titleTextColor = DialogUtils.resolveColor(this, R.attr.title_text_color);
|
||||||
int defaultBarColor = Util.resolveColor(this, R.attr.default_bar_color);
|
int defaultBarColor = DialogUtils.resolveColor(this, R.attr.default_bar_color);
|
||||||
|
|
||||||
toolbarColor = defaultBarColor;
|
toolbarColor = defaultBarColor;
|
||||||
artistNameTv.setBackgroundColor(defaultBarColor);
|
artistNameTv.setBackgroundColor(defaultBarColor);
|
||||||
artistNameTv.setTextColor(titleTextColor);
|
artistNameTv.setTextColor(titleTextColor);
|
||||||
|
|
||||||
if (Util.hasLollipopSDK() && PreferenceUtils.getInstance(this).coloredNavigationBarArtistEnabled())
|
if (Util.hasLollipopSDK() && PreferenceUtils.getInstance(this).coloredNavigationBarArtistEnabled())
|
||||||
getWindow().setNavigationBarColor(Util.resolveColor(this, R.attr.default_bar_color));
|
getWindow().setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpToolBar() {
|
private void setUpToolBar() {
|
||||||
|
|
@ -411,9 +413,9 @@ public class ArtistDetailActivity extends AbsFabActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onUIPreferenceChanged(UiPreferenceChangedEvent event) {
|
public void onUIPreferenceChanged(UIPreferenceChangedEvent event) {
|
||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
case UiPreferenceChangedEvent.COLORED_NAVIGATION_BAR_ARTIST_CHANGED:
|
case UIPreferenceChangedEvent.COLORED_NAVIGATION_BAR_ARTIST_CHANGED:
|
||||||
setNavigationBarColored((boolean) event.getValue());
|
setNavigationBarColored((boolean) event.getValue());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.support.v4.util.Pair;
|
import android.support.v4.util.Pair;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
|
|
@ -17,11 +18,12 @@ import android.view.MenuItem;
|
||||||
import android.view.SubMenu;
|
import android.view.SubMenu;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.ThemeSingleton;
|
||||||
import com.astuetz.PagerSlidingTabStrip;
|
import com.astuetz.PagerSlidingTabStrip;
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.adapter.PagerAdapter;
|
import com.kabouzeid.gramophone.adapter.PagerAdapter;
|
||||||
import com.kabouzeid.gramophone.helper.AboutDeveloperDialogHelper;
|
import com.kabouzeid.gramophone.dialogs.AboutDialog;
|
||||||
import com.kabouzeid.gramophone.helper.CreatePlaylistDialogHelper;
|
import com.kabouzeid.gramophone.dialogs.CreatePlaylistDialog;
|
||||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||||
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
|
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
|
||||||
import com.kabouzeid.gramophone.loader.AlbumSongLoader;
|
import com.kabouzeid.gramophone.loader.AlbumSongLoader;
|
||||||
|
|
@ -29,7 +31,7 @@ import com.kabouzeid.gramophone.loader.ArtistSongLoader;
|
||||||
import com.kabouzeid.gramophone.loader.PlaylistSongLoader;
|
import com.kabouzeid.gramophone.loader.PlaylistSongLoader;
|
||||||
import com.kabouzeid.gramophone.model.MusicRemoteEvent;
|
import com.kabouzeid.gramophone.model.MusicRemoteEvent;
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
import com.kabouzeid.gramophone.model.Song;
|
||||||
import com.kabouzeid.gramophone.model.UiPreferenceChangedEvent;
|
import com.kabouzeid.gramophone.model.UIPreferenceChangedEvent;
|
||||||
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
||||||
import com.kabouzeid.gramophone.ui.fragments.NavigationDrawerFragment;
|
import com.kabouzeid.gramophone.ui.fragments.NavigationDrawerFragment;
|
||||||
import com.kabouzeid.gramophone.ui.fragments.mainactivityfragments.AbsMainActivityFragment;
|
import com.kabouzeid.gramophone.ui.fragments.mainactivityfragments.AbsMainActivityFragment;
|
||||||
|
|
@ -44,6 +46,7 @@ import com.kabouzeid.gramophone.util.Util;
|
||||||
import com.kabouzeid.gramophone.util.ViewUtil;
|
import com.kabouzeid.gramophone.util.ViewUtil;
|
||||||
import com.koushikdutta.ion.Ion;
|
import com.koushikdutta.ion.Ion;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -95,8 +98,7 @@ public class MainActivity extends AbsFabActivity
|
||||||
|
|
||||||
navigationDrawerFragment.setItemChecked(startPosition);
|
navigationDrawerFragment.setItemChecked(startPosition);
|
||||||
|
|
||||||
final int accentColor = Util.resolveColor(MainActivity.this, R.attr.colorAccent);
|
slidingTabLayout.setIndicatorColor(ThemeSingleton.get().positiveColor);
|
||||||
slidingTabLayout.setIndicatorColor(accentColor);
|
|
||||||
slidingTabLayout.setViewPager(viewPager);
|
slidingTabLayout.setViewPager(viewPager);
|
||||||
|
|
||||||
slidingTabLayout.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
slidingTabLayout.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||||
|
|
@ -137,7 +139,7 @@ public class MainActivity extends AbsFabActivity
|
||||||
|
|
||||||
private void setToolBarTransparent(boolean transparent) {
|
private void setToolBarTransparent(boolean transparent) {
|
||||||
float alpha = transparent ? 0.97f : 1f;
|
float alpha = transparent ? 0.97f : 1f;
|
||||||
final int colorPrimary = Util.resolveColor(this, R.attr.colorPrimary);
|
final int colorPrimary = PreferenceUtils.getInstance(this).getThemeColorPrimary();
|
||||||
ViewUtil.setBackgroundAlpha(toolbar, alpha, colorPrimary);
|
ViewUtil.setBackgroundAlpha(toolbar, alpha, colorPrimary);
|
||||||
ViewUtil.setBackgroundAlpha(statusBar, alpha, colorPrimary);
|
ViewUtil.setBackgroundAlpha(statusBar, alpha, colorPrimary);
|
||||||
ViewUtil.setBackgroundAlpha(slidingTabLayout, alpha, colorPrimary);
|
ViewUtil.setBackgroundAlpha(slidingTabLayout, alpha, colorPrimary);
|
||||||
|
|
@ -223,6 +225,22 @@ public class MainActivity extends AbsFabActivity
|
||||||
getResources().getString(R.string.transition_album_cover)
|
getResources().getString(R.string.transition_album_cover)
|
||||||
)
|
)
|
||||||
}));
|
}));
|
||||||
|
} else if (position == NavigationDrawerFragment.ABOUT_INDEX) {
|
||||||
|
drawerLayout.closeDrawers();
|
||||||
|
new Handler().postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
new AboutDialog().show(getSupportFragmentManager(), "ABOUT_DIALOG");
|
||||||
|
}
|
||||||
|
}, 200);
|
||||||
|
} else if (position == NavigationDrawerFragment.SETTINGS_INDEX) {
|
||||||
|
drawerLayout.closeDrawers();
|
||||||
|
new Handler().postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
startActivity(new Intent(MainActivity.this, SettingsActivity.class));
|
||||||
|
}
|
||||||
|
}, 200);
|
||||||
} else {
|
} else {
|
||||||
if (viewPager != null) {
|
if (viewPager != null) {
|
||||||
viewPager.setCurrentItem(position, true);
|
viewPager.setCurrentItem(position, true);
|
||||||
|
|
@ -268,17 +286,11 @@ public class MainActivity extends AbsFabActivity
|
||||||
MusicPlayerRemote.shuffleAllSongs(this);
|
MusicPlayerRemote.shuffleAllSongs(this);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_new_playlist:
|
case R.id.action_new_playlist:
|
||||||
CreatePlaylistDialogHelper.getDialog(this).show();
|
CreatePlaylistDialog.create().show(getSupportFragmentManager(), "CREATE_PLAYLIST");
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_search:
|
case R.id.action_search:
|
||||||
startActivity(new Intent(MainActivity.this, SearchActivity.class));
|
startActivity(new Intent(MainActivity.this, SearchActivity.class));
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_settings:
|
|
||||||
startActivity(new Intent(MainActivity.this, SettingsActivity.class));
|
|
||||||
return true;
|
|
||||||
case R.id.action_about:
|
|
||||||
AboutDeveloperDialogHelper.getDialog(this).show();
|
|
||||||
return true;
|
|
||||||
case R.id.action_current_playing:
|
case R.id.action_current_playing:
|
||||||
NavigationUtil.openCurrentPlayingIfPossible(this, getSharedViewsWithFab(null));
|
NavigationUtil.openCurrentPlayingIfPossible(this, getSharedViewsWithFab(null));
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -296,10 +308,10 @@ public class MainActivity extends AbsFabActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUIPreferenceChangedEvent(UiPreferenceChangedEvent event) {
|
public void onUIPreferenceChangedEvent(UIPreferenceChangedEvent event) {
|
||||||
super.onUIPreferenceChangedEvent(event);
|
super.onUIPreferenceChangedEvent(event);
|
||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
case UiPreferenceChangedEvent.TOOLBAR_TRANSPARENT_CHANGED:
|
case UIPreferenceChangedEvent.TOOLBAR_TRANSPARENT_CHANGED:
|
||||||
setToolBarTransparent((boolean) event.getValue());
|
setToolBarTransparent((boolean) event.getValue());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -320,9 +332,9 @@ public class MainActivity extends AbsFabActivity
|
||||||
PreferenceUtils.getInstance(MainActivity.this).setLastStartPage(currentPage);
|
PreferenceUtils.getInstance(MainActivity.this).setLastStartPage(currentPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean handlePlaybackIntent(Intent intent) {
|
private void handlePlaybackIntent(Intent intent) {
|
||||||
if (intent == null) {
|
if (intent == null) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Uri uri = intent.getData();
|
Uri uri = intent.getData();
|
||||||
|
|
@ -336,7 +348,8 @@ public class MainActivity extends AbsFabActivity
|
||||||
final int id = (int) parseIdFromIntent(intent, "playlistId", "playlist");
|
final int id = (int) parseIdFromIntent(intent, "playlistId", "playlist");
|
||||||
if (id >= 0) {
|
if (id >= 0) {
|
||||||
int position = intent.getIntExtra("position", 0);
|
int position = intent.getIntExtra("position", 0);
|
||||||
MusicPlayerRemote.openQueue((List<Song>) (List<? extends Song>) PlaylistSongLoader.getPlaylistSongList(this, id), position, true);
|
//noinspection unchecked
|
||||||
|
MusicPlayerRemote.openQueue((ArrayList<Song>) (List<? extends Song>) PlaylistSongLoader.getPlaylistSongList(this, id), position, true);
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
} else if (MediaStore.Audio.Albums.CONTENT_TYPE.equals(mimeType)) {
|
} else if (MediaStore.Audio.Albums.CONTENT_TYPE.equals(mimeType)) {
|
||||||
|
|
@ -357,7 +370,6 @@ public class MainActivity extends AbsFabActivity
|
||||||
if (handled) {
|
if (handled) {
|
||||||
setIntent(new Intent());
|
setIntent(new Intent());
|
||||||
}
|
}
|
||||||
return handled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private long parseIdFromIntent(Intent intent, String longKey,
|
private long parseIdFromIntent(Intent intent, String longKey,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.graphics.Palette;
|
import android.support.v7.graphics.Palette;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
@ -19,17 +18,20 @@ import android.widget.SeekBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.ThemeSingleton;
|
||||||
|
import com.afollestad.materialdialogs.internal.MDTintHelper;
|
||||||
|
import com.afollestad.materialdialogs.util.DialogUtils;
|
||||||
import com.kabouzeid.gramophone.App;
|
import com.kabouzeid.gramophone.App;
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.helper.AddToPlaylistDialogHelper;
|
import com.kabouzeid.gramophone.dialogs.AddToPlaylistDialog;
|
||||||
|
import com.kabouzeid.gramophone.dialogs.SongDetailDialog;
|
||||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||||
import com.kabouzeid.gramophone.helper.SongDetailDialogHelper;
|
|
||||||
import com.kabouzeid.gramophone.lastfm.artist.LastFMArtistImageUrlLoader;
|
import com.kabouzeid.gramophone.lastfm.artist.LastFMArtistImageUrlLoader;
|
||||||
import com.kabouzeid.gramophone.loader.SongFilePathLoader;
|
import com.kabouzeid.gramophone.loader.SongFilePathLoader;
|
||||||
import com.kabouzeid.gramophone.misc.AppKeys;
|
import com.kabouzeid.gramophone.misc.AppKeys;
|
||||||
import com.kabouzeid.gramophone.model.MusicRemoteEvent;
|
import com.kabouzeid.gramophone.model.MusicRemoteEvent;
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
import com.kabouzeid.gramophone.model.Song;
|
||||||
import com.kabouzeid.gramophone.model.UiPreferenceChangedEvent;
|
import com.kabouzeid.gramophone.model.UIPreferenceChangedEvent;
|
||||||
import com.kabouzeid.gramophone.service.MusicService;
|
import com.kabouzeid.gramophone.service.MusicService;
|
||||||
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
||||||
import com.kabouzeid.gramophone.ui.activities.tageditor.SongTagEditorActivity;
|
import com.kabouzeid.gramophone.ui.activities.tageditor.SongTagEditorActivity;
|
||||||
|
|
@ -65,9 +67,7 @@ public class MusicControllerActivity extends AbsFabActivity {
|
||||||
private ImageButton repeatButton;
|
private ImageButton repeatButton;
|
||||||
private ImageButton shuffleButton;
|
private ImageButton shuffleButton;
|
||||||
private View mediaControllerContainer;
|
private View mediaControllerContainer;
|
||||||
|
|
||||||
private int lastFooterColor = -1;
|
private int lastFooterColor = -1;
|
||||||
|
|
||||||
private boolean killThreads = false;
|
private boolean killThreads = false;
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
|
@ -128,11 +128,13 @@ public class MusicControllerActivity extends AbsFabActivity {
|
||||||
if (Util.hasLollipopSDK()) {
|
if (Util.hasLollipopSDK()) {
|
||||||
mediaControllerContainer.setElevation(getResources().getDimensionPixelSize(R.dimen.cardview_default_elevation));
|
mediaControllerContainer.setElevation(getResources().getDimensionPixelSize(R.dimen.cardview_default_elevation));
|
||||||
}
|
}
|
||||||
mediaControllerContainer.setBackgroundColor(Util.resolveColor(this, R.attr.music_controller_container_color));
|
mediaControllerContainer.setBackgroundColor(
|
||||||
|
DialogUtils.resolveColor(this, R.attr.music_controller_container_color));
|
||||||
} else {
|
} else {
|
||||||
if (Util.hasLollipopSDK() && !Util.isInPortraitMode(this)) {
|
if (Util.hasLollipopSDK() && !Util.isInPortraitMode(this)) {
|
||||||
mediaControllerContainer.setElevation(getResources().getDimensionPixelSize(R.dimen.cardview_default_elevation));
|
mediaControllerContainer.setElevation(getResources().getDimensionPixelSize(R.dimen.cardview_default_elevation));
|
||||||
mediaControllerContainer.setBackgroundColor(Util.resolveColor(this, R.attr.music_controller_container_color));
|
mediaControllerContainer.setBackgroundColor(
|
||||||
|
DialogUtils.resolveColor(this, R.attr.music_controller_container_color));
|
||||||
} else {
|
} else {
|
||||||
mediaControllerContainer.setBackground(null);
|
mediaControllerContainer.setBackground(null);
|
||||||
}
|
}
|
||||||
|
|
@ -140,6 +142,7 @@ public class MusicControllerActivity extends AbsFabActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpProgressSlider() {
|
private void setUpProgressSlider() {
|
||||||
|
MDTintHelper.setTint(progressSlider, ThemeSingleton.get().positiveColor);
|
||||||
progressSlider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
progressSlider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||||
|
|
@ -159,8 +162,10 @@ public class MusicControllerActivity extends AbsFabActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpPrevNext() {
|
private void setUpPrevNext() {
|
||||||
nextButton.setImageDrawable(Util.getTintedDrawable(getResources(), R.drawable.ic_skip_next_white_48dp, Util.resolveColor(this, R.attr.themed_drawable_color)));
|
nextButton.setImageDrawable(Util.getTintedDrawable(this,
|
||||||
prevButton.setImageDrawable(Util.getTintedDrawable(getResources(), R.drawable.ic_skip_previous_white_48dp, Util.resolveColor(this, R.attr.themed_drawable_color)));
|
R.drawable.ic_skip_next_white_48dp, DialogUtils.resolveColor(this, R.attr.themed_drawable_color)));
|
||||||
|
prevButton.setImageDrawable(Util.getTintedDrawable(this,
|
||||||
|
R.drawable.ic_skip_previous_white_48dp, DialogUtils.resolveColor(this, R.attr.themed_drawable_color)));
|
||||||
nextButton.setOnClickListener(new View.OnClickListener() {
|
nextButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
@ -188,10 +193,12 @@ public class MusicControllerActivity extends AbsFabActivity {
|
||||||
private void updateShuffleState() {
|
private void updateShuffleState() {
|
||||||
switch (MusicPlayerRemote.getShuffleMode()) {
|
switch (MusicPlayerRemote.getShuffleMode()) {
|
||||||
case MusicService.SHUFFLE_MODE_SHUFFLE:
|
case MusicService.SHUFFLE_MODE_SHUFFLE:
|
||||||
shuffleButton.setImageDrawable(Util.getTintedDrawable(getResources(), R.drawable.ic_shuffle_white_48dp, Util.resolveColor(this, R.attr.themed_drawable_activated_color)));
|
shuffleButton.setImageDrawable(Util.getTintedDrawable(this, R.drawable.ic_shuffle_white_48dp,
|
||||||
|
ThemeSingleton.get().positiveColor));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
shuffleButton.setImageDrawable(Util.getTintedDrawable(getResources(), R.drawable.ic_shuffle_white_48dp, Util.resolveColor(this, R.attr.themed_drawable_color)));
|
shuffleButton.setImageDrawable(Util.getTintedDrawable(this, R.drawable.ic_shuffle_white_48dp,
|
||||||
|
DialogUtils.resolveColor(this, R.attr.themed_drawable_color)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -209,13 +216,16 @@ public class MusicControllerActivity extends AbsFabActivity {
|
||||||
private void updateRepeatState() {
|
private void updateRepeatState() {
|
||||||
switch (MusicPlayerRemote.getRepeatMode()) {
|
switch (MusicPlayerRemote.getRepeatMode()) {
|
||||||
case MusicService.REPEAT_MODE_NONE:
|
case MusicService.REPEAT_MODE_NONE:
|
||||||
repeatButton.setImageDrawable(Util.getTintedDrawable(getResources(), R.drawable.ic_repeat_white_48dp, Util.resolveColor(this, R.attr.themed_drawable_color)));
|
repeatButton.setImageDrawable(Util.getTintedDrawable(this, R.drawable.ic_repeat_white_48dp,
|
||||||
|
DialogUtils.resolveColor(this, R.attr.themed_drawable_color)));
|
||||||
break;
|
break;
|
||||||
case MusicService.REPEAT_MODE_ALL:
|
case MusicService.REPEAT_MODE_ALL:
|
||||||
repeatButton.setImageDrawable(Util.getTintedDrawable(getResources(), R.drawable.ic_repeat_white_48dp, Util.resolveColor(this, R.attr.themed_drawable_activated_color)));
|
repeatButton.setImageDrawable(Util.getTintedDrawable(this, R.drawable.ic_repeat_white_48dp,
|
||||||
|
ThemeSingleton.get().positiveColor));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
repeatButton.setImageDrawable(Util.getTintedDrawable(getResources(), R.drawable.ic_repeat_one_white_48dp, Util.resolveColor(this, R.attr.themed_drawable_activated_color)));
|
repeatButton.setImageDrawable(Util.getTintedDrawable(this, R.drawable.ic_repeat_one_white_48dp,
|
||||||
|
ThemeSingleton.get().positiveColor));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -301,9 +311,9 @@ public class MusicControllerActivity extends AbsFabActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetColors() {
|
private void resetColors() {
|
||||||
int songTitleTextColor = Util.resolveColor(this, R.attr.title_text_color);
|
int songTitleTextColor = DialogUtils.resolveColor(this, R.attr.title_text_color);
|
||||||
int artistNameTextColor = Util.resolveColor(this, R.attr.caption_text_color);
|
int artistNameTextColor = DialogUtils.resolveColor(this, R.attr.caption_text_color);
|
||||||
int defaultBarColor = Util.resolveColor(this, R.attr.default_bar_color);
|
int defaultBarColor = DialogUtils.resolveColor(this, R.attr.default_bar_color);
|
||||||
|
|
||||||
animateColorChange(defaultBarColor);
|
animateColorChange(defaultBarColor);
|
||||||
|
|
||||||
|
|
@ -358,7 +368,8 @@ public class MusicControllerActivity extends AbsFabActivity {
|
||||||
Thread.sleep(1);
|
Thread.sleep(1);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
return;
|
return;
|
||||||
} catch (Exception e) {
|
} catch (Exception e2) {
|
||||||
|
e2.printStackTrace();
|
||||||
}
|
}
|
||||||
final int finalTotal = total;
|
final int finalTotal = total;
|
||||||
final int finalCurrentPosition = currentPosition;
|
final int finalCurrentPosition = currentPosition;
|
||||||
|
|
@ -432,7 +443,7 @@ public class MusicControllerActivity extends AbsFabActivity {
|
||||||
Toast.makeText(this, "This feature is not available yet", Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, "This feature is not available yet", Toast.LENGTH_SHORT).show();
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_add_to_playlist:
|
case R.id.action_add_to_playlist:
|
||||||
AddToPlaylistDialogHelper.getDialog(this, song).show();
|
AddToPlaylistDialog.create(song).show(getSupportFragmentManager(), "ADD_PLAYLIST");
|
||||||
return true;
|
return true;
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
|
|
@ -448,7 +459,7 @@ public class MusicControllerActivity extends AbsFabActivity {
|
||||||
case R.id.action_details:
|
case R.id.action_details:
|
||||||
String songFilePath = SongFilePathLoader.getSongFilePath(this, song.id);
|
String songFilePath = SongFilePathLoader.getSongFilePath(this, song.id);
|
||||||
File songFile = new File(songFilePath);
|
File songFile = new File(songFilePath);
|
||||||
SongDetailDialogHelper.getDialog(this, songFile).show();
|
SongDetailDialog.create(songFile).show(getSupportFragmentManager(), "SONG_DETAIL");
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_go_to_album:
|
case R.id.action_go_to_album:
|
||||||
NavigationUtil.goToAlbum(this, song.albumId, getSharedViewsWithFab(null));
|
NavigationUtil.goToAlbum(this, song.albumId, getSharedViewsWithFab(null));
|
||||||
|
|
@ -472,9 +483,9 @@ public class MusicControllerActivity extends AbsFabActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onUIPrefsChanged(UiPreferenceChangedEvent event) {
|
public void onUIPrefsChanged(UIPreferenceChangedEvent event) {
|
||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
case UiPreferenceChangedEvent.PLAYBACK_CONTROLLER_CARD_CHANGED:
|
case UIPreferenceChangedEvent.PLAYBACK_CONTROLLER_CARD_CHANGED:
|
||||||
setUpBox((boolean) event.getValue());
|
setUpBox((boolean) event.getValue());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.kabouzeid.gramophone.ui.activities;
|
package com.kabouzeid.gramophone.ui.activities;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.widget.GridLayoutManager;
|
import android.support.v7.widget.GridLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
|
@ -18,25 +20,34 @@ import com.kabouzeid.gramophone.model.PlaylistSong;
|
||||||
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
||||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||||
import com.kabouzeid.gramophone.util.PlaylistsUtil;
|
import com.kabouzeid.gramophone.util.PlaylistsUtil;
|
||||||
|
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||||
|
import com.kabouzeid.gramophone.util.Util;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class PlaylistDetailActivity extends AbsFabActivity {
|
public class PlaylistDetailActivity extends AbsFabActivity {
|
||||||
|
|
||||||
public static final String TAG = PlaylistDetailActivity.class.getSimpleName();
|
public static final String TAG = PlaylistDetailActivity.class.getSimpleName();
|
||||||
private RecyclerView recyclerView;
|
|
||||||
private Playlist playlist;
|
private Playlist playlist;
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
setUpTranslucence(false, false);
|
setUpTranslucence(false, false);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_playlist_detail);
|
setContentView(R.layout.activity_playlist_detail);
|
||||||
|
|
||||||
getIntentExtras();
|
final int primary = PreferenceUtils.getInstance(this).getThemeColorPrimary();
|
||||||
setUpToolBar();
|
final int primaryDark = PreferenceUtils.getInstance(this).getThemeColorPrimaryDarker();
|
||||||
|
if (Util.hasLollipopSDK()) {
|
||||||
|
getWindow().setStatusBarColor(primaryDark);
|
||||||
|
getWindow().setNavigationBarColor(primaryDark);
|
||||||
|
}
|
||||||
|
|
||||||
recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
|
getIntentExtras();
|
||||||
final List<PlaylistSong> songs = PlaylistSongLoader.getPlaylistSongList(this, playlist.id);
|
|
||||||
|
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
|
||||||
|
final ArrayList<PlaylistSong> songs = PlaylistSongLoader.getPlaylistSongList(this, playlist.id);
|
||||||
final PlaylistSongAdapter adapter = new PlaylistSongAdapter(this, songs);
|
final PlaylistSongAdapter adapter = new PlaylistSongAdapter(this, songs);
|
||||||
recyclerView.setLayoutManager(new GridLayoutManager(this, 1));
|
recyclerView.setLayoutManager(new GridLayoutManager(this, 1));
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
@ -57,6 +68,12 @@ public class PlaylistDetailActivity extends AbsFabActivity {
|
||||||
recyclerView.addItemDecoration(dragSortRecycler);
|
recyclerView.addItemDecoration(dragSortRecycler);
|
||||||
recyclerView.addOnItemTouchListener(dragSortRecycler);
|
recyclerView.addOnItemTouchListener(dragSortRecycler);
|
||||||
recyclerView.setOnScrollListener(dragSortRecycler.getScrollListener());
|
recyclerView.setOnScrollListener(dragSortRecycler.getScrollListener());
|
||||||
|
|
||||||
|
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||||
|
toolbar.setBackgroundColor(primary);
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
getSupportActionBar().setTitle(playlist.name);
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getIntentExtras() {
|
private void getIntentExtras() {
|
||||||
|
|
@ -68,12 +85,6 @@ public class PlaylistDetailActivity extends AbsFabActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpToolBar() {
|
|
||||||
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
|
|
||||||
getSupportActionBar().setTitle(playlist.name);
|
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTag() {
|
public String getTag() {
|
||||||
return TAG;
|
return TAG;
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import com.kabouzeid.gramophone.model.SearchEntry;
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
import com.kabouzeid.gramophone.model.Song;
|
||||||
import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity;
|
import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity;
|
||||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||||
|
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||||
import com.kabouzeid.gramophone.util.Util;
|
import com.kabouzeid.gramophone.util.Util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -48,9 +49,11 @@ public class SearchActivity extends AbsBaseActivity {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_search);
|
setContentView(R.layout.activity_search);
|
||||||
|
|
||||||
|
final int primary = PreferenceUtils.getInstance(this).getThemeColorPrimary();
|
||||||
|
final int primaryDark = PreferenceUtils.getInstance(this).getThemeColorPrimaryDarker();
|
||||||
if (Util.hasLollipopSDK()) {
|
if (Util.hasLollipopSDK()) {
|
||||||
getWindow().setStatusBarColor(Util.resolveColor(this, R.attr.colorPrimaryDark));
|
getWindow().setStatusBarColor(primaryDark);
|
||||||
getWindow().setNavigationBarColor(Util.resolveColor(this, R.attr.colorPrimaryDark));
|
getWindow().setNavigationBarColor(primaryDark);
|
||||||
}
|
}
|
||||||
|
|
||||||
listView = (ListView) findViewById(R.id.list);
|
listView = (ListView) findViewById(R.id.list);
|
||||||
|
|
@ -60,7 +63,7 @@ public class SearchActivity extends AbsBaseActivity {
|
||||||
Object item = parent.getItemAtPosition(position);
|
Object item = parent.getItemAtPosition(position);
|
||||||
if (item instanceof SearchEntry) {
|
if (item instanceof SearchEntry) {
|
||||||
if (item instanceof Song) {
|
if (item instanceof Song) {
|
||||||
List<Song> playList = new ArrayList<>();
|
ArrayList<Song> playList = new ArrayList<>();
|
||||||
playList.add((Song) item);
|
playList.add((Song) item);
|
||||||
MusicPlayerRemote.openQueue(playList, 0, true);
|
MusicPlayerRemote.openQueue(playList, 0, true);
|
||||||
} else if (item instanceof Album) {
|
} else if (item instanceof Album) {
|
||||||
|
|
@ -95,7 +98,9 @@ public class SearchActivity extends AbsBaseActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
|
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||||
|
toolbar.setBackgroundColor(primary);
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -164,10 +169,7 @@ public class SearchActivity extends AbsBaseActivity {
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
if (id == R.id.action_settings) {
|
return id == R.id.action_settings || super.onOptionsItemSelected(item);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void search(String query) {
|
private void search(String query) {
|
||||||
|
|
@ -201,7 +203,7 @@ public class SearchActivity extends AbsBaseActivity {
|
||||||
|
|
||||||
|
|
||||||
public static class LabelEntry implements SearchEntry {
|
public static class LabelEntry implements SearchEntry {
|
||||||
String title;
|
final String title;
|
||||||
String label;
|
String label;
|
||||||
|
|
||||||
public LabelEntry(String label) {
|
public LabelEntry(String label) {
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.media.audiofx.AudioEffect;
|
import android.media.audiofx.AudioEffect;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
|
|
@ -12,23 +13,46 @@ import android.preference.PreferenceManager;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.util.DialogUtils;
|
||||||
import com.kabouzeid.gramophone.App;
|
import com.kabouzeid.gramophone.App;
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.model.UiPreferenceChangedEvent;
|
import com.kabouzeid.gramophone.dialogs.ColorChooserDialog;
|
||||||
|
import com.kabouzeid.gramophone.model.UIPreferenceChangedEvent;
|
||||||
|
import com.kabouzeid.gramophone.prefs.ColorChooserPreference;
|
||||||
import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity;
|
import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity;
|
||||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||||
|
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||||
|
|
||||||
public class SettingsActivity extends AbsBaseActivity {
|
public class SettingsActivity extends AbsBaseActivity implements ColorChooserDialog.ColorCallback {
|
||||||
public static final String TAG = SettingsActivity.class.getSimpleName();
|
public static final String TAG = SettingsActivity.class.getSimpleName();
|
||||||
|
|
||||||
|
private Toolbar mToolbar;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_preferences);
|
setContentView(R.layout.activity_preferences);
|
||||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
mToolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
mToolbar.setBackgroundColor(PreferenceUtils.getInstance(this).getThemeColorPrimary());
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
getWindow().setStatusBarColor(PreferenceUtils.getInstance(this).getThemeColorPrimaryDarker());
|
||||||
|
setSupportActionBar(mToolbar);
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
getFragmentManager().beginTransaction().replace(R.id.content_frame, new SettingsFragment()).commit();
|
|
||||||
|
if (savedInstanceState == null)
|
||||||
|
getFragmentManager().beginTransaction().replace(R.id.content_frame, new SettingsFragment()).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onColorSelection(int title, int color) {
|
||||||
|
if (title == R.string.primary_color) {
|
||||||
|
PreferenceUtils.getInstance(this).setThemeColorPrimary(color);
|
||||||
|
App.bus.post(new UIPreferenceChangedEvent(UIPreferenceChangedEvent.THEME_CHANGED, color));
|
||||||
|
} else if (title == R.string.accent_color) {
|
||||||
|
PreferenceUtils.getInstance(this).setThemeColorAccent(color);
|
||||||
|
App.bus.post(new UIPreferenceChangedEvent(UIPreferenceChangedEvent.THEME_CHANGED, color));
|
||||||
|
}
|
||||||
|
recreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SettingsFragment extends PreferenceFragment {
|
public static class SettingsFragment extends PreferenceFragment {
|
||||||
|
|
@ -57,7 +81,31 @@ public class SettingsActivity extends AbsBaseActivity {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object o) {
|
public boolean onPreferenceChange(Preference preference, Object o) {
|
||||||
setSummary(generalTheme, o);
|
setSummary(generalTheme, o);
|
||||||
App.bus.post(new UiPreferenceChangedEvent(UiPreferenceChangedEvent.THEME_CHANGED, o));
|
App.bus.post(new UIPreferenceChangedEvent(UIPreferenceChangedEvent.THEME_CHANGED, o));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ColorChooserPreference primaryColor = (ColorChooserPreference) findPreference("primary_color");
|
||||||
|
primaryColor.setColor(PreferenceUtils.getInstance(getActivity()).getThemeColorPrimary(),
|
||||||
|
DialogUtils.resolveColor(getActivity(), android.R.attr.textColorPrimary));
|
||||||
|
primaryColor.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
new ColorChooserDialog().show(getActivity(), preference.getTitleRes(),
|
||||||
|
PreferenceUtils.getInstance(getActivity()).getThemeColorPrimary());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ColorChooserPreference accentColor = (ColorChooserPreference) findPreference("accent_color");
|
||||||
|
accentColor.setColor(PreferenceUtils.getInstance(getActivity()).getThemeColorAccent(),
|
||||||
|
DialogUtils.resolveColor(getActivity(), android.R.attr.textColorPrimary));
|
||||||
|
accentColor.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
new ColorChooserDialog().show(getActivity(), preference.getTitleRes(),
|
||||||
|
PreferenceUtils.getInstance(getActivity()).getThemeColorAccent());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -65,7 +113,7 @@ public class SettingsActivity extends AbsBaseActivity {
|
||||||
findPreference("transparent_toolbar").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
findPreference("transparent_toolbar").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object o) {
|
public boolean onPreferenceChange(Preference preference, Object o) {
|
||||||
App.bus.post(new UiPreferenceChangedEvent(UiPreferenceChangedEvent.TOOLBAR_TRANSPARENT_CHANGED, o));
|
App.bus.post(new UIPreferenceChangedEvent(UIPreferenceChangedEvent.TOOLBAR_TRANSPARENT_CHANGED, o));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -73,7 +121,7 @@ public class SettingsActivity extends AbsBaseActivity {
|
||||||
findPreference("colored_album_footers").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
findPreference("colored_album_footers").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object o) {
|
public boolean onPreferenceChange(Preference preference, Object o) {
|
||||||
App.bus.post(new UiPreferenceChangedEvent(UiPreferenceChangedEvent.ALBUM_OVERVIEW_PALETTE_CHANGED, o));
|
App.bus.post(new UIPreferenceChangedEvent(UIPreferenceChangedEvent.ALBUM_OVERVIEW_PALETTE_CHANGED, o));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -81,7 +129,7 @@ public class SettingsActivity extends AbsBaseActivity {
|
||||||
findPreference("colored_navigation_bar_artist").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
findPreference("colored_navigation_bar_artist").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object o) {
|
public boolean onPreferenceChange(Preference preference, Object o) {
|
||||||
App.bus.post(new UiPreferenceChangedEvent(UiPreferenceChangedEvent.COLORED_NAVIGATION_BAR_ARTIST_CHANGED, o));
|
App.bus.post(new UIPreferenceChangedEvent(UIPreferenceChangedEvent.COLORED_NAVIGATION_BAR_ARTIST_CHANGED, o));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -89,7 +137,7 @@ public class SettingsActivity extends AbsBaseActivity {
|
||||||
findPreference("colored_navigation_bar_album").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
findPreference("colored_navigation_bar_album").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object o) {
|
public boolean onPreferenceChange(Preference preference, Object o) {
|
||||||
App.bus.post(new UiPreferenceChangedEvent(UiPreferenceChangedEvent.COLORED_NAVIGATION_BAR_ALBUM_CHANGED, o));
|
App.bus.post(new UIPreferenceChangedEvent(UIPreferenceChangedEvent.COLORED_NAVIGATION_BAR_ALBUM_CHANGED, o));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -97,7 +145,7 @@ public class SettingsActivity extends AbsBaseActivity {
|
||||||
findPreference("playback_controller_card").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
findPreference("playback_controller_card").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object o) {
|
public boolean onPreferenceChange(Preference preference, Object o) {
|
||||||
App.bus.post(new UiPreferenceChangedEvent(UiPreferenceChangedEvent.PLAYBACK_CONTROLLER_CARD_CHANGED, o));
|
App.bus.post(new UIPreferenceChangedEvent(UIPreferenceChangedEvent.PLAYBACK_CONTROLLER_CARD_CHANGED, o));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,26 +3,24 @@ package com.kabouzeid.gramophone.ui.activities.base;
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
|
|
||||||
import com.crashlytics.android.Crashlytics;
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.kabouzeid.gramophone.App;
|
import com.kabouzeid.gramophone.App;
|
||||||
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
|
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
|
||||||
import com.kabouzeid.gramophone.misc.AppKeys;
|
import com.kabouzeid.gramophone.misc.AppKeys;
|
||||||
import com.kabouzeid.gramophone.model.UiPreferenceChangedEvent;
|
import com.kabouzeid.gramophone.model.UIPreferenceChangedEvent;
|
||||||
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
|
||||||
import com.kabouzeid.gramophone.util.Util;
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 20.01.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public abstract class AbsBaseActivity extends ActionBarActivity implements KabViewsDisableAble {
|
public abstract class AbsBaseActivity extends ThemeBaseActivity implements KabViewsDisableAble {
|
||||||
|
|
||||||
private App app;
|
private App app;
|
||||||
private boolean areViewsEnabled;
|
private boolean areViewsEnabled;
|
||||||
private Object uiPreferenceChangeListener = new Object() {
|
private final Object uiPreferenceChangeListener = new Object() {
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onUIPreferenceChangedEvent(UiPreferenceChangedEvent event) {
|
public void onUIPreferenceChangedEvent(UIPreferenceChangedEvent event) {
|
||||||
AbsBaseActivity.this.onUIPreferenceChangedEvent(event);
|
AbsBaseActivity.this.onUIPreferenceChangedEvent(event);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -30,7 +28,6 @@ public abstract class AbsBaseActivity extends ActionBarActivity implements KabVi
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
Crashlytics.setString(AppKeys.CL_CURRENT_ACTIVITY, getTag());
|
Crashlytics.setString(AppKeys.CL_CURRENT_ACTIVITY, getTag());
|
||||||
setTheme(PreferenceUtils.getInstance(this).getGeneralTheme());
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
try {
|
try {
|
||||||
App.bus.register(uiPreferenceChangeListener);
|
App.bus.register(uiPreferenceChangeListener);
|
||||||
|
|
@ -45,7 +42,7 @@ public abstract class AbsBaseActivity extends ActionBarActivity implements KabVi
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String getTag();
|
protected abstract String getTag();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
|
|
@ -53,15 +50,6 @@ public abstract class AbsBaseActivity extends ActionBarActivity implements KabVi
|
||||||
enableViews();
|
enableViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
|
||||||
public void onUIPreferenceChangedEvent(UiPreferenceChangedEvent event) {
|
|
||||||
switch (event.getAction()) {
|
|
||||||
case UiPreferenceChangedEvent.THEME_CHANGED:
|
|
||||||
recreate();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enableViews() {
|
public void enableViews() {
|
||||||
areViewsEnabled = true;
|
areViewsEnabled = true;
|
||||||
|
|
@ -77,14 +65,12 @@ public abstract class AbsBaseActivity extends ActionBarActivity implements KabVi
|
||||||
return areViewsEnabled;
|
return areViewsEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setUpTranslucence(boolean statusBarTranslucent, boolean navigationBarTranslucent) {
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
protected void onUIPreferenceChangedEvent(UIPreferenceChangedEvent event) {
|
||||||
Util.setStatusBarTranslucent(getWindow(), statusBarTranslucent);
|
switch (event.getAction()) {
|
||||||
if (Util.isInPortraitMode(this) || Util.isTablet(this)) {
|
case UIPreferenceChangedEvent.THEME_CHANGED:
|
||||||
Util.setNavBarTranslucent(getWindow(), navigationBarTranslucent);
|
recreate();
|
||||||
} else {
|
break;
|
||||||
Util.setNavBarTranslucent(getWindow(), false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.kabouzeid.gramophone.ui.activities.base;
|
package com.kabouzeid.gramophone.ui.activities.base;
|
||||||
|
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.util.Pair;
|
import android.support.v4.util.Pair;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
@ -8,8 +10,10 @@ import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.ThemeSingleton;
|
||||||
import com.kabouzeid.gramophone.App;
|
import com.kabouzeid.gramophone.App;
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
|
import com.kabouzeid.gramophone.dialogs.ColorChooserDialog;
|
||||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||||
import com.kabouzeid.gramophone.misc.SmallOnGestureListener;
|
import com.kabouzeid.gramophone.misc.SmallOnGestureListener;
|
||||||
import com.kabouzeid.gramophone.model.MusicRemoteEvent;
|
import com.kabouzeid.gramophone.model.MusicRemoteEvent;
|
||||||
|
|
@ -19,14 +23,14 @@ import com.melnykov.fab.FloatingActionButton;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 22.01.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public abstract class AbsFabActivity extends AbsBaseActivity {
|
public abstract class AbsFabActivity extends AbsBaseActivity {
|
||||||
public static final String TAG = AbsFabActivity.class.getSimpleName();
|
public static final String TAG = AbsFabActivity.class.getSimpleName();
|
||||||
|
|
||||||
private FloatingActionButton fab;
|
private FloatingActionButton fab;
|
||||||
private PlayPauseDrawable playPauseDrawable;
|
private PlayPauseDrawable playPauseDrawable;
|
||||||
private Object busEventListener = new Object() {
|
private final Object busEventListener = new Object() {
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onBusEvent(MusicRemoteEvent event) {
|
public void onBusEvent(MusicRemoteEvent event) {
|
||||||
onMusicRemoteEvent(event);
|
onMusicRemoteEvent(event);
|
||||||
|
|
@ -49,6 +53,17 @@ public abstract class AbsFabActivity extends AbsBaseActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
getFab().setImageDrawable(playPauseDrawable);
|
getFab().setImageDrawable(playPauseDrawable);
|
||||||
|
final int accentColor = ThemeSingleton.get().positiveColor;
|
||||||
|
if (accentColor == Color.WHITE) {
|
||||||
|
getFab().setColorNormal(accentColor);
|
||||||
|
getFab().setColorPressed(ColorChooserDialog.shiftColorDown(accentColor));
|
||||||
|
getFab().getDrawable().setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN);
|
||||||
|
} else {
|
||||||
|
getFab().setColorNormal(accentColor);
|
||||||
|
getFab().setColorPressed(ColorChooserDialog.shiftColorUp(accentColor));
|
||||||
|
getFab().getDrawable().clearColorFilter();
|
||||||
|
}
|
||||||
|
|
||||||
updateFabState();
|
updateFabState();
|
||||||
final GestureDetector gestureDetector = new GestureDetector(this, new SmallOnGestureListener() {
|
final GestureDetector gestureDetector = new GestureDetector(this, new SmallOnGestureListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -111,9 +126,7 @@ public abstract class AbsFabActivity extends AbsBaseActivity {
|
||||||
Pair[] sharedViewsWithFab;
|
Pair[] sharedViewsWithFab;
|
||||||
if (sharedViews != null) {
|
if (sharedViews != null) {
|
||||||
sharedViewsWithFab = new Pair[sharedViews.length + 1];
|
sharedViewsWithFab = new Pair[sharedViews.length + 1];
|
||||||
for (int i = 0; i < sharedViews.length; i++) {
|
System.arraycopy(sharedViews, 0, sharedViewsWithFab, 0, sharedViews.length);
|
||||||
sharedViewsWithFab[i] = sharedViews[i];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
sharedViewsWithFab = new Pair[1];
|
sharedViewsWithFab = new Pair[1];
|
||||||
}
|
}
|
||||||
|
|
@ -134,7 +147,7 @@ public abstract class AbsFabActivity extends AbsBaseActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onMusicRemoteEvent(MusicRemoteEvent event) {
|
protected void onMusicRemoteEvent(MusicRemoteEvent event) {
|
||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
case MusicRemoteEvent.PLAY:
|
case MusicRemoteEvent.PLAY:
|
||||||
setFabPause();
|
setFabPause();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,76 @@
|
||||||
|
package com.kabouzeid.gramophone.ui.activities.base;
|
||||||
|
|
||||||
|
import android.app.ActivityManager;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.app.ActionBarActivity;
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.ThemeSingleton;
|
||||||
|
import com.kabouzeid.gramophone.R;
|
||||||
|
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
|
||||||
|
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||||
|
import com.kabouzeid.gramophone.util.Util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Aidan Follestad (afollestad)
|
||||||
|
*/
|
||||||
|
public abstract class ThemeBaseActivity extends ActionBarActivity implements KabViewsDisableAble {
|
||||||
|
|
||||||
|
private boolean mLastDarkTheme;
|
||||||
|
private int mLastPrimary;
|
||||||
|
private int mLastAccent;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
setTheme(PreferenceUtils.getInstance(this).getGeneralTheme());
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setupTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupTheme() {
|
||||||
|
// Persist current values so the Activity knows if they change
|
||||||
|
mLastDarkTheme = PreferenceUtils.getInstance(this).getGeneralTheme() == 1;
|
||||||
|
mLastPrimary = PreferenceUtils.getInstance(this).getThemeColorPrimary();
|
||||||
|
mLastAccent = PreferenceUtils.getInstance(this).getThemeColorAccent();
|
||||||
|
|
||||||
|
// Accent colors in dialogs, and any dynamic views that pull from this singleton
|
||||||
|
ThemeSingleton.get().positiveColor = mLastAccent;
|
||||||
|
ThemeSingleton.get().negativeColor = ThemeSingleton.get().positiveColor;
|
||||||
|
ThemeSingleton.get().neutralColor = ThemeSingleton.get().positiveColor;
|
||||||
|
ThemeSingleton.get().widgetColor = ThemeSingleton.get().positiveColor;
|
||||||
|
// Dark theme
|
||||||
|
ThemeSingleton.get().darkTheme = mLastDarkTheme;
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
// Sets color of entry in the system recents page
|
||||||
|
ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(
|
||||||
|
getString(R.string.app_name),
|
||||||
|
BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher),
|
||||||
|
mLastPrimary);
|
||||||
|
setTaskDescription(td);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
if (mLastDarkTheme != (PreferenceUtils.getInstance(this).getGeneralTheme() == 1) ||
|
||||||
|
mLastPrimary != PreferenceUtils.getInstance(this).getThemeColorPrimary() ||
|
||||||
|
mLastAccent != PreferenceUtils.getInstance(this).getThemeColorAccent()) {
|
||||||
|
// Theme colors changed, recreate the Activity
|
||||||
|
recreate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setUpTranslucence(boolean statusBarTranslucent, boolean navigationBarTranslucent) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||||
|
Util.setStatusBarTranslucent(getWindow(), statusBarTranslucent);
|
||||||
|
if (Util.isInPortraitMode(this) || Util.isTablet(this)) {
|
||||||
|
Util.setNavBarTranslucent(getWindow(), navigationBarTranslucent);
|
||||||
|
} else {
|
||||||
|
Util.setNavBarTranslucent(getWindow(), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -17,6 +17,7 @@ import android.view.animation.OvershootInterpolator;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
|
import com.afollestad.materialdialogs.util.DialogUtils;
|
||||||
import com.github.ksoichiro.android.observablescrollview.ObservableScrollView;
|
import com.github.ksoichiro.android.observablescrollview.ObservableScrollView;
|
||||||
import com.kabouzeid.gramophone.App;
|
import com.kabouzeid.gramophone.App;
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
|
|
@ -49,10 +50,11 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 18.01.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
||||||
public static final String TAG = AbsTagEditorActivity.class.getSimpleName();
|
|
||||||
|
private static final String TAG = AbsTagEditorActivity.class.getSimpleName();
|
||||||
private static final int REQUEST_CODE_SELECT_IMAGE = 1337;
|
private static final int REQUEST_CODE_SELECT_IMAGE = 1337;
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
|
|
@ -65,7 +67,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
||||||
private Toolbar toolBar;
|
private Toolbar toolBar;
|
||||||
private ImageView image;
|
private ImageView image;
|
||||||
private View header;
|
private View header;
|
||||||
private SmallObservableScrollViewCallbacks observableScrollViewCallbacks = new SmallObservableScrollViewCallbacks() {
|
private final SmallObservableScrollViewCallbacks observableScrollViewCallbacks = new SmallObservableScrollViewCallbacks() {
|
||||||
@Override
|
@Override
|
||||||
public void onScrollChanged(int scrollY, boolean b, boolean b2) {
|
public void onScrollChanged(int scrollY, boolean b, boolean b2) {
|
||||||
float alpha;
|
float alpha;
|
||||||
|
|
@ -169,7 +171,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
||||||
|
|
||||||
protected abstract void deleteImage();
|
protected abstract void deleteImage();
|
||||||
|
|
||||||
protected void setUpFab() {
|
private void setUpFab() {
|
||||||
ViewHelper.setScaleX(fab, 0);
|
ViewHelper.setScaleX(fab, 0);
|
||||||
ViewHelper.setScaleY(fab, 0);
|
ViewHelper.setScaleY(fab, 0);
|
||||||
fab.setEnabled(false);
|
fab.setEnabled(false);
|
||||||
|
|
@ -184,7 +186,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
||||||
protected abstract void save();
|
protected abstract void save();
|
||||||
|
|
||||||
private void restoreStandardColors() {
|
private void restoreStandardColors() {
|
||||||
final int vibrantColor = Util.resolveColor(this, R.attr.colorPrimary);
|
final int vibrantColor = DialogUtils.resolveColor(this, R.attr.colorPrimary);
|
||||||
paletteColorPrimary = vibrantColor;
|
paletteColorPrimary = vibrantColor;
|
||||||
observableScrollViewCallbacks.onScrollChanged(scrollView.getCurrentScrollY(), false, false);
|
observableScrollViewCallbacks.onScrollChanged(scrollView.getCurrentScrollY(), false, false);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
|
@ -200,7 +202,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setUpToolBar() {
|
private void setUpToolBar() {
|
||||||
setSupportActionBar(toolBar);
|
setSupportActionBar(toolBar);
|
||||||
getSupportActionBar().setTitle(getResources().getString(R.string.tag_editor));
|
getSupportActionBar().setTitle(getResources().getString(R.string.tag_editor));
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
@ -271,7 +273,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
||||||
Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() {
|
Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onGenerated(Palette palette) {
|
public void onGenerated(Palette palette) {
|
||||||
final int vibrantColor = palette.getVibrantColor(Util.resolveColor(AbsTagEditorActivity.this, R.attr.default_bar_color));
|
final int vibrantColor = palette.getVibrantColor(DialogUtils.resolveColor(AbsTagEditorActivity.this, R.attr.default_bar_color));
|
||||||
paletteColorPrimary = vibrantColor;
|
paletteColorPrimary = vibrantColor;
|
||||||
observableScrollViewCallbacks.onScrollChanged(scrollView.getCurrentScrollY(), false, false);
|
observableScrollViewCallbacks.onScrollChanged(scrollView.getCurrentScrollY(), false, false);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ import java.util.Map;
|
||||||
public class AlbumTagEditorActivity extends AbsTagEditorActivity implements TextWatcher {
|
public class AlbumTagEditorActivity extends AbsTagEditorActivity implements TextWatcher {
|
||||||
public static final String TAG = AlbumTagEditorActivity.class.getSimpleName();
|
public static final String TAG = AlbumTagEditorActivity.class.getSimpleName();
|
||||||
|
|
||||||
private File albumArtFile;
|
|
||||||
private Bitmap albumArtBitmap;
|
private Bitmap albumArtBitmap;
|
||||||
private boolean deleteAlbumArt;
|
private boolean deleteAlbumArt;
|
||||||
|
|
||||||
|
|
@ -150,13 +149,9 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text
|
||||||
fieldKeyValueMap.put(FieldKey.GENRE, genreName.getText().toString());
|
fieldKeyValueMap.put(FieldKey.GENRE, genreName.getText().toString());
|
||||||
fieldKeyValueMap.put(FieldKey.YEAR, year.getText().toString());
|
fieldKeyValueMap.put(FieldKey.YEAR, year.getText().toString());
|
||||||
|
|
||||||
try {
|
File albumArtFile = MusicUtil.getAlbumArtFile(String.valueOf(getId()));
|
||||||
albumArtFile = MusicUtil.getAlbumArtFile(this, String.valueOf(getId()));
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.e(TAG, "error while creating albumArtFile", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (albumArtBitmap != null && albumArtFile != null) {
|
if (albumArtBitmap != null) {
|
||||||
try {
|
try {
|
||||||
albumArtBitmap.compress(Bitmap.CompressFormat.PNG, 0, new FileOutputStream(albumArtFile));
|
albumArtBitmap.compress(Bitmap.CompressFormat.PNG, 0, new FileOutputStream(albumArtFile));
|
||||||
artwork = ArtworkFactory.createArtworkFromFile(albumArtFile);
|
artwork = ArtworkFactory.createArtworkFromFile(albumArtFile);
|
||||||
|
|
|
||||||
|
|
@ -7,34 +7,34 @@ import android.os.Handler;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.view.GravityCompat;
|
import android.support.v4.view.GravityCompat;
|
||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.App;
|
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.adapter.NavigationDrawerItemAdapter;
|
import com.kabouzeid.gramophone.adapter.NavigationDrawerItemAdapter;
|
||||||
import com.kabouzeid.gramophone.misc.AppKeys;
|
import com.kabouzeid.gramophone.misc.AppKeys;
|
||||||
import com.kabouzeid.gramophone.model.NavigationDrawerItem;
|
import com.kabouzeid.gramophone.model.NavigationDrawerItem;
|
||||||
import com.nhaarman.listviewanimations.appearance.simple.AlphaInAnimationAdapter;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class NavigationDrawerFragment extends Fragment {
|
public class NavigationDrawerFragment extends Fragment {
|
||||||
|
|
||||||
public static final int NAVIGATION_DRAWER_HEADER = -1;
|
public static final int NAVIGATION_DRAWER_HEADER = -1;
|
||||||
private static final String TAG = NavigationDrawerFragment.class.getSimpleName();
|
public static final int ABOUT_INDEX = 4;
|
||||||
|
public static final int SETTINGS_INDEX = 5;
|
||||||
private static final String STATE_SELECTED_POSITION = "selected_navigation_drawer_position";
|
private static final String STATE_SELECTED_POSITION = "selected_navigation_drawer_position";
|
||||||
|
|
||||||
public View fragmentRootView;
|
public View fragmentRootView;
|
||||||
private App app;
|
|
||||||
private NavigationDrawerCallbacks callbacks;
|
private NavigationDrawerCallbacks callbacks;
|
||||||
private NavigationDrawerItemAdapter drawerAdapter;
|
private NavigationDrawerItemAdapter drawerAdapter;
|
||||||
private DrawerLayout drawerLayout;
|
private DrawerLayout drawerLayout;
|
||||||
private ListView drawerListView;
|
private RecyclerView drawerRecyclerView;
|
||||||
private View fragmentContainerView;
|
private View fragmentContainerView;
|
||||||
|
|
||||||
private Button headerButton;
|
private Button headerButton;
|
||||||
|
|
@ -91,7 +91,6 @@ public class NavigationDrawerFragment extends Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
app = (App) getActivity().getApplicationContext();
|
|
||||||
userLearnedDrawer = PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean(AppKeys.SP_USER_LEARNED_DRAWER, false);
|
userLearnedDrawer = PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean(AppKeys.SP_USER_LEARNED_DRAWER, false);
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
setItemChecked(savedInstanceState.getInt(STATE_SELECTED_POSITION));
|
setItemChecked(savedInstanceState.getInt(STATE_SELECTED_POSITION));
|
||||||
|
|
@ -101,8 +100,7 @@ public class NavigationDrawerFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
Bundle savedInstanceState) {
|
|
||||||
return inflater.inflate(R.layout.fragment_navigation_drawer, container, false);
|
return inflater.inflate(R.layout.fragment_navigation_drawer, container, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -115,7 +113,7 @@ public class NavigationDrawerFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initViews() {
|
private void initViews() {
|
||||||
drawerListView = (ListView) fragmentRootView.findViewById(R.id.navigation_drawer_list);
|
drawerRecyclerView = (RecyclerView) fragmentRootView.findViewById(R.id.navigation_drawer_list);
|
||||||
final View drawerHeader = fragmentRootView.findViewById(R.id.header);
|
final View drawerHeader = fragmentRootView.findViewById(R.id.header);
|
||||||
headerButton = (Button) drawerHeader.findViewById(R.id.header_clickable);
|
headerButton = (Button) drawerHeader.findViewById(R.id.header_clickable);
|
||||||
albumArt = (ImageView) drawerHeader.findViewById(R.id.album_art);
|
albumArt = (ImageView) drawerHeader.findViewById(R.id.album_art);
|
||||||
|
|
@ -139,23 +137,22 @@ public class NavigationDrawerFragment extends Fragment {
|
||||||
navigationDrawerItems.add(new NavigationDrawerItem(getString(R.string.albums), R.drawable.ic_album_white_24dp));
|
navigationDrawerItems.add(new NavigationDrawerItem(getString(R.string.albums), R.drawable.ic_album_white_24dp));
|
||||||
navigationDrawerItems.add(new NavigationDrawerItem(getString(R.string.artists), R.drawable.ic_person_white_24dp));
|
navigationDrawerItems.add(new NavigationDrawerItem(getString(R.string.artists), R.drawable.ic_person_white_24dp));
|
||||||
navigationDrawerItems.add(new NavigationDrawerItem(getString(R.string.playlists), R.drawable.ic_queue_music_white_24dp));
|
navigationDrawerItems.add(new NavigationDrawerItem(getString(R.string.playlists), R.drawable.ic_queue_music_white_24dp));
|
||||||
|
navigationDrawerItems.add(new NavigationDrawerItem(getString(R.string.action_about), R.drawable.ic_drawer_about));
|
||||||
|
navigationDrawerItems.add(new NavigationDrawerItem(getString(R.string.action_settings), R.drawable.ic_drawer_settings));
|
||||||
|
|
||||||
drawerAdapter = new NavigationDrawerItemAdapter(getActivity(), R.id.navigation_drawer, navigationDrawerItems);
|
drawerAdapter = new NavigationDrawerItemAdapter(getActivity(), navigationDrawerItems, new NavigationDrawerItemAdapter.Callback() {
|
||||||
|
|
||||||
final AlphaInAnimationAdapter animationAdapter = new AlphaInAnimationAdapter(drawerAdapter);
|
|
||||||
animationAdapter.setAbsListView(drawerListView);
|
|
||||||
|
|
||||||
drawerListView.setAdapter(animationAdapter);
|
|
||||||
drawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(int index) {
|
||||||
selectItem(position);
|
selectItem(index);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
drawerRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||||
|
drawerRecyclerView.setAdapter(drawerAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectItem(final int position) {
|
private void selectItem(final int position) {
|
||||||
if (position != NAVIGATION_DRAWER_HEADER) {
|
if (position != NAVIGATION_DRAWER_HEADER &&
|
||||||
|
position != ABOUT_INDEX && position != SETTINGS_INDEX) {
|
||||||
setItemChecked(position);
|
setItemChecked(position);
|
||||||
if (drawerLayout != null) {
|
if (drawerLayout != null) {
|
||||||
new Handler().postDelayed(new Runnable() {
|
new Handler().postDelayed(new Runnable() {
|
||||||
|
|
@ -165,11 +162,9 @@ public class NavigationDrawerFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}, 400);
|
}, 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (callbacks != null) {
|
if (callbacks != null)
|
||||||
callbacks.onNavigationDrawerItemSelected(position);
|
callbacks.onNavigationDrawerItemSelected(position);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -191,7 +186,7 @@ public class NavigationDrawerFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static interface NavigationDrawerCallbacks {
|
public interface NavigationDrawerCallbacks {
|
||||||
void onNavigationDrawerItemSelected(int position);
|
void onNavigationDrawerItemSelected(int position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import com.kabouzeid.gramophone.ui.activities.MainActivity;
|
||||||
import com.kabouzeid.gramophone.util.Util;
|
import com.kabouzeid.gramophone.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 27.02.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public abstract class AbsMainActivityFragment extends Fragment implements KabViewsDisableAble {
|
public abstract class AbsMainActivityFragment extends Fragment implements KabViewsDisableAble {
|
||||||
private boolean areViewsEnabled;
|
private boolean areViewsEnabled;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import android.view.ViewGroup;
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 30.03.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public abstract class AbsMainActivityRecyclerViewFragment extends AbsMainActivityFragment {
|
public abstract class AbsMainActivityRecyclerViewFragment extends AbsMainActivityFragment {
|
||||||
public static final String TAG = AbsMainActivityRecyclerViewFragment.class.getSimpleName();
|
public static final String TAG = AbsMainActivityRecyclerViewFragment.class.getSimpleName();
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package com.kabouzeid.gramophone.ui.fragments.mainactivityfragments;
|
||||||
|
|
||||||
import android.support.v7.widget.GridLayoutManager;
|
import android.support.v7.widget.GridLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.adapter.AlbumAdapter;
|
import com.kabouzeid.gramophone.adapter.AlbumAdapter;
|
||||||
|
|
@ -10,7 +9,7 @@ import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||||
import com.kabouzeid.gramophone.util.Util;
|
import com.kabouzeid.gramophone.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 22.11.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class AlbumViewFragment extends AbsMainActivityRecyclerViewFragment {
|
public class AlbumViewFragment extends AbsMainActivityRecyclerViewFragment {
|
||||||
public static final String TAG = AlbumViewFragment.class.getSimpleName();
|
public static final String TAG = AlbumViewFragment.class.getSimpleName();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.kabouzeid.gramophone.ui.fragments.mainactivityfragments;
|
package com.kabouzeid.gramophone.ui.fragments.mainactivityfragments;
|
||||||
|
|
||||||
|
|
||||||
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.support.v7.widget.GridLayoutManager;
|
import android.support.v7.widget.GridLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
|
||||||
|
|
@ -8,6 +9,7 @@ import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.adapter.PlaylistAdapter;
|
import com.kabouzeid.gramophone.adapter.PlaylistAdapter;
|
||||||
|
|
||||||
public class PlaylistViewFragment extends AbsMainActivityRecyclerViewFragment {
|
public class PlaylistViewFragment extends AbsMainActivityRecyclerViewFragment {
|
||||||
|
|
||||||
public static final String TAG = PlaylistViewFragment.class.getSimpleName();
|
public static final String TAG = PlaylistViewFragment.class.getSimpleName();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -22,6 +24,6 @@ public class PlaylistViewFragment extends AbsMainActivityRecyclerViewFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected RecyclerView.Adapter createAdapter() {
|
protected RecyclerView.Adapter createAdapter() {
|
||||||
return new PlaylistAdapter(getActivity());
|
return new PlaylistAdapter((ActionBarActivity) getActivity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.kabouzeid.gramophone.ui.fragments.mainactivityfragments;
|
package com.kabouzeid.gramophone.ui.fragments.mainactivityfragments;
|
||||||
|
|
||||||
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.support.v7.widget.GridLayoutManager;
|
import android.support.v7.widget.GridLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
|
||||||
|
|
@ -7,9 +8,10 @@ import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.adapter.songadapter.SongAdapter;
|
import com.kabouzeid.gramophone.adapter.songadapter.SongAdapter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 29.12.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class SongViewFragment extends AbsMainActivityRecyclerViewFragment {
|
public class SongViewFragment extends AbsMainActivityRecyclerViewFragment {
|
||||||
|
|
||||||
public static final String TAG = SongViewFragment.class.getSimpleName();
|
public static final String TAG = SongViewFragment.class.getSimpleName();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -24,6 +26,6 @@ public class SongViewFragment extends AbsMainActivityRecyclerViewFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected RecyclerView.Adapter createAdapter() {
|
protected RecyclerView.Adapter createAdapter() {
|
||||||
return new SongAdapter(getActivity());
|
return new SongAdapter((ActionBarActivity) getActivity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ import android.graphics.Paint;
|
||||||
import android.graphics.Path;
|
import android.graphics.Path;
|
||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.util.Property;
|
import android.util.Property;
|
||||||
import android.view.animation.DecelerateInterpolator;
|
import android.view.animation.DecelerateInterpolator;
|
||||||
|
|
@ -45,8 +44,8 @@ public class PlayPauseDrawable extends Drawable {
|
||||||
|
|
||||||
private float width;
|
private float width;
|
||||||
private float height;
|
private float height;
|
||||||
private float fallBackWidth;
|
private final float fallBackWidth;
|
||||||
private float fallBackHeight;
|
private final float fallBackHeight;
|
||||||
|
|
||||||
private float progress;
|
private float progress;
|
||||||
private boolean isPlay;
|
private boolean isPlay;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import android.util.AttributeSet;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 22.11.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class SquareImageView extends ImageView {
|
public class SquareImageView extends ImageView {
|
||||||
|
|
||||||
|
|
@ -23,6 +23,7 @@ public class SquareImageView extends ImageView {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
//noinspection SuspiciousNameCombination
|
||||||
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
|
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package com.kabouzeid.gramophone.util;
|
package com.kabouzeid.gramophone.util;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
|
@ -11,24 +10,19 @@ import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 22.12.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public final class InternalStorageUtil {
|
public final class InternalStorageUtil {
|
||||||
private static final String TAG = InternalStorageUtil.class.getSimpleName();
|
|
||||||
|
|
||||||
public static synchronized void writeObject(final Context context, final String key, final Object object) throws IOException {
|
public static synchronized void writeObject(final Context context, final String key, final Object object) throws IOException {
|
||||||
try {
|
String tempFileName = "TEMP_" + key;
|
||||||
String tempFileName = "TEMP_" + key;
|
FileOutputStream fos;
|
||||||
FileOutputStream fos;
|
fos = context.openFileOutput(tempFileName, Context.MODE_PRIVATE);
|
||||||
fos = context.openFileOutput(tempFileName, Context.MODE_PRIVATE);
|
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||||
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
oos.writeObject(object);
|
||||||
oos.writeObject(object);
|
oos.close();
|
||||||
oos.close();
|
fos.close();
|
||||||
fos.close();
|
renameAppFile(context, tempFileName, key);
|
||||||
renameAppFile(context, tempFileName, key);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.e(TAG, "Writing Object to internal storage failed! Maybe the Object is not serializable?", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void renameAppFile(final Context context, String originalFileName, String newFileName) {
|
public static synchronized void renameAppFile(final Context context, String originalFileName, String newFileName) {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 29.12.14.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class MusicUtil {
|
public class MusicUtil {
|
||||||
public static final String TAG = MusicUtil.class.getSimpleName();
|
public static final String TAG = MusicUtil.class.getSimpleName();
|
||||||
|
|
@ -78,12 +78,11 @@ public class MusicUtil {
|
||||||
contentResolver.delete(ContentUris.withAppendedId(localUri, albumId), null, null);
|
contentResolver.delete(ContentUris.withAppendedId(localUri, albumId), null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File getAlbumArtFile(Context context, String name)
|
public static File getAlbumArtFile(String name) {
|
||||||
throws IOException {
|
return new File(createAlbumArtDir(), name + System.currentTimeMillis());
|
||||||
return new File(createAlbumArtDir(context), name + System.currentTimeMillis());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File createAlbumArtDir(Context paramContext) {
|
public static File createAlbumArtDir() {
|
||||||
File albumArtDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "/.albumart/");
|
File albumArtDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "/.albumart/");
|
||||||
if (!albumArtDir.exists()) {
|
if (!albumArtDir.exists()) {
|
||||||
albumArtDir.mkdirs();
|
albumArtDir.mkdirs();
|
||||||
|
|
@ -141,7 +140,7 @@ public class MusicUtil {
|
||||||
cursor.moveToNext();
|
cursor.moveToNext();
|
||||||
} catch (final SecurityException ex) {
|
} catch (final SecurityException ex) {
|
||||||
cursor.moveToNext();
|
cursor.moveToNext();
|
||||||
} catch (NullPointerException e){
|
} catch (NullPointerException e) {
|
||||||
Log.e("MusicUtils", "Failed to find file " + name);
|
Log.e("MusicUtils", "Failed to find file " + name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,12 @@ import android.media.audiofx.AudioEffect;
|
||||||
import android.support.v4.app.ActivityCompat;
|
import android.support.v4.app.ActivityCompat;
|
||||||
import android.support.v4.app.ActivityOptionsCompat;
|
import android.support.v4.app.ActivityOptionsCompat;
|
||||||
import android.support.v4.util.Pair;
|
import android.support.v4.util.Pair;
|
||||||
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
|
import com.kabouzeid.gramophone.dialogs.PlayingQueueDialog;
|
||||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||||
import com.kabouzeid.gramophone.helper.PlayingQueueDialogHelper;
|
|
||||||
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
|
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
|
||||||
import com.kabouzeid.gramophone.misc.AppKeys;
|
import com.kabouzeid.gramophone.misc.AppKeys;
|
||||||
import com.kabouzeid.gramophone.ui.activities.AlbumDetailActivity;
|
import com.kabouzeid.gramophone.ui.activities.AlbumDetailActivity;
|
||||||
|
|
@ -21,7 +21,7 @@ import com.kabouzeid.gramophone.ui.activities.MusicControllerActivity;
|
||||||
import com.kabouzeid.gramophone.ui.activities.PlaylistDetailActivity;
|
import com.kabouzeid.gramophone.ui.activities.PlaylistDetailActivity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 12.03.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class NavigationUtil {
|
public class NavigationUtil {
|
||||||
public static void goToArtist(final Activity activity, final int artistId, final Pair[] sharedViews) {
|
public static void goToArtist(final Activity activity, final int artistId, final Pair[] sharedViews) {
|
||||||
|
|
@ -34,7 +34,7 @@ public class NavigationUtil {
|
||||||
final Intent intent = new Intent(activity, ArtistDetailActivity.class);
|
final Intent intent = new Intent(activity, ArtistDetailActivity.class);
|
||||||
intent.putExtra(AppKeys.E_ARTIST, artistId);
|
intent.putExtra(AppKeys.E_ARTIST, artistId);
|
||||||
if (sharedViews != null) {
|
if (sharedViews != null) {
|
||||||
ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(activity,
|
@SuppressWarnings("unchecked") ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(activity,
|
||||||
sharedViews
|
sharedViews
|
||||||
);
|
);
|
||||||
ActivityCompat.startActivity(activity, intent, optionsCompat.toBundle());
|
ActivityCompat.startActivity(activity, intent, optionsCompat.toBundle());
|
||||||
|
|
@ -54,7 +54,7 @@ public class NavigationUtil {
|
||||||
final Intent intent = new Intent(activity, AlbumDetailActivity.class);
|
final Intent intent = new Intent(activity, AlbumDetailActivity.class);
|
||||||
intent.putExtra(AppKeys.E_ALBUM, albumId);
|
intent.putExtra(AppKeys.E_ALBUM, albumId);
|
||||||
if (sharedViews != null) {
|
if (sharedViews != null) {
|
||||||
ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(activity,
|
@SuppressWarnings("unchecked") ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(activity,
|
||||||
sharedViews
|
sharedViews
|
||||||
);
|
);
|
||||||
ActivityCompat.startActivity(activity, intent, optionsCompat.toBundle());
|
ActivityCompat.startActivity(activity, intent, optionsCompat.toBundle());
|
||||||
|
|
@ -71,7 +71,7 @@ public class NavigationUtil {
|
||||||
final Intent intent = new Intent(activity, PlaylistDetailActivity.class);
|
final Intent intent = new Intent(activity, PlaylistDetailActivity.class);
|
||||||
intent.putExtra(AppKeys.E_PLAYLIST, playlistId);
|
intent.putExtra(AppKeys.E_PLAYLIST, playlistId);
|
||||||
if (sharedViews != null) {
|
if (sharedViews != null) {
|
||||||
ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(activity,
|
@SuppressWarnings("unchecked") ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(activity,
|
||||||
sharedViews
|
sharedViews
|
||||||
);
|
);
|
||||||
ActivityCompat.startActivity(activity, intent, optionsCompat.toBundle());
|
ActivityCompat.startActivity(activity, intent, optionsCompat.toBundle());
|
||||||
|
|
@ -92,7 +92,7 @@ public class NavigationUtil {
|
||||||
((KabViewsDisableAble) activity).disableViews();
|
((KabViewsDisableAble) activity).disableViews();
|
||||||
Intent intent = new Intent(activity, MusicControllerActivity.class);
|
Intent intent = new Intent(activity, MusicControllerActivity.class);
|
||||||
if (sharedViews != null) {
|
if (sharedViews != null) {
|
||||||
ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(activity,
|
@SuppressWarnings("unchecked") ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(activity,
|
||||||
sharedViews
|
sharedViews
|
||||||
);
|
);
|
||||||
ActivityCompat.startActivity(activity, intent, optionsCompat.toBundle());
|
ActivityCompat.startActivity(activity, intent, optionsCompat.toBundle());
|
||||||
|
|
@ -105,10 +105,10 @@ public class NavigationUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openPlayingQueueDialog(final Activity activity) {
|
public static void openPlayingQueueDialog(final ActionBarActivity activity) {
|
||||||
final MaterialDialog materialDialog = PlayingQueueDialogHelper.getDialog(activity);
|
PlayingQueueDialog dialog = PlayingQueueDialog.create();
|
||||||
if (materialDialog != null) {
|
if (dialog != null) {
|
||||||
materialDialog.show();
|
dialog.show(activity.getSupportFragmentManager(), "PLAY_QUEUE");
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(activity, activity.getResources().getString(R.string.nothing_playing), Toast.LENGTH_SHORT).show();
|
Toast.makeText(activity, activity.getResources().getString(R.string.nothing_playing), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by karim on 16.03.15.
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class PlaylistsUtil {
|
public class PlaylistsUtil {
|
||||||
public static final String MUSIC_ONLY_SELECTION = MediaStore.Audio.AudioColumns.IS_MUSIC + "=1"
|
public static final String MUSIC_ONLY_SELECTION = MediaStore.Audio.AudioColumns.IS_MUSIC + "=1"
|
||||||
|
|
@ -57,7 +57,7 @@ public class PlaylistsUtil {
|
||||||
context.getContentResolver().delete(uri, null, null);
|
context.getContentResolver().delete(uri, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deletePlaylist(final Context context, final int playlistId) {
|
public static void deletePlaylist(final Context context, final long playlistId) {
|
||||||
final Uri uri = MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI;
|
final Uri uri = MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI;
|
||||||
String where = MediaStore.Audio.Playlists._ID + "=?";
|
String where = MediaStore.Audio.Playlists._ID + "=?";
|
||||||
String[] whereVal = {String.valueOf(playlistId)};
|
String[] whereVal = {String.valueOf(playlistId)};
|
||||||
|
|
@ -147,7 +147,6 @@ public class PlaylistsUtil {
|
||||||
Cursor c = context.getContentResolver().query(
|
Cursor c = context.getContentResolver().query(
|
||||||
MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId),
|
MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId),
|
||||||
new String[]{BaseColumns._ID}, MUSIC_ONLY_SELECTION, null, null);
|
new String[]{BaseColumns._ID}, MUSIC_ONLY_SELECTION, null, null);
|
||||||
|
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
if (c.moveToFirst()) {
|
if (c.moveToFirst()) {
|
||||||
|
|
@ -156,7 +155,6 @@ public class PlaylistsUtil {
|
||||||
c.close();
|
c.close();
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -165,7 +163,7 @@ public class PlaylistsUtil {
|
||||||
playlistId, from, to);
|
playlistId, from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void renamePlaylist(final Context context, final int id, final String newName) {
|
public static void renamePlaylist(final Context context, final long id, final String newName) {
|
||||||
ContentValues contentValues = new ContentValues();
|
ContentValues contentValues = new ContentValues();
|
||||||
contentValues.put(MediaStore.Audio.PlaylistsColumns.NAME, newName);
|
contentValues.put(MediaStore.Audio.PlaylistsColumns.NAME, newName);
|
||||||
context.getContentResolver().update(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
|
context.getContentResolver().update(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
|
||||||
|
|
@ -175,7 +173,7 @@ public class PlaylistsUtil {
|
||||||
App.bus.post(new DataBaseChangedEvent(DataBaseChangedEvent.PLAYLISTS_CHANGED));
|
App.bus.post(new DataBaseChangedEvent(DataBaseChangedEvent.PLAYLISTS_CHANGED));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getNameForPlaylist(final Context context, final int id) {
|
public static String getNameForPlaylist(final Context context, final long id) {
|
||||||
Cursor cursor = context.getContentResolver().query(
|
Cursor cursor = context.getContentResolver().query(
|
||||||
MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
|
MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
|
||||||
new String[]{MediaStore.Audio.PlaylistsColumns.NAME},
|
new String[]{MediaStore.Audio.PlaylistsColumns.NAME},
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
package com.kabouzeid.gramophone.util;
|
package com.kabouzeid.gramophone.util;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
|
import com.kabouzeid.gramophone.dialogs.ColorChooserDialog;
|
||||||
|
|
||||||
public final class PreferenceUtils {
|
public final class PreferenceUtils {
|
||||||
|
|
||||||
|
|
@ -19,7 +21,7 @@ public final class PreferenceUtils {
|
||||||
public static final String ALBUM_SONG_SORT_ORDER = "album_song_sort_order";
|
public static final String ALBUM_SONG_SORT_ORDER = "album_song_sort_order";
|
||||||
public static final String SONG_SORT_ORDER = "song_sort_order";
|
public static final String SONG_SORT_ORDER = "song_sort_order";
|
||||||
public static final String ONLY_ON_WIFI = "auto_download_artist_images";
|
public static final String ONLY_ON_WIFI = "auto_download_artist_images";
|
||||||
public static final String DOWNLOAD_MISSING_ARTIST_IMAGES = "auto_download_artist_images";
|
// public static final String DOWNLOAD_MISSING_ARTIST_IMAGES = "auto_download_artist_images";
|
||||||
public static final String COLORED_ALBUM_FOOTERS = "colored_album_footers";
|
public static final String COLORED_ALBUM_FOOTERS = "colored_album_footers";
|
||||||
public static final String COLORED_NAVIGATION_BAR_ALBUM = "colored_navigation_bar_album";
|
public static final String COLORED_NAVIGATION_BAR_ALBUM = "colored_navigation_bar_album";
|
||||||
public static final String COLORED_NAVIGATION_BAR_ARTIST = "colored_navigation_bar_artist";
|
public static final String COLORED_NAVIGATION_BAR_ARTIST = "colored_navigation_bar_artist";
|
||||||
|
|
@ -31,13 +33,15 @@ public final class PreferenceUtils {
|
||||||
|
|
||||||
private static PreferenceUtils sInstance;
|
private static PreferenceUtils sInstance;
|
||||||
|
|
||||||
|
private final Context mContext;
|
||||||
private final SharedPreferences mPreferences;
|
private final SharedPreferences mPreferences;
|
||||||
|
|
||||||
public PreferenceUtils(final Context context) {
|
public PreferenceUtils(final Context context) {
|
||||||
|
mContext = context;
|
||||||
mPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
mPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final PreferenceUtils getInstance(final Context context) {
|
public static PreferenceUtils getInstance(final Context context) {
|
||||||
if (sInstance == null) {
|
if (sInstance == null) {
|
||||||
sInstance = new PreferenceUtils(context.getApplicationContext());
|
sInstance = new PreferenceUtils(context.getApplicationContext());
|
||||||
}
|
}
|
||||||
|
|
@ -55,30 +59,52 @@ public final class PreferenceUtils {
|
||||||
return R.style.Theme_MaterialMusic_Light;
|
return R.style.Theme_MaterialMusic_Light;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGeneralTheme(int appTheme) {
|
public int getThemeColorPrimary() {
|
||||||
int value = -1;
|
return mPreferences.getInt("primary_color", mContext.getResources().getColor(R.color.indigo_500));
|
||||||
switch (appTheme) {
|
|
||||||
case R.style.Theme_MaterialMusic_Light:
|
|
||||||
value = 0;
|
|
||||||
break;
|
|
||||||
case R.style.Theme_MaterialMusic:
|
|
||||||
value = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (value != 0 && value != 1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putString(GENERAL_THEME, String.valueOf(value));
|
|
||||||
editor.apply();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultStartPage(final int value) {
|
public int getThemeColorPrimaryDarker() {
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
return ColorChooserDialog.shiftColorDown(getThemeColorPrimary());
|
||||||
editor.putString(DEFAULT_START_PAGE, String.valueOf(value));
|
|
||||||
editor.apply();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("CommitPrefEdits")
|
||||||
|
public void setThemeColorPrimary(int color) {
|
||||||
|
mPreferences.edit().putInt("primary_color", color).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getThemeColorAccent() {
|
||||||
|
return mPreferences.getInt("accent_color", mContext.getResources().getColor(R.color.pink_500));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("CommitPrefEdits")
|
||||||
|
public void setThemeColorAccent(int color) {
|
||||||
|
mPreferences.edit().putInt("accent_color", color).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// public void setGeneralTheme(int appTheme) {
|
||||||
|
// int value = -1;
|
||||||
|
// switch (appTheme) {
|
||||||
|
// case R.style.Theme_MaterialMusic_Light:
|
||||||
|
// value = 0;
|
||||||
|
// break;
|
||||||
|
// case R.style.Theme_MaterialMusic:
|
||||||
|
// value = 1;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// if (value != 0 && value != 1) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// final SharedPreferences.Editor editor = mPreferences.edit();
|
||||||
|
// editor.putString(GENERAL_THEME, String.valueOf(value));
|
||||||
|
// editor.apply();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void setDefaultStartPage(final int value) {
|
||||||
|
// final SharedPreferences.Editor editor = mPreferences.edit();
|
||||||
|
// editor.putString(DEFAULT_START_PAGE, String.valueOf(value));
|
||||||
|
// editor.apply();
|
||||||
|
// }
|
||||||
|
|
||||||
public final int getDefaultStartPage() {
|
public final int getDefaultStartPage() {
|
||||||
return Integer.parseInt(mPreferences.getString(DEFAULT_START_PAGE, "-1"));
|
return Integer.parseInt(mPreferences.getString(DEFAULT_START_PAGE, "-1"));
|
||||||
}
|
}
|
||||||
|
|
@ -97,81 +123,81 @@ public final class PreferenceUtils {
|
||||||
return mPreferences.getBoolean(ONLY_ON_WIFI, false);
|
return mPreferences.getBoolean(ONLY_ON_WIFI, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAutoDownloadOnlyOnWifi(final boolean value) {
|
// public void setAutoDownloadOnlyOnWifi(final boolean value) {
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
// final SharedPreferences.Editor editor = mPreferences.edit();
|
||||||
editor.putBoolean(ONLY_ON_WIFI, value);
|
// editor.putBoolean(ONLY_ON_WIFI, value);
|
||||||
editor.apply();
|
// editor.apply();
|
||||||
}
|
// }
|
||||||
|
|
||||||
public final boolean coloredAlbumFootersEnabled() {
|
public final boolean coloredAlbumFootersEnabled() {
|
||||||
return mPreferences.getBoolean(COLORED_ALBUM_FOOTERS, true);
|
return mPreferences.getBoolean(COLORED_ALBUM_FOOTERS, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColoredAlbumFootersEnabled(final boolean value) {
|
// public void setColoredAlbumFootersEnabled(final boolean value) {
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
// final SharedPreferences.Editor editor = mPreferences.edit();
|
||||||
editor.putBoolean(COLORED_ALBUM_FOOTERS, value);
|
// editor.putBoolean(COLORED_ALBUM_FOOTERS, value);
|
||||||
editor.apply();
|
// editor.apply();
|
||||||
}
|
// }
|
||||||
|
|
||||||
public final boolean coloredNavigationBarAlbumEnabled() {
|
public final boolean coloredNavigationBarAlbumEnabled() {
|
||||||
return mPreferences.getBoolean(COLORED_NAVIGATION_BAR_ALBUM, true);
|
return mPreferences.getBoolean(COLORED_NAVIGATION_BAR_ALBUM, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColoredNavigationBarAlbumEnabled(final boolean value) {
|
/*public void setColoredNavigationBarAlbumEnabled(final boolean value) {
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||||
editor.putBoolean(COLORED_NAVIGATION_BAR_ALBUM, value);
|
editor.putBoolean(COLORED_NAVIGATION_BAR_ALBUM, value);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public final boolean coloredNavigationBarArtistEnabled() {
|
public final boolean coloredNavigationBarArtistEnabled() {
|
||||||
return mPreferences.getBoolean(COLORED_NAVIGATION_BAR_ARTIST, true);
|
return mPreferences.getBoolean(COLORED_NAVIGATION_BAR_ARTIST, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColoredNavigationBarArtistEnabled(final boolean value) {
|
// public void setColoredNavigationBarArtistEnabled(final boolean value) {
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
// final SharedPreferences.Editor editor = mPreferences.edit();
|
||||||
editor.putBoolean(COLORED_NAVIGATION_BAR_ARTIST, value);
|
// editor.putBoolean(COLORED_NAVIGATION_BAR_ARTIST, value);
|
||||||
editor.apply();
|
// editor.apply();
|
||||||
}
|
// }
|
||||||
|
|
||||||
public final boolean coloredNavigationBarCurrentPlayingEnabled() {
|
public final boolean coloredNavigationBarCurrentPlayingEnabled() {
|
||||||
return mPreferences.getBoolean(COLORED_NAVIGATION_BAR_CURRENT_PLAYING, true);
|
return mPreferences.getBoolean(COLORED_NAVIGATION_BAR_CURRENT_PLAYING, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColoredNavigationBarCurrentPlayingEnabled(final boolean value) {
|
// public void setColoredNavigationBarCurrentPlayingEnabled(final boolean value) {
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
// final SharedPreferences.Editor editor = mPreferences.edit();
|
||||||
editor.putBoolean(COLORED_NAVIGATION_BAR_CURRENT_PLAYING, value);
|
// editor.putBoolean(COLORED_NAVIGATION_BAR_CURRENT_PLAYING, value);
|
||||||
editor.apply();
|
// editor.apply();
|
||||||
}
|
// }
|
||||||
|
|
||||||
public final boolean playbackControllerBoxEnabled() {
|
public final boolean playbackControllerBoxEnabled() {
|
||||||
return mPreferences.getBoolean(PLAYBACK_CONTROLLER_BOX, false);
|
return mPreferences.getBoolean(PLAYBACK_CONTROLLER_BOX, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlaybackControllerBoxEnabled(final boolean value) {
|
// public void setPlaybackControllerBoxEnabled(final boolean value) {
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
// final SharedPreferences.Editor editor = mPreferences.edit();
|
||||||
editor.putBoolean(PLAYBACK_CONTROLLER_BOX, value);
|
// editor.putBoolean(PLAYBACK_CONTROLLER_BOX, value);
|
||||||
editor.apply();
|
// editor.apply();
|
||||||
}
|
// }
|
||||||
|
|
||||||
public final boolean transparentToolbar() {
|
public final boolean transparentToolbar() {
|
||||||
return mPreferences.getBoolean(TRANSPARENT_TOOLBAR, false);
|
return mPreferences.getBoolean(TRANSPARENT_TOOLBAR, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTransparentToolbar(final boolean value) {
|
// public void setTransparentToolbar(final boolean value) {
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
// final SharedPreferences.Editor editor = mPreferences.edit();
|
||||||
editor.putBoolean(TRANSPARENT_TOOLBAR, value);
|
// editor.putBoolean(TRANSPARENT_TOOLBAR, value);
|
||||||
editor.apply();
|
// editor.apply();
|
||||||
}
|
// }
|
||||||
|
|
||||||
public final boolean downloadMissingArtistImages() {
|
// public final boolean downloadMissingArtistImages() {
|
||||||
return mPreferences.getBoolean(DOWNLOAD_MISSING_ARTIST_IMAGES, true);
|
// return mPreferences.getBoolean(DOWNLOAD_MISSING_ARTIST_IMAGES, true);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setDownloadMissingArtistImages(final boolean value) {
|
// public void setDownloadMissingArtistImages(final boolean value) {
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
// final SharedPreferences.Editor editor = mPreferences.edit();
|
||||||
editor.putBoolean(DOWNLOAD_MISSING_ARTIST_IMAGES, value);
|
// editor.putBoolean(DOWNLOAD_MISSING_ARTIST_IMAGES, value);
|
||||||
editor.apply();
|
// editor.apply();
|
||||||
}
|
// }
|
||||||
|
|
||||||
private void setSortOrder(final String key, final String value) {
|
private void setSortOrder(final String key, final String value) {
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||||
|
|
@ -179,52 +205,52 @@ public final class PreferenceUtils {
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArtistSortOrder(final String value) {
|
// public void setArtistSortOrder(final String value) {
|
||||||
setSortOrder(ARTIST_SORT_ORDER, value);
|
// setSortOrder(ARTIST_SORT_ORDER, value);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public final String getArtistSortOrder() {
|
public final String getArtistSortOrder() {
|
||||||
return mPreferences.getString(ARTIST_SORT_ORDER, SortOrder.ArtistSortOrder.ARTIST_A_Z);
|
return mPreferences.getString(ARTIST_SORT_ORDER, SortOrder.ArtistSortOrder.ARTIST_A_Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArtistSongSortOrder(final String value) {
|
// public void setArtistSongSortOrder(final String value) {
|
||||||
setSortOrder(ARTIST_SONG_SORT_ORDER, value);
|
// setSortOrder(ARTIST_SONG_SORT_ORDER, value);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public final String getArtistSongSortOrder() {
|
public final String getArtistSongSortOrder() {
|
||||||
return mPreferences.getString(ARTIST_SONG_SORT_ORDER,
|
return mPreferences.getString(ARTIST_SONG_SORT_ORDER,
|
||||||
SortOrder.ArtistSongSortOrder.SONG_A_Z);
|
SortOrder.ArtistSongSortOrder.SONG_A_Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArtistAlbumSortOrder(final String value) {
|
// public void setArtistAlbumSortOrder(final String value) {
|
||||||
setSortOrder(ARTIST_ALBUM_SORT_ORDER, value);
|
// setSortOrder(ARTIST_ALBUM_SORT_ORDER, value);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public final String getArtistAlbumSortOrder() {
|
public final String getArtistAlbumSortOrder() {
|
||||||
return mPreferences.getString(ARTIST_ALBUM_SORT_ORDER,
|
return mPreferences.getString(ARTIST_ALBUM_SORT_ORDER,
|
||||||
SortOrder.ArtistAlbumSortOrder.ALBUM_A_Z);
|
SortOrder.ArtistAlbumSortOrder.ALBUM_A_Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAlbumSortOrder(final String value) {
|
// public void setAlbumSortOrder(final String value) {
|
||||||
setSortOrder(ALBUM_SORT_ORDER, value);
|
// setSortOrder(ALBUM_SORT_ORDER, value);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public final String getAlbumSortOrder() {
|
public final String getAlbumSortOrder() {
|
||||||
return mPreferences.getString(ALBUM_SORT_ORDER, SortOrder.AlbumSortOrder.ALBUM_A_Z);
|
return mPreferences.getString(ALBUM_SORT_ORDER, SortOrder.AlbumSortOrder.ALBUM_A_Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAlbumSongSortOrder(final String value) {
|
// public void setAlbumSongSortOrder(final String value) {
|
||||||
setSortOrder(ALBUM_SONG_SORT_ORDER, value);
|
// setSortOrder(ALBUM_SONG_SORT_ORDER, value);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public final String getAlbumSongSortOrder() {
|
public final String getAlbumSongSortOrder() {
|
||||||
return mPreferences.getString(ALBUM_SONG_SORT_ORDER,
|
return mPreferences.getString(ALBUM_SONG_SORT_ORDER,
|
||||||
SortOrder.AlbumSongSortOrder.SONG_TRACK_LIST);
|
SortOrder.AlbumSongSortOrder.SONG_TRACK_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSongSortOrder(final String value) {
|
// public void setSongSortOrder(final String value) {
|
||||||
setSortOrder(SONG_SORT_ORDER, value);
|
// setSortOrder(SONG_SORT_ORDER, value);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public final String getSongSortOrder() {
|
public final String getSongSortOrder() {
|
||||||
return mPreferences.getString(SONG_SORT_ORDER, SortOrder.SongSortOrder.SONG_A_Z);
|
return mPreferences.getString(SONG_SORT_ORDER, SortOrder.SongSortOrder.SONG_A_Z);
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue