Code refactor
This commit is contained in:
parent
416ee91c39
commit
6d0898a49a
15 changed files with 59 additions and 25 deletions
|
@ -79,4 +79,13 @@
|
|||
<item name="android:padding">16dp</item>
|
||||
</style>
|
||||
|
||||
<style name="ToolbarTextAppearanceNormal">
|
||||
<item name="android:textStyle">bold</item>
|
||||
<item name="android:textAllCaps">false</item>
|
||||
<item name="android:textAppearance">@style/TextViewHeadline6</item>
|
||||
<item name="fontFamily">@font/sans</item>
|
||||
<item name="android:textSize">20sp</item>
|
||||
<item name="android:letterSpacing">0.0125</item>
|
||||
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
||||
</style>
|
||||
</resources>
|
|
@ -78,7 +78,6 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
|
||||
libraryViewModel.paletteColorLiveData.observe(this, Observer {
|
||||
this.paletteColor = it
|
||||
miniPlayerFragment?.updateProgressBar(it)
|
||||
onPaletteColorChanged()
|
||||
})
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public class DeviceInfo {
|
|||
return "Device info:\n"
|
||||
+ "---\n"
|
||||
+ "<table>\n"
|
||||
+ "<tr><td>App version</td><td>" + versionName + "</td></tr>\n"
|
||||
+ "<tr><td><b>App version</b></td><td>" + versionName + "</td></tr>\n"
|
||||
+ "<tr><td>App version code</td><td>" + versionCode + "</td></tr>\n"
|
||||
+ "<tr><td>Android build version</td><td>" + buildVersion + "</td></tr>\n"
|
||||
+ "<tr><td>Android release version</td><td>" + releaseVersion + "</td></tr>\n"
|
||||
|
|
|
@ -53,8 +53,8 @@ class SleepTimerDialog : DialogFragment() {
|
|||
@SuppressLint("InflateParams")
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
timerUpdater = TimerUpdater()
|
||||
val layout = LayoutInflater.from(requireContext())
|
||||
.inflate(R.layout.dialog_sleep_timer, null)
|
||||
val layout =
|
||||
LayoutInflater.from(requireContext()).inflate(R.layout.dialog_sleep_timer, null)
|
||||
shouldFinishLastSong = layout.findViewById(R.id.shouldFinishLastSong)
|
||||
seekBar = layout.findViewById(R.id.seekBar)
|
||||
timerDisplay = layout.findViewById(R.id.timerDisplay)
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.os.Bundle
|
|||
import android.view.*
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.findNavController
|
||||
|
@ -14,7 +15,6 @@ import androidx.navigation.fragment.navArgs
|
|||
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.common.ATHToolbarActivity.getToolbarBackgroundColor
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import code.name.monkey.retromusic.EXTRA_ALBUM_ID
|
||||
|
@ -76,9 +76,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
|||
mainActivity.hideBottomBarVisibility(false)
|
||||
mainActivity.addMusicServiceEventListener(detailsViewModel)
|
||||
mainActivity.setSupportActionBar(toolbar)
|
||||
|
||||
toolbar.title = null
|
||||
|
||||
toolbar.title = " "
|
||||
postponeEnterTransition()
|
||||
detailsViewModel.getAlbum().observe(viewLifecycleOwner, Observer {
|
||||
startPostponedEnterTransition()
|
||||
|
@ -148,7 +146,6 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
|||
album.songCount
|
||||
)
|
||||
songTitle.text = songText
|
||||
|
||||
if (MusicUtil.getYearString(album.year) == "-") {
|
||||
albumText.text = String.format(
|
||||
"%s • %s",
|
||||
|
@ -207,7 +204,10 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
|||
aboutAlbumTitle.show()
|
||||
aboutAlbumTitle.text =
|
||||
String.format(getString(R.string.about_album_label), lastFmAlbum.album.name)
|
||||
aboutAlbumText.text = lastFmAlbum.album.wiki.content
|
||||
aboutAlbumText.text = HtmlCompat.fromHtml(
|
||||
lastFmAlbum.album.wiki.content,
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
}
|
||||
if (lastFmAlbum.album.listeners.isNotEmpty()) {
|
||||
listeners.show()
|
||||
|
@ -250,10 +250,8 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
|||
}
|
||||
|
||||
private fun setColors(color: Int) {
|
||||
val finalColor =
|
||||
if (PreferenceUtil.isAdaptiveColor) color else ThemeStore.accentColor(requireContext())
|
||||
shuffleAction.applyColor(finalColor)
|
||||
playAction.applyOutlineColor(finalColor)
|
||||
shuffleAction.applyColor(color)
|
||||
playAction.applyOutlineColor(color)
|
||||
}
|
||||
|
||||
override fun onAlbumClick(albumId: Int, view: View) {
|
||||
|
|
|
@ -63,7 +63,7 @@ class MainSettingsFragment : Fragment(), View.OnClickListener {
|
|||
aboutSettings.setOnClickListener(this)
|
||||
|
||||
buyProContainer.apply {
|
||||
if (!App.isProVersion()) show() else hide()
|
||||
if (App.isProVersion()) hide() else show()
|
||||
setOnClickListener {
|
||||
NavigationUtil.goToProVersion(requireContext())
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import android.content.Context
|
|||
import android.database.Cursor
|
||||
import android.provider.MediaStore
|
||||
import android.provider.MediaStore.Audio.AudioColumns
|
||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||
import code.name.monkey.retromusic.Constants.IS_MUSIC
|
||||
import code.name.monkey.retromusic.Constants.baseProjection
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
|
@ -152,8 +153,16 @@ class RealSongRepository(private val context: Context) : SongRepository {
|
|||
selectionFinal =
|
||||
selectionFinal + " AND " + MediaStore.Audio.Media.DURATION + ">= " + (PreferenceUtil.filterLength * 1000)
|
||||
|
||||
|
||||
val uri = if (VersionUtils.hasQ()) {
|
||||
|
||||
MediaStore.Audio.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY)
|
||||
} else {
|
||||
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI
|
||||
}
|
||||
|
||||
return context.contentResolver.query(
|
||||
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
|
||||
uri,
|
||||
baseProjection,
|
||||
selectionFinal,
|
||||
selectionValuesFinal,
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<com.google.android.material.card.MaterialCardView 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"
|
||||
style="@style/MaterialCardViewStroke"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="8dp"
|
||||
|
@ -30,8 +31,7 @@
|
|||
android:background="?rectSelector"
|
||||
android:lineSpacingExtra="8dp"
|
||||
android:padding="16dp"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textAppearance="@style/TextViewBody1"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
<com.google.android.material.card.MaterialCardView 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"
|
||||
style="@style/MaterialCardViewStroke"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="4dp"
|
||||
app:cardCornerRadius="@dimen/about_card_radius">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
style="@style/MaterialCardViewStroke"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="4dp"
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
style="@style/MaterialCardViewStroke"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="4dp"
|
||||
app:cardCornerRadius="@dimen/about_card_radius">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
style="@style/MaterialCardViewStroke"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="4dp"
|
||||
app:cardCornerRadius="@dimen/about_card_radius">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/buyProContainer"
|
||||
style="@style/MaterialCardViewStroke"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="4dp"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardUseCompatPadding="true">
|
||||
app:cardCornerRadius="8dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -240,10 +240,14 @@
|
|||
</style>
|
||||
|
||||
|
||||
|
||||
<style name="Widget.BottomSheet" parent="Widget.MaterialComponents.BottomSheet">
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
<style name="MaterialCardViewStroke">
|
||||
<item name="cardUseCompatPadding">true</item>
|
||||
<item name="strokeWidth">1dp</item>
|
||||
<item name="strokeColor">?android:attr/colorButtonNormal</item>
|
||||
<item name="cardElevation">0dp</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
|
@ -42,4 +42,18 @@ object VersionUtils {
|
|||
fun hasOreo(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if device is running API >= 27
|
||||
*/
|
||||
fun hasP(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.P
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if device is running API >= 28
|
||||
*/
|
||||
fun hasQ(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue