Added fragment to bottom options

main
h4h13 2020-02-21 23:48:11 +05:30
parent 1dc0a8fcc0
commit bad40d4ccd
12 changed files with 80 additions and 112 deletions

View File

@ -14,8 +14,6 @@
package code.name.monkey.retromusic.activities;
import static code.name.monkey.appthemehelper.util.ATHUtil.INSTANCE;
import android.graphics.Color;
import android.os.Bundle;
import android.view.MenuItem;
@ -23,6 +21,7 @@ import android.webkit.WebView;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.appthemehelper.util.ATHUtil;
import code.name.monkey.appthemehelper.util.ColorUtil;
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
import code.name.monkey.retromusic.R;
@ -49,7 +48,7 @@ public class LicenseActivity extends AbsBaseActivity {
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ToolbarContentTintHelper.colorBackButton(toolbar);
toolbar.setBackgroundColor(INSTANCE.resolveColor(this, R.attr.colorSurface));
toolbar.setBackgroundColor(ATHUtil.INSTANCE.resolveColor(this, R.attr.colorSurface));
WebView webView = findViewById(R.id.license);
try {
StringBuilder buf = new StringBuilder();
@ -62,8 +61,8 @@ public class LicenseActivity extends AbsBaseActivity {
in.close();
// Inject color values for WebView body background and links
final boolean isDark = INSTANCE.isWindowBackgroundDark(this);
final String backgroundColor = colorToCSS(INSTANCE.resolveColor(this, R.attr.colorSurface,
final boolean isDark = ATHUtil.INSTANCE.isWindowBackgroundDark(this);
final String backgroundColor = colorToCSS(ATHUtil.INSTANCE.resolveColor(this, R.attr.colorSurface,
Color.parseColor(isDark ? "#424242" : "#ffffff")));
final String contentColor = colorToCSS(Color.parseColor(isDark ? "#ffffff" : "#000000"));
final String changeLog = buf.toString()

View File

@ -207,11 +207,21 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
getMenuInflater().inflate(R.menu.menu_main, menu);
if (isPlaylistPage()) {
menu.add(0, R.id.action_new_playlist, 0, R.string.new_playlist_title)
.setIcon(R.drawable.ic_playlist_add_white_24dp).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
.setIcon(R.drawable.ic_playlist_add_white_24dp)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}
if (isHomePage()) {
menu.add(0, R.id.action_search, 0, getString(R.string.action_search))
.setIcon(R.drawable.ic_mic_white_24dp).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
.setIcon(R.drawable.ic_mic_white_24dp)
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}
if (isFolderPage()) {
menu.add(0, R.id.action_scan, 0, R.string.scan_media)
.setIcon(R.drawable.ic_scanner_white_24dp)
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
menu.add(0, R.id.action_go_to_start_directory, 0, R.string.action_go_to_start_directory)
.setIcon(R.drawable.ic_bookmark_music_white_24dp)
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}
Fragment fragment = getCurrentFragment();
if (fragment instanceof AbsLibraryPagerRecyclerViewCustomGridSizeFragment) {
@ -562,6 +572,10 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
return false;
}
private boolean isFolderPage() {
return getSupportFragmentManager().findFragmentByTag(FoldersFragment.TAG) instanceof FoldersFragment;
}
private boolean isHomePage() {
return getSupportFragmentManager().findFragmentByTag(BannerHomeFragment.TAG) instanceof BannerHomeFragment;
}
@ -611,6 +625,9 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
case R.id.action_song:
setCurrentFragment(SongsFragment.newInstance(), SongsFragment.TAG);
break;
case R.id.action_folder:
setCurrentFragment(FoldersFragment.newInstance(this), FoldersFragment.TAG);
break;
default:
case R.id.action_home:
setCurrentFragment(BannerHomeFragment.newInstance(), BannerHomeFragment.TAG);

View File

@ -1,6 +1,5 @@
package code.name.monkey.retromusic.activities;
import static code.name.monkey.appthemehelper.util.ATHUtil.INSTANCE;
import android.content.Context;
import android.content.pm.PackageInfo;
@ -13,6 +12,7 @@ import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import androidx.core.widget.NestedScrollView;
import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.appthemehelper.util.ATHUtil;
import code.name.monkey.appthemehelper.util.ColorUtil;
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
import code.name.monkey.retromusic.R;
@ -45,13 +45,13 @@ public class WhatsNewActivity extends AbsBaseActivity {
toolbar = findViewById(R.id.toolbar);
appBarLayout = findViewById(R.id.appBarLayout);
toolbar.setBackgroundColor(INSTANCE.resolveColor(this, R.attr.colorSurface));
toolbar.setBackgroundColor(ATHUtil.INSTANCE.resolveColor(this, R.attr.colorSurface));
//setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(v -> onBackPressed());
ToolbarContentTintHelper.colorBackButton(toolbar);
NestedScrollView nestedScrollView = findViewById(R.id.container);
try {
StringBuilder buf = new StringBuilder();
InputStream json = getAssets().open("retro-changelog.html");
@ -63,8 +63,8 @@ public class WhatsNewActivity extends AbsBaseActivity {
in.close();
// Inject color values for WebView body background and links
final boolean isDark = INSTANCE.isWindowBackgroundDark(this);
final String backgroundColor = colorToCSS(INSTANCE.resolveColor(this, R.attr.colorSurface,
final boolean isDark = ATHUtil.INSTANCE.isWindowBackgroundDark(this);
final String backgroundColor = colorToCSS(ATHUtil.INSTANCE.resolveColor(this, R.attr.colorSurface,
Color.parseColor(isDark ? "#424242" : "#ffffff")));
final String contentColor = colorToCSS(Color.parseColor(isDark ? "#ffffff" : "#000000"));
final String changeLog = buf.toString()

View File

@ -37,8 +37,6 @@ class OptionsSheetDialogFragment : DialogFragment(), View.OnClickListener {
override fun onClick(view: View) {
val mainActivity = activity as MainActivity? ?: return
when (view.id) {
R.id.actionFolders -> mainActivity.setMusicChooser(FOLDER)
R.id.actionLibrary -> mainActivity.setMusicChooser(LIBRARY)
R.id.actionSettings -> NavigationUtil.goToSettings(mainActivity)
R.id.actionDriveMode -> NavigationUtil.gotoDriveMode(mainActivity)
R.id.actionRate -> NavigationUtil.goToPlayStore(mainActivity)
@ -47,8 +45,6 @@ class OptionsSheetDialogFragment : DialogFragment(), View.OnClickListener {
}
private lateinit var actionSettings: OptionMenuItemView
private lateinit var actionLibrary: OptionMenuItemView
private lateinit var actionFolders: OptionMenuItemView
private lateinit var actionRate: OptionMenuItemView
private lateinit var actionDriveMode: OptionMenuItemView
private lateinit var materialDialog: MaterialDialog
@ -58,20 +54,10 @@ class OptionsSheetDialogFragment : DialogFragment(), View.OnClickListener {
val layout = LayoutInflater.from(context).inflate(R.layout.fragment_main_options, null)
actionSettings = layout.findViewById(R.id.actionSettings)
actionRate = layout.findViewById(R.id.actionRate)
actionLibrary = layout.findViewById(R.id.actionLibrary)
actionFolders = layout.findViewById(R.id.actionFolders)
actionDriveMode = layout.findViewById(R.id.actionDriveMode)
when (arguments?.getInt(WHICH_ONE)) {
LIBRARY -> actionLibrary.isSelected = true
FOLDER -> actionFolders.isSelected = true
}
actionSettings.setOnClickListener(this)
actionRate.setOnClickListener(this)
actionLibrary.setOnClickListener(this)
actionFolders.setOnClickListener(this)
actionDriveMode.setOnClickListener(this)
if (MusicPlayerRemote.playingQueue.isEmpty()) {

View File

@ -7,11 +7,10 @@ import android.os.Bundle;
import android.os.Environment;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.MarginLayoutParams;
import android.webkit.MimeTypeMap;
import android.widget.PopupMenu;
import android.widget.TextView;
@ -37,6 +36,7 @@ import code.name.monkey.retromusic.misc.DialogAsyncTask;
import code.name.monkey.retromusic.misc.UpdateToastMediaScannerCompletionListener;
import code.name.monkey.retromusic.misc.WrappedAsyncTaskLoader;
import code.name.monkey.retromusic.model.Song;
import code.name.monkey.retromusic.util.DensityUtil;
import code.name.monkey.retromusic.util.FileUtil;
import code.name.monkey.retromusic.util.PreferenceUtil;
import code.name.monkey.retromusic.util.RetroColorUtil;
@ -392,7 +392,6 @@ public class FoldersFragment extends AbsMainActivityFragment implements
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
getMainActivity().setBottomBarVisibility(View.GONE);
if (savedInstanceState == null) {
//noinspection ConstantConditions
@ -438,12 +437,6 @@ public class FoldersFragment extends AbsMainActivityFragment implements
return new AsyncFileLoader(this);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.menu_folders, menu);
}
@Override
public void onCrumbSelection(BreadCrumbLayout.Crumb crumb, int index) {
setCrumb(crumb, true);
@ -587,6 +580,17 @@ public class FoldersFragment extends AbsMainActivityFragment implements
return super.onOptionsItemSelected(item);
}
@Override
public void onQueueChanged() {
super.onQueueChanged();
checkForPadding();
}
@Override
public void onServiceConnected() {
super.onServiceConnected();
checkForPadding();
}
@NonNull
@Override
@ -603,6 +607,13 @@ public class FoldersFragment extends AbsMainActivityFragment implements
return cab;
}
private void checkForPadding() {
final int count = adapter.getItemCount();
final MarginLayoutParams params = (MarginLayoutParams) coordinatorLayout.getLayoutParams();
params.bottomMargin = count > 0 && !MusicPlayerRemote.getPlayingQueue().isEmpty() ? DensityUtil
.dip2px(requireContext(), 104f) : DensityUtil.dip2px(requireContext(), 54f);
}
private void checkIsEmpty() {
emojiText.setText(getEmojiByUnicode(0x1F631));
if (empty != null) {
@ -672,6 +683,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
public void onChanged() {
super.onChanged();
checkIsEmpty();
checkForPadding();
}
});
recyclerView.setAdapter(adapter);

View File

@ -71,7 +71,7 @@ object MusicPlayerRemote {
musicService!!.position = position
}
}
@JvmStatic
val playingQueue: ArrayList<Song>
get() = if (musicService != null) {
musicService?.playingQueue as ArrayList<Song>
@ -390,6 +390,7 @@ object MusicPlayerRemote {
}
return false
}
@JvmStatic
fun playFromUri(uri: Uri) {
if (musicService != null) {

View File

@ -28,7 +28,8 @@ public class CategoryInfo implements Parcelable {
ARTISTS(R.id.action_artist, R.string.artists, R.drawable.ic_artist_white_24dp),
PLAYLISTS(R.id.action_playlist, R.string.playlists, R.drawable.ic_playlist_play_white_24dp),
GENRES(R.id.action_genre, R.string.genres, R.drawable.ic_guitar_white_24dp),
QUEUE(R.id.action_playing_queue, R.string.queue, R.drawable.ic_queue_music_white_24dp);
QUEUE(R.id.action_playing_queue, R.string.queue, R.drawable.ic_queue_music_white_24dp),
FOLDER(R.id.action_folder, R.string.folders, R.drawable.ic_folder_white_24dp);
public final int icon;

View File

@ -36,6 +36,7 @@ import code.name.monkey.retromusic.fragments.mainactivity.folders.FoldersFragmen
import code.name.monkey.retromusic.helper.SortOrder;
import code.name.monkey.retromusic.helper.SortOrder.AlbumSongSortOrder;
import code.name.monkey.retromusic.model.CategoryInfo;
import code.name.monkey.retromusic.model.CategoryInfo.Category;
import code.name.monkey.retromusic.transform.CascadingPageTransformer;
import code.name.monkey.retromusic.transform.DepthTransformation;
import code.name.monkey.retromusic.transform.HingeTransformation;
@ -491,14 +492,15 @@ public final class PreferenceUtil {
@NonNull
public List<CategoryInfo> getDefaultLibraryCategoryInfos() {
List<CategoryInfo> defaultCategoryInfos = new ArrayList<>(7);
defaultCategoryInfos.add(new CategoryInfo(CategoryInfo.Category.HOME, true));
defaultCategoryInfos.add(new CategoryInfo(CategoryInfo.Category.SONGS, true));
defaultCategoryInfos.add(new CategoryInfo(CategoryInfo.Category.ALBUMS, true));
defaultCategoryInfos.add(new CategoryInfo(CategoryInfo.Category.ARTISTS, true));
defaultCategoryInfos.add(new CategoryInfo(CategoryInfo.Category.PLAYLISTS, true));
defaultCategoryInfos.add(new CategoryInfo(CategoryInfo.Category.GENRES, false));
defaultCategoryInfos.add(new CategoryInfo(CategoryInfo.Category.QUEUE, false));
List<CategoryInfo> defaultCategoryInfos = new ArrayList<>(8);
defaultCategoryInfos.add(new CategoryInfo(Category.HOME, true));
defaultCategoryInfos.add(new CategoryInfo(Category.SONGS, true));
defaultCategoryInfos.add(new CategoryInfo(Category.ALBUMS, true));
defaultCategoryInfos.add(new CategoryInfo(Category.ARTISTS, true));
defaultCategoryInfos.add(new CategoryInfo(Category.PLAYLISTS, true));
defaultCategoryInfos.add(new CategoryInfo(Category.GENRES, false));
defaultCategoryInfos.add(new CategoryInfo(Category.QUEUE, false));
defaultCategoryInfos.add(new CategoryInfo(Category.FOLDER, false));
return defaultCategoryInfos;
}

View File

@ -14,28 +14,20 @@
package code.name.monkey.retromusic.util
import android.animation.Animator
import android.animation.ArgbEvaluator
import android.animation.ObjectAnimator
import android.content.Context
import android.content.res.ColorStateList
import android.content.res.Resources
import android.graphics.Color
import android.graphics.PorterDuff
import android.graphics.drawable.LayerDrawable
import android.os.Build
import android.view.View
import android.view.animation.PathInterpolator
import android.widget.ProgressBar
import android.widget.SeekBar
import androidx.annotation.ColorInt
import androidx.core.graphics.BlendModeColorFilterCompat
import androidx.core.graphics.BlendModeCompat.SRC_IN
import androidx.core.view.ViewCompat
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.retromusic.R
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
object ViewUtil {
@ -57,37 +49,24 @@ object ViewUtil {
fun setProgressDrawable(progressSlider: ProgressBar, newColor: Int) {
val ld = progressSlider.progressDrawable as LayerDrawable
val layerDrawable = progressSlider.progressDrawable as LayerDrawable
val progress = ld.findDrawableByLayerId(android.R.id.progress)
progress.setColorFilter(newColor, PorterDuff.Mode.SRC_IN)
val progress = layerDrawable.findDrawableByLayerId(android.R.id.progress)
progress.colorFilter =
BlendModeColorFilterCompat.createBlendModeColorFilterCompat(newColor, SRC_IN)
val background = ld.findDrawableByLayerId(android.R.id.background)
val background = layerDrawable.findDrawableByLayerId(android.R.id.background)
val primaryColor = ATHUtil.resolveColor(progressSlider.context, android.R.attr.windowBackground)
background.setColorFilter(MaterialValueHelper.getPrimaryDisabledTextColor(progressSlider.context, ColorUtil.isColorLight(primaryColor)), PorterDuff.Mode.SRC_IN)
val secondaryProgress = ld.findDrawableByLayerId(android.R.id.secondaryProgress)
secondaryProgress?.setColorFilter(
ColorUtil.withAlpha(newColor, 0.65f), PorterDuff.Mode.SRC_IN
background.colorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(
MaterialValueHelper.getPrimaryDisabledTextColor(
progressSlider.context,
ColorUtil.isColorLight(primaryColor)
), SRC_IN
)
}
private fun createColorAnimator(
target: Any, propertyName: String, @ColorInt startColor: Int, @ColorInt endColor: Int
): Animator {
val animator: ObjectAnimator
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
animator = ObjectAnimator.ofArgb(target, propertyName, startColor, endColor)
} else {
animator = ObjectAnimator.ofInt(target, propertyName, startColor, endColor)
animator.setEvaluator(ArgbEvaluator())
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
animator.interpolator = PathInterpolator(0.4f, 0f, 1f, 1f)
}
animator.duration = RETRO_MUSIC_ANIM_TIME.toLong()
return animator
val secondaryProgress = layerDrawable.findDrawableByLayerId(android.R.id.secondaryProgress)
secondaryProgress?.colorFilter =
BlendModeColorFilterCompat.createBlendModeColorFilterCompat(ColorUtil.withAlpha(newColor, 0.65f), SRC_IN)
}
fun hitTest(v: View, x: Int, y: Int): Boolean {
@ -101,18 +80,6 @@ object ViewUtil {
return x in left..right && y >= top && y <= bottom
}
fun setUpFastScrollRecyclerViewColor(
context: Context,
recyclerView: FastScrollRecyclerView,
accentColor: Int = ThemeStore.accentColor(context)
) {
recyclerView.setPopupBgColor(accentColor)
recyclerView.setPopupTextColor(MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(accentColor)))
recyclerView.setThumbColor(accentColor)
recyclerView.setTrackColor(Color.TRANSPARENT)
recyclerView.setTrackColor(ColorUtil.withAlpha(ATHUtil.resolveColor(context, R.attr.colorControlNormal), 0.12f))
}
fun convertDpToPixel(dp: Float, resources: Resources): Float {
val metrics = resources.displayMetrics
return dp * metrics.density

View File

@ -9,21 +9,6 @@
android:paddingEnd="8dp"
tools:ignore="MissingPrefix">
<code.name.monkey.retromusic.views.OptionMenuItemView
android:id="@+id/actionLibrary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
app:optionIcon="@drawable/ic_library_music_white_24dp"
app:optionTitle="@string/library" />
<code.name.monkey.retromusic.views.OptionMenuItemView
android:id="@+id/actionFolders"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
app:optionIcon="@drawable/ic_folder_white_24dp"
app:optionTitle="@string/folders" />
<code.name.monkey.retromusic.views.OptionMenuItemView
android:id="@+id/actionDriveMode"

View File

@ -2,10 +2,8 @@ package code.name.monkey.appthemehelper.common;
import android.graphics.Color;
import android.view.Menu;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import code.name.monkey.appthemehelper.ATHActivity;
import code.name.monkey.appthemehelper.R;
import code.name.monkey.appthemehelper.util.ATHUtil;
@ -13,6 +11,7 @@ import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
public class ATHToolbarActivity extends ATHActivity {
private Toolbar toolbar;
public static int getToolbarBackgroundColor(@Nullable Toolbar toolbar) {

View File

@ -159,8 +159,7 @@ public final class ToolbarContentTintHelper {
radioButtonField.setAccessible(true);
final boolean isDark = !ColorUtil.INSTANCE.isColorLight(
ATHUtil.INSTANCE
.resolveColor(context, android.R.attr.windowBackground));
ATHUtil.INSTANCE.resolveColor(context, android.R.attr.windowBackground));
for (int i = 0; i < listView.getChildCount(); i++) {
View v = listView.getChildAt(i);