Not using static app context wherever possible
This commit is contained in:
parent
904dd748cb
commit
5ff4438a42
15 changed files with 107 additions and 71 deletions
|
@ -18,9 +18,11 @@ import android.content.Context
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.appcompat.app.AppCompatDelegate.setDefaultNightMode
|
import androidx.appcompat.app.AppCompatDelegate.setDefaultNightMode
|
||||||
|
import androidx.core.graphics.ColorUtils
|
||||||
import androidx.core.os.ConfigurationCompat
|
import androidx.core.os.ConfigurationCompat
|
||||||
import code.name.monkey.appthemehelper.common.ATHToolbarActivity
|
import code.name.monkey.appthemehelper.common.ATHToolbarActivity
|
||||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||||
|
@ -28,12 +30,13 @@ import code.name.monkey.retromusic.LanguageContextWrapper
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.extensions.*
|
import code.name.monkey.retromusic.extensions.*
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import code.name.monkey.retromusic.util.theme.ThemeManager
|
import code.name.monkey.retromusic.util.theme.getNightMode
|
||||||
|
import code.name.monkey.retromusic.util.theme.getThemeResValue
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
|
abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
|
||||||
|
|
||||||
private val handler = Handler()
|
private val handler = Handler(Looper.getMainLooper())
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
updateTheme()
|
updateTheme()
|
||||||
|
@ -50,9 +53,9 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTheme() {
|
private fun updateTheme() {
|
||||||
setTheme(ThemeManager.getThemeResValue())
|
setTheme(getThemeResValue())
|
||||||
if (PreferenceUtil.materialYou) {
|
if (PreferenceUtil.materialYou) {
|
||||||
setDefaultNightMode(ThemeManager.getNightMode())
|
setDefaultNightMode(getNightMode())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PreferenceUtil.isCustomFont) {
|
if (PreferenceUtil.isCustomFont) {
|
||||||
|
|
|
@ -206,7 +206,7 @@ class AppWidgetCard : BaseAppWidget() {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
val image = getAlbumArtDrawable(service.resources, bitmap)
|
val image = getAlbumArtDrawable(service, bitmap)
|
||||||
val roundedBitmap = createRoundedBitmap(
|
val roundedBitmap = createRoundedBitmap(
|
||||||
image, imageSize, imageSize, cardRadius, 0F, cardRadius, 0F
|
image, imageSize, imageSize, cardRadius, 0F, cardRadius, 0F
|
||||||
)
|
)
|
||||||
|
|
|
@ -190,7 +190,7 @@ class AppWidgetClassic : BaseAppWidget() {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
val image = getAlbumArtDrawable(service.resources, bitmap)
|
val image = getAlbumArtDrawable(service, bitmap)
|
||||||
val roundedBitmap =
|
val roundedBitmap =
|
||||||
createRoundedBitmap(
|
createRoundedBitmap(
|
||||||
image,
|
image,
|
||||||
|
|
|
@ -207,7 +207,7 @@ class AppWidgetMD3 : BaseAppWidget() {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
val image = getAlbumArtDrawable(service.resources, bitmap)
|
val image = getAlbumArtDrawable(service, bitmap)
|
||||||
val roundedBitmap = createRoundedBitmap(
|
val roundedBitmap = createRoundedBitmap(
|
||||||
image,
|
image,
|
||||||
imageSize,
|
imageSize,
|
||||||
|
|
|
@ -182,7 +182,7 @@ class AppWidgetSmall : BaseAppWidget() {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
val image = getAlbumArtDrawable(service.resources, bitmap)
|
val image = getAlbumArtDrawable(service, bitmap)
|
||||||
val roundedBitmap = createRoundedBitmap(
|
val roundedBitmap = createRoundedBitmap(
|
||||||
image, imageSize, imageSize, cardRadius, 0f, 0f, 0f
|
image, imageSize, imageSize, cardRadius, 0f, 0f, 0f
|
||||||
)
|
)
|
||||||
|
|
|
@ -22,7 +22,6 @@ 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.appthemehelper.util.VersionUtils
|
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||||
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
|
||||||
|
@ -134,8 +133,8 @@ class AppWidgetText : BaseAppWidget() {
|
||||||
appWidgetView.setImageViewBitmap(
|
appWidgetView.setImageViewBitmap(
|
||||||
R.id.button_toggle_play_pause, createBitmap(
|
R.id.button_toggle_play_pause, createBitmap(
|
||||||
RetroUtil.getTintedVectorDrawable(
|
RetroUtil.getTintedVectorDrawable(
|
||||||
App.getContext(), playPauseRes, ContextCompat.getColor(
|
service, playPauseRes, ContextCompat.getColor(
|
||||||
App.getContext(), R.color.md_white_1000
|
service, R.color.md_white_1000
|
||||||
)
|
)
|
||||||
), 1f
|
), 1f
|
||||||
)
|
)
|
||||||
|
@ -143,10 +142,11 @@ class AppWidgetText : BaseAppWidget() {
|
||||||
appWidgetView.setImageViewBitmap(
|
appWidgetView.setImageViewBitmap(
|
||||||
R.id.button_next, createBitmap(
|
R.id.button_next, createBitmap(
|
||||||
RetroUtil.getTintedVectorDrawable(
|
RetroUtil.getTintedVectorDrawable(
|
||||||
App.getContext(),
|
service,
|
||||||
R.drawable.ic_skip_next,
|
R.drawable.ic_skip_next,
|
||||||
ContextCompat.getColor(
|
ContextCompat.getColor(
|
||||||
App.getContext(), R.color.md_white_1000
|
service,
|
||||||
|
R.color.md_white_1000
|
||||||
)
|
)
|
||||||
), 1f
|
), 1f
|
||||||
)
|
)
|
||||||
|
@ -154,10 +154,10 @@ class AppWidgetText : BaseAppWidget() {
|
||||||
appWidgetView.setImageViewBitmap(
|
appWidgetView.setImageViewBitmap(
|
||||||
R.id.button_prev, createBitmap(
|
R.id.button_prev, createBitmap(
|
||||||
RetroUtil.getTintedVectorDrawable(
|
RetroUtil.getTintedVectorDrawable(
|
||||||
App.getContext(),
|
service,
|
||||||
R.drawable.ic_skip_previous,
|
R.drawable.ic_skip_previous,
|
||||||
ContextCompat.getColor(
|
ContextCompat.getColor(
|
||||||
App.getContext(), R.color.md_white_1000
|
service, R.color.md_white_1000
|
||||||
)
|
)
|
||||||
), 1f
|
), 1f
|
||||||
)
|
)
|
||||||
|
|
|
@ -20,7 +20,6 @@ import android.appwidget.AppWidgetProvider
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.res.Resources
|
|
||||||
import android.graphics.*
|
import android.graphics.*
|
||||||
import android.graphics.drawable.BitmapDrawable
|
import android.graphics.drawable.BitmapDrawable
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
|
@ -116,11 +115,11 @@ abstract class BaseAppWidget : AppWidgetProvider() {
|
||||||
|
|
||||||
abstract fun performUpdate(service: MusicService, appWidgetIds: IntArray?)
|
abstract fun performUpdate(service: MusicService, appWidgetIds: IntArray?)
|
||||||
|
|
||||||
protected fun getAlbumArtDrawable(resources: Resources, bitmap: Bitmap?): Drawable {
|
protected fun getAlbumArtDrawable(context: Context, bitmap: Bitmap?): Drawable {
|
||||||
return if (bitmap == null) {
|
return if (bitmap == null) {
|
||||||
ContextCompat.getDrawable(App.getContext(), R.drawable.default_audio_art)!!
|
ContextCompat.getDrawable(context, R.drawable.default_audio_art)!!
|
||||||
} else {
|
} else {
|
||||||
BitmapDrawable(resources, bitmap)
|
BitmapDrawable(context.resources, bitmap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,17 @@ import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import androidx.core.view.updateLayoutParams
|
import androidx.core.view.updateLayoutParams
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.ActivityRestoreBinding
|
import code.name.monkey.retromusic.databinding.ActivityRestoreBinding
|
||||||
|
import code.name.monkey.retromusic.extensions.accentColor
|
||||||
|
import code.name.monkey.retromusic.extensions.accentOutlineColor
|
||||||
|
import code.name.monkey.retromusic.extensions.addAccentColor
|
||||||
import code.name.monkey.retromusic.helper.BackupContent
|
import code.name.monkey.retromusic.helper.BackupContent
|
||||||
import code.name.monkey.retromusic.helper.BackupContent.*
|
import code.name.monkey.retromusic.helper.BackupContent.*
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import code.name.monkey.retromusic.util.theme.ThemeManager
|
import code.name.monkey.retromusic.util.theme.getNightMode
|
||||||
import com.google.android.material.color.DynamicColors
|
import com.google.android.material.color.DynamicColors
|
||||||
|
import com.google.android.material.color.DynamicColorsOptions
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
@ -33,15 +38,21 @@ class RestoreActivity : AppCompatActivity() {
|
||||||
setWidth()
|
setWidth()
|
||||||
val backupUri = intent?.data
|
val backupUri = intent?.data
|
||||||
binding.backupName.setText(getFileName(backupUri))
|
binding.backupName.setText(getFileName(backupUri))
|
||||||
|
binding.cancelButton.accentOutlineColor()
|
||||||
binding.cancelButton.setOnClickListener {
|
binding.cancelButton.setOnClickListener {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
binding.restoreButton.accentColor()
|
||||||
|
binding.checkArtistImages.addAccentColor()
|
||||||
|
binding.checkDatabases.addAccentColor()
|
||||||
|
binding.checkSettings.addAccentColor()
|
||||||
|
binding.checkUserImages.addAccentColor()
|
||||||
binding.restoreButton.setOnClickListener {
|
binding.restoreButton.setOnClickListener {
|
||||||
val backupContents = mutableListOf<BackupContent>()
|
val backupContents = mutableListOf<BackupContent>()
|
||||||
if (binding.checkSettings.isChecked) backupContents.add(SETTINGS)
|
|
||||||
if (binding.checkDatabases.isChecked) backupContents.add(PLAYLISTS)
|
if (binding.checkDatabases.isChecked) backupContents.add(PLAYLISTS)
|
||||||
if (binding.checkArtistImages.isChecked) backupContents.add(CUSTOM_ARTIST_IMAGES)
|
if (binding.checkArtistImages.isChecked) backupContents.add(CUSTOM_ARTIST_IMAGES)
|
||||||
if (binding.checkUserImages.isChecked) backupContents.add(USER_IMAGES)
|
if (binding.checkSettings.isChecked) backupContents.add(SETTINGS)
|
||||||
|
if (binding.checkUserImages.isChecked) backupContents.add(SETTINGS)
|
||||||
lifecycleScope.launch(Dispatchers.IO) {
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
if (backupUri != null) {
|
if (backupUri != null) {
|
||||||
contentResolver.openInputStream(backupUri)?.use {
|
contentResolver.openInputStream(backupUri)?.use {
|
||||||
|
@ -53,13 +64,15 @@ class RestoreActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTheme() {
|
private fun updateTheme() {
|
||||||
AppCompatDelegate.setDefaultNightMode(ThemeManager.getNightMode())
|
AppCompatDelegate.setDefaultNightMode(getNightMode())
|
||||||
|
|
||||||
// Apply dynamic colors to activity if enabled
|
// Apply dynamic colors to activity if enabled
|
||||||
if (PreferenceUtil.materialYou) {
|
if (PreferenceUtil.materialYou) {
|
||||||
DynamicColors.applyIfAvailable(
|
DynamicColors.applyToActivityIfAvailable(
|
||||||
this,
|
this,
|
||||||
com.google.android.material.R.style.ThemeOverlay_Material3_DynamicColors_DayNight
|
DynamicColorsOptions.Builder()
|
||||||
|
.setThemeOverlay(R.style.ThemeOverlay_Material3_DynamicColors_DayNight)
|
||||||
|
.build()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,7 +205,7 @@ class FoldersFragment : AbsMainActivityFragment(R.layout.fragment_folder),
|
||||||
return@setOnMenuItemClickListener true
|
return@setOnMenuItemClickListener true
|
||||||
}
|
}
|
||||||
R.id.action_add_to_blacklist -> {
|
R.id.action_add_to_blacklist -> {
|
||||||
BlacklistStore.getInstance(App.getContext()).addPath(file)
|
BlacklistStore.getInstance(requireContext()).addPath(file)
|
||||||
return@setOnMenuItemClickListener true
|
return@setOnMenuItemClickListener true
|
||||||
}
|
}
|
||||||
R.id.action_set_as_start_directory -> {
|
R.id.action_set_as_start_directory -> {
|
||||||
|
|
|
@ -49,6 +49,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.interfaces.IScrollHelper
|
import code.name.monkey.retromusic.interfaces.IScrollHelper
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtil.userName
|
||||||
import com.google.android.gms.cast.framework.CastButtonFactory
|
import com.google.android.gms.cast.framework.CastButtonFactory
|
||||||
import com.google.android.material.shape.MaterialShapeDrawable
|
import com.google.android.material.shape.MaterialShapeDrawable
|
||||||
import com.google.android.material.transition.MaterialFadeThrough
|
import com.google.android.material.transition.MaterialFadeThrough
|
||||||
|
@ -67,7 +68,7 @@ class HomeFragment :
|
||||||
mainActivity.setSupportActionBar(binding.toolbar)
|
mainActivity.setSupportActionBar(binding.toolbar)
|
||||||
mainActivity.supportActionBar?.title = null
|
mainActivity.supportActionBar?.title = null
|
||||||
setupListeners()
|
setupListeners()
|
||||||
binding.titleWelcome.text = String.format("%s", PreferenceUtil.userName)
|
binding.titleWelcome.text = String.format("%s", userName)
|
||||||
|
|
||||||
enterTransition = MaterialFadeThrough().addTarget(binding.contentContainer)
|
enterTransition = MaterialFadeThrough().addTarget(binding.contentContainer)
|
||||||
reenterTransition = MaterialFadeThrough().addTarget(binding.contentContainer)
|
reenterTransition = MaterialFadeThrough().addTarget(binding.contentContainer)
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
package code.name.monkey.retromusic.fragments.other
|
package code.name.monkey.retromusic.fragments.other
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Intent
|
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
@ -24,6 +23,8 @@ import android.view.LayoutInflater
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.activity.result.ActivityResult
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.core.view.doOnPreDraw
|
import androidx.core.view.doOnPreDraw
|
||||||
import androidx.core.view.updateLayoutParams
|
import androidx.core.view.updateLayoutParams
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
@ -40,7 +41,7 @@ import code.name.monkey.retromusic.fragments.LibraryViewModel
|
||||||
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.util.ImageUtil
|
import code.name.monkey.retromusic.util.ImageUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil.userName
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.load.DataSource
|
import com.bumptech.glide.load.DataSource
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
|
@ -83,7 +84,7 @@ class UserInfoFragment : Fragment() {
|
||||||
|
|
||||||
binding.nameContainer.accentColor()
|
binding.nameContainer.accentColor()
|
||||||
binding.next.accentColor()
|
binding.next.accentColor()
|
||||||
binding.name.setText(PreferenceUtil.userName)
|
binding.name.setText(userName)
|
||||||
|
|
||||||
binding.userImage.setOnClickListener {
|
binding.userImage.setOnClickListener {
|
||||||
showUserImageOptions()
|
showUserImageOptions()
|
||||||
|
@ -99,7 +100,7 @@ class UserInfoFragment : Fragment() {
|
||||||
showToast("Your name can't be empty!")
|
showToast("Your name can't be empty!")
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
PreferenceUtil.userName = nameString
|
userName = nameString
|
||||||
findNavController().navigateUp()
|
findNavController().navigateUp()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +179,9 @@ class UserInfoFragment : Fragment() {
|
||||||
.compress(1440)
|
.compress(1440)
|
||||||
.provider(ImageProvider.GALLERY)
|
.provider(ImageProvider.GALLERY)
|
||||||
.crop(16f, 9f)
|
.crop(16f, 9f)
|
||||||
.start(PICK_BANNER_REQUEST)
|
.createIntent {
|
||||||
|
startForBannerImageResult.launch(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun pickNewPhoto() {
|
private fun pickNewPhoto() {
|
||||||
|
@ -186,23 +189,42 @@ class UserInfoFragment : Fragment() {
|
||||||
.provider(ImageProvider.GALLERY)
|
.provider(ImageProvider.GALLERY)
|
||||||
.cropSquare()
|
.cropSquare()
|
||||||
.compress(1440)
|
.compress(1440)
|
||||||
.start(PICK_IMAGE_REQUEST)
|
.createIntent {
|
||||||
|
startForProfileImageResult.launch(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
private val startForProfileImageResult =
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult ->
|
||||||
if (resultCode == Activity.RESULT_OK && requestCode == PICK_IMAGE_REQUEST) {
|
saveImage(result) { fileUri ->
|
||||||
val fileUri = data?.data
|
setAndSaveUserImage(fileUri)
|
||||||
fileUri?.let { setAndSaveUserImage(it) }
|
}
|
||||||
} else if (resultCode == Activity.RESULT_OK && requestCode == PICK_BANNER_REQUEST) {
|
}
|
||||||
val fileUri = data?.data
|
|
||||||
fileUri?.let { setAndSaveBannerImage(it) }
|
private val startForBannerImageResult =
|
||||||
} else if (resultCode == ImagePicker.RESULT_ERROR) {
|
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult ->
|
||||||
|
saveImage(result) { fileUri ->
|
||||||
|
setAndSaveBannerImage(fileUri)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun saveImage(result: ActivityResult, doIfResultOk: (uri: Uri) -> Unit) {
|
||||||
|
val resultCode = result.resultCode
|
||||||
|
val data = result.data
|
||||||
|
when (resultCode) {
|
||||||
|
Activity.RESULT_OK -> {
|
||||||
|
data?.data?.let { uri ->
|
||||||
|
doIfResultOk(uri)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImagePicker.RESULT_ERROR -> {
|
||||||
showToast(ImagePicker.getError(data))
|
showToast(ImagePicker.getError(data))
|
||||||
} else {
|
}
|
||||||
|
else -> {
|
||||||
showToast("Task Cancelled")
|
showToast("Task Cancelled")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setAndSaveBannerImage(fileUri: Uri) {
|
private fun setAndSaveBannerImage(fileUri: Uri) {
|
||||||
Glide.with(this)
|
Glide.with(this)
|
||||||
|
@ -288,6 +310,7 @@ class UserInfoFragment : Fragment() {
|
||||||
_binding = null
|
_binding = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val PICK_IMAGE_REQUEST = 9002
|
private const val PICK_IMAGE_REQUEST = 9002
|
||||||
private const val PICK_BANNER_REQUEST = 9004
|
private const val PICK_BANNER_REQUEST = 9004
|
||||||
|
|
|
@ -124,7 +124,7 @@ object SongMenuHelper : KoinComponent {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
R.id.action_add_to_blacklist -> {
|
R.id.action_add_to_blacklist -> {
|
||||||
BlacklistStore.getInstance(App.getContext()).addPath(File(song.data))
|
BlacklistStore.getInstance(activity).addPath(File(song.data))
|
||||||
libraryViewModel.forceReload(ReloadType.Songs)
|
libraryViewModel.forceReload(ReloadType.Songs)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ import androidx.core.graphics.BlendModeCompat.SRC_IN
|
||||||
import androidx.core.text.parseAsHtml
|
import androidx.core.text.parseAsHtml
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference
|
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference
|
||||||
import code.name.monkey.retromusic.App
|
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.dialogs.BlacklistFolderChooserDialog
|
import code.name.monkey.retromusic.dialogs.BlacklistFolderChooserDialog
|
||||||
import code.name.monkey.retromusic.extensions.accentTextColor
|
import code.name.monkey.retromusic.extensions.accentTextColor
|
||||||
|
@ -90,7 +89,7 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
|
||||||
).parseAsHtml()
|
).parseAsHtml()
|
||||||
)
|
)
|
||||||
.setPositiveButton(R.string.remove_action) { _, _ ->
|
.setPositiveButton(R.string.remove_action) { _, _ ->
|
||||||
BlacklistStore.getInstance(App.getContext())
|
BlacklistStore.getInstance(requireContext())
|
||||||
.removePath(File(paths[which]))
|
.removePath(File(paths[which]))
|
||||||
refreshBlacklistData()
|
refreshBlacklistData()
|
||||||
}
|
}
|
||||||
|
@ -119,13 +118,13 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
|
||||||
private lateinit var paths: ArrayList<String>
|
private lateinit var paths: ArrayList<String>
|
||||||
|
|
||||||
private fun refreshBlacklistData() {
|
private fun refreshBlacklistData() {
|
||||||
this.paths = BlacklistStore.getInstance(App.getContext()).paths
|
this.paths = BlacklistStore.getInstance(requireContext()).paths
|
||||||
val dialog = dialog as MaterialAlertDialogBuilder?
|
val dialog = dialog as MaterialAlertDialogBuilder?
|
||||||
dialog?.setItems(paths.toTypedArray(), null)
|
dialog?.setItems(paths.toTypedArray(), null)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFolderSelection(dialog: BlacklistFolderChooserDialog, folder: File) {
|
override fun onFolderSelection(dialog: BlacklistFolderChooserDialog, folder: File) {
|
||||||
BlacklistStore.getInstance(App.getContext()).addPath(folder)
|
BlacklistStore.getInstance(requireContext()).addPath(folder)
|
||||||
refreshBlacklistData()
|
refreshBlacklistData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.net.ConnectivityManager
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import androidx.core.content.res.use
|
import androidx.core.content.res.use
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import androidx.viewpager.widget.ViewPager
|
import androidx.viewpager.widget.ViewPager
|
||||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||||
|
@ -98,10 +99,10 @@ object PreferenceUtil {
|
||||||
|
|
||||||
val languageCode: String get() = sharedPreferences.getString(LANGUAGE_NAME, "auto") ?: "auto"
|
val languageCode: String get() = sharedPreferences.getString(LANGUAGE_NAME, "auto") ?: "auto"
|
||||||
|
|
||||||
var userName
|
var Fragment.userName
|
||||||
get() = sharedPreferences.getString(
|
get() = sharedPreferences.getString(
|
||||||
USER_NAME,
|
USER_NAME,
|
||||||
App.getContext().getString(R.string.user_name)
|
getString(R.string.user_name)
|
||||||
)
|
)
|
||||||
set(value) = sharedPreferences.edit {
|
set(value) = sharedPreferences.edit {
|
||||||
putString(USER_NAME, value)
|
putString(USER_NAME, value)
|
||||||
|
|
|
@ -1,21 +1,19 @@
|
||||||
package code.name.monkey.retromusic.util.theme
|
package code.name.monkey.retromusic.util.theme
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import androidx.annotation.StyleRes
|
import androidx.annotation.StyleRes
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import code.name.monkey.retromusic.App
|
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.extensions.generalThemeValue
|
import code.name.monkey.retromusic.extensions.generalThemeValue
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import code.name.monkey.retromusic.util.theme.ThemeMode.*
|
import code.name.monkey.retromusic.util.theme.ThemeMode.*
|
||||||
|
|
||||||
object ThemeManager {
|
@StyleRes
|
||||||
|
fun Context.getThemeResValue(): Int =
|
||||||
@StyleRes
|
|
||||||
fun getThemeResValue(): Int =
|
|
||||||
if (PreferenceUtil.materialYou) {
|
if (PreferenceUtil.materialYou) {
|
||||||
R.style.Theme_RetroMusic_MD3
|
R.style.Theme_RetroMusic_MD3
|
||||||
} else {
|
} else {
|
||||||
when (App.getContext().generalThemeValue) {
|
when (generalThemeValue) {
|
||||||
LIGHT -> R.style.Theme_RetroMusic_Light
|
LIGHT -> R.style.Theme_RetroMusic_Light
|
||||||
DARK -> R.style.Theme_RetroMusic_Base
|
DARK -> R.style.Theme_RetroMusic_Base
|
||||||
BLACK -> R.style.Theme_RetroMusic_Black
|
BLACK -> R.style.Theme_RetroMusic_Black
|
||||||
|
@ -23,9 +21,8 @@ object ThemeManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getNightMode(): Int = when (App.getContext().generalThemeValue) {
|
fun Context.getNightMode(): Int = when (generalThemeValue) {
|
||||||
LIGHT -> AppCompatDelegate.MODE_NIGHT_NO
|
LIGHT -> AppCompatDelegate.MODE_NIGHT_NO
|
||||||
DARK -> AppCompatDelegate.MODE_NIGHT_YES
|
DARK -> AppCompatDelegate.MODE_NIGHT_YES
|
||||||
else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue