First steps for folder support.
This commit is contained in:
parent
373bba9e98
commit
56d3a2dbce
27 changed files with 652 additions and 553 deletions
|
|
@ -120,6 +120,7 @@ dependencies {
|
||||||
transitive = true
|
transitive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//noinspection GradleDynamicVersion
|
||||||
compile 'com.android.support:support-v4:23.2.1'
|
compile 'com.android.support:support-v4:23.2.1'
|
||||||
compile 'com.android.support:support-v13:23.2.1'
|
compile 'com.android.support:support-v13:23.2.1'
|
||||||
compile 'com.android.support:appcompat-v7:23.2.1'
|
compile 'com.android.support:appcompat-v7:23.2.1'
|
||||||
|
|
@ -137,7 +138,6 @@ dependencies {
|
||||||
compile 'com.squareup.retrofit2:retrofit:2.0.0'
|
compile 'com.squareup.retrofit2:retrofit:2.0.0'
|
||||||
compile 'com.squareup.retrofit2:converter-gson:2.0.0'
|
compile 'com.squareup.retrofit2:converter-gson:2.0.0'
|
||||||
compile 'com.jakewharton:butterknife:7.0.1'
|
compile 'com.jakewharton:butterknife:7.0.1'
|
||||||
//noinspection GradleDynamicVersion
|
|
||||||
compile 'com.anjlab.android.iab.v3:library:1.0.+'
|
compile 'com.anjlab.android.iab.v3:library:1.0.+'
|
||||||
compile 'de.psdev.licensesdialog:licensesdialog:1.8.0'
|
compile 'de.psdev.licensesdialog:licensesdialog:1.8.0'
|
||||||
compile 'com.github.bumptech.glide:glide:3.7.0'
|
compile 'com.github.bumptech.glide:glide:3.7.0'
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,10 @@ import android.util.SparseArray;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.ui.fragments.mainactivityfragments.AlbumsFragment;
|
import com.kabouzeid.gramophone.ui.fragments.libraryfragments.AlbumsPagerFragment;
|
||||||
import com.kabouzeid.gramophone.ui.fragments.mainactivityfragments.ArtistsFragment;
|
import com.kabouzeid.gramophone.ui.fragments.libraryfragments.ArtistsPagerFragment;
|
||||||
import com.kabouzeid.gramophone.ui.fragments.mainactivityfragments.PlaylistsFragment;
|
import com.kabouzeid.gramophone.ui.fragments.libraryfragments.PlaylistsPagerFragment;
|
||||||
import com.kabouzeid.gramophone.ui.fragments.mainactivityfragments.SongsFragment;
|
import com.kabouzeid.gramophone.ui.fragments.libraryfragments.SongsPagerFragment;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -107,10 +107,10 @@ public class MusicLibraryPagerAdapter extends FragmentPagerAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum MusicFragments {
|
public enum MusicFragments {
|
||||||
SONG(SongsFragment.class),
|
SONG(SongsPagerFragment.class),
|
||||||
ALBUM(AlbumsFragment.class),
|
ALBUM(AlbumsPagerFragment.class),
|
||||||
ARTIST(ArtistsFragment.class),
|
ARTIST(ArtistsPagerFragment.class),
|
||||||
PLAYLIST(PlaylistsFragment.class);
|
PLAYLIST(PlaylistsPagerFragment.class);
|
||||||
|
|
||||||
private final Class<? extends Fragment> mFragmentClass;
|
private final Class<? extends Fragment> mFragmentClass;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
package com.kabouzeid.gramophone.interfaces;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Karim Abou Zeid (kabouzeid)
|
|
||||||
*/
|
|
||||||
public interface KabViewsDisableAble {
|
|
||||||
|
|
||||||
void enableViews();
|
|
||||||
|
|
||||||
void disableViews();
|
|
||||||
|
|
||||||
boolean areViewsEnabled();
|
|
||||||
}
|
|
||||||
|
|
@ -234,20 +234,6 @@ public class AlbumDetailActivity extends AbsSlidingMusicPanelActivity implements
|
||||||
adapter.swapDataSet(album.songs);
|
adapter.swapDataSet(album.songs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enableViews() {
|
|
||||||
super.enableViews();
|
|
||||||
recyclerView.setEnabled(true);
|
|
||||||
toolbar.setEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void disableViews() {
|
|
||||||
super.disableViews();
|
|
||||||
recyclerView.setEnabled(false);
|
|
||||||
toolbar.setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.menu_album_detail, menu);
|
getMenuInflater().inflate(R.menu.menu_album_detail, menu);
|
||||||
|
|
|
||||||
|
|
@ -361,22 +361,6 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enableViews() {
|
|
||||||
super.enableViews();
|
|
||||||
songListView.setEnabled(true);
|
|
||||||
toolbar.setEnabled(true);
|
|
||||||
albumRecyclerView.setEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void disableViews() {
|
|
||||||
super.disableViews();
|
|
||||||
songListView.setEnabled(false);
|
|
||||||
toolbar.setEnabled(false);
|
|
||||||
albumRecyclerView.setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MaterialCab openCab(int menuRes, @NonNull final MaterialCab.Callback callback) {
|
public MaterialCab openCab(int menuRes, @NonNull final MaterialCab.Callback callback) {
|
||||||
if (cab != null && cab.isActive()) cab.finish();
|
if (cab != null && cab.isActive()) cab.finish();
|
||||||
|
|
|
||||||
|
|
@ -13,53 +13,35 @@ import android.os.IBinder;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
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.AppBarLayout;
|
|
||||||
import android.support.design.widget.AppBarLayout.OnOffsetChangedListener;
|
|
||||||
import android.support.design.widget.NavigationView;
|
import android.support.design.widget.NavigationView;
|
||||||
import android.support.design.widget.TabLayout;
|
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.view.ViewPager;
|
|
||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
import android.support.v7.widget.Toolbar;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.SubMenu;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.afollestad.materialcab.MaterialCab;
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.kabouzeid.appthemehelper.ThemeStore;
|
import com.kabouzeid.appthemehelper.ThemeStore;
|
||||||
import com.kabouzeid.appthemehelper.util.ATHUtil;
|
import com.kabouzeid.appthemehelper.util.ATHUtil;
|
||||||
import com.kabouzeid.appthemehelper.util.NavigationViewUtil;
|
import com.kabouzeid.appthemehelper.util.NavigationViewUtil;
|
||||||
import com.kabouzeid.appthemehelper.util.TabLayoutUtil;
|
|
||||||
import com.kabouzeid.appthemehelper.util.ToolbarContentTintHelper;
|
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.adapter.MusicLibraryPagerAdapter;
|
|
||||||
import com.kabouzeid.gramophone.dialogs.ChangelogDialog;
|
import com.kabouzeid.gramophone.dialogs.ChangelogDialog;
|
||||||
import com.kabouzeid.gramophone.dialogs.CreatePlaylistDialog;
|
|
||||||
import com.kabouzeid.gramophone.dialogs.DonationDialog;
|
import com.kabouzeid.gramophone.dialogs.DonationDialog;
|
||||||
import com.kabouzeid.gramophone.dialogs.SleepTimerDialog;
|
|
||||||
import com.kabouzeid.gramophone.glide.SongGlideRequest;
|
import com.kabouzeid.gramophone.glide.SongGlideRequest;
|
||||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||||
import com.kabouzeid.gramophone.helper.SearchQueryHelper;
|
import com.kabouzeid.gramophone.helper.SearchQueryHelper;
|
||||||
import com.kabouzeid.gramophone.interfaces.CabHolder;
|
|
||||||
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
|
|
||||||
import com.kabouzeid.gramophone.loader.AlbumLoader;
|
import com.kabouzeid.gramophone.loader.AlbumLoader;
|
||||||
import com.kabouzeid.gramophone.loader.ArtistSongLoader;
|
import com.kabouzeid.gramophone.loader.ArtistSongLoader;
|
||||||
import com.kabouzeid.gramophone.loader.PlaylistSongLoader;
|
import com.kabouzeid.gramophone.loader.PlaylistSongLoader;
|
||||||
import com.kabouzeid.gramophone.loader.SongLoader;
|
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
import com.kabouzeid.gramophone.model.Song;
|
||||||
import com.kabouzeid.gramophone.service.MusicService;
|
import com.kabouzeid.gramophone.service.MusicService;
|
||||||
import com.kabouzeid.gramophone.ui.activities.base.AbsSlidingMusicPanelActivity;
|
import com.kabouzeid.gramophone.ui.activities.base.AbsSlidingMusicPanelActivity;
|
||||||
import com.kabouzeid.gramophone.ui.activities.intro.AppIntroActivity;
|
import com.kabouzeid.gramophone.ui.activities.intro.AppIntroActivity;
|
||||||
import com.kabouzeid.gramophone.ui.fragments.mainactivityfragments.AbsMainActivityFragment;
|
import com.kabouzeid.gramophone.ui.fragments.FolderFragment;
|
||||||
import com.kabouzeid.gramophone.ui.fragments.mainactivityfragments.AbsMainActivityRecyclerViewCustomGridSizeFragment;
|
import com.kabouzeid.gramophone.ui.fragments.LibraryFragment;
|
||||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
|
||||||
import com.kabouzeid.gramophone.util.PhonographColorUtil;
|
|
||||||
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
||||||
import com.kabouzeid.gramophone.util.Util;
|
import com.kabouzeid.gramophone.util.Util;
|
||||||
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
|
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
|
||||||
|
|
@ -71,28 +53,23 @@ import butterknife.Bind;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
public class MainActivity extends AbsSlidingMusicPanelActivity
|
public class MainActivity extends AbsSlidingMusicPanelActivity
|
||||||
implements KabViewsDisableAble, CabHolder, DrawerLayout.DrawerListener {
|
implements DrawerLayout.DrawerListener {
|
||||||
|
|
||||||
public static final String TAG = MainActivity.class.getSimpleName();
|
public static final String TAG = MainActivity.class.getSimpleName();
|
||||||
public static final int APP_INTRO_REQUEST = 100;
|
public static final int APP_INTRO_REQUEST = 100;
|
||||||
|
|
||||||
@Bind(R.id.toolbar)
|
private static final int LIBRARY = 0;
|
||||||
Toolbar toolbar;
|
private static final int FOLDERS = 1;
|
||||||
@Bind(R.id.tabs)
|
|
||||||
TabLayout tabs;
|
|
||||||
@Bind(R.id.appbar)
|
|
||||||
AppBarLayout appbar;
|
|
||||||
@Bind(R.id.pager)
|
|
||||||
ViewPager pager;
|
|
||||||
@Bind(R.id.navigation_view)
|
@Bind(R.id.navigation_view)
|
||||||
NavigationView navigationView;
|
NavigationView navigationView;
|
||||||
@Bind(R.id.drawer_layout)
|
@Bind(R.id.drawer_layout)
|
||||||
DrawerLayout drawerLayout;
|
DrawerLayout drawerLayout;
|
||||||
|
|
||||||
|
MainActivityFragmentCallbacks currentFragment;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private View navigationDrawerHeader;
|
private View navigationDrawerHeader;
|
||||||
private MusicLibraryPagerAdapter pagerAdapter;
|
|
||||||
private MaterialCab cab;
|
|
||||||
|
|
||||||
private boolean blockRequestPermissions;
|
private boolean blockRequestPermissions;
|
||||||
|
|
||||||
|
|
@ -105,32 +82,38 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
||||||
Util.setStatusBarTranslucent(getWindow());
|
Util.setStatusBarTranslucent(getWindow());
|
||||||
drawerLayout.setFitsSystemWindows(false);
|
drawerLayout.setFitsSystemWindows(false);
|
||||||
navigationView.setFitsSystemWindows(false);
|
navigationView.setFitsSystemWindows(false);
|
||||||
|
//noinspection ConstantConditions
|
||||||
findViewById(R.id.drawer_content_container).setFitsSystemWindows(false);
|
findViewById(R.id.drawer_content_container).setFitsSystemWindows(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setStatusbarColorAuto();
|
|
||||||
setNavigationbarColorAuto();
|
|
||||||
setTaskDescriptionColorAuto();
|
|
||||||
|
|
||||||
setUpDrawerLayout();
|
setUpDrawerLayout();
|
||||||
setUpToolbar();
|
|
||||||
setUpViewPager();
|
|
||||||
|
|
||||||
if (!PreferenceUtil.getInstance(this).introShown()) {
|
setMusicChooser(PreferenceUtil.getInstance(this).getLastMusicChooser());
|
||||||
PreferenceUtil.getInstance(this).setIntroShown();
|
|
||||||
ChangelogDialog.setChangelogRead(this);
|
if (!checkShowIntro()) {
|
||||||
blockRequestPermissions = true;
|
|
||||||
new Handler().postDelayed(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
startActivityForResult(new Intent(MainActivity.this, AppIntroActivity.class), APP_INTRO_REQUEST);
|
|
||||||
}
|
|
||||||
}, 200);
|
|
||||||
} else {
|
|
||||||
checkShowChangelog();
|
checkShowChangelog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setMusicChooser(int key) {
|
||||||
|
PreferenceUtil.getInstance(this).setLastMusicChooser(key);
|
||||||
|
switch (key) {
|
||||||
|
case LIBRARY:
|
||||||
|
navigationView.setCheckedItem(R.id.nav_library);
|
||||||
|
setCurrentFragment(new LibraryFragment());
|
||||||
|
break;
|
||||||
|
case FOLDERS:
|
||||||
|
navigationView.setCheckedItem(R.id.nav_folders);
|
||||||
|
setCurrentFragment(new FolderFragment());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setCurrentFragment(Fragment fragment) {
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment, LibraryFragment.TAG).commit();
|
||||||
|
currentFragment = (MainActivityFragmentCallbacks) fragment;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
|
@ -156,37 +139,7 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
||||||
return contentView;
|
return contentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpViewPager() {
|
|
||||||
pagerAdapter = new MusicLibraryPagerAdapter(this, getSupportFragmentManager());
|
|
||||||
pager.setAdapter(pagerAdapter);
|
|
||||||
pager.setOffscreenPageLimit(pagerAdapter.getCount() - 1); // => all
|
|
||||||
|
|
||||||
tabs.setupWithViewPager(pager);
|
|
||||||
|
|
||||||
int primaryColor = ThemeStore.primaryColor(this);
|
|
||||||
int normalColor = ToolbarContentTintHelper.toolbarSubtitleColor(this, primaryColor);
|
|
||||||
int selectedColor = ToolbarContentTintHelper.toolbarTitleColor(this, primaryColor);
|
|
||||||
TabLayoutUtil.setTabIconColors(tabs, normalColor, selectedColor);
|
|
||||||
tabs.setTabTextColors(normalColor, selectedColor);
|
|
||||||
tabs.setSelectedTabIndicatorColor(ThemeStore.accentColor(this));
|
|
||||||
|
|
||||||
int startPosition = PreferenceUtil.getInstance(this).getDefaultStartPage();
|
|
||||||
startPosition = startPosition == -1 ? PreferenceUtil.getInstance(this).getLastStartPage() : startPosition;
|
|
||||||
pager.setCurrentItem(startPosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpToolbar() {
|
|
||||||
int primaryColor = ThemeStore.primaryColor(this);
|
|
||||||
appbar.setBackgroundColor(primaryColor);
|
|
||||||
toolbar.setBackgroundColor(primaryColor);
|
|
||||||
toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
|
|
||||||
setTitle(getResources().getString(R.string.app_name));
|
|
||||||
setSupportActionBar(toolbar);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpNavigationView() {
|
private void setUpNavigationView() {
|
||||||
navigationView.setCheckedItem(R.id.nav_library);
|
|
||||||
|
|
||||||
int accentColor = ThemeStore.accentColor(this);
|
int accentColor = ThemeStore.accentColor(this);
|
||||||
NavigationViewUtil.setItemIconColors(navigationView, ATHUtil.resolveColor(this, R.attr.iconColor, ThemeStore.textColorSecondary(this)), accentColor);
|
NavigationViewUtil.setItemIconColors(navigationView, ATHUtil.resolveColor(this, R.attr.iconColor, ThemeStore.textColorSecondary(this)), accentColor);
|
||||||
NavigationViewUtil.setItemTextColors(navigationView, ThemeStore.textColorPrimary(this), accentColor);
|
NavigationViewUtil.setItemTextColors(navigationView, ThemeStore.textColorPrimary(this), accentColor);
|
||||||
|
|
@ -197,10 +150,20 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
||||||
drawerLayout.closeDrawers();
|
drawerLayout.closeDrawers();
|
||||||
switch (menuItem.getItemId()) {
|
switch (menuItem.getItemId()) {
|
||||||
case R.id.nav_library:
|
case R.id.nav_library:
|
||||||
// TODO
|
new Handler().postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
setMusicChooser(LIBRARY);
|
||||||
|
}
|
||||||
|
}, 300);
|
||||||
break;
|
break;
|
||||||
case R.id.nav_folders:
|
case R.id.nav_folders:
|
||||||
// TODO
|
new Handler().postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
setMusicChooser(FOLDERS);
|
||||||
|
}
|
||||||
|
}, 300);
|
||||||
break;
|
break;
|
||||||
case R.id.support_development:
|
case R.id.support_development:
|
||||||
new Handler().postDelayed(new Runnable() {
|
new Handler().postDelayed(new Runnable() {
|
||||||
|
|
@ -234,7 +197,7 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
||||||
|
|
||||||
private void setUpDrawerLayout() {
|
private void setUpDrawerLayout() {
|
||||||
setUpNavigationView();
|
setUpNavigationView();
|
||||||
drawerLayout.setDrawerListener(this);
|
drawerLayout.addDrawerListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateNavigationDrawerHeader() {
|
private void updateNavigationDrawerHeader() {
|
||||||
|
|
@ -266,25 +229,6 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enableViews() {
|
|
||||||
try {
|
|
||||||
super.enableViews();
|
|
||||||
toolbar.setEnabled(true);
|
|
||||||
((AbsMainActivityFragment) getCurrentFragment()).enableViews();
|
|
||||||
} catch (NullPointerException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void disableViews() {
|
|
||||||
try {
|
|
||||||
super.disableViews();
|
|
||||||
((AbsMainActivityFragment) getCurrentFragment()).disableViews();
|
|
||||||
} catch (NullPointerException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayingMetaChanged() {
|
public void onPlayingMetaChanged() {
|
||||||
super.onPlayingMetaChanged();
|
super.onPlayingMetaChanged();
|
||||||
|
|
@ -297,31 +241,6 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
||||||
handlePlaybackIntent(getIntent());
|
handlePlaybackIntent(getIntent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(@NonNull Menu menu) {
|
|
||||||
getMenuInflater().inflate(R.menu.menu_main, menu);
|
|
||||||
if (isPlaylistPage()) {
|
|
||||||
menu.add(0, R.id.action_new_playlist, 0, R.string.new_playlist_title);
|
|
||||||
}
|
|
||||||
Fragment currentFragment = getCurrentFragment();
|
|
||||||
if (currentFragment instanceof AbsMainActivityRecyclerViewCustomGridSizeFragment && currentFragment.isAdded()) {
|
|
||||||
AbsMainActivityRecyclerViewCustomGridSizeFragment absMainActivityRecyclerViewCustomGridSizeFragment = (AbsMainActivityRecyclerViewCustomGridSizeFragment) currentFragment;
|
|
||||||
|
|
||||||
MenuItem gridSizeItem = menu.findItem(R.id.action_grid_size);
|
|
||||||
if (Util.isLandscape(getResources())) {
|
|
||||||
gridSizeItem.setTitle(R.string.action_grid_size_land);
|
|
||||||
}
|
|
||||||
setUpGridSizeMenu(absMainActivityRecyclerViewCustomGridSizeFragment, gridSizeItem.getSubMenu());
|
|
||||||
|
|
||||||
menu.findItem(R.id.action_colored_footers).setChecked(absMainActivityRecyclerViewCustomGridSizeFragment.usePalette());
|
|
||||||
menu.findItem(R.id.action_colored_footers).setEnabled(absMainActivityRecyclerViewCustomGridSizeFragment.canUsePalette());
|
|
||||||
} else {
|
|
||||||
menu.removeItem(R.id.action_grid_size);
|
|
||||||
menu.removeItem(R.id.action_colored_footers);
|
|
||||||
}
|
|
||||||
return super.onCreateOptionsMenu(menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
if (item.getItemId() == android.R.id.home) {
|
if (item.getItemId() == android.R.id.home) {
|
||||||
|
|
@ -332,137 +251,15 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Fragment currentFragment = getCurrentFragment();
|
|
||||||
if (currentFragment instanceof AbsMainActivityRecyclerViewCustomGridSizeFragment) {
|
|
||||||
AbsMainActivityRecyclerViewCustomGridSizeFragment absMainActivityRecyclerViewCustomGridSizeFragment = (AbsMainActivityRecyclerViewCustomGridSizeFragment) currentFragment;
|
|
||||||
if (item.getItemId() == R.id.action_colored_footers) {
|
|
||||||
item.setChecked(!item.isChecked());
|
|
||||||
absMainActivityRecyclerViewCustomGridSizeFragment.setAndSaveUsePalette(item.isChecked());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (handleGridSizeMenuItem(absMainActivityRecyclerViewCustomGridSizeFragment, item)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int id = item.getItemId();
|
|
||||||
switch (id) {
|
|
||||||
case R.id.action_sleep_timer:
|
|
||||||
new SleepTimerDialog().show(getSupportFragmentManager(), "SET_SLEEP_TIMER");
|
|
||||||
return true;
|
|
||||||
case R.id.action_equalizer:
|
|
||||||
NavigationUtil.openEqualizer(this);
|
|
||||||
return true;
|
|
||||||
case R.id.action_shuffle_all:
|
|
||||||
MusicPlayerRemote.openAndShuffleQueue(SongLoader.getAllSongs(this), true);
|
|
||||||
return true;
|
|
||||||
case R.id.action_new_playlist:
|
|
||||||
CreatePlaylistDialog.create().show(getSupportFragmentManager(), "CREATE_PLAYLIST");
|
|
||||||
return true;
|
|
||||||
case R.id.action_search:
|
|
||||||
startActivity(new Intent(MainActivity.this, SearchActivity.class));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpGridSizeMenu(@NonNull AbsMainActivityRecyclerViewCustomGridSizeFragment fragment, @NonNull SubMenu gridSizeMenu) {
|
|
||||||
switch (fragment.getGridSize()) {
|
|
||||||
case 1:
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_1).setChecked(true);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_2).setChecked(true);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_3).setChecked(true);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_4).setChecked(true);
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_5).setChecked(true);
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_6).setChecked(true);
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_7).setChecked(true);
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_8).setChecked(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
int maxGridSize = fragment.getMaxGridSize();
|
|
||||||
if (maxGridSize < 8) {
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_8).setVisible(false);
|
|
||||||
}
|
|
||||||
if (maxGridSize < 7) {
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_7).setVisible(false);
|
|
||||||
}
|
|
||||||
if (maxGridSize < 6) {
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_6).setVisible(false);
|
|
||||||
}
|
|
||||||
if (maxGridSize < 5) {
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_5).setVisible(false);
|
|
||||||
}
|
|
||||||
if (maxGridSize < 4) {
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_4).setVisible(false);
|
|
||||||
}
|
|
||||||
if (maxGridSize < 3) {
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_3).setVisible(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean handleGridSizeMenuItem(@NonNull AbsMainActivityRecyclerViewCustomGridSizeFragment fragment, @NonNull MenuItem item) {
|
|
||||||
int gridSize = 0;
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.action_grid_size_1:
|
|
||||||
gridSize = 1;
|
|
||||||
break;
|
|
||||||
case R.id.action_grid_size_2:
|
|
||||||
gridSize = 2;
|
|
||||||
break;
|
|
||||||
case R.id.action_grid_size_3:
|
|
||||||
gridSize = 3;
|
|
||||||
break;
|
|
||||||
case R.id.action_grid_size_4:
|
|
||||||
gridSize = 4;
|
|
||||||
break;
|
|
||||||
case R.id.action_grid_size_5:
|
|
||||||
gridSize = 5;
|
|
||||||
break;
|
|
||||||
case R.id.action_grid_size_6:
|
|
||||||
gridSize = 6;
|
|
||||||
break;
|
|
||||||
case R.id.action_grid_size_7:
|
|
||||||
gridSize = 7;
|
|
||||||
break;
|
|
||||||
case R.id.action_grid_size_8:
|
|
||||||
gridSize = 8;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (gridSize > 0) {
|
|
||||||
item.setChecked(true);
|
|
||||||
fragment.setAndSaveGridSize(gridSize);
|
|
||||||
toolbar.getMenu().findItem(R.id.action_colored_footers).setEnabled(fragment.canUsePalette());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
if (drawerLayout.isDrawerOpen(navigationView)) drawerLayout.closeDrawers();
|
if (drawerLayout.isDrawerOpen(navigationView)) drawerLayout.closeDrawers();
|
||||||
else if (cab != null && cab.isActive()) cab.finish();
|
else if (currentFragment == null || !currentFragment.onBackPressed())
|
||||||
else super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
PreferenceUtil.getInstance(MainActivity.this).setLastStartPage(pager.getCurrentItem());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handlePlaybackIntent(@Nullable Intent intent) {
|
private void handlePlaybackIntent(@Nullable Intent intent) {
|
||||||
|
|
@ -531,37 +328,6 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Fragment getCurrentFragment() {
|
|
||||||
return pagerAdapter.getFragment(pager.getCurrentItem());
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isPlaylistPage() {
|
|
||||||
return pager.getCurrentItem() == MusicLibraryPagerAdapter.MusicFragments.PLAYLIST.ordinal();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MaterialCab openCab(final int menu, final MaterialCab.Callback callback) {
|
|
||||||
if (cab != null && cab.isActive()) cab.finish();
|
|
||||||
cab = new MaterialCab(this, R.id.cab_stub)
|
|
||||||
.setMenu(menu)
|
|
||||||
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
|
|
||||||
.setBackgroundColor(PhonographColorUtil.shiftBackgroundColorForLightText(ThemeStore.primaryColor(this)))
|
|
||||||
.start(callback);
|
|
||||||
return cab;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addOnAppBarOffsetChangedListener(OnOffsetChangedListener onOffsetChangedListener) {
|
|
||||||
appbar.addOnOffsetChangedListener(onOffsetChangedListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeOnAppBarOffsetChangedListener(OnOffsetChangedListener onOffsetChangedListener) {
|
|
||||||
appbar.removeOnOffsetChangedListener(onOffsetChangedListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTotalAppBarScrollingRange() {
|
|
||||||
return appbar.getTotalScrollRange();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPanelExpanded(View view) {
|
public void onPanelExpanded(View view) {
|
||||||
super.onPanelExpanded(view);
|
super.onPanelExpanded(view);
|
||||||
|
|
@ -574,16 +340,34 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
||||||
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
|
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkShowChangelog() {
|
private boolean checkShowIntro() {
|
||||||
|
if (!PreferenceUtil.getInstance(this).introShown()) {
|
||||||
|
PreferenceUtil.getInstance(this).setIntroShown();
|
||||||
|
ChangelogDialog.setChangelogRead(this);
|
||||||
|
blockRequestPermissions = true;
|
||||||
|
new Handler().postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
startActivityForResult(new Intent(MainActivity.this, AppIntroActivity.class), APP_INTRO_REQUEST);
|
||||||
|
}
|
||||||
|
}, 50);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkShowChangelog() {
|
||||||
try {
|
try {
|
||||||
PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
|
PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||||
int currentVersion = pInfo.versionCode;
|
int currentVersion = pInfo.versionCode;
|
||||||
if (currentVersion != PreferenceUtil.getInstance(this).getLastChangelogVersion()) {
|
if (currentVersion != PreferenceUtil.getInstance(this).getLastChangelogVersion()) {
|
||||||
ChangelogDialog.create().show(getSupportFragmentManager(), "CHANGE_LOG_DIALOG");
|
ChangelogDialog.create().show(getSupportFragmentManager(), "CHANGE_LOG_DIALOG");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -605,4 +389,8 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
||||||
public void onDrawerStateChanged(int newState) {
|
public void onDrawerStateChanged(int newState) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface MainActivityFragmentCallbacks {
|
||||||
|
boolean onBackPressed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -71,18 +71,6 @@ public class SearchActivity extends AbsMusicServiceActivity implements SearchVie
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enableViews() {
|
|
||||||
super.enableViews();
|
|
||||||
recyclerView.setEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void disableViews() {
|
|
||||||
super.disableViews();
|
|
||||||
recyclerView.setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.menu_search, menu);
|
getMenuInflater().inflate(R.menu.menu_search, menu);
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,11 @@ import android.view.View;
|
||||||
|
|
||||||
import com.kabouzeid.appthemehelper.ThemeStore;
|
import com.kabouzeid.appthemehelper.ThemeStore;
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Karim Abou Zeid (kabouzeid)
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public abstract class AbsBaseActivity extends AbsThemeActivity implements KabViewsDisableAble {
|
public abstract class AbsBaseActivity extends AbsThemeActivity {
|
||||||
public static final int PERMISSION_REQUEST = 100;
|
public static final int PERMISSION_REQUEST = 100;
|
||||||
|
|
||||||
private boolean areViewsEnabled;
|
private boolean areViewsEnabled;
|
||||||
|
|
@ -54,7 +53,6 @@ public abstract class AbsBaseActivity extends AbsThemeActivity implements KabVie
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
enableViews();
|
|
||||||
|
|
||||||
if (hasPermissions() != createdWithPermissionsGranted) {
|
if (hasPermissions() != createdWithPermissionsGranted) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
|
@ -88,31 +86,6 @@ public abstract class AbsBaseActivity extends AbsThemeActivity implements KabVie
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Should be overwritten and re enable all {@link android.view.View} to ensure they are accessible again
|
|
||||||
* <p/>
|
|
||||||
* This is necessary because of a bug with the shared element transition
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void enableViews() {
|
|
||||||
areViewsEnabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Should be overwritten and disable all views that start a new activity on click to prevent opening an activity multiple times
|
|
||||||
* <p/>
|
|
||||||
* This is necessary because of a bug with the shared element transition
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void disableViews() {
|
|
||||||
areViewsEnabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean areViewsEnabled() {
|
|
||||||
return areViewsEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
protected String[] getPermissionsToRequest() {
|
protected String[] getPermissionsToRequest() {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.kabouzeid.gramophone.ui.fragments;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
|
||||||
|
import com.kabouzeid.gramophone.ui.activities.MainActivity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
|
*/
|
||||||
|
public abstract class AbsMainActivityFragment extends Fragment {
|
||||||
|
|
||||||
|
public MainActivity getMainActivity() {
|
||||||
|
return (MainActivity) getActivity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.kabouzeid.gramophone.ui.fragments;
|
||||||
|
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import com.kabouzeid.gramophone.R;
|
||||||
|
import com.kabouzeid.gramophone.ui.activities.MainActivity;
|
||||||
|
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
||||||
|
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
|
public class FolderFragment extends AbsMainActivityFragment implements MainActivity.MainActivityFragmentCallbacks {
|
||||||
|
public static final String TAG = FolderFragment.class.getSimpleName();
|
||||||
|
|
||||||
|
public FolderFragment() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.fragment_folder, container, false);
|
||||||
|
ButterKnife.bind(this, view);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||||
|
PreferenceUtil.getInstance(getActivity()).setLastPage(-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
ButterKnife.unbind(this);
|
||||||
|
super.onDestroyView();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBackPressed() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,313 @@
|
||||||
|
package com.kabouzeid.gramophone.ui.fragments;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.design.widget.AppBarLayout;
|
||||||
|
import android.support.design.widget.TabLayout;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.view.ViewPager;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.SubMenu;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import com.afollestad.materialcab.MaterialCab;
|
||||||
|
import com.kabouzeid.appthemehelper.ThemeStore;
|
||||||
|
import com.kabouzeid.appthemehelper.util.TabLayoutUtil;
|
||||||
|
import com.kabouzeid.appthemehelper.util.ToolbarContentTintHelper;
|
||||||
|
import com.kabouzeid.gramophone.R;
|
||||||
|
import com.kabouzeid.gramophone.adapter.MusicLibraryPagerAdapter;
|
||||||
|
import com.kabouzeid.gramophone.dialogs.CreatePlaylistDialog;
|
||||||
|
import com.kabouzeid.gramophone.dialogs.SleepTimerDialog;
|
||||||
|
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||||
|
import com.kabouzeid.gramophone.interfaces.CabHolder;
|
||||||
|
import com.kabouzeid.gramophone.loader.SongLoader;
|
||||||
|
import com.kabouzeid.gramophone.ui.activities.MainActivity;
|
||||||
|
import com.kabouzeid.gramophone.ui.activities.SearchActivity;
|
||||||
|
import com.kabouzeid.gramophone.ui.fragments.libraryfragments.AbsLibraryRecyclerViewCustomGridSizePagerFragment;
|
||||||
|
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||||
|
import com.kabouzeid.gramophone.util.PhonographColorUtil;
|
||||||
|
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
||||||
|
import com.kabouzeid.gramophone.util.Util;
|
||||||
|
|
||||||
|
import butterknife.Bind;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
|
public class LibraryFragment extends AbsMainActivityFragment implements CabHolder, MainActivity.MainActivityFragmentCallbacks, ViewPager.OnPageChangeListener {
|
||||||
|
public static final String TAG = LibraryFragment.class.getSimpleName();
|
||||||
|
|
||||||
|
@Bind(R.id.toolbar)
|
||||||
|
Toolbar toolbar;
|
||||||
|
@Bind(R.id.tabs)
|
||||||
|
TabLayout tabs;
|
||||||
|
@Bind(R.id.appbar)
|
||||||
|
AppBarLayout appbar;
|
||||||
|
@Bind(R.id.pager)
|
||||||
|
ViewPager pager;
|
||||||
|
|
||||||
|
private MusicLibraryPagerAdapter pagerAdapter;
|
||||||
|
private MaterialCab cab;
|
||||||
|
|
||||||
|
public LibraryFragment() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.fragment_library, container, false);
|
||||||
|
ButterKnife.bind(this, view);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
pager.removeOnPageChangeListener(this);
|
||||||
|
ButterKnife.unbind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||||
|
getMainActivity().setStatusbarColorAuto();
|
||||||
|
getMainActivity().setNavigationbarColorAuto();
|
||||||
|
getMainActivity().setTaskDescriptionColorAuto();
|
||||||
|
|
||||||
|
setUpToolbar();
|
||||||
|
setUpViewPager();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setUpToolbar() {
|
||||||
|
int primaryColor = ThemeStore.primaryColor(getActivity());
|
||||||
|
appbar.setBackgroundColor(primaryColor);
|
||||||
|
toolbar.setBackgroundColor(primaryColor);
|
||||||
|
toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
|
||||||
|
getActivity().setTitle(getResources().getString(R.string.app_name));
|
||||||
|
getMainActivity().setSupportActionBar(toolbar);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setUpViewPager() {
|
||||||
|
pagerAdapter = new MusicLibraryPagerAdapter(getActivity(), getChildFragmentManager());
|
||||||
|
pager.setAdapter(pagerAdapter);
|
||||||
|
pager.setOffscreenPageLimit(pagerAdapter.getCount() - 1);
|
||||||
|
|
||||||
|
tabs.setupWithViewPager(pager);
|
||||||
|
|
||||||
|
int primaryColor = ThemeStore.primaryColor(getActivity());
|
||||||
|
int normalColor = ToolbarContentTintHelper.toolbarSubtitleColor(getActivity(), primaryColor);
|
||||||
|
int selectedColor = ToolbarContentTintHelper.toolbarTitleColor(getActivity(), primaryColor);
|
||||||
|
TabLayoutUtil.setTabIconColors(tabs, normalColor, selectedColor);
|
||||||
|
tabs.setTabTextColors(normalColor, selectedColor);
|
||||||
|
tabs.setSelectedTabIndicatorColor(ThemeStore.accentColor(getActivity()));
|
||||||
|
|
||||||
|
int startPosition = PreferenceUtil.getInstance(getActivity()).getDefaultStartPage();
|
||||||
|
startPosition = startPosition == -1 ? PreferenceUtil.getInstance(getActivity()).getLastPage() : startPosition;
|
||||||
|
pager.setCurrentItem(startPosition);
|
||||||
|
PreferenceUtil.getInstance(getActivity()).setLastPage(startPosition); // just in case
|
||||||
|
pager.addOnPageChangeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Fragment getCurrentFragment() {
|
||||||
|
return pagerAdapter.getFragment(pager.getCurrentItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isPlaylistPage() {
|
||||||
|
return pager.getCurrentItem() == MusicLibraryPagerAdapter.MusicFragments.PLAYLIST.ordinal();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MaterialCab openCab(final int menu, final MaterialCab.Callback callback) {
|
||||||
|
if (cab != null && cab.isActive()) cab.finish();
|
||||||
|
cab = new MaterialCab(getMainActivity(), R.id.cab_stub)
|
||||||
|
.setMenu(menu)
|
||||||
|
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
|
||||||
|
.setBackgroundColor(PhonographColorUtil.shiftBackgroundColorForLightText(ThemeStore.primaryColor(getActivity())))
|
||||||
|
.start(callback);
|
||||||
|
return cab;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addOnAppBarOffsetChangedListener(AppBarLayout.OnOffsetChangedListener onOffsetChangedListener) {
|
||||||
|
appbar.addOnOffsetChangedListener(onOffsetChangedListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeOnAppBarOffsetChangedListener(AppBarLayout.OnOffsetChangedListener onOffsetChangedListener) {
|
||||||
|
appbar.removeOnOffsetChangedListener(onOffsetChangedListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTotalAppBarScrollingRange() {
|
||||||
|
return appbar.getTotalScrollRange();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
inflater.inflate(R.menu.menu_main, menu);
|
||||||
|
if (isPlaylistPage()) {
|
||||||
|
menu.add(0, R.id.action_new_playlist, 0, R.string.new_playlist_title);
|
||||||
|
}
|
||||||
|
Fragment currentFragment = getCurrentFragment();
|
||||||
|
if (currentFragment instanceof AbsLibraryRecyclerViewCustomGridSizePagerFragment && currentFragment.isAdded()) {
|
||||||
|
AbsLibraryRecyclerViewCustomGridSizePagerFragment absLibraryRecyclerViewCustomGridSizeFragment = (AbsLibraryRecyclerViewCustomGridSizePagerFragment) currentFragment;
|
||||||
|
|
||||||
|
MenuItem gridSizeItem = menu.findItem(R.id.action_grid_size);
|
||||||
|
if (Util.isLandscape(getResources())) {
|
||||||
|
gridSizeItem.setTitle(R.string.action_grid_size_land);
|
||||||
|
}
|
||||||
|
setUpGridSizeMenu(absLibraryRecyclerViewCustomGridSizeFragment, gridSizeItem.getSubMenu());
|
||||||
|
|
||||||
|
menu.findItem(R.id.action_colored_footers).setChecked(absLibraryRecyclerViewCustomGridSizeFragment.usePalette());
|
||||||
|
menu.findItem(R.id.action_colored_footers).setEnabled(absLibraryRecyclerViewCustomGridSizeFragment.canUsePalette());
|
||||||
|
} else {
|
||||||
|
menu.removeItem(R.id.action_grid_size);
|
||||||
|
menu.removeItem(R.id.action_colored_footers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
|
Fragment currentFragment = getCurrentFragment();
|
||||||
|
if (currentFragment instanceof AbsLibraryRecyclerViewCustomGridSizePagerFragment) {
|
||||||
|
AbsLibraryRecyclerViewCustomGridSizePagerFragment absLibraryRecyclerViewCustomGridSizeFragment = (AbsLibraryRecyclerViewCustomGridSizePagerFragment) currentFragment;
|
||||||
|
if (item.getItemId() == R.id.action_colored_footers) {
|
||||||
|
item.setChecked(!item.isChecked());
|
||||||
|
absLibraryRecyclerViewCustomGridSizeFragment.setAndSaveUsePalette(item.isChecked());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (handleGridSizeMenuItem(absLibraryRecyclerViewCustomGridSizeFragment, item)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int id = item.getItemId();
|
||||||
|
switch (id) {
|
||||||
|
case R.id.action_sleep_timer:
|
||||||
|
new SleepTimerDialog().show(getChildFragmentManager(), "SET_SLEEP_TIMER");
|
||||||
|
return true;
|
||||||
|
case R.id.action_equalizer:
|
||||||
|
NavigationUtil.openEqualizer(getActivity());
|
||||||
|
return true;
|
||||||
|
case R.id.action_shuffle_all:
|
||||||
|
MusicPlayerRemote.openAndShuffleQueue(SongLoader.getAllSongs(getActivity()), true);
|
||||||
|
return true;
|
||||||
|
case R.id.action_new_playlist:
|
||||||
|
CreatePlaylistDialog.create().show(getChildFragmentManager(), "CREATE_PLAYLIST");
|
||||||
|
return true;
|
||||||
|
case R.id.action_search:
|
||||||
|
startActivity(new Intent(getActivity(), SearchActivity.class));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setUpGridSizeMenu(@NonNull AbsLibraryRecyclerViewCustomGridSizePagerFragment fragment, @NonNull SubMenu gridSizeMenu) {
|
||||||
|
switch (fragment.getGridSize()) {
|
||||||
|
case 1:
|
||||||
|
gridSizeMenu.findItem(R.id.action_grid_size_1).setChecked(true);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
gridSizeMenu.findItem(R.id.action_grid_size_2).setChecked(true);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
gridSizeMenu.findItem(R.id.action_grid_size_3).setChecked(true);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
gridSizeMenu.findItem(R.id.action_grid_size_4).setChecked(true);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
gridSizeMenu.findItem(R.id.action_grid_size_5).setChecked(true);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
gridSizeMenu.findItem(R.id.action_grid_size_6).setChecked(true);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
gridSizeMenu.findItem(R.id.action_grid_size_7).setChecked(true);
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
gridSizeMenu.findItem(R.id.action_grid_size_8).setChecked(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
int maxGridSize = fragment.getMaxGridSize();
|
||||||
|
if (maxGridSize < 8) {
|
||||||
|
gridSizeMenu.findItem(R.id.action_grid_size_8).setVisible(false);
|
||||||
|
}
|
||||||
|
if (maxGridSize < 7) {
|
||||||
|
gridSizeMenu.findItem(R.id.action_grid_size_7).setVisible(false);
|
||||||
|
}
|
||||||
|
if (maxGridSize < 6) {
|
||||||
|
gridSizeMenu.findItem(R.id.action_grid_size_6).setVisible(false);
|
||||||
|
}
|
||||||
|
if (maxGridSize < 5) {
|
||||||
|
gridSizeMenu.findItem(R.id.action_grid_size_5).setVisible(false);
|
||||||
|
}
|
||||||
|
if (maxGridSize < 4) {
|
||||||
|
gridSizeMenu.findItem(R.id.action_grid_size_4).setVisible(false);
|
||||||
|
}
|
||||||
|
if (maxGridSize < 3) {
|
||||||
|
gridSizeMenu.findItem(R.id.action_grid_size_3).setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean handleGridSizeMenuItem(@NonNull AbsLibraryRecyclerViewCustomGridSizePagerFragment fragment, @NonNull MenuItem item) {
|
||||||
|
int gridSize = 0;
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.action_grid_size_1:
|
||||||
|
gridSize = 1;
|
||||||
|
break;
|
||||||
|
case R.id.action_grid_size_2:
|
||||||
|
gridSize = 2;
|
||||||
|
break;
|
||||||
|
case R.id.action_grid_size_3:
|
||||||
|
gridSize = 3;
|
||||||
|
break;
|
||||||
|
case R.id.action_grid_size_4:
|
||||||
|
gridSize = 4;
|
||||||
|
break;
|
||||||
|
case R.id.action_grid_size_5:
|
||||||
|
gridSize = 5;
|
||||||
|
break;
|
||||||
|
case R.id.action_grid_size_6:
|
||||||
|
gridSize = 6;
|
||||||
|
break;
|
||||||
|
case R.id.action_grid_size_7:
|
||||||
|
gridSize = 7;
|
||||||
|
break;
|
||||||
|
case R.id.action_grid_size_8:
|
||||||
|
gridSize = 8;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (gridSize > 0) {
|
||||||
|
item.setChecked(true);
|
||||||
|
fragment.setAndSaveGridSize(gridSize);
|
||||||
|
toolbar.getMenu().findItem(R.id.action_colored_footers).setEnabled(fragment.canUsePalette());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBackPressed() {
|
||||||
|
if (cab != null && cab.isActive()) {
|
||||||
|
cab.finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageSelected(int position) {
|
||||||
|
PreferenceUtil.getInstance(getActivity()).setLastPage(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrollStateChanged(int state) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.kabouzeid.gramophone.ui.fragments.libraryfragments;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
|
||||||
|
import com.kabouzeid.gramophone.ui.fragments.LibraryFragment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
|
*/
|
||||||
|
public class AbsLibraryPagerFragment extends Fragment {
|
||||||
|
|
||||||
|
public LibraryFragment getLibraryFragment() {
|
||||||
|
return (LibraryFragment) getParentFragment();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.kabouzeid.gramophone.ui.fragments.mainactivityfragments;
|
package com.kabouzeid.gramophone.ui.fragments.libraryfragments;
|
||||||
|
|
||||||
import android.support.annotation.LayoutRes;
|
import android.support.annotation.LayoutRes;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
|
@ -9,7 +9,7 @@ import com.kabouzeid.gramophone.util.Util;
|
||||||
/**
|
/**
|
||||||
* @author Karim Abou Zeid (kabouzeid)
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public abstract class AbsMainActivityRecyclerViewCustomGridSizeFragment<A extends RecyclerView.Adapter, LM extends RecyclerView.LayoutManager> extends AbsMainActivityRecyclerViewFragment<A, LM> {
|
public abstract class AbsLibraryRecyclerViewCustomGridSizePagerFragment<A extends RecyclerView.Adapter, LM extends RecyclerView.LayoutManager> extends AbsLibraryRecyclerViewPagerFragment<A, LM> {
|
||||||
private int gridSize;
|
private int gridSize;
|
||||||
|
|
||||||
private boolean usePaletteInitialized;
|
private boolean usePaletteInitialized;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.kabouzeid.gramophone.ui.fragments.mainactivityfragments;
|
package com.kabouzeid.gramophone.ui.fragments.libraryfragments;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.LayoutRes;
|
import android.support.annotation.LayoutRes;
|
||||||
|
|
@ -27,9 +27,9 @@ import butterknife.ButterKnife;
|
||||||
/**
|
/**
|
||||||
* @author Karim Abou Zeid (kabouzeid)
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public abstract class AbsMainActivityRecyclerViewFragment<A extends RecyclerView.Adapter, LM extends RecyclerView.LayoutManager> extends AbsMainActivityFragment implements OnOffsetChangedListener, MusicServiceEventListener {
|
public abstract class AbsLibraryRecyclerViewPagerFragment<A extends RecyclerView.Adapter, LM extends RecyclerView.LayoutManager> extends AbsLibraryPagerFragment implements OnOffsetChangedListener, MusicServiceEventListener {
|
||||||
|
|
||||||
public static final String TAG = AbsMainActivityRecyclerViewFragment.class.getSimpleName();
|
public static final String TAG = AbsLibraryRecyclerViewPagerFragment.class.getSimpleName();
|
||||||
|
|
||||||
@Bind(R.id.container)
|
@Bind(R.id.container)
|
||||||
View container;
|
View container;
|
||||||
|
|
@ -53,8 +53,8 @@ public abstract class AbsMainActivityRecyclerViewFragment<A extends RecyclerView
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
getMainActivity().addOnAppBarOffsetChangedListener(this);
|
getLibraryFragment().addOnAppBarOffsetChangedListener(this);
|
||||||
getMainActivity().addMusicServiceEventListener(this);
|
getLibraryFragment().getMainActivity().addMusicServiceEventListener(this);
|
||||||
|
|
||||||
setUpRecyclerView();
|
setUpRecyclerView();
|
||||||
|
|
||||||
|
|
@ -104,7 +104,7 @@ public abstract class AbsMainActivityRecyclerViewFragment<A extends RecyclerView
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onOffsetChanged(AppBarLayout appBarLayout, int i) {
|
public void onOffsetChanged(AppBarLayout appBarLayout, int i) {
|
||||||
container.setPadding(container.getPaddingLeft(), container.getPaddingTop(), container.getPaddingRight(), getMainActivity().getTotalAppBarScrollingRange() + i);
|
container.setPadding(container.getPaddingLeft(), container.getPaddingTop(), container.getPaddingRight(), getLibraryFragment().getTotalAppBarScrollingRange() + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -132,18 +132,6 @@ public abstract class AbsMainActivityRecyclerViewFragment<A extends RecyclerView
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enableViews() {
|
|
||||||
super.enableViews();
|
|
||||||
recyclerView.setEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void disableViews() {
|
|
||||||
super.disableViews();
|
|
||||||
recyclerView.setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkIsEmpty() {
|
private void checkIsEmpty() {
|
||||||
if (empty != null) {
|
if (empty != null) {
|
||||||
RecyclerView.Adapter adapter = getAdapter();
|
RecyclerView.Adapter adapter = getAdapter();
|
||||||
|
|
@ -171,8 +159,8 @@ public abstract class AbsMainActivityRecyclerViewFragment<A extends RecyclerView
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
getMainActivity().removeOnAppBarOffsetChangedListener(this);
|
getLibraryFragment().removeOnAppBarOffsetChangedListener(this);
|
||||||
getMainActivity().removeMusicServiceEventListener(this);
|
getLibraryFragment().getMainActivity().removeMusicServiceEventListener(this);
|
||||||
ButterKnife.unbind(this);
|
ButterKnife.unbind(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.kabouzeid.gramophone.ui.fragments.mainactivityfragments;
|
package com.kabouzeid.gramophone.ui.fragments.libraryfragments;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v7.widget.GridLayoutManager;
|
import android.support.v7.widget.GridLayoutManager;
|
||||||
|
|
@ -11,8 +11,8 @@ import com.kabouzeid.gramophone.util.PreferenceUtil;
|
||||||
/**
|
/**
|
||||||
* @author Karim Abou Zeid (kabouzeid)
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class AlbumsFragment extends AbsMainActivityRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager> {
|
public class AlbumsPagerFragment extends AbsLibraryRecyclerViewCustomGridSizePagerFragment<AlbumAdapter, GridLayoutManager> {
|
||||||
public static final String TAG = AlbumsFragment.class.getSimpleName();
|
public static final String TAG = AlbumsPagerFragment.class.getSimpleName();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected GridLayoutManager createLayoutManager() {
|
protected GridLayoutManager createLayoutManager() {
|
||||||
|
|
@ -25,11 +25,11 @@ public class AlbumsFragment extends AbsMainActivityRecyclerViewCustomGridSizeFra
|
||||||
int itemLayoutRes = getItemLayoutRes();
|
int itemLayoutRes = getItemLayoutRes();
|
||||||
applyRecyclerViewPaddingForLayoutRes(itemLayoutRes);
|
applyRecyclerViewPaddingForLayoutRes(itemLayoutRes);
|
||||||
return new AlbumAdapter(
|
return new AlbumAdapter(
|
||||||
getMainActivity(),
|
getLibraryFragment().getMainActivity(),
|
||||||
AlbumLoader.getAllAlbums(getActivity()),
|
AlbumLoader.getAllAlbums(getActivity()),
|
||||||
itemLayoutRes,
|
itemLayoutRes,
|
||||||
loadUsePalette(),
|
loadUsePalette(),
|
||||||
getMainActivity());
|
getLibraryFragment());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.kabouzeid.gramophone.ui.fragments.mainactivityfragments;
|
package com.kabouzeid.gramophone.ui.fragments.libraryfragments;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v7.widget.GridLayoutManager;
|
import android.support.v7.widget.GridLayoutManager;
|
||||||
|
|
@ -11,9 +11,9 @@ import com.kabouzeid.gramophone.util.PreferenceUtil;
|
||||||
/**
|
/**
|
||||||
* @author Karim Abou Zeid (kabouzeid)
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class ArtistsFragment extends AbsMainActivityRecyclerViewCustomGridSizeFragment<ArtistAdapter, GridLayoutManager> {
|
public class ArtistsPagerFragment extends AbsLibraryRecyclerViewCustomGridSizePagerFragment<ArtistAdapter, GridLayoutManager> {
|
||||||
|
|
||||||
public static final String TAG = ArtistsFragment.class.getSimpleName();
|
public static final String TAG = ArtistsPagerFragment.class.getSimpleName();
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -27,11 +27,11 @@ public class ArtistsFragment extends AbsMainActivityRecyclerViewCustomGridSizeFr
|
||||||
int itemLayoutRes = getItemLayoutRes();
|
int itemLayoutRes = getItemLayoutRes();
|
||||||
applyRecyclerViewPaddingForLayoutRes(itemLayoutRes);
|
applyRecyclerViewPaddingForLayoutRes(itemLayoutRes);
|
||||||
return new ArtistAdapter(
|
return new ArtistAdapter(
|
||||||
getMainActivity(),
|
getLibraryFragment().getMainActivity(),
|
||||||
ArtistLoader.getAllArtists(getActivity()),
|
ArtistLoader.getAllArtists(getActivity()),
|
||||||
itemLayoutRes,
|
itemLayoutRes,
|
||||||
loadUsePalette(),
|
loadUsePalette(),
|
||||||
getMainActivity());
|
getLibraryFragment());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.kabouzeid.gramophone.ui.fragments.mainactivityfragments;
|
package com.kabouzeid.gramophone.ui.fragments.libraryfragments;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
|
@ -16,9 +16,9 @@ import java.util.ArrayList;
|
||||||
/**
|
/**
|
||||||
* @author Karim Abou Zeid (kabouzeid)
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class PlaylistsFragment extends AbsMainActivityRecyclerViewFragment<PlaylistAdapter, LinearLayoutManager> {
|
public class PlaylistsPagerFragment extends AbsLibraryRecyclerViewPagerFragment<PlaylistAdapter, LinearLayoutManager> {
|
||||||
|
|
||||||
public static final String TAG = PlaylistsFragment.class.getSimpleName();
|
public static final String TAG = PlaylistsPagerFragment.class.getSimpleName();
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -29,7 +29,7 @@ public class PlaylistsFragment extends AbsMainActivityRecyclerViewFragment<Playl
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected PlaylistAdapter createAdapter() {
|
protected PlaylistAdapter createAdapter() {
|
||||||
return new PlaylistAdapter(getMainActivity(), getAllPlaylists(), R.layout.item_list_single_row, getMainActivity());
|
return new PlaylistAdapter(getLibraryFragment().getMainActivity(), getAllPlaylists(), R.layout.item_list_single_row, getLibraryFragment());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.kabouzeid.gramophone.ui.fragments.mainactivityfragments;
|
package com.kabouzeid.gramophone.ui.fragments.libraryfragments;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v7.widget.GridLayoutManager;
|
import android.support.v7.widget.GridLayoutManager;
|
||||||
|
|
@ -8,7 +8,6 @@ import com.kabouzeid.gramophone.adapter.song.ShuffleButtonSongAdapter;
|
||||||
import com.kabouzeid.gramophone.adapter.song.SongAdapter;
|
import com.kabouzeid.gramophone.adapter.song.SongAdapter;
|
||||||
import com.kabouzeid.gramophone.loader.SongLoader;
|
import com.kabouzeid.gramophone.loader.SongLoader;
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
import com.kabouzeid.gramophone.model.Song;
|
||||||
import com.kabouzeid.gramophone.ui.activities.MainActivity;
|
|
||||||
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -16,9 +15,9 @@ import java.util.ArrayList;
|
||||||
/**
|
/**
|
||||||
* @author Karim Abou Zeid (kabouzeid)
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class SongsFragment extends AbsMainActivityRecyclerViewCustomGridSizeFragment<SongAdapter, GridLayoutManager> {
|
public class SongsPagerFragment extends AbsLibraryRecyclerViewCustomGridSizePagerFragment<SongAdapter, GridLayoutManager> {
|
||||||
|
|
||||||
public static final String TAG = SongsFragment.class.getSimpleName();
|
public static final String TAG = SongsPagerFragment.class.getSimpleName();
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -29,7 +28,6 @@ public class SongsFragment extends AbsMainActivityRecyclerViewCustomGridSizeFrag
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected SongAdapter createAdapter() {
|
protected SongAdapter createAdapter() {
|
||||||
MainActivity mainActivity = getMainActivity();
|
|
||||||
ArrayList<Song> songs = SongLoader.getAllSongs(getActivity());
|
ArrayList<Song> songs = SongLoader.getAllSongs(getActivity());
|
||||||
int itemLayoutRes = getItemLayoutRes();
|
int itemLayoutRes = getItemLayoutRes();
|
||||||
applyRecyclerViewPaddingForLayoutRes(itemLayoutRes);
|
applyRecyclerViewPaddingForLayoutRes(itemLayoutRes);
|
||||||
|
|
@ -37,18 +35,18 @@ public class SongsFragment extends AbsMainActivityRecyclerViewCustomGridSizeFrag
|
||||||
|
|
||||||
if (getGridSize() <= getMaxGridSizeForList()) {
|
if (getGridSize() <= getMaxGridSizeForList()) {
|
||||||
return new ShuffleButtonSongAdapter(
|
return new ShuffleButtonSongAdapter(
|
||||||
mainActivity,
|
getLibraryFragment().getMainActivity(),
|
||||||
songs,
|
songs,
|
||||||
itemLayoutRes,
|
itemLayoutRes,
|
||||||
usePalette,
|
usePalette,
|
||||||
mainActivity);
|
getLibraryFragment());
|
||||||
}
|
}
|
||||||
return new SongAdapter(
|
return new SongAdapter(
|
||||||
mainActivity,
|
getLibraryFragment().getMainActivity(),
|
||||||
songs,
|
songs,
|
||||||
itemLayoutRes,
|
itemLayoutRes,
|
||||||
usePalette,
|
usePalette,
|
||||||
mainActivity);
|
getLibraryFragment());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
package com.kabouzeid.gramophone.ui.fragments.mainactivityfragments;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
|
|
||||||
import com.kabouzeid.gramophone.ui.activities.MainActivity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Karim Abou Zeid (kabouzeid)
|
|
||||||
*/
|
|
||||||
public abstract class AbsMainActivityFragment extends Fragment implements KabViewsDisableAble {
|
|
||||||
private boolean areViewsEnabled;
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
protected MainActivity getMainActivity() {
|
|
||||||
return (MainActivity) getActivity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enableViews() {
|
|
||||||
areViewsEnabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void disableViews() {
|
|
||||||
areViewsEnabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean areViewsEnabled() {
|
|
||||||
return areViewsEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
enableViews();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
|
||||||
super.onActivityCreated(savedInstanceState);
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -12,7 +12,6 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||||
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
|
|
||||||
import com.kabouzeid.gramophone.model.Playlist;
|
import com.kabouzeid.gramophone.model.Playlist;
|
||||||
import com.kabouzeid.gramophone.ui.activities.AlbumDetailActivity;
|
import com.kabouzeid.gramophone.ui.activities.AlbumDetailActivity;
|
||||||
import com.kabouzeid.gramophone.ui.activities.ArtistDetailActivity;
|
import com.kabouzeid.gramophone.ui.activities.ArtistDetailActivity;
|
||||||
|
|
@ -24,8 +23,6 @@ import com.kabouzeid.gramophone.ui.activities.PlaylistDetailActivity;
|
||||||
public class NavigationUtil {
|
public class NavigationUtil {
|
||||||
|
|
||||||
public static void goToArtist(@NonNull final Activity activity, final int artistId, @Nullable Pair... sharedElements) {
|
public static void goToArtist(@NonNull final Activity activity, final int artistId, @Nullable Pair... sharedElements) {
|
||||||
if (!disableViewsAndCheckIsReadyForTransition(activity)) return;
|
|
||||||
|
|
||||||
final Intent intent = new Intent(activity, ArtistDetailActivity.class);
|
final Intent intent = new Intent(activity, ArtistDetailActivity.class);
|
||||||
intent.putExtra(ArtistDetailActivity.EXTRA_ARTIST_ID, artistId);
|
intent.putExtra(ArtistDetailActivity.EXTRA_ARTIST_ID, artistId);
|
||||||
|
|
||||||
|
|
@ -34,8 +31,6 @@ public class NavigationUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void goToAlbum(@NonNull final Activity activity, final int albumId, @Nullable Pair... sharedElements) {
|
public static void goToAlbum(@NonNull final Activity activity, final int albumId, @Nullable Pair... sharedElements) {
|
||||||
if (!disableViewsAndCheckIsReadyForTransition(activity)) return;
|
|
||||||
|
|
||||||
final Intent intent = new Intent(activity, AlbumDetailActivity.class);
|
final Intent intent = new Intent(activity, AlbumDetailActivity.class);
|
||||||
intent.putExtra(AlbumDetailActivity.EXTRA_ALBUM_ID, albumId);
|
intent.putExtra(AlbumDetailActivity.EXTRA_ALBUM_ID, albumId);
|
||||||
|
|
||||||
|
|
@ -44,24 +39,12 @@ public class NavigationUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void goToPlaylist(@NonNull final Activity activity, final Playlist playlist, @Nullable Pair... sharedElements) {
|
public static void goToPlaylist(@NonNull final Activity activity, final Playlist playlist, @Nullable Pair... sharedElements) {
|
||||||
if (!disableViewsAndCheckIsReadyForTransition(activity)) return;
|
|
||||||
|
|
||||||
final Intent intent = new Intent(activity, PlaylistDetailActivity.class);
|
final Intent intent = new Intent(activity, PlaylistDetailActivity.class);
|
||||||
intent.putExtra(PlaylistDetailActivity.EXTRA_PLAYLIST, playlist);
|
intent.putExtra(PlaylistDetailActivity.EXTRA_PLAYLIST, playlist);
|
||||||
|
|
||||||
activity.startActivity(intent);
|
activity.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean disableViewsAndCheckIsReadyForTransition(@NonNull final Activity activity) {
|
|
||||||
if (activity instanceof KabViewsDisableAble) {
|
|
||||||
if (((KabViewsDisableAble) activity).areViewsEnabled()) {
|
|
||||||
((KabViewsDisableAble) activity).disableViews();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void openEqualizer(@NonNull final Activity activity) {
|
public static void openEqualizer(@NonNull final Activity activity) {
|
||||||
final int sessionId = MusicPlayerRemote.getAudioSessionId();
|
final int sessionId = MusicPlayerRemote.getAudioSessionId();
|
||||||
if (sessionId == AudioEffect.ERROR_BAD_VALUE) {
|
if (sessionId == AudioEffect.ERROR_BAD_VALUE) {
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,8 @@ import com.kabouzeid.gramophone.helper.SortOrder;
|
||||||
public final class PreferenceUtil {
|
public final class PreferenceUtil {
|
||||||
public static final String GENERAL_THEME = "general_theme";
|
public static final String GENERAL_THEME = "general_theme";
|
||||||
public static final String DEFAULT_START_PAGE = "default_start_page";
|
public static final String DEFAULT_START_PAGE = "default_start_page";
|
||||||
public static final String LAST_START_PAGE = "last_start_page";
|
public static final String LAST_PAGE = "last_start_page";
|
||||||
|
public static final String LAST_MUSIC_CHOOSER = "last_music_chooser";
|
||||||
|
|
||||||
public static final String ARTIST_SORT_ORDER = "artist_sort_order";
|
public static final String ARTIST_SORT_ORDER = "artist_sort_order";
|
||||||
public static final String ARTIST_SONG_SORT_ORDER = "artist_song_sort_order";
|
public static final String ARTIST_SONG_SORT_ORDER = "artist_song_sort_order";
|
||||||
|
|
@ -100,16 +101,24 @@ public final class PreferenceUtil {
|
||||||
return Integer.parseInt(mPreferences.getString(DEFAULT_START_PAGE, "-1"));
|
return Integer.parseInt(mPreferences.getString(DEFAULT_START_PAGE, "-1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLastStartPage(final int value) {
|
public void setLastPage(final int value) {
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||||
editor.putInt(LAST_START_PAGE, value);
|
editor.putInt(LAST_PAGE, value);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final int DEFAULT_PAGE = 0;
|
public final int getLastPage() {
|
||||||
|
return mPreferences.getInt(LAST_PAGE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
public final int getLastStartPage() {
|
public void setLastMusicChooser(final int value) {
|
||||||
return mPreferences.getInt(LAST_START_PAGE, DEFAULT_PAGE);
|
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||||
|
editor.putInt(LAST_MUSIC_CHOOSER, value);
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getLastMusicChooser() {
|
||||||
|
return mPreferences.getInt(LAST_MUSIC_CHOOSER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean coloredNotification() {
|
public final boolean coloredNotification() {
|
||||||
|
|
|
||||||
|
|
@ -1,65 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout android:id="@+id/fragment_container"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent" />
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:elevation="0dp"
|
|
||||||
tools:ignore="UnusedAttribute">
|
|
||||||
|
|
||||||
<include layout="@layout/status_bar" />
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<android.support.design.widget.CoordinatorLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<android.support.design.widget.AppBarLayout
|
|
||||||
android:id="@+id/appbar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
tools:ignore="UnusedAttribute">
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:layout_scrollFlags="scroll|enterAlways">
|
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
|
||||||
android:id="@+id/toolbar"
|
|
||||||
style="@style/Toolbar"
|
|
||||||
android:elevation="0dp"
|
|
||||||
tools:ignore="UnusedAttribute">
|
|
||||||
|
|
||||||
</android.support.v7.widget.Toolbar>
|
|
||||||
|
|
||||||
<ViewStub
|
|
||||||
android:id="@+id/cab_stub"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="?attr/actionBarSize" />
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<android.support.design.widget.TabLayout
|
|
||||||
android:id="@+id/tabs"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/tab_height"
|
|
||||||
app:tabContentStart="72dp"
|
|
||||||
app:tabMode="scrollable" />
|
|
||||||
|
|
||||||
</android.support.design.widget.AppBarLayout>
|
|
||||||
|
|
||||||
<android.support.v4.view.ViewPager
|
|
||||||
android:id="@+id/pager"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
|
||||||
|
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
50
app/src/main/res/layout/fragment_folder.xml
Normal file
50
app/src/main/res/layout/fragment_folder.xml
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:ignore="UnusedAttribute">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<include layout="@layout/status_bar" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:elevation="@dimen/toolbar_elevation"
|
||||||
|
tools:ignore="UnusedAttribute">
|
||||||
|
|
||||||
|
<android.support.v7.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
style="@style/Toolbar"
|
||||||
|
android:background="@android:color/transparent" />
|
||||||
|
|
||||||
|
<ViewStub
|
||||||
|
android:id="@+id/cab_stub"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<android.support.v7.widget.RecyclerView
|
||||||
|
android:id="@+id/recycler_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:scrollbars="vertical" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@android:id/empty"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:fontFamily="sans-serif-light"
|
||||||
|
android:text="Placeholder"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
|
android:textSize="@dimen/empty_text_size" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
66
app/src/main/res/layout/fragment_library.xml
Normal file
66
app/src/main/res/layout/fragment_library.xml
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context="com.kabouzeid.gramophone.ui.fragments.LibraryFragment">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:elevation="0dp"
|
||||||
|
tools:ignore="UnusedAttribute">
|
||||||
|
|
||||||
|
<include layout="@layout/status_bar" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<android.support.design.widget.CoordinatorLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<android.support.design.widget.AppBarLayout
|
||||||
|
android:id="@+id/appbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
tools:ignore="UnusedAttribute">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_scrollFlags="scroll|enterAlways">
|
||||||
|
|
||||||
|
<android.support.v7.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
style="@style/Toolbar"
|
||||||
|
android:elevation="0dp"
|
||||||
|
tools:ignore="UnusedAttribute">
|
||||||
|
|
||||||
|
</android.support.v7.widget.Toolbar>
|
||||||
|
|
||||||
|
<ViewStub
|
||||||
|
android:id="@+id/cab_stub"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<android.support.design.widget.TabLayout
|
||||||
|
android:id="@+id/tabs"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/tab_height"
|
||||||
|
app:tabContentStart="72dp"
|
||||||
|
app:tabMode="scrollable" />
|
||||||
|
|
||||||
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
|
||||||
|
<android.support.v4.view.ViewPager
|
||||||
|
android:id="@+id/pager"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||||
|
|
||||||
|
</android.support.design.widget.CoordinatorLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
@ -9,10 +9,9 @@
|
||||||
android:icon="@drawable/ic_library_music_white_24dp"
|
android:icon="@drawable/ic_library_music_white_24dp"
|
||||||
android:title="@string/library" />
|
android:title="@string/library" />
|
||||||
<item
|
<item
|
||||||
android:enabled="false"
|
|
||||||
android:id="@+id/nav_folders"
|
android:id="@+id/nav_folders"
|
||||||
android:icon="@drawable/ic_folder_white_24dp"
|
android:icon="@drawable/ic_folder_white_24dp"
|
||||||
android:title="Folders (soon)" />
|
android:title="@string/folders" />
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
<group
|
<group
|
||||||
|
|
|
||||||
|
|
@ -236,4 +236,7 @@
|
||||||
<string name="folders">Folders</string>
|
<string name="folders">Folders</string>
|
||||||
<string name="saved_playlist_to">Saved playlist to %s.</string>
|
<string name="saved_playlist_to">Saved playlist to %s.</string>
|
||||||
<string name="failed_to_save_playlist">Failed to save playlist (%s).</string>
|
<string name="failed_to_save_playlist">Failed to save playlist (%s).</string>
|
||||||
|
|
||||||
|
<!-- TODO: Remove or change this placeholder text -->
|
||||||
|
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
<item>@string/albums</item>
|
<item>@string/albums</item>
|
||||||
<item>@string/artists</item>
|
<item>@string/artists</item>
|
||||||
<item>@string/playlists</item>
|
<item>@string/playlists</item>
|
||||||
|
<item>@string/folders</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="pref_start_page_list_values">
|
<string-array name="pref_start_page_list_values">
|
||||||
|
|
@ -13,6 +14,7 @@
|
||||||
<item>1</item>
|
<item>1</item>
|
||||||
<item>2</item>
|
<item>2</item>
|
||||||
<item>3</item>
|
<item>3</item>
|
||||||
|
<item>-2</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="pref_general_theme_list_titles">
|
<string-array name="pref_general_theme_list_titles">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue