Code refactor and Flat, Fit, Full, Circle theme toolbar shadow fixes
This commit is contained in:
parent
954dfb6327
commit
724f743627
304 changed files with 3874 additions and 3524 deletions
|
@ -17,6 +17,7 @@ package code.name.monkey.retromusic.util;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.bumptech.glide.signature.StringSignature;
|
||||
|
|
|
@ -33,7 +33,7 @@ import java.io.BufferedOutputStream
|
|||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
import java.util.Locale
|
||||
import java.util.*
|
||||
|
||||
|
||||
class CustomArtistImageUtil private constructor(context: Context) {
|
||||
|
@ -41,53 +41,65 @@ class CustomArtistImageUtil private constructor(context: Context) {
|
|||
private val mPreferences: SharedPreferences
|
||||
|
||||
init {
|
||||
mPreferences = context.applicationContext.getSharedPreferences(CUSTOM_ARTIST_IMAGE_PREFS, Context.MODE_PRIVATE)
|
||||
mPreferences = context.applicationContext.getSharedPreferences(
|
||||
CUSTOM_ARTIST_IMAGE_PREFS,
|
||||
Context.MODE_PRIVATE
|
||||
)
|
||||
}
|
||||
|
||||
fun setCustomArtistImage(artist: Artist, uri: Uri) {
|
||||
Glide.with(App.getContext())
|
||||
.load(uri)
|
||||
.asBitmap()
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.skipMemoryCache(true)
|
||||
.into(object : SimpleTarget<Bitmap>() {
|
||||
override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) {
|
||||
super.onLoadFailed(e, errorDrawable)
|
||||
e!!.printStackTrace()
|
||||
Toast.makeText(App.getContext(), e.toString(), Toast.LENGTH_LONG).show()
|
||||
}
|
||||
.load(uri)
|
||||
.asBitmap()
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.skipMemoryCache(true)
|
||||
.into(object : SimpleTarget<Bitmap>() {
|
||||
override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) {
|
||||
super.onLoadFailed(e, errorDrawable)
|
||||
e!!.printStackTrace()
|
||||
Toast.makeText(App.getContext(), e.toString(), Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
override fun onResourceReady(resource: Bitmap, glideAnimation: GlideAnimation<in Bitmap>) {
|
||||
object : AsyncTask<Void, Void, Void>() {
|
||||
@SuppressLint("ApplySharedPref")
|
||||
override fun doInBackground(vararg params: Void): Void? {
|
||||
val dir = File(App.getContext().filesDir, FOLDER_NAME)
|
||||
if (!dir.exists()) {
|
||||
if (!dir.mkdirs()) { // create the folder
|
||||
return null
|
||||
}
|
||||
override fun onResourceReady(
|
||||
resource: Bitmap,
|
||||
glideAnimation: GlideAnimation<in Bitmap>
|
||||
) {
|
||||
object : AsyncTask<Void, Void, Void>() {
|
||||
@SuppressLint("ApplySharedPref")
|
||||
override fun doInBackground(vararg params: Void): Void? {
|
||||
val dir = File(App.getContext().filesDir, FOLDER_NAME)
|
||||
if (!dir.exists()) {
|
||||
if (!dir.mkdirs()) { // create the folder
|
||||
return null
|
||||
}
|
||||
val file = File(dir, getFileName(artist))
|
||||
|
||||
var succesful = false
|
||||
try {
|
||||
val os = BufferedOutputStream(FileOutputStream(file))
|
||||
succesful = ImageUtil.resizeBitmap(resource, 2048).compress(Bitmap.CompressFormat.JPEG, 100, os)
|
||||
os.close()
|
||||
} catch (e: IOException) {
|
||||
Toast.makeText(App.getContext(), e.toString(), Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
if (succesful) {
|
||||
mPreferences.edit().putBoolean(getFileName(artist), true).commit()
|
||||
ArtistSignatureUtil.getInstance(App.getContext()).updateArtistSignature(artist.name)
|
||||
App.getContext().contentResolver.notifyChange(MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI, null) // trigger media store changed to force artist image reload
|
||||
}
|
||||
return null
|
||||
}
|
||||
}.execute()
|
||||
}
|
||||
})
|
||||
val file = File(dir, getFileName(artist))
|
||||
|
||||
var succesful = false
|
||||
try {
|
||||
val os = BufferedOutputStream(FileOutputStream(file))
|
||||
succesful = ImageUtil.resizeBitmap(resource, 2048)
|
||||
.compress(Bitmap.CompressFormat.JPEG, 100, os)
|
||||
os.close()
|
||||
} catch (e: IOException) {
|
||||
Toast.makeText(App.getContext(), e.toString(), Toast.LENGTH_LONG)
|
||||
.show()
|
||||
}
|
||||
|
||||
if (succesful) {
|
||||
mPreferences.edit().putBoolean(getFileName(artist), true).commit()
|
||||
ArtistSignatureUtil.getInstance(App.getContext())
|
||||
.updateArtistSignature(artist.name)
|
||||
App.getContext().contentResolver.notifyChange(
|
||||
MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI,
|
||||
null
|
||||
) // trigger media store changed to force artist image reload
|
||||
}
|
||||
return null
|
||||
}
|
||||
}.execute()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun resetCustomArtistImage(artist: Artist) {
|
||||
|
@ -96,7 +108,10 @@ class CustomArtistImageUtil private constructor(context: Context) {
|
|||
override fun doInBackground(vararg params: Void): Void? {
|
||||
mPreferences.edit().putBoolean(getFileName(artist), false).commit()
|
||||
ArtistSignatureUtil.getInstance(App.getContext()).updateArtistSignature(artist.name)
|
||||
App.getContext().contentResolver.notifyChange(MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI, null) // trigger media store changed to force artist image reload
|
||||
App.getContext().contentResolver.notifyChange(
|
||||
MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI,
|
||||
null
|
||||
) // trigger media store changed to force artist image reload
|
||||
|
||||
val file = getFile(artist)
|
||||
if (!file.exists()) {
|
||||
|
|
|
@ -27,9 +27,21 @@ import android.provider.BaseColumns;
|
|||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import org.jaudiotagger.audio.AudioFileIO;
|
||||
import org.jaudiotagger.tag.FieldKey;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote;
|
||||
import code.name.monkey.retromusic.loaders.PlaylistLoader;
|
||||
|
@ -39,14 +51,6 @@ import code.name.monkey.retromusic.model.Playlist;
|
|||
import code.name.monkey.retromusic.model.Song;
|
||||
import code.name.monkey.retromusic.model.lyrics.AbsSynchronizedLyrics;
|
||||
import code.name.monkey.retromusic.service.MusicService;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Pattern;
|
||||
import org.jaudiotagger.audio.AudioFileIO;
|
||||
import org.jaudiotagger.tag.FieldKey;
|
||||
|
||||
|
||||
public class MusicUtil {
|
||||
|
@ -188,7 +192,7 @@ public class MusicUtil {
|
|||
|
||||
@NonNull
|
||||
public static String getArtistInfoString(@NonNull final Context context,
|
||||
@NonNull final Artist artist) {
|
||||
@NonNull final Artist artist) {
|
||||
int albumCount = artist.getAlbumCount();
|
||||
int songCount = artist.getSongCount();
|
||||
String albumString = albumCount == 1 ? context.getResources().getString(R.string.album)
|
||||
|
@ -379,7 +383,7 @@ public class MusicUtil {
|
|||
}
|
||||
|
||||
public static boolean isFavoritePlaylist(@NonNull final Context context,
|
||||
@NonNull final Playlist playlist) {
|
||||
@NonNull final Playlist playlist) {
|
||||
return playlist.name != null && playlist.name.equals(context.getString(R.string.favorites));
|
||||
}
|
||||
|
||||
|
|
|
@ -14,9 +14,6 @@
|
|||
|
||||
package code.name.monkey.retromusic.util;
|
||||
|
||||
import static code.name.monkey.retromusic.Constants.RATE_ON_GOOGLE_PLAY;
|
||||
import static code.name.monkey.retromusic.util.RetroUtil.openUrl;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityOptions;
|
||||
import android.content.ActivityNotFoundException;
|
||||
|
@ -24,8 +21,12 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.media.audiofx.AudioEffect;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.activities.AboutActivity;
|
||||
import code.name.monkey.retromusic.activities.AlbumDetailsActivity;
|
||||
|
@ -46,7 +47,9 @@ import code.name.monkey.retromusic.activities.bugreport.BugReportActivity;
|
|||
import code.name.monkey.retromusic.helper.MusicPlayerRemote;
|
||||
import code.name.monkey.retromusic.model.Genre;
|
||||
import code.name.monkey.retromusic.model.Playlist;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static code.name.monkey.retromusic.Constants.RATE_ON_GOOGLE_PLAY;
|
||||
import static code.name.monkey.retromusic.util.RetroUtil.openUrl;
|
||||
|
||||
|
||||
public class NavigationUtil {
|
||||
|
@ -66,8 +69,8 @@ public class NavigationUtil {
|
|||
}
|
||||
|
||||
public static void goToAlbumOptions(@NonNull Activity activity,
|
||||
int albumId,
|
||||
@NonNull ActivityOptions options) {
|
||||
int albumId,
|
||||
@NonNull ActivityOptions options) {
|
||||
Intent intent = new Intent(activity, AlbumDetailsActivity.class);
|
||||
intent.putExtra(AlbumDetailsActivity.EXTRA_ALBUM_ID, albumId);
|
||||
ActivityCompat.startActivity(activity, intent, options.toBundle());
|
||||
|
@ -80,8 +83,8 @@ public class NavigationUtil {
|
|||
}
|
||||
|
||||
public static void goToArtistOptions(@NotNull Activity activity,
|
||||
int artistId,
|
||||
@NonNull ActivityOptions options) {
|
||||
int artistId,
|
||||
@NonNull ActivityOptions options) {
|
||||
|
||||
Intent intent = new Intent(activity, ArtistDetailActivity.class);
|
||||
intent.putExtra(ArtistDetailActivity.EXTRA_ARTIST_ID, artistId);
|
||||
|
@ -123,13 +126,13 @@ public class NavigationUtil {
|
|||
}
|
||||
|
||||
public static void goToSearch(@NonNull Activity activity,
|
||||
@NonNull ActivityOptions activityOptions) {
|
||||
@NonNull ActivityOptions activityOptions) {
|
||||
ActivityCompat.startActivity(activity, new Intent(activity, SearchActivity.class),
|
||||
activityOptions.toBundle());
|
||||
}
|
||||
|
||||
public static void goToSearch(@NonNull Activity activity, boolean isMicOpen,
|
||||
@NonNull ActivityOptions activityOptions) {
|
||||
@NonNull ActivityOptions activityOptions) {
|
||||
ActivityCompat.startActivity(activity, new Intent(activity, SearchActivity.class)
|
||||
.putExtra(SearchActivity.EXTRA_SHOW_MIC, isMicOpen),
|
||||
activityOptions.toBundle());
|
||||
|
@ -144,7 +147,7 @@ public class NavigationUtil {
|
|||
}
|
||||
|
||||
public static void goToUserInfo(@NonNull Activity activity,
|
||||
@NonNull ActivityOptions activityOptions) {
|
||||
@NonNull ActivityOptions activityOptions) {
|
||||
ActivityCompat.startActivity(activity, new Intent(activity, UserInfoActivity.class),
|
||||
activityOptions.toBundle());
|
||||
}
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
|
||||
package code.name.monkey.retromusic.util;
|
||||
|
||||
import static android.provider.MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
|
@ -25,24 +23,29 @@ import android.os.Environment;
|
|||
import android.provider.BaseColumns;
|
||||
import android.provider.MediaStore;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.helper.M3UWriter;
|
||||
import code.name.monkey.retromusic.model.Playlist;
|
||||
import code.name.monkey.retromusic.model.PlaylistSong;
|
||||
import code.name.monkey.retromusic.model.Song;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.helper.M3UWriter;
|
||||
import code.name.monkey.retromusic.model.Playlist;
|
||||
import code.name.monkey.retromusic.model.PlaylistSong;
|
||||
import code.name.monkey.retromusic.model.Song;
|
||||
|
||||
import static android.provider.MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI;
|
||||
|
||||
public class PlaylistsUtil {
|
||||
|
||||
public static void addToPlaylist(@NonNull Context context,
|
||||
@NonNull List<Song> songs,
|
||||
int playlistId,
|
||||
boolean showToastOnFinish) {
|
||||
@NonNull List<Song> songs,
|
||||
int playlistId,
|
||||
boolean showToastOnFinish) {
|
||||
|
||||
ArrayList<Song> noSongs = new ArrayList<Song>();
|
||||
for (Song song : songs) {
|
||||
|
@ -130,7 +133,7 @@ public class PlaylistsUtil {
|
|||
}
|
||||
|
||||
static boolean doPlaylistContains(@NonNull final Context context, final long playlistId,
|
||||
final int songId) {
|
||||
final int songId) {
|
||||
if (playlistId != -1) {
|
||||
try {
|
||||
Cursor c = context.getContentResolver().query(
|
||||
|
@ -179,7 +182,7 @@ public class PlaylistsUtil {
|
|||
|
||||
@NonNull
|
||||
public static ContentValues[] makeInsertItems(@NonNull final List<Song> songs, final int offset, int len,
|
||||
final int base) {
|
||||
final int base) {
|
||||
if (offset + len > songs.size()) {
|
||||
len = songs.size() - offset;
|
||||
}
|
||||
|
@ -246,21 +249,21 @@ public class PlaylistsUtil {
|
|||
|
||||
@Nullable
|
||||
public static File savePlaylist(@NonNull Context context,
|
||||
@NonNull Playlist playlist) throws IOException {
|
||||
@NonNull Playlist playlist) throws IOException {
|
||||
return M3UWriter.write(context, new File(Environment.getExternalStorageDirectory(), "Playlists"), playlist);
|
||||
}
|
||||
|
||||
static void addToPlaylist(@NonNull Context context,
|
||||
@NonNull Song song,
|
||||
int playlistId,
|
||||
boolean showToastOnFinish) {
|
||||
@NonNull Song song,
|
||||
int playlistId,
|
||||
boolean showToastOnFinish) {
|
||||
List<Song> helperList = new ArrayList<>();
|
||||
helperList.add(song);
|
||||
addToPlaylist(context, helperList, playlistId, showToastOnFinish);
|
||||
}
|
||||
|
||||
private static boolean doesPlaylistExist(@NonNull Context context, @NonNull final String selection,
|
||||
@NonNull final String[] values) {
|
||||
@NonNull final String[] values) {
|
||||
Cursor cursor = context.getContentResolver().query(EXTERNAL_CONTENT_URI,
|
||||
new String[]{}, selection, values, null);
|
||||
|
||||
|
|
|
@ -24,10 +24,24 @@ import android.net.ConnectivityManager;
|
|||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.google.android.material.bottomnavigation.LabelVisibilityMode;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.dialogs.OptionsSheetDialogFragment;
|
||||
import code.name.monkey.retromusic.fragments.AlbumCoverStyle;
|
||||
|
@ -44,15 +58,6 @@ import code.name.monkey.retromusic.transform.HorizontalFlipTransformation;
|
|||
import code.name.monkey.retromusic.transform.NormalPageTransformer;
|
||||
import code.name.monkey.retromusic.transform.VerticalFlipTransformation;
|
||||
import code.name.monkey.retromusic.transform.VerticalStackTransformer;
|
||||
import com.google.android.material.bottomnavigation.LabelVisibilityMode;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public final class PreferenceUtil {
|
||||
|
||||
|
@ -133,37 +138,21 @@ public final class PreferenceUtil {
|
|||
public static final String TAB_TEXT_MODE = "tab_text_mode";
|
||||
|
||||
public static final String SAF_SDCARD_URI = "saf_sdcard_uri";
|
||||
|
||||
private static final String GENRE_SORT_ORDER = "genre_sort_order";
|
||||
|
||||
private static final String LAST_PAGE = "last_start_page";
|
||||
|
||||
private static final String BLUETOOTH_PLAYBACK = "bluetooth_playback";
|
||||
|
||||
private static final String LAST_MUSIC_CHOOSER = "last_music_chooser";
|
||||
|
||||
private static final String DEFAULT_START_PAGE = "default_start_page";
|
||||
|
||||
private static final String INITIALIZED_BLACKLIST = "initialized_blacklist";
|
||||
|
||||
private static final String ARTIST_SORT_ORDER = "artist_sort_order";
|
||||
|
||||
private static final String ARTIST_SONG_SORT_ORDER = "artist_song_sort_order";
|
||||
|
||||
private static final String ARTIST_ALBUM_SORT_ORDER = "artist_album_sort_order";
|
||||
|
||||
private static final String ALBUM_SORT_ORDER = "album_sort_order";
|
||||
|
||||
private static final String ALBUM_SONG_SORT_ORDER = "album_song_sort_order";
|
||||
|
||||
public static final String SONG_SORT_ORDER = "song_sort_order";
|
||||
|
||||
private static final String ALBUM_GRID_SIZE = "album_grid_size";
|
||||
|
||||
private static final String ALBUM_GRID_SIZE_LAND = "album_grid_size_land";
|
||||
|
||||
public static final String SONG_GRID_SIZE = "song_grid_size";
|
||||
|
||||
private static final String GENRE_SORT_ORDER = "genre_sort_order";
|
||||
private static final String LAST_PAGE = "last_start_page";
|
||||
private static final String BLUETOOTH_PLAYBACK = "bluetooth_playback";
|
||||
private static final String LAST_MUSIC_CHOOSER = "last_music_chooser";
|
||||
private static final String DEFAULT_START_PAGE = "default_start_page";
|
||||
private static final String INITIALIZED_BLACKLIST = "initialized_blacklist";
|
||||
private static final String ARTIST_SORT_ORDER = "artist_sort_order";
|
||||
private static final String ARTIST_SONG_SORT_ORDER = "artist_song_sort_order";
|
||||
private static final String ARTIST_ALBUM_SORT_ORDER = "artist_album_sort_order";
|
||||
private static final String ALBUM_SORT_ORDER = "album_sort_order";
|
||||
private static final String ALBUM_SONG_SORT_ORDER = "album_song_sort_order";
|
||||
private static final String ALBUM_GRID_SIZE = "album_grid_size";
|
||||
private static final String ALBUM_GRID_SIZE_LAND = "album_grid_size_land";
|
||||
private static final String SONG_GRID_SIZE_LAND = "song_grid_size_land";
|
||||
|
||||
private static final String ARTIST_GRID_SIZE = "artist_grid_size";
|
||||
|
@ -227,11 +216,14 @@ public final class PreferenceUtil {
|
|||
private static final String SNOW_FALL_EFFECT = "snow_fall_effect";
|
||||
|
||||
private static final String FILTER_SONG = "filter_song";
|
||||
|
||||
private static final String TAG = "PreferenceUtil";
|
||||
private static PreferenceUtil sInstance;
|
||||
|
||||
private final SharedPreferences mPreferences;
|
||||
|
||||
private PreferenceUtil(@NonNull final Context context) {
|
||||
mPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static PreferenceUtil getInstance(Context context) {
|
||||
if (sInstance == null) {
|
||||
|
@ -267,10 +259,6 @@ public final class PreferenceUtil {
|
|||
}
|
||||
}
|
||||
|
||||
private PreferenceUtil(@NonNull final Context context) {
|
||||
mPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
}
|
||||
|
||||
public final boolean albumArtOnLockscreen() {
|
||||
return mPreferences.getBoolean(ALBUM_ART_ON_LOCKSCREEN, true);
|
||||
}
|
||||
|
@ -410,6 +398,9 @@ public final class PreferenceUtil {
|
|||
|
||||
@LayoutRes
|
||||
public int getAlbumGridStyle() {
|
||||
if (mPreferences.contains(ALBUM_GRID_STYLE)) {
|
||||
Log.i(TAG, "getAlbumGridStyle: " + mPreferences.getInt(ALBUM_GRID_STYLE, -10));
|
||||
}
|
||||
return mPreferences.getInt(ALBUM_GRID_STYLE, R.layout.item_grid);
|
||||
}
|
||||
|
||||
|
@ -461,6 +452,9 @@ public final class PreferenceUtil {
|
|||
|
||||
@LayoutRes
|
||||
public int getArtistGridStyle() {
|
||||
if (mPreferences.contains(ARTIST_GRID_STYLE)) {
|
||||
Log.i(TAG, "getArtistGridStyle: " + mPreferences.getInt(ARTIST_GRID_STYLE, -10));
|
||||
}
|
||||
return mPreferences.getInt(ARTIST_GRID_STYLE, R.layout.item_grid);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,9 +29,7 @@ import java.util.Collections;
|
|||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil;
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil;
|
||||
import code.name.monkey.retromusic.R;
|
||||
|
||||
public class RetroColorUtil {
|
||||
public static int desaturateColor(int color, float ratio) {
|
||||
|
|
|
@ -35,14 +35,17 @@ import android.view.View;
|
|||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import code.name.monkey.appthemehelper.util.TintHelper;
|
||||
import code.name.monkey.retromusic.App;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class RetroUtil {
|
||||
|
||||
|
@ -105,20 +108,20 @@ public class RetroUtil {
|
|||
|
||||
@Nullable
|
||||
public static Drawable getTintedVectorDrawable(@NonNull Context context, @DrawableRes int id,
|
||||
@ColorInt int color) {
|
||||
@ColorInt int color) {
|
||||
return TintHelper.createTintedDrawable(
|
||||
getVectorDrawable(context.getResources(), id, context.getTheme()), color);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Drawable getTintedVectorDrawable(@NonNull Resources res, @DrawableRes int resId,
|
||||
@Nullable Resources.Theme theme, @ColorInt int color) {
|
||||
@Nullable Resources.Theme theme, @ColorInt int color) {
|
||||
return TintHelper.createTintedDrawable(getVectorDrawable(res, resId, theme), color);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Drawable getVectorDrawable(@NonNull Resources res, @DrawableRes int resId,
|
||||
@Nullable Resources.Theme theme) {
|
||||
@Nullable Resources.Theme theme) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
return res.getDrawable(resId, theme);
|
||||
}
|
||||
|
|
|
@ -45,16 +45,18 @@ class RingtoneManager(val context: Context) {
|
|||
|
||||
|
||||
try {
|
||||
val cursor = resolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
|
||||
arrayOf(MediaStore.MediaColumns.TITLE),
|
||||
BaseColumns._ID + "=?",
|
||||
arrayOf(song.id.toString()), null)
|
||||
val cursor = resolver.query(
|
||||
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
|
||||
arrayOf(MediaStore.MediaColumns.TITLE),
|
||||
BaseColumns._ID + "=?",
|
||||
arrayOf(song.id.toString()), null
|
||||
)
|
||||
cursor.use { cursorSong ->
|
||||
if (cursorSong != null && cursorSong.count == 1) {
|
||||
cursorSong.moveToFirst()
|
||||
Settings.System.putString(resolver, Settings.System.RINGTONE, uri.toString())
|
||||
val message = context
|
||||
.getString(R.string.x_has_been_set_as_ringtone, cursorSong.getString(0))
|
||||
.getString(R.string.x_has_been_set_as_ringtone, cursorSong.getString(0))
|
||||
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ package code.name.monkey.retromusic.util;
|
|||
import android.graphics.Canvas;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class SwipeAndDragHelper extends ItemTouchHelper.Callback {
|
||||
|
||||
|
|
|
@ -13,18 +13,21 @@ import code.name.monkey.retromusic.R
|
|||
object ThemeManager {
|
||||
|
||||
@StyleRes
|
||||
fun getThemeResValue(context: Context): Int = when (PreferenceUtil.getInstance(context).generalThemeValue) {
|
||||
"light" -> R.style.Theme_RetroMusic_Light
|
||||
"dark" -> R.style.Theme_RetroMusic_Base
|
||||
"auto" -> R.style.Theme_RetroMusic_FollowSystem
|
||||
"black" -> R.style.Theme_RetroMusic_Black
|
||||
else -> R.style.Theme_RetroMusic_FollowSystem
|
||||
}
|
||||
fun getThemeResValue(context: Context): Int =
|
||||
when (PreferenceUtil.getInstance(context).generalThemeValue) {
|
||||
"light" -> R.style.Theme_RetroMusic_Light
|
||||
"dark" -> R.style.Theme_RetroMusic_Base
|
||||
"auto" -> R.style.Theme_RetroMusic_FollowSystem
|
||||
"black" -> R.style.Theme_RetroMusic_Black
|
||||
else -> R.style.Theme_RetroMusic_FollowSystem
|
||||
}
|
||||
|
||||
private fun isSystemDarkModeEnabled(context: Context): Boolean {
|
||||
val isBatterySaverEnabled = (context.getSystemService(Context.POWER_SERVICE) as PowerManager?)?.isPowerSaveMode
|
||||
val isBatterySaverEnabled =
|
||||
(context.getSystemService(Context.POWER_SERVICE) as PowerManager?)?.isPowerSaveMode
|
||||
?: false
|
||||
val isDarkModeEnabled = (context.resources.configuration.uiMode and UI_MODE_NIGHT_MASK) == UI_MODE_NIGHT_YES
|
||||
val isDarkModeEnabled =
|
||||
(context.resources.configuration.uiMode and UI_MODE_NIGHT_MASK) == UI_MODE_NIGHT_YES
|
||||
|
||||
return isBatterySaverEnabled or isDarkModeEnabled
|
||||
}
|
||||
|
|
|
@ -67,7 +67,8 @@ object ViewUtil {
|
|||
BlendModeColorFilterCompat.createBlendModeColorFilterCompat(newColor, SRC_IN)
|
||||
|
||||
val background = layerDrawable.findDrawableByLayerId(android.R.id.background)
|
||||
val primaryColor = ATHUtil.resolveColor(progressSlider.context, android.R.attr.windowBackground)
|
||||
val primaryColor =
|
||||
ATHUtil.resolveColor(progressSlider.context, android.R.attr.windowBackground)
|
||||
background.colorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(
|
||||
MaterialValueHelper.getPrimaryDisabledTextColor(
|
||||
progressSlider.context,
|
||||
|
@ -77,7 +78,12 @@ object ViewUtil {
|
|||
|
||||
val secondaryProgress = layerDrawable.findDrawableByLayerId(android.R.id.secondaryProgress)
|
||||
secondaryProgress?.colorFilter =
|
||||
BlendModeColorFilterCompat.createBlendModeColorFilterCompat(ColorUtil.withAlpha(newColor, 0.65f), SRC_IN)
|
||||
BlendModeColorFilterCompat.createBlendModeColorFilterCompat(
|
||||
ColorUtil.withAlpha(
|
||||
newColor,
|
||||
0.65f
|
||||
), SRC_IN
|
||||
)
|
||||
}
|
||||
|
||||
fun hitTest(v: View, x: Int, y: Int): Boolean {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue