Removed library fragment

main
h4h13 2020-02-19 12:38:12 +05:30
parent 1174cbb477
commit 8a58021deb
31 changed files with 1079 additions and 1206 deletions

View File

@ -417,7 +417,6 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
private fun loadLRCLyrics() {
lyricsView.resetView("Empty")
val song = MusicPlayerRemote.currentSong
println("${song.title} ${song.artistName}")
if (LyricUtil.isLrcFileExist(song.title, song.artistName)) {
showLyricsLocal(LyricUtil.getLocalLyricFile(song.title, song.artistName))
}

View File

@ -0,0 +1,708 @@
/*
* Copyright (c) 2020 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.
*/
package code.name.monkey.retromusic.activities;
import android.app.ActivityOptions;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.fragment.app.Fragment;
import code.name.monkey.appthemehelper.util.ATHUtil;
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity;
import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog;
import code.name.monkey.retromusic.dialogs.OptionsSheetDialogFragment;
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment;
import code.name.monkey.retromusic.fragments.mainactivity.AlbumsFragment;
import code.name.monkey.retromusic.fragments.mainactivity.ArtistsFragment;
import code.name.monkey.retromusic.fragments.mainactivity.GenresFragment;
import code.name.monkey.retromusic.fragments.mainactivity.PlayingQueueFragment;
import code.name.monkey.retromusic.fragments.mainactivity.PlaylistsFragment;
import code.name.monkey.retromusic.fragments.mainactivity.SongsFragment;
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.helper.SortOrder.AlbumSortOrder;
import code.name.monkey.retromusic.helper.SortOrder.ArtistSortOrder;
import code.name.monkey.retromusic.helper.SortOrder.SongSortOrder;
import code.name.monkey.retromusic.interfaces.CabHolder;
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks;
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.model.Song;
import code.name.monkey.retromusic.service.MusicService;
import code.name.monkey.retromusic.util.AppRater;
import code.name.monkey.retromusic.util.NavigationUtil;
import code.name.monkey.retromusic.util.PreferenceUtil;
import code.name.monkey.retromusic.util.RetroUtil;
import com.afollestad.materialcab.MaterialCab;
import com.afollestad.materialcab.MaterialCab.Callback;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.card.MaterialCardView;
import java.util.ArrayList;
import java.util.List;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Created by hemanths on 2020-02-19.
*/
public class MainActivity extends AbsSlidingMusicPanelActivity
implements CabHolder, SharedPreferences.OnSharedPreferenceChangeListener {
public static final String TAG = MainActivity.class.getSimpleName();
public static final int APP_INTRO_REQUEST = 100;
public static final String EXPAND_PANEL = "expand_panel";
@Nullable
MainActivityFragmentCallbacks currentFragment;
private boolean blockRequestPermissions = false;
private AppBarLayout mAppBarLayout;
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(final Context context, final Intent intent) {
String action = intent.getAction();
if (action != null && action.equals(Intent.ACTION_SCREEN_OFF)) {
if (PreferenceUtil.getInstance(context).getLockScreen() && MusicPlayerRemote.isPlaying()) {
final Intent activity = new Intent(context, LockScreenActivity.class);
activity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
activity.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
ActivityCompat.startActivity(context, activity, null);
}
}
}
};
private final IntentFilter mIntentFilter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
private Toolbar mToolbar;
private MaterialCardView mToolbarContainer;
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
setDrawUnderStatusBar();
super.onCreate(savedInstanceState);
setStatusbarColorAuto();
setNavigationbarColorAuto();
setLightNavigationBar(true);
setTaskDescriptionColorAuto();
hideStatusBar();
setBottomBarVisibility(View.VISIBLE);
getBottomNavigationView().setSelectedItemId(PreferenceUtil.getInstance(this).getLastPage());
getBottomNavigationView().setOnNavigationItemSelectedListener(item -> {
PreferenceUtil.getInstance(MainActivity.this).setLastPage(item.getItemId());
selectedFragment(item.getItemId());
return true;
});
if (savedInstanceState == null) {
selectedFragment(PreferenceUtil.getInstance(this).getLastPage());
} else {
restoreCurrentFragment();
}
mToolbarContainer = findViewById(R.id.toolbarContainer);
mToolbar = findViewById(R.id.toolbar);
mAppBarLayout = findViewById(R.id.appBarLayout);
checkShowChangelog();
AppRater.appLaunched(this);
setupToolbar();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == APP_INTRO_REQUEST) {
blockRequestPermissions = false;
if (!hasPermissions()) {
requestPermissions();
}
}
}
@Override
protected void onResume() {
super.onResume();
registerReceiver(mBroadcastReceiver, mIntentFilter);
PreferenceUtil.getInstance(this).registerOnSharedPreferenceChangedListener(this);
if (getIntent().hasExtra(EXPAND_PANEL)) {
if (getIntent().getBooleanExtra(EXPAND_PANEL, false)) {
expandPanel();
getIntent().putExtra(EXPAND_PANEL, false);
}
}
}
@Override
public void onDestroy() {
super.onDestroy();
unregisterReceiver(mBroadcastReceiver);
PreferenceUtil.getInstance(this).unregisterOnSharedPreferenceChangedListener(this);
}
public void addOnAppBarOffsetChangedListener(
@NonNull AppBarLayout.OnOffsetChangedListener onOffsetChangedListener) {
mAppBarLayout.addOnOffsetChangedListener(onOffsetChangedListener);
}
public int getTotalAppBarScrollingRange() {
return mAppBarLayout.getTotalScrollRange();
}
@Override
public boolean onCreateOptionsMenu(final 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)
.setIcon(R.drawable.ic_playlist_add_white_24dp).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}
if (isHomePage()) {
menu.add(0, R.id.action_search, 0, getString(R.string.action_search))
.setIcon(R.drawable.ic_mic_white_24dp).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}
Fragment fragment = getCurrentFragment();
if (fragment instanceof AbsLibraryPagerRecyclerViewCustomGridSizeFragment) {
AbsLibraryPagerRecyclerViewCustomGridSizeFragment currentFragment
= (AbsLibraryPagerRecyclerViewCustomGridSizeFragment) fragment;
if (currentFragment instanceof SongsFragment) {
menu.removeItem(R.id.action_grid_size);
menu.removeItem(R.id.action_layout_type);
} else {
MenuItem gridSizeItem = menu.findItem(R.id.action_grid_size);
if (RetroUtil.isLandscape()) {
gridSizeItem.setTitle(R.string.action_grid_size_land);
}
setUpGridSizeMenu(currentFragment, gridSizeItem.getSubMenu());
MenuItem layoutItem = menu.findItem(R.id.action_layout_type);
setupLayoutMenu(currentFragment, layoutItem.getSubMenu());
}
setUpSortOrderMenu(currentFragment, menu.findItem(R.id.action_sort_order).getSubMenu());
} else {
menu.removeItem(R.id.action_layout_type);
menu.removeItem(R.id.action_grid_size);
menu.removeItem(R.id.action_sort_order);
}
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
Fragment fragment = getCurrentFragment();
if (fragment instanceof AbsLibraryPagerRecyclerViewCustomGridSizeFragment) {
AbsLibraryPagerRecyclerViewCustomGridSizeFragment currentFragment
= (AbsLibraryPagerRecyclerViewCustomGridSizeFragment) fragment;
if (handleGridSizeMenuItem(currentFragment, item)) {
return true;
}
if (handleLayoutResType(currentFragment, item)) {
return true;
}
if (handleSortOrderMenuItem(currentFragment, item)) {
return true;
}
}
int id = item.getItemId();
switch (id) {
case R.id.action_search:
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, mToolbarContainer,
getString(R.string.transition_toolbar));
NavigationUtil.goToSearch(this, true, options);
break;
case R.id.action_new_playlist:
CreatePlaylistDialog.create().show(getSupportFragmentManager(), "CREATE_PLAYLIST");
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public boolean onPrepareOptionsMenu(final Menu menu) {
ToolbarContentTintHelper.handleOnPrepareOptionsMenu(this, mToolbar);
return super.onPrepareOptionsMenu(menu);
}
@Override
public void onServiceConnected() {
super.onServiceConnected();
handlePlaybackIntent(getIntent());
}
@Override
public void onSharedPreferenceChanged(final @NonNull SharedPreferences sharedPreferences,
final @NonNull String key) {
if (key.equals(PreferenceUtil.GENERAL_THEME) || key.equals(PreferenceUtil.BLACK_THEME) ||
key.equals(PreferenceUtil.ADAPTIVE_COLOR_APP) || key.equals(PreferenceUtil.DOMINANT_COLOR) ||
key.equals(PreferenceUtil.USER_NAME) || key.equals(PreferenceUtil.TOGGLE_FULL_SCREEN) ||
key.equals(PreferenceUtil.TOGGLE_VOLUME) || key.equals(PreferenceUtil.ROUND_CORNERS) ||
key.equals(PreferenceUtil.CAROUSEL_EFFECT) || key == PreferenceUtil.NOW_PLAYING_SCREEN_ID ||
key == PreferenceUtil.TOGGLE_GENRE || key == PreferenceUtil.BANNER_IMAGE_PATH ||
key == PreferenceUtil.PROFILE_IMAGE_PATH || key == PreferenceUtil.CIRCULAR_ALBUM_ART ||
key == PreferenceUtil.KEEP_SCREEN_ON || key == PreferenceUtil.TOGGLE_SEPARATE_LINE ||
key == PreferenceUtil.TOGGLE_HOME_BANNER || key == PreferenceUtil.TOGGLE_ADD_CONTROLS ||
key == PreferenceUtil.ALBUM_COVER_STYLE || key == PreferenceUtil.HOME_ARTIST_GRID_STYLE ||
key == PreferenceUtil.ALBUM_COVER_TRANSFORM || key == PreferenceUtil.DESATURATED_COLOR ||
key == PreferenceUtil.TAB_TEXT_MODE || key == PreferenceUtil.LIBRARY_CATEGORIES
) {
postRecreate();
}
}
@NotNull
@Override
public MaterialCab openCab(final int menuRes, @NotNull final Callback callback) {
return null;
}
public void removeOnAppBarOffsetChangedListener(
@NonNull AppBarLayout.OnOffsetChangedListener onOffsetChangedListener) {
mAppBarLayout.removeOnOffsetChangedListener(onOffsetChangedListener);
}
@NotNull
@Override
protected View createContentView() {
return wrapSlidingMusicPanel(R.layout.activity_main_content);
}
private void checkShowChangelog() {
try {
final PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
final int currentVersion = pInfo.versionCode;
if (currentVersion != PreferenceUtil.getInstance(this).getLastChangelogVersion()) {
startActivityForResult(new Intent(this, WhatsNewActivity.class), APP_INTRO_REQUEST);
}
} catch (NameNotFoundException e) {
e.printStackTrace();
}
}
@Nullable
private Fragment getCurrentFragment() {
return getSupportFragmentManager().findFragmentById(R.id.fragment_container);
}
private boolean handleGridSizeMenuItem(
@NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment 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);
return true;
}
return false;
}
private boolean handleLayoutResType(
final AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment,
final MenuItem item) {
int layoutRes = -1;
switch (item.getItemId()) {
case R.id.action_layout_normal:
layoutRes = R.layout.item_grid;
break;
case R.id.action_layout_card:
layoutRes = R.layout.item_card;
break;
case R.id.action_layout_colored_card:
layoutRes = R.layout.item_card_color;
break;
case R.id.action_layout_circular:
layoutRes = R.layout.item_grid_circle;
break;
case R.id.action_layout_image:
layoutRes = R.layout.image;
break;
case R.id.action_layout_gradient_image:
layoutRes = R.layout.item_image_gradient;
break;
}
if (layoutRes != -1) {
item.setChecked(true);
fragment.setAndSaveLayoutRes(layoutRes);
return true;
}
return false;
}
private void handlePlaybackIntent(@Nullable Intent intent) {
if (intent == null) {
return;
}
Uri uri = intent.getData();
String mimeType = intent.getType();
boolean handled = false;
if (intent.getAction() != null && intent.getAction()
.equals(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH)) {
final List<Song> songs = SearchQueryHelper.getSongs(this, intent.getExtras());
if (MusicPlayerRemote.getShuffleMode() == MusicService.SHUFFLE_MODE_SHUFFLE) {
MusicPlayerRemote.openAndShuffleQueue(songs, true);
} else {
MusicPlayerRemote.openQueue(songs, 0, true);
}
handled = true;
}
if (uri != null && uri.toString().length() > 0) {
MusicPlayerRemote.playFromUri(uri);
handled = true;
} else if (MediaStore.Audio.Playlists.CONTENT_TYPE.equals(mimeType)) {
final int id = (int) parseIdFromIntent(intent, "playlistId", "playlist");
if (id >= 0) {
int position = intent.getIntExtra("position", 0);
List<Song> songs = new ArrayList<>(PlaylistSongsLoader.getPlaylistSongList(this, id));
MusicPlayerRemote.openQueue(songs, position, true);
handled = true;
}
} else if (MediaStore.Audio.Albums.CONTENT_TYPE.equals(mimeType)) {
final int id = (int) parseIdFromIntent(intent, "albumId", "album");
if (id >= 0) {
int position = intent.getIntExtra("position", 0);
MusicPlayerRemote.openQueue(AlbumLoader.getAlbum(this, id).getSongs(), position, true);
handled = true;
}
} else if (MediaStore.Audio.Artists.CONTENT_TYPE.equals(mimeType)) {
final int id = (int) parseIdFromIntent(intent, "artistId", "artist");
if (id >= 0) {
int position = intent.getIntExtra("position", 0);
MusicPlayerRemote.openQueue(ArtistLoader.getArtist(this, id).getSongs(), position, true);
handled = true;
}
}
if (handled) {
setIntent(new Intent());
}
}
private boolean handleSortOrderMenuItem(
@NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment
fragment, @NonNull MenuItem item) {
String sortOrder = null;
if (fragment instanceof AlbumsFragment) {
switch (item.getItemId()) {
case R.id.action_album_sort_order_asc:
sortOrder = AlbumSortOrder.ALBUM_A_Z;
break;
case R.id.action_album_sort_order_desc:
sortOrder = AlbumSortOrder.ALBUM_Z_A;
break;
case R.id.action_album_sort_order_artist:
sortOrder = AlbumSortOrder.ALBUM_ARTIST;
break;
case R.id.action_album_sort_order_year:
sortOrder = AlbumSortOrder.ALBUM_YEAR;
break;
}
} else if (fragment instanceof ArtistsFragment) {
switch (item.getItemId()) {
case R.id.action_artist_sort_order_asc:
sortOrder = ArtistSortOrder.ARTIST_A_Z;
break;
case R.id.action_artist_sort_order_desc:
sortOrder = ArtistSortOrder.ARTIST_Z_A;
break;
}
} else if (fragment instanceof SongsFragment) {
switch (item.getItemId()) {
case R.id.action_song_sort_order_asc:
sortOrder = SongSortOrder.SONG_A_Z;
break;
case R.id.action_song_sort_order_desc:
sortOrder = SongSortOrder.SONG_Z_A;
break;
case R.id.action_song_sort_order_artist:
sortOrder = SongSortOrder.SONG_ARTIST;
break;
case R.id.action_song_sort_order_album:
sortOrder = SongSortOrder.SONG_ALBUM;
break;
case R.id.action_song_sort_order_year:
sortOrder = SongSortOrder.SONG_YEAR;
break;
case R.id.action_song_sort_order_date:
sortOrder = SongSortOrder.SONG_DATE;
break;
case R.id.action_song_sort_order_composer:
sortOrder = SongSortOrder.COMPOSER;
break;
}
}
if (sortOrder != null) {
item.setChecked(true);
fragment.setAndSaveSortOrder(sortOrder);
return true;
}
return false;
}
private boolean isHomePage() {
return getSupportFragmentManager().findFragmentByTag(BannerHomeFragment.TAG) instanceof BannerHomeFragment;
}
private boolean isPlaylistPage() {
return getSupportFragmentManager().findFragmentByTag(PlaylistsFragment.TAG) instanceof PlaylistsFragment;
}
private long parseIdFromIntent(@NonNull Intent intent, String longKey,
String stringKey) {
long id = intent.getLongExtra(longKey, -1);
if (id < 0) {
String idString = intent.getStringExtra(stringKey);
if (idString != null) {
try {
id = Long.parseLong(idString);
} catch (NumberFormatException e) {
Log.e(TAG, e.getMessage());
}
}
}
return id;
}
private void restoreCurrentFragment() {
currentFragment = (MainActivityFragmentCallbacks) getSupportFragmentManager()
.findFragmentById(R.id.fragment_container);
}
private void selectedFragment(final int itemId) {
switch (itemId) {
case R.id.action_album:
setCurrentFragment(AlbumsFragment.newInstance(), AlbumsFragment.TAG);
break;
case R.id.action_artist:
setCurrentFragment(ArtistsFragment.newInstance(), ArtistsFragment.TAG);
break;
case R.id.action_playlist:
setCurrentFragment(PlaylistsFragment.newInstance(), PlaylistsFragment.TAG);
break;
case R.id.action_genre:
setCurrentFragment(GenresFragment.newInstance(), GenresFragment.TAG);
break;
case R.id.action_playing_queue:
setCurrentFragment(PlayingQueueFragment.newInstance(), PlayingQueueFragment.TAG);
break;
case R.id.action_song:
setCurrentFragment(SongsFragment.newInstance(), SongsFragment.TAG);
break;
default:
case R.id.action_home:
setCurrentFragment(BannerHomeFragment.newInstance(), BannerHomeFragment.TAG);
break;
}
}
private void setCurrentFragment(Fragment fragment, String tag) {
String currentTag = null;
if (getSupportFragmentManager().findFragmentByTag(tag) != null) {
currentTag = getSupportFragmentManager().findFragmentByTag(tag).getTag();
}
if (!tag.equals(currentTag)) {
getSupportFragmentManager().beginTransaction()
.replace(R.id.fragment_container, fragment, tag)
.commit();
currentFragment = (MainActivityFragmentCallbacks) fragment;
}
}
private void setUpGridSizeMenu(@NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment 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 void setUpSortOrderMenu(
@NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment,
@NonNull SubMenu sortOrderMenu) {
String currentSortOrder = fragment.getSortOrder();
sortOrderMenu.clear();
if (fragment instanceof AlbumsFragment) {
sortOrderMenu.add(0, R.id.action_album_sort_order_asc, 0, R.string.sort_order_a_z)
.setChecked(currentSortOrder.equals(AlbumSortOrder.ALBUM_A_Z));
sortOrderMenu.add(0, R.id.action_album_sort_order_desc, 1, R.string.sort_order_z_a)
.setChecked(currentSortOrder.equals(AlbumSortOrder.ALBUM_Z_A));
sortOrderMenu.add(0, R.id.action_album_sort_order_artist, 2, R.string.sort_order_artist)
.setChecked(currentSortOrder.equals(AlbumSortOrder.ALBUM_ARTIST));
sortOrderMenu.add(0, R.id.action_album_sort_order_year, 3, R.string.sort_order_year)
.setChecked(currentSortOrder.equals(AlbumSortOrder.ALBUM_YEAR));
} else if (fragment instanceof ArtistsFragment) {
sortOrderMenu.add(0, R.id.action_artist_sort_order_asc, 0, R.string.sort_order_a_z)
.setChecked(currentSortOrder.equals(ArtistSortOrder.ARTIST_A_Z));
sortOrderMenu.add(0, R.id.action_artist_sort_order_desc, 1, R.string.sort_order_z_a)
.setChecked(currentSortOrder.equals(ArtistSortOrder.ARTIST_Z_A));
} else if (fragment instanceof SongsFragment) {
sortOrderMenu.add(0, R.id.action_song_sort_order_asc, 0, R.string.sort_order_a_z)
.setChecked(currentSortOrder.equals(SongSortOrder.SONG_A_Z));
sortOrderMenu.add(0, R.id.action_song_sort_order_desc, 1, R.string.sort_order_z_a)
.setChecked(currentSortOrder.equals(SongSortOrder.SONG_Z_A));
sortOrderMenu.add(0, R.id.action_song_sort_order_artist, 2, R.string.sort_order_artist)
.setChecked(currentSortOrder.equals(SongSortOrder.SONG_ARTIST));
sortOrderMenu.add(0, R.id.action_song_sort_order_album, 3, R.string.sort_order_album)
.setChecked(currentSortOrder.equals(SongSortOrder.SONG_ALBUM));
sortOrderMenu.add(0, R.id.action_song_sort_order_year, 4, R.string.sort_order_year)
.setChecked(currentSortOrder.equals(SongSortOrder.SONG_YEAR));
sortOrderMenu.add(0, R.id.action_song_sort_order_date, 5, R.string.sort_order_date)
.setChecked(currentSortOrder.equals(SongSortOrder.SONG_DATE));
sortOrderMenu.add(0, R.id.action_song_sort_order_composer, 6, R.string.sort_order_composer)
.setChecked(currentSortOrder.equals(SongSortOrder.COMPOSER));
}
sortOrderMenu.setGroupCheckable(0, true, true);
}
private void setupLayoutMenu(
@NonNull final AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment,
@NonNull final SubMenu subMenu) {
switch (fragment.itemLayoutRes()) {
case R.layout.item_card:
subMenu.findItem(R.id.action_layout_card).setChecked(true);
break;
case R.layout.item_grid:
subMenu.findItem(R.id.action_layout_normal).setChecked(true);
break;
case R.layout.item_card_color:
subMenu.findItem(R.id.action_layout_colored_card).setChecked(true);
break;
case R.layout.item_grid_circle:
subMenu.findItem(R.id.action_layout_circular).setChecked(true);
break;
case R.layout.image:
subMenu.findItem(R.id.action_layout_image).setChecked(true);
break;
case R.layout.item_image_gradient:
subMenu.findItem(R.id.action_layout_gradient_image).setChecked(true);
break;
}
}
private void setupToolbar() {
mToolbar.setBackgroundColor(Color.TRANSPARENT);
mToolbarContainer.setCardBackgroundColor(
ColorStateList.valueOf(ATHUtil.INSTANCE.resolveColor(this, R.attr.colorSurface)));
setSupportActionBar(mToolbar);
mToolbar.setOnClickListener(v -> {
ActivityOptions options = ActivityOptions
.makeSceneTransitionAnimation(this, mToolbarContainer, getString(R.string.transition_toolbar));
NavigationUtil.goToSearch(this, options);
});
mToolbar.setNavigationOnClickListener(
v -> OptionsSheetDialogFragment.newInstance().show(getSupportFragmentManager(), "Main_Menu"));
}
}

View File

@ -1,604 +0,0 @@
package code.name.monkey.retromusic.activities
import android.app.ActivityOptions
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.SharedPreferences
import android.content.res.ColorStateList
import android.graphics.Color
import android.os.Bundle
import android.provider.MediaStore
import android.util.Log
import android.view.Menu
import android.view.MenuItem
import android.view.SubMenu
import android.view.View
import androidx.core.app.ActivityCompat
import androidx.fragment.app.Fragment
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ATHUtil.resolveColor
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.R.drawable
import code.name.monkey.retromusic.R.id
import code.name.monkey.retromusic.R.layout
import code.name.monkey.retromusic.R.string
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog.Companion.create
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
import code.name.monkey.retromusic.fragments.mainactivity.AlbumsFragment
import code.name.monkey.retromusic.fragments.mainactivity.ArtistsFragment
import code.name.monkey.retromusic.fragments.mainactivity.GenresFragment
import code.name.monkey.retromusic.fragments.mainactivity.LibraryFragment
import code.name.monkey.retromusic.fragments.mainactivity.PlayingQueueFragment
import code.name.monkey.retromusic.fragments.mainactivity.PlaylistsFragment
import code.name.monkey.retromusic.fragments.mainactivity.SongsFragment
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.helper.SortOrder.AlbumSortOrder
import code.name.monkey.retromusic.helper.SortOrder.ArtistSortOrder
import code.name.monkey.retromusic.helper.SortOrder.SongSortOrder
import code.name.monkey.retromusic.interfaces.CabHolder
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
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.util.AppRater
import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroColorUtil
import code.name.monkey.retromusic.util.RetroUtil
import com.afollestad.materialcab.MaterialCab
import com.afollestad.materialcab.MaterialCab.Callback
import com.google.android.material.appbar.AppBarLayout.OnOffsetChangedListener
import kotlinx.android.synthetic.main.activity_main_content.appBarLayout
import kotlinx.android.synthetic.main.activity_main_content.toolbar
import kotlinx.android.synthetic.main.activity_main_content.toolbarContainer
import java.util.ArrayList
class MainActivity : AbsSlidingMusicPanelActivity(), CabHolder, SharedPreferences.OnSharedPreferenceChangeListener {
private lateinit var currentFragment: MainActivityFragmentCallbacks
private var blockRequestPermissions: Boolean = false
private val broadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
val action = intent.action
if (action != null && action == Intent.ACTION_SCREEN_OFF) {
if (PreferenceUtil.getInstance(this@MainActivity).lockScreen && MusicPlayerRemote.isPlaying) {
val activity = Intent(context, LockScreenActivity::class.java)
activity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
activity.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
ActivityCompat.startActivity(context, activity, null)
}
}
}
}
override fun createContentView(): View {
return wrapSlidingMusicPanel(R.layout.activity_main_content)
}
override fun onCreate(
savedInstanceState: Bundle?
) {
setDrawUnderStatusBar()
super.onCreate(savedInstanceState)
getBottomNavigationView().selectedItemId = PreferenceUtil.getInstance(this).lastPage
getBottomNavigationView().setOnNavigationItemSelectedListener {
PreferenceUtil.getInstance(this).lastPage = it.itemId
selectedFragment(it.itemId)
true
}
if (savedInstanceState == null) {
setMusicChooser(PreferenceUtil.getInstance(this).lastMusicChooser)
} else {
restoreCurrentFragment()
}
checkShowChangelog()
AppRater.appLaunched(this)
setupToolbar()
setBottomBarVisibility(View.VISIBLE)
}
private fun setupToolbar() {
toolbar.setBackgroundColor(Color.TRANSPARENT)
toolbarContainer.backgroundTintList =
ColorStateList.valueOf(resolveColor(this, R.attr.colorSurface))
setSupportActionBar(toolbar)
toolbar.setOnClickListener {
val options = ActivityOptions
.makeSceneTransitionAnimation(
this, toolbarContainer,
getString(R.string.transition_toolbar)
)
NavigationUtil.goToSearch(this, options)
}
}
private fun checkShowChangelog() {
try {
val pInfo = packageManager.getPackageInfo(packageName, 0)
val currentVersion = pInfo.versionCode
if (currentVersion != PreferenceUtil.getInstance(this).lastChangelogVersion) {
startActivityForResult(
Intent(this, WhatsNewActivity::class.java),
APP_INTRO_REQUEST
)
}
} catch (e: Throwable) {
e.printStackTrace()
}
}
override fun onResume() {
super.onResume()
val screenOnOff = IntentFilter()
screenOnOff.addAction(Intent.ACTION_SCREEN_OFF)
registerReceiver(broadcastReceiver, screenOnOff)
PreferenceUtil.getInstance(this).registerOnSharedPreferenceChangedListener(this)
if (intent.hasExtra("expand")) {
if (intent.getBooleanExtra("expand", false)) {
expandPanel()
intent.putExtra("expand", false)
}
}
}
override fun onDestroy() {
super.onDestroy()
unregisterReceiver(broadcastReceiver)
PreferenceUtil.getInstance(this).unregisterOnSharedPreferenceChangedListener(this)
}
private fun setCurrentFragment(fragment: Fragment, tag: String) {
if (tag != supportFragmentManager.findFragmentById(R.id.fragment_container)?.tag) {
supportFragmentManager.beginTransaction()
.replace(R.id.fragment_container, fragment, tag).commit()
currentFragment = fragment as MainActivityFragmentCallbacks
}
}
private fun restoreCurrentFragment() {
currentFragment =
supportFragmentManager.findFragmentById(R.id.fragment_container) as MainActivityFragmentCallbacks
}
private fun handlePlaybackIntent(intent: Intent?) {
if (intent == null) {
return
}
val uri = intent.data
val mimeType = intent.type
var handled = false
if (intent.action != null && intent.action == MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH) {
val songs = SearchQueryHelper.getSongs(this, intent.extras!!)
if (MusicPlayerRemote.shuffleMode == MusicService.SHUFFLE_MODE_SHUFFLE) {
MusicPlayerRemote.openAndShuffleQueue(songs, true)
} else {
MusicPlayerRemote.openQueue(songs, 0, true)
}
handled = true
}
if (uri != null && uri.toString().isNotEmpty()) {
MusicPlayerRemote.playFromUri(uri)
handled = true
} else if (MediaStore.Audio.Playlists.CONTENT_TYPE == mimeType) {
val id = parseIdFromIntent(intent, "playlistId", "playlist").toInt()
if (id >= 0) {
val position = intent.getIntExtra("position", 0)
val songs = ArrayList(PlaylistSongsLoader.getPlaylistSongList(this, id))
MusicPlayerRemote.openQueue(songs, position, true)
handled = true
}
} else if (MediaStore.Audio.Albums.CONTENT_TYPE == mimeType) {
val id = parseIdFromIntent(intent, "albumId", "album").toInt()
if (id >= 0) {
val position = intent.getIntExtra("position", 0)
MusicPlayerRemote.openQueue(AlbumLoader.getAlbum(this, id).songs!!, position, true)
handled = true
}
} else if (MediaStore.Audio.Artists.CONTENT_TYPE == mimeType) {
val id = parseIdFromIntent(intent, "artistId", "artist").toInt()
if (id >= 0) {
val position = intent.getIntExtra("position", 0)
MusicPlayerRemote.openQueue(ArtistLoader.getArtist(this, id).songs, position, true)
handled = true
}
}
if (handled) {
setIntent(Intent())
}
}
private fun parseIdFromIntent(intent: Intent, longKey: String, stringKey: String): Long {
var id = intent.getLongExtra(longKey, -1)
if (id < 0) {
val idString = intent.getStringExtra(stringKey)
if (idString != null) {
try {
id = java.lang.Long.parseLong(idString)
} catch (e: NumberFormatException) {
Log.e(TAG, e.message)
}
}
}
return id
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
when (requestCode) {
APP_INTRO_REQUEST -> {
blockRequestPermissions = false
if (!hasPermissions()) {
requestPermissions()
}
}
REQUEST_CODE_THEME, APP_USER_INFO_REQUEST -> postRecreate()
PURCHASE_REQUEST -> {
if (resultCode == RESULT_OK) {
//checkSetUpPro();
}
}
}
}
override fun handleBackPress(): Boolean {
return super.handleBackPress() || currentFragment.handleBackPress()
}
override fun onServiceConnected() {
super.onServiceConnected()
handlePlaybackIntent(intent)
}
override fun requestPermissions() {
if (!blockRequestPermissions) {
super.requestPermissions()
}
}
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
if (key == PreferenceUtil.GENERAL_THEME || key == PreferenceUtil.BLACK_THEME ||
key == PreferenceUtil.ADAPTIVE_COLOR_APP || key == PreferenceUtil.DOMINANT_COLOR ||
key == PreferenceUtil.USER_NAME || key == PreferenceUtil.TOGGLE_FULL_SCREEN ||
key == PreferenceUtil.TOGGLE_VOLUME || key == PreferenceUtil.ROUND_CORNERS ||
key == PreferenceUtil.CAROUSEL_EFFECT || key == PreferenceUtil.NOW_PLAYING_SCREEN_ID ||
key == PreferenceUtil.TOGGLE_GENRE || key == PreferenceUtil.BANNER_IMAGE_PATH ||
key == PreferenceUtil.PROFILE_IMAGE_PATH || key == PreferenceUtil.CIRCULAR_ALBUM_ART ||
key == PreferenceUtil.KEEP_SCREEN_ON || key == PreferenceUtil.TOGGLE_SEPARATE_LINE ||
key == PreferenceUtil.TOGGLE_HOME_BANNER || key == PreferenceUtil.TOGGLE_ADD_CONTROLS ||
key == PreferenceUtil.ALBUM_COVER_STYLE || key == PreferenceUtil.HOME_ARTIST_GRID_STYLE ||
key == PreferenceUtil.ALBUM_COVER_TRANSFORM || key == PreferenceUtil.DESATURATED_COLOR ||
key == PreferenceUtil.TAB_TEXT_MODE || key == PreferenceUtil.LIBRARY_CATEGORIES
)
postRecreate()
}
private fun selectedFragment(itemId: Int) {
when (itemId) {
R.id.action_album -> setCurrentFragment(AlbumsFragment.newInstance(), itemId.toString())
R.id.action_artist -> setCurrentFragment(ArtistsFragment.newInstance(), itemId.toString())
R.id.action_playlist -> setCurrentFragment(PlaylistsFragment.newInstance(), itemId.toString())
R.id.action_genre -> setCurrentFragment(GenresFragment.newInstance(), itemId.toString())
R.id.action_playing_queue -> setCurrentFragment(PlayingQueueFragment.newInstance(), itemId.toString())
R.id.action_song -> setCurrentFragment(SongsFragment.newInstance(), itemId.toString())
R.id.action_home -> setCurrentFragment(BannerHomeFragment.newInstance(), BannerHomeFragment.TAG)
else -> {
setCurrentFragment(BannerHomeFragment.newInstance(), BannerHomeFragment.TAG)
}
}
}
fun setMusicChooser(key: Int) {
PreferenceUtil.getInstance(this).lastMusicChooser = key
when (key) {
FOLDER -> setCurrentFragment(FoldersFragment.newInstance(this), FoldersFragment.TAG)
else -> selectedFragment(PreferenceUtil.getInstance(this).lastPage)
}
}
companion object {
const val APP_INTRO_REQUEST = 2323
const val HOME = 0
const val FOLDER = 1
const val LIBRARY = 2
private const val TAG = "MainActivity"
private const val APP_USER_INFO_REQUEST = 9003
private const val REQUEST_CODE_THEME = 9002
private const val PURCHASE_REQUEST = 101
}
private lateinit var cab: MaterialCab
fun getTotalAppBarScrollingRange(): Int {
return appBarLayout.totalScrollRange
}
fun addOnAppBarOffsetChangedListener(
onOffsetChangedListener: OnOffsetChangedListener
) {
appBarLayout.addOnOffsetChangedListener(onOffsetChangedListener)
}
fun removeOnAppBarOffsetChangedListener(
onOffsetChangedListener: OnOffsetChangedListener
) {
appBarLayout.removeOnOffsetChangedListener(onOffsetChangedListener)
}
override fun openCab(menuRes: Int, callback: Callback): MaterialCab {
if (cab != null && cab.isActive()) {
cab.finish()
}
cab = MaterialCab(this, R.id.cab_stub)
.setMenu(menuRes)
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
.setBackgroundColor(
RetroColorUtil.shiftBackgroundColorForLightText(
ATHUtil.resolveColor(this, R.attr.colorSurface)
)
)
.start(callback)
return cab
}
private fun getCurrentFragment(): Fragment? {
return if (supportFragmentManager == null) {
SongsFragment.newInstance()
} else supportFragmentManager.findFragmentByTag(LibraryFragment.TAG)
}
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.menu_main, menu)
val currentFragment: Fragment? = getCurrentFragment()
if (currentFragment is AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>
&& currentFragment.isAdded()
) {
if (currentFragment is SongsFragment) {
menu!!.removeItem(id.action_grid_size)
menu.removeItem(id.action_layout_type)
} else {
val gridSizeItem = menu!!.findItem(id.action_grid_size)
if (RetroUtil.isLandscape()) {
gridSizeItem.setTitle(string.action_grid_size_land)
}
setUpGridSizeMenu(currentFragment, gridSizeItem.subMenu)
val layoutItem = menu.findItem(id.action_layout_type)
setupLayoutMenu(currentFragment, layoutItem.subMenu)
}
setUpSortOrderMenu(currentFragment, menu.findItem(id.action_sort_order).subMenu)
} else if (currentFragment is GenresFragment || currentFragment is PlayingQueueFragment) {
menu!!.removeItem(id.action_new_playlist)
menu.removeItem(id.action_layout_type)
menu.removeItem(id.action_grid_size)
menu.removeItem(id.action_sort_order)
} else {
menu!!.add(0, id.action_new_playlist, 0, string.new_playlist_title)
.setIcon(drawable.ic_playlist_add_white_24dp)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM)
menu.removeItem(id.action_grid_size)
menu.removeItem(id.action_layout_type)
}
return super.onCreateOptionsMenu(menu)
}
private fun setUpGridSizeMenu(
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>,
gridSizeMenu: SubMenu
) {
when (fragment.getGridSize()) {
1 -> gridSizeMenu.findItem(id.action_grid_size_1).isChecked = true
2 -> gridSizeMenu.findItem(id.action_grid_size_2).isChecked = true
3 -> gridSizeMenu.findItem(id.action_grid_size_3).isChecked = true
4 -> gridSizeMenu.findItem(id.action_grid_size_4).isChecked = true
5 -> gridSizeMenu.findItem(id.action_grid_size_5).isChecked = true
6 -> gridSizeMenu.findItem(id.action_grid_size_6).isChecked = true
7 -> gridSizeMenu.findItem(id.action_grid_size_7).isChecked = true
8 -> gridSizeMenu.findItem(id.action_grid_size_8).isChecked = true
}
val maxGridSize = fragment.maxGridSize
if (maxGridSize < 8) {
gridSizeMenu.findItem(id.action_grid_size_8).isVisible = false
}
if (maxGridSize < 7) {
gridSizeMenu.findItem(id.action_grid_size_7).isVisible = false
}
if (maxGridSize < 6) {
gridSizeMenu.findItem(id.action_grid_size_6).isVisible = false
}
if (maxGridSize < 5) {
gridSizeMenu.findItem(id.action_grid_size_5).isVisible = false
}
if (maxGridSize < 4) {
gridSizeMenu.findItem(id.action_grid_size_4).isVisible = false
}
if (maxGridSize < 3) {
gridSizeMenu.findItem(id.action_grid_size_3).isVisible = false
}
}
private fun setUpSortOrderMenu(
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>,
sortOrderMenu: SubMenu
) {
val currentSortOrder = fragment.getSortOrder()
sortOrderMenu.clear()
when (fragment) {
is AlbumsFragment -> {
sortOrderMenu.add(0, id.action_album_sort_order_asc, 0, string.sort_order_a_z).isChecked =
currentSortOrder == AlbumSortOrder.ALBUM_A_Z
sortOrderMenu.add(0, id.action_album_sort_order_desc, 1, string.sort_order_z_a).isChecked =
currentSortOrder == AlbumSortOrder.ALBUM_Z_A
sortOrderMenu.add(0, id.action_album_sort_order_artist, 2, string.sort_order_artist).isChecked =
currentSortOrder == AlbumSortOrder.ALBUM_ARTIST
sortOrderMenu.add(0, id.action_album_sort_order_year, 3, string.sort_order_year).isChecked =
currentSortOrder == AlbumSortOrder.ALBUM_YEAR
}
is ArtistsFragment -> {
sortOrderMenu.add(0, id.action_artist_sort_order_asc, 0, string.sort_order_a_z).isChecked =
currentSortOrder == ArtistSortOrder.ARTIST_A_Z
sortOrderMenu.add(0, id.action_artist_sort_order_desc, 1, string.sort_order_z_a).isChecked =
currentSortOrder == ArtistSortOrder.ARTIST_Z_A
}
is SongsFragment -> {
sortOrderMenu.add(0, id.action_song_sort_order_asc, 0, string.sort_order_a_z).isChecked =
currentSortOrder == SongSortOrder.SONG_A_Z
sortOrderMenu.add(0, id.action_song_sort_order_desc, 1, string.sort_order_z_a).isChecked =
currentSortOrder == SongSortOrder.SONG_Z_A
sortOrderMenu.add(0, id.action_song_sort_order_artist, 2, string.sort_order_artist).isChecked =
currentSortOrder == SongSortOrder.SONG_ARTIST
sortOrderMenu.add(0, id.action_song_sort_order_album, 3, string.sort_order_album).isChecked =
currentSortOrder == SongSortOrder.SONG_ALBUM
sortOrderMenu.add(0, id.action_song_sort_order_year, 4, string.sort_order_year).isChecked =
currentSortOrder == SongSortOrder.SONG_YEAR
sortOrderMenu.add(0, id.action_song_sort_order_date, 5, string.sort_order_date).isChecked =
currentSortOrder == SongSortOrder.SONG_DATE
sortOrderMenu.add(0, id.action_song_sort_order_composer, 6, string.sort_order_composer).isChecked =
currentSortOrder == SongSortOrder.COMPOSER
}
}
sortOrderMenu.setGroupCheckable(0, true, true)
}
private fun setupLayoutMenu(
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>,
subMenu: SubMenu
) {
when (fragment.itemLayoutRes()) {
layout.item_card -> subMenu.findItem(id.action_layout_card).isChecked = true
layout.item_grid -> subMenu.findItem(id.action_layout_normal).isChecked = true
layout.item_card_color -> subMenu.findItem(id.action_layout_colored_card).isChecked = true
layout.item_grid_circle -> subMenu.findItem(id.action_layout_circular).isChecked = true
layout.image -> subMenu.findItem(id.action_layout_image).isChecked = true
layout.item_image_gradient -> subMenu.findItem(id.action_layout_gradient_image).isChecked = true
}
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
//if (pager == null) return false;
val currentFragment = getCurrentFragment()
if (currentFragment is AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>) {
if (handleGridSizeMenuItem(currentFragment, item)) {
return true
}
if (handleLayoutResType(currentFragment, item)) {
return true
}
if (handleSortOrderMenuItem(currentFragment, item)) {
return true
}
}
when (item.itemId) {
R.id.action_search -> {
val options = ActivityOptions
.makeSceneTransitionAnimation(
this, toolbarContainer,
getString(string.transition_toolbar)
)
NavigationUtil.goToSearch(this, options)
}
R.id.action_new_playlist -> {
create().show(supportFragmentManager, "CREATE_PLAYLIST")
return true
}
}
return super.onOptionsItemSelected(item)
}
private fun handleGridSizeMenuItem(
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>,
item: MenuItem
): Boolean {
var gridSize = 0
when (item.itemId) {
id.action_grid_size_1 -> gridSize = 1
id.action_grid_size_2 -> gridSize = 2
id.action_grid_size_3 -> gridSize = 3
id.action_grid_size_4 -> gridSize = 4
id.action_grid_size_5 -> gridSize = 5
id.action_grid_size_6 -> gridSize = 6
id.action_grid_size_7 -> gridSize = 7
id.action_grid_size_8 -> gridSize = 8
}
if (gridSize > 0) {
item.isChecked = true
fragment.setAndSaveGridSize(gridSize)
return true
}
return false
}
private fun handleLayoutResType(
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>,
item: MenuItem
): Boolean {
var layoutRes = -1
when (item.itemId) {
id.action_layout_normal -> layoutRes = layout.item_grid
id.action_layout_card -> layoutRes = layout.item_card
id.action_layout_colored_card -> layoutRes = layout.item_card_color
id.action_layout_circular -> layoutRes = layout.item_grid_circle
id.action_layout_image -> layoutRes = layout.image
id.action_layout_gradient_image -> layoutRes = layout.item_image_gradient
}
if (layoutRes != -1) {
item.isChecked = true
fragment.setAndSaveLayoutRes(layoutRes)
return true
}
return false
}
private fun handleSortOrderMenuItem(
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>, item: MenuItem
): Boolean {
var sortOrder: String? = null
when (fragment) {
is SongsFragment -> {
when (item.itemId) {
id.action_song_sort_order_asc -> sortOrder = SongSortOrder.SONG_A_Z
id.action_song_sort_order_desc -> sortOrder = SongSortOrder.SONG_Z_A
id.action_song_sort_order_artist -> sortOrder = SongSortOrder.SONG_ARTIST
id.action_song_sort_order_album -> sortOrder = SongSortOrder.SONG_ALBUM
id.action_song_sort_order_year -> sortOrder = SongSortOrder.SONG_YEAR
id.action_song_sort_order_date -> sortOrder = SongSortOrder.SONG_DATE
id.action_song_sort_order_composer -> sortOrder = SongSortOrder.COMPOSER
}
}
is AlbumsFragment -> {
when (item.itemId) {
id.action_album_sort_order_asc -> sortOrder = AlbumSortOrder.ALBUM_A_Z
id.action_album_sort_order_desc -> sortOrder = AlbumSortOrder.ALBUM_Z_A
id.action_album_sort_order_artist -> sortOrder = AlbumSortOrder.ALBUM_ARTIST
id.action_album_sort_order_year -> sortOrder = AlbumSortOrder.ALBUM_YEAR
}
}
is ArtistsFragment -> {
when (item.itemId) {
id.action_artist_sort_order_asc -> sortOrder = ArtistSortOrder.ARTIST_A_Z
id.action_artist_sort_order_desc -> sortOrder = ArtistSortOrder.ARTIST_Z_A
}
}
}
if (sortOrder != null) {
item.isChecked = true
fragment.setAndSaveSortOrder(sortOrder)
return true
}
return false
}
}

View File

@ -67,7 +67,6 @@ class ContributorAdapter(
internal fun bindData(contributor: Contributor) {
title.text = contributor.name
text.text = contributor.summary
println(contributor.profileImage)
Glide.with(image.context).load(contributor.profileImage)
.error(R.drawable.ic_account_white_24dp)
.placeholder(R.drawable.ic_account_white_24dp).dontAnimate().into(image)

View File

@ -52,7 +52,6 @@ class HomeAdapter(
}
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
println("ViewType ${getItemViewType(position)}")
when (getItemViewType(position)) {
RECENT_ALBUMS -> {
val viewHolder = holder as AlbumViewHolder

View File

@ -35,36 +35,35 @@ import com.afollestad.materialdialogs.customview.getCustomView
import com.google.android.material.textfield.TextInputEditText
import com.google.android.material.textfield.TextInputLayout
class CreatePlaylistDialog : DialogFragment() {
private lateinit var playlistView: TextInputEditText
private lateinit var actionNewPlaylistContainer: TextInputLayout
override fun onCreateDialog(
savedInstanceState: Bundle?
savedInstanceState: Bundle?
): Dialog {
val materialDialog = MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT))
.show {
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
title(string.new_playlist_title)
customView(layout.dialog_playlist)
negativeButton(android.R.string.cancel)
positiveButton(string.create_action) {
if (activity == null) {
return@positiveButton
}
val songs = arguments?.getParcelableArrayList<Song>("songs")
?: return@positiveButton
.show {
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
title(string.new_playlist_title)
customView(layout.dialog_playlist)
negativeButton(android.R.string.cancel)
positiveButton(string.create_action) {
if (activity == null) {
return@positiveButton
}
val songs = arguments?.getParcelableArrayList<Song>("songs")
?: return@positiveButton
if (playlistView.text.toString().trim { it <= ' ' }.isNotEmpty()) {
val playlistId = PlaylistsUtil.createPlaylist(requireContext(), playlistView.text.toString())
if (playlistId != -1 && activity != null) {
PlaylistsUtil.addToPlaylist(requireContext(), songs, playlistId, true)
}
if (playlistView.text.toString().trim { it <= ' ' }.isNotEmpty()) {
val playlistId = PlaylistsUtil.createPlaylist(requireContext(), playlistView.text.toString())
if (playlistId != -1 && activity != null) {
PlaylistsUtil.addToPlaylist(requireContext(), songs, playlistId, true)
}
}
}
}
val dialogView = materialDialog.getCustomView()
playlistView = dialogView.findViewById(R.id.actionNewPlaylist)
@ -73,12 +72,14 @@ class CreatePlaylistDialog : DialogFragment() {
MaterialUtil.setTint(actionNewPlaylistContainer, false)
val playlistId = arguments!!.getLong(MediaStore.Audio.Playlists.Members.PLAYLIST_ID)
playlistView.appHandleColor().setText(PlaylistsUtil.getNameForPlaylist(requireContext(), playlistId), TextView.BufferType.EDITABLE)
playlistView.appHandleColor()
.setText(PlaylistsUtil.getNameForPlaylist(requireContext(), playlistId), TextView.BufferType.EDITABLE)
return materialDialog
}
companion object {
@JvmOverloads
@JvmStatic
fun create(song: Song? = null): CreatePlaylistDialog {
val list = ArrayList<Song>()
if (song != null) {
@ -87,6 +88,7 @@ class CreatePlaylistDialog : DialogFragment() {
return create(list)
}
@JvmStatic
fun create(songs: ArrayList<Song>): CreatePlaylistDialog {
val dialog = CreatePlaylistDialog()
val args = Bundle()

View File

@ -37,8 +37,10 @@ class OptionsSheetDialogFragment : DialogFragment(), View.OnClickListener {
override fun onClick(view: View) {
val mainActivity = activity as MainActivity? ?: return
when (view.id) {
R.id.actionFolders -> mainActivity.setMusicChooser(MainActivity.FOLDER)
R.id.actionLibrary -> mainActivity.setMusicChooser(MainActivity.LIBRARY)
R.id.actionFolders -> {
}//mainActivity.setMusicChooser(MainActivity.FOLDER)
R.id.actionLibrary -> {
}//mainActivity.setMusicChooser(MainActivity.LIBRARY)
R.id.actionSettings -> NavigationUtil.goToSettings(mainActivity)
R.id.actionDriveMode -> NavigationUtil.gotoDriveMode(mainActivity)
R.id.actionRate -> NavigationUtil.goToPlayStore(mainActivity)
@ -105,6 +107,7 @@ class OptionsSheetDialogFragment : DialogFragment(), View.OnClickListener {
@JvmField
var FOLDER: Int = 1
@JvmStatic
fun newInstance(selectedId: Int): OptionsSheetDialogFragment {
val bundle = Bundle()
bundle.putInt(WHICH_ONE, selectedId)
@ -113,6 +116,7 @@ class OptionsSheetDialogFragment : DialogFragment(), View.OnClickListener {
return fragment
}
@JvmStatic
fun newInstance(): OptionsSheetDialogFragment {
return OptionsSheetDialogFragment()
}

View File

@ -1,32 +0,0 @@
/*
* 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.
*/
package code.name.monkey.retromusic.extensions
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song
/**
* Created by hemanths on 2019-11-01.
*/
fun ArrayList<Song>.lastElement(): Boolean {
println("${this.size} ${this.indexOf(MusicPlayerRemote.currentSong)}")
return this.size - 1 == this.indexOf(MusicPlayerRemote.currentSong)
}
fun ArrayList<Song>.fistElement(): Boolean {
return 0 == this.indexOf(MusicPlayerRemote.currentSong)
}

View File

@ -109,7 +109,7 @@ abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>,
container.paddingLeft,
container.paddingTop,
container.paddingRight,
mainActivity.getTotalAppBarScrollingRange() + i
mainActivity.totalAppBarScrollingRange + i
)
}

View File

@ -118,7 +118,7 @@ class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAd
companion object {
@JvmField
var TAG: String = AlbumsFragment::class.java.simpleName
@JvmStatic
fun newInstance(): AlbumsFragment {
val args = Bundle()
val fragment = AlbumsFragment()

View File

@ -111,7 +111,7 @@ class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Artist
companion object {
@JvmField
val TAG: String = ArtistsFragment::class.java.simpleName
@JvmStatic
fun newInstance(): ArtistsFragment {
val args = Bundle()
val fragment = ArtistsFragment()

View File

@ -85,7 +85,7 @@ class GenresFragment : AbsLibraryPagerRecyclerViewFragment<GenreAdapter, LinearL
companion object {
@JvmField
val TAG: String = GenresFragment::class.java.simpleName
@JvmStatic
fun newInstance(): GenresFragment {
return GenresFragment()
}

View File

@ -137,7 +137,7 @@ class PlayingQueueFragment : AbsLibraryPagerRecyclerViewFragment<PlayingQueueAda
companion object {
@JvmField
val TAG: String = PlayingQueueFragment::class.java.simpleName
@JvmStatic
fun newInstance(): PlayingQueueFragment {
return PlayingQueueFragment()
}

View File

@ -88,6 +88,7 @@ class PlaylistsFragment : AbsLibraryPagerRecyclerViewFragment<PlaylistAdapter, L
@JvmField
val TAG: String = PlaylistsFragment::class.java.simpleName
@JvmStatic
fun newInstance(): PlaylistsFragment {
val args = Bundle()
val fragment = PlaylistsFragment()

View File

@ -1,26 +1,17 @@
package code.name.monkey.retromusic.fragments.mainactivity.home
import android.app.ActivityOptions
import android.content.res.ColorStateList
import android.os.Bundle
import android.util.DisplayMetrics
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import androidx.recyclerview.widget.LinearLayoutManager
import code.name.monkey.appthemehelper.common.ATHToolbarActivity
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.Constants
import code.name.monkey.retromusic.Constants.USER_BANNER
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.adapter.HomeAdapter
import code.name.monkey.retromusic.dialogs.OptionsSheetDialogFragment
import code.name.monkey.retromusic.extensions.show
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote
@ -42,7 +33,6 @@ import kotlinx.android.synthetic.main.abs_playlists.lastAdded
import kotlinx.android.synthetic.main.abs_playlists.topPlayed
import kotlinx.android.synthetic.main.fragment_banner_home.bannerImage
import kotlinx.android.synthetic.main.fragment_banner_home.titleWelcome
import kotlinx.android.synthetic.main.fragment_banner_home.toolbarContainer
import kotlinx.android.synthetic.main.fragment_banner_home.userImage
import kotlinx.android.synthetic.main.home_content.emptyContainer
import kotlinx.android.synthetic.main.home_content.recyclerView
@ -56,10 +46,8 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
lateinit var homePresenter: HomePresenter
private lateinit var homeAdapter: HomeAdapter
private lateinit var toolbar: Toolbar
override fun sections(sections: List<Home>) {
println(sections.size)
homeAdapter.swapData(sections)
}
@ -93,7 +81,6 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setStatusBarColorAuto(view)
toolbar = view.findViewById(R.id.toolbar)
bannerImage?.setOnClickListener {
val options = ActivityOptions.makeSceneTransitionAnimation(
@ -120,8 +107,6 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
NavigationUtil.goToPlaylistNew(requireActivity(), HistoryPlaylist(requireActivity()))
}
setupToolbar()
userImage?.setOnClickListener {
val options = ActivityOptions.makeSceneTransitionAnimation(
mainActivity,
@ -143,24 +128,6 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
homePresenter.loadSections()
}
private fun setupToolbar() {
toolbar.apply {
backgroundTintList = ColorStateList.valueOf(ATHUtil.resolveColor(requireContext(), R.attr.colorSurface))
setNavigationIcon(R.drawable.ic_menu_white_24dp)
setOnClickListener {
val options = ActivityOptions.makeSceneTransitionAnimation(
mainActivity,
toolbarContainer,
getString(R.string.transition_toolbar)
)
NavigationUtil.goToSearch(requireActivity(), options)
}
}
mainActivity.setSupportActionBar(toolbar)
toolbar.setNavigationOnClickListener { showMainMenu(OptionsSheetDialogFragment.LIBRARY) }
}
override fun handleBackPress(): Boolean {
return false
}
@ -179,35 +146,6 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
emptyContainer.show()
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
super.onCreateOptionsMenu(menu, inflater)
inflater.inflate(R.menu.menu_search, menu)
ToolbarContentTintHelper.handleOnCreateOptionsMenu(
requireActivity(),
toolbar,
menu,
ATHToolbarActivity.getToolbarBackgroundColor(toolbar)
)
}
override fun onPrepareOptionsMenu(menu: Menu) {
super.onPrepareOptionsMenu(menu)
ToolbarContentTintHelper.handleOnPrepareOptionsMenu(requireActivity(), toolbar)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.action_search) {
val options = ActivityOptions.makeSceneTransitionAnimation(
mainActivity,
toolbarContainer,
getString(R.string.transition_toolbar)
)
NavigationUtil.goToSearch(requireActivity(), true, options)
}
return super.onOptionsItemSelected(item)
}
private fun getTimeOfTheDay() {
val c = Calendar.getInstance()
val timeOfDay = c.get(Calendar.HOUR_OF_DAY)
@ -250,6 +188,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
const val TAG: String = "BannerHomeFragment"
@JvmStatic
fun newInstance(): BannerHomeFragment {
return BannerHomeFragment()
}

View File

@ -265,7 +265,7 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment(), OnSharedPref
}
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
println(key)
if (key == PreferenceUtil.EXTRA_SONG_INFO) {
if (activity != null) updateSong()
}

View File

@ -152,14 +152,12 @@ class PeakPlayerControlFragment : AbsPlayerControlsFragment() {
private fun setUpShuffleButton() {
shuffleButton.setOnClickListener {
println("shuffleButton Click")
MusicPlayerRemote.toggleShuffleMode()
}
}
private fun setUpRepeatButton() {
repeatButton.setOnClickListener {
println("repeatButton Click")
MusicPlayerRemote.cycleRepeatMode()
}
}

View File

@ -44,7 +44,7 @@ object MusicPlayerRemote {
val TAG: String = MusicPlayerRemote::class.java.simpleName
private val mConnectionMap = WeakHashMap<Context, ServiceBinder>()
var musicService: MusicService? = null
@JvmStatic
val isPlaying: Boolean
get() = musicService != null && musicService!!.isPlaying
@ -91,7 +91,7 @@ object MusicPlayerRemote {
get() = if (musicService != null) {
musicService!!.repeatMode
} else MusicService.REPEAT_MODE_NONE
@JvmStatic
val shuffleMode: Int
get() = if (musicService != null) {
musicService!!.shuffleMode
@ -207,6 +207,7 @@ object MusicPlayerRemote {
/**
* Async
*/
@JvmStatic
fun openQueue(queue: List<Song>, startPosition: Int, startPlaying: Boolean) {
if (!tryToHandleOpenPlayingQueue(queue, startPosition, startPlaying) && musicService != null) {
musicService?.openQueue(queue, startPosition, startPlaying)
@ -218,6 +219,7 @@ object MusicPlayerRemote {
/**
* Async
*/
@JvmStatic
fun openAndShuffleQueue(queue: List<Song>, startPlaying: Boolean) {
var startPosition = 0
if (queue.isNotEmpty()) {
@ -388,7 +390,7 @@ object MusicPlayerRemote {
}
return false
}
@JvmStatic
fun playFromUri(uri: Uri) {
if (musicService != null) {

View File

@ -20,8 +20,7 @@ import android.os.Bundle
import android.provider.MediaStore
import code.name.monkey.retromusic.loaders.SongLoader
import code.name.monkey.retromusic.model.Song
import java.util.*
import java.util.ArrayList
object SearchQueryHelper {
private const val TITLE_SELECTION = "lower(" + MediaStore.Audio.AudioColumns.TITLE + ") = ?"
@ -29,7 +28,7 @@ object SearchQueryHelper {
private const val ARTIST_SELECTION = "lower(" + MediaStore.Audio.AudioColumns.ARTIST + ") = ?"
private const val AND = " AND "
var songs = ArrayList<Song>()
@JvmStatic
fun getSongs(context: Context, extras: Bundle): ArrayList<Song> {
val query = extras.getString(SearchManager.QUERY, null)
val artistName = extras.getString(MediaStore.EXTRA_MEDIA_ARTIST, null)
@ -38,42 +37,79 @@ object SearchQueryHelper {
var songs = ArrayList<Song>()
if (artistName != null && albumName != null && titleName != null) {
songs = SongLoader.getSongs(SongLoader.makeSongCursor(context, ARTIST_SELECTION + AND + ALBUM_SELECTION + AND + TITLE_SELECTION, arrayOf(artistName.toLowerCase(), albumName.toLowerCase(), titleName.toLowerCase())))
songs = SongLoader.getSongs(
SongLoader.makeSongCursor(
context,
ARTIST_SELECTION + AND + ALBUM_SELECTION + AND + TITLE_SELECTION,
arrayOf(artistName.toLowerCase(), albumName.toLowerCase(), titleName.toLowerCase())
)
)
}
if (songs.isNotEmpty()) {
return songs
}
if (artistName != null && titleName != null) {
songs = SongLoader.getSongs(SongLoader.makeSongCursor(context, ARTIST_SELECTION + AND + TITLE_SELECTION, arrayOf(artistName.toLowerCase(), titleName.toLowerCase())))
songs = SongLoader.getSongs(
SongLoader.makeSongCursor(
context,
ARTIST_SELECTION + AND + TITLE_SELECTION,
arrayOf(artistName.toLowerCase(), titleName.toLowerCase())
)
)
}
if (songs.isNotEmpty()) {
return songs
}
if (albumName != null && titleName != null) {
songs = SongLoader.getSongs(SongLoader.makeSongCursor(context, ALBUM_SELECTION + AND + TITLE_SELECTION, arrayOf(albumName.toLowerCase(), titleName.toLowerCase())))
songs = SongLoader.getSongs(
SongLoader.makeSongCursor(
context,
ALBUM_SELECTION + AND + TITLE_SELECTION,
arrayOf(albumName.toLowerCase(), titleName.toLowerCase())
)
)
}
if (songs.isNotEmpty()) {
return songs
}
if (artistName != null) {
songs = SongLoader.getSongs(SongLoader.makeSongCursor(context, ARTIST_SELECTION, arrayOf(artistName.toLowerCase())))
songs = SongLoader.getSongs(
SongLoader.makeSongCursor(
context,
ARTIST_SELECTION,
arrayOf(artistName.toLowerCase())
)
)
}
if (songs.isNotEmpty()) {
return songs
}
if (albumName != null) {
songs = SongLoader.getSongs(SongLoader.makeSongCursor(context, ALBUM_SELECTION, arrayOf(albumName.toLowerCase())))
songs = SongLoader.getSongs(
SongLoader.makeSongCursor(
context,
ALBUM_SELECTION,
arrayOf(albumName.toLowerCase())
)
)
}
if (songs.isNotEmpty()) {
return songs
}
if (titleName != null) {
songs = SongLoader.getSongs(SongLoader.makeSongCursor(context, TITLE_SELECTION, arrayOf(titleName.toLowerCase())))
songs = SongLoader.getSongs(
SongLoader.makeSongCursor(
context,
TITLE_SELECTION,
arrayOf(titleName.toLowerCase())
)
)
}
if (songs.isNotEmpty()) {
return songs
}
songs = SongLoader.getSongs(SongLoader.makeSongCursor(context, ARTIST_SELECTION, arrayOf(query.toLowerCase())))
songs =
SongLoader.getSongs(SongLoader.makeSongCursor(context, ARTIST_SELECTION, arrayOf(query.toLowerCase())))
if (songs.isNotEmpty()) {
return songs
@ -87,6 +123,4 @@ object SearchQueryHelper {
songs
} else ArrayList()
}
}

View File

@ -19,8 +19,7 @@ import android.provider.MediaStore.Audio.AudioColumns
import code.name.monkey.retromusic.model.Album
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.PreferenceUtil
import java.util.*
import kotlin.collections.ArrayList
import java.util.Comparator
/**
@ -41,7 +40,7 @@ object AlbumLoader {
)
return splitIntoAlbums(songs)
}
@JvmStatic
fun getAlbum(
context: Context,
albumId: Int

View File

@ -20,27 +20,32 @@ import code.name.monkey.retromusic.model.Album
import code.name.monkey.retromusic.model.Artist
import code.name.monkey.retromusic.util.PreferenceUtil
object ArtistLoader {
private fun getSongLoaderSortOrder(context: Context): String {
return PreferenceUtil.getInstance(context).artistSortOrder + ", " + PreferenceUtil.getInstance(context).artistAlbumSortOrder + ", " + PreferenceUtil.getInstance(context).albumSongSortOrder
return PreferenceUtil.getInstance(context).artistSortOrder + ", " + PreferenceUtil.getInstance(context).artistAlbumSortOrder + ", " + PreferenceUtil.getInstance(
context
).albumSongSortOrder
}
fun getAllArtists(context: Context): ArrayList<Artist> {
val songs = SongLoader.getSongs(SongLoader.makeSongCursor(
val songs = SongLoader.getSongs(
SongLoader.makeSongCursor(
context,
null, null,
getSongLoaderSortOrder(context))
getSongLoaderSortOrder(context)
)
)
return splitIntoArtists(AlbumLoader.splitIntoAlbums(songs))
}
fun getArtists(context: Context, query: String): ArrayList<Artist> {
val songs = SongLoader.getSongs(SongLoader.makeSongCursor(
val songs = SongLoader.getSongs(
SongLoader.makeSongCursor(
context,
AudioColumns.ARTIST + " LIKE ?",
arrayOf("%$query%"),
getSongLoaderSortOrder(context))
getSongLoaderSortOrder(context)
)
)
return splitIntoArtists(AlbumLoader.splitIntoAlbums(songs))
}
@ -66,12 +71,15 @@ object ArtistLoader {
return album
}
@JvmStatic
fun getArtist(context: Context, artistId: Int): Artist {
val songs = SongLoader.getSongs(SongLoader.makeSongCursor(
val songs = SongLoader.getSongs(
SongLoader.makeSongCursor(
context,
AudioColumns.ARTIST_ID + "=?",
arrayOf(artistId.toString()),
getSongLoaderSortOrder(context))
getSongLoaderSortOrder(context)
)
)
return Artist(AlbumLoader.splitIntoAlbums(songs))
}

View File

@ -38,7 +38,7 @@ object PlaylistSongsLoader {
return (playlist as? AbsCustomPlaylist)?.getSongs(context)
?: getPlaylistSongList(context, playlist.id)
}
@JvmStatic
fun getPlaylistSongList(context: Context, playlistId: Int): ArrayList<Song> {
val songs = arrayListOf<Song>()
val cursor = makePlaylistSongCursor(context, playlistId)

View File

@ -17,6 +17,7 @@ package code.name.monkey.retromusic.model
import java.util.ArrayList
class Album {
val songs: ArrayList<Song>?
val id: Int

View File

@ -124,7 +124,6 @@ class MaterialListPreferenceDialog : PreferenceDialogFragmentCompat() {
fun newInstance(listPreference: ListPreference): MaterialListPreferenceDialog {
val entries = listPreference.entries.toList() as ArrayList<String>
val entriesValues = listPreference.entryValues.toList() as ArrayList<String>
println("List value: ${listPreference.value}")
val position = listPreference.findIndexOfValue(listPreference.value)
val args = Bundle()
args.putString(ARG_KEY, listPreference.key)

View File

@ -34,7 +34,7 @@ object AppRater {
private const val DAYS_UNTIL_PROMPT = 3//Min number of days
private const val LAUNCHES_UNTIL_PROMPT = 5//Min number of launches
@JvmStatic
fun appLaunched(context: Context) {
val prefs = context.getSharedPreferences(APP_RATING, 0)
if (prefs.getBoolean(DO_NOT_SHOW_AGAIN, false)) {
@ -66,26 +66,31 @@ object AppRater {
private fun showRateDialog(context: Context, editor: SharedPreferences.Editor) {
MaterialDialog(context, BottomSheet(LayoutMode.WRAP_CONTENT))
.show {
.show {
cornerRadius(PreferenceUtil.getInstance(context).dialogCorner)
title(text = "Rate this App")
message(text = "If you enjoy using Retro Music, please take a moment to rate it. Thanks for your support!")
positiveButton(R.string.app_name) {
context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=${context.packageName}")))
editor.putBoolean(DO_NOT_SHOW_AGAIN, true)
editor.commit()
dismiss()
}
negativeButton(text = "Later") {
dismiss()
}
neutralButton(text = " No thanks") {
editor.putBoolean(DO_NOT_SHOW_AGAIN, true)
editor.commit()
dismiss()
}
getActionButton(WhichButton.POSITIVE).updateTextColor(Color.RED)
cornerRadius(PreferenceUtil.getInstance(context).dialogCorner)
title(text = "Rate this App")
message(text = "If you enjoy using Retro Music, please take a moment to rate it. Thanks for your support!")
positiveButton(R.string.app_name) {
context.startActivity(
Intent(
Intent.ACTION_VIEW,
Uri.parse("market://details?id=${context.packageName}")
)
)
editor.putBoolean(DO_NOT_SHOW_AGAIN, true)
editor.commit()
dismiss()
}
negativeButton(text = "Later") {
dismiss()
}
neutralButton(text = " No thanks") {
editor.putBoolean(DO_NOT_SHOW_AGAIN, true)
editor.commit()
dismiss()
}
getActionButton(WhichButton.POSITIVE).updateTextColor(Color.RED)
}
}
}

View File

@ -29,7 +29,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.StyleRes;
import androidx.viewpager.widget.ViewPager;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.activities.MainActivity;
import code.name.monkey.retromusic.fragments.AlbumCoverStyle;
import code.name.monkey.retromusic.fragments.NowPlayingScreen;
import code.name.monkey.retromusic.fragments.mainactivity.folders.FoldersFragment;
@ -585,14 +584,6 @@ public final class PreferenceUtil {
return mPreferences.getInt(LAST_CHANGELOG_VERSION, -1);
}
public final int getLastMusicChooser() {
return mPreferences.getInt(LAST_MUSIC_CHOOSER, MainActivity.HOME);
}
public void setLastMusicChooser(int value) {
mPreferences.edit().putInt(LAST_MUSIC_CHOOSER, value).apply();
}
public final int getLastPage() {
return mPreferences.getInt(LAST_PAGE, R.id.action_song);
}

View File

@ -12,130 +12,89 @@
~ See the GNU General Public License for more details.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.core.widget.NestedScrollView 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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorSurface"
android:orientation="vertical">
android:layout_marginStart="@dimen/toolbar_margin_horizontal"
android:layout_marginEnd="@dimen/toolbar_margin_horizontal"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<FrameLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/status_bar" />
</FrameLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/toolbar_margin_horizontal"
android:layout_marginEnd="@dimen/toolbar_margin_horizontal"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<LinearLayout
<com.google.android.material.card.MaterialCardView
android:id="@+id/imageContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_height="228dp"
app:cardCornerRadius="24dp"
app:cardUseCompatPadding="true">
<com.google.android.material.card.MaterialCardView
android:id="@+id/imageContainer"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="228dp"
app:cardCornerRadius="24dp"
app:cardUseCompatPadding="true">
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/bannerImage"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
tools:ignore="ContentDescription"
tools:srcCompat="@tools:sample/backgrounds/scenic[9]" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/bannerImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
tools:ignore="ContentDescription"
tools:srcCompat="@tools:sample/backgrounds/scenic[9]" />
<View
android:layout_width="match_parent"
android:layout_height="52dp"
android:background="@drawable/shadow_up"
app:layout_constraintBottom_toBottomOf="parent" />
<code.name.monkey.retromusic.views.CircularImageView
android:id="@+id/userImage"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_marginStart="16dp"
android:layout_marginBottom="8dp"
app:civ_border="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:srcCompat="@tools:sample/avatars" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:ellipsize="end"
android:text="@string/welcome"
android:textColor="@color/md_white_1000"
app:layout_constraintStart_toEndOf="@+id/userImage"
app:layout_constraintTop_toTopOf="@+id/userImage" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/titleWelcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:padding="0dp"
android:textAppearance="@style/TextViewHeadline5"
android:textColor="@color/md_white_1000"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/userImage"
app:layout_constraintStart_toEndOf="@+id/userImage"
app:layout_constraintTop_toBottomOf="@+id/text"
tools:text="@string/app_name" />
<com.google.android.material.card.MaterialCardView
android:id="@+id/toolbarContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/toolbar_margin_horizontal"
android:layout_marginTop="8dp"
android:layout_marginEnd="@dimen/toolbar_margin_horizontal"
app:cardBackgroundColor="@android:color/transparent"
app:cardCornerRadius="8dp"
app:cardUseCompatPadding="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_scrollFlags="scroll|enterAlways"
app:shapeAppearance="@style/ToolbarCornerCardView">
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:background="?attr/colorSurface"
app:popupTheme="?toolbarPopupTheme"
app:title="@string/action_search"
app:titleTextAppearance="@style/TextViewHeadline6"
tools:ignore="UnusedAttribute" />
</com.google.android.material.card.MaterialCardView>
<View
android:layout_width="match_parent"
android:layout_height="52dp"
android:background="@drawable/shadow_up"
app:layout_constraintBottom_toBottomOf="parent" />
<code.name.monkey.retromusic.views.CircularImageView
android:id="@+id/userImage"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_marginStart="16dp"
android:layout_marginBottom="8dp"
app:civ_border="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:srcCompat="@tools:sample/avatars" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:ellipsize="end"
android:text="@string/welcome"
android:textColor="@color/md_white_1000"
app:layout_constraintStart_toEndOf="@+id/userImage"
app:layout_constraintTop_toTopOf="@+id/userImage" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/titleWelcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:padding="0dp"
android:textAppearance="@style/TextViewHeadline5"
android:textColor="@color/md_white_1000"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/userImage"
app:layout_constraintStart_toEndOf="@+id/userImage"
app:layout_constraintTop_toBottomOf="@+id/text"
tools:text="@string/app_name" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
<include layout="@layout/home_content" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
<include layout="@layout/home_content" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View File

@ -12,115 +12,64 @@
~ See the GNU General Public License for more details.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.core.widget.NestedScrollView 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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorSurface"
android:orientation="vertical">
android:layout_marginStart="@dimen/toolbar_margin_horizontal"
android:layout_marginEnd="@dimen/toolbar_margin_horizontal"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<FrameLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="UnusedAttribute">
android:layout_height="wrap_content">
<include layout="@layout/status_bar" />
<code.name.monkey.retromusic.views.CircularImageView
android:id="@+id/userImage"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
app:civ_border="false"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@tools:sample/avatars" />
</FrameLayout>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
<com.google.android.material.textview.MaterialTextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:elevation="0dp"
app:elevation="0dp">
android:layout_marginStart="16dp"
android:ellipsize="end"
android:text="@string/welcome"
app:layout_constraintStart_toEndOf="@+id/userImage"
app:layout_constraintTop_toTopOf="@+id/userImage"
tools:text="@tools:sample/lorem" />
<com.google.android.material.card.MaterialCardView
android:id="@+id/toolbarContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="8dp"
app:cardUseCompatPadding="true"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/titleWelcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:padding="0dp"
android:textAppearance="@style/TextViewHeadline5"
android:textColor="?android:attr/textColorPrimary"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/userImage"
app:layout_constraintStart_toEndOf="@+id/userImage"
app:layout_constraintTop_toBottomOf="@+id/text"
tools:text="@tools:sample/lorem" />
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:background="?colorSurface"
app:popupTheme="?toolbarPopupTheme"
app:title="@string/action_search"
app:titleTextAppearance="@style/TextViewHeadline6"
tools:ignore="UnusedAttribute" />
</com.google.android.material.card.MaterialCardView>
<include
layout="@layout/home_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/titleWelcome" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/toolbar_margin_horizontal"
android:layout_marginEnd="@dimen/toolbar_margin_horizontal"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<code.name.monkey.retromusic.views.CircularImageView
android:id="@+id/userImage"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
app:civ_border="false"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@tools:sample/avatars" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:ellipsize="end"
android:text="@string/welcome"
app:layout_constraintStart_toEndOf="@+id/userImage"
app:layout_constraintTop_toTopOf="@+id/userImage"
tools:text="@tools:sample/lorem" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/titleWelcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:padding="0dp"
android:textAppearance="@style/TextViewHeadline5"
android:textColor="?android:attr/textColorPrimary"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/userImage"
app:layout_constraintStart_toEndOf="@+id/userImage"
app:layout_constraintTop_toBottomOf="@+id/text"
tools:text="@tools:sample/lorem" />
<include
layout="@layout/home_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/titleWelcome" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View File

@ -46,7 +46,7 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:background="?colorSurface"
android:background="?attr/colorSurface"
app:navigationIcon="@drawable/ic_menu_white_24dp"
app:popupTheme="?attr/toolbarPopupTheme"
app:title="@string/action_search"

View File

@ -11,133 +11,97 @@
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~ See the GNU General Public License for more details.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.core.widget.NestedScrollView 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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorSurface"
android:orientation="vertical">
android:layout_height="wrap_content"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/status_bar" />
</FrameLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/container"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/bannerContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/bannerContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.google.android.material.card.MaterialCardView
android:id="@+id/toolbarContainer"
<com.google.android.material.card.MaterialCardView
android:id="@+id/imageContainer"
android:layout_width="0dp"
android:layout_height="0dp"
app:cardCornerRadius="24dp"
app:cardUseCompatPadding="true"
app:layout_constraintDimensionRatio="21:10"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbarContainer">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="8dp"
app:cardUseCompatPadding="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_scrollFlags="scroll|enterAlways"
app:shapeAppearance="@style/ToolbarCornerCardView">
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/bannerImage"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:background="?attr/colorSurface"
app:popupTheme="?toolbarPopupTheme"
app:title="@string/action_search"
app:titleTextAppearance="@style/TextViewHeadline6"
tools:ignore="UnusedAttribute" />
</com.google.android.material.card.MaterialCardView>
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
tools:ignore="ContentDescription"
tools:srcCompat="@tools:sample/backgrounds/scenic[9]" />
<com.google.android.material.card.MaterialCardView
android:id="@+id/imageContainer"
android:layout_width="0dp"
android:layout_height="0dp"
app:cardCornerRadius="24dp"
app:cardUseCompatPadding="true"
app:layout_constraintDimensionRatio="21:10"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbarContainer">
<androidx.constraintlayout.widget.ConstraintLayout
<View
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="52dp"
android:background="@drawable/shadow_up"
app:layout_constraintBottom_toBottomOf="parent" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/bannerImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
tools:ignore="ContentDescription"
tools:srcCompat="@tools:sample/backgrounds/scenic[9]" />
<code.name.monkey.retromusic.views.CircularImageView
android:id="@+id/userImage"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_marginStart="16dp"
android:layout_marginBottom="8dp"
app:civ_border="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:srcCompat="@tools:sample/avatars" />
<View
android:layout_width="match_parent"
android:layout_height="52dp"
android:background="@drawable/shadow_up"
app:layout_constraintBottom_toBottomOf="parent" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:ellipsize="end"
android:text="@string/welcome"
android:textColor="@color/md_white_1000"
app:layout_constraintStart_toEndOf="@+id/userImage"
app:layout_constraintTop_toTopOf="@+id/userImage" />
<code.name.monkey.retromusic.views.CircularImageView
android:id="@+id/userImage"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_marginStart="16dp"
android:layout_marginBottom="8dp"
app:civ_border="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:srcCompat="@tools:sample/avatars" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:ellipsize="end"
android:text="@string/welcome"
android:textColor="@color/md_white_1000"
app:layout_constraintStart_toEndOf="@+id/userImage"
app:layout_constraintTop_toTopOf="@+id/userImage" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/titleWelcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:padding="0dp"
android:textAppearance="@style/TextViewHeadline5"
android:textColor="@color/md_white_1000"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/userImage"
app:layout_constraintStart_toEndOf="@+id/userImage"
app:layout_constraintTop_toBottomOf="@+id/text"
tools:text="@string/app_name" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/titleWelcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:padding="0dp"
android:textAppearance="@style/TextViewHeadline5"
android:textColor="@color/md_white_1000"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/userImage"
app:layout_constraintStart_toEndOf="@+id/userImage"
app:layout_constraintTop_toBottomOf="@+id/text"
tools:text="@string/app_name" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
<include
layout="@layout/home_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageContainer" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
<include
layout="@layout/home_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageContainer" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>

View File

@ -11,113 +11,62 @@
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~ See the GNU General Public License for more details.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.core.widget.NestedScrollView 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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorSurface"
android:orientation="vertical">
android:layout_height="wrap_content"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<FrameLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/status_bar" />
</FrameLayout>
<code.name.monkey.retromusic.views.CircularImageView
android:id="@+id/userImage"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
app:civ_border="false"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@tools:sample/avatars" />
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
<com.google.android.material.textview.MaterialTextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:elevation="0dp"
app:elevation="0dp"
app:liftOnScroll="true">
android:layout_marginStart="16dp"
android:ellipsize="end"
android:text="@string/welcome"
app:layout_constraintStart_toEndOf="@+id/userImage"
app:layout_constraintTop_toTopOf="@+id/userImage"
tools:text="@tools:sample/lorem" />
<com.google.android.material.card.MaterialCardView
android:id="@+id/toolbarContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="?attr/colorSurface"
app:cardCornerRadius="8dp"
app:cardUseCompatPadding="true"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:background="?attr/colorSurface"
app:popupTheme="?toolbarPopupTheme"
app:title="@string/action_search"
app:titleTextAppearance="@style/TextViewHeadline6"
tools:ignore="UnusedAttribute" />
</com.google.android.material.card.MaterialCardView>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/container"
android:layout_width="match_parent"
<com.google.android.material.textview.MaterialTextView
android:id="@+id/titleWelcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
android:layout_marginStart="16dp"
android:padding="0dp"
android:textAppearance="@style/TextViewHeadline5"
android:textColor="?android:attr/textColorPrimary"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/userImage"
app:layout_constraintStart_toEndOf="@+id/userImage"
app:layout_constraintTop_toBottomOf="@+id/text"
tools:text="@tools:sample/lorem" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
layout="@layout/home_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/titleWelcome" />
</androidx.constraintlayout.widget.ConstraintLayout>
<code.name.monkey.retromusic.views.CircularImageView
android:id="@+id/userImage"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
app:civ_border="false"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@tools:sample/avatars" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:ellipsize="end"
android:text="@string/welcome"
app:layout_constraintStart_toEndOf="@+id/userImage"
app:layout_constraintTop_toTopOf="@+id/userImage"
tools:text="@tools:sample/lorem" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/titleWelcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:padding="0dp"
android:textAppearance="@style/TextViewHeadline5"
android:textColor="?android:attr/textColorPrimary"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/userImage"
app:layout_constraintStart_toEndOf="@+id/userImage"
app:layout_constraintTop_toBottomOf="@+id/text"
tools:text="@tools:sample/lorem" />
<include
layout="@layout/home_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/titleWelcome" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>