Fix crashing, loading albums
This commit is contained in:
parent
397f42a54a
commit
d7ab358e60
59 changed files with 370 additions and 405 deletions
|
@ -13,8 +13,8 @@ android {
|
|||
vectorDrawables.useSupportLibrary = true
|
||||
|
||||
applicationId "code.name.monkey.retromusic"
|
||||
versionCode 366
|
||||
versionName '3.4.000-beta05'
|
||||
versionCode 367
|
||||
versionName '3.4.000-beta10'
|
||||
|
||||
multiDexEnabled true
|
||||
|
||||
|
@ -102,9 +102,9 @@ dependencies {
|
|||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
|
||||
implementation 'androidx.multidex:multidex:2.0.1'
|
||||
implementation 'androidx.fragment:fragment:1.2.0-alpha02'
|
||||
implementation 'androidx.fragment:fragment:1.2.0-alpha03'
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.1.0-beta03'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.1.0-beta04'
|
||||
implementation "androidx.gridlayout:gridlayout:1.0.0"
|
||||
implementation "androidx.cardview:cardview:1.0.0"
|
||||
implementation "androidx.palette:palette:1.0.0"
|
||||
|
@ -113,8 +113,8 @@ dependencies {
|
|||
implementation 'androidx.palette:palette-ktx:1.0.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
|
||||
implementation 'com.google.android.material:material:1.1.0-alpha09'
|
||||
implementation 'com.google.android.play:core:1.6.1'
|
||||
implementation 'com.google.android.material:material:1.1.0-alpha10'
|
||||
implementation 'com.google.android.play:core:1.6.3'
|
||||
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.6.1'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.6.1'
|
||||
|
@ -158,6 +158,5 @@ dependencies {
|
|||
kapt 'com.google.dagger:dagger-compiler:2.23.1'
|
||||
|
||||
implementation project(':appthemehelper')
|
||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-beta-3'
|
||||
}
|
||||
|
||||
|
|
|
@ -124,13 +124,11 @@
|
|||
android:immersive="true"
|
||||
android:label="@string/error"
|
||||
android:launchMode="singleInstance"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/ErrorHandlingTheme" />
|
||||
|
||||
<activity
|
||||
android:name=".activities.LockScreenActivity"
|
||||
android:noHistory="true"
|
||||
android:screenOrientation="portrait"
|
||||
android:showOnLockScreen="true" />
|
||||
|
||||
<activity
|
||||
|
@ -241,6 +239,7 @@
|
|||
<service
|
||||
android:name=".service.MusicService"
|
||||
android:enabled="true"
|
||||
android:exported="true"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.media.browse.MediaBrowserService" />
|
||||
|
|
|
@ -24,7 +24,6 @@ import code.name.monkey.retromusic.dagger.MusicComponent
|
|||
import code.name.monkey.retromusic.dagger.module.AppModule
|
||||
import com.anjlab.android.iab.v3.BillingProcessor
|
||||
import com.anjlab.android.iab.v3.TransactionDetails
|
||||
import com.google.android.play.core.missingsplits.MissingSplitsManagerFactory
|
||||
|
||||
|
||||
class App : MultiDexApplication() {
|
||||
|
@ -32,9 +31,9 @@ class App : MultiDexApplication() {
|
|||
lateinit var billingProcessor: BillingProcessor
|
||||
|
||||
override fun onCreate() {
|
||||
if (MissingSplitsManagerFactory.create(this).disableAppIfMissingRequiredSplits()) {
|
||||
/* if (MissingSplitsManagerFactory.create(this).disableAppIfMissingRequiredSplits()) {
|
||||
return
|
||||
}
|
||||
}*/
|
||||
super.onCreate()
|
||||
instance = this
|
||||
musicComponent = DaggerMusicComponent.builder()
|
||||
|
|
|
@ -33,7 +33,6 @@ import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
|||
import code.name.monkey.retromusic.glide.SongGlideRequest
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.helper.SortOrder.AlbumSongSortOrder
|
||||
import code.name.monkey.retromusic.loaders.ArtistLoader
|
||||
import code.name.monkey.retromusic.misc.AppBarStateChangeListener
|
||||
import code.name.monkey.retromusic.model.Album
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
|
@ -78,6 +77,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView {
|
|||
setDrawUnderStatusBar()
|
||||
setupWindowTransition()
|
||||
super.onCreate(savedInstanceState)
|
||||
App.musicComponent.inject(this)
|
||||
toggleBottomNavigationView(true)
|
||||
setLightNavigationBar(true)
|
||||
setNavigationbarColorAuto()
|
||||
|
@ -102,7 +102,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView {
|
|||
setOnClickListener { MusicPlayerRemote.openAndShuffleQueue(album.songs!!, true) }
|
||||
}
|
||||
|
||||
App.musicComponent?.inject(this)
|
||||
|
||||
albumDetailsPresenter.attachView(this)
|
||||
|
||||
if (intent.extras!!.containsKey(EXTRA_ALBUM_ID)) {
|
||||
|
@ -186,38 +186,11 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView {
|
|||
|
||||
loadAlbumCover()
|
||||
simpleSongAdapter.swapDataSet(album.songs)
|
||||
|
||||
albumDetailsPresenter.loadMore(album.artistId)
|
||||
}
|
||||
|
||||
private lateinit var artistImage: ImageView
|
||||
|
||||
private fun loadMoreFrom(album: Album) {
|
||||
disposable.add(ArtistLoader.getArtistFlowable(this, album.artistId)
|
||||
.map {
|
||||
|
||||
return@map it.albums!!
|
||||
}
|
||||
.map { it.filter { albumSearch -> albumSearch.id != album.id } }
|
||||
.subscribe {
|
||||
for (albumFinal in it) {
|
||||
if (albumFinal.id == album.id)
|
||||
println("$albumFinal -> $album")
|
||||
}
|
||||
if (it.isEmpty()) {
|
||||
return@subscribe
|
||||
}
|
||||
moreTitle.visibility = View.VISIBLE
|
||||
moreRecyclerView.visibility = View.VISIBLE
|
||||
moreTitle.text = String.format("More from %s", album.artistName)
|
||||
|
||||
val albumAdapter = HorizontalAlbumAdapter(this, it as ArrayList<Album>, false, null)
|
||||
moreRecyclerView.layoutManager = GridLayoutManager(this, 1, GridLayoutManager.HORIZONTAL, false)
|
||||
moreRecyclerView.adapter = albumAdapter
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
override fun moreAlbums(albums: ArrayList<Album>) {
|
||||
moreTitle.show()
|
||||
moreRecyclerView.show()
|
||||
|
@ -237,6 +210,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView {
|
|||
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
private fun loadAlbumCover() {
|
||||
|
|
|
@ -79,16 +79,6 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView {
|
|||
|
||||
ActivityCompat.postponeEnterTransition(this)
|
||||
|
||||
|
||||
App.musicComponent.inject(this)
|
||||
artistDetailsPresenter.attachView(this)
|
||||
|
||||
if (intent.extras!!.containsKey(EXTRA_ARTIST_ID)) {
|
||||
artistDetailsPresenter.loadArtist(intent.extras!!.getInt(EXTRA_ARTIST_ID))
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
|
||||
lastFMRestClient = LastFMRestClient(this)
|
||||
|
||||
setUpViews()
|
||||
|
@ -107,6 +97,15 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView {
|
|||
biographyText.maxLines = 4
|
||||
}
|
||||
}
|
||||
|
||||
App.musicComponent.inject(this)
|
||||
artistDetailsPresenter.attachView(this)
|
||||
|
||||
if (intent.extras!!.containsKey(EXTRA_ARTIST_ID)) {
|
||||
artistDetailsPresenter.loadArtist(intent.extras!!.getInt(EXTRA_ARTIST_ID))
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
@ -203,14 +202,6 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView {
|
|||
}
|
||||
|
||||
override fun artist(artist: Artist) {
|
||||
setArtist(artist)
|
||||
}
|
||||
|
||||
private fun getArtist(): Artist {
|
||||
return this.artist
|
||||
}
|
||||
|
||||
private fun setArtist(artist: Artist) {
|
||||
if (artist.songCount <= 0) {
|
||||
finish()
|
||||
}
|
||||
|
@ -224,10 +215,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView {
|
|||
text.text = String.format("%s • %s", MusicUtil.getArtistInfoString(this, artist), MusicUtil
|
||||
.getReadableDurationString(MusicUtil.getTotalDuration(this, artist.songs)))
|
||||
|
||||
//val songs = artist.songs.sortedWith(compareBy { it.title }) as ArrayList<Song>
|
||||
songAdapter.swapDataSet(artist.songs)
|
||||
|
||||
//val albums = artist.albums?.sortedWith(compareBy { it.artistName }) as ArrayList<Album>
|
||||
albumAdapter.swapDataSet(artist.albums!!)
|
||||
}
|
||||
|
||||
|
@ -255,7 +243,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView {
|
|||
|
||||
// If the "lang" parameter is set and no biography is given, retry with default language
|
||||
if (biography == null && lang != null) {
|
||||
loadBiography(getArtist().name, null)
|
||||
loadBiography(artist.name, null)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -293,7 +281,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView {
|
|||
}
|
||||
|
||||
private fun handleSortOrderMenuItem(item: MenuItem): Boolean {
|
||||
val songs = getArtist().songs
|
||||
val songs = artist.songs
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
super.onBackPressed()
|
||||
|
|
|
@ -50,10 +50,10 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
|
|||
override fun onPageScrollStateChanged(state: Int) {
|
||||
when (state) {
|
||||
ViewPager.SCROLL_STATE_IDLE ->
|
||||
fab.show(true)
|
||||
fab.show( )
|
||||
ViewPager.SCROLL_STATE_DRAGGING,
|
||||
ViewPager.SCROLL_STATE_SETTLING ->
|
||||
fab.hide(true)
|
||||
fab.hide( )
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,9 +92,9 @@ class PlayingQueueActivity : AbsMusicServiceActivity() {
|
|||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
super.onScrolled(recyclerView, dx, dy)
|
||||
if (dy > 0) {
|
||||
clearQueue.shrink(true)
|
||||
clearQueue.shrink( )
|
||||
} else if (dy < 0) {
|
||||
clearQueue.extend(true)
|
||||
clearQueue.extend( )
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -95,9 +95,9 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
|
|||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
super.onScrolled(recyclerView, dx, dy)
|
||||
if (dy > 0) {
|
||||
keyboardPopup.shrink(true)
|
||||
keyboardPopup.shrink()
|
||||
} else if (dy < 0) {
|
||||
keyboardPopup.extend(true)
|
||||
keyboardPopup.extend()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package code.name.monkey.retromusic.activities
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import androidx.annotation.StringRes
|
||||
|
@ -11,11 +10,10 @@ import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
|||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
||||
import code.name.monkey.retromusic.fragments.settings.MainSettingsFragment
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
|
||||
|
||||
class SettingsActivity : AbsBaseActivity(), SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
class SettingsActivity : AbsBaseActivity() {
|
||||
|
||||
private val fragmentManager = supportFragmentManager
|
||||
|
||||
|
@ -25,7 +23,6 @@ class SettingsActivity : AbsBaseActivity(), SharedPreferences.OnSharedPreference
|
|||
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
|
||||
setLightNavigationBar(true)
|
||||
|
||||
setupToolbar()
|
||||
|
@ -84,23 +81,6 @@ class SettingsActivity : AbsBaseActivity(), SharedPreferences.OnSharedPreference
|
|||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
public override fun onPause() {
|
||||
super.onPause()
|
||||
PreferenceUtil.getInstance(this).unregisterOnSharedPreferenceChangedListener(this)
|
||||
}
|
||||
|
||||
public override fun onResume() {
|
||||
super.onResume()
|
||||
PreferenceUtil.getInstance(this).registerOnSharedPreferenceChangedListener(this)
|
||||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
||||
if (key == PreferenceUtil.PROFILE_IMAGE_PATH) {
|
||||
recreate()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
const val TAG: String = "SettingsActivity"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.adapter.base;
|
||||
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.card.MaterialCardView;
|
||||
|
||||
import code.name.monkey.appthemehelper.ThemeStore;
|
||||
import code.name.monkey.retromusic.R;
|
||||
|
||||
public class MediaEntryViewHolder extends RecyclerView.ViewHolder implements View.OnLongClickListener, View.OnClickListener {
|
||||
@Nullable
|
||||
public TextView title;
|
||||
|
||||
@Nullable
|
||||
public TextView text;
|
||||
|
||||
@Nullable
|
||||
public TextView time;
|
||||
|
||||
@Nullable
|
||||
public TextView imageText;
|
||||
|
||||
@Nullable
|
||||
public ViewGroup imageContainer;
|
||||
|
||||
@Nullable
|
||||
public MaterialCardView imageContainerCard;
|
||||
|
||||
@Nullable
|
||||
public View menu;
|
||||
|
||||
@Nullable
|
||||
public View dragView;
|
||||
|
||||
@Nullable
|
||||
public View paletteColorContainer;
|
||||
|
||||
@Nullable
|
||||
public RecyclerView recyclerView;
|
||||
|
||||
@Nullable
|
||||
public ImageButton playSongs;
|
||||
|
||||
@Nullable
|
||||
public View mask;
|
||||
|
||||
@Nullable
|
||||
public MaterialCardView imageTextContainer;
|
||||
|
||||
@Nullable
|
||||
public ImageView image;
|
||||
|
||||
public MediaEntryViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
title = itemView.findViewById(R.id.title);
|
||||
text = itemView.findViewById(R.id.text);
|
||||
|
||||
image = itemView.findViewById(R.id.image);
|
||||
time = itemView.findViewById(R.id.time);
|
||||
|
||||
imageText = itemView.findViewById(R.id.image_text);
|
||||
imageContainer = itemView.findViewById(R.id.image_container);
|
||||
imageTextContainer = itemView.findViewById(R.id.image_text_container);
|
||||
imageContainerCard = itemView.findViewById(R.id.image_container_card);
|
||||
|
||||
menu = itemView.findViewById(R.id.menu);
|
||||
dragView = itemView.findViewById(R.id.drag_view);
|
||||
paletteColorContainer = itemView.findViewById(R.id.palette_color_container);
|
||||
recyclerView = itemView.findViewById(R.id.recycler_view);
|
||||
mask = itemView.findViewById(R.id.mask);
|
||||
playSongs = itemView.findViewById(R.id.playSongs);
|
||||
|
||||
if (imageContainerCard != null) {
|
||||
imageContainerCard.setCardBackgroundColor(ThemeStore.Companion.primaryColor(itemView.getContext()));
|
||||
}
|
||||
itemView.setOnClickListener(this);
|
||||
itemView.setOnLongClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
}
|
||||
|
||||
public void setImageTransitionName(@NonNull String transitionName) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && image != null) {
|
||||
image.setTransitionName(transitionName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
package code.name.monkey.retromusic.adapter.base
|
||||
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageButton
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.cardview.widget.CardView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.retromusic.R
|
||||
|
||||
open class MediaEntryViewHolder(view: View) : RecyclerView.ViewHolder(view), View.OnClickListener, View.OnLongClickListener {
|
||||
override fun onLongClick(v: View?): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
|
||||
}
|
||||
|
||||
var image: ImageView? = null
|
||||
var imageText: TextView? = null
|
||||
var title: TextView? = null
|
||||
var text: TextView? = null
|
||||
var imageContainer: ViewGroup? = null
|
||||
var imageContainerCard: CardView? = null
|
||||
var menu: View? = null
|
||||
var dragView: View? = null
|
||||
var paletteColorContainer: View? = null
|
||||
var time: TextView? = null
|
||||
var recyclerView: RecyclerView? = null
|
||||
var playSongs: ImageButton? = null
|
||||
var mask: View? = null
|
||||
var imageTextContainer: CardView? = null
|
||||
|
||||
init {
|
||||
|
||||
|
||||
title = view.findViewById(R.id.title)
|
||||
text = view.findViewById(R.id.text)
|
||||
|
||||
image = view.findViewById(R.id.image)
|
||||
imageContainer = view.findViewById(R.id.image_container)
|
||||
imageTextContainer = view.findViewById(R.id.image_text_container)
|
||||
imageContainerCard = view.findViewById(R.id.image_container_card)
|
||||
|
||||
imageText = view.findViewById(R.id.image_text)
|
||||
|
||||
menu = view.findViewById(R.id.menu)
|
||||
dragView = view.findViewById(R.id.drag_view)
|
||||
|
||||
paletteColorContainer = view.findViewById(R.id.palette_color_container)
|
||||
|
||||
time = view.findViewById(R.id.time);
|
||||
recyclerView = view.findViewById(R.id.recycler_view)
|
||||
|
||||
mask = view.findViewById(R.id.mask)
|
||||
playSongs = view.findViewById(R.id.playSongs)
|
||||
|
||||
view.setOnClickListener(this@MediaEntryViewHolder)
|
||||
view.setOnLongClickListener(this@MediaEntryViewHolder)
|
||||
|
||||
imageContainerCard?.setCardBackgroundColor(ThemeStore.primaryColor(itemView.context))
|
||||
|
||||
}
|
||||
|
||||
fun setImageTransitionName(transitionName: String) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && image != null) {
|
||||
image!!.transitionName = transitionName
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +1,15 @@
|
|||
package code.name.monkey.retromusic.adapter.song
|
||||
|
||||
import android.app.ActivityOptions
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.LayoutRes
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.util.Pair
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.base.AbsMultiSelectAdapter
|
||||
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
|
||||
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
||||
|
@ -33,9 +33,14 @@ import java.util.*
|
|||
* Created by hemanths on 13/08/17.
|
||||
*/
|
||||
|
||||
open class SongAdapter @JvmOverloads constructor(protected val activity: AppCompatActivity, dataSet: ArrayList<Song>,
|
||||
@param:LayoutRes protected var itemLayoutRes: Int, usePalette: Boolean, cabHolder: CabHolder?,
|
||||
showSectionName: Boolean = true) : AbsMultiSelectAdapter<SongAdapter.ViewHolder, Song>(activity, cabHolder, code.name.monkey.retromusic.R.menu.menu_media_selection), MaterialCab.Callback, FastScrollRecyclerView.SectionedAdapter {
|
||||
open class SongAdapter @JvmOverloads constructor(
|
||||
protected val activity: AppCompatActivity,
|
||||
dataSet: ArrayList<Song>,
|
||||
protected var itemLayoutRes: Int,
|
||||
usePalette: Boolean,
|
||||
cabHolder: CabHolder?,
|
||||
showSectionName: Boolean = true
|
||||
) : AbsMultiSelectAdapter<SongAdapter.ViewHolder, Song>(activity, cabHolder, code.name.monkey.retromusic.R.menu.menu_media_selection), MaterialCab.Callback, FastScrollRecyclerView.SectionedAdapter {
|
||||
var dataSet: ArrayList<Song>
|
||||
|
||||
protected var usePalette = false
|
||||
|
@ -83,9 +88,7 @@ open class SongAdapter @JvmOverloads constructor(protected val activity: AppComp
|
|||
if (holder.text != null) {
|
||||
holder.text!!.text = getSongText(song)
|
||||
}
|
||||
|
||||
loadAlbumCover(song, holder)
|
||||
|
||||
}
|
||||
|
||||
private fun setColors(color: Int, holder: ViewHolder) {
|
||||
|
@ -161,41 +164,35 @@ open class SongAdapter @JvmOverloads constructor(protected val activity: AppComp
|
|||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
return MusicUtil.getSectionName(sectionName)
|
||||
}
|
||||
|
||||
open inner class ViewHolder(itemView: View) : MediaEntryViewHolder(itemView) {
|
||||
|
||||
protected open var songMenuRes = SongMenuHelper.MENU_RES
|
||||
|
||||
protected open val song: Song
|
||||
get() = dataSet[adapterPosition]
|
||||
|
||||
init {
|
||||
setImageTransitionName(activity.getString(code.name.monkey.retromusic.R.string.transition_album_art))
|
||||
if (menu != null) {
|
||||
menu!!.setOnClickListener(object : SongMenuHelper.OnClickSongMenu(activity) {
|
||||
override val song: Song
|
||||
get() = this@ViewHolder.song
|
||||
setImageTransitionName(activity.getString(R.string.transition_album_art))
|
||||
menu?.setOnClickListener(object : SongMenuHelper.OnClickSongMenu(activity) {
|
||||
override val song: Song
|
||||
get() = this@ViewHolder.song
|
||||
|
||||
override val menuRes: Int
|
||||
get() = songMenuRes
|
||||
override val menuRes: Int
|
||||
get() = songMenuRes
|
||||
|
||||
override fun onMenuItemClick(item: MenuItem): Boolean {
|
||||
return onSongMenuItemClick(item) || super.onMenuItemClick(item)
|
||||
}
|
||||
})
|
||||
}
|
||||
override fun onMenuItemClick(item: MenuItem): Boolean {
|
||||
return onSongMenuItemClick(item) || super.onMenuItemClick(item)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
protected open fun onSongMenuItemClick(item: MenuItem): Boolean {
|
||||
if (image != null && image!!.visibility == View.VISIBLE) {
|
||||
when (item.itemId) {
|
||||
code.name.monkey.retromusic.R.id.action_go_to_album -> {
|
||||
val albumPairs = arrayOf<Pair<*, *>>(Pair.create(imageContainer,
|
||||
activity.resources.getString(code.name.monkey.retromusic.R.string.transition_album_art)))
|
||||
NavigationUtil.goToAlbum(activity, song.albumId, *albumPairs)
|
||||
R.id.action_go_to_album -> {
|
||||
val options: ActivityOptions = ActivityOptions.makeSceneTransitionAnimation(activity, image, activity.getString(R.string.transition_album_art))
|
||||
NavigationUtil.goToAlbumOptions(activity, song.albumId, options)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import code.name.monkey.retromusic.mvp.presenter.AlbumsPresenter
|
|||
import code.name.monkey.retromusic.mvp.presenter.AlbumsPresenter.AlbumsPresenterImpl
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import javax.inject.Singleton
|
||||
|
||||
/**
|
||||
* Created by hemanths on 2019-09-04.
|
||||
|
@ -29,13 +28,11 @@ import javax.inject.Singleton
|
|||
class AlbumModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun providesAlbumsPresenter(presenter: AlbumsPresenterImpl): AlbumsPresenter {
|
||||
return presenter
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun providesAlbumDetailsPresenter(presenter: AlbumDetailsPresenterImpl): AlbumDetailsPresenter {
|
||||
return presenter
|
||||
}
|
||||
|
|
|
@ -15,14 +15,12 @@
|
|||
package code.name.monkey.retromusic.dagger.module
|
||||
|
||||
import code.name.monkey.retromusic.mvp.presenter.ArtistDetailsPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.ArtistDetailsPresenter.ArtistDetailsPresenterImpl
|
||||
import code.name.monkey.retromusic.mvp.presenter.ArtistsPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.ArtistsPresenter.ArtistsPresenterImpl
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
||||
import code.name.monkey.retromusic.mvp.presenter.ArtistDetailsPresenter.*
|
||||
import code.name.monkey.retromusic.mvp.presenter.ArtistsPresenter.*
|
||||
import javax.inject.Singleton
|
||||
|
||||
/**
|
||||
* Created by hemanths on 2019-09-04.
|
||||
*/
|
||||
|
@ -30,13 +28,11 @@ import javax.inject.Singleton
|
|||
class ArtistModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun providesArtistDetailsPresenter(presenter: ArtistDetailsPresenterImpl): ArtistDetailsPresenter {
|
||||
return presenter
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun providesArtistsPresenter(presenter: ArtistsPresenterImpl): ArtistsPresenter {
|
||||
return presenter
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ import code.name.monkey.retromusic.R
|
|||
import code.name.monkey.retromusic.loaders.PlaylistLoader
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
import com.afollestad.materialdialogs.list.listItems
|
||||
|
@ -39,8 +41,9 @@ class AddToPlaylistDialog : DialogFragment() {
|
|||
playlistNames.add(p.name)
|
||||
}
|
||||
|
||||
return MaterialDialog(requireContext(), BottomSheet()).show {
|
||||
return MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT)).show {
|
||||
title(R.string.add_playlist_title)
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
listItems(items = playlistNames) { dialog, index, _ ->
|
||||
val songs = arguments!!.getParcelableArrayList<Song>("songs") ?: return@listItems
|
||||
if (index == 0) {
|
||||
|
|
|
@ -23,6 +23,8 @@ import android.os.Environment
|
|||
import androidx.core.app.ActivityCompat
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
import com.afollestad.materialdialogs.list.listItems
|
||||
|
@ -51,7 +53,7 @@ class BlacklistFolderChooserDialog : DialogFragment() {
|
|||
results[0] = ".."
|
||||
}
|
||||
for (i in parentContents!!.indices) {
|
||||
results[if (canGoUp) i + 1 else i] = parentContents!![i].name!!
|
||||
results[if (canGoUp) i + 1 else i] = parentContents!![i].name
|
||||
}
|
||||
|
||||
val data = ArrayList<String>()
|
||||
|
@ -79,8 +81,8 @@ class BlacklistFolderChooserDialog : DialogFragment() {
|
|||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
var savedInstanceStateFinal = savedInstanceState
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
|
||||
ActivityCompat.checkSelfPermission(activity!!, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
return MaterialDialog(activity!!).show {
|
||||
ActivityCompat.checkSelfPermission(requireActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
return MaterialDialog(requireActivity(), BottomSheet(LayoutMode.WRAP_CONTENT)).show {
|
||||
title(R.string.md_error_label)
|
||||
message(R.string.md_storage_perm_error)
|
||||
positiveButton(android.R.string.ok)
|
||||
|
@ -96,8 +98,9 @@ class BlacklistFolderChooserDialog : DialogFragment() {
|
|||
checkIfCanGoUp()
|
||||
parentContents = listFiles()
|
||||
|
||||
return MaterialDialog(activity!!, BottomSheet()).show {
|
||||
return MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT)).show {
|
||||
title(text = parentFolder!!.absolutePath)
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
listItems(items = contentsArray(), waitForPositiveButton = false) { _, index, _ ->
|
||||
onSelection(index)
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ import android.text.Html
|
|||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.model.smartplaylist.AbsSmartPlaylist
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
|
||||
|
@ -33,8 +35,9 @@ class ClearSmartPlaylistDialog : DialogFragment() {
|
|||
|
||||
val content = Html.fromHtml(getString(R.string.clear_playlist_x, playlist!!.name))
|
||||
|
||||
return MaterialDialog(activity!!, BottomSheet()).show {
|
||||
return MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT)).show {
|
||||
title(title)
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
message(text = content)
|
||||
positiveButton(R.string.clear_action) {
|
||||
if (activity == null) {
|
||||
|
|
|
@ -27,6 +27,8 @@ import code.name.monkey.retromusic.R.string
|
|||
import code.name.monkey.retromusic.extensions.appHandleColor
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.WhichButton
|
||||
import com.afollestad.materialdialogs.actions.getActionButton
|
||||
|
@ -45,8 +47,9 @@ class CreatePlaylistDialog : DialogFragment() {
|
|||
override fun onCreateDialog(
|
||||
savedInstanceState: Bundle?
|
||||
): Dialog {
|
||||
val materialDialog = MaterialDialog(activity!!, BottomSheet())
|
||||
val materialDialog = MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT))
|
||||
.show {
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
title(string.new_playlist_title)
|
||||
customView(layout.dialog_playlist)
|
||||
negativeButton(android.R.string.cancel)
|
||||
|
|
|
@ -22,6 +22,8 @@ import code.name.monkey.retromusic.R
|
|||
import code.name.monkey.retromusic.R.string
|
||||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
import java.util.*
|
||||
|
@ -42,8 +44,9 @@ class DeletePlaylistDialog : DialogFragment() {
|
|||
content = Html.fromHtml(getString(string.delete_playlist_x, playlists[0].name))
|
||||
}
|
||||
|
||||
return MaterialDialog(activity!!, BottomSheet())
|
||||
return MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT))
|
||||
.show {
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
title(title)
|
||||
message(text = content)
|
||||
negativeButton(android.R.string.cancel)
|
||||
|
|
|
@ -25,7 +25,9 @@ import code.name.monkey.retromusic.activities.saf.SAFGuideActivity
|
|||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.SAFUtil
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
|
||||
|
@ -53,12 +55,13 @@ class DeleteSongsDialog : DialogFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
return MaterialDialog(requireActivity(), BottomSheet()).show {
|
||||
return MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT)).show {
|
||||
title(title)
|
||||
message(text = content)
|
||||
negativeButton(android.R.string.cancel) {
|
||||
dismiss()
|
||||
}
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
noAutoDismiss()
|
||||
positiveButton(R.string.action_delete) {
|
||||
if (songs != null) {
|
||||
|
|
|
@ -24,6 +24,7 @@ import code.name.monkey.retromusic.activities.MainActivity
|
|||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.views.OptionMenuItemView
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
import com.afollestad.materialdialogs.customview.customView
|
||||
|
@ -66,11 +67,12 @@ class OptionsSheetDialogFragment : DialogFragment(), View.OnClickListener {
|
|||
actionFolders.setOnClickListener(this)
|
||||
|
||||
|
||||
materialDialog = MaterialDialog(activity!!, BottomSheet())
|
||||
materialDialog = MaterialDialog(requireActivity(), BottomSheet(LayoutMode.WRAP_CONTENT))
|
||||
.show {
|
||||
icon(R.mipmap.ic_launcher_round)
|
||||
title(R.string.app_name)
|
||||
customView(view = layout, scrollable = true)
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
}
|
||||
return materialDialog
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ import androidx.fragment.app.DialogFragment
|
|||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.model.PlaylistSong
|
||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
|
||||
|
@ -43,7 +45,7 @@ class RemoveFromPlaylistDialog : DialogFragment() {
|
|||
}
|
||||
|
||||
|
||||
return MaterialDialog(activity!!, BottomSheet())
|
||||
return MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT))
|
||||
.show {
|
||||
title(title)
|
||||
message(text = content)
|
||||
|
@ -53,6 +55,7 @@ class RemoveFromPlaylistDialog : DialogFragment() {
|
|||
return@positiveButton
|
||||
PlaylistsUtil.removeFromPlaylist(activity!!, songs as MutableList<PlaylistSong>)
|
||||
}
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@ import code.name.monkey.retromusic.R.layout
|
|||
import code.name.monkey.retromusic.R.string
|
||||
import code.name.monkey.retromusic.extensions.appHandleColor
|
||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.WhichButton
|
||||
import com.afollestad.materialdialogs.actions.getActionButton
|
||||
|
@ -41,8 +43,9 @@ class RenamePlaylistDialog : DialogFragment() {
|
|||
private lateinit var actionNewPlaylistContainer: TextInputLayout
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val materialDialog = MaterialDialog(activity!!, BottomSheet())
|
||||
val materialDialog = MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT))
|
||||
.show {
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
title(string.rename_playlist_title)
|
||||
customView(layout.dialog_playlist)
|
||||
negativeButton(android.R.string.cancel)
|
||||
|
|
|
@ -36,6 +36,7 @@ import code.name.monkey.retromusic.service.MusicService.ACTION_QUIT
|
|||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.WhichButton
|
||||
import com.afollestad.materialdialogs.actions.getActionButton
|
||||
|
@ -57,8 +58,9 @@ class SleepTimerDialog : DialogFragment() {
|
|||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
timerUpdater = TimerUpdater()
|
||||
|
||||
materialDialog = MaterialDialog(activity!!, BottomSheet())
|
||||
materialDialog = MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT))
|
||||
.title(R.string.action_sleep_timer)
|
||||
.cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
.positiveButton(R.string.action_set) {
|
||||
PreferenceUtil.getInstance(requireContext()).sleepTimerFinishMusic = shouldFinishLastSong.isChecked
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
package code.name.monkey.retromusic.dialogs
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
|
@ -31,6 +30,8 @@ import code.name.monkey.retromusic.R.layout
|
|||
import code.name.monkey.retromusic.R.string
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
import com.afollestad.materialdialogs.customview.customView
|
||||
|
@ -53,15 +54,16 @@ inline fun ViewGroup.forEach(action: (View) -> Unit) {
|
|||
class SongDetailDialog : DialogFragment() {
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val context: Activity = activity!!
|
||||
val context: Context = requireContext()
|
||||
val song = arguments!!.getParcelable<Song>("song")
|
||||
|
||||
val materialDialog = MaterialDialog(context, BottomSheet())
|
||||
val materialDialog = MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT))
|
||||
.show {
|
||||
customView(layout.dialog_file_details,
|
||||
scrollable = true)
|
||||
positiveButton(android.R.string.ok)
|
||||
title(string.action_details)
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
}
|
||||
val dialogView = materialDialog.getCustomView()
|
||||
|
||||
|
|
|
@ -21,55 +21,22 @@ import androidx.fragment.app.DialogFragment
|
|||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
import com.afollestad.materialdialogs.list.listItems
|
||||
|
||||
|
||||
class SongShareDialog : DialogFragment() {
|
||||
/* override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.dialog_file_share, container, false)
|
||||
}
|
||||
|
||||
@SuppressLint("StringFormatInvalid")
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val song: Song = arguments!!.getParcelable("song") ?: return
|
||||
|
||||
dialogTitle.setTextColor(ThemeStore.textColorPrimary(context!!))
|
||||
audioText.apply {
|
||||
text = getString(R.string.currently_listening_to_x_by_x, song.title, song.artistName)
|
||||
setTextColor(ThemeStore.textColorSecondary(context!!))
|
||||
setOnClickListener {
|
||||
val currentlyListening = getString(code.name.monkey.retromusic.R.string.currently_listening_to_x_by_x, song.title, song.artistName)
|
||||
activity!!.startActivity(Intent.createChooser(Intent().setAction(Intent.ACTION_SEND)
|
||||
.putExtra(Intent.EXTRA_TEXT, currentlyListening)
|
||||
.setType("text/plain"), null))
|
||||
dismiss()
|
||||
}
|
||||
icon = ContextCompat.getDrawable(context, code.name.monkey.retromusic.R.drawable.ic_text_fields_black_24dp)
|
||||
MaterialUtil.setTint(this)
|
||||
}
|
||||
|
||||
audioFile.apply {
|
||||
setTextColor(ThemeStore.textColorSecondary(context!!))
|
||||
setOnClickListener {
|
||||
activity!!.startActivity(Intent.createChooser(MusicUtil.createShareSongFileIntent(song, context), null))
|
||||
dismiss()
|
||||
}
|
||||
icon = ContextCompat.getDrawable(context, code.name.monkey.retromusic.R.drawable.ic_share_white_24dp)
|
||||
MaterialUtil.setTint(this, false)
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val song: Song? = arguments!!.getParcelable("song")
|
||||
val currentlyListening: String = getString(R.string.currently_listening_to_x_by_x, song?.title, song?.artistName)
|
||||
|
||||
return MaterialDialog(activity!!, BottomSheet())
|
||||
return MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT))
|
||||
.title(R.string.what_do_you_want_to_share)
|
||||
.show {
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
listItems(items = listOf(getString(code.name.monkey.retromusic.R.string.the_audio_file), "\u201C" + currentlyListening + "\u201D")) { dialog, index, text ->
|
||||
when (index) {
|
||||
0 -> {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package code.name.monkey.retromusic.fragments.mainactivity
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
|
@ -26,6 +27,10 @@ class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdap
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
App.musicComponent.inject(this)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
songPresenter.attachView(this)
|
||||
}
|
||||
|
||||
|
|
|
@ -26,10 +26,10 @@ import code.name.monkey.appthemehelper.ThemeStore
|
|||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEColorPreference
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
import com.afollestad.materialdialogs.color.colorChooser
|
||||
|
@ -40,15 +40,7 @@ import com.afollestad.materialdialogs.color.colorChooser
|
|||
*/
|
||||
|
||||
class ThemeSettingsFragment : AbsSettingsFragment() {
|
||||
private var materialDialog: MaterialDialog? = null
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
materialDialog?.dismiss()
|
||||
}
|
||||
|
||||
override fun invalidateSettings() {
|
||||
|
||||
val generalTheme: Preference? = findPreference("general_theme")
|
||||
generalTheme?.let {
|
||||
setSummary(it)
|
||||
|
@ -83,7 +75,7 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
|
|||
accentColorPref.setColor(accentColor, ColorUtil.darkenColor(accentColor))
|
||||
|
||||
accentColorPref.setOnPreferenceClickListener {
|
||||
materialDialog = MaterialDialog(requireContext(), BottomSheet()).show {
|
||||
MaterialDialog(requireActivity(), BottomSheet(LayoutMode.WRAP_CONTENT)).show {
|
||||
title(R.string.accent_color)
|
||||
positiveButton(R.string.set)
|
||||
colorChooser(colors = ACCENT_COLORS, allowCustomArgb = true, subColors = ACCENT_COLORS_SUB) { _, color ->
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.io.InputStream
|
|||
|
||||
class RetroMusicGlideModule : GlideModule {
|
||||
override fun applyOptions(context: Context, builder: GlideBuilder) {
|
||||
|
||||
}
|
||||
|
||||
override fun registerComponents(context: Context, glide: Glide) {
|
||||
|
|
|
@ -49,7 +49,6 @@ object MusicPlayerRemote {
|
|||
} else song.id == currentSong.id
|
||||
}
|
||||
|
||||
|
||||
val currentSong: Song
|
||||
get() = if (musicService != null) {
|
||||
musicService!!.currentSong
|
||||
|
@ -219,7 +218,7 @@ object MusicPlayerRemote {
|
|||
*/
|
||||
fun openAndShuffleQueue(queue: ArrayList<Song>, startPlaying: Boolean) {
|
||||
var startPosition = 0
|
||||
if (!queue.isEmpty()) {
|
||||
if (queue.isNotEmpty()) {
|
||||
startPosition = Random().nextInt(queue.size)
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ interface AlbumDetailsPresenter : Presenter<AlbumDetailsView> {
|
|||
) : PresenterImpl<AlbumDetailsView>(), AlbumDetailsPresenter {
|
||||
|
||||
private lateinit var album: Album
|
||||
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
override fun loadMore(artistId: Int) {
|
||||
disposable += repository.getArtistByIdFlowable(artistId)
|
||||
.map {
|
||||
|
@ -64,7 +64,6 @@ interface AlbumDetailsPresenter : Presenter<AlbumDetailsView> {
|
|||
}
|
||||
}
|
||||
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
override fun loadAlbum(albumId: Int) {
|
||||
disposable += repository.getAlbumFlowable(albumId)
|
||||
|
|
|
@ -42,9 +42,9 @@ interface SongPresenter : Presenter<SongView> {
|
|||
|
||||
override fun loadSongs() {
|
||||
disposable = repository.allSongsFlowable
|
||||
.subscribe {
|
||||
view.songs(it)
|
||||
}
|
||||
.subscribe({
|
||||
view?.songs(it)
|
||||
}, { t -> print(t) })
|
||||
}
|
||||
|
||||
override fun detachView() {
|
||||
|
|
|
@ -74,8 +74,9 @@ class AlbumCoverStylePreferenceDialog : PreferenceDialogFragmentCompat(), ViewPa
|
|||
viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt()
|
||||
viewPager.currentItem = PreferenceUtil.getInstance(requireContext()).albumCoverStyle.ordinal
|
||||
|
||||
return MaterialDialog(activity!!).show {
|
||||
return MaterialDialog(requireActivity()).show {
|
||||
title(R.string.pref_title_album_cover_style)
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
positiveButton(R.string.set) {
|
||||
val nowPlayingScreen = AlbumCoverStyle.values()[viewPagerPosition]
|
||||
PreferenceUtil.getInstance(requireContext()).albumCoverStyle = nowPlayingScreen
|
||||
|
|
|
@ -26,6 +26,8 @@ import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreferenc
|
|||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.dialogs.BlacklistFolderChooserDialog
|
||||
import code.name.monkey.retromusic.providers.BlacklistStore
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
import com.afollestad.materialdialogs.list.listItems
|
||||
|
@ -58,15 +60,17 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
|
|||
val blacklistFolderChooserDialog = childFragmentManager.findFragmentByTag("FOLDER_CHOOSER") as BlacklistFolderChooserDialog?
|
||||
blacklistFolderChooserDialog?.setCallback(this)
|
||||
refreshBlacklistData()
|
||||
return MaterialDialog(context!!, BottomSheet()).show {
|
||||
return MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT)).show {
|
||||
title(code.name.monkey.retromusic.R.string.blacklist)
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
positiveButton(android.R.string.ok) {
|
||||
dismiss()
|
||||
}
|
||||
neutralButton(text = getString(R.string.clear_action)) {
|
||||
MaterialDialog(context, BottomSheet()).show {
|
||||
MaterialDialog(context, BottomSheet(LayoutMode.WRAP_CONTENT)).show {
|
||||
title(code.name.monkey.retromusic.R.string.clear_blacklist)
|
||||
message(code.name.monkey.retromusic.R.string.do_you_want_to_clear_the_blacklist)
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
positiveButton(code.name.monkey.retromusic.R.string.clear_action) {
|
||||
BlacklistStore.getInstance(context).clear()
|
||||
refreshBlacklistData()
|
||||
|
@ -80,7 +84,8 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
|
|||
dialog.show(childFragmentManager, "FOLDER_CHOOSER");
|
||||
}
|
||||
listItems(items = paths, waitForPositiveButton = false) { _, _, text ->
|
||||
MaterialDialog(context, BottomSheet()).show {
|
||||
MaterialDialog(context, BottomSheet(LayoutMode.WRAP_CONTENT)).show {
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
title(code.name.monkey.retromusic.R.string.remove_from_blacklist)
|
||||
message(text = Html.fromHtml(getString(code.name.monkey.retromusic.R.string.do_you_want_to_remove_from_the_blacklist, text)))
|
||||
positiveButton(code.name.monkey.retromusic.R.string.remove_action) {
|
||||
|
|
|
@ -28,6 +28,7 @@ import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreferenc
|
|||
import code.name.monkey.retromusic.adapter.CategoryInfoAdapter
|
||||
import code.name.monkey.retromusic.model.CategoryInfo
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
import com.afollestad.materialdialogs.customview.customView
|
||||
|
@ -73,8 +74,9 @@ class LibraryPreferenceDialog : PreferenceDialogFragmentCompat() {
|
|||
|
||||
adapter.attachToRecyclerView(recyclerView)
|
||||
|
||||
return MaterialDialog(context!!, BottomSheet())
|
||||
return MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT))
|
||||
.title(code.name.monkey.retromusic.R.string.library_categories)
|
||||
.cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
.customView(view = view)
|
||||
.positiveButton(android.R.string.ok) {
|
||||
updateCategories(adapter.categoryInfos)
|
||||
|
|
|
@ -24,6 +24,8 @@ import androidx.preference.ListPreference
|
|||
import androidx.preference.PreferenceDialogFragmentCompat
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
import com.afollestad.materialdialogs.list.listItemsSingleChoice
|
||||
|
@ -78,9 +80,10 @@ class MaterialListPreferenceDialog : PreferenceDialogFragmentCompat() {
|
|||
|
||||
val entries = arguments?.getStringArrayList(EXTRA_ENTRIES)
|
||||
val entriesValues = arguments?.getStringArrayList(EXTRA_ENTRIES_VALUES)
|
||||
materialDialog = MaterialDialog(requireContext(), BottomSheet())
|
||||
materialDialog = MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT))
|
||||
.title(text = materialListPreference.title.toString())
|
||||
.positiveButton(R.string.set)
|
||||
.cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
.listItemsSingleChoice(items = entries, initialSelection = position, waitForPositiveButton = true) { _, index, _ ->
|
||||
materialListPreference.callChangeListener(entriesValues!![index])
|
||||
materialListPreference.setCustomValue(entriesValues[index])
|
||||
|
|
|
@ -91,7 +91,7 @@ class NowPlayingScreenPreferenceDialog : PreferenceDialogFragmentCompat(), ViewP
|
|||
viewPager.currentItem = PreferenceUtil.getInstance(requireContext()).nowPlayingScreen.ordinal
|
||||
|
||||
|
||||
return MaterialDialog(activity!!).show {
|
||||
return MaterialDialog(requireContext()).show {
|
||||
title(R.string.pref_title_album_cover_style)
|
||||
positiveButton(R.string.set) {
|
||||
val nowPlayingScreen = NowPlayingScreen.values()[viewPagerPosition]
|
||||
|
@ -103,6 +103,7 @@ class NowPlayingScreenPreferenceDialog : PreferenceDialogFragmentCompat(), ViewP
|
|||
PreferenceUtil.getInstance(requireContext()).nowPlayingScreen = nowPlayingScreen
|
||||
}
|
||||
}
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
negativeButton(android.R.string.cancel)
|
||||
customView(view = view, scrollable = false, noVerticalPadding = false)
|
||||
}
|
||||
|
|
|
@ -88,7 +88,8 @@ import code.name.monkey.retromusic.util.RetroUtil;
|
|||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid), Andrew Neal
|
||||
*/
|
||||
public class MusicService extends MediaBrowserServiceCompat implements SharedPreferences.OnSharedPreferenceChangeListener, Playback.PlaybackCallbacks {
|
||||
public class MusicService extends MediaBrowserServiceCompat implements
|
||||
SharedPreferences.OnSharedPreferenceChangeListener, Playback.PlaybackCallbacks {
|
||||
public static final String TAG = MusicService.class.getSimpleName();
|
||||
|
||||
public static final String RETRO_MUSIC_PACKAGE_NAME = "code.name.monkey.retromusic";
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package code.name.monkey.retromusic.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityOptions;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
@ -62,6 +63,12 @@ public class NavigationUtil {
|
|||
ActivityOptionsCompat.makeSceneTransitionAnimation(activity, sharedElements).toBundle());
|
||||
}
|
||||
|
||||
public static void goToAlbumOptions(@NonNull Activity activity, int albumId, @NonNull ActivityOptions activityOptions) {
|
||||
Intent intent = new Intent(activity, AlbumDetailsActivity.class);
|
||||
intent.putExtra(AlbumDetailsActivity.EXTRA_ALBUM_ID, albumId);
|
||||
ActivityCompat.startActivity(activity, intent, activityOptions.toBundle());
|
||||
}
|
||||
|
||||
public static void goToArtist(@NonNull Activity activity, int i,
|
||||
@Nullable Pair... sharedElements) {
|
||||
Intent intent = new Intent(activity, ArtistDetailActivity.class);
|
||||
|
|
|
@ -56,6 +56,7 @@ import code.name.monkey.retromusic.transform.VerticalStackTransformer;
|
|||
|
||||
public final class PreferenceUtil {
|
||||
public static final String LIBRARY_CATEGORIES = "library_categories";
|
||||
public static final String DIALOG_CORNER = "dialog_corner";
|
||||
public static final String KEEP_SCREEN_ON = "keep_screen_on";
|
||||
public static final String TOGGLE_HOME_BANNER = "toggle_home_banner";
|
||||
public static final String NOW_PLAYING_SCREEN_ID = "now_playing_screen_id";
|
||||
|
@ -185,6 +186,10 @@ public final class PreferenceUtil {
|
|||
return mPreferences.getInt(FILTER_SONG, 20);
|
||||
}
|
||||
|
||||
public float getDialogCorner() {
|
||||
return mPreferences.getInt(DIALOG_CORNER, 16);
|
||||
}
|
||||
|
||||
public boolean isSnowFall() {
|
||||
return mPreferences.getBoolean(SNOW_FALL_EFFECT, false);
|
||||
}
|
||||
|
|
29
app/src/main/res/layout/preference_category_title.xml
Normal file
29
app/src/main/res/layout/preference_category_title.xml
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright (c) 2019 Hemanth Savarala.
|
||||
~
|
||||
~ Licensed under the GNU General Public License v3
|
||||
~
|
||||
~ This is free software: you can redistribute it and/or modify it under
|
||||
~ the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
~
|
||||
~ This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
~ See the GNU General Public License for more details.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<code.name.monkey.appthemehelper.common.views.ATEAccentTextView
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="72dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Overline"
|
||||
tools:text="@string/about_settings_summary" />
|
||||
</LinearLayout>
|
|
@ -45,7 +45,11 @@
|
|||
<item>@string/dark_theme_name</item>
|
||||
<item>@string/black_theme_name</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_general_theme_list_values">
|
||||
<item>light</item>
|
||||
<item>dark</item>
|
||||
<item>black</item>
|
||||
</string-array>
|
||||
<string-array name="pref_grid_style_list_titles">
|
||||
<item>@string/normal_style</item>
|
||||
<item>@string/card_style</item>
|
||||
|
@ -91,11 +95,6 @@
|
|||
<item>@layout/item_album_card</item>
|
||||
</array>
|
||||
|
||||
<string-array name="pref_general_theme_list_values">
|
||||
<item>light</item>
|
||||
<item>dark</item>
|
||||
<item>black</item>
|
||||
</string-array>
|
||||
|
||||
<array name="pref_auto_download_images_values">
|
||||
<item>always</item>
|
||||
|
|
|
@ -657,4 +657,5 @@
|
|||
<string name="action_cycle_repeat">Cycle repeat mode</string>
|
||||
<string name="action_toggle_shuffle">Toggle shuffle mode</string>
|
||||
<string name="action_toggle_favorite">Toggle favorite</string>
|
||||
<string name="pref_dialog_corner_title">Dialog corner</string>
|
||||
</resources>
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
<style name="Theme.RetroMusic.Base" parent="Theme.MaterialComponents.NoActionBar">
|
||||
|
||||
<item name="md_corner_radius">16dp</item>
|
||||
<item name="md_font_title">@font/circular</item>
|
||||
<item name="md_font_body">@font/circular</item>
|
||||
<item name="md_font_button">@font/circular</item>
|
||||
|
@ -76,7 +75,6 @@
|
|||
|
||||
<style name="Theme.RetroMusic.Base.Light" parent="Theme.MaterialComponents.Light.NoActionBar">
|
||||
|
||||
<item name="md_corner_radius">16dp</item>
|
||||
<item name="md_font_title">@font/circular</item>
|
||||
<item name="md_font_body">@font/circular</item>
|
||||
<item name="md_font_button">@font/circular</item>
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory android:title="Advanced">
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory
|
||||
android:layout="@layout/preference_category_title"
|
||||
android:title="Advanced">
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESeekBarPreference
|
||||
android:defaultValue="30"
|
||||
|
@ -28,5 +30,14 @@
|
|||
app:enableCopying="true"
|
||||
app:icon="@drawable/ic_settings_brigntness_white_24dp" />
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESeekBarPreference
|
||||
android:defaultValue="16"
|
||||
android:key="dialog_corner"
|
||||
android:max="50"
|
||||
android:title="@string/pref_dialog_corner_title"
|
||||
app:enableCopying="true"
|
||||
app:icon="@drawable/ic_rounded_corner"
|
||||
app:showSeekBarValue="true" />
|
||||
|
||||
</code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory>
|
||||
</androidx.preference.PreferenceScreen>
|
|
@ -1,7 +1,8 @@
|
|||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory android:title="Blacklist">
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory
|
||||
android:layout="@layout/preference_category_title"
|
||||
android:title="Blacklist">
|
||||
|
||||
<code.name.monkey.retromusic.preferences.BlacklistPreference
|
||||
android:key="blacklist"
|
||||
|
@ -11,5 +12,4 @@
|
|||
app:icon="@drawable/ic_music_note_off_white_24dp" />
|
||||
|
||||
</code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory>
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
|
@ -1,19 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory android:title="@string/pref_header_general">
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory
|
||||
android:layout="@layout/preference_category_title"
|
||||
android:title="@string/pref_header_general">
|
||||
<code.name.monkey.retromusic.preferences.MaterialListPreference
|
||||
android:defaultValue="dark"
|
||||
android:entries="@array/pref_general_theme_list_titles"
|
||||
android:entryValues="@array/pref_general_theme_list_values"
|
||||
android:key="general_theme"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null"
|
||||
android:title="@string/pref_title_general_theme"
|
||||
app:enableCopying="true"
|
||||
app:icon="@drawable/ic_color_lens_white_24dp" />
|
||||
</code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory>
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory
|
||||
android:layout="@layout/preference_category_title"
|
||||
android:key="category_color"
|
||||
android:title="@string/colors">
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEColorPreference
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory android:title="@string/pref_header_lockscreen">
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory
|
||||
android:layout="@layout/preference_category_title"
|
||||
android:title="@string/pref_header_lockscreen">
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="album_art_on_lockscreen"
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
app:enableCopying="true"
|
||||
app:icon="@drawable/ic_play_circle_filled_white_24dp" />
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory android:title="@string/pref_header_album">
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory
|
||||
android:layout="@layout/preference_category_title"
|
||||
android:title="@string/pref_header_album">
|
||||
<code.name.monkey.retromusic.preferences.AlbumCoverStylePreference
|
||||
android:key="album_cover_style_id"
|
||||
android:title="@string/pref_title_album_cover_style"
|
||||
|
@ -32,7 +34,9 @@
|
|||
app:title="@string/pref_title_toggle_carousel_effect" />
|
||||
</code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory>
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory android:title="@string/pref_header_controls">
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory
|
||||
android:layout="@layout/preference_category_title"
|
||||
android:title="@string/pref_header_controls">
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
|
||||
app:defaultValue="false"
|
||||
app:enableCopying="true"
|
||||
|
@ -42,13 +46,13 @@
|
|||
app:title="@string/pref_title_extra_controls" />
|
||||
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
|
||||
app:defaultValue="false"
|
||||
app:enableCopying="true"
|
||||
app:icon="@drawable/ic_volume_up_white_24dp"
|
||||
app:key="toggle_volume"
|
||||
app:summary="@string/pref_summary_toggle_volume"
|
||||
app:title="@string/pref_title_toggle_volume" />
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
|
||||
app:defaultValue="false"
|
||||
app:enableCopying="true"
|
||||
app:icon="@drawable/ic_volume_up_white_24dp"
|
||||
app:key="toggle_volume"
|
||||
app:summary="@string/pref_summary_toggle_volume"
|
||||
app:title="@string/pref_title_toggle_volume" />
|
||||
</code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory>
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESeekBarPreference
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory android:title="@string/pref_header_playlists">
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory
|
||||
android:layout="@layout/preference_category_title"
|
||||
android:title="@string/pref_header_playlists">
|
||||
|
||||
<code.name.monkey.retromusic.preferences.MaterialListPreference
|
||||
android:defaultValue="this_month"
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory app:title="@string/grid_style_label">
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory
|
||||
android:layout="@layout/preference_category_title"
|
||||
app:title="@string/grid_style_label">
|
||||
<code.name.monkey.retromusic.preferences.MaterialListPreference
|
||||
android:defaultValue="0"
|
||||
android:entries="@array/pref_grid_style_list_titles"
|
||||
|
@ -43,7 +45,9 @@
|
|||
android:summary="@string/pref_summary_home_banner"
|
||||
android:title="@string/pref_title_home_banner" />
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory android:title="@string/pref_header_library">
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory
|
||||
android:layout="@layout/preference_category_title"
|
||||
android:title="@string/pref_header_library">
|
||||
|
||||
<code.name.monkey.retromusic.preferences.LibraryPreference
|
||||
android:key="library_categories"
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory
|
||||
android:title="@string/window"
|
||||
app:enableCopying="true"
|
||||
app:iconSpaceReserved="true">
|
||||
android:layout="@layout/preference_category_title"
|
||||
android:title="@string/window" >
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
|
||||
android:defaultValue="false"
|
||||
|
|
|
@ -26,13 +26,13 @@ android {
|
|||
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
|
||||
implementation 'com.google.android.material:material:1.1.0-alpha09'
|
||||
implementation 'androidx.preference:preference:1.1.0-rc01'
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'com.google.android.material:material:1.1.0-alpha10'
|
||||
implementation 'androidx.preference:preference:1.1.0'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
// Used for the list preference classes
|
||||
implementation 'com.afollestad.material-dialogs:core:3.0.0-alpha1'
|
||||
implementation 'com.afollestad.material-dialogs:input:3.0.0-alpha1'
|
||||
implementation 'com.afollestad.material-dialogs:color:3.0.0-alpha1'
|
||||
implementation 'com.afollestad.material-dialogs:core:3.1.1'
|
||||
implementation 'com.afollestad.material-dialogs:input:3.1.1'
|
||||
implementation 'com.afollestad.material-dialogs:color:3.1.1'
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
}
|
||||
|
|
27
appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEPreferenceCategory.kt
Executable file → Normal file
27
appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEPreferenceCategory.kt
Executable file → Normal file
|
@ -19,23 +19,26 @@ import android.util.AttributeSet
|
|||
import android.widget.TextView
|
||||
import androidx.preference.PreferenceCategory
|
||||
import androidx.preference.PreferenceViewHolder
|
||||
import code.name.monkey.appthemehelper.R
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
|
||||
class ATEPreferenceCategory @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0,
|
||||
defStyleRes: Int = 0
|
||||
context: Context?,
|
||||
attrs: AttributeSet?,
|
||||
defStyleAttr: Int = -1,
|
||||
defStyleRes: Int = -1
|
||||
) : PreferenceCategory(context, attrs, defStyleAttr, defStyleRes) {
|
||||
|
||||
init {
|
||||
layoutResource = R.layout.ate_preference_category
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: PreferenceViewHolder) {
|
||||
super.onBindViewHolder(holder)
|
||||
val mTitle = holder.itemView as TextView
|
||||
mTitle.setTextColor(ThemeStore.accentColor(context))
|
||||
val mTitle = holder.itemView.findViewById<TextView>(android.R.id.title)
|
||||
mTitle.setTextColor(ThemeStore.accentColor(holder.itemView.context))
|
||||
/*mTitle.textSize = dip2px(context, 4f)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
mTitle.setTextAppearance(R.style.TextAppearance_MaterialComponents_Overline)
|
||||
}*/
|
||||
}
|
||||
|
||||
fun dip2px(context: Context, dpVale: Float): Float {
|
||||
val scale = context.resources.displayMetrics.density
|
||||
return (dpVale * scale + 0.5f)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
package code.name.monkey.appthemehelper.util
|
||||
|
||||
/**
|
||||
* @author Aidan Follestad (afollestad)
|
||||
*/
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Typeface
|
||||
import androidx.collection.SimpleArrayMap
|
||||
|
||||
/*
|
||||
Each call to Typeface.createFromAsset will load a new instance of the typeface into memory,
|
||||
and this memory is not consistently get garbage collected
|
||||
http://code.google.com/p/android/issues/detail?id=9904
|
||||
(It states released but even on Lollipop you can see the typefaces accumulate even after
|
||||
multiple GC passes)
|
||||
|
||||
You can detect this by running:
|
||||
adb shell dumpsys meminfo com.your.packagenage
|
||||
|
||||
You will see output like:
|
||||
|
||||
Asset Allocations
|
||||
zip:/data/app/com.your.packagenage-1.apk:/assets/Roboto-Medium.ttf: 125K
|
||||
zip:/data/app/com.your.packagenage-1.apk:/assets/Roboto-Medium.ttf: 125K
|
||||
zip:/data/app/com.your.packagenage-1.apk:/assets/Roboto-Medium.ttf: 125K
|
||||
zip:/data/app/com.your.packagenage-1.apk:/assets/Roboto-Regular.ttf: 123K
|
||||
zip:/data/app/com.your.packagenage-1.apk:/assets/Roboto-Medium.ttf: 125K
|
||||
|
||||
*/
|
||||
object TypefaceHelper {
|
||||
|
||||
private val cache = SimpleArrayMap<String, Typeface>()
|
||||
|
||||
operator fun get(c: Context, name: String): Typeface? {
|
||||
synchronized(cache) {
|
||||
if (!cache.containsKey(name)) {
|
||||
try {
|
||||
val t = Typeface.createFromAsset(c.assets, name)
|
||||
cache.put(name, t)
|
||||
return t
|
||||
} catch (e: RuntimeException) {
|
||||
return null
|
||||
}
|
||||
|
||||
}
|
||||
return cache.get(name)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +1,11 @@
|
|||
package code.name.monkey.appthemehelper.util
|
||||
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.TransitionDrawable
|
||||
import android.view.View
|
||||
import android.view.ViewTreeObserver
|
||||
import androidx.annotation.ColorInt
|
||||
|
||||
|
||||
object ViewUtil {
|
||||
|
||||
fun removeOnGlobalLayoutListener(v: View, listener: ViewTreeObserver.OnGlobalLayoutListener) {
|
||||
v.viewTreeObserver.removeOnGlobalLayoutListener(listener)
|
||||
}
|
||||
|
@ -17,23 +13,4 @@ object ViewUtil {
|
|||
fun setBackgroundCompat(view: View, drawable: Drawable?) {
|
||||
view.background = drawable
|
||||
}
|
||||
|
||||
fun setBackgroundTransition(view: View, newDrawable: Drawable): TransitionDrawable {
|
||||
val transition = DrawableUtil.createTransitionDrawable(view.background, newDrawable)
|
||||
setBackgroundCompat(view, transition)
|
||||
return transition
|
||||
}
|
||||
|
||||
fun setBackgroundColorTransition(view: View, @ColorInt newColor: Int): TransitionDrawable {
|
||||
val oldColor = view.background
|
||||
|
||||
val start = oldColor ?: ColorDrawable(view.solidColor)
|
||||
val end = ColorDrawable(newColor)
|
||||
|
||||
val transition = DrawableUtil.createTransitionDrawable(start, end)
|
||||
|
||||
setBackgroundCompat(view, transition)
|
||||
|
||||
return transition
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
|
||||
<code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView
|
||||
android:id="@android:id/title"
|
||||
style="@style/TextViewSubtitle1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
|
@ -53,7 +52,6 @@
|
|||
android:layout_alignLeft="@android:id/title"
|
||||
android:layout_marginTop="2dp"
|
||||
android:maxLines="4"
|
||||
android:textAppearance="@style/TextViewBody2"
|
||||
tools:text="Summary" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -54,7 +54,6 @@
|
|||
android:layout_alignLeft="@android:id/title"
|
||||
android:layout_marginTop="2dp"
|
||||
android:maxLines="4"
|
||||
android:textAppearance="@style/TextViewBody2"
|
||||
tools:text="I have one solution for you.you can change font size for specific preference by managing layout file." />
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:textAppearance="@style/TextViewSubtitle1"
|
||||
android:textColor="#000000" />
|
||||
|
||||
<code.name.monkey.appthemehelper.common.views.ATESecondaryTextView
|
||||
|
|
Loading…
Reference in a new issue