Removed Some animations and palette
This commit is contained in:
parent
b293123603
commit
af21f191dd
20 changed files with 343 additions and 120 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue