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