Removed app context for PreferenceUtil class

This commit is contained in:
h4h13 2019-09-09 18:34:53 +05:30
parent 5df5f6c93e
commit 2bbe39eab7
97 changed files with 397 additions and 456 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 360 versionCode 365
versionName '3.3.200' versionName '3.4.000-beta01'
multiDexEnabled true multiDexEnabled true
@ -100,19 +100,21 @@ 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-alpha02' implementation 'androidx.fragment:fragment:1.2.0-alpha02'
implementation 'androidx.appcompat:appcompat:1.1.0-rc01' implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0-beta03' implementation 'androidx.recyclerview:recyclerview:1.1.0-beta03'
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'
implementation 'androidx.palette:palette-ktx:1.0.0' implementation 'androidx.palette:palette-ktx:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.1.0-alpha09' implementation 'com.google.android.material:material:1.1.0-alpha09'
implementation 'com.google.android.play:core:1.6.1'
implementation 'com.squareup.retrofit2:retrofit:2.6.1' implementation 'com.squareup.retrofit2:retrofit:2.6.1'
implementation 'com.squareup.retrofit2:converter-gson:2.6.1' implementation 'com.squareup.retrofit2:converter-gson:2.6.1'

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="code.name.monkey.retromusic"> package="code.name.monkey.retromusic">
<uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WAKE_LOCK" />
@ -22,7 +23,8 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.RetroMusic.Light" android:theme="@style/Theme.RetroMusic.Light"
android:usesCleartextTraffic="false"> android:usesCleartextTraffic="false"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
<activity <activity
android:name=".activities.MainActivity" android:name=".activities.MainActivity"
android:label="@string/app_name"> android:label="@string/app_name">
@ -271,6 +273,8 @@
<meta-data <meta-data
android:name="com.bumptech.glide.integration.okhttp3.OkHttpGlideModule" android:name="com.bumptech.glide.integration.okhttp3.OkHttpGlideModule"
android:value="GlideModule" /> android:value="GlideModule" />
<meta-data
android:name="com.android.vending.splits.required"
android:value="true" />
</application> </application>
</manifest> </manifest>

File diff suppressed because one or more lines are too long

View file

@ -14,7 +14,6 @@
package code.name.monkey.retromusic package code.name.monkey.retromusic
import android.content.Context
import android.widget.Toast import android.widget.Toast
import androidx.multidex.MultiDexApplication import androidx.multidex.MultiDexApplication
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
@ -25,6 +24,7 @@ import code.name.monkey.retromusic.dagger.MusicComponent
import code.name.monkey.retromusic.dagger.module.AppModule import code.name.monkey.retromusic.dagger.module.AppModule
import com.anjlab.android.iab.v3.BillingProcessor import com.anjlab.android.iab.v3.BillingProcessor
import com.anjlab.android.iab.v3.TransactionDetails import com.anjlab.android.iab.v3.TransactionDetails
import com.google.android.play.core.missingsplits.MissingSplitsManagerFactory
class App : MultiDexApplication() { class App : MultiDexApplication() {
@ -32,10 +32,11 @@ class App : MultiDexApplication() {
lateinit var billingProcessor: BillingProcessor lateinit var billingProcessor: BillingProcessor
override fun onCreate() { override fun onCreate() {
if (MissingSplitsManagerFactory.create(this).disableAppIfMissingRequiredSplits()) {
return
}
super.onCreate() super.onCreate()
instance = this instance = this
musicComponent = DaggerMusicComponent.builder() musicComponent = DaggerMusicComponent.builder()
.appModule(AppModule(this)) .appModule(AppModule(this))
.build() .build()
@ -72,19 +73,25 @@ class App : MultiDexApplication() {
} }
companion object { companion object {
private var instance: App? = null
fun getContext(): App {
return instance!!
}
fun isProVersion(): Boolean {
return BuildConfig.DEBUG || instance?.billingProcessor!!.isPurchased(PRO_VERSION_PRODUCT_ID)
}
lateinit var musicComponent: MusicComponent lateinit var musicComponent: MusicComponent
const val PRO_VERSION_PRODUCT_ID = "pro_version" const val PRO_VERSION_PRODUCT_ID = "pro_version"
lateinit var instance: App
private set
val context: Context /*val context: Context
get() = instance.applicationContext get() = (instance as App).applicationContext*/
val isProVersion: Boolean /*val isProVersion: Boolean
get() = BuildConfig.DEBUG || instance.billingProcessor.isPurchased(PRO_VERSION_PRODUCT_ID) get() = BuildConfig.DEBUG || instance.billingProcessor.isPurchased(PRO_VERSION_PRODUCT_ID)*/
} }
} }

View file

@ -1,31 +0,0 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic
import code.name.monkey.retromusic.providers.RepositoryImpl
import code.name.monkey.retromusic.providers.interfaces.Repository
import code.name.monkey.retromusic.util.schedulers.BaseSchedulerProvider
import code.name.monkey.retromusic.util.schedulers.SchedulerProvider
object Injection {
fun provideRepository(): Repository {
return RepositoryImpl.instance
}
fun provideSchedulerProvider(): BaseSchedulerProvider {
return SchedulerProvider.getInstance()
}
}

View file

@ -58,7 +58,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView {
private lateinit var album: Album private lateinit var album: Album
private val savedSortOrder: String private val savedSortOrder: String
get() = PreferenceUtil.getInstance().albumDetailSongSortOrder get() = PreferenceUtil.getInstance(this).albumDetailSongSortOrder
override fun createContentView(): View { override fun createContentView(): View {
return wrapSlidingMusicPanel(R.layout.activity_album) return wrapSlidingMusicPanel(R.layout.activity_album)
@ -101,7 +101,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView {
setOnClickListener { MusicPlayerRemote.openAndShuffleQueue(album.songs!!, true) } setOnClickListener { MusicPlayerRemote.openAndShuffleQueue(album.songs!!, true) }
} }
App.musicComponent.inject(this) App.musicComponent?.inject(this)
albumDetailsPresenter.attachView(this) albumDetailsPresenter.attachView(this)
if (intent.extras!!.containsKey(EXTRA_ALBUM_ID)) { if (intent.extras!!.containsKey(EXTRA_ALBUM_ID)) {
@ -137,7 +137,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView {
toolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp) toolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp)
if (toolbar != null && !PreferenceUtil.getInstance().fullScreenMode) { if (toolbar != null && !PreferenceUtil.getInstance(this).fullScreenMode) {
val params = toolbar.layoutParams as ViewGroup.MarginLayoutParams val params = toolbar.layoutParams as ViewGroup.MarginLayoutParams
params.topMargin = RetroUtil.getStatusBarHeight() params.topMargin = RetroUtil.getStatusBarHeight()
toolbar.layoutParams = params toolbar.layoutParams = params
@ -256,13 +256,13 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView {
} }
private fun setColors(color: Int) { private fun setColors(color: Int) {
val themeColor = if (PreferenceUtil.getInstance().adaptiveColor) color val themeColor = if (PreferenceUtil.getInstance(this).adaptiveColor) color
else ThemeStore.accentColor(this) else ThemeStore.accentColor(this)
songTitle.setTextColor(themeColor) songTitle.setTextColor(themeColor)
moreTitle.setTextColor(themeColor) moreTitle.setTextColor(themeColor)
val buttonColor = if (PreferenceUtil.getInstance().adaptiveColor) color val buttonColor = if (PreferenceUtil.getInstance(this).adaptiveColor) color
else ATHUtil.resolveColor(this, R.attr.cardBackgroundColor) else ATHUtil.resolveColor(this, R.attr.cardBackgroundColor)
MaterialUtil.setTint(button = shuffleAction, color = buttonColor) MaterialUtil.setTint(button = shuffleAction, color = buttonColor)
@ -340,7 +340,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView {
} }
private fun setSaveSortOrder(sortOrder: String?) { private fun setSaveSortOrder(sortOrder: String?) {
PreferenceUtil.getInstance().albumDetailSongSortOrder = sortOrder PreferenceUtil.getInstance(this).albumDetailSongSortOrder = sortOrder
reload() reload()
} }

View file

@ -81,7 +81,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView {
ActivityCompat.postponeEnterTransition(this) ActivityCompat.postponeEnterTransition(this)
App.musicComponent.inject(this) App.musicComponent?.inject(this)
artistDetailsPresenter.attachView(this) artistDetailsPresenter.attachView(this)
if (intent.extras!!.containsKey(EXTRA_ARTIST_ID)) { if (intent.extras!!.containsKey(EXTRA_ARTIST_ID)) {
@ -137,7 +137,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView {
supportActionBar?.title = null supportActionBar?.title = null
if (toolbar != null && !PreferenceUtil.getInstance().fullScreenMode) { if (toolbar != null && !PreferenceUtil.getInstance(this).fullScreenMode) {
val params = toolbar!!.layoutParams as ViewGroup.MarginLayoutParams val params = toolbar!!.layoutParams as ViewGroup.MarginLayoutParams
params.topMargin = RetroUtil.getStatusBarHeight() params.topMargin = RetroUtil.getStatusBarHeight()
toolbar!!.layoutParams = params toolbar!!.layoutParams = params
@ -279,13 +279,13 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView {
private fun setColors(color: Int) { private fun setColors(color: Int) {
val textColor = if (PreferenceUtil.getInstance().adaptiveColor) color else ThemeStore.accentColor(this) val textColor = if (PreferenceUtil.getInstance(this).adaptiveColor) color else ThemeStore.accentColor(this)
albumTitle.setTextColor(textColor) albumTitle.setTextColor(textColor)
songTitle.setTextColor(textColor) songTitle.setTextColor(textColor)
biographyTitle.setTextColor(textColor) biographyTitle.setTextColor(textColor)
val buttonColor = if (PreferenceUtil.getInstance().adaptiveColor) color val buttonColor = if (PreferenceUtil.getInstance(this).adaptiveColor) color
else ATHUtil.resolveColor(this, R.attr.cardBackgroundColor) else ATHUtil.resolveColor(this, R.attr.cardBackgroundColor)
MaterialUtil.setTint(button = shuffleAction, color = buttonColor) MaterialUtil.setTint(button = shuffleAction, color = buttonColor)

View file

@ -65,7 +65,7 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder, GenreDet
setUpToolBar() setUpToolBar()
setupRecyclerView() setupRecyclerView()
App.musicComponent.inject(this) App.musicComponent?.inject(this)
genreDetailsPresenter.attachView(this) genreDetailsPresenter.attachView(this)
} }

View file

@ -61,7 +61,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
} }
override fun onPageSelected(position: Int) { override fun onPageSelected(position: Int) {
PreferenceUtil.getInstance().lyricsOptions = position PreferenceUtil.getInstance(this).lyricsOptions = position
if (position == 0) fab.text = getString(R.string.synced_lyrics) if (position == 0) fab.text = getString(R.string.synced_lyrics)
else if (position == 1) fab.text = getString(R.string.lyrics) else if (position == 1) fab.text = getString(R.string.lyrics)
} }
@ -110,7 +110,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
viewPager.apply { viewPager.apply {
adapter = PagerAdapter(supportFragmentManager) adapter = PagerAdapter(supportFragmentManager)
currentItem = PreferenceUtil.getInstance().lyricsOptions currentItem = PreferenceUtil.getInstance(this@LyricsActivity).lyricsOptions
addOnPageChangeListener(this@LyricsActivity) addOnPageChangeListener(this@LyricsActivity)
} }
@ -234,7 +234,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
} }
override fun getPageTitle(position: Int): CharSequence? { override fun getPageTitle(position: Int): CharSequence? {
return App.context.getString(tabs[position].title) return App.getContext().getString(tabs[position].title)
} }
override fun getCount(): Int { override fun getCount(): Int {

View file

@ -1,13 +1,11 @@
package code.name.monkey.retromusic.activities package code.name.monkey.retromusic.activities
import android.annotation.SuppressLint
import android.content.* import android.content.*
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.os.Bundle import android.os.Bundle
import android.provider.MediaStore import android.provider.MediaStore
import android.util.Log import android.util.Log
import android.view.View import android.view.View
import android.view.ViewGroup
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
@ -37,7 +35,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
override fun onReceive(context: Context, intent: Intent) { override fun onReceive(context: Context, intent: Intent) {
val action = intent.action val action = intent.action
if (action != null && action == Intent.ACTION_SCREEN_OFF) { if (action != null && action == Intent.ACTION_SCREEN_OFF) {
if (PreferenceUtil.getInstance().lockScreen && MusicPlayerRemote.isPlaying) { if (PreferenceUtil.getInstance(this@MainActivity).lockScreen && MusicPlayerRemote.isPlaying) {
val activity = Intent(context, LockScreenActivity::class.java) val activity = Intent(context, LockScreenActivity::class.java)
activity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) activity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
activity.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY) activity.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
@ -57,16 +55,16 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
setDrawUnderStatusBar() setDrawUnderStatusBar()
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
getBottomNavigationView().selectedItemId = PreferenceUtil.getInstance().lastPage getBottomNavigationView().selectedItemId = PreferenceUtil.getInstance(this).lastPage
getBottomNavigationView().setOnNavigationItemSelectedListener { getBottomNavigationView().setOnNavigationItemSelectedListener {
PreferenceUtil.getInstance().lastPage = it.itemId PreferenceUtil.getInstance(this).lastPage = it.itemId
selectedFragment(it.itemId) selectedFragment(it.itemId)
true true
} }
if (savedInstanceState == null) { if (savedInstanceState == null) {
selectedFragment(PreferenceUtil.getInstance().lastPage) selectedFragment(PreferenceUtil.getInstance(this).lastPage)
} else { } else {
restoreCurrentFragment(); restoreCurrentFragment();
} }
@ -82,7 +80,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
try { try {
val pInfo = packageManager.getPackageInfo(packageName, 0) val pInfo = packageManager.getPackageInfo(packageName, 0)
val currentVersion = pInfo.versionCode val currentVersion = pInfo.versionCode
if (currentVersion != PreferenceUtil.getInstance().lastChangelogVersion) { if (currentVersion != PreferenceUtil.getInstance(this).lastChangelogVersion) {
startActivityForResult(Intent(this, WhatsNewActivity::class.java), APP_INTRO_REQUEST) startActivityForResult(Intent(this, WhatsNewActivity::class.java), APP_INTRO_REQUEST)
} }
} catch (e: PackageManager.NameNotFoundException) { } catch (e: PackageManager.NameNotFoundException) {
@ -97,7 +95,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
screenOnOff.addAction(Intent.ACTION_SCREEN_OFF) screenOnOff.addAction(Intent.ACTION_SCREEN_OFF)
registerReceiver(broadcastReceiver, screenOnOff) registerReceiver(broadcastReceiver, screenOnOff)
PreferenceUtil.getInstance().registerOnSharedPreferenceChangedListener(this) PreferenceUtil.getInstance(this).registerOnSharedPreferenceChangedListener(this)
if (intent.hasExtra("expand")) { if (intent.hasExtra("expand")) {
if (intent.getBooleanExtra("expand", false)) { if (intent.getBooleanExtra("expand", false)) {
@ -111,7 +109,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
super.onDestroy() super.onDestroy()
disposable.clear() disposable.clear()
unregisterReceiver(broadcastReceiver) unregisterReceiver(broadcastReceiver)
PreferenceUtil.getInstance().unregisterOnSharedPreferenceChangedListener(this) PreferenceUtil.getInstance(this).unregisterOnSharedPreferenceChangedListener(this)
} }
private fun setCurrentFragment(fragment: Fragment, b: Boolean = false) { private fun setCurrentFragment(fragment: Fragment, b: Boolean = false) {

View file

@ -64,7 +64,7 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
finish() finish()
} }
App.musicComponent.inject(this) App.musicComponent?.inject(this)
playlistSongsPresenter.attachView(this) playlistSongsPresenter.attachView(this)

View file

@ -74,7 +74,7 @@ class PurchaseActivity : AbsBaseActivity(), BillingProcessor.IBillingHandler {
} }
override fun onPurchaseHistoryRestored() { override fun onPurchaseHistoryRestored() {
if (App.isProVersion) { if (App.isProVersion()) {
Toast.makeText(this, R.string.restored_previous_purchase_please_restart, Toast.LENGTH_LONG).show() Toast.makeText(this, R.string.restored_previous_purchase_please_restart, Toast.LENGTH_LONG).show()
setResult(RESULT_OK) setResult(RESULT_OK)
} else { } else {

View file

@ -45,7 +45,7 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_search) setContentView(R.layout.activity_search)
App.musicComponent.inject(this) App.musicComponent?.inject(this)
searchPresenter.attachView(this) searchPresenter.attachView(this)

View file

@ -8,7 +8,6 @@ import androidx.fragment.app.Fragment
import androidx.transition.TransitionManager import androidx.transition.TransitionManager
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.App.Companion.context
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.base.AbsBaseActivity import code.name.monkey.retromusic.activities.base.AbsBaseActivity
import code.name.monkey.retromusic.fragments.settings.MainSettingsFragment import code.name.monkey.retromusic.fragments.settings.MainSettingsFragment
@ -87,12 +86,12 @@ class SettingsActivity : AbsBaseActivity(), SharedPreferences.OnSharedPreference
public override fun onPause() { public override fun onPause() {
super.onPause() super.onPause()
PreferenceUtil.getInstance().unregisterOnSharedPreferenceChangedListener(this) PreferenceUtil.getInstance(this).unregisterOnSharedPreferenceChangedListener(this)
} }
public override fun onResume() { public override fun onResume() {
super.onResume() super.onResume()
PreferenceUtil.getInstance().registerOnSharedPreferenceChangedListener(this) PreferenceUtil.getInstance(this).registerOnSharedPreferenceChangedListener(this)
} }
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {

View file

@ -55,14 +55,14 @@ class UserInfoActivity : AbsBaseActivity() {
MaterialUtil.setTint(nameContainer, false) MaterialUtil.setTint(nameContainer, false)
MaterialUtil.setTint(bioContainer, false) MaterialUtil.setTint(bioContainer, false)
name.setText(PreferenceUtil.getInstance().userName) name.setText(PreferenceUtil.getInstance(this).userName)
bio.setText(PreferenceUtil.getInstance().userBio) bio.setText(PreferenceUtil.getInstance(this).userBio)
if (PreferenceUtil.getInstance().profileImage.isNotEmpty()) { if (PreferenceUtil.getInstance(this).profileImage.isNotEmpty()) {
loadImageFromStorage(PreferenceUtil.getInstance().profileImage) loadImageFromStorage(PreferenceUtil.getInstance(this).profileImage)
} }
if (PreferenceUtil.getInstance().bannerImage.isNotEmpty()) { if (PreferenceUtil.getInstance(this).bannerImage.isNotEmpty()) {
loadBannerFromStorage(PreferenceUtil.getInstance().bannerImage) loadBannerFromStorage(PreferenceUtil.getInstance(this).bannerImage)
} }
userImage.setOnClickListener { userImage.setOnClickListener {
MaterialDialog(this, BottomSheet()).show { MaterialDialog(this, BottomSheet()).show {
@ -70,7 +70,7 @@ class UserInfoActivity : AbsBaseActivity() {
listItems(items = listOf(getString(R.string.new_profile_photo), getString(R.string.remove_profile_photo))) { _, position, _ -> listItems(items = listOf(getString(R.string.new_profile_photo), getString(R.string.remove_profile_photo))) { _, position, _ ->
when (position) { when (position) {
0 -> pickNewPhoto() 0 -> pickNewPhoto()
1 -> PreferenceUtil.getInstance().saveProfileImage("") 1 -> PreferenceUtil.getInstance(this@UserInfoActivity).saveProfileImage("")
} }
} }
} }
@ -90,7 +90,7 @@ class UserInfoActivity : AbsBaseActivity() {
return@setOnClickListener return@setOnClickListener
}*/ }*/
PreferenceUtil.getInstance().userName = nameString PreferenceUtil.getInstance(this).userName = nameString
//PreferenceUtil.getInstance().userBio = bioString //PreferenceUtil.getInstance().userBio = bioString
setResult(Activity.RESULT_OK) setResult(Activity.RESULT_OK)
finish() finish()
@ -122,7 +122,7 @@ class UserInfoActivity : AbsBaseActivity() {
{ _, position, _ -> { _, position, _ ->
when (position) { when (position) {
0 -> selectBannerImage() 0 -> selectBannerImage()
1 -> PreferenceUtil.getInstance().setBannerImagePath("") 1 -> PreferenceUtil.getInstance(this@UserInfoActivity).setBannerImagePath("")
} }
} }
} }
@ -130,7 +130,7 @@ class UserInfoActivity : AbsBaseActivity() {
private fun selectBannerImage() { private fun selectBannerImage() {
if (TextUtils.isEmpty(PreferenceUtil.getInstance().bannerImage)) { if (TextUtils.isEmpty(PreferenceUtil.getInstance(this).bannerImage)) {
val pickImageIntent = Intent(Intent.ACTION_PICK, Media.EXTERNAL_CONTENT_URI) val pickImageIntent = Intent(Intent.ACTION_PICK, Media.EXTERNAL_CONTENT_URI)
pickImageIntent.type = "image/*" pickImageIntent.type = "image/*"
//pickImageIntent.putExtra("crop", "true") //pickImageIntent.putExtra("crop", "true")
@ -142,7 +142,7 @@ class UserInfoActivity : AbsBaseActivity() {
//intent.setAction(Intent.ACTION_GET_CONTENT); //intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(pickImageIntent, "Select Picture"), PICK_BANNER_REQUEST) startActivityForResult(Intent.createChooser(pickImageIntent, "Select Picture"), PICK_BANNER_REQUEST)
} else { } else {
PreferenceUtil.getInstance().setBannerImagePath("") PreferenceUtil.getInstance(this).setBannerImagePath("")
bannerImage.setImageResource(android.R.color.transparent) bannerImage.setImageResource(android.R.color.transparent)
} }
} }
@ -169,7 +169,7 @@ class UserInfoActivity : AbsBaseActivity() {
data.data?.let { data.data?.let {
val bitmap = getResizedBitmap(getBitmap(contentResolver, it), PROFILE_ICON_SIZE) val bitmap = getResizedBitmap(getBitmap(contentResolver, it), PROFILE_ICON_SIZE)
val profileImagePath = saveToInternalStorage(bitmap, USER_PROFILE) val profileImagePath = saveToInternalStorage(bitmap, USER_PROFILE)
PreferenceUtil.getInstance().saveProfileImage(profileImagePath) PreferenceUtil.getInstance(this).saveProfileImage(profileImagePath)
loadImageFromStorage(profileImagePath) loadImageFromStorage(profileImagePath)
} }
@ -182,7 +182,7 @@ class UserInfoActivity : AbsBaseActivity() {
data.data?.let { data.data?.let {
val bitmap = getBitmap(contentResolver, it) val bitmap = getBitmap(contentResolver, it)
val profileImagePath = saveToInternalStorage(bitmap, USER_BANNER) val profileImagePath = saveToInternalStorage(bitmap, USER_BANNER)
PreferenceUtil.getInstance().setBannerImagePath(profileImagePath) PreferenceUtil.getInstance(this).setBannerImagePath(profileImagePath)
loadBannerFromStorage(profileImagePath) loadBannerFromStorage(profileImagePath)
} }
} catch (e: IOException) { } catch (e: IOException) {
@ -199,7 +199,7 @@ class UserInfoActivity : AbsBaseActivity() {
if (aUri == null) { if (aUri == null) {
return imagePath return imagePath
} }
if (DocumentsContract.isDocumentUri(App.context, aUri)) { if (DocumentsContract.isDocumentUri(App.getContext(), aUri)) {
val documentId = DocumentsContract.getDocumentId(aUri) val documentId = DocumentsContract.getDocumentId(aUri)
if ("com.android.providers.media.documents" == aUri.authority) { if ("com.android.providers.media.documents" == aUri.authority) {
val id = documentId.split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()[1] val id = documentId.split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()[1]
@ -220,7 +220,7 @@ class UserInfoActivity : AbsBaseActivity() {
private fun getImagePath(aUri: Uri, aSelection: String?): String? { private fun getImagePath(aUri: Uri, aSelection: String?): String? {
var path: String? = null var path: String? = null
val cursor = App.context.contentResolver.query(aUri, null, aSelection, null, null) val cursor = App.getContext().contentResolver.query(aUri, null, aSelection, null, null)
if (cursor != null) { if (cursor != null) {
if (cursor.moveToFirst()) { if (cursor.moveToFirst()) {
path = cursor.getString(cursor.getColumnIndex(Media.DATA)) path = cursor.getString(cursor.getColumnIndex(Media.DATA))

View file

@ -37,7 +37,7 @@ public class WhatsNewActivity extends AbsBaseActivity {
try { try {
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
int currentVersion = pInfo.versionCode; int currentVersion = pInfo.versionCode;
PreferenceUtil.getInstance().setLastChangeLogVersion(currentVersion); PreferenceUtil.getInstance(context).setLastChangeLogVersion(currentVersion);
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -67,7 +67,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), Sliding
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
if (currentNowPlayingScreen != PreferenceUtil.getInstance().nowPlayingScreen) { if (currentNowPlayingScreen != PreferenceUtil.getInstance(this).nowPlayingScreen) {
postRecreate() postRecreate()
} }
} }
@ -181,7 +181,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), Sliding
} }
private fun chooseFragmentForTheme() { private fun chooseFragmentForTheme() {
currentNowPlayingScreen = PreferenceUtil.getInstance().nowPlayingScreen currentNowPlayingScreen = PreferenceUtil.getInstance(this).nowPlayingScreen
val fragment: Fragment = when (currentNowPlayingScreen) { val fragment: Fragment = when (currentNowPlayingScreen) {
BLUR -> BlurPlayerFragment() BLUR -> BlurPlayerFragment()
@ -262,7 +262,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), Sliding
val isColorLight = ColorUtil.isColorLight(paletteColor) val isColorLight = ColorUtil.isColorLight(paletteColor)
if (PreferenceUtil.getInstance().adaptiveColor && if (PreferenceUtil.getInstance(this).adaptiveColor &&
(currentNowPlayingScreen == NORMAL || currentNowPlayingScreen == FLAT)) { (currentNowPlayingScreen == NORMAL || currentNowPlayingScreen == FLAT)) {
super.setLightNavigationBar(true) super.setLightNavigationBar(true)
super.setLightStatusbar(isColorLight) super.setLightStatusbar(isColorLight)
@ -314,7 +314,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), Sliding
private fun updateTabs() { private fun updateTabs() {
bottomNavigationView.menu.clear() bottomNavigationView.menu.clear()
val currentTabs = PreferenceUtil.getInstance().libraryCategoryInfos val currentTabs = PreferenceUtil.getInstance(this).libraryCategoryInfos
for (tab in currentTabs) { for (tab in currentTabs) {
if (tab.visible) { if (tab.visible) {
val menu = tab.category; val menu = tab.category;

View file

@ -25,7 +25,7 @@ abstract class AbsThemeActivity : ATHActivity(), Runnable {
private val handler = Handler() private val handler = Handler()
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
setTheme(PreferenceUtil.getInstance().generalTheme) setTheme(PreferenceUtil.getInstance(this).generalTheme)
hideStatusBar() hideStatusBar()
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
//MaterialDialogsUtil.updateMaterialDialogsThemeSingleton(this) //MaterialDialogsUtil.updateMaterialDialogsThemeSingleton(this)
@ -37,7 +37,7 @@ abstract class AbsThemeActivity : ATHActivity(), Runnable {
} }
private fun toggleScreenOn() { private fun toggleScreenOn() {
if (PreferenceUtil.getInstance().isScreenOnEnabled) { if (PreferenceUtil.getInstance(this).isScreenOnEnabled) {
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
} else { } else {
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
@ -56,7 +56,7 @@ abstract class AbsThemeActivity : ATHActivity(), Runnable {
} }
fun hideStatusBar() { fun hideStatusBar() {
hideStatusBar(PreferenceUtil.getInstance().fullScreenMode) hideStatusBar(PreferenceUtil.getInstance(this).fullScreenMode)
} }
private fun hideStatusBar(fullscreen: Boolean) { private fun hideStatusBar(fullscreen: Boolean) {
@ -68,7 +68,7 @@ abstract class AbsThemeActivity : ATHActivity(), Runnable {
private fun changeBackgroundShape() { private fun changeBackgroundShape() {
var background: Drawable? = if (PreferenceUtil.getInstance().isRoundCorners) var background: Drawable? = if (PreferenceUtil.getInstance(this).isRoundCorners)
ContextCompat.getDrawable(this, R.drawable.round_window) ContextCompat.getDrawable(this, R.drawable.round_window)
else else
ContextCompat.getDrawable(this, R.drawable.square_window) ContextCompat.getDrawable(this, R.drawable.square_window)
@ -168,7 +168,7 @@ abstract class AbsThemeActivity : ATHActivity(), Runnable {
or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_FULLSCREEN
or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
if (PreferenceUtil.getInstance().fullScreenMode) { if (PreferenceUtil.getInstance(this).fullScreenMode) {
window.decorView.systemUiVisibility = flags window.decorView.systemUiVisibility = flags
} }
} }

View file

@ -54,9 +54,9 @@ public class DeviceInfo {
versionCode = -1; versionCode = -1;
versionName = null; versionName = null;
} }
baseTheme = PreferenceUtil.getInstance().getBaseTheme(); baseTheme = PreferenceUtil.getInstance(context).getBaseTheme();
nowPlayingTheme = context.getString(PreferenceUtil.getInstance().getNowPlayingScreen().getTitleRes()); nowPlayingTheme = context.getString(PreferenceUtil.getInstance(context).getNowPlayingScreen().getTitleRes());
isAdaptive = PreferenceUtil.getInstance().getAdaptiveColor(); isAdaptive = PreferenceUtil.getInstance(context).getAdaptiveColor();
} }
public String toMarkdown() { public String toMarkdown() {

View file

@ -12,10 +12,28 @@ import code.name.monkey.retromusic.model.Contributor
import code.name.monkey.retromusic.util.RetroUtil.openUrl import code.name.monkey.retromusic.util.RetroUtil.openUrl
import code.name.monkey.retromusic.views.CircularImageView import code.name.monkey.retromusic.views.CircularImageView
class ContributorAdapter(private var contributors: List<Contributor>) : RecyclerView.Adapter<ContributorAdapter.ViewHolder>() { class ContributorAdapter(
private var contributors: List<Contributor>
) : RecyclerView.Adapter<ContributorAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_contributor, parent, false)) return if (viewType == HEADER) {
ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_contributor_header, parent, false))
} else
ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_contributor, parent, false))
}
companion object {
const val HEADER: Int = 0
const val ITEM: Int = 1
}
override fun getItemViewType(position: Int): Int {
return if (position == 0) {
HEADER
} else {
ITEM
}
} }
override fun onBindViewHolder(holder: ViewHolder, position: Int) { override fun onBindViewHolder(holder: ViewHolder, position: Int) {

View file

@ -15,7 +15,11 @@ import java.util.*
* @author Hemanth S (h4h13). * @author Hemanth S (h4h13).
*/ */
class GenreAdapter(private val mActivity: Activity, dataSet: ArrayList<Genre>, private val mItemLayoutRes: Int) : RecyclerView.Adapter<GenreAdapter.ViewHolder>() { class GenreAdapter(
private val mActivity: Activity,
dataSet: ArrayList<Genre>,
private val mItemLayoutRes: Int
) : RecyclerView.Adapter<GenreAdapter.ViewHolder>() {
var dataSet = ArrayList<Genre>() var dataSet = ArrayList<Genre>()
private set private set

View file

@ -8,7 +8,6 @@ import android.view.ViewGroup
import androidx.annotation.IntDef import androidx.annotation.IntDef
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
@ -16,13 +15,19 @@ import code.name.monkey.retromusic.adapter.album.AlbumFullWidthAdapter
import code.name.monkey.retromusic.adapter.artist.ArtistAdapter import code.name.monkey.retromusic.adapter.artist.ArtistAdapter
import code.name.monkey.retromusic.adapter.song.SongAdapter import code.name.monkey.retromusic.adapter.song.SongAdapter
import code.name.monkey.retromusic.loaders.PlaylistSongsLoader import code.name.monkey.retromusic.loaders.PlaylistSongsLoader
import code.name.monkey.retromusic.model.* import code.name.monkey.retromusic.model.Album
import code.name.monkey.retromusic.model.Artist
import code.name.monkey.retromusic.model.Home
import code.name.monkey.retromusic.model.Playlist
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import com.google.android.material.chip.Chip import com.google.android.material.chip.Chip
class HomeAdapter(private val activity: AppCompatActivity, private var homes: List<Home>, private val displayMetrics: DisplayMetrics) : RecyclerView.Adapter<RecyclerView.ViewHolder>() { class HomeAdapter(
private val activity: AppCompatActivity,
private var homes: List<Home>,
private val displayMetrics: DisplayMetrics
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
override fun getItemViewType(position: Int): Int { override fun getItemViewType(position: Int): Int {
return homes[position].homeSection return homes[position].homeSection
@ -96,13 +101,14 @@ class HomeAdapter(private val activity: AppCompatActivity, private var homes: Li
fun bindView(home: Home) { fun bindView(home: Home) {
recyclerView.apply { recyclerView.apply {
layoutManager = GridLayoutManager(activity, 1, GridLayoutManager.HORIZONTAL, false) layoutManager = GridLayoutManager(activity, 1, GridLayoutManager.HORIZONTAL, false)
val artistAdapter = ArtistAdapter(activity, home.arrayList as ArrayList<Artist>, PreferenceUtil.getInstance().getHomeGridStyle(context!!), false, null) val artistAdapter = ArtistAdapter(activity, home.arrayList as ArrayList<Artist>, PreferenceUtil.getInstance(activity).getHomeGridStyle(context!!), false, null)
adapter = artistAdapter adapter = artistAdapter
} }
chip.text = activity.getString(home.title) chip.text = activity.getString(home.title)
chip.setChipIconResource(home.icon) chip.setChipIconResource(home.icon)
} }
} }
private inner class PlaylistViewHolder(view: View) : AbsHomeViewItem(view) { private inner class PlaylistViewHolder(view: View) : AbsHomeViewItem(view) {
fun bindView(home: Home) { fun bindView(home: Home) {
val songs = PlaylistSongsLoader.getPlaylistSongList(activity, home.arrayList[0] as Playlist) val songs = PlaylistSongsLoader.getPlaylistSongList(activity, home.arrayList[0] as Playlist)

View file

@ -8,6 +8,7 @@ import androidx.core.util.Pair
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
import code.name.monkey.retromusic.glide.GlideApp import code.name.monkey.retromusic.glide.GlideApp
import code.name.monkey.retromusic.glide.RetroGlideExtension import code.name.monkey.retromusic.glide.RetroGlideExtension
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
@ -15,13 +16,15 @@ import code.name.monkey.retromusic.helper.menu.SongMenuHelper
import code.name.monkey.retromusic.model.Album import code.name.monkey.retromusic.model.Album
import code.name.monkey.retromusic.model.Artist import code.name.monkey.retromusic.model.Artist
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.NavigationUtil import code.name.monkey.retromusic.util.NavigationUtil
import java.util.* import java.util.*
class SearchAdapter(private val activity: AppCompatActivity, private var dataSet: List<Any>?) : RecyclerView.Adapter<SearchAdapter.ViewHolder>() { class SearchAdapter(
private val activity: AppCompatActivity,
private var dataSet: List<Any>?
) : RecyclerView.Adapter<SearchAdapter.ViewHolder>() {
fun swapDataSet(dataSet: MutableList<Any>) { fun swapDataSet(dataSet: MutableList<Any>) {
this.dataSet = dataSet this.dataSet = dataSet

View file

@ -31,7 +31,8 @@ class SongFileAdapter(
private var dataSet: List<File>?, private var dataSet: List<File>?,
private val itemLayoutRes: Int, private val itemLayoutRes: Int,
private val callbacks: Callbacks?, private val callbacks: Callbacks?,
cabHolder: CabHolder?) : AbsMultiSelectAdapter<SongFileAdapter.ViewHolder, File>(activity, cabHolder, R.menu.menu_media_selection), FastScrollRecyclerView.SectionedAdapter { cabHolder: CabHolder?
) : AbsMultiSelectAdapter<SongFileAdapter.ViewHolder, File>(activity, cabHolder, R.menu.menu_media_selection), FastScrollRecyclerView.SectionedAdapter {
init { init {
this.setHasStableIds(true) this.setHasStableIds(true)

View file

@ -166,7 +166,7 @@ open class AlbumAdapter(protected val activity: AppCompatActivity,
override fun getSectionName(position: Int): String { override fun getSectionName(position: Int): String {
var sectionName: String? = null var sectionName: String? = null
when (PreferenceUtil.getInstance().albumSortOrder) { when (PreferenceUtil.getInstance(activity).albumSortOrder) {
SortOrder.AlbumSortOrder.ALBUM_A_Z, SortOrder.AlbumSortOrder.ALBUM_Z_A -> sectionName = dataSet[position].title SortOrder.AlbumSortOrder.ALBUM_A_Z, SortOrder.AlbumSortOrder.ALBUM_Z_A -> sectionName = dataSet[position].title
SortOrder.AlbumSortOrder.ALBUM_ARTIST -> sectionName = dataSet[position].artistName SortOrder.AlbumSortOrder.ALBUM_ARTIST -> sectionName = dataSet[position].artistName
SortOrder.AlbumSortOrder.ALBUM_YEAR -> return MusicUtil.getYearString(dataSet[position].year) SortOrder.AlbumSortOrder.ALBUM_YEAR -> return MusicUtil.getYearString(dataSet[position].year)

View file

@ -71,7 +71,7 @@ class AlbumCoverPagerAdapter(fm: FragmentManager, private val dataSet: ArrayList
private val layout: Int private val layout: Int
get() { get() {
return when (PreferenceUtil.getInstance().albumCoverStyle) { return when (PreferenceUtil.getInstance(activity).albumCoverStyle) {
AlbumCoverStyle.NORMAL -> R.layout.fragment_album_cover AlbumCoverStyle.NORMAL -> R.layout.fragment_album_cover
AlbumCoverStyle.FLAT -> R.layout.fragment_album_flat_cover AlbumCoverStyle.FLAT -> R.layout.fragment_album_flat_cover
AlbumCoverStyle.CIRCLE -> R.layout.fragment_album_circle_cover AlbumCoverStyle.CIRCLE -> R.layout.fragment_album_circle_cover
@ -92,8 +92,8 @@ class AlbumCoverPagerAdapter(fm: FragmentManager, private val dataSet: ArrayList
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val finalLayout = when { val finalLayout = when {
PreferenceUtil.getInstance().nowPlayingScreen == NowPlayingScreen.CLASSIC -> R.layout.fragment_album_full_cover PreferenceUtil.getInstance(activity).nowPlayingScreen == NowPlayingScreen.CLASSIC -> R.layout.fragment_album_full_cover
PreferenceUtil.getInstance().carouselEffect() -> R.layout.fragment_album_carousel_cover PreferenceUtil.getInstance(activity).carouselEffect() -> R.layout.fragment_album_carousel_cover
else -> layout else -> layout
} }
val view = inflater.inflate(finalLayout, container, false) val view = inflater.inflate(finalLayout, container, false)

View file

@ -150,7 +150,7 @@ open class SongAdapter @JvmOverloads constructor(protected val activity: AppComp
if (!showSectionName) { if (!showSectionName) {
return "" return ""
} }
val sectionName: String? = when (PreferenceUtil.getInstance().songSortOrder) { val sectionName: String? = when (PreferenceUtil.getInstance(activity).songSortOrder) {
SortOrder.SongSortOrder.SONG_A_Z, SortOrder.SongSortOrder.SONG_Z_A -> dataSet[position].title SortOrder.SongSortOrder.SONG_A_Z, SortOrder.SongSortOrder.SONG_Z_A -> dataSet[position].title
SortOrder.SongSortOrder.SONG_ALBUM -> dataSet[position].albumName SortOrder.SongSortOrder.SONG_ALBUM -> dataSet[position].albumName
SortOrder.SongSortOrder.SONG_ARTIST -> dataSet[position].artistName SortOrder.SongSortOrder.SONG_ARTIST -> dataSet[position].artistName

View file

@ -32,7 +32,7 @@ import code.name.monkey.retromusic.util.RetroUtil
@RequiresApi(Build.VERSION_CODES.N_MR1) @RequiresApi(Build.VERSION_CODES.N_MR1)
object AppShortcutIconGenerator { object AppShortcutIconGenerator {
fun generateThemedIcon(context: Context, iconId: Int): Icon { fun generateThemedIcon(context: Context, iconId: Int): Icon {
return if (PreferenceUtil.getInstance().coloredAppShortcuts()) { return if (PreferenceUtil.getInstance(context).coloredAppShortcuts()) {
generateUserThemedIcon(context, iconId) generateUserThemedIcon(context, iconId)
} else { } else {
generateDefaultThemedIcon(context, iconId) generateDefaultThemedIcon(context, iconId)

View file

@ -22,7 +22,7 @@ import android.text.TextUtils
import android.view.View import android.view.View
import android.widget.RemoteViews import android.widget.RemoteViews
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import code.name.monkey.retromusic.App.Companion.context import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.MainActivity import code.name.monkey.retromusic.activities.MainActivity
import code.name.monkey.retromusic.appwidgets.base.BaseAppWidget import code.name.monkey.retromusic.appwidgets.base.BaseAppWidget
@ -95,9 +95,9 @@ class AppWidgetText : BaseAppWidget() {
R.drawable.ic_pause_white_24dp R.drawable.ic_pause_white_24dp
else else
R.drawable.ic_play_arrow_white_32dp R.drawable.ic_play_arrow_white_32dp
appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, createBitmap(RetroUtil.getTintedVectorDrawable(context, playPauseRes, ContextCompat.getColor(context, R.color.md_white_1000))!!, 1f)) appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, createBitmap(RetroUtil.getTintedVectorDrawable(App.getContext(), playPauseRes, ContextCompat.getColor(App.getContext(), R.color.md_white_1000))!!, 1f))
appWidgetView.setImageViewBitmap(R.id.button_next, createBitmap(RetroUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_next_white_24dp, ContextCompat.getColor(context, R.color.md_white_1000))!!, 1f)) appWidgetView.setImageViewBitmap(R.id.button_next, createBitmap(RetroUtil.getTintedVectorDrawable(App.getContext(), R.drawable.ic_skip_next_white_24dp, ContextCompat.getColor(App.getContext(), R.color.md_white_1000))!!, 1f))
appWidgetView.setImageViewBitmap(R.id.button_prev, createBitmap(RetroUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_previous_white_24dp, ContextCompat.getColor(context, R.color.md_white_1000))!!, 1f)) appWidgetView.setImageViewBitmap(R.id.button_prev, createBitmap(RetroUtil.getTintedVectorDrawable(App.getContext(), R.drawable.ic_skip_previous_white_24dp, ContextCompat.getColor(App.getContext(), R.color.md_white_1000))!!, 1f))

View file

@ -97,7 +97,7 @@ abstract class BaseAppWidget : AppWidgetProvider() {
protected fun getAlbumArtDrawable(resources: Resources, bitmap: Bitmap?): Drawable { protected fun getAlbumArtDrawable(resources: Resources, bitmap: Bitmap?): Drawable {
return if (bitmap == null) { return if (bitmap == null) {
ContextCompat.getDrawable(App.context, R.drawable.default_album_art)!! ContextCompat.getDrawable(App.getContext(), R.drawable.default_album_art)!!
} else { } else {
BitmapDrawable(resources, bitmap) BitmapDrawable(resources, bitmap)
} }

View file

@ -34,7 +34,7 @@ class OptionsSheetDialogFragment : DialogFragment(), View.OnClickListener {
val mainActivity = activity as MainActivity? ?: return val mainActivity = activity as MainActivity? ?: return
when (view.id) { when (view.id) {
R.id.actionFolders -> mainActivity.selectedFragment(R.id.action_folder) R.id.actionFolders -> mainActivity.selectedFragment(R.id.action_folder)
R.id.actionLibrary -> mainActivity.selectedFragment(PreferenceUtil.getInstance().lastPage) R.id.actionLibrary -> mainActivity.selectedFragment(PreferenceUtil.getInstance(requireContext()).lastPage)
R.id.actionSettings -> NavigationUtil.goToSettings(mainActivity) R.id.actionSettings -> NavigationUtil.goToSettings(mainActivity)
R.id.actionRate -> NavigationUtil.goToPlayStore(mainActivity) R.id.actionRate -> NavigationUtil.goToPlayStore(mainActivity)
} }

View file

@ -60,14 +60,14 @@ class SleepTimerDialog : DialogFragment() {
materialDialog = MaterialDialog(activity!!, BottomSheet()) materialDialog = MaterialDialog(activity!!, BottomSheet())
.title(R.string.action_sleep_timer) .title(R.string.action_sleep_timer)
.positiveButton(R.string.action_set) { .positiveButton(R.string.action_set) {
PreferenceUtil.getInstance().sleepTimerFinishMusic = shouldFinishLastSong.isChecked PreferenceUtil.getInstance(requireContext()).sleepTimerFinishMusic = shouldFinishLastSong.isChecked
val minutes = seekArcProgress val minutes = seekArcProgress
val pi = makeTimerPendingIntent(PendingIntent.FLAG_CANCEL_CURRENT) val pi = makeTimerPendingIntent(PendingIntent.FLAG_CANCEL_CURRENT)
val nextSleepTimerElapsedTime = SystemClock.elapsedRealtime() + minutes * 60 * 1000 val nextSleepTimerElapsedTime = SystemClock.elapsedRealtime() + minutes * 60 * 1000
PreferenceUtil.getInstance().setNextSleepTimerElapsedRealtime(nextSleepTimerElapsedTime) PreferenceUtil.getInstance(requireContext()).setNextSleepTimerElapsedRealtime(nextSleepTimerElapsedTime)
val am = activity!!.getSystemService(Context.ALARM_SERVICE) as AlarmManager val am = activity!!.getSystemService(Context.ALARM_SERVICE) as AlarmManager
am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextSleepTimerElapsedTime, pi) am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextSleepTimerElapsedTime, pi)
@ -109,11 +109,11 @@ class SleepTimerDialog : DialogFragment() {
timerDisplay = materialDialog.getCustomView().findViewById(R.id.timerDisplay) timerDisplay = materialDialog.getCustomView().findViewById(R.id.timerDisplay)
val finishMusic = PreferenceUtil.getInstance().sleepTimerFinishMusic val finishMusic = PreferenceUtil.getInstance(requireContext()).sleepTimerFinishMusic
shouldFinishLastSong.isChecked = finishMusic shouldFinishLastSong.isChecked = finishMusic
seekArcProgress = PreferenceUtil.getInstance().lastSleepTimerValue seekArcProgress = PreferenceUtil.getInstance(requireContext()).lastSleepTimerValue
updateTimeDisplayTime() updateTimeDisplayTime()
seekBar.progress = seekArcProgress seekBar.progress = seekArcProgress
@ -134,7 +134,7 @@ class SleepTimerDialog : DialogFragment() {
} }
override fun onStopTrackingTouch(seekBar: SeekBar) { override fun onStopTrackingTouch(seekBar: SeekBar) {
PreferenceUtil.getInstance().lastSleepTimerValue = seekArcProgress PreferenceUtil.getInstance(requireContext()).lastSleepTimerValue = seekArcProgress
} }
}) })
@ -167,7 +167,7 @@ class SleepTimerDialog : DialogFragment() {
} }
} }
private inner class TimerUpdater internal constructor() : CountDownTimer(PreferenceUtil.getInstance().nextSleepTimerElapsedRealTime - SystemClock.elapsedRealtime(), 1000) { private inner class TimerUpdater internal constructor() : CountDownTimer(PreferenceUtil.getInstance(requireContext()).nextSleepTimerElapsedRealTime - SystemClock.elapsedRealtime(), 1000) {
override fun onTick(millisUntilFinished: Long) { override fun onTick(millisUntilFinished: Long) {
materialDialog.getActionButton(WhichButton.NEGATIVE).text = materialDialog.getActionButton(WhichButton.NEGATIVE).text =

View file

@ -61,9 +61,9 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
actionPrevious.visibility = View.VISIBLE actionPrevious.visibility = View.VISIBLE
actionPlayingQueue.visibility = View.VISIBLE actionPlayingQueue.visibility = View.VISIBLE
} else { } else {
actionNext.visibility = if (PreferenceUtil.getInstance().isExtraMiniExtraControls) View.VISIBLE else View.GONE actionNext.visibility = if (PreferenceUtil.getInstance(requireContext()).isExtraMiniExtraControls) View.VISIBLE else View.GONE
actionPlayingQueue.visibility = if (PreferenceUtil.getInstance().isExtraMiniExtraControls) View.GONE else View.VISIBLE actionPlayingQueue.visibility = if (PreferenceUtil.getInstance(requireContext()).isExtraMiniExtraControls) View.GONE else View.VISIBLE
actionPrevious.visibility = if (PreferenceUtil.getInstance().isExtraMiniExtraControls) View.VISIBLE else View.GONE actionPrevious.visibility = if (PreferenceUtil.getInstance(requireContext()).isExtraMiniExtraControls) View.VISIBLE else View.GONE
} }
actionPlayingQueue.setOnClickListener(this) actionPlayingQueue.setOnClickListener(this)

View file

@ -118,7 +118,7 @@ class VolumeFragment : Fragment(), SeekBar.OnSeekBarChangeListener, OnAudioVolum
} }
private fun setPauseWhenZeroVolume(pauseWhenZeroVolume: Boolean) { private fun setPauseWhenZeroVolume(pauseWhenZeroVolume: Boolean) {
if (PreferenceUtil.getInstance().pauseOnZeroVolume()) if (PreferenceUtil.getInstance(requireContext()).pauseOnZeroVolume())
if (MusicPlayerRemote.isPlaying && pauseWhenZeroVolume) { if (MusicPlayerRemote.isPlaying && pauseWhenZeroVolume) {
MusicPlayerRemote.pauseSong() MusicPlayerRemote.pauseSong()
} }

View file

@ -61,7 +61,7 @@ abstract class AbsPlayerControlsFragment : AbsMusicServiceFragment(), MusicProgr
protected var volumeFragment: VolumeFragment? = null protected var volumeFragment: VolumeFragment? = null
private fun hideVolumeIfAvailable() { private fun hideVolumeIfAvailable() {
if (PreferenceUtil.getInstance().volumeToggle) { if (PreferenceUtil.getInstance(requireContext()).volumeToggle) {
requireFragmentManager().beginTransaction().replace(R.id.volumeFragmentContainer, VolumeFragment()).commit() requireFragmentManager().beginTransaction().replace(R.id.volumeFragmentContainer, VolumeFragment()).commit()
requireFragmentManager().executePendingTransactions() requireFragmentManager().executePendingTransactions()
volumeFragment = requireFragmentManager().findFragmentById(R.id.volumeFragmentContainer) as VolumeFragment? volumeFragment = requireFragmentManager().findFragmentById(R.id.volumeFragmentContainer) as VolumeFragment?

View file

@ -248,7 +248,7 @@ abstract class AbsPlayerFragment : AbsMusicServiceFragment(),
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
view.setBackgroundColor(ThemeStore.primaryColor(requireActivity())) view.setBackgroundColor(ThemeStore.primaryColor(requireActivity()))
if (PreferenceUtil.getInstance().fullScreenMode && if (PreferenceUtil.getInstance(requireContext()).fullScreenMode &&
view.findViewById<View>(R.id.status_bar) != null) { view.findViewById<View>(R.id.status_bar) != null) {
view.findViewById<View>(R.id.status_bar).visibility = View.GONE view.findViewById<View>(R.id.status_bar).visibility = View.GONE
} }

View file

@ -31,14 +31,14 @@ open class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Al
var itemLayoutRes = itemLayoutRes var itemLayoutRes = itemLayoutRes
notifyLayoutResChanged(itemLayoutRes) notifyLayoutResChanged(itemLayoutRes)
if (itemLayoutRes != R.layout.item_list) { if (itemLayoutRes != R.layout.item_list) {
itemLayoutRes = PreferenceUtil.getInstance().getAlbumGridStyle(requireContext()) itemLayoutRes = PreferenceUtil.getInstance(requireContext()).getAlbumGridStyle(requireContext())
} }
val dataSet = if (adapter == null) ArrayList() else adapter!!.dataSet val dataSet = if (adapter == null) ArrayList() else adapter!!.dataSet
return AlbumAdapter(libraryFragment.mainActivity, dataSet, itemLayoutRes, loadUsePalette(), libraryFragment) return AlbumAdapter(libraryFragment.mainActivity, dataSet, itemLayoutRes, loadUsePalette(), libraryFragment)
} }
public override fun loadUsePalette(): Boolean { public override fun loadUsePalette(): Boolean {
return PreferenceUtil.getInstance().albumColoredFooters() return PreferenceUtil.getInstance(requireContext()).albumColoredFooters()
} }
override fun setUsePalette(usePalette: Boolean) { override fun setUsePalette(usePalette: Boolean) {
@ -53,43 +53,43 @@ open class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Al
override fun loadSortOrder(): String { override fun loadSortOrder(): String {
return PreferenceUtil.getInstance().albumSortOrder return PreferenceUtil.getInstance(requireContext()).albumSortOrder
} }
override fun saveSortOrder(sortOrder: String) { override fun saveSortOrder(sortOrder: String) {
PreferenceUtil.getInstance().albumSortOrder = sortOrder PreferenceUtil.getInstance(requireContext()).albumSortOrder = sortOrder
} }
override fun loadGridSize(): Int { override fun loadGridSize(): Int {
return PreferenceUtil.getInstance().getAlbumGridSize(activity!!) return PreferenceUtil.getInstance(requireContext()).getAlbumGridSize(activity!!)
} }
override fun saveGridSize(gridColumns: Int) { override fun saveGridSize(gridColumns: Int) {
PreferenceUtil.getInstance().setAlbumGridSize(gridColumns) PreferenceUtil.getInstance(requireContext()).setAlbumGridSize(gridColumns)
} }
override fun loadGridSizeLand(): Int { override fun loadGridSizeLand(): Int {
return PreferenceUtil.getInstance().getAlbumGridSizeLand(activity!!) return PreferenceUtil.getInstance(requireContext()).getAlbumGridSizeLand(activity!!)
} }
override fun saveGridSizeLand(gridColumns: Int) { override fun saveGridSizeLand(gridColumns: Int) {
PreferenceUtil.getInstance().setAlbumGridSizeLand(gridColumns) PreferenceUtil.getInstance(requireContext()).setAlbumGridSizeLand(gridColumns)
} }
override fun saveUsePalette(usePalette: Boolean) { override fun saveUsePalette(usePalette: Boolean) {
PreferenceUtil.getInstance().setAlbumColoredFooters(usePalette) PreferenceUtil.getInstance(requireContext()).setAlbumColoredFooters(usePalette)
} }
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
App.musicComponent.inject(this) App.musicComponent?.inject(this)
albumsPresenter.attachView(this) albumsPresenter.attachView(this)
} }

View file

@ -25,7 +25,7 @@ class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Artist
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
App.musicComponent.inject(this) App.musicComponent?.inject(this)
artistsPresenter.attachView(this) artistsPresenter.attachView(this)
} }
@ -52,7 +52,7 @@ class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Artist
var itemLayoutRes = itemLayoutRes var itemLayoutRes = itemLayoutRes
notifyLayoutResChanged(itemLayoutRes) notifyLayoutResChanged(itemLayoutRes)
if (itemLayoutRes != R.layout.item_list) { if (itemLayoutRes != R.layout.item_list) {
itemLayoutRes = PreferenceUtil.getInstance().getArtistGridStyle(requireContext()) itemLayoutRes = PreferenceUtil.getInstance(requireContext()).getArtistGridStyle(requireContext())
} }
val dataSet = if (adapter == null) ArrayList() else adapter!!.dataSet val dataSet = if (adapter == null) ArrayList() else adapter!!.dataSet
return ArtistAdapter(libraryFragment.mainActivity, dataSet, itemLayoutRes, loadUsePalette(), libraryFragment) return ArtistAdapter(libraryFragment.mainActivity, dataSet, itemLayoutRes, loadUsePalette(), libraryFragment)
@ -60,27 +60,27 @@ class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Artist
override fun loadGridSize(): Int { override fun loadGridSize(): Int {
return PreferenceUtil.getInstance().getArtistGridSize(activity!!) return PreferenceUtil.getInstance(requireContext()).getArtistGridSize(activity!!)
} }
override fun saveGridSize(gridColumns: Int) { override fun saveGridSize(gridColumns: Int) {
PreferenceUtil.getInstance().setArtistGridSize(gridColumns) PreferenceUtil.getInstance(requireContext()).setArtistGridSize(gridColumns)
} }
override fun loadGridSizeLand(): Int { override fun loadGridSizeLand(): Int {
return PreferenceUtil.getInstance().getArtistGridSizeLand(activity!!) return PreferenceUtil.getInstance(requireContext()).getArtistGridSizeLand(activity!!)
} }
override fun saveGridSizeLand(gridColumns: Int) { override fun saveGridSizeLand(gridColumns: Int) {
PreferenceUtil.getInstance().setArtistGridSizeLand(gridColumns) PreferenceUtil.getInstance(requireContext()).setArtistGridSizeLand(gridColumns)
} }
override fun saveUsePalette(usePalette: Boolean) { override fun saveUsePalette(usePalette: Boolean) {
PreferenceUtil.getInstance().setArtistColoredFooters(usePalette) PreferenceUtil.getInstance(requireContext()).setArtistColoredFooters(usePalette)
} }
public override fun loadUsePalette(): Boolean { public override fun loadUsePalette(): Boolean {
return PreferenceUtil.getInstance().artistColoredFooters() return PreferenceUtil.getInstance(requireContext()).artistColoredFooters()
} }
override fun setUsePalette(usePalette: Boolean) { override fun setUsePalette(usePalette: Boolean) {
@ -94,11 +94,11 @@ class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Artist
override fun loadSortOrder(): String { override fun loadSortOrder(): String {
return PreferenceUtil.getInstance().artistSortOrder return PreferenceUtil.getInstance(requireContext()).artistSortOrder
} }
override fun saveSortOrder(sortOrder: String) { override fun saveSortOrder(sortOrder: String) {
PreferenceUtil.getInstance().artistSortOrder = sortOrder PreferenceUtil.getInstance(requireContext()).artistSortOrder = sortOrder
} }
override fun onDestroyView() { override fun onDestroyView() {

View file

@ -54,7 +54,7 @@ class GenresFragment : AbsLibraryPagerRecyclerViewFragment<GenreAdapter, LinearL
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
App.musicComponent.inject(this) App.musicComponent?.inject(this)
genresPresenter.attachView(this) genresPresenter.attachView(this)
} }

View file

@ -80,7 +80,7 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
public void onDestroyView() { public void onDestroyView() {
super.onDestroyView(); super.onDestroyView();
disposable.dispose(); disposable.dispose();
PreferenceUtil.getInstance().unregisterOnSharedPreferenceChangedListener(this); PreferenceUtil.getInstance(requireActivity()).unregisterOnSharedPreferenceChangedListener(this);
} }
@Nullable @Nullable
@ -93,7 +93,7 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
toolbarContainer = view.findViewById(R.id.toolbarContainer); toolbarContainer = view.findViewById(R.id.toolbarContainer);
appBarLayout = view.findViewById(R.id.appBarLayout); appBarLayout = view.findViewById(R.id.appBarLayout);
toolbar = view.findViewById(R.id.toolbar); toolbar = view.findViewById(R.id.toolbar);
PreferenceUtil.getInstance().registerOnSharedPreferenceChangedListener(this); PreferenceUtil.getInstance(requireActivity()).registerOnSharedPreferenceChangedListener(this);
return view; return view;
} }

View file

@ -24,7 +24,7 @@ class PlaylistsFragment : AbsLibraryPagerRecyclerViewFragment<PlaylistAdapter, L
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
App.musicComponent.inject(this) App.musicComponent?.inject(this)
playlistsPresenter.attachView(this) playlistsPresenter.attachView(this)
} }
@ -58,8 +58,8 @@ class PlaylistsFragment : AbsLibraryPagerRecyclerViewFragment<PlaylistAdapter, L
adapter!!.swapDataSet(ArrayList()) adapter!!.swapDataSet(ArrayList())
} }
override fun playlists(list: ArrayList<Playlist>) { override fun playlists(playlists: ArrayList<Playlist>) {
adapter!!.swapDataSet(list) adapter!!.swapDataSet(playlists)
} }
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {

View file

@ -25,7 +25,7 @@ class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdap
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
App.musicComponent.inject(this) App.musicComponent?.inject(this)
songPresenter.attachView(this) songPresenter.attachView(this)
} }
@ -55,27 +55,27 @@ class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdap
} }
override fun loadGridSize(): Int { override fun loadGridSize(): Int {
return PreferenceUtil.getInstance().getSongGridSize(activity!!) return PreferenceUtil.getInstance(requireContext()).getSongGridSize(activity!!)
} }
override fun saveGridSize(gridColumns: Int) { override fun saveGridSize(gridColumns: Int) {
PreferenceUtil.getInstance().setSongGridSize(gridColumns) PreferenceUtil.getInstance(requireContext()).setSongGridSize(gridColumns)
} }
override fun loadGridSizeLand(): Int { override fun loadGridSizeLand(): Int {
return PreferenceUtil.getInstance().getSongGridSizeLand(activity!!) return PreferenceUtil.getInstance(requireContext()).getSongGridSizeLand(activity!!)
} }
override fun saveGridSizeLand(gridColumns: Int) { override fun saveGridSizeLand(gridColumns: Int) {
PreferenceUtil.getInstance().setSongGridSizeLand(gridColumns) PreferenceUtil.getInstance(requireContext()).setSongGridSizeLand(gridColumns)
} }
public override fun saveUsePalette(usePalette: Boolean) { public override fun saveUsePalette(usePalette: Boolean) {
PreferenceUtil.getInstance().setSongColoredFooters(usePalette) PreferenceUtil.getInstance(requireContext()).setSongColoredFooters(usePalette)
} }
public override fun loadUsePalette(): Boolean { public override fun loadUsePalette(): Boolean {
return PreferenceUtil.getInstance().songColoredFooters() return PreferenceUtil.getInstance(requireContext()).songColoredFooters()
} }
public override fun setUsePalette(usePalette: Boolean) { public override fun setUsePalette(usePalette: Boolean) {
@ -104,11 +104,11 @@ class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdap
} }
override fun loadSortOrder(): String { override fun loadSortOrder(): String {
return PreferenceUtil.getInstance().songSortOrder return PreferenceUtil.getInstance(requireContext()).songSortOrder
} }
override fun saveSortOrder(sortOrder: String) { override fun saveSortOrder(sortOrder: String) {
PreferenceUtil.getInstance().songSortOrder = sortOrder PreferenceUtil.getInstance(requireContext()).songSortOrder = sortOrder
} }
override fun setSortOrder(sortOrder: String) { override fun setSortOrder(sortOrder: String) {

View file

@ -109,7 +109,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
} }
public static FoldersFragment newInstance(Context context) { public static FoldersFragment newInstance(Context context) {
return newInstance(PreferenceUtil.getInstance().getStartDirectory()); return newInstance(PreferenceUtil.getInstance(context).getStartDirectory());
} }
public static FoldersFragment newInstance(File directory) { public static FoldersFragment newInstance(File directory) {
@ -328,7 +328,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
public boolean onOptionsItemSelected(@NonNull MenuItem item) { public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.action_go_to_start_directory: case R.id.action_go_to_start_directory:
setCrumb(new BreadCrumbLayout.Crumb(tryGetCanonicalFile(PreferenceUtil.getInstance().getStartDirectory())), true); setCrumb(new BreadCrumbLayout.Crumb(tryGetCanonicalFile(PreferenceUtil.getInstance(requireContext()).getStartDirectory())), true);
return true; return true;
case R.id.action_scan: case R.id.action_scan:
BreadCrumbLayout.Crumb crumb = getActiveCrumb(); BreadCrumbLayout.Crumb crumb = getActiveCrumb();
@ -415,7 +415,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
getFileComparator())); getFileComparator()));
return true; return true;
case R.id.action_set_as_start_directory: case R.id.action_set_as_start_directory:
PreferenceUtil.getInstance().setStartDirectory(file); PreferenceUtil.getInstance(requireContext()).setStartDirectory(file);
Toast.makeText(getActivity(), Toast.makeText(getActivity(),
String.format(getString(R.string.new_start_directory), file.getPath()), String.format(getString(R.string.new_start_directory), file.getPath()),
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();

View file

@ -68,7 +68,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
private lateinit var toolbar: Toolbar private lateinit var toolbar: Toolbar
override fun onCreateView(inflater: LayoutInflater, viewGroup: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, viewGroup: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(if (PreferenceUtil.getInstance().isHomeBanner) R.layout.fragment_banner_home else R.layout.fragment_home, viewGroup, false) return inflater.inflate(if (PreferenceUtil.getInstance(requireContext()).isHomeBanner) R.layout.fragment_banner_home else R.layout.fragment_home, viewGroup, false)
} }
private fun loadImageFromStorage() { private fun loadImageFromStorage() {
@ -77,17 +77,17 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
.setMaxWidth(300) .setMaxWidth(300)
.setQuality(75) .setQuality(75)
.setCompressFormat(Bitmap.CompressFormat.WEBP) .setCompressFormat(Bitmap.CompressFormat.WEBP)
.compressToBitmapAsFlowable(File(PreferenceUtil.getInstance().profileImage, Constants.USER_PROFILE)) .compressToBitmapAsFlowable(File(PreferenceUtil.getInstance(requireContext()).profileImage, Constants.USER_PROFILE))
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe({ .subscribe({
if (it != null) { if (it != null) {
userImage.setImageBitmap(it) userImage.setImageBitmap(it)
} else { } else {
userImage.setImageDrawable(ContextCompat.getDrawable(context!!, R.drawable.ic_person_flat)) userImage.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_person_flat))
} }
}) { }) {
userImage.setImageDrawable(ContextCompat.getDrawable(context!!, R.drawable.ic_person_flat)) userImage.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_person_flat))
}) })
} }
@ -101,7 +101,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
App.musicComponent.inject(this) App.musicComponent?.inject(this)
homePresenter.attachView(this) homePresenter.attachView(this)
} }
@ -115,7 +115,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
bannerImage?.setOnClickListener { bannerImage?.setOnClickListener {
NavigationUtil.goToUserInfo(requireActivity()) NavigationUtil.goToUserInfo(requireActivity())
} }
if (!PreferenceUtil.getInstance().isHomeBanner) if (!PreferenceUtil.getInstance(requireContext()).isHomeBanner)
setStatusbarColorAuto(view) setStatusbarColorAuto(view)
lastAdded.setOnClickListener { lastAdded.setOnClickListener {
@ -145,7 +145,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
NavigationUtil.goToUserInfo(requireActivity()) NavigationUtil.goToUserInfo(requireActivity())
} }
titleWelcome.setTextColor(ThemeStore.textColorPrimary(requireContext())) titleWelcome.setTextColor(ThemeStore.textColorPrimary(requireContext()))
titleWelcome.text = String.format("%s", PreferenceUtil.getInstance().userName) titleWelcome.text = String.format("%s", PreferenceUtil.getInstance(requireContext()).userName)
homePresenter.loadSections() homePresenter.loadSections()
} }
@ -160,7 +160,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
} }
private fun toolbarColor(): Int { private fun toolbarColor(): Int {
return if (PreferenceUtil.getInstance().isHomeBanner) { return if (PreferenceUtil.getInstance(requireContext()).isHomeBanner) {
toolbarContainer.setBackgroundColor(Color.TRANSPARENT) toolbarContainer.setBackgroundColor(Color.TRANSPARENT)
ColorUtil.withAlpha(RetroColorUtil.toolbarColor(mainActivity), 0.85f) ColorUtil.withAlpha(RetroColorUtil.toolbarColor(mainActivity), 0.85f)
} else { } else {
@ -253,7 +253,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
private fun loadTimeImage(day: String) { private fun loadTimeImage(day: String) {
if (bannerImage != null) { if (bannerImage != null) {
if (PreferenceUtil.getInstance().bannerImage.isEmpty()) { if (PreferenceUtil.getInstance(requireContext()).bannerImage.isEmpty()) {
GlideApp.with(requireActivity()) GlideApp.with(requireActivity())
.load(day) .load(day)
.placeholder(R.drawable.material_design_default) .placeholder(R.drawable.material_design_default)
@ -263,7 +263,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
disposable.add(Compressor(requireActivity()) disposable.add(Compressor(requireActivity())
.setQuality(100) .setQuality(100)
.setCompressFormat(Bitmap.CompressFormat.WEBP) .setCompressFormat(Bitmap.CompressFormat.WEBP)
.compressToBitmapAsFlowable(File(PreferenceUtil.getInstance().bannerImage, USER_BANNER)) .compressToBitmapAsFlowable(File(PreferenceUtil.getInstance(requireContext()).bannerImage, USER_BANNER))
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe { bitmap -> bannerImage.setImageBitmap(bitmap) }) .subscribe { bitmap -> bannerImage.setImageBitmap(bitmap) })

View file

@ -48,17 +48,17 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChan
viewPager.addOnPageChangeListener(this) viewPager.addOnPageChangeListener(this)
//noinspection ConstantConditions //noinspection ConstantConditions
if (PreferenceUtil.getInstance().carouselEffect() && if (PreferenceUtil.getInstance(requireContext()).carouselEffect() &&
!((PreferenceUtil.getInstance().nowPlayingScreen == NowPlayingScreen.FULL) || !((PreferenceUtil.getInstance(requireContext()).nowPlayingScreen == NowPlayingScreen.FULL) ||
(PreferenceUtil.getInstance().nowPlayingScreen == NowPlayingScreen.ADAPTIVE) (PreferenceUtil.getInstance(requireContext()).nowPlayingScreen == NowPlayingScreen.ADAPTIVE)
|| (PreferenceUtil.getInstance().nowPlayingScreen == NowPlayingScreen.FIT))) { || (PreferenceUtil.getInstance(requireContext()).nowPlayingScreen == NowPlayingScreen.FIT))) {
viewPager.clipToPadding = false viewPager.clipToPadding = false
viewPager.setPadding(40, 40, 40, 0) viewPager.setPadding(40, 40, 40, 0)
viewPager.pageMargin = 0 viewPager.pageMargin = 0
viewPager.setPageTransformer(false, CarousalPagerTransformer(requireContext())) viewPager.setPageTransformer(false, CarousalPagerTransformer(requireContext()))
} else { } else {
viewPager.offscreenPageLimit = 2 viewPager.offscreenPageLimit = 2
viewPager.setPageTransformer(true, PreferenceUtil.getInstance().albumCoverTransform) viewPager.setPageTransformer(true, PreferenceUtil.getInstance(requireContext()).albumCoverTransform)
} }

View file

@ -98,7 +98,7 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
updatePrevNextColor() updatePrevNextColor()
updatePlayPauseColor() updatePlayPauseColor()
val colorFinal = if (PreferenceUtil.getInstance().adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color color
} else { } else {
ThemeStore.accentColor(context!!) ThemeStore.accentColor(context!!)

View file

@ -125,7 +125,7 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
updateProgressTextColor() updateProgressTextColor()
val colorFinal = if (PreferenceUtil.getInstance().adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color color
} else { } else {
ThemeStore.accentColor(context!!).ripAlpha() ThemeStore.accentColor(context!!).ripAlpha()

View file

@ -110,7 +110,7 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(activity, false) lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(activity, false)
} }
val colorFinal = if (PreferenceUtil.getInstance().adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color color
} else { } else {
ThemeStore.accentColor(context!!).ripAlpha() ThemeStore.accentColor(context!!).ripAlpha()

View file

@ -100,7 +100,7 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(activity, false) lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(activity, false)
} }
val colorFinal = if (PreferenceUtil.getInstance().adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color color
} else { } else {
ThemeStore.accentColor(context!!).ripAlpha() ThemeStore.accentColor(context!!).ripAlpha()

View file

@ -89,7 +89,7 @@ class FlatPlayerFragment : AbsPlayerFragment() {
override fun toolbarIconColor(): Int { override fun toolbarIconColor(): Int {
val isLight = ColorUtil.isColorLight(paletteColor) val isLight = ColorUtil.isColorLight(paletteColor)
return if (PreferenceUtil.getInstance().adaptiveColor) return if (PreferenceUtil.getInstance(requireContext()).adaptiveColor)
MaterialValueHelper.getPrimaryTextColor(context, isLight) MaterialValueHelper.getPrimaryTextColor(context, isLight)
else else
ATHUtil.resolveColor(context, R.attr.iconColor) ATHUtil.resolveColor(context, R.attr.iconColor)
@ -103,12 +103,12 @@ class FlatPlayerFragment : AbsPlayerFragment() {
val isLight = ColorUtil.isColorLight(color) val isLight = ColorUtil.isColorLight(color)
//TransitionManager.beginDelayedTransition(mToolbar); //TransitionManager.beginDelayedTransition(mToolbar);
val iconColor = if (PreferenceUtil.getInstance().adaptiveColor) val iconColor = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor)
MaterialValueHelper.getPrimaryTextColor(context!!, isLight) MaterialValueHelper.getPrimaryTextColor(context!!, isLight)
else else
ATHUtil.resolveColor(context!!, R.attr.iconColor) ATHUtil.resolveColor(context!!, R.attr.iconColor)
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, iconColor, activity) ToolbarContentTintHelper.colorizeToolbar(playerToolbar, iconColor, activity)
if (PreferenceUtil.getInstance().adaptiveColor) { if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
colorize(color) colorize(color)
} }
} }

View file

@ -109,7 +109,7 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(), PopupMenu.OnMe
lastPlaybackControlsColor = Color.WHITE lastPlaybackControlsColor = Color.WHITE
lastDisabledPlaybackControlsColor = ContextCompat.getColor(context!!, R.color.md_grey_500) lastDisabledPlaybackControlsColor = ContextCompat.getColor(context!!, R.color.md_grey_500)
val colorFinal = if (PreferenceUtil.getInstance().adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color color
} else { } else {
ThemeStore.accentColor(context!!).ripAlpha() ThemeStore.accentColor(context!!).ripAlpha()

View file

@ -120,7 +120,7 @@ class LockScreenPlayerControlsFragment : AbsPlayerControlsFragment() {
lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false) lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
} }
val colorFinal = if (PreferenceUtil.getInstance().adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color color
} else { } else {
ThemeStore.textColorSecondary(requireContext()) ThemeStore.textColorSecondary(requireContext())

View file

@ -112,7 +112,7 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
updateRepeatState() updateRepeatState()
updateShuffleState() updateShuffleState()
val colorFinal = if (PreferenceUtil.getInstance().adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
lastPlaybackControlsColor = color lastPlaybackControlsColor = color
color color
} else { } else {

View file

@ -69,7 +69,7 @@ class PlayerFragment : AbsPlayerFragment() {
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(context, R.attr.iconColor), activity) ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(context, R.attr.iconColor), activity)
if (PreferenceUtil.getInstance().adaptiveColor) { if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
colorize(color) colorize(color)
} }
} }

View file

@ -69,7 +69,7 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false) lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
} }
val colorFinal = if (PreferenceUtil.getInstance().adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color color
} else { } else {
ThemeStore.accentColor(requireContext()) ThemeStore.accentColor(requireContext())

View file

@ -129,7 +129,7 @@ class PlainPlaybackControlsFragment : AbsPlayerControlsFragment() {
lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(context!!, false) lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(context!!, false)
} }
val colorFinal = if (PreferenceUtil.getInstance().adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color color
} else { } else {
ThemeStore.accentColor(context!!) ThemeStore.accentColor(context!!)

View file

@ -187,7 +187,7 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(context!!, false) lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(context!!, false)
} }
val colorFinal = if (PreferenceUtil.getInstance().adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color color
} else { } else {
ThemeStore.accentColor(context!!) ThemeStore.accentColor(context!!)

View file

@ -71,7 +71,7 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
override fun onColorChanged(color: Int) { override fun onColorChanged(color: Int) {
val colorFinal = if (PreferenceUtil.getInstance().adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color color
} else { } else {
ThemeStore.accentColor(requireContext()) ThemeStore.accentColor(requireContext())

View file

@ -29,7 +29,7 @@ import code.name.monkey.retromusic.util.PreferenceUtil
class AudioSettings : AbsSettingsFragment() { class AudioSettings : AbsSettingsFragment() {
override fun invalidateSettings() { override fun invalidateSettings() {
val findPreference: Preference = findPreference("equalizer")!! val findPreference: Preference = findPreference("equalizer")!!
if (!hasEqualizer() && PreferenceUtil.getInstance().selectedEqualizer != "retro") { if (!hasEqualizer() && PreferenceUtil.getInstance(requireContext()).selectedEqualizer != "retro") {
findPreference.isEnabled = false findPreference.isEnabled = false
findPreference.summary = resources.getString(R.string.no_equalizer) findPreference.summary = resources.getString(R.string.no_equalizer)
} else { } else {

View file

@ -66,7 +66,7 @@ class MainSettingsFragment : Fragment(), View.OnClickListener {
aboutSettings.setOnClickListener(this) aboutSettings.setOnClickListener(this)
buyProContainer.apply { buyProContainer.apply {
if (!App.isProVersion) show() else hide() if (!App.isProVersion()) show() else hide()
setOnClickListener { setOnClickListener {
NavigationUtil.goToProVersion(context) NavigationUtil.goToProVersion(context)
} }

View file

@ -34,10 +34,10 @@ class NotificationSettingsFragment : AbsSettingsFragment() {
classicNotification?.isVisible = false classicNotification?.isVisible = false
} else { } else {
classicNotification?.apply { classicNotification?.apply {
isChecked = PreferenceUtil.getInstance().classicNotification() isChecked = PreferenceUtil.getInstance(requireContext()).classicNotification()
setOnPreferenceChangeListener { _, newValue -> setOnPreferenceChangeListener { _, newValue ->
// Save preference // Save preference
PreferenceUtil.getInstance().setClassicNotification(newValue as Boolean) PreferenceUtil.getInstance(requireContext()).setClassicNotification(newValue as Boolean)
invalidateSettings() invalidateSettings()
true true
} }
@ -46,12 +46,12 @@ class NotificationSettingsFragment : AbsSettingsFragment() {
val coloredNotification: TwoStatePreference? = findPreference("colored_notification") val coloredNotification: TwoStatePreference? = findPreference("colored_notification")
if (VERSION.SDK_INT >= VERSION_CODES.O) { if (VERSION.SDK_INT >= VERSION_CODES.O) {
coloredNotification?.isEnabled = PreferenceUtil.getInstance().classicNotification() coloredNotification?.isEnabled = PreferenceUtil.getInstance(requireContext()).classicNotification()
} else { } else {
coloredNotification?.apply { coloredNotification?.apply {
isChecked = PreferenceUtil.getInstance().coloredNotification() isChecked = PreferenceUtil.getInstance(requireContext()).coloredNotification()
setOnPreferenceChangeListener { _, newValue -> setOnPreferenceChangeListener { _, newValue ->
PreferenceUtil.getInstance().setColoredNotification(newValue as Boolean) PreferenceUtil.getInstance(requireContext()).setColoredNotification(newValue as Boolean)
true true
} }
} }

View file

@ -35,7 +35,7 @@ class NowPlayingSettingsFragment : AbsSettingsFragment(), SharedPreferences.OnSh
val carouselEffect: TwoStatePreference = findPreference("carousel_effect")!! val carouselEffect: TwoStatePreference = findPreference("carousel_effect")!!
carouselEffect.setOnPreferenceChangeListener { _, newValue -> carouselEffect.setOnPreferenceChangeListener { _, newValue ->
if (newValue as Boolean && !App.isProVersion) { if (newValue as Boolean && !App.isProVersion()) {
showProToastAndNavigate(activity!!.getString(R.string.pref_title_toggle_carousel_effect)) showProToastAndNavigate(activity!!.getString(R.string.pref_title_toggle_carousel_effect))
return@setOnPreferenceChangeListener false return@setOnPreferenceChangeListener false
} }
@ -49,24 +49,24 @@ class NowPlayingSettingsFragment : AbsSettingsFragment(), SharedPreferences.OnSh
private fun updateAlbumCoverStyleSummary() { private fun updateAlbumCoverStyleSummary() {
val preference: Preference = findPreference(ALBUM_COVER_STYLE)!! val preference: Preference = findPreference(ALBUM_COVER_STYLE)!!
preference.setSummary(getInstance().albumCoverStyle.titleRes) preference.setSummary(getInstance(requireContext()).albumCoverStyle.titleRes)
} }
private fun updateNowPlayingScreenSummary() { private fun updateNowPlayingScreenSummary() {
val preference: Preference = findPreference(NOW_PLAYING_SCREEN_ID)!! val preference: Preference = findPreference(NOW_PLAYING_SCREEN_ID)!!
preference.setSummary(getInstance().nowPlayingScreen.titleRes) preference.setSummary(getInstance(requireContext()).nowPlayingScreen.titleRes)
} }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
getInstance().registerOnSharedPreferenceChangedListener(this) getInstance(requireContext()).registerOnSharedPreferenceChangedListener(this)
val preference: Preference = findPreference("album_cover_transform")!! val preference: Preference = findPreference("album_cover_transform")!!
setSummary(preference) setSummary(preference)
} }
override fun onDestroyView() { override fun onDestroyView() {
super.onDestroyView() super.onDestroyView()
getInstance().unregisterOnSharedPreferenceChangedListener(this) getInstance(requireContext()).unregisterOnSharedPreferenceChangedListener(this)
} }
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {

View file

@ -29,7 +29,7 @@ class PersonaizeSettingsFragment : AbsSettingsFragment(), SharedPreferences.OnSh
override fun invalidateSettings() { override fun invalidateSettings() {
val cornerWindow: TwoStatePreference = findPreference("corner_window")!! val cornerWindow: TwoStatePreference = findPreference("corner_window")!!
cornerWindow.setOnPreferenceChangeListener { _, newValue -> cornerWindow.setOnPreferenceChangeListener { _, newValue ->
if (newValue as Boolean && !App.isProVersion) { if (newValue as Boolean && !App.isProVersion()) {
showProToastAndNavigate(activity!!.getString(R.string.pref_title_round_corners)) showProToastAndNavigate(activity!!.getString(R.string.pref_title_round_corners))
return@setOnPreferenceChangeListener false return@setOnPreferenceChangeListener false
} }
@ -51,7 +51,7 @@ class PersonaizeSettingsFragment : AbsSettingsFragment(), SharedPreferences.OnSh
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
PreferenceUtil.getInstance().registerOnSharedPreferenceChangedListener(this) PreferenceUtil.getInstance(requireContext()).registerOnSharedPreferenceChangedListener(this)
var preference: Preference? = findPreference("album_grid_style") var preference: Preference? = findPreference("album_grid_style")
setSummary(preference!!) setSummary(preference!!)
@ -65,7 +65,7 @@ class PersonaizeSettingsFragment : AbsSettingsFragment(), SharedPreferences.OnSh
override fun onDestroyView() { override fun onDestroyView() {
super.onDestroyView() super.onDestroyView()
PreferenceUtil.getInstance().unregisterOnSharedPreferenceChangedListener(this) PreferenceUtil.getInstance(requireContext()).unregisterOnSharedPreferenceChangedListener(this)
} }
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {

View file

@ -54,14 +54,7 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
setSummary(it) setSummary(it)
it.setOnPreferenceChangeListener { _, newValue -> it.setOnPreferenceChangeListener { _, newValue ->
val theme = newValue as String val theme = newValue as String
println(newValue)
if (theme == "color" && !App.isProVersion) {
showProToastAndNavigate("Color theme")
return@setOnPreferenceChangeListener false
}
setSummary(generalTheme, newValue) setSummary(generalTheme, newValue)
val color = when (theme) { val color = when (theme) {
"light" -> Color.WHITE "light" -> Color.WHITE
"black" -> Color.BLACK "black" -> Color.BLACK
@ -107,10 +100,10 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
if (!VersionUtils.hasNougatMR()) { if (!VersionUtils.hasNougatMR()) {
colorAppShortcuts.isVisible = false colorAppShortcuts.isVisible = false
} else { } else {
colorAppShortcuts.isChecked = PreferenceUtil.getInstance().coloredAppShortcuts() colorAppShortcuts.isChecked = PreferenceUtil.getInstance(requireContext()).coloredAppShortcuts()
colorAppShortcuts.setOnPreferenceChangeListener { _, newValue -> colorAppShortcuts.setOnPreferenceChangeListener { _, newValue ->
// Save preference // Save preference
PreferenceUtil.getInstance().setColoredAppShortcuts(newValue as Boolean) PreferenceUtil.getInstance(requireContext()).setColoredAppShortcuts(newValue as Boolean)
DynamicShortcutManager(requireContext()).updateDynamicShortcuts() DynamicShortcutManager(requireContext()).updateDynamicShortcuts()
true true
} }

View file

@ -103,7 +103,7 @@ public final class RetroGlideExtension {
@NonNull @NonNull
public static Object getSongModel(@NonNull Song song) { public static Object getSongModel(@NonNull Song song) {
return getSongModel(song, PreferenceUtil.getInstance().ignoreMediaStoreArtwork()); return getSongModel(song, PreferenceUtil.getInstance(App.Companion.getContext()).ignoreMediaStoreArtwork());
} }
@NonNull @NonNull

View file

@ -45,7 +45,7 @@ abstract class RetroMusicColoredTarget(view: ImageView) : BitmapPaletteTarget(vi
val defaultColor = defaultFooterColor val defaultColor = defaultFooterColor
onColorReady(if (PreferenceUtil.getInstance().isDominantColor) onColorReady(if (PreferenceUtil.getInstance(getView().context).isDominantColor)
getDominantColor(resource.bitmap, defaultColor) getDominantColor(resource.bitmap, defaultColor)
else else
getColor(resource.palette, defaultColor)) getColor(resource.palette, defaultColor))

View file

@ -45,7 +45,7 @@ class TopExceptionHandler() : Thread.UncaughtExceptionHandler {
} }
} }
report += "-------------------------------\n\n" report += "-------------------------------\n\n"
ActivityCompat.startActivity(App.context, Intent(App.context, ErrorHandlerActivity::class.java) ActivityCompat.startActivity(App.getContext(), Intent(App.getContext(), ErrorHandlerActivity::class.java)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra("error", report), null) .putExtra("error", report), null)
defaultUEH.uncaughtException(t, e) defaultUEH.uncaughtException(t, e)

View file

@ -209,7 +209,7 @@ object MusicPlayerRemote {
fun openQueue(queue: ArrayList<Song>, startPosition: Int, startPlaying: Boolean) { fun openQueue(queue: ArrayList<Song>, startPosition: Int, startPlaying: Boolean) {
if (!tryToHandleOpenPlayingQueue(queue, startPosition, startPlaying) && musicService != null) { if (!tryToHandleOpenPlayingQueue(queue, startPosition, startPlaying) && musicService != null) {
musicService!!.openQueue(queue, startPosition, startPlaying) musicService!!.openQueue(queue, startPosition, startPlaying)
if (PreferenceUtil.getInstance().isShuffleModeOn) if (PreferenceUtil.getInstance(musicService).isShuffleModeOn)
setShuffleMode(MusicService.SHUFFLE_MODE_NONE) setShuffleMode(MusicService.SHUFFLE_MODE_NONE)
} }
} }

View file

@ -87,8 +87,8 @@ object PlaylistMenuHelper {
private class SavePlaylistAsyncTask internal constructor(context: Context) : WeakContextAsyncTask<Playlist, String, String>(context) { private class SavePlaylistAsyncTask internal constructor(context: Context) : WeakContextAsyncTask<Playlist, String, String>(context) {
override fun doInBackground(vararg params: Playlist): String { override fun doInBackground(vararg params: Playlist): String {
return String.format(App.instance.applicationContext.getString(R.string return String.format(App.getContext().getString(R.string
.saved_playlist_to), PlaylistsUtil.savePlaylist(App.instance.applicationContext, params[0])) .saved_playlist_to), PlaylistsUtil.savePlaylist(App.getContext(), params[0]))
} }
override fun onPostExecute(string: String) { override fun onPostExecute(string: String) {

View file

@ -35,7 +35,7 @@ object AlbumLoader {
val songs = SongLoader.getSongsFlowable( val songs = SongLoader.getSongsFlowable(
SongLoader.makeSongCursor( SongLoader.makeSongCursor(
context, null, null, context, null, null,
getSongLoaderSortOrder()) getSongLoaderSortOrder(context))
) )
return splitIntoAlbumsFlowable(songs) return splitIntoAlbumsFlowable(songs)
@ -50,7 +50,7 @@ object AlbumLoader {
context, context,
AudioColumns.ALBUM + " LIKE ?", AudioColumns.ALBUM + " LIKE ?",
arrayOf("%$query%"), arrayOf("%$query%"),
getSongLoaderSortOrder()) getSongLoaderSortOrder(context))
) )
return splitIntoAlbumsFlowable(songs) return splitIntoAlbumsFlowable(songs)
} }
@ -63,7 +63,7 @@ object AlbumLoader {
context, context,
AudioColumns.ALBUM + " LIKE ?", AudioColumns.ALBUM + " LIKE ?",
arrayOf("%$query%"), arrayOf("%$query%"),
getSongLoaderSortOrder()) getSongLoaderSortOrder(context))
) )
return splitIntoAlbums(songs) return splitIntoAlbums(songs)
} }
@ -78,7 +78,7 @@ object AlbumLoader {
context, context,
AudioColumns.ALBUM_ID + "=?", AudioColumns.ALBUM_ID + "=?",
arrayOf(albumId.toString()), arrayOf(albumId.toString()),
getSongLoaderSortOrder() getSongLoaderSortOrder(context)
) )
) )
songs.subscribe { songs1 -> songs.subscribe { songs1 ->
@ -97,7 +97,7 @@ object AlbumLoader {
context, context,
AudioColumns.ALBUM_ID + "=?", AudioColumns.ALBUM_ID + "=?",
arrayOf(albumId.toString()), arrayOf(albumId.toString()),
getSongLoaderSortOrder())) getSongLoaderSortOrder(context)))
val album = Album(songs) val album = Album(songs)
sortSongsByTrackNumber(album) sortSongsByTrackNumber(album)
return album return album
@ -129,7 +129,7 @@ object AlbumLoader {
val songs = SongLoader.getSongs( val songs = SongLoader.getSongs(
SongLoader.makeSongCursor( SongLoader.makeSongCursor(
context, null, null, context, null, null,
getSongLoaderSortOrder()) getSongLoaderSortOrder(context))
) )
return splitIntoAlbums(songs) return splitIntoAlbums(songs)
@ -189,8 +189,8 @@ object AlbumLoader {
album.songs?.sortWith(Comparator { o1, o2 -> o1.trackNumber - o2.trackNumber }) album.songs?.sortWith(Comparator { o1, o2 -> o1.trackNumber - o2.trackNumber })
} }
private fun getSongLoaderSortOrder(): String { private fun getSongLoaderSortOrder(context: Context): String {
return PreferenceUtil.getInstance().albumSortOrder + ", " + return PreferenceUtil.getInstance(context).albumSortOrder + ", " +
PreferenceUtil.getInstance().albumDetailSongSortOrder PreferenceUtil.getInstance(context).albumDetailSongSortOrder
} }
} }

View file

@ -23,11 +23,11 @@ import io.reactivex.Observable
object ArtistLoader { object ArtistLoader {
private fun getSongLoaderSortOrder(): String { private fun getSongLoaderSortOrder(context: Context): String {
return PreferenceUtil.getInstance().artistSortOrder + ", " + return PreferenceUtil.getInstance(context).artistSortOrder + ", " +
PreferenceUtil.getInstance().artistAlbumSortOrder + ", " + PreferenceUtil.getInstance(context).artistAlbumSortOrder + ", " +
PreferenceUtil.getInstance().albumDetailSongSortOrder + ", " + PreferenceUtil.getInstance(context).albumDetailSongSortOrder + ", " +
PreferenceUtil.getInstance().artistDetailSongSortOrder PreferenceUtil.getInstance(context).artistDetailSongSortOrder
} }
fun getAllArtistsFlowable( fun getAllArtistsFlowable(
@ -36,7 +36,7 @@ object ArtistLoader {
return Observable.create { e -> return Observable.create { e ->
SongLoader.getSongsFlowable(SongLoader.makeSongCursor( SongLoader.getSongsFlowable(SongLoader.makeSongCursor(
context, null, null, context, null, null,
getSongLoaderSortOrder()) getSongLoaderSortOrder(context))
).subscribe { songs -> ).subscribe { songs ->
e.onNext(splitIntoArtists(AlbumLoader.splitIntoAlbums(songs))) e.onNext(splitIntoArtists(AlbumLoader.splitIntoAlbums(songs)))
e.onComplete() e.onComplete()
@ -48,7 +48,7 @@ object ArtistLoader {
val songs = SongLoader.getSongs(SongLoader.makeSongCursor( val songs = SongLoader.getSongs(SongLoader.makeSongCursor(
context, context,
null, null, null, null,
getSongLoaderSortOrder()) getSongLoaderSortOrder(context))
) )
return splitIntoArtists(AlbumLoader.splitIntoAlbums(songs)) return splitIntoArtists(AlbumLoader.splitIntoAlbums(songs))
} }
@ -59,7 +59,7 @@ object ArtistLoader {
context, context,
AudioColumns.ARTIST + " LIKE ?", AudioColumns.ARTIST + " LIKE ?",
arrayOf("%$query%"), arrayOf("%$query%"),
getSongLoaderSortOrder()) getSongLoaderSortOrder(context))
).subscribe { songs -> ).subscribe { songs ->
e.onNext(splitIntoArtists(AlbumLoader.splitIntoAlbums(songs))) e.onNext(splitIntoArtists(AlbumLoader.splitIntoAlbums(songs)))
e.onComplete() e.onComplete()
@ -72,7 +72,7 @@ object ArtistLoader {
context, context,
AudioColumns.ARTIST + " LIKE ?", AudioColumns.ARTIST + " LIKE ?",
arrayOf("%$query%"), arrayOf("%$query%"),
getSongLoaderSortOrder()) getSongLoaderSortOrder(context))
) )
return splitIntoArtists(AlbumLoader.splitIntoAlbums(songs)) return splitIntoArtists(AlbumLoader.splitIntoAlbums(songs))
} }
@ -117,7 +117,7 @@ object ArtistLoader {
return Observable.create { e -> return Observable.create { e ->
SongLoader.getSongsFlowable(SongLoader.makeSongCursor(context, AudioColumns.ARTIST_ID + "=?", SongLoader.getSongsFlowable(SongLoader.makeSongCursor(context, AudioColumns.ARTIST_ID + "=?",
arrayOf(artistId.toString()), arrayOf(artistId.toString()),
getSongLoaderSortOrder())) getSongLoaderSortOrder(context)))
.subscribe { songs -> .subscribe { songs ->
val artist = Artist(AlbumLoader.splitIntoAlbums(songs)) val artist = Artist(AlbumLoader.splitIntoAlbums(songs))
e.onNext(artist) e.onNext(artist)
@ -131,7 +131,7 @@ object ArtistLoader {
context, context,
AudioColumns.ARTIST_ID + "=?", AudioColumns.ARTIST_ID + "=?",
arrayOf(artistId.toString()), arrayOf(artistId.toString()),
getSongLoaderSortOrder()) getSongLoaderSortOrder(context))
) )
return Artist(AlbumLoader.splitIntoAlbums(songs)) return Artist(AlbumLoader.splitIntoAlbums(songs))
} }

View file

@ -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()),
baseProjection, BASE_SELECTION, null, PreferenceUtil.getInstance().songSortOrder) baseProjection, BASE_SELECTION, null, PreferenceUtil.getInstance(context).songSortOrder)
} catch (e: SecurityException) { } catch (e: SecurityException) {
return null return null
} }
@ -172,7 +172,7 @@ object GenreLoader {
try { try {
return context.contentResolver.query( return context.contentResolver.query(
Genres.EXTERNAL_CONTENT_URI, Genres.EXTERNAL_CONTENT_URI,
projection, null, null, PreferenceUtil.getInstance().genreSortOrder) projection, null, null, PreferenceUtil.getInstance(context).genreSortOrder)
} catch (e: SecurityException) { } catch (e: SecurityException) {
return null return null
} }

View file

@ -41,7 +41,7 @@ object LastAddedSongsLoader {
} }
private fun makeLastAddedCursor(context: Context): Cursor? { private fun makeLastAddedCursor(context: Context): Cursor? {
val cutoff = PreferenceUtil.getInstance().lastAddedCutoff val cutoff = PreferenceUtil.getInstance(context).lastAddedCutoff
return SongLoader.makeSongCursor( return SongLoader.makeSongCursor(
context, context,

View file

@ -176,7 +176,7 @@ object SongLoader {
context: Context, context: Context,
selection: String?, selection: String?,
selectionValues: Array<String>?, selectionValues: Array<String>?,
sortOrder: String = PreferenceUtil.getInstance().songSortOrder sortOrder: String = PreferenceUtil.getInstance(context).songSortOrder
): Cursor? { ): Cursor? {
var selectionFinal = selection var selectionFinal = selection
var selectionValuesFinal = selectionValues var selectionValuesFinal = selectionValues
@ -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,
baseProjection, selectionFinal + " AND " + MediaStore.Audio.Media.DURATION + ">= " + (PreferenceUtil.getInstance().filterLength * 1000), selectionValuesFinal, sortOrder) baseProjection, selectionFinal + " AND " + MediaStore.Audio.Media.DURATION + ">= " + (PreferenceUtil.getInstance(context).filterLength * 1000), selectionValuesFinal, sortOrder)
} catch (e: SecurityException) { } catch (e: SecurityException) {
return null return null
} }

View file

@ -18,7 +18,6 @@ import code.name.monkey.retromusic.model.Genre
import code.name.monkey.retromusic.mvp.BaseView import code.name.monkey.retromusic.mvp.BaseView
import code.name.monkey.retromusic.mvp.Presenter import code.name.monkey.retromusic.mvp.Presenter
import code.name.monkey.retromusic.mvp.PresenterImpl import code.name.monkey.retromusic.mvp.PresenterImpl
import code.name.monkey.retromusic.providers.RepositoryImpl
import code.name.monkey.retromusic.providers.interfaces.Repository import code.name.monkey.retromusic.providers.interfaces.Repository
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
import java.util.* import java.util.*

View file

@ -72,13 +72,13 @@ class AlbumCoverStylePreferenceDialog : PreferenceDialogFragmentCompat(), ViewPa
viewPager.adapter = AlbumCoverStyleAdapter(activity!!) viewPager.adapter = AlbumCoverStyleAdapter(activity!!)
viewPager.addOnPageChangeListener(this) viewPager.addOnPageChangeListener(this)
viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt() viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt()
viewPager.currentItem = PreferenceUtil.getInstance().albumCoverStyle.ordinal viewPager.currentItem = PreferenceUtil.getInstance(requireContext()).albumCoverStyle.ordinal
return MaterialDialog(activity!!).show { return MaterialDialog(activity!!).show {
title(R.string.pref_title_album_cover_style) title(R.string.pref_title_album_cover_style)
positiveButton(R.string.set) { positiveButton(R.string.set) {
val nowPlayingScreen = AlbumCoverStyle.values()[viewPagerPosition] val nowPlayingScreen = AlbumCoverStyle.values()[viewPagerPosition]
PreferenceUtil.getInstance().albumCoverStyle = nowPlayingScreen PreferenceUtil.getInstance(requireContext()).albumCoverStyle = nowPlayingScreen
} }
negativeButton(android.R.string.cancel) negativeButton(android.R.string.cancel)
customView(view = view, scrollable = false, noVerticalPadding = false) customView(view = view, scrollable = false, noVerticalPadding = false)

View file

@ -63,7 +63,7 @@ class LibraryPreferenceDialog : PreferenceDialogFragmentCompat() {
if (savedInstanceState != null) { if (savedInstanceState != null) {
categoryInfos = savedInstanceState.getParcelableArrayList(PreferenceUtil.LIBRARY_CATEGORIES)!! categoryInfos = savedInstanceState.getParcelableArrayList(PreferenceUtil.LIBRARY_CATEGORIES)!!
} else { } else {
categoryInfos = PreferenceUtil.getInstance().libraryCategoryInfos categoryInfos = PreferenceUtil.getInstance(requireContext()).libraryCategoryInfos
} }
adapter = CategoryInfoAdapter(categoryInfos) adapter = CategoryInfoAdapter(categoryInfos)
@ -84,7 +84,7 @@ class LibraryPreferenceDialog : PreferenceDialogFragmentCompat() {
dismiss() dismiss()
} }
.neutralButton(code.name.monkey.retromusic.R.string.reset_action) { .neutralButton(code.name.monkey.retromusic.R.string.reset_action) {
adapter.categoryInfos = PreferenceUtil.getInstance().defaultLibraryCategoryInfos adapter.categoryInfos = PreferenceUtil.getInstance(requireContext()).defaultLibraryCategoryInfos
} }
.noAutoDismiss() .noAutoDismiss()
} }
@ -100,7 +100,7 @@ class LibraryPreferenceDialog : PreferenceDialogFragmentCompat() {
Toast.makeText(context, "Not more than 5 items", Toast.LENGTH_SHORT).show() Toast.makeText(context, "Not more than 5 items", Toast.LENGTH_SHORT).show()
return return
} }
PreferenceUtil.getInstance().libraryCategoryInfos = categories PreferenceUtil.getInstance(requireContext()).libraryCategoryInfos = categories
} }
private fun getSelected(categories: List<CategoryInfo>): Int { private fun getSelected(categories: List<CategoryInfo>): Int {

View file

@ -88,7 +88,7 @@ class NowPlayingScreenPreferenceDialog : PreferenceDialogFragmentCompat(), ViewP
viewPager.adapter = NowPlayingScreenAdapter(activity!!) viewPager.adapter = NowPlayingScreenAdapter(activity!!)
viewPager.addOnPageChangeListener(this) viewPager.addOnPageChangeListener(this)
viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt() viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt()
viewPager.currentItem = PreferenceUtil.getInstance().nowPlayingScreen.ordinal viewPager.currentItem = PreferenceUtil.getInstance(requireContext()).nowPlayingScreen.ordinal
return MaterialDialog(activity!!).show { return MaterialDialog(activity!!).show {
@ -100,7 +100,7 @@ class NowPlayingScreenPreferenceDialog : PreferenceDialogFragmentCompat(), ViewP
Toast.makeText(context, result, Toast.LENGTH_SHORT).show() Toast.makeText(context, result, Toast.LENGTH_SHORT).show()
NavigationUtil.goToProVersion(activity!!) NavigationUtil.goToProVersion(activity!!)
} else { } else {
PreferenceUtil.getInstance().nowPlayingScreen = nowPlayingScreen PreferenceUtil.getInstance(requireContext()).nowPlayingScreen = nowPlayingScreen
} }
} }
negativeButton(android.R.string.cancel) negativeButton(android.R.string.cancel)
@ -110,8 +110,8 @@ class NowPlayingScreenPreferenceDialog : PreferenceDialogFragmentCompat(), ViewP
private fun isNowPlayingThemes(nowPlayingScreen: NowPlayingScreen): Boolean { private fun isNowPlayingThemes(nowPlayingScreen: NowPlayingScreen): Boolean {
if (nowPlayingScreen == NowPlayingScreen.BLUR_CARD) { if (nowPlayingScreen == NowPlayingScreen.BLUR_CARD) {
PreferenceUtil.getInstance().resetCarouselEffect() PreferenceUtil.getInstance(requireContext()).resetCarouselEffect()
PreferenceUtil.getInstance().resetCircularAlbumArt() PreferenceUtil.getInstance(requireContext()).resetCircularAlbumArt()
} }
return (nowPlayingScreen == NowPlayingScreen.FULL || return (nowPlayingScreen == NowPlayingScreen.FULL ||
@ -122,7 +122,7 @@ class NowPlayingScreenPreferenceDialog : PreferenceDialogFragmentCompat(), ViewP
nowPlayingScreen == NowPlayingScreen.SIMPLE || nowPlayingScreen == NowPlayingScreen.SIMPLE ||
nowPlayingScreen == NowPlayingScreen.BLUR_CARD || nowPlayingScreen == NowPlayingScreen.BLUR_CARD ||
nowPlayingScreen == NowPlayingScreen.ADAPTIVE) nowPlayingScreen == NowPlayingScreen.ADAPTIVE)
&& !App.isProVersion && !App.isProVersion()
} }
companion object { companion object {

View file

@ -47,13 +47,13 @@ public class BlacklistStore extends SQLiteOpenHelper {
public static synchronized BlacklistStore getInstance(@NonNull final Context context) { public static synchronized BlacklistStore getInstance(@NonNull final Context context) {
if (sInstance == null) { if (sInstance == null) {
sInstance = new BlacklistStore(context.getApplicationContext()); sInstance = new BlacklistStore(context.getApplicationContext());
if (!PreferenceUtil.getInstance().initializedBlacklist()) { if (!PreferenceUtil.getInstance(context).initializedBlacklist()) {
// blacklisted by default // blacklisted by default
sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_ALARMS)); sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_ALARMS));
sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_NOTIFICATIONS)); sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_NOTIFICATIONS));
sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_RINGTONES)); sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_RINGTONES));
PreferenceUtil.getInstance().setInitializedBlacklist(); PreferenceUtil.getInstance(context).setInitializedBlacklist();
} }
} }
return sInstance; return sInstance;

View file

@ -26,6 +26,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
class RepositoryImpl(private val context: Context) : Repository { class RepositoryImpl(private val context: Context) : Repository {
override fun artistInfoFloable( override fun artistInfoFloable(
name: String, name: String,
lang: String?, lang: String?,
@ -188,17 +189,4 @@ class RepositoryImpl(private val context: Context) : Repository {
return GenreLoader.getSongs(context, genreId) return GenreLoader.getSongs(context, genreId)
} }
companion object {
private var INSTANCE: RepositoryImpl? = null
val instance: RepositoryImpl
@Synchronized get() {
if (INSTANCE == null) {
INSTANCE = RepositoryImpl(App.instance)
}
return INSTANCE!!
}
}
} }

View file

@ -129,7 +129,7 @@ public class MultiPlayer implements Playback, MediaPlayer.OnErrorListener, Media
if (path == null) { if (path == null) {
return; return;
} }
if (PreferenceUtil.getInstance().gaplessPlayback()) { if (PreferenceUtil.getInstance(context).gaplessPlayback()) {
mNextMediaPlayer = new MediaPlayer(); mNextMediaPlayer = new MediaPlayer();
mNextMediaPlayer.setWakeMode(context, PowerManager.PARTIAL_WAKE_LOCK); mNextMediaPlayer.setWakeMode(context, PowerManager.PARTIAL_WAKE_LOCK);
mNextMediaPlayer.setAudioSessionId(getAudioSessionId()); mNextMediaPlayer.setAudioSessionId(getAudioSessionId());

View file

@ -341,7 +341,7 @@ public class MusicService extends MediaBrowserServiceCompat implements SharedPre
getContentResolver().registerContentObserver( getContentResolver().registerContentObserver(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, true, mediaStoreObserver); MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, true, mediaStoreObserver);
PreferenceUtil.getInstance().registerOnSharedPreferenceChangedListener(this); PreferenceUtil.getInstance(this).registerOnSharedPreferenceChangedListener(this);
restoreState(); restoreState();
@ -477,7 +477,7 @@ public class MusicService extends MediaBrowserServiceCompat implements SharedPre
quit(); quit();
releaseResources(); releaseResources();
getContentResolver().unregisterContentObserver(mediaStoreObserver); getContentResolver().unregisterContentObserver(mediaStoreObserver);
PreferenceUtil.getInstance().unregisterOnSharedPreferenceChangedListener(this); PreferenceUtil.getInstance(this).unregisterOnSharedPreferenceChangedListener(this);
wakeLock.release(); wakeLock.release();
sendBroadcast(new Intent("code.name.monkey.retromusic.RETRO_MUSIC_SERVICE_DESTROYED")); sendBroadcast(new Intent("code.name.monkey.retromusic.RETRO_MUSIC_SERVICE_DESTROYED"));
@ -676,7 +676,7 @@ public class MusicService extends MediaBrowserServiceCompat implements SharedPre
} }
public void initNotification() { public void initNotification() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && !PreferenceUtil.getInstance().classicNotification()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && !PreferenceUtil.getInstance(this).classicNotification()) {
playingNotification = new PlayingNotificationImpl24(); playingNotification = new PlayingNotificationImpl24();
} else { } else {
playingNotification = new PlayingNotificationOreo(); playingNotification = new PlayingNotificationOreo();
@ -745,14 +745,14 @@ public class MusicService extends MediaBrowserServiceCompat implements SharedPre
metaData.putLong(MediaMetadataCompat.METADATA_KEY_NUM_TRACKS, getPlayingQueue().size()); metaData.putLong(MediaMetadataCompat.METADATA_KEY_NUM_TRACKS, getPlayingQueue().size());
} }
if (PreferenceUtil.getInstance().albumArtOnLockscreen()) { if (PreferenceUtil.getInstance(this).albumArtOnLockscreen()) {
final Point screenSize = RetroUtil.getScreenSize(MusicService.this); final Point screenSize = RetroUtil.getScreenSize(MusicService.this);
GlideRequest request = GlideApp.with(MusicService.this) GlideRequest request = GlideApp.with(MusicService.this)
.asBitmap() .asBitmap()
.load(RetroGlideExtension.getSongModel(song)) .load(RetroGlideExtension.getSongModel(song))
.transition(RetroGlideExtension.getDefaultTransition()) .transition(RetroGlideExtension.getDefaultTransition())
.songOptions(song); .songOptions(song);
if (PreferenceUtil.getInstance().blurredAlbumArt()) { if (PreferenceUtil.getInstance(this).blurredAlbumArt()) {
request.transform(new BlurTransformation.Builder(MusicService.this).build()); request.transform(new BlurTransformation.Builder(MusicService.this).build());
} }
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@ -1271,7 +1271,7 @@ public class MusicService extends MediaBrowserServiceCompat implements SharedPre
} }
private void registerHeadsetEvents() { private void registerHeadsetEvents() {
if (!headsetReceiverRegistered && PreferenceUtil.getInstance().getHeadsetPlugged()) { if (!headsetReceiverRegistered && PreferenceUtil.getInstance(this).getHeadsetPlugged()) {
registerReceiver(headsetReceiver, headsetReceiverIntentFilter); registerReceiver(headsetReceiver, headsetReceiverIntentFilter);
headsetReceiverRegistered = true; headsetReceiverRegistered = true;
} }

View file

@ -51,7 +51,7 @@ class PlaybackHandler extends Handler {
switch (msg.what) { switch (msg.what) {
case MusicService.DUCK: case MusicService.DUCK:
if (PreferenceUtil.getInstance().audioDucking()) { if (PreferenceUtil.getInstance(service).audioDucking()) {
currentDuckVolume -= .05f; currentDuckVolume -= .05f;
if (currentDuckVolume > .2f) { if (currentDuckVolume > .2f) {
sendEmptyMessageDelayed(DUCK, 10); sendEmptyMessageDelayed(DUCK, 10);
@ -65,7 +65,7 @@ class PlaybackHandler extends Handler {
break; break;
case MusicService.UNDUCK: case MusicService.UNDUCK:
if (PreferenceUtil.getInstance().audioDucking()) { if (PreferenceUtil.getInstance(service).audioDucking()) {
currentDuckVolume += .03f; currentDuckVolume += .03f;
if (currentDuckVolume < 1f) { if (currentDuckVolume < 1f) {
sendEmptyMessageDelayed(MusicService.UNDUCK, 10); sendEmptyMessageDelayed(MusicService.UNDUCK, 10);

View file

@ -113,7 +113,7 @@ class PlayingNotificationImpl : PlayingNotification() {
bigNotificationImageSize) { bigNotificationImageSize) {
override fun onResourceReady(resource: BitmapPaletteWrapper, transition: Transition<in BitmapPaletteWrapper>?) { override fun onResourceReady(resource: BitmapPaletteWrapper, transition: Transition<in BitmapPaletteWrapper>?) {
update(resource.bitmap, update(resource.bitmap,
if (PreferenceUtil.getInstance().isDominantColor) if (PreferenceUtil.getInstance(service).isDominantColor)
RetroColorUtil.getDominantColor(resource.bitmap, Color.TRANSPARENT) RetroColorUtil.getDominantColor(resource.bitmap, Color.TRANSPARENT)
else else
RetroColorUtil.getColor(resource.palette, Color.TRANSPARENT)) RetroColorUtil.getColor(resource.palette, Color.TRANSPARENT))
@ -135,7 +135,7 @@ class PlayingNotificationImpl : PlayingNotification() {
.setImageViewResource(R.id.image, R.drawable.default_album_art) .setImageViewResource(R.id.image, R.drawable.default_album_art)
} }
if (!PreferenceUtil.getInstance().coloredNotification()) { if (!PreferenceUtil.getInstance(service).coloredNotification()) {
bgColorFinal = Color.WHITE bgColorFinal = Color.WHITE
} }
setBackgroundColor(bgColorFinal) setBackgroundColor(bgColorFinal)

View file

@ -84,7 +84,7 @@ class PlayingNotificationImpl24 : PlayingNotification() {
.into(object : RetroSimpleTarget<BitmapPaletteWrapper>(bigNotificationImageSize, bigNotificationImageSize) { .into(object : RetroSimpleTarget<BitmapPaletteWrapper>(bigNotificationImageSize, bigNotificationImageSize) {
override fun onResourceReady(resource: BitmapPaletteWrapper, transition: Transition<in BitmapPaletteWrapper>?) { override fun onResourceReady(resource: BitmapPaletteWrapper, transition: Transition<in BitmapPaletteWrapper>?) {
update(resource.bitmap, when { update(resource.bitmap, when {
PreferenceUtil.getInstance().isDominantColor -> RetroColorUtil.getDominantColor(resource.bitmap, Color.TRANSPARENT) PreferenceUtil.getInstance(service).isDominantColor -> RetroColorUtil.getDominantColor(resource.bitmap, Color.TRANSPARENT)
else -> RetroColorUtil.getColor(resource.palette, Color.TRANSPARENT) else -> RetroColorUtil.getColor(resource.palette, Color.TRANSPARENT)
}) })
} }
@ -146,7 +146,7 @@ class PlayingNotificationImpl24 : PlayingNotification() {
.setMediaSession(service.mediaSession.sessionToken) .setMediaSession(service.mediaSession.sessionToken)
.setShowActionsInCompactView( 1, 2, 3)) .setShowActionsInCompactView( 1, 2, 3))
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O && PreferenceUtil.getInstance().coloredNotification()) { if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O && PreferenceUtil.getInstance(service).coloredNotification()) {
builder.color = color builder.color = color
} }
} }

View file

@ -127,7 +127,7 @@ class PlayingNotificationOreo : PlayingNotification() {
notificationLayoutBig.setImageViewResource(R.id.largeIcon, R.drawable.default_album_art) notificationLayoutBig.setImageViewResource(R.id.largeIcon, R.drawable.default_album_art)
} }
if (!PreferenceUtil.getInstance().coloredNotification()) { if (!PreferenceUtil.getInstance(service).coloredNotification()) {
bgColorFinal = Color.WHITE bgColorFinal = Color.WHITE
} }
setBackgroundColor(bgColorFinal) setBackgroundColor(bgColorFinal)

View file

@ -44,7 +44,7 @@ class CustomArtistImageUtil private constructor(context: Context) {
} }
fun setCustomArtistImage(artist: Artist, uri: Uri) { fun setCustomArtistImage(artist: Artist, uri: Uri) {
GlideApp.with(App.context) GlideApp.with(App.getContext())
.asBitmap() .asBitmap()
.load(uri) .load(uri)
.apply(RequestOptions() .apply(RequestOptions()
@ -57,7 +57,7 @@ class CustomArtistImageUtil private constructor(context: Context) {
object : AsyncTask<Void, Void, Void>() { object : AsyncTask<Void, Void, Void>() {
@SuppressLint("ApplySharedPref") @SuppressLint("ApplySharedPref")
override fun doInBackground(vararg params: Void): Void? { override fun doInBackground(vararg params: Void): Void? {
val dir = File(App.context.filesDir, FOLDER_NAME) val dir = File(App.getContext().filesDir, FOLDER_NAME)
println(dir.absolutePath) println(dir.absolutePath)
if (!dir.exists()) { if (!dir.exists()) {
if (!dir.mkdirs()) { // create the folder if (!dir.mkdirs()) { // create the folder
@ -72,13 +72,13 @@ class CustomArtistImageUtil private constructor(context: Context) {
succesful = ImageUtil.resizeBitmap(resource, 2048).compress(Bitmap.CompressFormat.JPEG, 100, os) succesful = ImageUtil.resizeBitmap(resource, 2048).compress(Bitmap.CompressFormat.JPEG, 100, os)
os.close() os.close()
} catch (e: IOException) { } catch (e: IOException) {
Toast.makeText(App.context, e.toString(), Toast.LENGTH_LONG).show() Toast.makeText(App.getContext(), e.toString(), Toast.LENGTH_LONG).show()
} }
if (succesful) { if (succesful) {
mPreferences.edit().putBoolean(getFileName(artist), true).commit() mPreferences.edit().putBoolean(getFileName(artist), true).commit()
ArtistSignatureUtil.getInstance().updateArtistSignature(artist.name) ArtistSignatureUtil.getInstance().updateArtistSignature(artist.name)
App.context.contentResolver.notifyChange(Uri.parse("content://media"), null) // trigger media store changed to force artist image reload App.getContext().contentResolver.notifyChange(Uri.parse("content://media"), null) // trigger media store changed to force artist image reload
} }
return null return null
} }
@ -93,7 +93,7 @@ class CustomArtistImageUtil private constructor(context: Context) {
override fun doInBackground(vararg params: Void): Void? { override fun doInBackground(vararg params: Void): Void? {
mPreferences.edit().putBoolean(getFileName(artist), false).commit() mPreferences.edit().putBoolean(getFileName(artist), false).commit()
ArtistSignatureUtil.getInstance().updateArtistSignature(artist.name) ArtistSignatureUtil.getInstance().updateArtistSignature(artist.name)
App.context.contentResolver.notifyChange(Uri.parse("content://media"), null) // trigger media store changed to force artist image reload App.getContext().contentResolver.notifyChange(Uri.parse("content://media"), null) // trigger media store changed to force artist image reload
val file = getFile(artist) val file = getFile(artist)
if (!file.exists()) { if (!file.exists()) {
@ -133,7 +133,7 @@ class CustomArtistImageUtil private constructor(context: Context) {
@JvmStatic @JvmStatic
fun getFile(artist: Artist): File { fun getFile(artist: Artist): File {
val dir = File(App.context.filesDir, FOLDER_NAME) val dir = File(App.getContext().filesDir, FOLDER_NAME)
return File(dir, getFileName(artist)) return File(dir, getFileName(artist))
} }
} }

View file

@ -142,7 +142,8 @@ public final class PreferenceUtil {
mPreferences = PreferenceManager.getDefaultSharedPreferences(context); mPreferences = PreferenceManager.getDefaultSharedPreferences(context);
} }
public static PreferenceUtil getInstance() { @NonNull
public static PreferenceUtil getInstance(Context context) {
if (sInstance == null) { if (sInstance == null) {
sInstance = new PreferenceUtil(App.Companion.getContext()); sInstance = new PreferenceUtil(App.Companion.getContext());
} }

View file

@ -26,7 +26,6 @@ import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Point; import android.graphics.Point;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo; import android.net.NetworkInfo;
@ -37,15 +36,10 @@ import android.provider.BaseColumns;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.Display; import android.view.Display;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout;
import androidx.annotation.ColorInt; import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes; import androidx.annotation.DrawableRes;
@ -197,8 +191,8 @@ public class RetroUtil {
public static Drawable getTintedDrawable(@DrawableRes int id) { public static Drawable getTintedDrawable(@DrawableRes int id) {
return TintHelper return TintHelper
.createTintedDrawable(ContextCompat.getDrawable(App.Companion.getInstance(), id), .createTintedDrawable(ContextCompat.getDrawable(App.Companion.getContext(), id),
ThemeStore.Companion.accentColor(App.Companion.getInstance())); ThemeStore.Companion.accentColor(App.Companion.getContext()));
} }
@NonNull @NonNull
@ -218,7 +212,7 @@ public class RetroUtil {
} }
public static boolean isAllowedToDownloadMetadata(final @NonNull Context context) { public static boolean isAllowedToDownloadMetadata(final @NonNull Context context) {
switch (PreferenceUtil.getInstance().autoDownloadImagesPolicy()) { switch (PreferenceUtil.getInstance(context).autoDownloadImagesPolicy()) {
case "always": case "always":
return true; return true;
case "only_wifi": case "only_wifi":
@ -291,10 +285,6 @@ public class RetroUtil {
} }
} }
public static void statusBarHeight(View statusBar) {
statusBar.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight()));
}
public static int getStatusBarHeight() { public static int getStatusBarHeight() {
int result = 0; int result = 0;
int resourceId = App.Companion.getContext().getResources().getIdentifier("status_bar_height", "dimen", "android"); int resourceId = App.Companion.getContext().getResources().getIdentifier("status_bar_height", "dimen", "android");
@ -321,117 +311,4 @@ public class RetroUtil {
window.getDecorView().setSystemUiVisibility( window.getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
} }
public static int getSoftButtonsBarSizePort(Activity activity) {
// getRealMetrics is only available with API 17 and +
DisplayMetrics metrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
int usableHeight = metrics.heightPixels;
activity.getWindowManager().getDefaultDisplay().getRealMetrics(metrics);
int realHeight = metrics.heightPixels;
if (realHeight > usableHeight)
return realHeight - usableHeight;
else
return 0;
}
public static int getNavigationBarHeight(Activity activity) {
/* int result = 0;
int resourceId = App.getContext().getResources().getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0) {
result = App.getContext().getResources().getDimensionPixelSize(resourceId);
}
return result;*/
DisplayMetrics metrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
int usableHeight = metrics.heightPixels;
activity.getWindowManager().getDefaultDisplay().getRealMetrics(metrics);
int realHeight = metrics.heightPixels;
if (realHeight > usableHeight)
if (PreferenceUtil.getInstance().getFullScreenMode()) {
return 0;
} else
return realHeight - usableHeight;
else
return 0;
}
public static int getNavBarHeight(Context c) {
int result = 0;
boolean hasMenuKey = ViewConfiguration.get(c).hasPermanentMenuKey();
boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
if (!hasMenuKey && !hasBackKey) {
//The device has a navigation bar
Resources resources = c.getResources();
int orientation = resources.getConfiguration().orientation;
int resourceId;
if (isTablet(c)) {
resourceId = resources.getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_height_landscape", "dimen", "android");
} else {
resourceId = resources.getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_width", "dimen", "android");
}
if (resourceId > 0) {
return resources.getDimensionPixelSize(resourceId);
}
}
return result;
}
private static boolean isTablet(Context c) {
return (c.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK)
>= Configuration.SCREENLAYOUT_SIZE_LARGE;
}
private static boolean hasNavBar(Resources resources) {
int id = resources.getIdentifier("config_showNavigationBar", "bool", "android");
if (id > 0)
return resources.getBoolean(id);
else
return false;
}
public static int getNavigationBarHeight(Resources resources) {
if (!hasNavBar(resources))
return 0;
int orientation = resources.getConfiguration().orientation;
//Only phone between 0-599 has navigationbar can move
boolean isSmartphone = resources.getConfiguration().smallestScreenWidthDp < 600;
if (isSmartphone && Configuration.ORIENTATION_LANDSCAPE == orientation)
return 0;
int id = resources
.getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_height_landscape", "dimen", "android");
if (id > 0)
return resources.getDimensionPixelSize(id);
return 0;
}
public static boolean checkNavigationBarHeight() {
Resources resources = App.Companion.getContext().getResources();
int orientation = resources.getConfiguration().orientation;
if (!hasNavBar(resources)) {
return false;
}
boolean isSmartPhone = resources.getConfiguration().smallestScreenWidthDp < 600;
if (isSmartPhone && Configuration.ORIENTATION_LANDSCAPE == orientation)
return false;
int id = resources
.getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_height_landscape", "dimen", "android");
return id > 0;
}
@NonNull
public static Drawable resize(@NonNull Context context, @NonNull Drawable image) {
Bitmap b = ((BitmapDrawable) image).getBitmap();
Bitmap bitmapResized = Bitmap.createScaledBitmap(b, 50, 50, false);
return new BitmapDrawable(context.getResources(), bitmapResized);
}
} }

View file

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

View file

@ -31,9 +31,9 @@ class BottomNavigationBarTinted @JvmOverloads constructor(
) : BottomNavigationView(context, attrs, defStyleAttr) { ) : BottomNavigationView(context, attrs, defStyleAttr) {
init { init {
labelVisibilityMode = PreferenceUtil.getInstance().tabTitleMode labelVisibilityMode = PreferenceUtil.getInstance(context).tabTitleMode
setBackgroundColor(ThemeStore.primaryColor(context)) setBackgroundColor(ThemeStore.primaryColor(context))
selectedItemId = PreferenceUtil.getInstance().lastPage selectedItemId = PreferenceUtil.getInstance(context).lastPage
val iconColor = ATHUtil.resolveColor(context, R.attr.iconColor) val iconColor = ATHUtil.resolveColor(context, R.attr.iconColor)
val accentColor = ThemeStore.accentColor(context) val accentColor = ThemeStore.accentColor(context)

View file

@ -62,7 +62,7 @@ public class UserImageView extends CircularImageView implements SharedPreference
.asDrawable() .asDrawable()
.placeholder(R.drawable.ic_account_white_24dp) .placeholder(R.drawable.ic_account_white_24dp)
.fallback(R.drawable.ic_account_white_24dp) .fallback(R.drawable.ic_account_white_24dp)
.load(new File(PreferenceUtil.getInstance().getProfileImage(), USER_PROFILE)) .load(new File(PreferenceUtil.getInstance(context).getProfileImage(), USER_PROFILE))
.into(new Target<Drawable>() { .into(new Target<Drawable>() {
@Override @Override
public void onLoadStarted(@Nullable Drawable placeholder) { public void onLoadStarted(@Nullable Drawable placeholder) {

View file

@ -1,4 +1,17 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (c) 2019 Hemanth Savarala.
~
~ Licensed under the GNU General Public License v3
~
~ This is free software: you can redistribute it and/or modify it under
~ the terms of the GNU General Public License as published by
~ the Free Software Foundation either version 3 of the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~ See the GNU General Public License for more details.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"

View file

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (c) 2019 Hemanth Savarala.
~
~ Licensed under the GNU General Public License v3
~
~ This is free software: you can redistribute it and/or modify it under
~ the terms of the GNU General Public License as published by
~ the Free Software Foundation either version 3 of the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~ See the GNU General Public License for more details.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/rectSelector"
android:gravity="center_horizontal"
android:minHeight="@dimen/md_listitem_height"
android:orientation="vertical"
android:paddingBottom="24dp"
tools:ignore="PrivateResource">
<code.name.monkey.retromusic.views.CircularImageView
android:id="@+id/image"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_margin="8dp"
app:civ_border="false"
app:civ_shadow="false"
app:srcCompat="@drawable/ic_person_flat" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:paddingStart="16dp"
android:paddingTop="8dp"
android:paddingEnd="16dp"
android:paddingBottom="8dp">
<code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="@style/TextViewHeadline5" />
<code.name.monkey.appthemehelper.common.views.ATESecondaryTextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.85"
android:textAppearance="@style/TextViewBody2" />
</LinearLayout>
</LinearLayout>

View file

@ -37,7 +37,7 @@
android:focusable="false" android:focusable="false"
android:gravity="center_vertical" /> android:gravity="center_vertical" />
<com.google.android.material.textview.MaterialTextView <code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView
android:id="@+id/title" android:id="@+id/title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"

View file

@ -16,6 +16,13 @@
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory <code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory
android:key="category_color" android:key="category_color"
android:title="@string/colors"> android:title="@string/colors">
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEColorPreference
android:key="accent_color"
android:persistent="false"
android:summary="@string/accent_color_desc"
android:title="@string/accent_color"
app:enableCopying="true"
app:icon="@drawable/ic_colorize_white_24dp" />
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference <code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
android:defaultValue="false" android:defaultValue="false"
@ -38,13 +45,5 @@
android:title="@string/pref_title_toggle_dominant_color" android:title="@string/pref_title_toggle_dominant_color"
app:enableCopying="true" /> app:enableCopying="true" />
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEColorPreference
android:key="accent_color"
android:persistent="false"
android:summary="@string/accent_color_desc"
android:title="@string/accent_color"
app:enableCopying="true"
app:icon="@drawable/ic_colorize_white_24dp" />
</code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory> </code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory>
</androidx.preference.PreferenceScreen> </androidx.preference.PreferenceScreen>

View file

@ -9,6 +9,7 @@ buildscript {
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.5.0' classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.android.tools.build:bundletool:0.9.0'
} }
} }