Code Cleanup
This commit is contained in:
parent
8b5b6d0e64
commit
608c265390
5 changed files with 38 additions and 35 deletions
|
@ -132,7 +132,7 @@ class WhatsNewFragment : BottomSheetDialogFragment() {
|
|||
fun showChangeLog(activity: FragmentActivity) {
|
||||
val pInfo = activity.packageManager.getPackageInfo(activity.packageName, 0)
|
||||
val currentVersion = PackageInfoCompat.getLongVersionCode(pInfo)
|
||||
if (currentVersion > lastVersion && BuildConfig.DEBUG) {
|
||||
if (currentVersion > lastVersion && !BuildConfig.DEBUG) {
|
||||
val changelogBottomSheet = WhatsNewFragment()
|
||||
changelogBottomSheet.show(activity.supportFragmentManager, TAG)
|
||||
}
|
||||
|
|
|
@ -82,6 +82,11 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search),
|
|||
doAfterTextChanged {
|
||||
if (!it.isNullOrEmpty())
|
||||
search(it.toString())
|
||||
else {
|
||||
TransitionManager.beginDelayedTransition(binding.appBarLayout)
|
||||
binding.voiceSearch.isVisible = true
|
||||
binding.clearText.isGone = true
|
||||
}
|
||||
}
|
||||
focusAndShowKeyboard()
|
||||
}
|
||||
|
@ -210,7 +215,8 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search),
|
|||
}
|
||||
}
|
||||
|
||||
private val speechInputLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result->
|
||||
private val speechInputLauncher =
|
||||
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
|
||||
if (result.resultCode == RESULT_OK) {
|
||||
val spokenText: String? =
|
||||
result?.data?.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS)?.get(0)
|
||||
|
|
|
@ -58,6 +58,7 @@ import code.name.monkey.retromusic.auto.AutoMusicProvider
|
|||
import code.name.monkey.retromusic.extensions.showToast
|
||||
import code.name.monkey.retromusic.glide.BlurTransformation
|
||||
import code.name.monkey.retromusic.glide.GlideApp
|
||||
import code.name.monkey.retromusic.glide.RetroGlideExtension.getDefaultTransition
|
||||
import code.name.monkey.retromusic.glide.RetroGlideExtension.getSongModel
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote.isCasting
|
||||
import code.name.monkey.retromusic.helper.ShuffleHelper.makeShuffleList
|
||||
|
@ -91,7 +92,6 @@ import code.name.monkey.retromusic.util.PreferenceUtil.unregisterOnSharedPrefere
|
|||
import code.name.monkey.retromusic.volume.AudioVolumeObserver
|
||||
import code.name.monkey.retromusic.volume.OnAudioVolumeChangedListener
|
||||
import com.bumptech.glide.request.target.CustomTarget
|
||||
import com.bumptech.glide.request.target.Target
|
||||
import com.bumptech.glide.request.transition.Transition
|
||||
import org.koin.java.KoinJavaComponent.get
|
||||
import java.util.*
|
||||
|
@ -642,7 +642,7 @@ class MusicService : MediaBrowserServiceCompat(),
|
|||
override fun onGetRoot(
|
||||
clientPackageName: String,
|
||||
clientUid: Int,
|
||||
rootHints: Bundle?
|
||||
rootHints: Bundle?,
|
||||
): BrowserRoot {
|
||||
|
||||
|
||||
|
@ -671,7 +671,7 @@ class MusicService : MediaBrowserServiceCompat(),
|
|||
|
||||
override fun onLoadChildren(
|
||||
parentId: String,
|
||||
result: Result<List<MediaBrowserCompat.MediaItem>>
|
||||
result: Result<List<MediaBrowserCompat.MediaItem>>,
|
||||
) {
|
||||
if (parentId == AutoMediaIDHelper.RECENT_ROOT) {
|
||||
val song = currentSong
|
||||
|
@ -690,7 +690,7 @@ class MusicService : MediaBrowserServiceCompat(),
|
|||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(
|
||||
sharedPreferences: SharedPreferences, key: String
|
||||
sharedPreferences: SharedPreferences, key: String,
|
||||
) {
|
||||
when (key) {
|
||||
CROSS_FADE_DURATION -> {
|
||||
|
@ -799,7 +799,7 @@ class MusicService : MediaBrowserServiceCompat(),
|
|||
fun openQueue(
|
||||
playingQueue: List<Song>?,
|
||||
startPosition: Int,
|
||||
startPlaying: Boolean
|
||||
startPlaying: Boolean,
|
||||
) {
|
||||
if (playingQueue != null && playingQueue.isNotEmpty()
|
||||
&& startPosition >= 0 && startPosition < playingQueue.size
|
||||
|
@ -1141,10 +1141,13 @@ class MusicService : MediaBrowserServiceCompat(),
|
|||
.putLong(MediaMetadataCompat.METADATA_KEY_NUM_TRACKS, playingQueue.size.toLong())
|
||||
|
||||
if (isAlbumArtOnLockScreen) {
|
||||
val request = GlideApp.with(this@MusicService)
|
||||
// val screenSize: Point = RetroUtil.getScreenSize(this)
|
||||
val request = GlideApp.with(this)
|
||||
.asBitmap()
|
||||
.songCoverOptions(song)
|
||||
.load(getSongModel(song))
|
||||
.transition(getDefaultTransition())
|
||||
|
||||
if (isBlurredAlbumArt) {
|
||||
request.transform(BlurTransformation.Builder(this@MusicService).build())
|
||||
}
|
||||
|
@ -1158,7 +1161,7 @@ class MusicService : MediaBrowserServiceCompat(),
|
|||
|
||||
override fun onResourceReady(
|
||||
resource: Bitmap,
|
||||
transition: Transition<in Bitmap?>?
|
||||
transition: Transition<in Bitmap?>?,
|
||||
) {
|
||||
metaData.putBitmap(
|
||||
MediaMetadataCompat.METADATA_KEY_ALBUM_ART,
|
||||
|
|
|
@ -16,18 +16,14 @@ package code.name.monkey.retromusic.util
|
|||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.content.res.Resources
|
||||
import code.name.monkey.retromusic.App.Companion.getContext
|
||||
import android.view.WindowManager
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.ColorInt
|
||||
import android.graphics.drawable.Drawable
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
import android.content.res.Resources.Theme
|
||||
import android.graphics.Point
|
||||
import android.view.Display
|
||||
import android.graphics.drawable.Drawable
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.core.view.DisplayCompat
|
||||
import java.lang.Exception
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
import code.name.monkey.retromusic.App.Companion.getContext
|
||||
import java.net.InetAddress
|
||||
import java.net.NetworkInterface
|
||||
import java.text.DecimalFormat
|
||||
|
@ -50,14 +46,10 @@ object RetroUtil {
|
|||
return (frequency / 1000.0).toFloat()
|
||||
}
|
||||
|
||||
fun getScreenSize(c: Context): Point {
|
||||
var display: Display? = null
|
||||
if (c.getSystemService(Context.WINDOW_SERVICE) != null) {
|
||||
display = (c.getSystemService(Context.WINDOW_SERVICE) as WindowManager).defaultDisplay
|
||||
}
|
||||
val size = Point()
|
||||
display?.getSize(size)
|
||||
return size
|
||||
fun getScreenSize(context: Context): Point {
|
||||
val x: Int = context.resources.displayMetrics.widthPixels
|
||||
val y: Int = context.resources.displayMetrics.heightPixels
|
||||
return Point(x, y)
|
||||
}
|
||||
|
||||
val statusBarHeight: Int
|
||||
|
@ -85,7 +77,9 @@ object RetroUtil {
|
|||
}
|
||||
|
||||
fun getTintedVectorDrawable(
|
||||
context: Context, @DrawableRes id: Int, @ColorInt color: Int
|
||||
context: Context,
|
||||
@DrawableRes id: Int,
|
||||
@ColorInt color: Int,
|
||||
): Drawable {
|
||||
return TintHelper.createTintedDrawable(
|
||||
getVectorDrawable(context.resources, id, context.theme), color)
|
||||
|
@ -95,13 +89,13 @@ object RetroUtil {
|
|||
res: Resources,
|
||||
@DrawableRes resId: Int,
|
||||
theme: Theme?,
|
||||
@ColorInt color: Int
|
||||
@ColorInt color: Int,
|
||||
): Drawable {
|
||||
return TintHelper.createTintedDrawable(getVectorDrawable(res, resId, theme), color)
|
||||
}
|
||||
|
||||
private fun getVectorDrawable(
|
||||
res: Resources, @DrawableRes resId: Int, theme: Theme?
|
||||
res: Resources, @DrawableRes resId: Int, theme: Theme?,
|
||||
): Drawable? {
|
||||
return ResourcesCompat.getDrawable(res, resId, theme)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue