main
h4h13 2018-08-11 01:18:18 +05:30
parent 74ae7f517e
commit e5774b422c
22 changed files with 756 additions and 637 deletions

View File

@ -2,43 +2,40 @@ package code.name.monkey.retromusic;
public class Constants { public class Constants {
public static final String DISCORD_LINK = "https://discord.gg/qTecXXn"; public static final String DISCORD_LINK = "https://discord.gg/qTecXXn";
public static final String RETRO_MUSIC_PACKAGE_NAME = "code.name.monkey.retromusic"; public static final String RETRO_MUSIC_PACKAGE_NAME = "code.name.monkey.retromusic";
public static final String MUSIC_PACKAGE_NAME = "com.android.music"; public static final String MUSIC_PACKAGE_NAME = "com.android.music";
public static final String ACTION_TOGGLE_PAUSE = RETRO_MUSIC_PACKAGE_NAME + ".togglepause"; public static final String ACTION_TOGGLE_PAUSE = RETRO_MUSIC_PACKAGE_NAME + ".togglepause";
public static final String ACTION_PLAY = RETRO_MUSIC_PACKAGE_NAME + ".play"; public static final String ACTION_PLAY = RETRO_MUSIC_PACKAGE_NAME + ".play";
public static final String ACTION_PLAY_PLAYLIST = RETRO_MUSIC_PACKAGE_NAME + ".play.playlist"; public static final String ACTION_PLAY_PLAYLIST = RETRO_MUSIC_PACKAGE_NAME + ".play.playlist";
public static final String ACTION_PAUSE = RETRO_MUSIC_PACKAGE_NAME + ".pause"; public static final String ACTION_PAUSE = RETRO_MUSIC_PACKAGE_NAME + ".pause";
public static final String ACTION_STOP = RETRO_MUSIC_PACKAGE_NAME + ".stop"; public static final String ACTION_STOP = RETRO_MUSIC_PACKAGE_NAME + ".stop";
public static final String ACTION_SKIP = RETRO_MUSIC_PACKAGE_NAME + ".skip"; public static final String ACTION_SKIP = RETRO_MUSIC_PACKAGE_NAME + ".skip";
public static final String ACTION_REWIND = RETRO_MUSIC_PACKAGE_NAME + ".rewind"; public static final String ACTION_REWIND = RETRO_MUSIC_PACKAGE_NAME + ".rewind";
public static final String ACTION_QUIT = RETRO_MUSIC_PACKAGE_NAME + ".quitservice"; public static final String ACTION_QUIT = RETRO_MUSIC_PACKAGE_NAME + ".quitservice";
public static final String INTENT_EXTRA_PLAYLIST = public static final String INTENT_EXTRA_PLAYLIST = RETRO_MUSIC_PACKAGE_NAME + "intentextra.playlist";
RETRO_MUSIC_PACKAGE_NAME + "intentextra.playlist"; public static final String INTENT_EXTRA_SHUFFLE_MODE = RETRO_MUSIC_PACKAGE_NAME + ".intentextra.shufflemode";
public static final String INTENT_EXTRA_SHUFFLE_MODE = public static final String APP_WIDGET_UPDATE = RETRO_MUSIC_PACKAGE_NAME + ".appwidgetupdate";
RETRO_MUSIC_PACKAGE_NAME + ".intentextra.shufflemode"; public static final String EXTRA_APP_WIDGET_NAME = RETRO_MUSIC_PACKAGE_NAME + "app_widget_name";
public static final String APP_WIDGET_UPDATE = RETRO_MUSIC_PACKAGE_NAME + ".appwidgetupdate"; // do not change these three strings as it will break support with other apps (e.g. last.fm scrobbling)
public static final String EXTRA_APP_WIDGET_NAME = RETRO_MUSIC_PACKAGE_NAME + "app_widget_name"; public static final String META_CHANGED = RETRO_MUSIC_PACKAGE_NAME + ".metachanged";
// do not change these three strings as it will break support with other apps (e.g. last.fm scrobbling) public static final String QUEUE_CHANGED = RETRO_MUSIC_PACKAGE_NAME + ".queuechanged";
public static final String META_CHANGED = RETRO_MUSIC_PACKAGE_NAME + ".metachanged"; public static final String PLAY_STATE_CHANGED = RETRO_MUSIC_PACKAGE_NAME + ".playstatechanged";
public static final String QUEUE_CHANGED = RETRO_MUSIC_PACKAGE_NAME + ".queuechanged"; public static final String REPEAT_MODE_CHANGED = RETRO_MUSIC_PACKAGE_NAME + ".repeatmodechanged";
public static final String PLAY_STATE_CHANGED = RETRO_MUSIC_PACKAGE_NAME + ".playstatechanged"; public static final String SHUFFLE_MODE_CHANGED = RETRO_MUSIC_PACKAGE_NAME + ".shufflemodechanged";
public static final String REPEAT_MODE_CHANGED = RETRO_MUSIC_PACKAGE_NAME + ".repeatmodechanged"; public static final String MEDIA_STORE_CHANGED = RETRO_MUSIC_PACKAGE_NAME + ".mediastorechanged";
public static final String SHUFFLE_MODE_CHANGED = public static final String RATE_ON_GOOGLE_PLAY = "https://play.google.com/store/apps/details?id=code.name.monkey.retromusic";
RETRO_MUSIC_PACKAGE_NAME + ".shufflemodechanged"; public static final String PAYPAL_ME_URL = "https://www.paypal.me/h4h14";
public static final String MEDIA_STORE_CHANGED = RETRO_MUSIC_PACKAGE_NAME + ".mediastorechanged"; public static final String GOOGLE_PLUS_COMMUNITY = "https://plus.google.com/communities/110811566242871492162";
public static final String RATE_ON_GOOGLE_PLAY = "https://play.google.com/store/apps/details?id=code.name.monkey.retromusic"; public static final String TRANSLATE = "http://monkeycodeapp.oneskyapp.com/collaboration/project?id=238534";
public static final String PAYPAL_ME_URL = "https://www.paypal.me/h4h14"; public static final String GITHUB_PROJECT = "https://github.com/h4h13/RetroMusicPlayer";
public static final String GOOGLE_PLUS_COMMUNITY = "https://plus.google.com/communities/110811566242871492162"; public static final String BASE_API_URL_KUGOU = "http://lyrics.kugou.com/";
public static final String TRANSLATE = "http://monkeycodeapp.oneskyapp.com/collaboration/project?id=238534"; public static final String TELEGRAM_CHANGE_LOG = "https://t.me/retromusiclog";
public static final String GITHUB_PROJECT = "https://github.com/h4h13/RetroMusicPlayer"; public static final String USER_PROFILE = "profile.jpg";
public static final String BASE_API_URL_KUGOU = "http://lyrics.kugou.com/"; public static final String USER_BANNER = "banner.jpg";
public static final String TELEGRAM_CHANGE_LOG = "https://t.me/retromusiclog"; public static final String APP_INSTAGRAM_LINK = "https://www.instagram.com/retromusicapp/";
public static final String USER_PROFILE = "profile.jpg"; public static final String APP_TELEGRAM_LINK = "https://t.me/retromusicapp/";
public static final String USER_BANNER = "banner.jpg"; public static final String APP_TWITTER_LINK = "https://twitter.com/retromusicapp";
public static final String APP_INSTAGRAM_LINK = "https://www.instagram.com/retromusicapp/"; public static final String FAQ_LINK = "https://github.com/h4h13/RetroMusicPlayer/blob/master/FAQ.md";
public static final String APP_TELEGRAM_LINK = "https://t.me/retromusicapp/";
public static final String APP_TWITTER_LINK = "https://twitter.com/retromusicapp";
public static final String FAQ_LINK = "https://github.com/h4h13/RetroMusicPlayer/blob/master/FAQ.md";
} }

View File

@ -1,77 +1,112 @@
package code.name.monkey.retromusic; package code.name.monkey.retromusic;
import android.content.Intent;
import android.os.Build; import android.os.Build;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.multidex.MultiDexApplication; import android.support.multidex.MultiDexApplication;
import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager;
import com.anjlab.android.iab.v3.BillingProcessor; import com.anjlab.android.iab.v3.BillingProcessor;
import com.anjlab.android.iab.v3.TransactionDetails; import com.anjlab.android.iab.v3.TransactionDetails;
import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager;
import code.name.monkey.retromusic.ui.activities.ErrorHandlerActivity;
import uk.co.chrisjenx.calligraphy.CalligraphyConfig; import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
public class RetroApplication extends MultiDexApplication { public class RetroApplication extends MultiDexApplication {
public static final String PRO_VERSION_PRODUCT_ID = "pro_version"; public static final String PRO_VERSION_PRODUCT_ID = "pro_version";
private static RetroApplication app; private static RetroApplication app;
private BillingProcessor billingProcessor; private BillingProcessor billingProcessor;
public static RetroApplication getInstance() { public static RetroApplication getInstance() {
return app; return app;
}
public static boolean isProVersion() {
return BuildConfig.DEBUG || app.billingProcessor.isPurchased(PRO_VERSION_PRODUCT_ID);
}
@Override
public void onCreate() {
super.onCreate();
app = this;
// default theme
if (!ThemeStore.isConfigured(this, 1)) {
ThemeStore.editTheme(this)
.accentColorRes(R.color.md_green_A200)
.commit();
} }
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() public static boolean isProVersion() {
.setDefaultFontPath("fonts/circular_std_book.otf") return BuildConfig.DEBUG || app.billingProcessor.isPurchased(PRO_VERSION_PRODUCT_ID);
.setFontAttrId(R.attr.fontPath)
.build()
);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
new DynamicShortcutManager(this).initDynamicShortcuts();
} }
// automatically restores purchases public static void deleteAppData() {
billingProcessor = new BillingProcessor(this, BuildConfig.GOOGLE_PLAY_LICENSE_KEY, try {
new BillingProcessor.IBillingHandler() { // clearing app data
@Override String packageName = app.getPackageName();
public void onProductPurchased(@NonNull String productId, TransactionDetails details) { Runtime runtime = Runtime.getRuntime();
} runtime.exec("pm clear " + packageName);
@Override System.exit(0);
public void onPurchaseHistoryRestored() {
//Toast.makeText(App.this, R.string.restored_previous_purchase_please_restart, Toast.LENGTH_LONG).show();
}
@Override } catch (Exception e) {
public void onBillingError(int errorCode, Throwable error) { e.printStackTrace();
} }
}
@Override @Override
public void onBillingInitialized() { public void onCreate() {
} super.onCreate();
app = this;
// default theme
if (!ThemeStore.isConfigured(this, 1)) {
ThemeStore.editTheme(this)
.accentColorRes(R.color.md_green_A200)
.commit();
}
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/circular_std_book.otf")
.setFontAttrId(R.attr.fontPath)
.build()
);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
new DynamicShortcutManager(this).initDynamicShortcuts();
}
// automatically restores purchases
billingProcessor = new BillingProcessor(this, BuildConfig.GOOGLE_PLAY_LICENSE_KEY,
new BillingProcessor.IBillingHandler() {
@Override
public void onProductPurchased(@NonNull String productId, TransactionDetails details) {
}
@Override
public void onPurchaseHistoryRestored() {
//Toast.makeText(App.this, R.string.restored_previous_purchase_please_restart, Toast.LENGTH_LONG).show();
}
@Override
public void onBillingError(int errorCode, Throwable error) {
}
@Override
public void onBillingInitialized() {
}
});
}
private void setupErrorHandler() {
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable throwable) {
handleUncaughtException(thread, throwable);
}
}); });
} }
@Override private void handleUncaughtException(Thread thread, Throwable throwable) {
public void onTerminate() { throwable.printStackTrace();
super.onTerminate(); //Intent intent = new Intent(this, ErrorHandlerActivity.class);
billingProcessor.release(); //intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
} //startActivity(intent);
}
@Override
public void onTerminate() {
super.onTerminate();
billingProcessor.release();
}
} }

View File

@ -10,6 +10,7 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
@ -20,6 +21,7 @@ import code.name.monkey.retromusic.model.Playlist;
import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.model.Song;
import code.name.monkey.retromusic.ui.adapter.playlist.AddToPlaylist; import code.name.monkey.retromusic.ui.adapter.playlist.AddToPlaylist;
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment; import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
@ -27,60 +29,62 @@ import java.util.ArrayList;
*/ */
public class AddToPlaylistDialog extends RoundedBottomSheetDialogFragment { public class AddToPlaylistDialog extends RoundedBottomSheetDialogFragment {
@BindView(R.id.playlists) @BindView(R.id.playlists)
RecyclerView playlist; RecyclerView playlist;
@BindView(R.id.title)
TextView title;
ArrayList<Playlist> playlists;
@NonNull @BindView(R.id.title)
public static AddToPlaylistDialog create(Song song) { TextView title;
ArrayList<Song> list = new ArrayList<>();
list.add(song);
return create(list);
}
@NonNull ArrayList<Playlist> playlists;
public static AddToPlaylistDialog create(ArrayList<Song> songs) {
AddToPlaylistDialog dialog = new AddToPlaylistDialog();
Bundle args = new Bundle();
args.putParcelableArrayList("songs", songs);
dialog.setArguments(args);
return dialog;
}
@Nullable @NonNull
@Override public static AddToPlaylistDialog create(Song song) {
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, ArrayList<Song> list = new ArrayList<>();
@Nullable Bundle savedInstanceState) { list.add(song);
View layout = inflater.inflate(R.layout.dialog_add_to_playlist, container, false); return create(list);
ButterKnife.bind(this, layout); }
return layout;
}
@SuppressWarnings("ConstantConditions") @NonNull
@OnClick(R.id.action_add_playlist) public static AddToPlaylistDialog create(ArrayList<Song> songs) {
void newPlaylist() { AddToPlaylistDialog dialog = new AddToPlaylistDialog();
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs"); Bundle args = new Bundle();
CreatePlaylistDialog.create(songs) args.putParcelableArrayList("songs", songs);
.show(getActivity().getSupportFragmentManager(), "ADD_TO_PLAYLIST"); dialog.setArguments(args);
dismiss(); return dialog;
} }
@SuppressWarnings("ConstantConditions") @Nullable
@Override @Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
super.onViewCreated(view, savedInstanceState); @Nullable Bundle savedInstanceState) {
View layout = inflater.inflate(R.layout.dialog_add_to_playlist, container, false);
ButterKnife.bind(this, layout);
return layout;
}
title.setTextColor(ThemeStore.textColorPrimary(getContext())); @SuppressWarnings("ConstantConditions")
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs"); @OnClick(R.id.action_add_playlist)
playlists = PlaylistLoader.getAllPlaylists(getActivity()).blockingFirst(); void newPlaylist() {
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs");
CreatePlaylistDialog.create(songs)
.show(getActivity().getSupportFragmentManager(), "ADD_TO_PLAYLIST");
dismiss();
}
AddToPlaylist playlistAdapter = new AddToPlaylist(getActivity(), playlists, @SuppressWarnings("ConstantConditions")
R.layout.item_playlist, songs, getDialog()); @Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
playlist.setLayoutManager(new LinearLayoutManager(getContext())); title.setTextColor(ThemeStore.textColorPrimary(getContext()));
playlist.setItemAnimator(new DefaultItemAnimator()); final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs");
playlist.setAdapter(playlistAdapter); playlists = PlaylistLoader.getAllPlaylists(getActivity()).blockingFirst();
}
AddToPlaylist playlistAdapter = new AddToPlaylist(getActivity(), playlists,
R.layout.item_playlist, songs, getDialog());
playlist.setLayoutManager(new LinearLayoutManager(getContext()));
playlist.setItemAnimator(new DefaultItemAnimator());
playlist.setAdapter(playlistAdapter);
}
} }

View File

@ -3,12 +3,12 @@ package code.name.monkey.retromusic.dialogs;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.design.widget.BottomSheetDialogFragment; import android.support.design.widget.TextInputEditText;
import android.support.v7.widget.CardView;
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.Button; import android.widget.TextView;
import android.widget.EditText;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Objects; import java.util.Objects;
@ -17,7 +17,8 @@ import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import code.name.monkey.appthemehelper.ThemeStore; import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.appthemehelper.util.TintHelper; import code.name.monkey.appthemehelper.util.ColorUtil;
import code.name.monkey.appthemehelper.util.MaterialValueHelper;
import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.model.Song;
import code.name.monkey.retromusic.util.PlaylistsUtil; import code.name.monkey.retromusic.util.PlaylistsUtil;
@ -29,11 +30,16 @@ import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment;
public class CreatePlaylistDialog extends RoundedBottomSheetDialogFragment { public class CreatePlaylistDialog extends RoundedBottomSheetDialogFragment {
@BindView(R.id.option_1) @BindView(R.id.option_1)
EditText playlistName; TextInputEditText playlistName;
@BindView(R.id.action_cancel) @BindView(R.id.action_cancel)
Button actionCancel; TextView actionCancel;
@BindView(R.id.action_create) @BindView(R.id.action_create)
Button actionCreate; TextView actionCreate;
@BindView(R.id.action_create_container)
CardView actionCreateContainer;
@NonNull @NonNull
public static CreatePlaylistDialog create() { public static CreatePlaylistDialog create() {
@ -70,9 +76,17 @@ public class CreatePlaylistDialog extends RoundedBottomSheetDialogFragment {
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
int accentColor = ThemeStore.accentColor(Objects.requireNonNull(getContext())); int accentColor = ThemeStore.accentColor(Objects.requireNonNull(getContext()));
TintHelper.setTintAuto(playlistName, accentColor, true); actionCreateContainer.setCardBackgroundColor(ThemeStore.accentColor(getContext()));
TintHelper.setTintAuto(actionCreate, accentColor, true);
actionCancel.setTextColor(accentColor); int primaryTextColor = MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil
.isColorLight(accentColor));
int secondaryTextColor = MaterialValueHelper.getSecondaryTextColor(getContext(), ColorUtil
.isColorLight(accentColor));
actionCreate.setTextColor(primaryTextColor);
actionCancel.setTextColor(secondaryTextColor);
} }
@OnClick({R.id.action_cancel, R.id.action_create}) @OnClick({R.id.action_cancel, R.id.action_create})

View File

@ -8,85 +8,93 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.model.Song;
import code.name.monkey.retromusic.util.MusicUtil; import code.name.monkey.retromusic.util.MusicUtil;
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment; import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment;
import java.util.ArrayList; import java.util.ArrayList;
public class DeleteSongsDialog extends RoundedBottomSheetDialogFragment { public class DeleteSongsDialog extends RoundedBottomSheetDialogFragment {
@BindView(R.id.action_delete) @BindView(R.id.action_delete)
TextView delete; TextView delete;
@BindView(R.id.title) @BindView(R.id.title)
TextView title; TextView title;
@BindView(R.id.action_cancel) @BindView(R.id.action_cancel)
TextView cancel; TextView cancel;
@NonNull @NonNull
public static DeleteSongsDialog create(Song song) { public static DeleteSongsDialog create(Song song) {
ArrayList<Song> list = new ArrayList<>(); ArrayList<Song> list = new ArrayList<>();
list.add(song); list.add(song);
return create(list); return create(list);
} }
@NonNull @NonNull
public static DeleteSongsDialog create(ArrayList<Song> songs) { public static DeleteSongsDialog create(ArrayList<Song> songs) {
DeleteSongsDialog dialog = new DeleteSongsDialog(); DeleteSongsDialog dialog = new DeleteSongsDialog();
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putParcelableArrayList("songs", songs); args.putParcelableArrayList("songs", songs);
dialog.setArguments(args); dialog.setArguments(args);
return dialog; return dialog;
} }
@OnClick({R.id.action_cancel, R.id.action_delete}) @OnClick({R.id.action_cancel, R.id.action_delete})
void actions(View view) { void actions(View view) {
//noinspection ConstantConditions //noinspection ConstantConditions
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs"); final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs");
switch (view.getId()) { switch (view.getId()) {
case R.id.action_delete: case R.id.action_delete:
if (getActivity() == null) { if (getActivity() == null) {
return; return;
}
if (songs != null) {
MusicUtil.deleteTracks(getActivity(), songs);
}
break;
default:
} }
dismiss();
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
delete.setTextColor(ThemeStore.textColorPrimary(getContext()));
title.setTextColor(ThemeStore.textColorPrimary(getContext()));
cancel.setTextColor(ThemeStore.textColorPrimary(getContext()));
//noinspection unchecked,ConstantConditions
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs");
int title;
CharSequence content;
if (songs != null) { if (songs != null) {
MusicUtil.deleteTracks(getActivity(), songs); if (songs.size() > 1) {
title = R.string.delete_songs_title;
content = Html.fromHtml(getString(R.string.delete_x_songs, songs.size()));
} else {
title = R.string.delete_song_title;
content = Html.fromHtml(getString(R.string.delete_song_x, songs.get(0).title));
}
this.title.setText(title);
this.delete.setText(content);
} }
break;
default:
} }
dismiss();
}
@Override @Nullable
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { @Override
super.onViewCreated(view, savedInstanceState); public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
//noinspection unchecked,ConstantConditions @Nullable Bundle savedInstanceState) {
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs"); View layout = inflater.inflate(R.layout.dialog_delete_songs, container, false);
int title; ButterKnife.bind(this, layout);
CharSequence content; return layout;
if (songs != null) {
if (songs.size() > 1) {
title = R.string.delete_songs_title;
content = Html.fromHtml(getString(R.string.delete_x_songs, songs.size()));
} else {
title = R.string.delete_song_title;
content = Html.fromHtml(getString(R.string.delete_song_x, songs.get(0).title));
}
this.title.setText(title);
this.delete.setText(content);
} }
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View layout = inflater.inflate(R.layout.dialog_delete_songs, container, false);
ButterKnife.bind(this, layout);
return layout;
}
} }

View File

@ -9,14 +9,21 @@ import android.support.v7.widget.AppCompatTextView;
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.TextView;
import java.io.File; import java.io.File;
import java.util.Calendar; import java.util.Calendar;
import java.util.List;
import java.util.Objects;
import butterknife.BindView; import butterknife.BindView;
import butterknife.BindViews;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import butterknife.Unbinder; import butterknife.Unbinder;
import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView;
import code.name.monkey.appthemehelper.common.views.ATESecondaryTextView;
import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.RetroApplication; import code.name.monkey.retromusic.RetroApplication;
import code.name.monkey.retromusic.ui.activities.MainActivity; import code.name.monkey.retromusic.ui.activities.MainActivity;
@ -46,6 +53,12 @@ public class HomeOptionDialog extends RoundedBottomSheetDialogFragment {
@BindView(R.id.title_welcome) @BindView(R.id.title_welcome)
AppCompatTextView titleWelcome; AppCompatTextView titleWelcome;
@BindViews({R.id.tv_about, R.id.title_welcome, R.id.text, R.id.tv_buy_pro, R.id.tv_folder, R.id.tv_rate_app,
R.id.tv_settings, R.id.tv_sleep_timer})
List<TextView> textViews;
static ButterKnife.Setter<TextView, Integer> textColor = (view, value, index) -> view.setTextColor(value.intValue());
private CompositeDisposable disposable = new CompositeDisposable(); private CompositeDisposable disposable = new CompositeDisposable();
@Nullable @Nullable
@ -56,6 +69,7 @@ public class HomeOptionDialog extends RoundedBottomSheetDialogFragment {
mUnbinder = ButterKnife.bind(this, layout); mUnbinder = ButterKnife.bind(this, layout);
layout.findViewById(R.id.action_buy_pro).setVisibility(RetroApplication.isProVersion() ? View layout.findViewById(R.id.action_buy_pro).setVisibility(RetroApplication.isProVersion() ? View
.GONE : View.VISIBLE); .GONE : View.VISIBLE);
ButterKnife.apply(textViews, textColor, ThemeStore.textColorPrimary(getContext()));
return layout; return layout;
} }
@ -97,12 +111,13 @@ public class HomeOptionDialog extends RoundedBottomSheetDialogFragment {
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
@OnClick({R.id.action_about, R.id.user_info_container, R.id.action_buy_pro, R.id.action_folder, @OnClick({R.id.action_about, R.id.user_info_container, R.id.action_buy_pro, R.id.action_folder,
R.id.action_settings, R.id.action_sleep_timer,R.id.action_rate}) R.id.action_settings, R.id.action_sleep_timer, R.id.action_rate})
public void onViewClicked(View view) { public void onViewClicked(View view) {
switch (view.getId()) { switch (view.getId()) {
case R.id.user_info_container: case R.id.user_info_container:
NavigationUtil.goToUserInfo(getActivity()); NavigationUtil.goToUserInfo(getActivity());
break; case R.id.action_rate: break;
case R.id.action_rate:
NavigationUtil.goToPlayStore(getActivity()); NavigationUtil.goToPlayStore(getActivity());
break; break;
case R.id.action_folder: case R.id.action_folder:

View File

@ -5,6 +5,9 @@ import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.graphics.PorterDuff;
import android.graphics.drawable.ClipDrawable;
import android.graphics.drawable.LayerDrawable;
import android.os.Bundle; import android.os.Bundle;
import android.os.CountDownTimer; import android.os.CountDownTimer;
import android.os.SystemClock; import android.os.SystemClock;
@ -24,7 +27,6 @@ import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import code.name.monkey.appthemehelper.ThemeStore; import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.appthemehelper.util.TintHelper;
import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.service.MusicService; import code.name.monkey.retromusic.service.MusicService;
import code.name.monkey.retromusic.util.MusicUtil; import code.name.monkey.retromusic.util.MusicUtil;
@ -39,9 +41,9 @@ public class SleepTimerDialog extends RoundedBottomSheetDialogFragment {
@BindView(R.id.timer_display) @BindView(R.id.timer_display)
TextView timerDisplay; TextView timerDisplay;
@BindView(R.id.action_set) @BindView(R.id.action_set)
Button setButton; TextView setButton;
@BindView(R.id.action_cancel) @BindView(R.id.action_cancel)
Button cancelButton; TextView cancelButton;
private int seekArcProgress; private int seekArcProgress;
private TimerUpdater timerUpdater; private TimerUpdater timerUpdater;
@ -68,6 +70,12 @@ public class SleepTimerDialog extends RoundedBottomSheetDialogFragment {
return layout; return layout;
} }
private void setProgressBarColor(int dark) {
LayerDrawable ld = (LayerDrawable) seekArc.getProgressDrawable();
ClipDrawable clipDrawable = (ClipDrawable) ld.findDrawableByLayerId(android.R.id.progress);
clipDrawable.setColorFilter(dark, PorterDuff.Mode.SRC_IN);
}
@Override @Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
@ -77,10 +85,8 @@ public class SleepTimerDialog extends RoundedBottomSheetDialogFragment {
updateTimeDisplayTime(); updateTimeDisplayTime();
seekArc.setProgress(seekArcProgress); seekArc.setProgress(seekArcProgress);
int accentColor = ThemeStore.accentColor(getContext()); //noinspection ConstantConditions
TintHelper.setTintAuto(seekArc, accentColor, true); setProgressBarColor(ThemeStore.accentColor(getContext()));
setButton.setTextColor(accentColor);
cancelButton.setTextColor(accentColor);
seekArc.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { seekArc.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override @Override

View File

@ -23,7 +23,12 @@ import org.jaudiotagger.tag.TagException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.List;
import butterknife.BindView;
import butterknife.BindViews;
import butterknife.ButterKnife;
import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.model.Song;
import code.name.monkey.retromusic.util.MusicUtil; import code.name.monkey.retromusic.util.MusicUtil;
@ -55,60 +60,65 @@ public class SongDetailDialog extends RoundedBottomSheetDialogFragment {
return fileSizeInMB + " MB"; return fileSizeInMB + " MB";
} }
private void setTextColor(List<TextView> textColor) {
for (TextView textView : textColor) {
//noinspection ConstantConditions
textView.setTextColor(ThemeStore.textColorPrimary(getContext()));
}
}
@BindViews({R.id.title,
R.id.file_name,
R.id.file_path,
R.id.file_size,
R.id.file_format,
R.id.track_length,
R.id.bitrate,
R.id.sampling_rate})
List<TextView> textViews;
@SuppressWarnings("ConstantConditions")
@Nullable @Nullable
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View dialogView = inflater.inflate(R.layout.dialog_file_details, container, false); View dialogView = inflater.inflate(R.layout.dialog_file_details, container, false);
ButterKnife.bind(this, dialogView);
Context context = getContext(); Context context = getContext();
final TextView fileName = dialogView.findViewById(R.id.file_name); setTextColor(textViews);
final TextView filePath = dialogView.findViewById(R.id.file_path);
final TextView fileSize = dialogView.findViewById(R.id.file_size);
final TextView fileFormat = dialogView.findViewById(R.id.file_format);
final TextView trackLength = dialogView.findViewById(R.id.track_length);
final TextView bitRate = dialogView.findViewById(R.id.bitrate);
final TextView samplingRate = dialogView.findViewById(R.id.sampling_rate);
fileName.setText(makeTextWithTitle(context, R.string.label_file_name, "-")); textViews.get(1).setText(makeTextWithTitle(context, R.string.label_file_name, "-"));
filePath.setText(makeTextWithTitle(context, R.string.label_file_path, "-")); textViews.get(2).setText(makeTextWithTitle(context, R.string.label_file_path, "-"));
fileSize.setText(makeTextWithTitle(context, R.string.label_file_size, "-")); textViews.get(3).setText(makeTextWithTitle(context, R.string.label_file_size, "-"));
fileFormat.setText(makeTextWithTitle(context, R.string.label_file_format, "-")); textViews.get(4).setText(makeTextWithTitle(context, R.string.label_file_format, "-"));
trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, "-")); textViews.get(5).setText(makeTextWithTitle(context, R.string.label_track_length, "-"));
bitRate.setText(makeTextWithTitle(context, R.string.label_bit_rate, "-")); textViews.get(6).setText(makeTextWithTitle(context, R.string.label_bit_rate, "-"));
samplingRate.setText(makeTextWithTitle(context, R.string.label_sampling_rate, "-")); textViews.get(7).setText(makeTextWithTitle(context, R.string.label_sampling_rate, "-"));
final Song song = getArguments().getParcelable("song"); final Song song = getArguments().getParcelable("song");
if (song != null) { if (song != null) {
final File songFile = new File(song.data); final File songFile = new File(song.data);
if (songFile.exists()) { if (songFile.exists()) {
fileName.setText(makeTextWithTitle(context, R.string.label_file_name, songFile.getName())); textViews.get(1).setText(makeTextWithTitle(context, R.string.label_file_name, songFile.getName()));
filePath.setText( textViews.get(2).setText(makeTextWithTitle(context, R.string.label_file_path, songFile.getAbsolutePath()));
makeTextWithTitle(context, R.string.label_file_path, songFile.getAbsolutePath())); textViews.get(3).setText(makeTextWithTitle(context, R.string.label_file_size, getFileSizeString(songFile.length())));
fileSize.setText(makeTextWithTitle(context, R.string.label_file_size,
getFileSizeString(songFile.length())));
try { try {
AudioFile audioFile = AudioFileIO.read(songFile); AudioFile audioFile = AudioFileIO.read(songFile);
AudioHeader audioHeader = audioFile.getAudioHeader(); AudioHeader audioHeader = audioFile.getAudioHeader();
fileFormat.setText( textViews.get(4).setText(makeTextWithTitle(context, R.string.label_file_format, audioHeader.getFormat()));
makeTextWithTitle(context, R.string.label_file_format, audioHeader.getFormat())); textViews.get(5).setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(audioHeader.getTrackLength() * 1000)));
trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil textViews.get(6).setText(makeTextWithTitle(context, R.string.label_bit_rate, audioHeader.getBitRate() + " kb/s"));
.getReadableDurationString(audioHeader.getTrackLength() * 1000))); textViews.get(7).setText(makeTextWithTitle(context, R.string.label_sampling_rate, audioHeader.getSampleRate() + " Hz"));
bitRate.setText(makeTextWithTitle(context, R.string.label_bit_rate,
audioHeader.getBitRate() + " kb/s"));
samplingRate.setText(makeTextWithTitle(context, R.string.label_sampling_rate,
audioHeader.getSampleRate() + " Hz"));
} catch (@NonNull CannotReadException | IOException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) { } catch (@NonNull CannotReadException | IOException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) {
Log.e(TAG, "error while reading the song file", e); Log.e(TAG, "error while reading the song file", e);
// fallback // fallback
trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, textViews.get(5).setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration)));
MusicUtil.getReadableDurationString(song.duration)));
} }
} else { } else {
// fallback // fallback
fileName.setText(makeTextWithTitle(context, R.string.label_file_name, song.title)); textViews.get(1).setText(makeTextWithTitle(context, R.string.label_file_name, song.title));
trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, textViews.get(5).setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration)));
MusicUtil.getReadableDurationString(song.duration)));
} }
} }

View File

@ -13,7 +13,7 @@ import code.name.monkey.retromusic.util.PreferenceUtil;
import io.reactivex.Observable; import io.reactivex.Observable;
public class ArtistLoader { public class ArtistLoader {
public static String getSongLoaderSortOrder(Context context) { private static String getSongLoaderSortOrder(Context context) {
return PreferenceUtil.getInstance(context).getArtistSortOrder() + ", " + return PreferenceUtil.getInstance(context).getArtistSortOrder() + ", " +
PreferenceUtil.getInstance(context).getArtistAlbumSortOrder() + ", " + PreferenceUtil.getInstance(context).getArtistAlbumSortOrder() + ", " +
PreferenceUtil.getInstance(context).getAlbumDetailSongSortOrder() + ", " + PreferenceUtil.getInstance(context).getAlbumDetailSongSortOrder() + ", " +
@ -98,22 +98,4 @@ public class ArtistLoader {
}); });
}); });
} }
/* public static Observable<ArrayList<Artist>> getAllArtists(Context context) {
return getArtistsForCursor(makeArtistCursor(context, null, null));
}
public static Observable<Artist> getArtist(Context context, long id) {
return getArtist(makeArtistCursor(context, "_id=?", new String[]{String.valueOf(id)}));
}
public static Observable<ArrayList<Artist>> getArtists(Context context, String paramString) {
return getArtistsForCursor(makeArtistCursor(context, "artist LIKE ?", new String[]{"%" + paramString + "%"}));
}
private static Cursor makeArtistCursor(Context context, String selection, String[] paramArrayOfString) {
final String artistSortOrder = PreferenceUtil.getInstance(context).getArtistSortOrder();
Cursor cursor = context.getContentResolver().query(MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI, new String[]{"_id", "artist", "number_of_albums", "number_of_tracks"}, selection, paramArrayOfString, artistSortOrder);
return cursor;
}*/
} }

View File

@ -16,6 +16,6 @@ public interface ArtistDetailContract {
} }
interface Presenter extends BasePresenter<ArtistsDetailsView> { interface Presenter extends BasePresenter<ArtistsDetailsView> {
void loadArtistById(int artistId); void loadArtistById();
} }
} }

View File

@ -1,11 +1,14 @@
package code.name.monkey.retromusic.mvp.presenter; package code.name.monkey.retromusic.mvp.presenter;
import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import code.name.monkey.retromusic.model.Artist; import code.name.monkey.retromusic.model.Artist;
import code.name.monkey.retromusic.mvp.Presenter; import code.name.monkey.retromusic.mvp.Presenter;
import code.name.monkey.retromusic.mvp.contract.ArtistDetailContract; import code.name.monkey.retromusic.mvp.contract.ArtistDetailContract;
import static code.name.monkey.retromusic.ui.activities.ArtistDetailActivity.EXTRA_ARTIST_ID;
/** /**
* Created by hemanths on 20/08/17. * Created by hemanths on 20/08/17.
@ -13,19 +16,19 @@ import code.name.monkey.retromusic.mvp.contract.ArtistDetailContract;
public class ArtistDetailsPresenter extends Presenter implements ArtistDetailContract.Presenter { public class ArtistDetailsPresenter extends Presenter implements ArtistDetailContract.Presenter {
private final int artistId;
@NonNull @NonNull
private final ArtistDetailContract.ArtistsDetailsView view; private final ArtistDetailContract.ArtistsDetailsView view;
private Bundle bundle;
public ArtistDetailsPresenter(@NonNull ArtistDetailContract.ArtistsDetailsView view, public ArtistDetailsPresenter(@NonNull ArtistDetailContract.ArtistsDetailsView view,
int artistId) { Bundle artistId) {
this.view = view; this.view = view;
this.artistId = artistId; this.bundle = artistId;
} }
@Override @Override
public void subscribe() { public void subscribe() {
loadArtistById(artistId); loadArtistById();
} }
@Override @Override
@ -34,14 +37,14 @@ public class ArtistDetailsPresenter extends Presenter implements ArtistDetailCon
} }
@Override @Override
public void loadArtistById(int artistId) { public void loadArtistById() {
disposable.add(repository.getArtistById(artistId) disposable.add(repository.getArtistById(bundle.getInt(EXTRA_ARTIST_ID))
.subscribeOn(schedulerProvider.computation()) .subscribeOn(schedulerProvider.computation())
.observeOn(schedulerProvider.ui()) .observeOn(schedulerProvider.ui())
.doOnSubscribe(disposable1 -> view.loading()) .doOnSubscribe(disposable1 -> view.loading())
.subscribe(this::showArtist, .subscribe(this::showArtist,
throwable -> view.showEmptyView(), throwable -> view.showEmptyView(),
() -> view.completed())); view::completed));
} }
private void showArtist(Artist album) { private void showArtist(Artist album) {

View File

@ -171,9 +171,10 @@ public class AlbumDetailsActivity extends AbsSlidingMusicPanelActivity implement
public void onViewClicked(View view) { public void onViewClicked(View view) {
switch (view.getId()) { switch (view.getId()) {
case R.id.artist_image: case R.id.artist_image:
Pair<View, String> pair = new Pair<>(artistImage, Pair[] artistPairs = new Pair[]{Pair.create(image,
getString(R.string.transition_artist_image)); getResources().getString(R.string.transition_artist_image))};
NavigationUtil.goToArtist(this, getAlbum().getArtistId(), pair); NavigationUtil.goToArtist(this, getAlbum().getArtistId(),
artistPairs);
break; break;
case R.id.action_shuffle_all: case R.id.action_shuffle_all:
MusicPlayerRemote.openAndShuffleQueue(album.songs, true); MusicPlayerRemote.openAndShuffleQueue(album.songs, true);

View File

@ -125,18 +125,19 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
setDrawUnderStatusBar(true); setDrawUnderStatusBar(true);
super.onCreate(bundle); super.onCreate(bundle);
ButterKnife.bind(this); ButterKnife.bind(this);
supportPostponeEnterTransition();
setBottomBarVisibility(View.GONE); setBottomBarVisibility(View.GONE);
setNavigationbarColorAuto(); setNavigationbarColorAuto();
setLightNavigationBar(true); setLightNavigationBar(true);
supportPostponeEnterTransition();
lastFMRestClient = new LastFMRestClient(this); lastFMRestClient = new LastFMRestClient(this);
setUpViews(); setUpViews();
int artistID = getIntent().getIntExtra(EXTRA_ARTIST_ID, -1); artistDetailsPresenter = new ArtistDetailsPresenter(this, getIntent().getExtras());
artistDetailsPresenter = new ArtistDetailsPresenter(this, artistID); artistDetailsPresenter.subscribe();
} }
private void setUpViews() { private void setUpViews() {
@ -232,7 +233,7 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
artistDetailsPresenter.subscribe();
} }
@Override @Override

View File

@ -0,0 +1 @@
package code.name.monkey.retromusic.ui.activities; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import butterknife.OnClick; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.RetroApplication; import code.name.monkey.retromusic.ui.activities.base.AbsBaseActivity; public class ErrorHandlerActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_error_handler); } @OnClick(R.id.clear_app_data) void clearAppDate(View view) { RetroApplication.deleteAppData(); } }

View File

@ -37,11 +37,14 @@ public class ProVersionActivity extends AbsBaseActivity implements
private static final String TAG = "ProVersionActivity"; private static final String TAG = "ProVersionActivity";
@BindView(R.id.toolbar) @BindView(R.id.toolbar)
Toolbar toolbar; Toolbar toolbar;
@BindView(R.id.restore_button) @BindView(R.id.restore_button)
View restoreButton; View restoreButton;
@BindView(R.id.purchase_button) @BindView(R.id.purchase_button)
View purchaseButton; View purchaseButton;
@BindView(R.id.app_bar) @BindView(R.id.app_bar)
AppBarLayout appBar; AppBarLayout appBar;
@BindView(R.id.status_bar) @BindView(R.id.status_bar)
View statusBar; View statusBar;

View File

@ -11,6 +11,10 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import android.view.animation.PathInterpolator; import android.view.animation.PathInterpolator;
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
import com.sothree.slidinguppanel.SlidingUpPanelLayout.PanelState;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import code.name.monkey.appthemehelper.ThemeStore; import code.name.monkey.appthemehelper.ThemeStore;
@ -35,399 +39,397 @@ import code.name.monkey.retromusic.ui.fragments.player.simple.SimplePlayerFragme
import code.name.monkey.retromusic.util.PreferenceUtil; import code.name.monkey.retromusic.util.PreferenceUtil;
import code.name.monkey.retromusic.util.ViewUtil; import code.name.monkey.retromusic.util.ViewUtil;
import code.name.monkey.retromusic.views.BottomNavigationViewEx; import code.name.monkey.retromusic.views.BottomNavigationViewEx;
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
import com.sothree.slidinguppanel.SlidingUpPanelLayout.PanelState;
public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivity implements public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivity implements
SlidingUpPanelLayout.PanelSlideListener, SlidingUpPanelLayout.PanelSlideListener,
PlayerFragment.Callbacks { PlayerFragment.Callbacks {
public static final String TAG = AbsSlidingMusicPanelActivity.class.getSimpleName(); public static final String TAG = AbsSlidingMusicPanelActivity.class.getSimpleName();
@BindView(R.id.bottom_navigation) @BindView(R.id.bottom_navigation)
BottomNavigationViewEx bottomNavigationView; BottomNavigationViewEx bottomNavigationView;
@BindView(R.id.sliding_layout) @BindView(R.id.sliding_layout)
SlidingUpPanelLayout slidingUpPanelLayout; SlidingUpPanelLayout slidingUpPanelLayout;
private int navigationbarColor; private int navigationbarColor;
private int taskColor; private int taskColor;
private boolean lightStatusBar; private boolean lightStatusBar;
private boolean lightNavigationBar; private boolean lightNavigationBar;
private NowPlayingScreen currentNowPlayingScreen; private NowPlayingScreen currentNowPlayingScreen;
private AbsPlayerFragment playerFragment; private AbsPlayerFragment playerFragment;
private MiniPlayerFragment miniPlayerFragment; private MiniPlayerFragment miniPlayerFragment;
private ValueAnimator navigationBarColorAnimator; private ValueAnimator navigationBarColorAnimator;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(createContentView()); setContentView(createContentView());
ButterKnife.bind(this); ButterKnife.bind(this);
choosFragmentForTheme(); choosFragmentForTheme();
//noinspection ConstantConditions //noinspection ConstantConditions
miniPlayerFragment.getView().setOnClickListener(v -> expandPanel()); miniPlayerFragment.getView().setOnClickListener(v -> expandPanel());
slidingUpPanelLayout.getViewTreeObserver() slidingUpPanelLayout.getViewTreeObserver()
.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override @Override
public void onGlobalLayout() { public void onGlobalLayout() {
slidingUpPanelLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this); slidingUpPanelLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
if (getPanelState() == PanelState.EXPANDED) { if (getPanelState() == PanelState.EXPANDED) {
onPanelSlide(slidingUpPanelLayout, 1); onPanelSlide(slidingUpPanelLayout, 1);
onPanelExpanded(slidingUpPanelLayout); onPanelExpanded(slidingUpPanelLayout);
} else if (getPanelState() == PanelState.COLLAPSED) { } else if (getPanelState() == PanelState.COLLAPSED) {
onPanelCollapsed(slidingUpPanelLayout); onPanelCollapsed(slidingUpPanelLayout);
} else { } else {
playerFragment.onHide(); playerFragment.onHide();
} }
} }
}); });
setupBottomView(); setupBottomView();
slidingUpPanelLayout.addPanelSlideListener(this); slidingUpPanelLayout.addPanelSlideListener(this);
}
private void choosFragmentForTheme() {
currentNowPlayingScreen = PreferenceUtil.getInstance(this).getNowPlayingScreen();
Fragment fragment; // must implement AbsPlayerFragment
switch (currentNowPlayingScreen) {
case MATERIAL:
fragment = new MaterialFragment();
break;
case BLUR:
fragment = new BlurPlayerFragment();
break;
case FLAT:
fragment = new FlatPlayerFragment();
break;
case PLAIN:
fragment = new PlainPlayerFragment();
break;
case FULL:
fragment = new FullPlayerFragment();
break;
case COLOR:
fragment = new ColorFragment();
break;
case CARD:
fragment = new CardFragment();
break;
case SIMPLE:
fragment = new SimplePlayerFragment();
break;
case TINY:
fragment = new HmmPlayerFragment();
break;
case BLUR_CARD:
fragment = new CardBlurFragment();
break;
case ADAPTIVE:
fragment = new AdaptiveFragment();
break;
case NORMAL:
default:
fragment = new PlayerFragment();
break;
}
getSupportFragmentManager().beginTransaction().replace(R.id.player_fragment_container, fragment)
.commit();
getSupportFragmentManager().executePendingTransactions();
playerFragment = (AbsPlayerFragment) getSupportFragmentManager()
.findFragmentById(R.id.player_fragment_container);
miniPlayerFragment = (MiniPlayerFragment) getSupportFragmentManager()
.findFragmentById(R.id.mini_player_fragment);
}
private void setupBottomView() {
bottomNavigationView.setSelectedItemId(PreferenceUtil.getInstance(this).getLastPage());
bottomNavigationView.setBackgroundColor(ThemeStore.primaryColor(this));
bottomNavigationView.enableAnimation(false);
bottomNavigationView.enableItemShiftingMode(false);
bottomNavigationView.enableShiftingMode(false);
bottomNavigationView.setTextSize(10f);
bottomNavigationView.setTextVisibility(PreferenceUtil.getInstance(this).tabTitles());
}
@Override
protected void onResume() {
super.onResume();
if (currentNowPlayingScreen != PreferenceUtil.getInstance(this).getNowPlayingScreen()) {
postRecreate();
}
}
@Override
public void onDestroy() {
super.onDestroy();
if (navigationBarColorAnimator != null) {
navigationBarColorAnimator.cancel(); // just in case
}
}
protected abstract View createContentView();
@Override
public void onServiceConnected() {
super.onServiceConnected();
if (!MusicPlayerRemote.getPlayingQueue().isEmpty()) {
slidingUpPanelLayout.getViewTreeObserver()
.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
slidingUpPanelLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
hideBottomBar(false);
}
});
}// don't call hideBottomBar(true) here as it causes a bug with the SlidingUpPanelLayout
}
@Override
public void onQueueChanged() {
super.onQueueChanged();
hideBottomBar(MusicPlayerRemote.getPlayingQueue().isEmpty());
}
@Override
public void onPanelSlide(View panel, @FloatRange(from = 0, to = 1) float slideOffset) {
bottomNavigationView.setTranslationY(slideOffset * 400);
setMiniPlayerAlphaProgress(slideOffset);
//findViewById(R.id.player_fragment_container).setAlpha(slideOffset);
}
@Override
public void onPanelStateChanged(View panel, PanelState previousState, PanelState newState) {
switch (newState) {
case COLLAPSED:
onPanelCollapsed(panel);
break;
case EXPANDED:
onPanelExpanded(panel);
break;
case ANCHORED:
collapsePanel(); // this fixes a bug where the panel would get stuck for some reason
break;
}
}
public void onPanelCollapsed(View panel) {
// restore values
super.setLightStatusbar(lightStatusBar);
super.setTaskDescriptionColor(taskColor);
super.setNavigationbarColor(navigationbarColor);
super.setLightNavigationBar(lightNavigationBar);
playerFragment.setMenuVisibility(false);
playerFragment.setUserVisibleHint(false);
playerFragment.onHide();
}
public void onPanelExpanded(View panel) {
// setting fragments values
int playerFragmentColor = playerFragment.getPaletteColor();
super.setTaskDescriptionColor(playerFragmentColor);
if (currentNowPlayingScreen == NowPlayingScreen.COLOR) {
super.setNavigationbarColor(playerFragmentColor);
} else {
super.setNavigationbarColor(ThemeStore.primaryColor(this));
} }
setLightStatusBar(); private void choosFragmentForTheme() {
currentNowPlayingScreen = PreferenceUtil.getInstance(this).getNowPlayingScreen();
playerFragment.setMenuVisibility(true); Fragment fragment; // must implement AbsPlayerFragment
playerFragment.setUserVisibleHint(true); switch (currentNowPlayingScreen) {
playerFragment.onShow(); case MATERIAL:
} fragment = new MaterialFragment();
break;
case BLUR:
fragment = new BlurPlayerFragment();
break;
case FLAT:
fragment = new FlatPlayerFragment();
break;
case PLAIN:
fragment = new PlainPlayerFragment();
break;
case FULL:
fragment = new FullPlayerFragment();
break;
case COLOR:
fragment = new ColorFragment();
break;
case CARD:
fragment = new CardFragment();
break;
case SIMPLE:
fragment = new SimplePlayerFragment();
break;
case TINY:
fragment = new HmmPlayerFragment();
break;
case BLUR_CARD:
fragment = new CardBlurFragment();
break;
case ADAPTIVE:
fragment = new AdaptiveFragment();
break;
private void setLightStatusBar() { case NORMAL:
super.setLightStatusbar(!PreferenceUtil.getInstance(this).getAdaptiveColor() && default:
ColorUtil.isColorLight(ThemeStore.primaryColor(this)) && ( fragment = new PlayerFragment();
currentNowPlayingScreen == NowPlayingScreen.FLAT break;
|| currentNowPlayingScreen == NowPlayingScreen.PLAIN }
|| currentNowPlayingScreen == NowPlayingScreen.SIMPLE getSupportFragmentManager().beginTransaction().replace(R.id.player_fragment_container, fragment)
|| currentNowPlayingScreen == NowPlayingScreen.NORMAL .commit();
|| currentNowPlayingScreen == NowPlayingScreen.ADAPTIVE getSupportFragmentManager().executePendingTransactions();
|| currentNowPlayingScreen == NowPlayingScreen.TINY
|| currentNowPlayingScreen == NowPlayingScreen.MATERIAL));
}
@Override playerFragment = (AbsPlayerFragment) getSupportFragmentManager()
public void setLightStatusbar(boolean enabled) { .findFragmentById(R.id.player_fragment_container);
lightStatusBar = enabled; miniPlayerFragment = (MiniPlayerFragment) getSupportFragmentManager()
if (getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) { .findFragmentById(R.id.mini_player_fragment);
super.setLightStatusbar(enabled);
} }
}
@Override private void setupBottomView() {
public void setLightNavigationBar(boolean enabled) { bottomNavigationView.setSelectedItemId(PreferenceUtil.getInstance(this).getLastPage());
lightNavigationBar = enabled; bottomNavigationView.setBackgroundColor(ThemeStore.primaryColor(this));
bottomNavigationView.enableAnimation(false);
bottomNavigationView.enableItemShiftingMode(false);
bottomNavigationView.enableShiftingMode(false);
bottomNavigationView.setTextSize(10f);
bottomNavigationView.setTextVisibility(PreferenceUtil.getInstance(this).tabTitles());
}
@Override
protected void onResume() {
super.onResume();
if (currentNowPlayingScreen != PreferenceUtil.getInstance(this).getNowPlayingScreen()) {
postRecreate();
}
}
@Override
public void onDestroy() {
super.onDestroy();
if (navigationBarColorAnimator != null) {
navigationBarColorAnimator.cancel(); // just in case
}
}
protected abstract View createContentView();
@Override
public void onServiceConnected() {
super.onServiceConnected();
if (!MusicPlayerRemote.getPlayingQueue().isEmpty()) {
slidingUpPanelLayout.getViewTreeObserver()
.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
slidingUpPanelLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
hideBottomBar(false);
}
});
}// don't call hideBottomBar(true) here as it causes a bug with the SlidingUpPanelLayout
}
@Override
public void onQueueChanged() {
super.onQueueChanged();
hideBottomBar(MusicPlayerRemote.getPlayingQueue().isEmpty());
}
@Override
public void onPanelSlide(View panel, @FloatRange(from = 0, to = 1) float slideOffset) {
bottomNavigationView.setTranslationY(slideOffset * 400);
setMiniPlayerAlphaProgress(slideOffset);
//findViewById(R.id.player_fragment_container).setAlpha(slideOffset);
}
@Override
public void onPanelStateChanged(View panel, PanelState previousState, PanelState newState) {
switch (newState) {
case COLLAPSED:
onPanelCollapsed(panel);
break;
case EXPANDED:
onPanelExpanded(panel);
break;
case ANCHORED:
collapsePanel(); // this fixes a bug where the panel would get stuck for some reason
break;
}
}
public void onPanelCollapsed(View panel) {
// restore values
super.setLightStatusbar(lightStatusBar);
super.setTaskDescriptionColor(taskColor);
super.setNavigationbarColor(navigationbarColor);
super.setLightNavigationBar(lightNavigationBar);
playerFragment.setMenuVisibility(false);
playerFragment.setUserVisibleHint(false);
playerFragment.onHide();
}
public void onPanelExpanded(View panel) {
// setting fragments values
int playerFragmentColor = playerFragment.getPaletteColor();
super.setTaskDescriptionColor(playerFragmentColor);
if (currentNowPlayingScreen == NowPlayingScreen.COLOR) {
super.setNavigationbarColor(playerFragmentColor);
} else {
super.setNavigationbarColor(ThemeStore.primaryColor(this));
}
setLightStatusBar();
playerFragment.setMenuVisibility(true);
playerFragment.setUserVisibleHint(true);
playerFragment.onShow();
}
private void setLightStatusBar() {
super.setLightStatusbar(!PreferenceUtil.getInstance(this).getAdaptiveColor() &&
ColorUtil.isColorLight(ThemeStore.primaryColor(this)) && (
currentNowPlayingScreen == NowPlayingScreen.FLAT
|| currentNowPlayingScreen == NowPlayingScreen.PLAIN
|| currentNowPlayingScreen == NowPlayingScreen.SIMPLE
|| currentNowPlayingScreen == NowPlayingScreen.NORMAL
|| currentNowPlayingScreen == NowPlayingScreen.ADAPTIVE
|| currentNowPlayingScreen == NowPlayingScreen.TINY
|| currentNowPlayingScreen == NowPlayingScreen.MATERIAL));
}
@Override
public void setLightStatusbar(boolean enabled) {
lightStatusBar = enabled;
if (getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) {
super.setLightStatusbar(enabled);
}
}
@Override
public void setLightNavigationBar(boolean enabled) {
lightNavigationBar = enabled;
/*if (getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) { /*if (getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) {
super.setLightNavigationBar(enabled); super.setLightNavigationBar(enabled);
}*/ }*/
}
@Override
public void setTaskDescriptionColor(@ColorInt int color) {
taskColor = color;
if (getPanelState() == null || getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) {
super.setTaskDescriptionColor(color);
} }
}
@Override @Override
public void setNavigationbarColor(int color) { public void setTaskDescriptionColor(@ColorInt int color) {
navigationbarColor = color; taskColor = color;
if (getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) { if (getPanelState() == null || getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) {
if (navigationBarColorAnimator != null) { super.setTaskDescriptionColor(color);
navigationBarColorAnimator.cancel(); }
}
super.setNavigationbarColor(color);
} }
}
@Override @Override
public void onPaletteColorChanged() { public void setNavigationbarColor(int color) {
int playerFragmentColor = playerFragment.getPaletteColor(); navigationbarColor = color;
if (getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) {
if (getPanelState() == PanelState.EXPANDED) { if (navigationBarColorAnimator != null) {
super.setTaskDescriptionColor(playerFragmentColor); navigationBarColorAnimator.cancel();
if (currentNowPlayingScreen == NowPlayingScreen.COLOR) { }
super.setNavigationbarColor(playerFragmentColor); super.setNavigationbarColor(color);
} }
} }
}
private void setMiniPlayerAlphaProgress(@FloatRange(from = 0, to = 1) float progress) { @Override
if (miniPlayerFragment == null) { public void onPaletteColorChanged() {
return; int playerFragmentColor = playerFragment.getPaletteColor();
if (getPanelState() == PanelState.EXPANDED) {
super.setTaskDescriptionColor(playerFragmentColor);
if (currentNowPlayingScreen == NowPlayingScreen.COLOR) {
super.setNavigationbarColor(playerFragmentColor);
}
}
} }
float alpha = 1 - progress;
miniPlayerFragment.getView().setAlpha(alpha);
// necessary to make the views below clickable
miniPlayerFragment.getView().setVisibility(alpha == 0 ? View.GONE : View.VISIBLE);
} private void setMiniPlayerAlphaProgress(@FloatRange(from = 0, to = 1) float progress) {
if (miniPlayerFragment == null) {
return;
}
float alpha = 1 - progress;
miniPlayerFragment.getView().setAlpha(alpha);
// necessary to make the views below clickable
miniPlayerFragment.getView().setVisibility(alpha == 0 ? View.GONE : View.VISIBLE);
public void hideBottomBar(final boolean hide) {
int heightOfBar =
getResources().getDimensionPixelSize(R.dimen.mini_player_height);
int heightOfBarWithTabs =
getResources().getDimensionPixelSize(R.dimen.mini_player_height_expanded);
if (hide) {
slidingUpPanelLayout.setPanelHeight(0);
collapsePanel();
} else {
if (!MusicPlayerRemote.getPlayingQueue().isEmpty()) {
slidingUpPanelLayout.setPanelHeight(bottomNavigationView.getVisibility() == View.VISIBLE ?
heightOfBarWithTabs : heightOfBar);
}
} }
}
public void setBottomBarVisibility(int gone) { public void hideBottomBar(final boolean hide) {
if (bottomNavigationView != null) {
//TransitionManager.beginDelayedTransition(bottomNavigationView); int heightOfBar =
bottomNavigationView.setVisibility(gone); getResources().getDimensionPixelSize(R.dimen.mini_player_height);
hideBottomBar(false); int heightOfBarWithTabs =
getResources().getDimensionPixelSize(R.dimen.mini_player_height_expanded);
if (hide) {
slidingUpPanelLayout.setPanelHeight(0);
collapsePanel();
} else {
if (!MusicPlayerRemote.getPlayingQueue().isEmpty()) {
slidingUpPanelLayout.setPanelHeight(bottomNavigationView.getVisibility() == View.VISIBLE ?
heightOfBarWithTabs : heightOfBar);
}
}
} }
}
protected View wrapSlidingMusicPanel(@LayoutRes int resId) { public void setBottomBarVisibility(int gone) {
@SuppressLint("InflateParams") if (bottomNavigationView != null) {
View slidingMusicPanelLayout = getLayoutInflater() //TransitionManager.beginDelayedTransition(bottomNavigationView);
.inflate(R.layout.sliding_music_panel_layout, null); bottomNavigationView.setVisibility(gone);
ViewGroup contentContainer = slidingMusicPanelLayout.findViewById(R.id.content_container); hideBottomBar(false);
getLayoutInflater().inflate(resId, contentContainer); }
return slidingMusicPanelLayout;
}
@Override
public void onBackPressed() {
if (!handleBackPress()) {
super.onBackPressed();
} }
}
public boolean handleBackPress() { protected View wrapSlidingMusicPanel(@LayoutRes int resId) {
if (slidingUpPanelLayout.getPanelHeight() != 0 && playerFragment.onBackPressed()) { @SuppressLint("InflateParams")
return true; View slidingMusicPanelLayout = getLayoutInflater()
.inflate(R.layout.sliding_music_panel_layout, null);
ViewGroup contentContainer = slidingMusicPanelLayout.findViewById(R.id.content_container);
getLayoutInflater().inflate(resId, contentContainer);
return slidingMusicPanelLayout;
} }
if (getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
collapsePanel(); @Override
return true; public void onBackPressed() {
if (!handleBackPress()) {
super.onBackPressed();
}
} }
return false;
}
private void animateNavigationBarColor(int color) { public boolean handleBackPress() {
if (navigationBarColorAnimator != null) { if (slidingUpPanelLayout.getPanelHeight() != 0 && playerFragment.onBackPressed()) {
navigationBarColorAnimator.cancel(); return true;
}
if (getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
collapsePanel();
return true;
}
return false;
} }
navigationBarColorAnimator = ValueAnimator.ofArgb(getWindow().getNavigationBarColor(), color)
.setDuration(ViewUtil.RETRO_MUSIC_ANIM_TIME);
navigationBarColorAnimator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
navigationBarColorAnimator.addUpdateListener(animation -> {
int playerFragmentColorDark = ColorUtil.darkenColor((Integer) animation.getAnimatedValue());
bottomNavigationView.setBackgroundColor(playerFragmentColorDark); private void animateNavigationBarColor(int color) {
miniPlayerFragment.setColor(playerFragmentColorDark); if (navigationBarColorAnimator != null) {
AbsSlidingMusicPanelActivity.super.setNavigationbarColor(playerFragmentColorDark); navigationBarColorAnimator.cancel();
}
navigationBarColorAnimator = ValueAnimator.ofArgb(getWindow().getNavigationBarColor(), color)
.setDuration(ViewUtil.RETRO_MUSIC_ANIM_TIME);
navigationBarColorAnimator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
navigationBarColorAnimator.addUpdateListener(animation -> {
int playerFragmentColorDark = ColorUtil.darkenColor((Integer) animation.getAnimatedValue());
View view = getWindow().getDecorView().getRootView(); bottomNavigationView.setBackgroundColor(playerFragmentColorDark);
view.setBackgroundColor(playerFragmentColorDark); miniPlayerFragment.setColor(playerFragmentColorDark);
AbsSlidingMusicPanelActivity.super.setNavigationbarColor(playerFragmentColorDark);
if (view.findViewById(R.id.toolbar) != null) { View view = getWindow().getDecorView().getRootView();
view.findViewById(R.id.toolbar).setBackgroundColor(playerFragmentColorDark); view.setBackgroundColor(playerFragmentColorDark);
}
if (view.findViewById(R.id.appbar) != null) {
view.findViewById(R.id.appbar).setBackgroundColor(playerFragmentColorDark);
}
if (view.findViewById(R.id.status_bar) != null) {
view.findViewById(R.id.status_bar)
.setBackgroundColor(ColorUtil.darkenColor(playerFragmentColorDark));
}
});
navigationBarColorAnimator.start();
}
@Override if (view.findViewById(R.id.toolbar) != null) {
protected View getSnackBarContainer() { view.findViewById(R.id.toolbar).setBackgroundColor(playerFragmentColorDark);
return findViewById(R.id.content_container); }
} if (view.findViewById(R.id.appbar) != null) {
view.findViewById(R.id.appbar).setBackgroundColor(playerFragmentColorDark);
}
if (view.findViewById(R.id.status_bar) != null) {
view.findViewById(R.id.status_bar)
.setBackgroundColor(ColorUtil.darkenColor(playerFragmentColorDark));
}
});
navigationBarColorAnimator.start();
}
public SlidingUpPanelLayout getSlidingUpPanelLayout() { @Override
return slidingUpPanelLayout; protected View getSnackBarContainer() {
} return findViewById(R.id.content_container);
}
public MiniPlayerFragment getMiniPlayerFragment() { public SlidingUpPanelLayout getSlidingUpPanelLayout() {
return miniPlayerFragment; return slidingUpPanelLayout;
} }
public AbsPlayerFragment getPlayerFragment() { public MiniPlayerFragment getMiniPlayerFragment() {
return playerFragment; return miniPlayerFragment;
} }
public BottomNavigationViewEx getBottomNavigationView() { public AbsPlayerFragment getPlayerFragment() {
return bottomNavigationView; return playerFragment;
} }
public SlidingUpPanelLayout.PanelState getPanelState() { public BottomNavigationViewEx getBottomNavigationView() {
return slidingUpPanelLayout == null ? null : slidingUpPanelLayout.getPanelState(); return bottomNavigationView;
} }
public void collapsePanel() { public SlidingUpPanelLayout.PanelState getPanelState() {
slidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); return slidingUpPanelLayout == null ? null : slidingUpPanelLayout.getPanelState();
} }
public void expandPanel() { public void collapsePanel() {
slidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED); slidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
} }
public void expandPanel() {
slidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED);
}
} }

View File

@ -43,10 +43,13 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
private static final int REQUEST_CODE_SELECT_IMAGE = 1000; private static final int REQUEST_CODE_SELECT_IMAGE = 1000;
@BindView(R.id.save_fab) @BindView(R.id.save_fab)
FloatingActionButton save; FloatingActionButton save;
@BindView(R.id.image) @BindView(R.id.image)
ImageView image; ImageView image;
@BindView(R.id.image_container) @BindView(R.id.image_container)
FrameLayout imageContainer; FrameLayout imageContainer;
CharSequence[] items; CharSequence[] items;
private int id; private int id;
private int paletteColorPrimary; private int paletteColorPrimary;

View File

@ -8,6 +8,7 @@ import android.support.v7.widget.Toolbar;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView;
import org.jaudiotagger.tag.FieldKey; import org.jaudiotagger.tag.FieldKey;
@ -28,22 +29,34 @@ public class SongTagEditorActivity extends AbsTagEditorActivity implements TextW
public static final String TAG = SongTagEditorActivity.class.getSimpleName(); public static final String TAG = SongTagEditorActivity.class.getSimpleName();
@BindView(R.id.toolbar) @BindView(R.id.toolbar)
Toolbar toolbar; Toolbar toolbar;
@BindView(R.id.app_bar) @BindView(R.id.app_bar)
AppBarLayout appBarLayout; AppBarLayout appBarLayout;
@BindView(R.id.title)
TextView title;
@BindView(R.id.title1) @BindView(R.id.title1)
EditText songTitle; EditText songTitle;
@BindView(R.id.title2) @BindView(R.id.title2)
EditText albumTitle; EditText albumTitle;
@BindView(R.id.artist) @BindView(R.id.artist)
EditText artist; EditText artist;
@BindView(R.id.genre) @BindView(R.id.genre)
EditText genre; EditText genre;
@BindView(R.id.year) @BindView(R.id.year)
EditText year; EditText year;
@BindView(R.id.image_text) @BindView(R.id.image_text)
EditText trackNumber; EditText trackNumber;
@BindView(R.id.lyrics) @BindView(R.id.lyrics)
EditText lyrics; EditText lyrics;
@BindView(R.id.album_artist) @BindView(R.id.album_artist)
EditText albumArtist; EditText albumArtist;
@ -51,7 +64,8 @@ public class SongTagEditorActivity extends AbsTagEditorActivity implements TextW
appBarLayout.setBackgroundColor(ThemeStore.primaryColor(this)); appBarLayout.setBackgroundColor(ThemeStore.primaryColor(this));
toolbar.setBackgroundColor(ThemeStore.primaryColor(this)); toolbar.setBackgroundColor(ThemeStore.primaryColor(this));
toolbar.setNavigationOnClickListener(v -> onBackPressed()); toolbar.setNavigationOnClickListener(v -> onBackPressed());
setTitle(R.string.action_tag_editor); setTitle(null);
title.setTextColor(ThemeStore.textColorPrimary(this));
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
} }

View File

@ -31,9 +31,7 @@ import code.name.monkey.retromusic.util.MusicUtil;
import code.name.monkey.retromusic.util.NavigationUtil; import code.name.monkey.retromusic.util.NavigationUtil;
public class ArtistAdapter extends public class ArtistAdapter extends AbsMultiSelectAdapter<ArtistAdapter.ViewHolder, Artist> implements FastScrollRecyclerView.SectionedAdapter {
AbsMultiSelectAdapter<ArtistAdapter.ViewHolder, Artist> implements
FastScrollRecyclerView.SectionedAdapter {
protected final AppCompatActivity activity; protected final AppCompatActivity activity;
protected ArrayList<Artist> dataSet; protected ArrayList<Artist> dataSet;
@ -54,7 +52,7 @@ public class ArtistAdapter extends
} }
public ArtistAdapter(@NonNull AppCompatActivity activity, ArrayList<Artist> dataSet, public ArtistAdapter(@NonNull AppCompatActivity activity, ArrayList<Artist> dataSet,
@LayoutRes int itemLayoutRes ) { @LayoutRes int itemLayoutRes) {
super(activity, null, R.menu.menu_media_selection); super(activity, null, R.menu.menu_media_selection);
this.activity = activity; this.activity = activity;
this.dataSet = dataSet; this.dataSet = dataSet;

View File

@ -55,10 +55,13 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
@BindView(R.id.toolbar) @BindView(R.id.toolbar)
Toolbar toolbar; Toolbar toolbar;
@BindView(R.id.app_bar) @BindView(R.id.app_bar)
AppBarLayout appbar; AppBarLayout appbar;
@BindView(R.id.title) @BindView(R.id.title)
TextView title; TextView title;
@BindView(R.id.search) @BindView(R.id.search)
IconImageView search; IconImageView search;

View File

@ -86,18 +86,25 @@ public class FoldersFragment extends AbsMainActivityFragment implements
private static final int LOADER_ID = LoaderIds.FOLDERS_FRAGMENT; private static final int LOADER_ID = LoaderIds.FOLDERS_FRAGMENT;
@BindView(R.id.coordinator_layout) @BindView(R.id.coordinator_layout)
CoordinatorLayout coordinatorLayout; CoordinatorLayout coordinatorLayout;
@BindView(R.id.container) @BindView(R.id.container)
View container; View container;
@BindView(R.id.title) @BindView(R.id.title)
TextView title; TextView title;
@BindView(android.R.id.empty) @BindView(android.R.id.empty)
View empty; View empty;
@BindView(R.id.toolbar) @BindView(R.id.toolbar)
Toolbar toolbar; Toolbar toolbar;
@BindView(R.id.bread_crumbs) @BindView(R.id.bread_crumbs)
BreadCrumbLayout breadCrumbs; BreadCrumbLayout breadCrumbs;
@BindView(R.id.appbar) @BindView(R.id.appbar)
AppBarLayout appbar; AppBarLayout appbar;
@BindView(R.id.recycler_view) @BindView(R.id.recycler_view)
FastScrollRecyclerView recyclerView; FastScrollRecyclerView recyclerView;

View File

@ -42,27 +42,39 @@ import code.name.monkey.retromusic.util.PreferenceUtil;
public class FullPlaybackControlsFragment extends AbsPlayerControlsFragment { public class FullPlaybackControlsFragment extends AbsPlayerControlsFragment {
@BindView(R.id.player_song_current_progress) @BindView(R.id.player_song_current_progress)
TextView mPlayerSongCurrentProgress; TextView mPlayerSongCurrentProgress;
@BindView(R.id.player_song_total_time) @BindView(R.id.player_song_total_time)
TextView songTotalTime; TextView songTotalTime;
@BindView(R.id.player_progress_slider) @BindView(R.id.player_progress_slider)
SeekBar progressSlider; SeekBar progressSlider;
@BindView(R.id.player_prev_button) @BindView(R.id.player_prev_button)
ImageButton playerPrevButton; ImageButton playerPrevButton;
@BindView(R.id.player_next_button) @BindView(R.id.player_next_button)
ImageButton playerNextButton; ImageButton playerNextButton;
@BindView(R.id.player_repeat_button) @BindView(R.id.player_repeat_button)
ImageButton playerRepeatButton; ImageButton playerRepeatButton;
@BindView(R.id.player_shuffle_button) @BindView(R.id.player_shuffle_button)
ImageButton playerShuffleButton; ImageButton playerShuffleButton;
@BindView(R.id.player_play_pause_button) @BindView(R.id.player_play_pause_button)
ImageButton playerPlayPauseFab; ImageButton playerPlayPauseFab;
Unbinder unbinder;
@BindView(R.id.title) @BindView(R.id.title)
TextView mTitle; TextView mTitle;
@BindView(R.id.text) @BindView(R.id.text)
TextView mText; TextView mText;
@BindView(R.id.volume_fragment_container) @BindView(R.id.volume_fragment_container)
View mVolumeContainer; View mVolumeContainer;
Unbinder unbinder;
private int lastPlaybackControlsColor; private int lastPlaybackControlsColor;
private int lastDisabledPlaybackControlsColor; private int lastDisabledPlaybackControlsColor;
private MusicProgressViewUpdateHelper progressViewUpdateHelper; private MusicProgressViewUpdateHelper progressViewUpdateHelper;