Removed Some animations and palette
This commit is contained in:
parent
b293123603
commit
af21f191dd
20 changed files with 343 additions and 120 deletions
|
|
@ -33,7 +33,7 @@ public class AlbumViewGridAdapter extends ArrayAdapter<Album> {
|
|||
public AlbumViewGridAdapter(Context context, List<Album> objects) {
|
||||
super(context, R.layout.album_tile, objects);
|
||||
this.context = context;
|
||||
usePalette = true;
|
||||
usePalette = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -62,7 +62,6 @@ public class AlbumViewGridAdapter extends ArrayAdapter<Album> {
|
|||
Picasso.with(context)
|
||||
.load(MusicUtil.getAlbumArtUri(album.id))
|
||||
.placeholder(R.drawable.default_album_art)
|
||||
.error(R.drawable.default_album_art)
|
||||
.into(viewHolder.image, new Callback.EmptyCallback(){
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import android.provider.BaseColumns;
|
|||
import android.provider.MediaStore;
|
||||
|
||||
import com.kabouzeid.gramophone.model.Album;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -57,7 +58,7 @@ public class AlbumLoader {
|
|||
MediaStore.Audio.AlbumColumns.NUMBER_OF_SONGS,
|
||||
/* 5 */
|
||||
MediaStore.Audio.AlbumColumns.FIRST_YEAR
|
||||
}, selection, null, null);
|
||||
}, selection, null, PreferenceUtils.getInstace(context).getAlbumSortOrder());
|
||||
}
|
||||
|
||||
public static Album getAlbum(Context context, int albumId) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import android.provider.BaseColumns;
|
|||
import android.provider.MediaStore;
|
||||
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
|
@ -68,6 +69,6 @@ public class AlbumSongLoader {
|
|||
MediaStore.Audio.AudioColumns.TRACK,
|
||||
/* 6 */
|
||||
MediaStore.Audio.AudioColumns.ARTIST_ID
|
||||
}, selection.toString(), null, null);
|
||||
}, selection.toString(), null, PreferenceUtils.getInstace(context).getAlbumSongSortOrder());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import android.provider.BaseColumns;
|
|||
import android.provider.MediaStore;
|
||||
|
||||
import com.kabouzeid.gramophone.model.Album;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -50,6 +51,6 @@ public class ArtistAlbumLoader {
|
|||
MediaStore.Audio.AlbumColumns.NUMBER_OF_SONGS,
|
||||
/* 4 */
|
||||
MediaStore.Audio.AlbumColumns.FIRST_YEAR
|
||||
}, null, null, null);
|
||||
}, null, null, PreferenceUtils.getInstace(context).getArtistAlbumSortOrder());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import android.provider.BaseColumns;
|
|||
import android.provider.MediaStore;
|
||||
|
||||
import com.kabouzeid.gramophone.model.Artist;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -51,7 +52,7 @@ public class ArtistLoader {
|
|||
MediaStore.Audio.ArtistColumns.NUMBER_OF_ALBUMS,
|
||||
/* 3 */
|
||||
MediaStore.Audio.ArtistColumns.NUMBER_OF_TRACKS
|
||||
}, selection, null, null);
|
||||
}, selection, null, PreferenceUtils.getInstace(context).getArtistSortOrder());
|
||||
}
|
||||
|
||||
public static Artist getArtist(Context context, int artistId) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import android.provider.BaseColumns;
|
|||
import android.provider.MediaStore;
|
||||
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -59,6 +60,6 @@ public class ArtistSongLoader {
|
|||
MediaStore.Audio.AudioColumns.TRACK,
|
||||
/* 6 */
|
||||
MediaStore.Audio.AudioColumns.ALBUM_ID
|
||||
}, selection.toString(), null, null);
|
||||
}, selection.toString(), null, PreferenceUtils.getInstace(context).getArtistSongSortOrder());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import android.provider.BaseColumns;
|
|||
import android.provider.MediaStore;
|
||||
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -62,7 +63,7 @@ public class SongLoader {
|
|||
MediaStore.Audio.AudioColumns.ARTIST_ID,
|
||||
/* 7 */
|
||||
MediaStore.Audio.AudioColumns.ALBUM_ID
|
||||
}, selection, null, null);
|
||||
}, selection, null, PreferenceUtils.getInstace(context).getSongSortOrder());
|
||||
}
|
||||
|
||||
public static List<Song> getSongs(Context context, String query) {
|
||||
|
|
|
|||
|
|
@ -7,13 +7,11 @@ import android.graphics.Color;
|
|||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v7.graphics.Palette;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ImageView;
|
||||
|
|
@ -37,10 +35,7 @@ import com.kabouzeid.gramophone.ui.activities.tageditor.AlbumTagEditorActivity;
|
|||
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||
import com.kabouzeid.gramophone.util.Util;
|
||||
import com.kabouzeid.gramophone.util.ViewUtil;
|
||||
import com.nhaarman.listviewanimations.appearance.AnimationAdapter;
|
||||
import com.nhaarman.listviewanimations.appearance.simple.ScaleInAnimationAdapter;
|
||||
import com.nineoldandroids.view.ViewHelper;
|
||||
import com.nineoldandroids.view.ViewPropertyAnimator;
|
||||
import com.squareup.picasso.Callback;
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
|
|
@ -58,15 +53,11 @@ public class AlbumDetailActivity extends AbsFabActivity implements KabViewsDisab
|
|||
public static final String TAG = AlbumDetailActivity.class.getSimpleName();
|
||||
|
||||
private static final boolean TOOLBAR_IS_STICKY = true;
|
||||
private static final int DEFAULT_DELAY_NO_TRANSITION = 200;
|
||||
private static final int DEFAULT_DELAY = 450;
|
||||
private static final int DEFAULT_ANIMATION_TIME = 1000;
|
||||
|
||||
private App app;
|
||||
|
||||
private Album album;
|
||||
|
||||
private AnimationAdapter animatedSongsAdapter;
|
||||
private ObservableListView absSongListView;
|
||||
private View statusBar;
|
||||
private ImageView albumArtImageView;
|
||||
|
|
@ -138,6 +129,8 @@ public class AlbumDetailActivity extends AbsFabActivity implements KabViewsDisab
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_album_detail);
|
||||
|
||||
if (Util.hasLollipopSDK()) postponeEnterTransition();
|
||||
|
||||
Bundle intentExtras = getIntent().getExtras();
|
||||
int albumId = -1;
|
||||
if (intentExtras != null) {
|
||||
|
|
@ -152,7 +145,8 @@ public class AlbumDetailActivity extends AbsFabActivity implements KabViewsDisab
|
|||
setUpObservableListViewParams();
|
||||
setUpToolBar();
|
||||
setUpViews();
|
||||
animateEnterActivity();
|
||||
|
||||
if (Util.hasLollipopSDK()) startPostponedEnterTransition();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -190,17 +184,11 @@ public class AlbumDetailActivity extends AbsFabActivity implements KabViewsDisab
|
|||
albumTitleView.setText(album.title);
|
||||
ViewHelper.setAlpha(albumArtOverlayView, 0);
|
||||
|
||||
prepareViewsForOpenAnimation();
|
||||
setUpAlbumArtAndApplyPalette();
|
||||
setUpListView();
|
||||
setUpSongsAdapter();
|
||||
}
|
||||
|
||||
private void prepareViewsForOpenAnimation() {
|
||||
albumTitleView.setPivotY(0);
|
||||
albumTitleView.setScaleY(0);
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private void setUpAlbumArtAndApplyPalette() {
|
||||
Picasso.with(this).load(MusicUtil.getAlbumArtUri(album.id))
|
||||
.placeholder(R.drawable.default_album_art)
|
||||
|
|
@ -285,39 +273,11 @@ public class AlbumDetailActivity extends AbsFabActivity implements KabViewsDisab
|
|||
}
|
||||
}
|
||||
|
||||
private void animateEnterActivity() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
animateHeader(0);
|
||||
setUpSongsAdapter();
|
||||
}
|
||||
}, DEFAULT_DELAY);
|
||||
|
||||
} else {
|
||||
setUpSongsAdapter();
|
||||
getFab().setScaleX(0);
|
||||
getFab().setScaleY(0);
|
||||
animateHeader(DEFAULT_DELAY_NO_TRANSITION);
|
||||
animateFab(DEFAULT_DELAY_NO_TRANSITION);
|
||||
}
|
||||
}
|
||||
|
||||
private void setUpSongsAdapter() {
|
||||
final List<Song> songs = AlbumSongLoader.getAlbumSongList(this, album.id, new SongTrackNumberComparator());
|
||||
final SongAdapter songAdapter = new SongAdapter(this, this, songs);
|
||||
|
||||
// SwingBottomInAnimationAdapter songsAdapter = new SwingBottomInAnimationAdapter(songAdapter);
|
||||
// SwingRightInAnimationAdapter songsAdapter = new SwingRightInAnimationAdapter(songAdapter);
|
||||
// SwingLeftInAnimationAdapter songsAdapter = new SwingLeftInAnimationAdapter(songAdapter);
|
||||
ScaleInAnimationAdapter songsAdapter = new ScaleInAnimationAdapter(songAdapter);
|
||||
// AlphaInAnimationAdapter songsAdapter = new AlphaInAnimationAdapter(songAdapter);
|
||||
|
||||
animatedSongsAdapter = songsAdapter;
|
||||
animatedSongsAdapter.setAbsListView(absSongListView);
|
||||
|
||||
absSongListView.setAdapter(animatedSongsAdapter);
|
||||
absSongListView.setAdapter(songAdapter);
|
||||
absSongListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
|
|
@ -328,26 +288,6 @@ public class AlbumDetailActivity extends AbsFabActivity implements KabViewsDisab
|
|||
});
|
||||
}
|
||||
|
||||
private void animateHeader(int startDelay) {
|
||||
ViewPropertyAnimator.animate(albumTitleView)
|
||||
.scaleX(1)
|
||||
.scaleY(1)
|
||||
.setInterpolator(new DecelerateInterpolator(4))
|
||||
.setDuration(DEFAULT_ANIMATION_TIME)
|
||||
.setStartDelay(startDelay)
|
||||
.start();
|
||||
}
|
||||
|
||||
private void animateFab(int startDelay) {
|
||||
ViewPropertyAnimator.animate(getFab())
|
||||
.scaleX(1)
|
||||
.scaleY(1)
|
||||
.setInterpolator(new DecelerateInterpolator(4))
|
||||
.setDuration(DEFAULT_ANIMATION_TIME)
|
||||
.setStartDelay(startDelay)
|
||||
.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableViews() {
|
||||
super.enableViews();
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import android.support.v13.app.FragmentPagerAdapter;
|
|||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.graphics.Palette;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.transition.Transition;
|
||||
import android.util.SparseArray;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
|
@ -91,40 +90,15 @@ public class ArtistDetailActivity extends AbsFabActivity implements KabViewsDisa
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_artist_detail);
|
||||
|
||||
if (Util.hasLollipopSDK()) postponeEnterTransition();
|
||||
|
||||
getIntentExtras();
|
||||
initViews();
|
||||
setUpObservableListViewParams();
|
||||
setUpToolBar();
|
||||
setUpViews();
|
||||
|
||||
if (Util.hasLollipopSDK()) {
|
||||
getWindow().getSharedElementEnterTransition().addListener(new Transition.TransitionListener() {
|
||||
@Override
|
||||
public void onTransitionStart(Transition transition) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionEnd(Transition transition) {
|
||||
setUpArtistImageAndApplyPalette(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionCancel(Transition transition) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionPause(Transition transition) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionResume(Transition transition) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
if (Util.hasLollipopSDK()) startPostponedEnterTransition();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -442,7 +416,7 @@ public class ArtistDetailActivity extends AbsFabActivity implements KabViewsDisa
|
|||
|
||||
private String[] titles;
|
||||
|
||||
private SparseArray<Fragment> pages; //TODO check if this must be static
|
||||
private SparseArray<Fragment> pages;
|
||||
private Artist artist;
|
||||
private Context context;
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import com.kabouzeid.gramophone.ui.fragments.mainactivityfragments.ArtistViewFra
|
|||
import com.kabouzeid.gramophone.ui.fragments.mainactivityfragments.MainActivityFragment;
|
||||
import com.kabouzeid.gramophone.ui.fragments.mainactivityfragments.SongViewFragment;
|
||||
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtils;
|
||||
import com.kabouzeid.gramophone.util.Util;
|
||||
import com.kabouzeid.gramophone.util.ViewUtil;
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
|
@ -75,7 +76,7 @@ public class MainActivity extends AbsFabActivity
|
|||
private void setUpViewPager() {
|
||||
viewPagerAdapter = new MainActivityViewPagerAdapter(this);
|
||||
viewPager.setAdapter(viewPagerAdapter);
|
||||
int startPosition = PreferenceManager.getDefaultSharedPreferences(this).getInt(AppKeys.SP_VIEWPAGER_ITEM_POSITION, 1);
|
||||
int startPosition = PreferenceUtils.getInstace(this).getStartPage();
|
||||
viewPager.setCurrentItem(startPosition);
|
||||
navigationDrawerFragment.setItemChecked(startPosition);
|
||||
|
||||
|
|
@ -89,7 +90,7 @@ public class MainActivity extends AbsFabActivity
|
|||
|
||||
@Override
|
||||
public void onPageSelected(final int position) {
|
||||
PreferenceManager.getDefaultSharedPreferences(MainActivity.this).edit().putInt(AppKeys.SP_VIEWPAGER_ITEM_POSITION, position).apply();
|
||||
PreferenceUtils.getInstace(MainActivity.this).setStartPage(position);
|
||||
navigationDrawerFragment.setItemChecked(position);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ public abstract class AbsFabActivity extends AbsBaseActivity {
|
|||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
setUpFab();
|
||||
App.bus.register(busEventListener);
|
||||
}
|
||||
|
||||
private void setUpFab() {
|
||||
|
|
@ -100,7 +101,6 @@ public abstract class AbsFabActivity extends AbsBaseActivity {
|
|||
protected void onResume() {
|
||||
super.onResume();
|
||||
updateControllerState();
|
||||
App.bus.register(busEventListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -149,9 +149,9 @@ public abstract class AbsFabActivity extends AbsBaseActivity {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
protected void onDestroy() {
|
||||
App.bus.unregister(busEventListener);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
public void onMusicRemoteEvent(MusicRemoteEvent event) {
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public class AlbumViewFragment extends MainActivityFragment {
|
|||
}
|
||||
|
||||
private void fillAbsListView(List<Album> albums) {
|
||||
Collections.sort(albums, new AlbumAlphabeticComparator());
|
||||
//Collections.sort(albums, new AlbumAlphabeticComparator());
|
||||
AlbumViewGridAdapter albumViewGridAdapter = new AlbumViewGridAdapter(getActivity(), albums);
|
||||
absListView.setAdapter(albumViewGridAdapter);
|
||||
absListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ public class ArtistViewFragment extends MainActivityFragment {
|
|||
}
|
||||
|
||||
private void fillAbsListView(List<Artist> artists) {
|
||||
Collections.sort(artists, new ArtistAlphabeticComparator());
|
||||
//Collections.sort(artists, new ArtistAlphabeticComparator());
|
||||
ArtistViewListAdapter artistAdapter = new ArtistViewListAdapter(getActivity(), artists);
|
||||
absListView.setAdapter(artistAdapter);
|
||||
absListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public class SongViewFragment extends MainActivityFragment {
|
|||
}
|
||||
|
||||
private void fillAbsListView(final List<Song> songs) {
|
||||
Collections.sort(songs, new SongAlphabeticComparator());
|
||||
//Collections.sort(songs, new SongAlphabeticComparator());
|
||||
AbsBaseActivity absBaseActivity = null;
|
||||
if (getActivity() instanceof AbsBaseActivity) {
|
||||
absBaseActivity = (AbsBaseActivity) getActivity();
|
||||
|
|
|
|||
|
|
@ -6,9 +6,12 @@ import android.content.ContentValues;
|
|||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
|
|
@ -24,6 +27,16 @@ public class MusicUtil {
|
|||
return ContentUris.withAppendedId(sArtworkUri, album_id);
|
||||
}
|
||||
|
||||
public static boolean hasAlbumArt(final Context context, int album_id) {
|
||||
try {
|
||||
context.getContentResolver().openFileDescriptor(getAlbumArtUri(album_id), "r");
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String getReadableDurationString(long songDurationMillis) {
|
||||
long minutes = (songDurationMillis / 1000) / 60;
|
||||
long seconds = (songDurationMillis / 1000) % 60;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,140 @@
|
|||
package com.kabouzeid.gramophone.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
public final class PreferenceUtils {
|
||||
|
||||
/* Default start page (Artist page) */
|
||||
public static final int DEFAULT_PAGE = 2;
|
||||
|
||||
/* Saves the last page the pager was on in {@link MusicBrowserPhoneFragment} */
|
||||
public static final String START_PAGE = "start_page";
|
||||
|
||||
// Sort order for the artist list
|
||||
public static final String ARTIST_SORT_ORDER = "artist_sort_order";
|
||||
|
||||
// Sort order for the artist song list
|
||||
public static final String ARTIST_SONG_SORT_ORDER = "artist_song_sort_order";
|
||||
|
||||
// Sort order for the artist album list
|
||||
public static final String ARTIST_ALBUM_SORT_ORDER = "artist_album_sort_order";
|
||||
|
||||
// Sort order for the album list
|
||||
public static final String ALBUM_SORT_ORDER = "album_sort_order";
|
||||
|
||||
// Sort order for the album song list
|
||||
public static final String ALBUM_SONG_SORT_ORDER = "album_song_sort_order";
|
||||
|
||||
// Sort order for the song list
|
||||
public static final String SONG_SORT_ORDER = "song_sort_order";
|
||||
|
||||
// Key used to download images only on Wi-Fi
|
||||
public static final String ONLY_ON_WIFI = "only_on_wifi";
|
||||
|
||||
// Key that gives permissions to download missing artist images
|
||||
public static final String DOWNLOAD_MISSING_ARTIST_IMAGES = "download_missing_artist_images";
|
||||
|
||||
private static PreferenceUtils sInstance;
|
||||
|
||||
private final SharedPreferences mPreferences;
|
||||
|
||||
public PreferenceUtils(final Context context) {
|
||||
mPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
}
|
||||
|
||||
public static final PreferenceUtils getInstace(final Context context) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new PreferenceUtils(context.getApplicationContext());
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void setStartPage(final int value) {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putInt(START_PAGE, value);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public final int getStartPage() {
|
||||
return mPreferences.getInt(START_PAGE, DEFAULT_PAGE);
|
||||
}
|
||||
|
||||
public final boolean onlyOnWifi() {
|
||||
return mPreferences.getBoolean(ONLY_ON_WIFI, true);
|
||||
}
|
||||
|
||||
public void setOnlyOnWifi(final boolean value) {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean(ONLY_ON_WIFI, value);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public final boolean downloadMissingArtistImages() {
|
||||
return mPreferences.getBoolean(DOWNLOAD_MISSING_ARTIST_IMAGES, true);
|
||||
}
|
||||
|
||||
public void setDownloadMissingArtistImages(final boolean value) {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean(DOWNLOAD_MISSING_ARTIST_IMAGES, value);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
private void setSortOrder(final String key, final String value) {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putString(key, value);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public void setArtistSortOrder(final String value) {
|
||||
setSortOrder(ARTIST_SORT_ORDER, value);
|
||||
}
|
||||
|
||||
public final String getArtistSortOrder() {
|
||||
return mPreferences.getString(ARTIST_SORT_ORDER, SortOrder.ArtistSortOrder.ARTIST_A_Z);
|
||||
}
|
||||
|
||||
public void setArtistSongSortOrder(final String value) {
|
||||
setSortOrder(ARTIST_SONG_SORT_ORDER, value);
|
||||
}
|
||||
|
||||
public final String getArtistSongSortOrder() {
|
||||
return mPreferences.getString(ARTIST_SONG_SORT_ORDER,
|
||||
SortOrder.ArtistSongSortOrder.SONG_A_Z);
|
||||
}
|
||||
|
||||
public void setArtistAlbumSortOrder(final String value) {
|
||||
setSortOrder(ARTIST_ALBUM_SORT_ORDER, value);
|
||||
}
|
||||
|
||||
public final String getArtistAlbumSortOrder() {
|
||||
return mPreferences.getString(ARTIST_ALBUM_SORT_ORDER,
|
||||
SortOrder.ArtistAlbumSortOrder.ALBUM_A_Z);
|
||||
}
|
||||
|
||||
public void setAlbumSortOrder(final String value) {
|
||||
setSortOrder(ALBUM_SORT_ORDER, value);
|
||||
}
|
||||
|
||||
public final String getAlbumSortOrder() {
|
||||
return mPreferences.getString(ALBUM_SORT_ORDER, SortOrder.AlbumSortOrder.ALBUM_A_Z);
|
||||
}
|
||||
|
||||
public void setAlbumSongSortOrder(final String value) {
|
||||
setSortOrder(ALBUM_SONG_SORT_ORDER, value);
|
||||
}
|
||||
|
||||
public final String getAlbumSongSortOrder() {
|
||||
return mPreferences.getString(ALBUM_SONG_SORT_ORDER,
|
||||
SortOrder.AlbumSongSortOrder.SONG_TRACK_LIST);
|
||||
}
|
||||
|
||||
public void setSongSortOrder(final String value) {
|
||||
setSortOrder(SONG_SORT_ORDER, value);
|
||||
}
|
||||
|
||||
public final String getSongSortOrder() {
|
||||
return mPreferences.getString(SONG_SORT_ORDER, SortOrder.SongSortOrder.SONG_A_Z);
|
||||
}
|
||||
}
|
||||
154
app/src/main/java/com/kabouzeid/gramophone/util/SortOrder.java
Normal file
154
app/src/main/java/com/kabouzeid/gramophone/util/SortOrder.java
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
/*
|
||||
* Copyright (C) 2012 Andrew Neal Licensed under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
|
||||
* or agreed to in writing, software distributed under the License is
|
||||
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.kabouzeid.gramophone.util;
|
||||
|
||||
import android.provider.MediaStore;
|
||||
|
||||
/**
|
||||
* Holds all of the sort orders for each list type.
|
||||
*
|
||||
* @author Andrew Neal (andrewdneal@gmail.com)
|
||||
*/
|
||||
public final class SortOrder {
|
||||
|
||||
/** This class is never instantiated */
|
||||
public SortOrder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Artist sort order entries.
|
||||
*/
|
||||
public static interface ArtistSortOrder {
|
||||
/* Artist sort order A-Z */
|
||||
public final static String ARTIST_A_Z = MediaStore.Audio.Artists.DEFAULT_SORT_ORDER;
|
||||
|
||||
/* Artist sort order Z-A */
|
||||
public final static String ARTIST_Z_A = ARTIST_A_Z + " DESC";
|
||||
|
||||
/* Artist sort order number of songs */
|
||||
public final static String ARTIST_NUMBER_OF_SONGS = MediaStore.Audio.Artists.NUMBER_OF_TRACKS
|
||||
+ " DESC";
|
||||
|
||||
/* Artist sort order number of albums */
|
||||
public final static String ARTIST_NUMBER_OF_ALBUMS = MediaStore.Audio.Artists.NUMBER_OF_ALBUMS
|
||||
+ " DESC";
|
||||
}
|
||||
|
||||
/**
|
||||
* Album sort order entries.
|
||||
*/
|
||||
public static interface AlbumSortOrder {
|
||||
/* Album sort order A-Z */
|
||||
public final static String ALBUM_A_Z = MediaStore.Audio.Albums.DEFAULT_SORT_ORDER;
|
||||
|
||||
/* Album sort order Z-A */
|
||||
public final static String ALBUM_Z_A = ALBUM_A_Z + " DESC";
|
||||
|
||||
/* Album sort order songs */
|
||||
public final static String ALBUM_NUMBER_OF_SONGS = MediaStore.Audio.Albums.NUMBER_OF_SONGS
|
||||
+ " DESC";
|
||||
|
||||
/* Album sort order artist */
|
||||
public final static String ALBUM_ARTIST = MediaStore.Audio.Albums.ARTIST;
|
||||
|
||||
/* Album sort order year */
|
||||
public final static String ALBUM_YEAR = MediaStore.Audio.Albums.FIRST_YEAR + " DESC";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Song sort order entries.
|
||||
*/
|
||||
public static interface SongSortOrder {
|
||||
/* Song sort order A-Z */
|
||||
public final static String SONG_A_Z = MediaStore.Audio.Media.DEFAULT_SORT_ORDER;
|
||||
|
||||
/* Song sort order Z-A */
|
||||
public final static String SONG_Z_A = SONG_A_Z + " DESC";
|
||||
|
||||
/* Song sort order artist */
|
||||
public final static String SONG_ARTIST = MediaStore.Audio.Media.ARTIST;
|
||||
|
||||
/* Song sort order album */
|
||||
public final static String SONG_ALBUM = MediaStore.Audio.Media.ALBUM;
|
||||
|
||||
/* Song sort order year */
|
||||
public final static String SONG_YEAR = MediaStore.Audio.Media.YEAR + " DESC";
|
||||
|
||||
/* Song sort order duration */
|
||||
public final static String SONG_DURATION = MediaStore.Audio.Media.DURATION + " DESC";
|
||||
|
||||
/* Song sort order date */
|
||||
public final static String SONG_DATE = MediaStore.Audio.Media.DATE_ADDED + " DESC";
|
||||
}
|
||||
|
||||
/**
|
||||
* Album song sort order entries.
|
||||
*/
|
||||
public static interface AlbumSongSortOrder {
|
||||
/* Album song sort order A-Z */
|
||||
public final static String SONG_A_Z = MediaStore.Audio.Media.DEFAULT_SORT_ORDER;
|
||||
|
||||
/* Album song sort order Z-A */
|
||||
public final static String SONG_Z_A = SONG_A_Z + " DESC";
|
||||
|
||||
/* Album song sort order track list */
|
||||
public final static String SONG_TRACK_LIST = MediaStore.Audio.Media.TRACK + ", "
|
||||
+ MediaStore.Audio.Media.DEFAULT_SORT_ORDER;
|
||||
|
||||
/* Album song sort order duration */
|
||||
public final static String SONG_DURATION = SongSortOrder.SONG_DURATION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Artist song sort order entries.
|
||||
*/
|
||||
public static interface ArtistSongSortOrder {
|
||||
/* Artist song sort order A-Z */
|
||||
public final static String SONG_A_Z = MediaStore.Audio.Media.DEFAULT_SORT_ORDER;
|
||||
|
||||
/* Artist song sort order Z-A */
|
||||
public final static String SONG_Z_A = SONG_A_Z + " DESC";
|
||||
|
||||
/* Artist song sort order album */
|
||||
public final static String SONG_ALBUM = MediaStore.Audio.Media.ALBUM;
|
||||
|
||||
/* Artist song sort order year */
|
||||
public final static String SONG_YEAR = MediaStore.Audio.Media.YEAR + " DESC";
|
||||
|
||||
/* Artist song sort order duration */
|
||||
public final static String SONG_DURATION = MediaStore.Audio.Media.DURATION + " DESC";
|
||||
|
||||
/* Artist song sort order date */
|
||||
public final static String SONG_DATE = MediaStore.Audio.Media.DATE_ADDED + " DESC";
|
||||
}
|
||||
|
||||
/**
|
||||
* Artist album sort order entries.
|
||||
*/
|
||||
public static interface ArtistAlbumSortOrder {
|
||||
/* Artist album sort order A-Z */
|
||||
public final static String ALBUM_A_Z = MediaStore.Audio.Albums.DEFAULT_SORT_ORDER;
|
||||
|
||||
/* Artist album sort order Z-A */
|
||||
public final static String ALBUM_Z_A = ALBUM_A_Z + " DESC";
|
||||
|
||||
/* Artist album sort order songs */
|
||||
public final static String ALBUM_NUMBER_OF_SONGS = MediaStore.Audio.Artists.Albums.NUMBER_OF_SONGS
|
||||
+ " DESC";
|
||||
|
||||
/* Artist album sort order year */
|
||||
public final static String ALBUM_YEAR = MediaStore.Audio.Artists.Albums.FIRST_YEAR
|
||||
+ " DESC";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -10,7 +10,6 @@ import android.net.ConnectivityManager;
|
|||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
|
|
@ -18,9 +17,7 @@ import android.view.Window;
|
|||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import com.kabouzeid.gramophone.App;
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.misc.AppKeys;
|
||||
|
||||
/**
|
||||
* Created by karim on 12.12.14.
|
||||
|
|
@ -117,7 +114,7 @@ public class Util {
|
|||
}
|
||||
|
||||
boolean state = false;
|
||||
final boolean onlyOnWifi = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(AppKeys.SP_ONLY_ON_WIFI, true);
|
||||
final boolean onlyOnWifi = PreferenceUtils.getInstace(context).onlyOnWifi();
|
||||
|
||||
/* Monitor network connections */
|
||||
final ConnectivityManager connectivityManager = (ConnectivityManager) context
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#FFFFFF" />
|
||||
<solid android:color="@android:color/transparent" />
|
||||
<stroke android:width="5px" android:color="#222222" />
|
||||
<padding android:left="5px" android:top="5px" android:right="5px"
|
||||
android:bottom="5px" />
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
android:shape="rectangle">
|
||||
<gradient
|
||||
android:angle="90"
|
||||
android:endColor="#00000000"
|
||||
android:startColor="#50000000"
|
||||
android:type="linear"/>
|
||||
android:endColor="#34000000"
|
||||
android:startColor="@android:color/transparent" />
|
||||
</shape>
|
||||
Loading…
Add table
Add a link
Reference in a new issue