code refactor

This commit is contained in:
h4h13 2019-09-01 19:02:36 +05:30
parent 6b492c039c
commit 8f272ab0d2
11 changed files with 49 additions and 38 deletions

View file

@ -13,8 +13,8 @@ android {
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
applicationId "code.name.monkey.retromusic" applicationId "code.name.monkey.retromusic"
versionCode 358 versionCode 360
versionName '3.3.200-beta-1' versionName '3.3.200'
multiDexEnabled true multiDexEnabled true
@ -98,22 +98,22 @@ static def getDate() {
dependencies { dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.fragment:fragment:1.2.0-alpha01' implementation 'androidx.fragment:fragment:1.2.0-alpha02'
implementation 'androidx.appcompat:appcompat:1.1.0-rc01' implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.recyclerview:recyclerview:1.1.0-beta01' implementation 'androidx.recyclerview:recyclerview:1.1.0-beta02'
implementation "androidx.gridlayout:gridlayout:1.0.0" implementation "androidx.gridlayout:gridlayout:1.0.0"
implementation "androidx.cardview:cardview:1.0.0" implementation "androidx.cardview:cardview:1.0.0"
implementation "androidx.palette:palette:1.0.0" implementation "androidx.palette:palette:1.0.0"
implementation 'androidx.annotation:annotation:1.1.0' implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.preference:preference:1.1.0-rc01' implementation 'androidx.preference:preference:1.1.0-rc01'
implementation 'androidx.palette:palette-ktx:1.0.0' implementation 'androidx.palette:palette-ktx:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2' implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation 'com.google.android.material:material:1.1.0-alpha09' implementation 'com.google.android.material:material:1.1.0-alpha09'
implementation 'com.squareup.retrofit2:retrofit:2.6.0' implementation 'com.squareup.retrofit2:retrofit:2.6.1'
implementation 'com.squareup.retrofit2:converter-gson:2.6.0' implementation 'com.squareup.retrofit2:converter-gson:2.6.1'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.6.0' implementation 'com.squareup.retrofit2:adapter-rxjava2:2.6.1'
implementation 'com.afollestad.material-dialogs:core:3.0.0-alpha1' implementation 'com.afollestad.material-dialogs:core:3.0.0-alpha1'
implementation 'com.afollestad.material-dialogs:input:3.0.0-alpha1' implementation 'com.afollestad.material-dialogs:input:3.0.0-alpha1'
@ -144,7 +144,7 @@ dependencies {
implementation 'com.github.kabouzeid:AndroidSlidingUpPanel:3.3.0-kmod3' implementation 'com.github.kabouzeid:AndroidSlidingUpPanel:3.3.0-kmod3'
implementation 'com.github.AdrienPoupa:jaudiotagger:2.2.3' implementation 'com.github.AdrienPoupa:jaudiotagger:2.2.3'
implementation 'com.anjlab.android.iab.v3:library:1.0.44' implementation 'com.anjlab.android.iab.v3:library:1.1.0'
implementation 'com.r0adkll:slidableactivity:2.0.6' implementation 'com.r0adkll:slidableactivity:2.0.6'
implementation 'com.heinrichreimersoftware:material-intro:1.6' implementation 'com.heinrichreimersoftware:material-intro:1.6'

File diff suppressed because one or more lines are too long

View file

@ -33,7 +33,7 @@ object Constants {
const val BASE_SELECTION = MediaStore.Audio.AudioColumns.IS_MUSIC + "=1" + " AND " + MediaStore.Audio.AudioColumns.TITLE + " != ''" const val BASE_SELECTION = MediaStore.Audio.AudioColumns.IS_MUSIC + "=1" + " AND " + MediaStore.Audio.AudioColumns.TITLE + " != ''"
val BASE_PROJECTION = arrayOf(BaseColumns._ID, // 0 val baseProjection = arrayOf(BaseColumns._ID, // 0
MediaStore.Audio.AudioColumns.TITLE, // 1 MediaStore.Audio.AudioColumns.TITLE, // 1
MediaStore.Audio.AudioColumns.TRACK, // 2 MediaStore.Audio.AudioColumns.TRACK, // 2
MediaStore.Audio.AudioColumns.YEAR, // 3 MediaStore.Audio.AudioColumns.YEAR, // 3

View file

@ -33,6 +33,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentSkipListMap; import java.util.concurrent.ConcurrentSkipListMap;
import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.loaders.AlbumLoader; import code.name.monkey.retromusic.loaders.AlbumLoader;
import code.name.monkey.retromusic.loaders.ArtistLoader; import code.name.monkey.retromusic.loaders.ArtistLoader;
@ -46,6 +47,7 @@ import code.name.monkey.retromusic.model.Playlist;
import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.model.Song;
import code.name.monkey.retromusic.providers.MusicPlaybackQueueStore; import code.name.monkey.retromusic.providers.MusicPlaybackQueueStore;
import code.name.monkey.retromusic.service.MusicService; import code.name.monkey.retromusic.service.MusicService;
import code.name.monkey.retromusic.util.ImageUtil;
/** /**
* Created by Beesham Sarendranauth (Beesham) * Created by Beesham Sarendranauth (Beesham)
@ -332,22 +334,26 @@ public class AutoMusicProvider {
mediaItems.add( mediaItems.add(
createBrowsableMediaItem( createBrowsableMediaItem(
AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_ALBUM, AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_ALBUM,
resources.getString(R.string.albums_label) resources.getString(R.string.albums_label),
R.drawable.ic_album_white_24dp
)); ));
mediaItems.add( mediaItems.add(
createBrowsableMediaItem( createBrowsableMediaItem(
AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_ARTIST, AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_ARTIST,
resources.getString(R.string.artists_label) resources.getString(R.string.artists_label),
R.drawable.ic_artist_white_24dp
)); ));
mediaItems.add( mediaItems.add(
createBrowsableMediaItem( createBrowsableMediaItem(
AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_PLAYLIST, AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_PLAYLIST,
resources.getString(R.string.playlists_label) resources.getString(R.string.playlists_label),
R.drawable.ic_queue_music_white_24dp
)); ));
mediaItems.add( mediaItems.add(
createBrowsableMediaItem( createBrowsableMediaItem(
AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_GENRE, AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_GENRE,
resources.getString(R.string.genres_label) resources.getString(R.string.genres_label),
R.drawable.ic_guitar_white_24dp
)); ));
/* mediaItems.add( /* mediaItems.add(
createPlayableMediaItem( createPlayableMediaItem(
@ -403,10 +409,13 @@ public class AutoMusicProvider {
return mediaItems; return mediaItems;
} }
private MediaBrowserCompat.MediaItem createBrowsableMediaItem(String mediaId, String title) { private MediaBrowserCompat.MediaItem createBrowsableMediaItem(String mediaId,
String title,
int iconDrawableId) {
MediaDescriptionCompat.Builder builder = new MediaDescriptionCompat.Builder(); MediaDescriptionCompat.Builder builder = new MediaDescriptionCompat.Builder();
builder.setMediaId(mediaId) builder.setMediaId(mediaId)
.setTitle(title); .setTitle(title)
.setIconBitmap(ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(mContext, iconDrawableId, ThemeStore.Companion.textColorSecondary(mContext))));
return new MediaBrowserCompat.MediaItem(builder.build(), return new MediaBrowserCompat.MediaItem(builder.build(),
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE); MediaBrowserCompat.MediaItem.FLAG_BROWSABLE);

View file

@ -19,7 +19,7 @@ import android.database.Cursor
import android.net.Uri import android.net.Uri
import android.provider.BaseColumns import android.provider.BaseColumns
import android.provider.MediaStore.Audio.Genres import android.provider.MediaStore.Audio.Genres
import code.name.monkey.retromusic.Constants.BASE_PROJECTION import code.name.monkey.retromusic.Constants.baseProjection
import code.name.monkey.retromusic.Constants.BASE_SELECTION import code.name.monkey.retromusic.Constants.BASE_SELECTION
import code.name.monkey.retromusic.model.Genre import code.name.monkey.retromusic.model.Genre
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
@ -105,7 +105,7 @@ object GenreLoader {
try { try {
return context.contentResolver.query( return context.contentResolver.query(
Genres.Members.getContentUri("external", genreId.toLong()), Genres.Members.getContentUri("external", genreId.toLong()),
BASE_PROJECTION, BASE_SELECTION, null, PreferenceUtil.getInstance().songSortOrder) baseProjection, BASE_SELECTION, null, PreferenceUtil.getInstance().songSortOrder)
} catch (e: SecurityException) { } catch (e: SecurityException) {
return null return null
} }

View file

@ -18,7 +18,7 @@ import android.content.Context
import android.database.Cursor import android.database.Cursor
import android.provider.MediaStore import android.provider.MediaStore
import android.provider.MediaStore.Audio.AudioColumns import android.provider.MediaStore.Audio.AudioColumns
import code.name.monkey.retromusic.Constants.BASE_PROJECTION import code.name.monkey.retromusic.Constants.baseProjection
import code.name.monkey.retromusic.Constants.BASE_SELECTION import code.name.monkey.retromusic.Constants.BASE_SELECTION
import code.name.monkey.retromusic.helper.ShuffleHelper import code.name.monkey.retromusic.helper.ShuffleHelper
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
@ -195,7 +195,7 @@ object SongLoader {
try { try {
return context.contentResolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, return context.contentResolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
BASE_PROJECTION, selectionFinal + " AND " + MediaStore.Audio.Media.DURATION + ">= " + (PreferenceUtil.getInstance().filterLength * 1000), selectionValuesFinal, sortOrder) baseProjection, selectionFinal + " AND " + MediaStore.Audio.Media.DURATION + ">= " + (PreferenceUtil.getInstance().filterLength * 1000), selectionValuesFinal, sortOrder)
} catch (e: SecurityException) { } catch (e: SecurityException) {
return null return null
} }

View file

@ -39,5 +39,7 @@ class BottomNavigationBarTinted @JvmOverloads constructor(
val accentColor = ThemeStore.accentColor(context) val accentColor = ThemeStore.accentColor(context)
NavigationViewUtil.setItemIconColors(this, ColorUtil.withAlpha(iconColor, 0.5f), accentColor) NavigationViewUtil.setItemIconColors(this, ColorUtil.withAlpha(iconColor, 0.5f), accentColor)
NavigationViewUtil.setItemTextColors(this, ColorUtil.withAlpha(iconColor, 0.5f), accentColor) NavigationViewUtil.setItemTextColors(this, ColorUtil.withAlpha(iconColor, 0.5f), accentColor)
setOnApplyWindowInsetsListener(null)
} }
} }

View file

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?><!--
<!--
~ Copyright (c) 2019 Hemanth Savarala. ~ Copyright (c) 2019 Hemanth Savarala.
~ ~
~ Licensed under the GNU General Public License v3 ~ Licensed under the GNU General Public License v3
@ -70,12 +69,13 @@
android:id="@+id/toolbarContainer" android:id="@+id/toolbarContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:cardCornerRadius="8dp"
app:cardElevation="6dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
app:cardCornerRadius="8dp"
app:cardElevation="0dp"
app:cardUseCompatPadding="true" app:cardUseCompatPadding="true"
app:layout_scrollFlags="scroll|enterAlways"> app:layout_scrollFlags="scroll|enterAlways"
app:strokeColor="?dividerColor">
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"

View file

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?><!--
<!--
~ Copyright (c) 2019 Hemanth Savarala. ~ Copyright (c) 2019 Hemanth Savarala.
~ ~
~ Licensed under the GNU General Public License v3 ~ Licensed under the GNU General Public License v3
@ -47,13 +46,13 @@
android:id="@+id/toolbarContainer" android:id="@+id/toolbarContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
app:cardCornerRadius="8dp" app:cardCornerRadius="8dp"
app:cardElevation="0dp" app:cardElevation="0dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
app:strokeColor="?dividerColor"
app:cardUseCompatPadding="true" app:cardUseCompatPadding="true"
app:layout_scrollFlags="scroll|enterAlways" app:layout_scrollFlags="scroll|enterAlways"
app:strokeColor="?dividerColor"
app:strokeWidth="1dp"> app:strokeWidth="1dp">
<FrameLayout <FrameLayout
@ -63,8 +62,9 @@
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
style="@style/Toolbar" style="@style/Toolbar"
app:title="@string/search_hint"
app:titleMarginStart="0dp" app:titleMarginStart="0dp"
app:title="@string/library" app:titleTextAppearance="@style/TextAppearance.MaterialComponents.Body1"
tools:ignore="UnusedAttribute" /> tools:ignore="UnusedAttribute" />
<ViewStub <ViewStub

View file

@ -46,7 +46,7 @@
<code.name.monkey.retromusic.views.BottomNavigationBarTinted <code.name.monkey.retromusic.views.BottomNavigationBarTinted
android:id="@+id/bottomNavigationView" android:id="@+id/bottomNavigationView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="56dp" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:elevation="0dp" android:elevation="0dp"
app:elevation="0dp" app:elevation="0dp"

View file

@ -26,13 +26,13 @@ android {
dependencies { dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0-beta01' implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'com.google.android.material:material:1.1.0-alpha07' implementation 'com.google.android.material:material:1.1.0-alpha09'
implementation 'androidx.preference:preference:1.1.0-beta01' implementation 'androidx.preference:preference:1.1.0-rc01'
implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.cardview:cardview:1.0.0'
// Used for the list preference classes // Used for the list preference classes
implementation 'com.afollestad.material-dialogs:core:3.0.0-alpha1' implementation 'com.afollestad.material-dialogs:core:3.0.0-alpha1'
implementation 'com.afollestad.material-dialogs:input:3.0.0-alpha1' implementation 'com.afollestad.material-dialogs:input:3.0.0-alpha1'
implementation 'com.afollestad.material-dialogs:color:3.0.0-alpha1' implementation 'com.afollestad.material-dialogs:color:3.0.0-alpha1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
} }