Code refactor

This commit is contained in:
Hemanth S 2020-06-07 00:27:28 +05:30
parent a8f0867c9d
commit 5394f94973
96 changed files with 384 additions and 1068 deletions

View file

@ -23,18 +23,18 @@ import com.google.gson.JsonSyntaxException
import com.google.gson.reflect.TypeToken
import java.io.File
object PreferenceUtilKT {
object PreferenceUtil {
private val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(App.getContext())
val defaultCategories = listOf(
CategoryInfo(CategoryInfo.Category.HOME, true),
CategoryInfo(CategoryInfo.Category.SONGS, true),
CategoryInfo(CategoryInfo.Category.ALBUMS, true),
CategoryInfo(CategoryInfo.Category.ARTISTS, true),
CategoryInfo(CategoryInfo.Category.PLAYLISTS, true),
CategoryInfo(CategoryInfo.Category.GENRES, false),
CategoryInfo(CategoryInfo.Category.QUEUE, false),
CategoryInfo(CategoryInfo.Category.FOLDER, false)
CategoryInfo(CategoryInfo.Category.Home, true),
CategoryInfo(CategoryInfo.Category.Songs, true),
CategoryInfo(CategoryInfo.Category.Albums, true),
CategoryInfo(CategoryInfo.Category.Artists, true),
CategoryInfo(CategoryInfo.Category.Playlists, true),
CategoryInfo(CategoryInfo.Category.Genres, false),
CategoryInfo(CategoryInfo.Category.Queue, false),
CategoryInfo(CategoryInfo.Category.Folder, false)
)
var libraryCategory: List<CategoryInfo>
@ -484,7 +484,7 @@ object PreferenceUtilKT {
return albumCoverStyle
}
}
return AlbumCoverStyle.CARD
return AlbumCoverStyle.Card
}
set(value) = sharedPreferences.edit { putInt(ALBUM_COVER_STYLE, value.id) }

View file

@ -142,7 +142,7 @@ public class RetroUtil {
}
public static boolean isAllowedToDownloadMetadata(final @NonNull Context context) {
switch (PreferenceUtilKT.INSTANCE.getAutoDownloadImagesPolicy()) {
switch (PreferenceUtil.INSTANCE.getAutoDownloadImagesPolicy()) {
case "always":
return true;
case "only_wifi":

View file

@ -119,19 +119,19 @@ public class SAFUtil {
public static void saveTreeUri(Context context, Intent data) {
Uri uri = data.getData();
context.getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
PreferenceUtilKT.INSTANCE.setSafSdCardUri(uri.toString());
PreferenceUtil.INSTANCE.setSafSdCardUri(uri.toString());
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static boolean isTreeUriSaved(Context context) {
return !TextUtils.isEmpty(PreferenceUtilKT.INSTANCE.getSafSdCardUri());
return !TextUtils.isEmpty(PreferenceUtil.INSTANCE.getSafSdCardUri());
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static boolean isSDCardAccessGranted(Context context) {
if (!isTreeUriSaved(context)) return false;
String sdcardUri = PreferenceUtilKT.INSTANCE.getSafSdCardUri();
String sdcardUri = PreferenceUtil.INSTANCE.getSafSdCardUri();
List<UriPermission> perms = context.getContentResolver().getPersistedUriPermissions();
for (UriPermission perm : perms) {
@ -198,7 +198,7 @@ public class SAFUtil {
if (isTreeUriSaved(context)) {
List<String> pathSegments = new ArrayList<>(Arrays.asList(audio.getFile().getAbsolutePath().split("/")));
Uri sdcard = Uri.parse(PreferenceUtilKT.INSTANCE.getSafSdCardUri());
Uri sdcard = Uri.parse(PreferenceUtil.INSTANCE.getSafSdCardUri());
uri = findDocument(DocumentFile.fromTreeUri(context, sdcard), pathSegments);
}
@ -271,7 +271,7 @@ public class SAFUtil {
if (isTreeUriSaved(context)) {
List<String> pathSegments = new ArrayList<>(Arrays.asList(path.split("/")));
Uri sdcard = Uri.parse(PreferenceUtilKT.INSTANCE.getSafSdCardUri());
Uri sdcard = Uri.parse(PreferenceUtil.INSTANCE.getSafSdCardUri());
uri = findDocument(DocumentFile.fromTreeUri(context, sdcard), pathSegments);
}