Merge pull request #1173 from prathameshmm02/dev

Fixed some bugs & visual inconsistencies
This commit is contained in:
Daksh P. Jain 2021-11-25 16:52:17 +05:30 committed by GitHub
commit be460124ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 221 additions and 158 deletions

View file

@ -9,14 +9,14 @@ android {
defaultConfig {
minSdkVersion 21
targetSdkVersion 31
targetSdkVersion 30
renderscriptTargetApi 29//must match target sdk and build tools
vectorDrawables.useSupportLibrary = true
applicationId "code.name.monkey.retromusic"
versionCode 10543
versionName '5.4.0 ' + "_" + getDate()
versionCode 10544
versionName '5.4.1 ' + "_" + getDate()
buildConfigField("String", "GOOGLE_PLAY_LICENSING_KEY", "\"${getProperty(getProperties('../public.properties'), 'GOOGLE_PLAY_LICENSE_KEY')}\"")
}
@ -110,7 +110,7 @@ dependencies {
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
def room_version = "2.3.0"
def room_version = '2.4.0-beta02'
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.room:room-ktx:$room_version"
kapt "androidx.room:room-compiler:$room_version"
@ -154,7 +154,7 @@ dependencies {
implementation 'org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5'
implementation 'com.github.AdrienPoupa:jaudiotagger:2.2.3'
implementation 'com.anjlab.android.iab.v3:library:2.0.1'
implementation 'com.anjlab.android.iab.v3:library:2.0.3'
implementation 'com.r0adkll:slidableactivity:2.1.0'
implementation 'com.heinrichreimersoftware:material-intro:2.0.0'
implementation 'com.github.dhaval2404:imagepicker:1.7.1'

View file

@ -64,7 +64,7 @@
<body>
<div>
<h5>Date</h5>
<h2>v5.1.0<span class="tag"><i>Beta</i></span></h2>
<h2>v5.4.0<span class="tag"><i>Beta</i></span></h2>
<h3>What's New</h3>
<ul>
<li><b>Material You</b></li>
@ -73,6 +73,7 @@
</ul>
<h3>Improved</h3>
<ul>
<li>Improved Animations</li>
<li>Improved Crossfade</li>
</ul>
</div>

View file

@ -129,7 +129,6 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
if (RetroUtil.isLandscape()) {
binding.slidingPanel.drawAboveSystemBarsWithPadding(true)
}
binding.fragmentContainer.addBottomInsets()
chooseFragmentForTheme()
setupSlidingUpPanel()
setupBottomSheet()
@ -235,7 +234,9 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
super.onQueueChanged()
// Mini player should be hidden in Playing Queue
// it may pop up if hideBottomSheet is called
if (currentFragment(R.id.fragment_container) !is PlayingQueueFragment) {
if (currentFragment(R.id.fragment_container) !is PlayingQueueFragment &&
bottomSheetBehavior.state != STATE_EXPANDED
) {
hideBottomSheet(MusicPlayerRemote.playingQueue.isEmpty())
}
}
@ -350,7 +351,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
binding.bottomNavigationView.translationY = 0F
}
binding.bottomNavigationView.bringToFront()
libraryViewModel.setFabMargin(heightOfBarWithTabs - 2 * windowInsets.safeGetBottomInsets())
libraryViewModel.setFabMargin(dip(R.dimen.mini_player_height_expanded))
} else {
println("Details")
if (animate) {
@ -367,7 +368,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
dip(R.dimen.bottom_nav_height).toFloat()
binding.slidingPanel.bringToFront()
}
libraryViewModel.setFabMargin(heightOfBar - 2 * windowInsets.safeGetBottomInsets())
libraryViewModel.setFabMargin(dip(R.dimen.mini_player_height))
}
}
}

View file

@ -44,6 +44,7 @@ import code.name.monkey.retromusic.util.RetroColorUtil.getColor
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.request.target.ImageViewTarget
import com.bumptech.glide.request.transition.Transition
import com.google.android.material.shape.MaterialShapeDrawable
import org.jaudiotagger.tag.FieldKey
import java.util.*
@ -101,8 +102,9 @@ class AlbumTagEditorActivity : AbsTagEditorActivity<ActivityAlbumTagEditorBindin
private var deleteAlbumArt: Boolean = false
private fun setupToolbar() {
binding.toolbar.setBackgroundColor(ATHUtil.resolveColor(this, R.attr.colorSurface))
setSupportActionBar(binding.toolbar)
binding.appBarLayout?.statusBarForeground =
MaterialShapeDrawable.createWithElevationOverlay(this)
}
override fun onCreate(savedInstanceState: Bundle?) {

View file

@ -21,13 +21,12 @@ import android.text.Editable
import android.text.TextWatcher
import android.view.LayoutInflater
import android.widget.ImageView
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.databinding.ActivitySongTagEditorBinding
import code.name.monkey.retromusic.extensions.appHandleColor
import code.name.monkey.retromusic.extensions.setTint
import code.name.monkey.retromusic.repository.SongRepository
import code.name.monkey.retromusic.util.MusicUtil
import com.google.android.material.shape.MaterialShapeDrawable
import org.jaudiotagger.tag.FieldKey
import org.koin.android.ext.android.inject
import java.util.*
@ -44,8 +43,9 @@ class SongTagEditorActivity : AbsTagEditorActivity<ActivitySongTagEditorBinding>
super.onCreate(savedInstanceState)
setUpViews()
setNoImageMode()
binding.toolbar.setBackgroundColor(ATHUtil.resolveColor(this, R.attr.colorSurface))
setSupportActionBar(binding.toolbar)
binding.appBarLayout.statusBarForeground =
MaterialShapeDrawable.createWithElevationOverlay(this)
}
@SuppressLint("ClickableViewAccessibility")

View file

@ -90,9 +90,9 @@ class DeleteSongsDialog : DialogFragment() {
if ((songs.size == 1) && MusicPlayerRemote.isPlaying(songs[0])) {
MusicPlayerRemote.playNextSong()
}
if (VersionUtils.hasQ()) {
if (VersionUtils.hasR()) {
dismiss()
MusicUtil.deleteTracksQ(requireActivity(), songs)
MusicUtil.deleteTracksR(requireActivity(), songs)
reloadTabs()
} else if (!SAFUtil.isSAFRequiredForSongs(songs)) {
CoroutineScope(Dispatchers.IO).launch {

View file

@ -138,7 +138,7 @@ class SleepTimerDialog : DialogFragment() {
}
private fun makeTimerPendingIntent(flag: Int): PendingIntent? {
return PendingIntent.getService(requireActivity(), 0, makeTimerIntent(), flag)
return PendingIntent.getService(requireActivity(), 0, makeTimerIntent(), flag or PendingIntent.FLAG_IMMUTABLE)
}
private fun makeTimerIntent(): Intent {

View file

@ -237,6 +237,6 @@ data class InitialPadding(
val right: Int, val bottom: Int
)
private fun recordInitialPaddingForView(view: View) = InitialPadding(
fun recordInitialPaddingForView(view: View) = InitialPadding(
view.paddingLeft, view.paddingTop, view.paddingRight, view.paddingBottom
)

View file

@ -14,6 +14,7 @@
*/
package code.name.monkey.retromusic.fragments
import android.animation.ValueAnimator
import android.widget.Toast
import androidx.lifecycle.*
import code.name.monkey.retromusic.*
@ -42,7 +43,7 @@ class LibraryViewModel(
private val legacyPlaylists = MutableLiveData<List<Playlist>>()
private val genres = MutableLiveData<List<Genre>>()
private val searchResults = MutableLiveData<List<Any>>()
private val fabMargin = MutableLiveData(0)
private val fabMargin = MutableLiveData<Int>(0)
val paletteColor: LiveData<Int> = _paletteColor
init {
@ -337,12 +338,19 @@ class LibraryViewModel(
}
fun setFabMargin(bottomMargin: Int) {
fabMargin.postValue(
// Normal Margin
DensityUtil.dip2px(App.getContext(), 16F) +
val currentValue = DensityUtil.dip2px(App.getContext(), 16F) +
bottomMargin
if (currentValue != fabMargin.value) {
ValueAnimator.ofInt(fabMargin.value!!, currentValue).apply {
addUpdateListener {
fabMargin.postValue(
it.animatedValue as Int
)
}
start()
}
}
}
}
enum class ReloadType {

View file

@ -49,7 +49,7 @@ class AboutFragment : Fragment(R.layout.fragment_about), View.OnClickListener {
// insets are not passed to child views
// https://github.com/material-components/material-components-android/issues/1310
if (!RetroUtil.isLandscape()) {
binding.root.updatePadding(bottom = RetroUtil.getNavigationBarHeight())
binding.aboutContent.root.updatePadding(bottom = RetroUtil.getNavigationBarHeight())
}
}

View file

@ -1,10 +1,12 @@
package code.name.monkey.retromusic.fragments.backup
import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.view.MenuItem
import android.view.View
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AlertDialog
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
@ -16,9 +18,11 @@ import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.adapter.backup.BackupAdapter
import code.name.monkey.retromusic.databinding.FragmentBackupBinding
import code.name.monkey.retromusic.helper.BackupHelper
import code.name.monkey.retromusic.helper.sanitize
import code.name.monkey.retromusic.util.BackupUtil
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.input.input
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import java.io.File
@ -42,25 +46,16 @@ class BackupFragment : Fragment(R.layout.fragment_backup), BackupAdapter.BackupC
backupAdapter?.swapDataset(listOf())
}
backupViewModel.loadBackups()
setupButtons()
val openFilePicker = registerForActivityResult(ActivityResultContracts.OpenDocument()) {
lifecycleScope.launch(Dispatchers.IO) {
backupViewModel.restoreBackup(requireActivity(), requireContext().contentResolver.openInputStream(it))
}
}
private fun setupButtons() {
binding.createBackup.setOnClickListener {
MaterialDialog(requireContext()).show {
title(res = R.string.action_rename)
input(prefill = System.currentTimeMillis().toString()) { _, text ->
// Text submitted with the action button
lifecycleScope.launch {
BackupHelper.createBackup(requireContext(), text.toString())
backupViewModel.loadBackups()
showCreateBackupDialog()
}
}
positiveButton(android.R.string.ok)
negativeButton(R.string.action_cancel)
setTitle(R.string.title_new_backup)
}
binding.restoreBackup.setOnClickListener {
openFilePicker.launch(arrayOf("application/octet-stream"))
}
}
@ -76,7 +71,6 @@ class BackupFragment : Fragment(R.layout.fragment_backup), BackupAdapter.BackupC
private fun checkIsEmpty() {
val isEmpty = backupAdapter!!.itemCount == 0
binding.empty.isVisible = isEmpty
binding.backupTitle.isVisible = !isEmpty
binding.backupRecyclerview.isVisible = !isEmpty
}
@ -88,13 +82,31 @@ class BackupFragment : Fragment(R.layout.fragment_backup), BackupAdapter.BackupC
}
}
@SuppressLint("CheckResult")
private fun showCreateBackupDialog() {
MaterialDialog(requireContext()).show {
cornerRadius(res = R.dimen.m3_card_corner_radius)
title(res = R.string.action_rename)
input(prefill = System.currentTimeMillis().toString()) { _, text ->
// Text submitted with the action button
lifecycleScope.launch {
BackupHelper.createBackup(requireContext(), text.sanitize())
backupViewModel.loadBackups()
}
}
positiveButton(android.R.string.ok)
negativeButton(R.string.action_cancel)
setTitle(R.string.title_new_backup)
}
}
override fun onBackupClicked(file: File) {
AlertDialog.Builder(requireContext())
.setTitle(R.string.restore)
.setMessage(R.string.restore_message)
.setPositiveButton(R.string.restore) { _, _ ->
lifecycleScope.launch {
backupViewModel.restoreBackup(requireActivity(), file)
backupViewModel.restoreBackup(requireActivity(), file.inputStream())
}
}
.setNegativeButton(android.R.string.cancel, null)
@ -102,6 +114,7 @@ class BackupFragment : Fragment(R.layout.fragment_backup), BackupAdapter.BackupC
.show()
}
@SuppressLint("CheckResult")
override fun onBackupMenuClicked(file: File, menuItem: MenuItem): Boolean {
when (menuItem.itemId) {
R.id.action_delete -> {
@ -119,7 +132,11 @@ class BackupFragment : Fragment(R.layout.fragment_backup), BackupAdapter.BackupC
}
R.id.action_share -> {
activity?.startActivity(
Intent.createChooser(BackupUtil.createShareFileIntent(file, requireContext()), null))
Intent.createChooser(
BackupUtil.createShareFileIntent(file, requireContext()),
null
)
)
return true
}
R.id.action_rename -> {

View file

@ -9,6 +9,7 @@ import code.name.monkey.retromusic.helper.BackupHelper
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.io.File
import java.io.InputStream
import kotlin.system.exitProcess
@ -24,8 +25,8 @@ class BackupViewModel : ViewModel() {
}
}
suspend fun restoreBackup(activity: Activity, file: File) {
BackupHelper.restoreBackup(activity, file)
suspend fun restoreBackup(activity: Activity, inputStream: InputStream?) {
BackupHelper.restoreBackup(activity, inputStream)
withContext(Dispatchers.Main) {
val intent = Intent(
activity,

View file

@ -22,7 +22,6 @@ import androidx.appcompat.widget.Toolbar
import androidx.core.view.doOnPreDraw
import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams
import androidx.core.view.updatePadding
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.RecyclerView
import code.name.monkey.appthemehelper.common.ATHToolbarActivity
@ -161,11 +160,9 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
val itemCount: Int = adapter?.itemCount ?: 0
if (itemCount > 0 && MusicPlayerRemote.playingQueue.isNotEmpty()) {
val height = dip(R.dimen.mini_player_height_expanded)
binding.recyclerView.updatePadding(0, 0, 0, height)
binding.recyclerView.updatePadding(bottom = dip(R.dimen.mini_player_height_expanded))
} else {
val height = dip(R.dimen.mini_player_height)
binding.recyclerView.updatePadding(0, 0, 0, height)
binding.recyclerView.updatePadding(bottom = dip(R.dimen.mini_player_height))
}
}

View file

@ -89,7 +89,7 @@ class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_de
override fun onChanged() {
super.onChanged()
val height = dipToPix(52f)
binding.recyclerView.setPadding(0, 0, 0, height.toInt())
binding.recyclerView.updatePadding(bottom = height.toInt())
}
})
}
@ -204,7 +204,7 @@ class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_de
if (RetroUtil.isTablet()) {
return if (RetroUtil.isLandscape()) 6 else 4
}
return 2
return if (RetroUtil.isLandscape()) 4 else 2
}
override fun onArtist(artistId: Long, view: View) {

View file

@ -379,6 +379,7 @@ class LyricsFragment : AbsMusicServiceFragment(R.layout.fragment_lyrics) {
override fun onDestroyView() {
super.onDestroyView()
if (MusicPlayerRemote.playingQueue.isNotEmpty())
(requireActivity() as MainActivity).expandPanel()
}
}

View file

@ -23,7 +23,9 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.MainActivity
import code.name.monkey.retromusic.adapter.song.PlayingQueueAdapter
import code.name.monkey.retromusic.databinding.FragmentPlayingQueueBinding
import code.name.monkey.retromusic.extensions.accentColor
@ -172,6 +174,8 @@ class PlayingQueueFragment : AbsMusicServiceFragment(R.layout.fragment_playing_q
}
playingQueueAdapter = null
super.onDestroy()
if (MusicPlayerRemote.playingQueue.isNotEmpty())
(requireActivity() as MainActivity).expandPanel()
}
private fun setupToolbar() {
@ -191,6 +195,7 @@ class PlayingQueueFragment : AbsMusicServiceFragment(R.layout.fragment_playing_q
findNavController().navigateUp()
}
setNavigationIcon(R.drawable.ic_keyboard_backspace_black)
ToolbarContentTintHelper.colorBackButton(this)
}
}
}

View file

@ -40,6 +40,7 @@ import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.views.addAlpha
import com.google.android.material.chip.Chip
import com.google.android.material.chip.ChipGroup
import com.google.android.material.shape.MaterialShapeDrawable
import com.google.android.material.textfield.TextInputEditText
import com.google.android.material.transition.MaterialSharedAxis
import java.util.*
@ -96,6 +97,8 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
bottomMargin = it
}
})
binding.appBarLayout.statusBarForeground =
MaterialShapeDrawable.createWithElevationOverlay(requireContext())
}
private fun setupChips() {

View file

@ -66,7 +66,6 @@ abstract class AbsSettingsFragment : ATEPreferenceFragmentCompat() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setDivider(ColorDrawable(Color.TRANSPARENT))
listView.overScrollMode = View.OVER_SCROLL_NEVER
// This is a workaround as CollapsingToolbarLayout consumes insets and
// insets are not passed to child views
// https://github.com/material-components/material-components-android/issues/1310

View file

@ -19,15 +19,18 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.updatePadding
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.databinding.FragmentMainSettingsBinding
import code.name.monkey.retromusic.extensions.addBottomInsets
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.extensions.show
import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.RetroUtil
class MainSettingsFragment : Fragment(), View.OnClickListener {
@ -84,6 +87,9 @@ class MainSettingsFragment : Fragment(), View.OnClickListener {
binding.buyPremium.setTextColor(it)
binding.diamondIcon.imageTintList = ColorStateList.valueOf(it)
}
if (!RetroUtil.isLandscape()) {
binding.container.updatePadding(bottom = RetroUtil.getNavigationBarHeight())
}
}
override fun onDestroyView() {

View file

@ -15,7 +15,7 @@ import java.util.zip.ZipOutputStream
object BackupHelper {
suspend fun createBackup(context: Context, name: String) {
val backupFile =
File(backupRootPath + name + APPEND_EXTENSION)
File(backupRootPath + File.separator + name + APPEND_EXTENSION)
if (backupFile.parentFile?.exists() != true) {
backupFile.parentFile?.mkdirs()
}
@ -28,7 +28,7 @@ object BackupHelper {
}
}
private fun zipAll(zipItems: List<ZipItem>, backupFile: File) {
private suspend fun zipAll(zipItems: List<ZipItem>, backupFile: File) {
try {
ZipOutputStream(BufferedOutputStream(FileOutputStream(backupFile))).use { out ->
for (zipItem in zipItems) {
@ -36,13 +36,17 @@ object BackupHelper {
BufferedInputStream(fi).use { origin ->
val entry = ZipEntry(zipItem.zipPath)
out.putNextEntry(entry)
origin.copyTo(out, 1024)
origin.copyTo(out)
}
}
}
}
} catch (exception: FileNotFoundException) {
Toast.makeText(App.getContext(), "Couldn't create backup", Toast.LENGTH_SHORT).show()
exception.printStackTrace()
withContext(Dispatchers.Main) {
Toast.makeText(App.getContext(), "Couldn't create backup", Toast.LENGTH_SHORT)
.show()
}
}
}
@ -72,9 +76,9 @@ object BackupHelper {
}
}
suspend fun restoreBackup(context: Context, file: File) {
suspend fun restoreBackup(context: Context, inputStream: InputStream?) {
withContext(Dispatchers.IO) {
ZipInputStream(FileInputStream(file)).use {
ZipInputStream(inputStream).use {
var entry = it.nextEntry
while (entry != null) {
if (entry.isDatabaseEntry()) restoreDatabase(context, it, entry)
@ -157,3 +161,16 @@ object BackupHelper {
}
data class ZipItem(val filePath: String, val zipPath: String)
fun CharSequence.sanitize(): String {
return toString().replace("/", "_")
.replace(":", "_")
.replace("*", "_")
.replace("?", "_")
.replace("\"", "_")
.replace("<", "_")
.replace(">", "_")
.replace("|", "_")
.replace("\\", "_")
.replace("&", "_")
}

View file

@ -72,6 +72,7 @@ interface Repository {
suspend fun genresHome(): Home
suspend fun playlists(): Home
suspend fun homeSections(): List<Home>
@ExperimentalCoroutinesApi
suspend fun homeSectionsFlow(): Flow<Result<List<Home>>>
suspend fun playlist(playlistId: Long): Playlist
suspend fun fetchPlaylistWithSongs(): List<PlaylistWithSongs>

View file

@ -525,7 +525,7 @@ object MusicUtil : KoinComponent {
}
@RequiresApi(Build.VERSION_CODES.R)
fun deleteTracksQ(activity: Activity, songs: List<Song>) {
fun deleteTracksR(activity: Activity, songs: List<Song>) {
val pendingIntent = MediaStore.createDeleteRequest(activity.contentResolver, songs.map {
getSongFileUri(it.id)
})

View file

@ -7,6 +7,7 @@ import androidx.core.content.ContextCompat
import androidx.core.content.edit
import androidx.preference.PreferenceManager
import androidx.viewpager.widget.ViewPager
import code.name.monkey.appthemehelper.util.VersionUtils
import code.name.monkey.retromusic.*
import code.name.monkey.retromusic.extensions.getIntRes
import code.name.monkey.retromusic.extensions.getStringOrDefault
@ -615,5 +616,5 @@ object PreferenceUtil {
.getInt(CROSS_FADE_DURATION, 0)
val materialYou
get() = sharedPreferences.getBoolean(MATERIAL_YOU, false)
get() = sharedPreferences.getBoolean(MATERIAL_YOU, VersionUtils.hasS())
}

View file

@ -0,0 +1,23 @@
package code.name.monkey.retromusic.views.insets
import android.content.Context
import android.util.AttributeSet
import android.view.WindowInsets
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.WindowInsetsCompat
import code.name.monkey.retromusic.extensions.drawAboveSystemBarsWithPadding
import code.name.monkey.retromusic.extensions.recordInitialPaddingForView
import code.name.monkey.retromusic.extensions.requestApplyInsetsWhenAttached
import code.name.monkey.retromusic.util.RetroUtil
import com.afollestad.materialdialogs.utils.MDUtil.updatePadding
class InsetsConstraintLayout @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr) {
init {
if (!RetroUtil.isLandscape())
drawAboveSystemBarsWithPadding()
}
}

View file

@ -0,0 +1,30 @@
package code.name.monkey.retromusic.views.insets
import android.content.Context
import android.util.AttributeSet
import androidx.annotation.Px
import androidx.recyclerview.widget.RecyclerView
import code.name.monkey.retromusic.extensions.drawAboveSystemBarsWithPadding
import code.name.monkey.retromusic.util.RetroUtil
class InsetsRecyclerView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : RecyclerView(context, attrs, defStyleAttr) {
init {
if (!RetroUtil.isLandscape())
drawAboveSystemBarsWithPadding()
}
fun updatePadding(
@Px left: Int = paddingLeft,
@Px top: Int = paddingTop,
@Px right: Int = paddingRight,
@Px bottom: Int = paddingBottom
) {
setPadding(left, top, right, bottom)
if (!RetroUtil.isLandscape())
drawAboveSystemBarsWithPadding()
}
}

View file

@ -66,7 +66,7 @@
android:transitionGroup="true"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<androidx.constraintlayout.widget.ConstraintLayout
<code.name.monkey.retromusic.views.insets.InsetsConstraintLayout
android:id="@+id/contentContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -152,6 +152,6 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageContainer" />
</androidx.constraintlayout.widget.ConstraintLayout>
</code.name.monkey.retromusic.views.insets.InsetsConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -59,14 +59,12 @@
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/toolbar_margin_horizontal"
android:layout_marginEnd="@dimen/toolbar_margin_horizontal"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:transitionGroup="true"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<androidx.constraintlayout.widget.ConstraintLayout
<code.name.monkey.retromusic.views.insets.InsetsConstraintLayout
android:id="@+id/contentContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -119,6 +117,6 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/titleWelcome" />
</androidx.constraintlayout.widget.ConstraintLayout>
</code.name.monkey.retromusic.views.insets.InsetsConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -5,8 +5,7 @@
android:layout_height="match_parent"
android:background="?attr/colorSurface"
android:fitsSystemWindows="true"
android:orientation="vertical"
tools:ignore="UnusedAttribute">
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"

View file

@ -59,14 +59,13 @@
<com.google.android.material.button.MaterialButton
android:id="@+id/finish"
style="@style/Widget.MaterialComponents.Button"
style="@style/Widget.Material3.Button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:paddingVertical="12dp"
android:text="Let's go"
android:textAppearance="@style/TextViewButton"
app:cornerRadius="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

View file

@ -1,9 +1,7 @@
<androidx.coordinatorlayout.widget.CoordinatorLayout 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="match_parent"
android:background="?attr/colorSurface"
android:fitsSystemWindows="true"
android:focusable="true"
android:focusableInTouchMode="true">
@ -20,8 +18,7 @@
style="@style/Toolbar"
app:navigationIcon="@drawable/ic_keyboard_backspace_black"
app:title="@string/action_tag_editor"
app:titleTextAppearance="@style/ToolbarTextAppearanceNormal"
tools:ignore="UnusedAttribute" />
app:titleTextAppearance="@style/ToolbarTextAppearanceNormal" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<code.name.monkey.retromusic.views.insets.InsetsConstraintLayout 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"
@ -197,4 +197,4 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/listeners" />
</androidx.constraintlayout.widget.ConstraintLayout>
</code.name.monkey.retromusic.views.insets.InsetsConstraintLayout>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<code.name.monkey.retromusic.views.insets.InsetsConstraintLayout 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"
@ -192,4 +192,4 @@
android:layout_height="72dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/listeners" />
</androidx.constraintlayout.widget.ConstraintLayout>
</code.name.monkey.retromusic.views.insets.InsetsConstraintLayout>

View file

@ -1,10 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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="match_parent"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
android:layout_height="match_parent">
<com.google.android.material.button.MaterialButton
android:id="@+id/create_backup"
@ -60,37 +58,4 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/backup_title" />
<LinearLayout
android:id="@android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/create_backup"
tools:visibility="visible">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/emptyEmoji"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="@string/empty_text_emoji"
android:textAppearance="@style/TextViewHeadline3" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/emptyText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/no_backups_found"
android:textAppearance="@style/TextViewHeadline5"
android:textColor="?android:attr/textColorSecondary"
tools:visibility="visible" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -63,7 +63,7 @@
android:focusableInTouchMode="true"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<androidx.constraintlayout.widget.ConstraintLayout
<code.name.monkey.retromusic.views.insets.InsetsConstraintLayout
android:id="@+id/contentContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -149,6 +149,6 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageContainer" />
</androidx.constraintlayout.widget.ConstraintLayout>
</code.name.monkey.retromusic.views.insets.InsetsConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -77,7 +77,7 @@
tools:visibility="visible" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
<code.name.monkey.retromusic.views.insets.InsetsRecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"

View file

@ -63,7 +63,7 @@
android:focusableInTouchMode="true"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<androidx.constraintlayout.widget.ConstraintLayout
<code.name.monkey.retromusic.views.insets.InsetsConstraintLayout
android:id="@+id/contentContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -116,7 +116,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/titleWelcome" />
</androidx.constraintlayout.widget.ConstraintLayout>
</code.name.monkey.retromusic.views.insets.InsetsConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -38,7 +38,7 @@
</FrameLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
<code.name.monkey.retromusic.views.insets.InsetsRecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"

View file

@ -8,6 +8,7 @@
android:transitionGroup="true">
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

View file

@ -30,7 +30,7 @@
</FrameLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
<code.name.monkey.retromusic.views.insets.InsetsRecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -4,21 +4,20 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorSurface"
android:fitsSystemWindows="true"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
style="@style/Toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorSurface"
app:navigationIcon="@drawable/ic_keyboard_backspace_black"
app:titleTextAppearance="@style/ToolbarTextAppearanceNormal">
@ -30,7 +29,7 @@
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/searchView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@null"
android:hint="@string/action_search"
@ -70,14 +69,6 @@
</FrameLayout>
</LinearLayout>
</com.google.android.material.appbar.MaterialToolbar>
</com.google.android.material.appbar.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:orientation="vertical">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -128,18 +119,16 @@
</com.google.android.material.chip.ChipGroup>
</HorizontalScrollView>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
<code.name.monkey.retromusic.views.insets.InsetsRecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:clipToPadding="false"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />
</LinearLayout>
<com.google.android.material.textview.MaterialTextView
android:id="@android:id/empty"

View file

@ -12,7 +12,7 @@
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:fitsSystemWindows="true"
app:liftOnScroll="true">
<com.google.android.material.appbar.MaterialToolbar
@ -25,7 +25,7 @@
</com.google.android.material.appbar.AppBarLayout>
<androidx.constraintlayout.widget.ConstraintLayout
<code.name.monkey.retromusic.views.insets.InsetsConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@ -85,7 +85,7 @@
tools:text="@tools:sample/full_names" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</code.name.monkey.retromusic.views.insets.InsetsConstraintLayout>
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton

View file

@ -54,12 +54,11 @@
<com.google.android.material.button.MaterialButton
android:id="@+id/button"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
style="@style/Widget.Material3.Button.OutlinedButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingVertical="10dp"
android:textAppearance="@style/TextViewButton"
app:cornerRadius="8dp"
app:icon="@drawable/ic_history"
app:iconGravity="start"
app:layout_constraintEnd_toEndOf="parent"

View file

@ -241,7 +241,7 @@
<string name="no_songs">Aucun morceau</string>
<string name="normal">Normal</string>
<string name="normal_lyrics">Paroles normales</string>
<string name="not_listed_in_media_store"><![CDATA[<b>%s</b> N'est pas répertorié dans le stockage des médias.]]></string>
<string name="not_listed_in_media_store"><![CDATA[<b>%s</b> N\'est pas répertorié dans le stockage des médias.]]></string>
<string name="not_recently_played">Non jouée récemment</string>
<string name="nothing_to_scan">Rien à scanner.</string>
<string name="nothing_to_see">Rien à afficher</string>

View file

@ -8,6 +8,9 @@
<item name="android:statusBarColor">@color/transparent</item>
<item name="android:navigationBarColor">@color/transparent</item>
<item name="android:enforceNavigationBarContrast">false</item>
<item name="floatingActionButtonStyle">
@style/Widget.MaterialComponents.FloatingActionButton
</item>
<item name="popupMenuBackground">@drawable/popup_background</item>
</style>

View file

@ -307,7 +307,7 @@ private constructor(private val mContext: Context) : ThemeStorePrefKeys, ThemeSt
}
private fun isMD3Enabled(context: Context): Boolean {
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(ThemeStorePrefKeys.KEY_MATERIAL_YOU, false)
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(ThemeStorePrefKeys.KEY_MATERIAL_YOU, VersionUtils.hasS())
}
}
}

View file

@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.5.31'
ext.kotlin_version = '1.6.0'
repositories {
mavenCentral()
google()