Folder screen have main menuu access
This commit is contained in:
parent
59e83445bc
commit
9002b165b7
13 changed files with 144 additions and 33 deletions
|
@ -12,6 +12,10 @@ import android.view.ViewGroup
|
|||
import androidx.core.app.ActivityCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
|
||||
import code.name.monkey.retromusic.fragments.mainactivity.LibraryFragment
|
||||
import code.name.monkey.retromusic.fragments.mainactivity.folders.FoldersFragment
|
||||
import code.name.monkey.retromusic.fragments.mainactivity.home.BannerHomeFragment
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.helper.SearchQueryHelper
|
||||
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
|
||||
|
@ -19,9 +23,6 @@ import code.name.monkey.retromusic.loaders.AlbumLoader
|
|||
import code.name.monkey.retromusic.loaders.ArtistLoader
|
||||
import code.name.monkey.retromusic.loaders.PlaylistSongsLoader
|
||||
import code.name.monkey.retromusic.service.MusicService
|
||||
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
|
||||
import code.name.monkey.retromusic.fragments.mainactivity.LibraryFragment
|
||||
import code.name.monkey.retromusic.fragments.mainactivity.home.BannerHomeFragment
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
|
@ -66,10 +67,8 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
|
|||
true
|
||||
}
|
||||
|
||||
//setUpDrawerLayout()
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
selectedFragment(PreferenceUtil.getInstance().lastPage);
|
||||
selectedFragment(PreferenceUtil.getInstance().lastPage)
|
||||
} else {
|
||||
restoreCurrentFragment();
|
||||
}
|
||||
|
@ -272,13 +271,14 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
|
|||
}*/
|
||||
}
|
||||
|
||||
private fun selectedFragment(itemId: Int) {
|
||||
fun selectedFragment(itemId: Int) {
|
||||
when (itemId) {
|
||||
R.id.action_album,
|
||||
R.id.action_artist,
|
||||
R.id.action_playlist,
|
||||
R.id.action_song -> setCurrentFragment(LibraryFragment.newInstance(itemId), false)
|
||||
R.id.action_home -> setCurrentFragment(BannerHomeFragment.newInstance(), false)
|
||||
R.id.action_folder -> setCurrentFragment(FoldersFragment.newInstance(this), false)
|
||||
else -> {
|
||||
setCurrentFragment(BannerHomeFragment.newInstance(), false)
|
||||
}
|
||||
|
|
|
@ -14,7 +14,10 @@ import android.view.MenuItem
|
|||
import android.widget.Toast
|
||||
import androidx.core.content.FileProvider
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.*
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.Constants.USER_BANNER
|
||||
import code.name.monkey.retromusic.Constants.USER_PROFILE
|
||||
|
@ -24,6 +27,7 @@ import code.name.monkey.retromusic.util.Compressor
|
|||
import code.name.monkey.retromusic.util.ImageUtil.getResizedBitmap
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
import com.afollestad.materialdialogs.list.listItems
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
|
@ -60,7 +64,7 @@ class UserInfoActivity : AbsBaseActivity() {
|
|||
loadBannerFromStorage(PreferenceUtil.getInstance().bannerImage)
|
||||
}
|
||||
userImage.setOnClickListener {
|
||||
MaterialDialog(this).show {
|
||||
MaterialDialog(this, BottomSheet()).show {
|
||||
title(text = getString(R.string.set_photo))
|
||||
listItems(items = listOf(getString(R.string.new_profile_photo), getString(R.string.remove_profile_photo))) { _, position, _ ->
|
||||
when (position) {
|
||||
|
@ -117,7 +121,7 @@ class UserInfoActivity : AbsBaseActivity() {
|
|||
}
|
||||
|
||||
private fun showBannerOptions() {
|
||||
MaterialDialog(this).show {
|
||||
MaterialDialog(this, BottomSheet()).show {
|
||||
title(R.string.select_banner_photo)
|
||||
listItems(items = listOf(getString(R.string.new_banner_photo), getString(R.string.remove_banner_photo)))
|
||||
{ _, position, _ ->
|
||||
|
|
|
@ -28,7 +28,6 @@ import code.name.monkey.retromusic.Constants.USER_PROFILE
|
|||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.MainActivity
|
||||
import code.name.monkey.retromusic.activities.bugreport.BugReportActivity
|
||||
import code.name.monkey.retromusic.fragments.mainactivity.folders.FoldersFragment
|
||||
import code.name.monkey.retromusic.util.Compressor
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
|
@ -81,6 +80,7 @@ class OptionsSheetDialogFragment : RoundedBottomSheetDialogFragment(), View.OnCl
|
|||
actionSettings.setOnClickListener(this)
|
||||
|
||||
actionSleepTimer.setOnClickListener(this)
|
||||
actionLibrary.setOnClickListener(this)
|
||||
userInfoContainer.setOnClickListener(this)
|
||||
actionEqualizer.setOnClickListener(this)
|
||||
actionFolders.setOnClickListener(this)
|
||||
|
@ -100,7 +100,8 @@ class OptionsSheetDialogFragment : RoundedBottomSheetDialogFragment(), View.OnCl
|
|||
override fun onClick(view: View) {
|
||||
val mainActivity = activity as MainActivity? ?: return
|
||||
when (view.id) {
|
||||
R.id.actionFolders -> mainActivity.setCurrentFragment(FoldersFragment.newInstance(context), true)
|
||||
R.id.actionFolders -> mainActivity.selectedFragment(R.id.action_folder)
|
||||
R.id.actionLibrary -> mainActivity.selectedFragment(PreferenceUtil.getInstance().lastPage)
|
||||
R.id.actionSettings -> NavigationUtil.goToSettings(mainActivity)
|
||||
|
||||
R.id.actionSleepTimer -> if (fragmentManager != null) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package code.name.monkey.retromusic.fragments.mainactivity.folders;
|
|||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.MediaScannerConnection;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
|
@ -13,6 +14,7 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.PopupMenu;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
@ -29,6 +31,10 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
import com.afollestad.materialcab.MaterialCab;
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet;
|
||||
import com.bumptech.glide.request.Request;
|
||||
import com.bumptech.glide.request.target.SizeReadyCallback;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView;
|
||||
|
@ -53,6 +59,7 @@ import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
|
|||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.adapter.SongFileAdapter;
|
||||
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment;
|
||||
import code.name.monkey.retromusic.glide.GlideApp;
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote;
|
||||
import code.name.monkey.retromusic.helper.menu.SongMenuHelper;
|
||||
import code.name.monkey.retromusic.helper.menu.SongsMenuHelper;
|
||||
|
@ -69,6 +76,8 @@ import code.name.monkey.retromusic.util.RetroColorUtil;
|
|||
import code.name.monkey.retromusic.util.ViewUtil;
|
||||
import code.name.monkey.retromusic.views.BreadCrumbLayout;
|
||||
|
||||
import static code.name.monkey.retromusic.Constants.USER_PROFILE;
|
||||
|
||||
public class FoldersFragment extends AbsMainActivityFragment implements
|
||||
MainActivityFragmentCallbacks,
|
||||
CabHolder, BreadCrumbLayout.SelectionCallback, SongFileAdapter.Callbacks,
|
||||
|
@ -94,6 +103,8 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
|||
|
||||
private AppBarLayout appBarLayout;
|
||||
|
||||
private ImageView userImage;
|
||||
|
||||
private FastScrollRecyclerView recyclerView;
|
||||
|
||||
private Comparator<File> fileComparator = (lhs, rhs) -> {
|
||||
|
@ -149,8 +160,76 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
|||
}
|
||||
}
|
||||
|
||||
private void loadImageFromStorage() {
|
||||
GlideApp.with(getMainActivity())
|
||||
.asDrawable()
|
||||
.placeholder(R.drawable.ic_person_flat)
|
||||
.fallback(R.drawable.ic_person_flat)
|
||||
.load(new File(PreferenceUtil.getInstance().getProfileImage(), USER_PROFILE))
|
||||
.into(new Target<Drawable>() {
|
||||
@Override
|
||||
public void onLoadStarted(@Nullable Drawable placeholder) {
|
||||
userImage.setImageDrawable(placeholder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed(@Nullable Drawable errorDrawable) {
|
||||
userImage.setImageDrawable(errorDrawable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
userImage.setImageDrawable(resource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSize(@NonNull SizeReadyCallback cb) {
|
||||
cb.onSizeReady(32, 32);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCallback(@NonNull SizeReadyCallback cb) {
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Request getRequest() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRequest(@Nullable Request request) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void initViews(View view) {
|
||||
coordinatorLayout = view.findViewById(R.id.coordinatorLayout);
|
||||
userImage = view.findViewById(R.id.userImage);
|
||||
userImage.setOnClickListener(v -> showMainMenu());
|
||||
recyclerView = view.findViewById(R.id.recyclerView);
|
||||
appBarLayout = view.findViewById(R.id.appBarLayout);
|
||||
breadCrumbs = view.findViewById(R.id.breadCrumbs);
|
||||
|
@ -209,8 +288,10 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
|||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_folder, container, false);
|
||||
initViews(view);
|
||||
|
@ -224,18 +305,14 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
|||
setUpBreadCrumbs();
|
||||
setUpRecyclerView();
|
||||
setUpAdapter();
|
||||
|
||||
loadImageFromStorage();
|
||||
}
|
||||
|
||||
private void setUpAppbarColor() {
|
||||
title.setTextColor(ThemeStore.Companion.textColorPrimary(getContext()));
|
||||
|
||||
//noinspection ConstantConditions
|
||||
int primaryColor = ThemeStore.Companion.primaryColor(getContext());
|
||||
|
||||
toolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp);
|
||||
//noinspection ConstantConditions
|
||||
|
||||
getActivity().setTitle(null);
|
||||
getMainActivity().setSupportActionBar(toolbar);
|
||||
TintHelper.setTintAuto(container, primaryColor, true);
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="4dp"/>
|
||||
<solid android:color="@color/twenty_percent_black_overlay"/>
|
||||
</shape>
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners
|
||||
android:bottomLeftRadius="12dp"
|
||||
android:bottomRightRadius="12dp" />
|
||||
<solid android:color="?colorPrimary" />
|
||||
</shape>
|
Binary file not shown.
Before Width: | Height: | Size: 423 B |
18
app/src/main/res/drawable/navigation_item_background.xml
Normal file
18
app/src/main/res/drawable/navigation_item_background.xml
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright (c) 2019 Hemanth Savarala.
|
||||
~
|
||||
~ Licensed under the GNU General Public License v3
|
||||
~
|
||||
~ This is free software: you can redistribute it and/or modify it under
|
||||
~ the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
~
|
||||
~ This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
~ See the GNU General Public License for more details.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@null" android:state_checked="false" />
|
||||
<item android:drawable="@drawable/navigation_item_checked" android:state_checked="true" />
|
||||
</selector>
|
|
@ -11,7 +11,10 @@
|
|||
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
~ See the GNU General Public License for more details.
|
||||
-->
|
||||
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/md_red_A400" />
|
||||
<corners android:radius="56dp" />
|
||||
<corners
|
||||
android:bottomRightRadius="25dp"
|
||||
android:topRightRadius="25dp" />
|
||||
<solid android:color="@color/md_deep_orange_A400" />
|
||||
</shape>
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/ic_album_selected_white_24dp" android:state_checked="true" />
|
||||
<item android:drawable="@drawable/ic_album_selected_white_24dp" android:state_checked="true" />
|
||||
<item android:drawable="@drawable/ic_album_white_24dp" />
|
||||
</selector>
|
|
@ -42,6 +42,15 @@
|
|||
app:layout_collapseMode="pin"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
<code.name.monkey.retromusic.views.CircularImageView
|
||||
android:id="@+id/userImage"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="14dp"
|
||||
android:layout_weight="0"
|
||||
app:civ_border="false" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bannerTitle"
|
||||
style="@style/BigTitleTextAppearanceToolbar"
|
||||
|
|
|
@ -96,6 +96,16 @@
|
|||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<code.name.monkey.retromusic.views.OptionMenuItemView
|
||||
android:id="@+id/actionLibrary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?rectSelector"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
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"
|
||||
|
|
|
@ -19,4 +19,5 @@
|
|||
<item name="action_song_sort_order_composer" type="id" />
|
||||
|
||||
<item name="action_multi_select_adapter_check_all" type="id" />
|
||||
<item name="action_folder" type="id" />
|
||||
</resources>
|
Loading…
Reference in a new issue