Dialog corner and Filter song duration
This commit is contained in:
parent
a5a27e62aa
commit
fc868e1c2e
75 changed files with 1409 additions and 1294 deletions
|
@ -129,13 +129,16 @@ dependencies {
|
|||
implementation "androidx.legacy:legacy-support-v13:$supportLibVersion"
|
||||
implementation "androidx.legacy:legacy-preference-v14:$supportLibVersion"
|
||||
implementation "com.google.android.material:material:$supportLibVersion"
|
||||
implementation "androidx.palette:palette-ktx:1.0.0"
|
||||
|
||||
implementation "com.squareup.retrofit2:retrofit:2.5.0"
|
||||
implementation "com.squareup.retrofit2:converter-gson:2.5.0"
|
||||
implementation "com.squareup.retrofit2:adapter-rxjava2:2.5.0"
|
||||
|
||||
implementation "com.afollestad.material-dialogs:core:$materialDialog"
|
||||
implementation "com.afollestad.material-dialogs:commons:$materialDialog"
|
||||
implementation "com.afollestad.material-dialogs:core:$materialDialog"
|
||||
implementation 'com.afollestad.material-dialogs:input:2.0.0'
|
||||
implementation 'com.afollestad.material-dialogs:color:2.0.0'
|
||||
implementation 'com.afollestad:material-cab:0.1.12'
|
||||
|
||||
implementation 'com.github.bumptech.glide:glide:4.8.0'
|
||||
|
|
|
@ -1 +1 @@
|
|||
<html>
<head>
<style type="text/css">
* {
word-wrap: break-word;
}
{style-placeholder}
a {
color: #{link-color};
}
a:active {
color: #{link-color-active};
}
ul {
list-style-position: outside;
padding-left: 0;
padding-right: 0;
margin-left: 1em;
}
li {
padding-top: 8px;
}
</style>
</head>
<body>
<h4>v3.0.570</h4>
<ul>
<li>Fix Album/Artist square image</li>
<li>Fix Delete dialog text format</li>
<li>Fix Profile picture not showing after coming back from folders</li>
<li>Fix Play button color i Simple and Plain themes</li>
<li>Fix Sleep timer dialog crashing</li>
<li>Fix Share song dialog title and text</li>
</ul>
<p>If you see entire app white or dark or black select same theme in settings to fix </p>
<p style="line-height:150%"><a href="https://github.com/h4h13/RetroMusicPlayer/wiki/FAQ">FAQ's</a>
</p>
<p style="line-height:150%">*If you face any UI related issues you clear app data and cache, if its
not working try to
uninstall and install again. </p>
</body>
|
||||
<html>
<head>
<style type="text/css">
* {
word-wrap: break-word;
}
{style-placeholder}
a {
color: #{link-color};
}
a:active {
color: #{link-color-active};
}
ul {
list-style-position: outside;
padding-left: 0;
padding-right: 0;
margin-left: 1em;
}
li {
padding-top: 8px;
}
</style>
</head>
<body>
<h4>v3.1.00</h4>
<ul>
<li>Added filter song length</li>
<li>Added colorful settings icons</li>
</ul>
<h4>v3.0.570</h4>
<ul>
<li>Fix Album/Artist square image</li>
<li>Fix Delete dialog text format</li>
<li>Fix Profile picture not showing after coming back from folders</li>
<li>Fix Play button color i Simple and Plain themes</li>
<li>Fix Sleep timer dialog crashing</li>
<li>Fix Share song dialog title and text</li>
</ul>
<p>If you see entire app white or dark or black select same theme in settings to fix </p>
<p style="line-height:150%"><a href="https://github.com/h4h13/RetroMusicPlayer/wiki/FAQ">FAQ's</a>
</p>
<p style="line-height:150%">*If you face any UI related issues you clear app data and cache, if its
not working try to
uninstall and install again. </p>
</body>
|
|
@ -1,157 +0,0 @@
|
|||
package code.name.monkey.retromusic.dialogs;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Dialog;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.view.View;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import code.name.monkey.retromusic.R;
|
||||
|
||||
/**
|
||||
* @author Aidan Follestad (afollestad), modified by Karim Abou Zeid
|
||||
*/
|
||||
public class BlacklistFolderChooserDialog extends DialogFragment /*implements MaterialDialog.ListCallback */{
|
||||
|
||||
private String initialPath = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||
private File parentFolder;
|
||||
private File[] parentContents;
|
||||
private boolean canGoUp = false;
|
||||
private FolderCallback callback;
|
||||
|
||||
public static BlacklistFolderChooserDialog create() {
|
||||
return new BlacklistFolderChooserDialog();
|
||||
}
|
||||
|
||||
private String[] getContentsArray() {
|
||||
if (parentContents == null) {
|
||||
if (canGoUp) {
|
||||
return new String[]{".."};
|
||||
}
|
||||
return new String[]{};
|
||||
}
|
||||
String[] results = new String[parentContents.length + (canGoUp ? 1 : 0)];
|
||||
if (canGoUp) {
|
||||
results[0] = "..";
|
||||
}
|
||||
for (int i = 0; i < parentContents.length; i++) {
|
||||
results[canGoUp ? i + 1 : i] = parentContents[i].getName();
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private File[] listFiles() {
|
||||
File[] contents = parentFolder.listFiles();
|
||||
List<File> results = new ArrayList<>();
|
||||
if (contents != null) {
|
||||
for (File fi : contents) {
|
||||
if (fi.isDirectory()) {
|
||||
results.add(fi);
|
||||
}
|
||||
}
|
||||
Collections.sort(results, new FolderSorter());
|
||||
return results.toArray(new File[results.size()]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
return new MaterialDialog.Builder(getActivity())
|
||||
.title(R.string.md_error_label)
|
||||
.content(R.string.md_storage_perm_error)
|
||||
.positiveText(android.R.string.ok)
|
||||
.build();
|
||||
}
|
||||
if (savedInstanceState == null) {
|
||||
savedInstanceState = new Bundle();
|
||||
}
|
||||
if (!savedInstanceState.containsKey("current_path")) {
|
||||
savedInstanceState.putString("current_path", initialPath);
|
||||
}
|
||||
parentFolder = new File(savedInstanceState.getString("current_path", File.pathSeparator));
|
||||
checkIfCanGoUp();
|
||||
parentContents = listFiles();
|
||||
MaterialDialog.Builder builder =
|
||||
new MaterialDialog.Builder(getActivity())
|
||||
.title(parentFolder.getAbsolutePath())
|
||||
.items((CharSequence[]) getContentsArray())
|
||||
.itemsCallback(this)
|
||||
.autoDismiss(false)
|
||||
.onPositive((dialog, which) -> {
|
||||
dismiss();
|
||||
callback.onFolderSelection(BlacklistFolderChooserDialog.this, parentFolder);
|
||||
})
|
||||
.onNegative((materialDialog, dialogAction) -> dismiss())
|
||||
.positiveText(R.string.add_action)
|
||||
.negativeText(android.R.string.cancel);
|
||||
return builder.build();
|
||||
}*/
|
||||
|
||||
/*@Override
|
||||
public void onSelection(MaterialDialog materialDialog, View view, int i, CharSequence s) {
|
||||
if (canGoUp && i == 0) {
|
||||
parentFolder = parentFolder.getParentFile();
|
||||
if (parentFolder.getAbsolutePath().equals("/storage/emulated")) {
|
||||
parentFolder = parentFolder.getParentFile();
|
||||
}
|
||||
checkIfCanGoUp();
|
||||
} else {
|
||||
parentFolder = parentContents[canGoUp ? i - 1 : i];
|
||||
canGoUp = true;
|
||||
if (parentFolder.getAbsolutePath().equals("/storage/emulated")) {
|
||||
parentFolder = Environment.getExternalStorageDirectory();
|
||||
}
|
||||
}
|
||||
reload();
|
||||
}*/
|
||||
|
||||
private void checkIfCanGoUp() {
|
||||
canGoUp = parentFolder.getParent() != null;
|
||||
}
|
||||
|
||||
private void reload() {
|
||||
parentContents = listFiles();
|
||||
MaterialDialog dialog = (MaterialDialog) getDialog();
|
||||
dialog.setTitle(parentFolder.getAbsolutePath());
|
||||
//dialog.setItems((CharSequence[]) getContentsArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putString("current_path", parentFolder.getAbsolutePath());
|
||||
}
|
||||
|
||||
public void setCallback(FolderCallback callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public interface FolderCallback {
|
||||
void onFolderSelection(@NonNull BlacklistFolderChooserDialog dialog, @NonNull File folder);
|
||||
}
|
||||
|
||||
private static class FolderSorter implements Comparator<File> {
|
||||
|
||||
@Override
|
||||
public int compare(File lhs, File rhs) {
|
||||
return lhs.getName().compareTo(rhs.getName());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,162 @@
|
|||
package code.name.monkey.retromusic.dialogs
|
||||
|
||||
import android.Manifest
|
||||
import android.app.Dialog
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.retromusic.R
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.list.listItems
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
/**
|
||||
* @author Aidan Follestad (afollestad), modified by Karim Abou Zeid
|
||||
*/
|
||||
class BlacklistFolderChooserDialog : DialogFragment() {
|
||||
|
||||
private val initialPath = Environment.getExternalStorageDirectory().absolutePath
|
||||
private var parentFolder: File? = null
|
||||
private var parentContents: Array<File>? = null
|
||||
private var canGoUp = false
|
||||
private var callback: FolderCallback? = null
|
||||
|
||||
|
||||
private fun contentsArray(): List<String> {
|
||||
if (parentContents == null) {
|
||||
return if (canGoUp) {
|
||||
return listOf("..")
|
||||
} else listOf()
|
||||
}
|
||||
|
||||
val results = arrayOfNulls<String>(parentContents!!.size + if (canGoUp) 1 else 0)
|
||||
if (canGoUp) {
|
||||
results[0] = ".."
|
||||
}
|
||||
for (i in parentContents!!.indices) {
|
||||
results[if (canGoUp) i + 1 else i] = parentContents!![i].name!!
|
||||
}
|
||||
|
||||
val data = ArrayList<String>()
|
||||
for (i in results) {
|
||||
data.add(i!!)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
private fun listFiles(): Array<File>? {
|
||||
val contents = parentFolder!!.listFiles()
|
||||
val results = ArrayList<File>()
|
||||
if (contents != null) {
|
||||
for (fi in contents) {
|
||||
if (fi.isDirectory) {
|
||||
results.add(fi)
|
||||
}
|
||||
}
|
||||
Collections.sort(results, FolderSorter())
|
||||
return results.toTypedArray()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
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 {
|
||||
title(R.string.md_error_label)
|
||||
message(R.string.md_storage_perm_error)
|
||||
positiveButton(android.R.string.ok)
|
||||
}
|
||||
}
|
||||
if (savedInstanceStateFinal == null) {
|
||||
savedInstanceStateFinal = Bundle()
|
||||
}
|
||||
if (!savedInstanceStateFinal.containsKey("current_path")) {
|
||||
savedInstanceStateFinal.putString("current_path", initialPath)
|
||||
}
|
||||
parentFolder = File(savedInstanceStateFinal.getString("current_path", File.pathSeparator))
|
||||
checkIfCanGoUp()
|
||||
parentContents = listFiles()
|
||||
|
||||
return MaterialDialog(activity!!).show {
|
||||
title(text = parentFolder!!.absolutePath)
|
||||
listItems(items = contentsArray(), waitForPositiveButton = false) { dialog, index, text ->
|
||||
onSelection(dialog, index, text)
|
||||
}
|
||||
noAutoDismiss()
|
||||
positiveButton(R.string.add_action) {
|
||||
dismiss()
|
||||
callback!!.onFolderSelection(this@BlacklistFolderChooserDialog, parentFolder!!)
|
||||
}
|
||||
negativeButton(android.R.string.cancel) {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun onSelection(materialDialog: MaterialDialog, i: Int, s: String) {
|
||||
if (canGoUp && i == 0) {
|
||||
parentFolder = parentFolder!!.parentFile
|
||||
if (parentFolder!!.absolutePath == "/storage/emulated") {
|
||||
parentFolder = parentFolder!!.parentFile
|
||||
}
|
||||
checkIfCanGoUp()
|
||||
} else {
|
||||
parentFolder = parentContents!![if (canGoUp) i - 1 else i]
|
||||
canGoUp = true
|
||||
if (parentFolder!!.absolutePath == "/storage/emulated") {
|
||||
parentFolder = Environment.getExternalStorageDirectory()
|
||||
}
|
||||
}
|
||||
reload()
|
||||
}
|
||||
|
||||
private fun checkIfCanGoUp() {
|
||||
canGoUp = parentFolder!!.parent != null
|
||||
}
|
||||
|
||||
private fun reload() {
|
||||
parentContents = listFiles()
|
||||
val dialog = dialog as MaterialDialog?
|
||||
|
||||
dialog?.apply {
|
||||
setTitle(parentFolder!!.absolutePath)
|
||||
listItems(items = contentsArray()) { dialog, index, text ->
|
||||
onSelection(dialog, index, text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
outState.putString("current_path", parentFolder!!.absolutePath)
|
||||
}
|
||||
|
||||
fun setCallback(callback: FolderCallback) {
|
||||
this.callback = callback
|
||||
}
|
||||
|
||||
interface FolderCallback {
|
||||
fun onFolderSelection(dialog: BlacklistFolderChooserDialog, folder: File)
|
||||
}
|
||||
|
||||
private class FolderSorter : Comparator<File> {
|
||||
|
||||
override fun compare(lhs: File, rhs: File): Int {
|
||||
return lhs.name.compareTo(rhs.name)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
fun create(): BlacklistFolderChooserDialog {
|
||||
return BlacklistFolderChooserDialog()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,18 +18,17 @@ class ClearSmartPlaylistDialog : DialogFragment() {
|
|||
|
||||
val content = Html.fromHtml(getString(R.string.clear_playlist_x, playlist!!.name))
|
||||
|
||||
return MaterialDialog.Builder(activity!!)
|
||||
.title(title)
|
||||
.content(content)
|
||||
.positiveText(R.string.clear_action)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.onPositive { _, _ ->
|
||||
if (activity == null) {
|
||||
return@onPositive
|
||||
}
|
||||
playlist.clear(activity)
|
||||
return MaterialDialog(activity!!).show {
|
||||
title(title)
|
||||
message(text = content)
|
||||
positiveButton(R.string.clear_action) {
|
||||
if (activity == null) {
|
||||
return@positiveButton
|
||||
}
|
||||
.build()
|
||||
playlist.clear(activity)
|
||||
}
|
||||
negativeButton { (android.R.string.cancel) }
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -2,6 +2,7 @@ package code.name.monkey.retromusic.glide
|
|||
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.widget.ImageView
|
||||
import androidx.palette.graphics.Palette
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.glide.palette.BitmapPaletteTarget
|
||||
|
@ -28,6 +29,8 @@ abstract class RetroMusicColoredTarget(view: ImageView) : BitmapPaletteTarget(vi
|
|||
override fun onResourceReady(resource: BitmapPaletteWrapper,
|
||||
glideAnimation: Transition<in BitmapPaletteWrapper>?) {
|
||||
super.onResourceReady(resource, glideAnimation)
|
||||
|
||||
|
||||
val defaultColor = defaultFooterColor
|
||||
|
||||
val primaryColor = getColor(resource.palette, defaultColor)
|
||||
|
|
|
@ -82,7 +82,7 @@ object SongLoader {
|
|||
|
||||
try {
|
||||
return context.contentResolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
|
||||
BASE_PROJECTION, selectionFinal, selectionValuesFinal, sortOrder)
|
||||
BASE_PROJECTION, selectionFinal + " AND " + MediaStore.Audio.Media.DURATION + ">= " + (PreferenceUtil.getInstance().filterLength * 1000), selectionValuesFinal, sortOrder)
|
||||
} catch (e: SecurityException) {
|
||||
return null
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
package code.name.monkey.retromusic.preferences
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import androidx.preference.DialogPreference
|
||||
|
||||
|
||||
class AlbumCoverStylePreference : DialogPreference {
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
}
|
|
@ -3,28 +3,50 @@ package code.name.monkey.retromusic.preferences
|
|||
import android.annotation.SuppressLint
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.os.Bundle
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.preference.DialogPreference
|
||||
import androidx.preference.PreferenceDialogFragmentCompat
|
||||
import androidx.viewpager.widget.PagerAdapter
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.ui.fragments.AlbumCoverStyle
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
import com.afollestad.materialdialogs.DialogAction
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.customview.customView
|
||||
import com.bumptech.glide.Glide
|
||||
|
||||
|
||||
class AlbumCoverStylePreferenceDialog : DialogFragment(), ViewPager.OnPageChangeListener, MaterialDialog.SingleButtonCallback {
|
||||
class AlbumCoverStylePreference : DialogPreference {
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
private val mLayoutRes = R.layout.preference_dialog_now_playing_screen
|
||||
|
||||
override fun getDialogLayoutResource(): Int {
|
||||
return mLayoutRes;
|
||||
}
|
||||
}
|
||||
|
||||
class AlbumCoverStylePreferenceDialog : PreferenceDialogFragmentCompat(), ViewPager.OnPageChangeListener {
|
||||
override fun onDialogClosed(positiveResult: Boolean) {
|
||||
if (positiveResult) {
|
||||
val nowPlayingScreen = AlbumCoverStyle.values()[viewPagerPosition]
|
||||
PreferenceUtil.getInstance().albumCoverStyle = nowPlayingScreen
|
||||
}
|
||||
}
|
||||
|
||||
private var whichButtonClicked: DialogAction? = null
|
||||
private var viewPagerPosition: Int = 0
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
|
@ -35,29 +57,14 @@ class AlbumCoverStylePreferenceDialog : DialogFragment(), ViewPager.OnPageChange
|
|||
viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt()
|
||||
viewPager.currentItem = PreferenceUtil.getInstance().albumCoverStyle.ordinal
|
||||
|
||||
return MaterialDialog.Builder(activity!!)
|
||||
.title(R.string.pref_title_album_cover_style)
|
||||
.positiveText(android.R.string.ok)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.onAny(this)
|
||||
.customView(view, false)
|
||||
.build()
|
||||
}
|
||||
|
||||
override fun onClick(dialog: MaterialDialog,
|
||||
which: DialogAction) {
|
||||
whichButtonClicked = which
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface?) {
|
||||
super.onDismiss(dialog)
|
||||
if (whichButtonClicked == DialogAction.POSITIVE) {
|
||||
val nowPlayingScreen = AlbumCoverStyle.values()[viewPagerPosition]
|
||||
PreferenceUtil.getInstance().albumCoverStyle = nowPlayingScreen
|
||||
return MaterialDialog(activity!!).show {
|
||||
title(R.string.pref_title_album_cover_style)
|
||||
positiveButton(android.R.string.ok)
|
||||
negativeButton(android.R.string.cancel)
|
||||
customView(view = view, scrollable = false, noVerticalPadding = false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
||||
|
||||
}
|
||||
|
@ -109,8 +116,14 @@ class AlbumCoverStylePreferenceDialog : DialogFragment(), ViewPager.OnPageChange
|
|||
companion object {
|
||||
val TAG: String = AlbumCoverStylePreferenceDialog::class.java.simpleName
|
||||
|
||||
fun newInstance(): AlbumCoverStylePreferenceDialog {
|
||||
return AlbumCoverStylePreferenceDialog()
|
||||
private const val EXTRA_KEY = "key"
|
||||
|
||||
fun newInstance(key: String): AlbumCoverStylePreferenceDialog {
|
||||
val args = Bundle()
|
||||
args.putString(EXTRA_KEY, key)
|
||||
val fragment = AlbumCoverStylePreferenceDialog()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
package code.name.monkey.retromusic.preferences
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference
|
||||
|
||||
|
||||
class BlacklistPreference : ATEDialogPreference {
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
package code.name.monkey.retromusic.preferences;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import android.text.Html;
|
||||
import android.view.View;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.dialogs.BlacklistFolderChooserDialog;
|
||||
import code.name.monkey.retromusic.providers.BlacklistStore;
|
||||
import com.afollestad.materialdialogs.DialogAction;
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class BlacklistPreferenceDialog extends DialogFragment implements
|
||||
BlacklistFolderChooserDialog.FolderCallback {
|
||||
|
||||
public static final String TAG = BlacklistPreferenceDialog.class.getSimpleName();
|
||||
|
||||
private ArrayList<String> paths;
|
||||
|
||||
public static BlacklistPreferenceDialog newInstance() {
|
||||
return new BlacklistPreferenceDialog();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
BlacklistFolderChooserDialog blacklistFolderChooserDialog = (BlacklistFolderChooserDialog) getChildFragmentManager()
|
||||
.findFragmentByTag("FOLDER_CHOOSER");
|
||||
if (blacklistFolderChooserDialog != null) {
|
||||
blacklistFolderChooserDialog.setCallback(this);
|
||||
}
|
||||
|
||||
refreshBlacklistData();
|
||||
return new MaterialDialog.Builder(getContext())
|
||||
.title(R.string.blacklist)
|
||||
.positiveText(android.R.string.ok)
|
||||
.neutralText(R.string.clear_action)
|
||||
.negativeText(R.string.add_action)
|
||||
.items(paths)
|
||||
.autoDismiss(false)
|
||||
.itemsCallback(new MaterialDialog.ListCallback() {
|
||||
@Override
|
||||
public void onSelection(MaterialDialog materialDialog, View view, int i,
|
||||
final CharSequence charSequence) {
|
||||
new MaterialDialog.Builder(getContext())
|
||||
.title(R.string.remove_from_blacklist)
|
||||
.content(Html.fromHtml(
|
||||
getString(R.string.do_you_want_to_remove_from_the_blacklist, charSequence)))
|
||||
.positiveText(R.string.remove_action)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog materialDialog,
|
||||
@NonNull DialogAction dialogAction) {
|
||||
BlacklistStore.getInstance(getContext())
|
||||
.removePath(new File(charSequence.toString()));
|
||||
refreshBlacklistData();
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
})
|
||||
// clear
|
||||
.onNeutral(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog materialDialog,
|
||||
@NonNull DialogAction dialogAction) {
|
||||
new MaterialDialog.Builder(getContext())
|
||||
.title(R.string.clear_blacklist)
|
||||
.content(R.string.do_you_want_to_clear_the_blacklist)
|
||||
.positiveText(R.string.clear_action)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog materialDialog,
|
||||
@NonNull DialogAction dialogAction) {
|
||||
BlacklistStore.getInstance(getContext()).clear();
|
||||
refreshBlacklistData();
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
})
|
||||
// add
|
||||
.onNegative(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog materialDialog,
|
||||
@NonNull DialogAction dialogAction) {
|
||||
BlacklistFolderChooserDialog dialog = BlacklistFolderChooserDialog.create();
|
||||
dialog.setCallback(BlacklistPreferenceDialog.this);
|
||||
dialog.show(getChildFragmentManager(), "FOLDER_CHOOSER");
|
||||
}
|
||||
})
|
||||
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog materialDialog,
|
||||
@NonNull DialogAction dialogAction) {
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
private void refreshBlacklistData() {
|
||||
paths = BlacklistStore.getInstance(getContext()).getPaths();
|
||||
|
||||
MaterialDialog dialog = (MaterialDialog) getDialog();
|
||||
if (dialog != null) {
|
||||
String[] pathArray = new String[paths.size()];
|
||||
pathArray = paths.toArray(pathArray);
|
||||
dialog.setItems((CharSequence[]) pathArray);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFolderSelection(@NonNull BlacklistFolderChooserDialog folderChooserDialog,
|
||||
@NonNull File file) {
|
||||
BlacklistStore.getInstance(getContext()).addPath(file);
|
||||
refreshBlacklistData();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,198 @@
|
|||
package code.name.monkey.retromusic.preferences
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.text.Html
|
||||
import android.util.AttributeSet
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference
|
||||
import code.name.monkey.retromusic.dialogs.BlacklistFolderChooserDialog
|
||||
import code.name.monkey.retromusic.providers.BlacklistStore
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.list.listItems
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
|
||||
class BlacklistPreference : ATEDialogPreference {
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
}
|
||||
|
||||
class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog.FolderCallback {
|
||||
companion object {
|
||||
private const val EXTRA_KEY = "key"
|
||||
|
||||
fun newInstance(key: String): BlacklistPreferenceDialog {
|
||||
val args = Bundle()
|
||||
args.putString(EXTRA_KEY, key)
|
||||
val fragment = BlacklistPreferenceDialog()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val blacklistFolderChooserDialog = childFragmentManager.findFragmentByTag("FOLDER_CHOOSER") as BlacklistFolderChooserDialog?
|
||||
blacklistFolderChooserDialog?.setCallback(this)
|
||||
refreshBlacklistData()
|
||||
return MaterialDialog(context!!).show {
|
||||
title(code.name.monkey.retromusic.R.string.blacklist)
|
||||
positiveButton(android.R.string.ok) {
|
||||
dismiss();
|
||||
}
|
||||
neutralButton(code.name.monkey.retromusic.R.string.clear_action) {
|
||||
MaterialDialog(context).show {
|
||||
title(code.name.monkey.retromusic.R.string.clear_blacklist)
|
||||
message(code.name.monkey.retromusic.R.string.do_you_want_to_clear_the_blacklist)
|
||||
positiveButton(code.name.monkey.retromusic.R.string.clear_action) {
|
||||
BlacklistStore.getInstance(context).clear();
|
||||
refreshBlacklistData();
|
||||
}
|
||||
negativeButton(android.R.string.cancel)
|
||||
}
|
||||
}
|
||||
negativeButton(code.name.monkey.retromusic.R.string.add_action) {
|
||||
val dialog = BlacklistFolderChooserDialog.create()
|
||||
dialog.setCallback(this@BlacklistPreferenceDialog)
|
||||
dialog.show(childFragmentManager, "FOLDER_CHOOSER");
|
||||
}
|
||||
listItems(items = paths) { dialog, index, text ->
|
||||
MaterialDialog(context).show {
|
||||
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) {
|
||||
BlacklistStore.getInstance(context).removePath(File(text));
|
||||
refreshBlacklistData();
|
||||
}
|
||||
negativeButton(android.R.string.cancel)
|
||||
}
|
||||
}
|
||||
noAutoDismiss()
|
||||
}
|
||||
}
|
||||
|
||||
private lateinit var paths: ArrayList<String>
|
||||
|
||||
private fun refreshBlacklistData() {
|
||||
this.paths = BlacklistStore.getInstance(context!!).paths
|
||||
val dialog: MaterialDialog? = dialog as MaterialDialog?
|
||||
dialog?.listItems(items = paths)
|
||||
}
|
||||
|
||||
override fun onFolderSelection(dialog: BlacklistFolderChooserDialog, folder: File) {
|
||||
BlacklistStore.getInstance(context!!).addPath(folder);
|
||||
refreshBlacklistData();
|
||||
}
|
||||
|
||||
/*public static final String TAG = BlacklistPreferenceDialog.class.getSimpleName();
|
||||
|
||||
private ArrayList<String> paths;
|
||||
|
||||
public static BlacklistPreferenceDialog newInstance() {
|
||||
return new BlacklistPreferenceDialog();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
BlacklistFolderChooserDialog blacklistFolderChooserDialog = (BlacklistFolderChooserDialog) getChildFragmentManager()
|
||||
.findFragmentByTag("FOLDER_CHOOSER");
|
||||
if (blacklistFolderChooserDialog != null) {
|
||||
blacklistFolderChooserDialog.setCallback(this);
|
||||
}
|
||||
|
||||
refreshBlacklistData();
|
||||
return new MaterialDialog.Builder(getContext())
|
||||
.title(R.string.blacklist)
|
||||
.positiveText(android.R.string.ok)
|
||||
.neutralText(R.string.clear_action)
|
||||
.negativeText(R.string.add_action)
|
||||
.items(paths)
|
||||
.autoDismiss(false)
|
||||
.itemsCallback(new MaterialDialog.ListCallback() {
|
||||
@Override
|
||||
public void onSelection(MaterialDialog materialDialog, View view, int i,
|
||||
final CharSequence charSequence) {
|
||||
new MaterialDialog.Builder(getContext())
|
||||
.title(R.string.remove_from_blacklist)
|
||||
.content(Html.fromHtml(
|
||||
getString(R.string.do_you_want_to_remove_from_the_blacklist, charSequence)))
|
||||
.positiveText(R.string.remove_action)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog materialDialog,
|
||||
@NonNull DialogAction dialogAction) {
|
||||
BlacklistStore.getInstance(getContext())
|
||||
.removePath(new File(charSequence.toString()));
|
||||
refreshBlacklistData();
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
})
|
||||
// clear
|
||||
.onNeutral(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog materialDialog,
|
||||
@NonNull DialogAction dialogAction) {
|
||||
new MaterialDialog.Builder(getContext())
|
||||
.title(R.string.clear_blacklist)
|
||||
.content(R.string.do_you_want_to_clear_the_blacklist)
|
||||
.positiveText(R.string.clear_action)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog materialDialog,
|
||||
@NonNull DialogAction dialogAction) {
|
||||
BlacklistStore.getInstance(getContext()).clear();
|
||||
refreshBlacklistData();
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
})
|
||||
// add
|
||||
.onNegative(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog materialDialog,
|
||||
@NonNull DialogAction dialogAction) {
|
||||
BlacklistFolderChooserDialog dialog = BlacklistFolderChooserDialog.create();
|
||||
dialog.setCallback(BlacklistPreferenceDialog.this);
|
||||
dialog.show(getChildFragmentManager(), "FOLDER_CHOOSER");
|
||||
}
|
||||
})
|
||||
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog materialDialog,
|
||||
@NonNull DialogAction dialogAction) {
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
private void refreshBlacklistData() {
|
||||
paths = BlacklistStore.getInstance(getContext()).getPaths();
|
||||
|
||||
MaterialDialog dialog = (MaterialDialog) getDialog();
|
||||
if (dialog != null) {
|
||||
String[] pathArray = new String[paths.size()];
|
||||
pathArray = paths.toArray(pathArray);
|
||||
dialog.setItems((CharSequence[]) pathArray);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFolderSelection(@NonNull BlacklistFolderChooserDialog folderChooserDialog,
|
||||
@NonNull File file) {
|
||||
BlacklistStore.getInstance(getContext()).addPath(file);
|
||||
refreshBlacklistData();
|
||||
}*/
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package code.name.monkey.retromusic.preferences
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.content.res.TypedArray
|
||||
import android.os.Bundle
|
||||
import android.util.AttributeSet
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.PreferenceDialogFragmentCompat
|
||||
import code.name.monkey.retromusic.R
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.list.listItemsSingleChoice
|
||||
|
||||
|
||||
class MaterialListPreference : ListPreference {
|
||||
private val mLayoutRes = code.name.monkey.retromusic.R.layout.ate_preference_list
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
override fun getDialogLayoutResource(): Int {
|
||||
return mLayoutRes;
|
||||
}
|
||||
|
||||
override fun onGetDefaultValue(a: TypedArray, index: Int): Any {
|
||||
// Default value from attribute. Fallback value is set to 0.
|
||||
return a.getString(index)
|
||||
}
|
||||
|
||||
fun setCustomValue(any: Any) {
|
||||
when (any) {
|
||||
is String -> persistString(any)
|
||||
is Int -> persistInt(any)
|
||||
is Boolean -> persistBoolean(any)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MaterialListPreferenceDialog : PreferenceDialogFragmentCompat() {
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val materialListPreference = preference as MaterialListPreference
|
||||
position = materialListPreference.findIndexOfValue(materialListPreference.value)
|
||||
|
||||
val entries = arguments?.getStringArrayList(EXTRA_ENTRIES)
|
||||
val entriesValues = arguments?.getStringArrayList(EXTRA_ENTRIES_VALUES)
|
||||
return MaterialDialog(activity!!).show {
|
||||
title(text = materialListPreference.title.toString())
|
||||
positiveButton(R.string.set)
|
||||
listItemsSingleChoice(items = entries, initialSelection = position) { dialog, index, text ->
|
||||
materialListPreference.callChangeListener(entriesValues!![index])
|
||||
materialListPreference.setCustomValue(entriesValues[index])
|
||||
materialListPreference.summary = entries!![index]
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDialogClosed(positiveResult: Boolean) {
|
||||
if (positiveResult) {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
var position = 0
|
||||
private const val EXTRA_KEY = "key"
|
||||
private const val EXTRA_TITLE = "title"
|
||||
private const val EXTRA_ENTRIES = "extra_entries"
|
||||
private const val EXTRA_ENTRIES_VALUES = "extra_entries_values"
|
||||
|
||||
fun newInstance(listPreference: ListPreference): MaterialListPreferenceDialog {
|
||||
val entries = listPreference.entries.toList() as ArrayList<String>
|
||||
val entriesValues = listPreference.entryValues.toList() as ArrayList<String>
|
||||
val args = Bundle()
|
||||
args.putString(EXTRA_KEY, listPreference.key)
|
||||
args.putString(EXTRA_TITLE, listPreference.title.toString())
|
||||
args.putStringArrayList(EXTRA_ENTRIES, entries)
|
||||
args.putStringArrayList(EXTRA_ENTRIES_VALUES, entriesValues)
|
||||
val fragment = MaterialListPreferenceDialog()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package code.name.monkey.retromusic.preferences
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference
|
||||
|
||||
|
||||
class NowPlayingScreenPreference : ATEDialogPreference {
|
||||
constructor(context: Context) : super(context) {}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {}
|
||||
}
|
|
@ -1,17 +1,17 @@
|
|||
package code.name.monkey.retromusic.preferences
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.os.Bundle
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.preference.DialogPreference
|
||||
import androidx.preference.PreferenceDialogFragmentCompat
|
||||
import androidx.viewpager.widget.PagerAdapter
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import code.name.monkey.retromusic.App
|
||||
|
@ -20,42 +20,43 @@ import code.name.monkey.retromusic.ui.fragments.NowPlayingScreen
|
|||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
import com.afollestad.materialdialogs.DialogAction
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.customview.customView
|
||||
import com.bumptech.glide.Glide
|
||||
|
||||
class NowPlayingScreenPreference : DialogPreference {
|
||||
|
||||
class NowPlayingScreenPreferenceDialog : DialogFragment(), ViewPager.OnPageChangeListener, MaterialDialog.SingleButtonCallback {
|
||||
constructor(context: Context) : super(context) {}
|
||||
|
||||
private var whichButtonClicked: DialogAction? = null
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {}
|
||||
|
||||
private val mLayoutRes = R.layout.preference_dialog_now_playing_screen
|
||||
|
||||
override fun getDialogLayoutResource(): Int {
|
||||
return mLayoutRes;
|
||||
}
|
||||
}
|
||||
|
||||
class NowPlayingScreenPreferenceDialog : PreferenceDialogFragmentCompat(), ViewPager.OnPageChangeListener {
|
||||
private var viewPagerPosition: Int = 0
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
@SuppressLint("InflateParams") val view = LayoutInflater.from(activity)
|
||||
.inflate(R.layout.preference_dialog_now_playing_screen, null)
|
||||
val viewPager = view.findViewById<ViewPager>(R.id.now_playing_screen_view_pager)
|
||||
viewPager.adapter = NowPlayingScreenAdapter(activity!!)
|
||||
viewPager.addOnPageChangeListener(this)
|
||||
viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt()
|
||||
viewPager.currentItem = PreferenceUtil.getInstance().nowPlayingScreen.ordinal
|
||||
|
||||
return MaterialDialog.Builder(activity!!)
|
||||
.title(R.string.pref_title_now_playing_screen_appearance)
|
||||
.positiveText(android.R.string.ok)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.onAny(this)
|
||||
.customView(view, false)
|
||||
.build()
|
||||
}
|
||||
|
||||
override fun onClick(dialog: MaterialDialog,
|
||||
which: DialogAction) {
|
||||
whichButtonClicked = which
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface?) {
|
||||
super.onDismiss(dialog)
|
||||
if (whichButtonClicked == DialogAction.POSITIVE) {
|
||||
override fun onPageSelected(position: Int) {
|
||||
this.viewPagerPosition = position
|
||||
}
|
||||
|
||||
override fun onDialogClosed(positiveResult: Boolean) {
|
||||
if (positiveResult) {
|
||||
val nowPlayingScreen = NowPlayingScreen.values()[viewPagerPosition]
|
||||
if (isNowPlayingThemes(nowPlayingScreen)) {
|
||||
val result = getString(nowPlayingScreen.titleRes) + " theme is Pro version feature."
|
||||
|
@ -67,8 +68,25 @@ class NowPlayingScreenPreferenceDialog : DialogFragment(), ViewPager.OnPageChang
|
|||
}
|
||||
}
|
||||
|
||||
private fun isNowPlayingThemes(nowPlayingScreen: NowPlayingScreen): Boolean {
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val view = LayoutInflater.from(activity).inflate(R.layout.preference_dialog_now_playing_screen, null)
|
||||
val viewPager = view.findViewById<ViewPager>(R.id.now_playing_screen_view_pager)
|
||||
?: throw IllegalStateException("Dialog view must contain a ViewPager with id 'now_playing_screen_view_pager'")
|
||||
viewPager.adapter = NowPlayingScreenAdapter(activity!!)
|
||||
viewPager.addOnPageChangeListener(this)
|
||||
viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt()
|
||||
viewPager.currentItem = PreferenceUtil.getInstance().nowPlayingScreen.ordinal
|
||||
|
||||
|
||||
return MaterialDialog(activity!!).show {
|
||||
title(R.string.pref_title_album_cover_style)
|
||||
positiveButton(android.R.string.ok)
|
||||
negativeButton(android.R.string.cancel)
|
||||
customView(view = view, scrollable = false, noVerticalPadding = false)
|
||||
}
|
||||
}
|
||||
|
||||
private fun isNowPlayingThemes(nowPlayingScreen: NowPlayingScreen): Boolean {
|
||||
if (nowPlayingScreen == NowPlayingScreen.BLUR_CARD) {
|
||||
PreferenceUtil.getInstance().resetCarouselEffect()
|
||||
PreferenceUtil.getInstance().resetCircularAlbumArt()
|
||||
|
@ -83,62 +101,53 @@ class NowPlayingScreenPreferenceDialog : DialogFragment(), ViewPager.OnPageChang
|
|||
nowPlayingScreen == NowPlayingScreen.BLUR_CARD ||
|
||||
nowPlayingScreen == NowPlayingScreen.ADAPTIVE)
|
||||
&& !App.isProVersion
|
||||
|
||||
}
|
||||
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
this.viewPagerPosition = position
|
||||
}
|
||||
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
|
||||
}
|
||||
|
||||
private class NowPlayingScreenAdapter internal constructor(private val context: Context) : PagerAdapter() {
|
||||
|
||||
override fun instantiateItem(collection: ViewGroup, position: Int): Any {
|
||||
val nowPlayingScreen = NowPlayingScreen.values()[position]
|
||||
|
||||
val inflater = LayoutInflater.from(context)
|
||||
val layout = inflater.inflate(R.layout.preference_now_playing_screen_item, collection, false) as ViewGroup
|
||||
collection.addView(layout)
|
||||
|
||||
val image = layout.findViewById<ImageView>(R.id.image)
|
||||
val title = layout.findViewById<TextView>(R.id.title)
|
||||
Glide.with(context).load(nowPlayingScreen.drawableResId).into(image)
|
||||
title.setText(nowPlayingScreen.titleRes)
|
||||
|
||||
return layout
|
||||
}
|
||||
|
||||
override fun destroyItem(collection: ViewGroup,
|
||||
position: Int,
|
||||
view: Any) {
|
||||
collection.removeView(view as View)
|
||||
}
|
||||
|
||||
override fun getCount(): Int {
|
||||
return NowPlayingScreen.values().size
|
||||
}
|
||||
|
||||
override fun isViewFromObject(view: View, `object`: Any): Boolean {
|
||||
return view === `object`
|
||||
}
|
||||
|
||||
override fun getPageTitle(position: Int): CharSequence? {
|
||||
return context.getString(NowPlayingScreen.values()[position].titleRes)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val TAG: String = NowPlayingScreenPreferenceDialog::class.java.simpleName
|
||||
private const val EXTRA_KEY = "key"
|
||||
|
||||
fun newInstance(): NowPlayingScreenPreferenceDialog {
|
||||
return NowPlayingScreenPreferenceDialog()
|
||||
fun newInstance(key: String): NowPlayingScreenPreferenceDialog {
|
||||
val args = Bundle()
|
||||
args.putString(EXTRA_KEY, key)
|
||||
val fragment = NowPlayingScreenPreferenceDialog()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class NowPlayingScreenAdapter internal constructor(private val context: Context) : PagerAdapter() {
|
||||
|
||||
override fun instantiateItem(collection: ViewGroup, position: Int): Any {
|
||||
val nowPlayingScreen = NowPlayingScreen.values()[position]
|
||||
|
||||
val inflater = LayoutInflater.from(context)
|
||||
val layout = inflater.inflate(R.layout.preference_now_playing_screen_item, collection, false) as ViewGroup
|
||||
collection.addView(layout)
|
||||
|
||||
val image = layout.findViewById<ImageView>(R.id.image)
|
||||
val title = layout.findViewById<TextView>(R.id.title)
|
||||
Glide.with(context).load(nowPlayingScreen.drawableResId).into(image)
|
||||
title.setText(nowPlayingScreen.titleRes)
|
||||
|
||||
return layout
|
||||
}
|
||||
|
||||
override fun destroyItem(collection: ViewGroup,
|
||||
position: Int,
|
||||
view: Any) {
|
||||
collection.removeView(view as View)
|
||||
}
|
||||
|
||||
override fun getCount(): Int {
|
||||
return NowPlayingScreen.values().size
|
||||
}
|
||||
|
||||
override fun isViewFromObject(view: View, `object`: Any): Boolean {
|
||||
return view === `object`
|
||||
}
|
||||
|
||||
override fun getPageTitle(position: Int): CharSequence? {
|
||||
return context.getString(NowPlayingScreen.values()[position].titleRes)
|
||||
}
|
||||
}
|
|
@ -28,6 +28,7 @@ import code.name.monkey.retromusic.ui.activities.base.AbsBaseActivity
|
|||
import code.name.monkey.retromusic.ui.adapter.ContributorAdapter
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.list.listItems
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import kotlinx.android.synthetic.main.activity_about.*
|
||||
|
@ -117,7 +118,7 @@ class AboutActivity : AbsBaseActivity(), View.OnClickListener {
|
|||
|
||||
override fun onClick(view: View) {
|
||||
when (view.id) {
|
||||
R.id.pinterestLink->openUrl(PINTEREST)
|
||||
R.id.pinterestLink -> openUrl(PINTEREST)
|
||||
R.id.faqLink -> openUrl(FAQ_LINK)
|
||||
R.id.telegramLink -> openUrl(APP_TELEGRAM_LINK)
|
||||
R.id.discordLink -> openUrl(DISCORD_LINK)
|
||||
|
@ -135,17 +136,15 @@ class AboutActivity : AbsBaseActivity(), View.OnClickListener {
|
|||
}
|
||||
|
||||
private fun showChangeLogOptions() {
|
||||
MaterialDialog.Builder(this)
|
||||
.items("Telegram Channel", "App")
|
||||
.itemsCallback { _, _, position, _ ->
|
||||
if (position == 0) {
|
||||
openUrl(TELEGRAM_CHANGE_LOG)
|
||||
} else {
|
||||
NavigationUtil.gotoWhatNews(this@AboutActivity)
|
||||
}
|
||||
MaterialDialog(this).show {
|
||||
listItems(items = listOf("Telegram Channel", "App")) { _, position, _ ->
|
||||
if (position == 0) {
|
||||
openUrl(TELEGRAM_CHANGE_LOG)
|
||||
} else {
|
||||
NavigationUtil.gotoWhatNews(this@AboutActivity)
|
||||
}
|
||||
.build()
|
||||
.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getAppVersion(): String {
|
||||
|
|
|
@ -27,6 +27,7 @@ import code.name.monkey.retromusic.util.MusicUtil
|
|||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.input.input
|
||||
import kotlinx.android.synthetic.main.activity_lyrics.*
|
||||
import kotlinx.android.synthetic.main.fragment_lyrics.*
|
||||
import kotlinx.android.synthetic.main.fragment_synced.*
|
||||
|
@ -133,19 +134,18 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
|
|||
e.printStackTrace()
|
||||
}
|
||||
|
||||
MaterialDialog.Builder(this)
|
||||
.title("Add lyrics")
|
||||
.neutralText("Search")
|
||||
.content("Add time frame lyrics")
|
||||
.negativeText("Delete")
|
||||
.onNegative { _, _ ->
|
||||
LyricUtil.deleteLrcFile(song.title, song.artistName)
|
||||
}
|
||||
.onNeutral { _, _ -> RetroUtil.openUrl(this@LyricsActivity, googleSearchLrcUrl) }
|
||||
.inputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE)
|
||||
.input("Paste lyrics here", content) { _, input ->
|
||||
LyricUtil.writeLrcToLoc(song.title, song.artistName, input.toString())
|
||||
}.show()
|
||||
MaterialDialog(this).show {
|
||||
title(text = "Add lyrics")
|
||||
neutralButton(text = "Search") { RetroUtil.openUrl(this@LyricsActivity, googleSearchLrcUrl) }
|
||||
message(text = "Add time frame lyrics")
|
||||
negativeButton(text = "Delete") { LyricUtil.deleteLrcFile(song.title, song.artistName) }
|
||||
input(hint = "Paste lyrics here",
|
||||
prefill = content,
|
||||
inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE) { _, input ->
|
||||
LyricUtil.writeLrcToLoc(song.title, song.artistName, input.toString())
|
||||
}
|
||||
positiveButton(android.R.string.ok)
|
||||
}
|
||||
}
|
||||
|
||||
private fun showLyricsSaveDialog() {
|
||||
|
@ -154,17 +154,20 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
|
|||
} else {
|
||||
lyricsString!!
|
||||
}
|
||||
MaterialDialog.Builder(this)
|
||||
.title("Add lyrics")
|
||||
.neutralText("Search")
|
||||
.onNeutral { _, _ -> RetroUtil.openUrl(this@LyricsActivity, getGoogleSearchUrl(song.title, song.artistName)) }
|
||||
.inputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE)
|
||||
.input("Paste lyrics here", content) { _, input ->
|
||||
val fieldKeyValueMap = EnumMap<FieldKey, String>(FieldKey::class.java)
|
||||
fieldKeyValueMap[FieldKey.LYRICS] = input.toString()
|
||||
WriteTagsAsyncTask(this@LyricsActivity).execute(WriteTagsAsyncTask.LoadingInfo(getSongPaths(song), fieldKeyValueMap, null))
|
||||
}
|
||||
.show()
|
||||
|
||||
MaterialDialog(this).show {
|
||||
title(text = "Add lyrics")
|
||||
neutralButton(text = "Search") { RetroUtil.openUrl(this@LyricsActivity, googleSearchLrcUrl) }
|
||||
negativeButton(text = "Delete") { LyricUtil.deleteLrcFile(song.title, song.artistName) }
|
||||
input(hint = "Paste lyrics here",
|
||||
prefill = content,
|
||||
inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE) { _, input ->
|
||||
val fieldKeyValueMap = EnumMap<FieldKey, String>(FieldKey::class.java)
|
||||
fieldKeyValueMap[FieldKey.LYRICS] = input.toString()
|
||||
WriteTagsAsyncTask(this@LyricsActivity).execute(WriteTagsAsyncTask.LoadingInfo(getSongPaths(song), fieldKeyValueMap, null))
|
||||
}
|
||||
positiveButton(android.R.string.ok)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getSongPaths(song: Song): ArrayList<String> {
|
||||
|
|
|
@ -12,7 +12,6 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.helper.SearchQueryHelper
|
||||
|
@ -27,6 +26,7 @@ import code.name.monkey.retromusic.ui.fragments.mainactivity.home.BannerHomeFrag
|
|||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.callbacks.onDismiss
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import java.util.*
|
||||
|
||||
|
@ -262,18 +262,17 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
|
|||
}
|
||||
|
||||
private fun showPromotionalOffer() {
|
||||
MaterialDialog.Builder(this)
|
||||
.positiveText("Buy")
|
||||
.onPositive { _, _ -> startActivity(Intent(this@MainActivity, PurchaseActivity::class.java)) }
|
||||
.negativeText(android.R.string.cancel)
|
||||
.customView(R.layout.dialog_promotional_offer, false)
|
||||
.dismissListener {
|
||||
PreferenceManager.getDefaultSharedPreferences(this@MainActivity)
|
||||
.edit()
|
||||
.putBoolean("shown", true)
|
||||
.apply()
|
||||
}
|
||||
.show()
|
||||
/*MaterialDialog(this).show {
|
||||
positiveButton(text = "Buy") { startActivity(Intent(this@MainActivity, PurchaseActivity::class.java)) }
|
||||
negativeButton(android.R.string.cancel)
|
||||
customView(R.layout.dialog_promotional_offer)
|
||||
onDismiss {
|
||||
PreferenceManager.getDefaultSharedPreferences(this@MainActivity)
|
||||
.edit()
|
||||
.putBoolean("shown", true)
|
||||
.apply()
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private fun selectedFragment(itemId: Int) {
|
||||
|
|
|
@ -3,28 +3,22 @@ package code.name.monkey.retromusic.ui.activities
|
|||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.fragment.app.Fragment
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||
import code.name.monkey.retromusic.App.Companion.context
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager
|
||||
import code.name.monkey.retromusic.ui.activities.base.AbsBaseActivity
|
||||
import code.name.monkey.retromusic.ui.fragments.settings.MainSettingsFragment
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.color.ColorChooserDialog
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
|
||||
|
||||
class SettingsActivity : AbsBaseActivity(), ColorChooserDialog.ColorCallback, SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
class SettingsActivity : AbsBaseActivity(), /*ColorChooserDialog.ColorCallback,*/ SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
private val fragmentManager = supportFragmentManager
|
||||
|
||||
override fun onColorSelection(dialog: ColorChooserDialog, @ColorInt selectedColor: Int) {
|
||||
/* override fun onColorSelection(dialog: ColorChooserDialog, @ColorInt selectedColor: Int) {
|
||||
when (dialog.title) {
|
||||
R.string.primary_color -> {
|
||||
val theme = if (ColorUtil.isColorLight(selectedColor))
|
||||
|
@ -43,7 +37,7 @@ class SettingsActivity : AbsBaseActivity(), ColorChooserDialog.ColorCallback, Sh
|
|||
|
||||
override fun onColorChooserDismissed(dialog: ColorChooserDialog) {
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
|
|
@ -22,6 +22,7 @@ import code.name.monkey.retromusic.util.Compressor
|
|||
import code.name.monkey.retromusic.util.ImageUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.list.listItems
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
@ -29,7 +30,6 @@ import kotlinx.android.synthetic.main.activity_user_info.*
|
|||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
|
||||
class UserInfoActivity : AbsBaseActivity() {
|
||||
|
||||
|
@ -56,15 +56,15 @@ class UserInfoActivity : AbsBaseActivity() {
|
|||
loadBannerFromStorage(PreferenceUtil.getInstance().bannerImage)
|
||||
}
|
||||
userImage.setOnClickListener {
|
||||
MaterialDialog.Builder(this)
|
||||
.title("Set a profile photo")
|
||||
.items(Arrays.asList(getString(R.string.new_profile_photo), getString(R.string.remove_profile_photo)))
|
||||
.itemsCallback { _, _, position, _ ->
|
||||
when (position) {
|
||||
0 -> pickNewPhoto()
|
||||
1 -> PreferenceUtil.getInstance().saveProfileImage("")
|
||||
}
|
||||
}.show()
|
||||
MaterialDialog(this).show {
|
||||
title(text = "Set a profile photo")
|
||||
listItems(items = listOf(getString(R.string.new_profile_photo), getString(R.string.remove_profile_photo))) { _, position, _ ->
|
||||
when (position) {
|
||||
0 -> pickNewPhoto()
|
||||
1 -> PreferenceUtil.getInstance().saveProfileImage("")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bannerSelect.setOnClickListener {
|
||||
showBannerOptions()
|
||||
|
@ -103,16 +103,16 @@ class UserInfoActivity : AbsBaseActivity() {
|
|||
|
||||
private fun showBannerOptions() {
|
||||
|
||||
MaterialDialog.Builder(this)
|
||||
.title(R.string.select_banner_photo)
|
||||
.items(Arrays.asList(getString(R.string.new_banner_photo),
|
||||
getString(R.string.remove_banner_photo)))
|
||||
.itemsCallback { _, _, position, _ ->
|
||||
when (position) {
|
||||
0 -> selectBannerImage()
|
||||
1 -> PreferenceUtil.getInstance().setBannerImagePath("")
|
||||
}
|
||||
}.show()
|
||||
MaterialDialog(this).show {
|
||||
title(R.string.select_banner_photo)
|
||||
listItems(items = listOf(getString(R.string.new_banner_photo), getString(R.string.remove_banner_photo)))
|
||||
{ _, position, _ ->
|
||||
when (position) {
|
||||
0 -> selectBannerImage()
|
||||
1 -> PreferenceUtil.getInstance().setBannerImagePath("")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun selectBannerImage() {
|
||||
|
|
|
@ -7,7 +7,6 @@ import android.os.Bundle;
|
|||
import android.webkit.WebView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.afollestad.materialdialogs.internal.ThemeSingleton;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
@ -17,6 +16,7 @@ import java.io.InputStreamReader;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import code.name.monkey.appthemehelper.ThemeStore;
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil;
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil;
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
|
||||
import code.name.monkey.retromusic.R;
|
||||
|
@ -79,12 +79,12 @@ public class WhatsNewActivity extends AbsBaseActivity {
|
|||
|
||||
// Inject color values for WebView body background and links
|
||||
final String backgroundColor = colorToHex(ThemeStore.Companion.primaryColor(this));
|
||||
final String contentColor = ThemeSingleton.get().darkTheme ? "#ffffff" : "#000000";
|
||||
final String contentColor = ATHUtil.INSTANCE.isWindowBackgroundDark(this) ? "#ffffff" : "#000000";
|
||||
webView.loadData(buf.toString()
|
||||
.replace("{style-placeholder}",
|
||||
String.format("body { background-color: %s; color: %s; }", backgroundColor, contentColor))
|
||||
.replace("{link-color}", colorToHex(ThemeSingleton.get().positiveColor.getDefaultColor()))
|
||||
.replace("{link-color-active}", colorToHex(ColorUtil.INSTANCE.lightenColor(ThemeSingleton.get().positiveColor.getDefaultColor())))
|
||||
.replace("{link-color}", colorToHex(ThemeStore.Companion.accentColor(this)))
|
||||
.replace("{link-color-active}", colorToHex(ColorUtil.INSTANCE.lightenColor(ThemeStore.Companion.accentColor(this))))
|
||||
, "text/html", "UTF-8");
|
||||
} catch (Throwable e) {
|
||||
webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", "UTF-8");
|
||||
|
|
|
@ -24,7 +24,7 @@ abstract class AbsThemeActivity : AbsCrashCollector(), Runnable {
|
|||
setTheme(PreferenceUtil.getInstance().generalTheme)
|
||||
hideStatusBar()
|
||||
super.onCreate(savedInstanceState)
|
||||
MaterialDialogsUtil.updateMaterialDialogsThemeSingleton(this)
|
||||
//MaterialDialogsUtil.updateMaterialDialogsThemeSingleton(this)
|
||||
|
||||
changeBackgroundShape()
|
||||
setImmersiveFullscreen()
|
||||
|
|
|
@ -14,6 +14,7 @@ import android.view.inputmethod.EditorInfo
|
|||
import android.widget.Toast
|
||||
import androidx.annotation.StringDef
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
import code.name.monkey.retromusic.R
|
||||
|
@ -25,6 +26,7 @@ import code.name.monkey.retromusic.ui.activities.bugreport.model.github.ExtraInf
|
|||
import code.name.monkey.retromusic.ui.activities.bugreport.model.github.GithubLogin
|
||||
import code.name.monkey.retromusic.ui.activities.bugreport.model.github.GithubTarget
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.callbacks.onCancel
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import kotlinx.android.synthetic.main.activity_bug_report.*
|
||||
|
@ -223,12 +225,8 @@ open class BugReportActivity : AbsThemeActivity() {
|
|||
|
||||
private class ReportIssueAsyncTask private constructor(activity: Activity, private val report: Report, private val target: GithubTarget,
|
||||
private val login: GithubLogin) : DialogAsyncTask<Void, Void, String>(activity) {
|
||||
|
||||
override fun createDialog(context: Context): Dialog {
|
||||
return MaterialDialog.Builder(context)
|
||||
.progress(true, 0)
|
||||
.progressIndeterminateStyle(true)
|
||||
.title(R.string.bug_report_uploading)
|
||||
return AlertDialog.Builder(context)
|
||||
.show()
|
||||
}
|
||||
|
||||
|
@ -269,28 +267,27 @@ open class BugReportActivity : AbsThemeActivity() {
|
|||
|
||||
when (result) {
|
||||
RESULT_SUCCESS -> tryToFinishActivity()
|
||||
RESULT_BAD_CREDENTIALS -> MaterialDialog.Builder(context)
|
||||
.title(R.string.bug_report_failed)
|
||||
.content(R.string.bug_report_failed_wrong_credentials)
|
||||
.positiveText(android.R.string.ok)
|
||||
.show()
|
||||
RESULT_INVALID_TOKEN -> MaterialDialog.Builder(context)
|
||||
.title(R.string.bug_report_failed)
|
||||
.content(R.string.bug_report_failed_invalid_token)
|
||||
.positiveText(android.R.string.ok)
|
||||
.show()
|
||||
RESULT_ISSUES_NOT_ENABLED -> MaterialDialog.Builder(context)
|
||||
.title(R.string.bug_report_failed)
|
||||
.content(R.string.bug_report_failed_issues_not_available)
|
||||
.positiveText(android.R.string.ok)
|
||||
.show()
|
||||
else -> MaterialDialog.Builder(context)
|
||||
.title(R.string.bug_report_failed)
|
||||
.content(R.string.bug_report_failed_unknown)
|
||||
.positiveText(android.R.string.ok)
|
||||
.onPositive { _, _ -> tryToFinishActivity() }
|
||||
.cancelListener { tryToFinishActivity() }
|
||||
.show()
|
||||
RESULT_BAD_CREDENTIALS -> MaterialDialog(context).show {
|
||||
title(R.string.bug_report_failed)
|
||||
message(R.string.bug_report_failed_wrong_credentials)
|
||||
positiveButton(android.R.string.ok)
|
||||
}
|
||||
RESULT_INVALID_TOKEN -> MaterialDialog(context).show {
|
||||
title(R.string.bug_report_failed)
|
||||
message(R.string.bug_report_failed_invalid_token)
|
||||
positiveButton(android.R.string.ok)
|
||||
}
|
||||
RESULT_ISSUES_NOT_ENABLED -> MaterialDialog(context).show {
|
||||
title(R.string.bug_report_failed)
|
||||
message(R.string.bug_report_failed_issues_not_available)
|
||||
positiveButton(android.R.string.ok)
|
||||
}
|
||||
else -> MaterialDialog(context).show {
|
||||
title(R.string.bug_report_failed)
|
||||
message(R.string.bug_report_failed_unknown)
|
||||
positiveButton(android.R.string.ok) { tryToFinishActivity() }
|
||||
onCancel { tryToFinishActivity() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import code.name.monkey.retromusic.R
|
|||
import code.name.monkey.retromusic.ui.activities.base.AbsBaseActivity
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.list.listItems
|
||||
import kotlinx.android.synthetic.main.activity_album_tag_editor.*
|
||||
import org.jaudiotagger.audio.AudioFile
|
||||
import org.jaudiotagger.audio.AudioFileIO
|
||||
|
@ -34,18 +35,17 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() {
|
|||
private var songPaths: List<String>? = null
|
||||
|
||||
protected val show: MaterialDialog
|
||||
get() = MaterialDialog.Builder(this@AbsTagEditorActivity)
|
||||
.title(R.string.update_image)
|
||||
.items(*items)
|
||||
.itemsCallback { _, _, position, _ ->
|
||||
when (position) {
|
||||
0 -> getImageFromLastFM()
|
||||
1 -> startImagePicker()
|
||||
2 -> searchImageOnWeb()
|
||||
3 -> deleteImage()
|
||||
}
|
||||
}.show()
|
||||
|
||||
get() = MaterialDialog(this@AbsTagEditorActivity).show {
|
||||
title(R.string.update_image)
|
||||
listItems(items = items as List<String>) { _, position, _ ->
|
||||
when (position) {
|
||||
0 -> getImageFromLastFM()
|
||||
1 -> startImagePicker()
|
||||
2 -> searchImageOnWeb()
|
||||
3 -> deleteImage()
|
||||
}
|
||||
}
|
||||
}
|
||||
protected abstract val contentViewLayout: Int
|
||||
|
||||
internal val albumArtist: String?
|
||||
|
|
|
@ -5,8 +5,6 @@ import android.app.Dialog;
|
|||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.media.MediaScannerConnection;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
|
||||
|
@ -28,6 +26,8 @@ import java.io.IOException;
|
|||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.misc.DialogAsyncTask;
|
||||
import code.name.monkey.retromusic.misc.UpdateToastMediaScannerCompletionListener;
|
||||
|
@ -134,18 +134,16 @@ public class WriteTagsAsyncTask extends
|
|||
|
||||
@Override
|
||||
protected Dialog createDialog(@NonNull Context context) {
|
||||
return new MaterialDialog.Builder(context)
|
||||
.title(R.string.saving_changes)
|
||||
.cancelable(false)
|
||||
.progress(false, 0)
|
||||
.build();
|
||||
return new MaterialDialog(context)
|
||||
.title(R.string.saving_changes, "")
|
||||
.cancelable(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onProgressUpdate(@NonNull Dialog dialog, Integer... values) {
|
||||
super.onProgressUpdate(dialog, values);
|
||||
((MaterialDialog) dialog).setMaxProgress(values[1]);
|
||||
((MaterialDialog) dialog).setProgress(values[0]);
|
||||
//((MaterialDialog) dialog).setMaxProgress(values[1]);
|
||||
//((MaterialDialog) dialog).setProgress(values[0]);
|
||||
}
|
||||
|
||||
public static class LoadingInfo {
|
||||
|
|
|
@ -543,8 +543,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
|||
}
|
||||
}
|
||||
|
||||
private static class ListSongsAsyncTask extends
|
||||
ListingFilesDialogAsyncTask<ListSongsAsyncTask.LoadingInfo, Void, ArrayList<Song>> {
|
||||
private static class ListSongsAsyncTask extends ListingFilesDialogAsyncTask<ListSongsAsyncTask.LoadingInfo, Void, ArrayList<Song>> {
|
||||
|
||||
private final Object extra;
|
||||
private WeakReference<Context> contextWeakReference;
|
||||
|
@ -738,15 +737,8 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
|||
|
||||
@Override
|
||||
protected Dialog createDialog(@NonNull Context context) {
|
||||
return new MaterialDialog.Builder(context)
|
||||
.title(R.string.listing_files)
|
||||
.progress(true, 0)
|
||||
.progressIndeterminateStyle(true)
|
||||
.cancelListener(dialog -> cancel(false))
|
||||
.dismissListener(dialog -> cancel(false))
|
||||
.negativeText(android.R.string.cancel)
|
||||
.onNegative((dialog, which) -> cancel(false))
|
||||
.show();
|
||||
return new MaterialDialog(context)
|
||||
.title(R.string.listing_files,"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.animation.ArgbEvaluator
|
|||
import android.animation.ValueAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.AsyncTask
|
||||
import android.os.Bundle
|
||||
|
@ -12,6 +13,7 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.palette.graphics.Palette
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||
|
@ -142,6 +144,10 @@ class ColorFragment : AbsPlayerFragment() {
|
|||
|
||||
override fun onResourceReady(resource: BitmapPaletteWrapper, glideAnimation: Transition<in BitmapPaletteWrapper>?) {
|
||||
super.onResourceReady(resource, glideAnimation)
|
||||
|
||||
val background = resource.palette.getColor()
|
||||
val accentColor = resource.palette.getContrastColor(background)
|
||||
|
||||
val palette = resource.palette
|
||||
val swatch = RetroColorUtil.getSwatch(palette)
|
||||
|
||||
|
@ -298,3 +304,17 @@ class ColorFragment : AbsPlayerFragment() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun Palette.getContrastColor(background: Int): Int {
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
private fun Palette.getColor(): Int {
|
||||
return when {
|
||||
darkMutedSwatch != null -> darkMutedSwatch!!.rgb
|
||||
mutedSwatch != null -> mutedSwatch!!.rgb
|
||||
lightMutedSwatch != null -> lightMutedSwatch!!.rgb
|
||||
else -> Palette.Swatch(Color.BLACK, 1).rgb
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
package code.name.monkey.retromusic.ui.fragments.settings;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import code.name.monkey.appthemehelper.ThemeStore;
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceFragmentCompat;
|
||||
import code.name.monkey.retromusic.preferences.AlbumCoverStylePreference;
|
||||
import code.name.monkey.retromusic.preferences.AlbumCoverStylePreferenceDialog;
|
||||
import code.name.monkey.retromusic.preferences.BlacklistPreference;
|
||||
import code.name.monkey.retromusic.preferences.BlacklistPreferenceDialog;
|
||||
import code.name.monkey.retromusic.preferences.NowPlayingScreenPreference;
|
||||
import code.name.monkey.retromusic.preferences.NowPlayingScreenPreferenceDialog;
|
||||
import code.name.monkey.retromusic.util.NavigationUtil;
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
*/
|
||||
|
||||
public abstract class AbsSettingsFragment extends ATEPreferenceFragmentCompat {
|
||||
void showProToastAndNavigate(String message) {
|
||||
Toast.makeText(getContext(), message + " is Pro version feature.", Toast.LENGTH_SHORT).show();
|
||||
//noinspection ConstantConditions
|
||||
NavigationUtil.goToProVersion(getActivity());
|
||||
}
|
||||
|
||||
protected void setSummary(@NonNull Preference preference) {
|
||||
setSummary(preference, PreferenceManager
|
||||
.getDefaultSharedPreferences(preference.getContext())
|
||||
.getString(preference.getKey(), ""));
|
||||
}
|
||||
|
||||
void setSummary(Preference preference, @NonNull Object value) {
|
||||
String stringValue = value.toString();
|
||||
if (preference instanceof ListPreference) {
|
||||
ListPreference listPreference = (ListPreference) preference;
|
||||
int index = listPreference.findIndexOfValue(stringValue);
|
||||
preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
|
||||
} else {
|
||||
preference.setSummary(stringValue);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void invalidateSettings();
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
setDivider(new ColorDrawable(Color.TRANSPARENT));
|
||||
getListView().setBackgroundColor(ThemeStore.Companion.primaryColor(getContext()));
|
||||
getListView().setOverScrollMode(View.OVER_SCROLL_NEVER);
|
||||
getListView().setPadding(0, 0, 0, 0);
|
||||
getListView().setPaddingRelative(0, 0, 0, 0);
|
||||
invalidateSettings();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public DialogFragment onCreatePreferenceDialog(Preference preference) {
|
||||
if (preference instanceof NowPlayingScreenPreference) {
|
||||
return NowPlayingScreenPreferenceDialog.Companion.newInstance();
|
||||
} else if (preference instanceof BlacklistPreference) {
|
||||
return BlacklistPreferenceDialog.newInstance();
|
||||
} else if (preference instanceof AlbumCoverStylePreference) {
|
||||
return AlbumCoverStylePreferenceDialog.Companion.newInstance();
|
||||
}
|
||||
return super.onCreatePreferenceDialog(preference);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package code.name.monkey.retromusic.ui.fragments.settings
|
||||
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.PreferenceManager
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.retromusic.preferences.*
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
*/
|
||||
|
||||
abstract class AbsSettingsFragment : PreferenceFragmentCompat() {
|
||||
internal fun showProToastAndNavigate(message: String) {
|
||||
Toast.makeText(context, "$message is Pro version feature.", Toast.LENGTH_SHORT).show()
|
||||
|
||||
NavigationUtil.goToProVersion(activity!!)
|
||||
}
|
||||
|
||||
protected fun setSummary(preference: Preference) {
|
||||
setSummary(preference, PreferenceManager
|
||||
.getDefaultSharedPreferences(preference.context)
|
||||
.getString(preference.key, "")!!)
|
||||
}
|
||||
|
||||
internal fun setSummary(preference: Preference, value: Any) {
|
||||
val stringValue = value.toString()
|
||||
if (preference is ListPreference) {
|
||||
val index = preference.findIndexOfValue(stringValue)
|
||||
preference.setSummary(if (index >= 0) preference.entries[index] else null)
|
||||
} else {
|
||||
preference.summary = stringValue
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun invalidateSettings()
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
setDivider(ColorDrawable(Color.TRANSPARENT))
|
||||
listView.setBackgroundColor(ThemeStore.primaryColor(context!!))
|
||||
listView.overScrollMode = View.OVER_SCROLL_NEVER
|
||||
listView.setPadding(0, 0, 0, 0)
|
||||
listView.setPaddingRelative(0, 0, 0, 0)
|
||||
invalidateSettings()
|
||||
}
|
||||
|
||||
override fun onDisplayPreferenceDialog(preference: Preference) {
|
||||
var dialogFragment: DialogFragment? = null
|
||||
if (preference is NowPlayingScreenPreference) {
|
||||
dialogFragment = NowPlayingScreenPreferenceDialog.newInstance(preference.key);
|
||||
} else if (preference is AlbumCoverStylePreference) {
|
||||
dialogFragment = AlbumCoverStylePreferenceDialog.newInstance(preference.key);
|
||||
}
|
||||
if (preference is MaterialListPreference) {
|
||||
val entries = preference.entries
|
||||
|
||||
dialogFragment = MaterialListPreferenceDialog.newInstance(preference)
|
||||
}
|
||||
if (preference is BlacklistPreference) {
|
||||
dialogFragment = BlacklistPreferenceDialog.newInstance(preference.key)
|
||||
}
|
||||
if (dialogFragment != null) {
|
||||
// The dialog was created (it was one of our custom Preferences), show the dialog for it
|
||||
dialogFragment.setTargetFragment(this, 0);
|
||||
dialogFragment.show(this.fragmentManager, "android.support.v7.preference.PreferenceFragment.DIALOG");
|
||||
} else {
|
||||
// Dialog creation could not be handled here. Try with the super method.
|
||||
super.onDisplayPreferenceDialog(preference);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
package code.name.monkey.retromusic.ui.fragments.settings
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.preference.Preference
|
||||
|
||||
import android.view.View
|
||||
import code.name.monkey.retromusic.R
|
||||
|
||||
/**
|
||||
|
@ -23,4 +22,10 @@ class ImageSettingFragment : AbsSettingsFragment() {
|
|||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
addPreferencesFromResource(R.xml.pref_images)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val preference = findPreference("auto_download_images_policy")
|
||||
setSummary(preference)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,10 @@ import android.content.SharedPreferences
|
|||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.preference.TwoStatePreference
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil.*
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
|
@ -26,39 +27,37 @@ class NowPlayingSettingsFragment : AbsSettingsFragment(), SharedPreferences.OnSh
|
|||
}
|
||||
true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
addPreferencesFromResource(R.xml.pref_now_playing_screen)
|
||||
}
|
||||
|
||||
private fun updateNowPlayingScreenSummary() {
|
||||
private fun updateAlbumCoverStyleSummary() {
|
||||
findPreference(ALBUM_COVER_STYLE).setSummary(getInstance().albumCoverStyle.titleRes)
|
||||
}
|
||||
|
||||
findPreference("now_playing_screen_id").setSummary(PreferenceUtil.getInstance().nowPlayingScreen.titleRes)
|
||||
private fun updateNowPlayingScreenSummary() {
|
||||
findPreference(NOW_PLAYING_SCREEN_ID).setSummary(getInstance().nowPlayingScreen.titleRes)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
PreferenceUtil.getInstance().registerOnSharedPreferenceChangedListener(this)
|
||||
getInstance().registerOnSharedPreferenceChangedListener(this)
|
||||
val preference = findPreference("album_cover_transform")
|
||||
setSummary(preference)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
|
||||
PreferenceUtil.getInstance().unregisterOnSharedPreferenceChangedListener(this)
|
||||
getInstance().unregisterOnSharedPreferenceChangedListener(this)
|
||||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
||||
when (key) {
|
||||
PreferenceUtil.NOW_PLAYING_SCREEN_ID -> updateNowPlayingScreenSummary()
|
||||
PreferenceUtil.ALBUM_COVER_STYLE -> updateAlbumCoverStyleSummary()
|
||||
PreferenceUtil.CIRCULAR_ALBUM_ART, PreferenceUtil.CAROUSEL_EFFECT -> invalidateSettings()
|
||||
NOW_PLAYING_SCREEN_ID -> updateNowPlayingScreenSummary()
|
||||
ALBUM_COVER_STYLE -> updateAlbumCoverStyleSummary()
|
||||
CIRCULAR_ALBUM_ART, CAROUSEL_EFFECT -> invalidateSettings()
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateAlbumCoverStyleSummary() {
|
||||
findPreference("album_cover_style_id").setSummary(PreferenceUtil.getInstance().albumCoverStyle.titleRes)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package code.name.monkey.retromusic.ui.fragments.settings
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
|
||||
import code.name.monkey.retromusic.R
|
||||
|
||||
|
@ -18,4 +19,10 @@ class OtherSettingsFragment : AbsSettingsFragment() {
|
|||
addPreferencesFromResource(R.xml.pref_playlists)
|
||||
addPreferencesFromResource(R.xml.pref_advanced)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val preference = findPreference("last_added_interval")
|
||||
setSummary(preference)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,8 +28,6 @@ class PersonaizeSettingsFragment : AbsSettingsFragment(), SharedPreferences.OnSh
|
|||
activity!!.recreate()
|
||||
true
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
|
@ -41,11 +39,19 @@ class PersonaizeSettingsFragment : AbsSettingsFragment(), SharedPreferences.OnSh
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
PreferenceUtil.getInstance().registerOnSharedPreferenceChangedListener(this)
|
||||
|
||||
var preference = findPreference("album_grid_style")
|
||||
setSummary(preference)
|
||||
preference = findPreference("artist_grid_style")
|
||||
setSummary(preference)
|
||||
preference = findPreference("home_artist_grid_style")
|
||||
setSummary(preference)
|
||||
preference = findPreference("tab_text_mode")
|
||||
setSummary(preference)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
|
||||
PreferenceUtil.getInstance().unregisterOnSharedPreferenceChangedListener(this)
|
||||
}
|
||||
|
||||
|
@ -54,5 +60,4 @@ class PersonaizeSettingsFragment : AbsSettingsFragment(), SharedPreferences.OnSh
|
|||
PreferenceUtil.CAROUSEL_EFFECT -> invalidateSettings()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package code.name.monkey.retromusic.ui.fragments.settings
|
||||
|
||||
import android.graphics.Color
|
||||
import android.graphics.Color.BLUE
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.preference.TwoStatePreference
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.*
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEColorPreference
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||
|
@ -13,7 +14,9 @@ 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.color.ColorChooserDialog
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.color.colorChooser
|
||||
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
|
@ -23,16 +26,26 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
|
|||
|
||||
override fun invalidateSettings() {
|
||||
val primaryColorPref = findPreference("primary_color") as ATEColorPreference
|
||||
primaryColorPref.isVisible = PreferenceUtil.getInstance().generalTheme == R.style.Theme_RetroMusic_Color
|
||||
primaryColorPref.isVisible = PreferenceUtil.getInstance().generalTheme == code.name.monkey.retromusic.R.style.Theme_RetroMusic_Color
|
||||
val primaryColor = ThemeStore.primaryColor(activity!!)
|
||||
primaryColorPref.setColor(primaryColor, ColorUtil.darkenColor(primaryColor))
|
||||
primaryColorPref.setOnPreferenceClickListener {
|
||||
ColorChooserDialog.Builder(activity!!, R.string.primary_color)
|
||||
.accentMode(false)
|
||||
.allowUserColorInput(true)
|
||||
.allowUserColorInputAlpha(false)
|
||||
.preselect(primaryColor)
|
||||
.show(activity!!)
|
||||
MaterialDialog(activity!!).show {
|
||||
title(code.name.monkey.retromusic.R.string.primary_color)
|
||||
positiveButton(R.string.set)
|
||||
colorChooser(initialSelection = BLUE, allowCustomArgb = true, colors = PRIMARY_COLORS, subColors = PRIMARY_COLORS_SUB) { _, color ->
|
||||
val theme = if (ColorUtil.isColorLight(color))
|
||||
PreferenceUtil.getThemeResFromPrefValue("light")
|
||||
else
|
||||
PreferenceUtil.getThemeResFromPrefValue("dark")
|
||||
|
||||
ThemeStore.editTheme(context).activityTheme(theme).primaryColor(color).commit()
|
||||
|
||||
if (VersionUtils.hasNougatMR())
|
||||
DynamicShortcutManager(context).updateDynamicShortcuts()
|
||||
activity!!.recreate()
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
|
@ -55,8 +68,8 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
|
|||
when (theme) {
|
||||
"light" -> ThemeStore.editTheme(context!!).primaryColor(Color.WHITE).commit()
|
||||
"black" -> ThemeStore.editTheme(context!!).primaryColor(Color.BLACK).commit()
|
||||
"dark" -> ThemeStore.editTheme(context!!).primaryColor(ContextCompat.getColor(context!!, R.color.md_grey_900)).commit()
|
||||
"color" -> ThemeStore.editTheme(context!!).primaryColor(ContextCompat.getColor(context!!, R.color.md_blue_grey_800)).commit()
|
||||
"dark" -> ThemeStore.editTheme(context!!).primaryColor(ContextCompat.getColor(context!!, code.name.monkey.retromusic.R.color.md_grey_900)).commit()
|
||||
"color" -> ThemeStore.editTheme(context!!).primaryColor(ContextCompat.getColor(context!!, code.name.monkey.retromusic.R.color.md_blue_grey_800)).commit()
|
||||
}
|
||||
|
||||
ThemeStore.editTheme(activity!!)
|
||||
|
@ -77,13 +90,17 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
|
|||
accentColorPref.setColor(accentColor, ColorUtil.darkenColor(accentColor))
|
||||
|
||||
accentColorPref.setOnPreferenceClickListener {
|
||||
ColorChooserDialog.Builder(context!!, R.string.accent_color)
|
||||
.accentMode(true)
|
||||
.allowUserColorInput(true)
|
||||
.allowUserColorInputAlpha(false)
|
||||
.preselect(accentColor)
|
||||
.show(activity!!)
|
||||
true
|
||||
MaterialDialog(activity!!).show {
|
||||
title(code.name.monkey.retromusic.R.string.primary_color)
|
||||
positiveButton(R.string.set)
|
||||
colorChooser(colors = ACCENT_COLORS, subColors = ACCENT_COLORS_SUB) { _, color ->
|
||||
ThemeStore.editTheme(context).accentColor(color).commit()
|
||||
if (VersionUtils.hasNougatMR())
|
||||
DynamicShortcutManager(context).updateDynamicShortcuts()
|
||||
activity!!.recreate()
|
||||
}
|
||||
}
|
||||
return@setOnPreferenceClickListener true
|
||||
}
|
||||
|
||||
val colorAppShortcuts = findPreference("should_color_app_shortcuts") as TwoStatePreference
|
||||
|
@ -102,6 +119,6 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
|
|||
}
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
addPreferencesFromResource(R.xml.pref_general)
|
||||
addPreferencesFromResource( R.xml.pref_general)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
package code.name.monkey.retromusic.util;
|
||||
|
||||
import android.graphics.Color;
|
||||
import androidx.annotation.ColorInt;
|
||||
|
||||
public class ColorUtils {
|
||||
|
||||
public static boolean isColorLight(@ColorInt int color) {
|
||||
return getColorDarkness(color) < 0.5;
|
||||
}
|
||||
|
||||
private static double getColorDarkness(@ColorInt int color) {
|
||||
if (color == Color.BLACK)
|
||||
return 1.0;
|
||||
else if (color == Color.WHITE || color == Color.TRANSPARENT)
|
||||
return 0.0;
|
||||
else
|
||||
return (1 - (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color)) / 255);
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
public static int getInverseColor(@ColorInt int color) {
|
||||
return (0xFFFFFF - color) | 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
public static boolean isColorSaturated(@ColorInt int color) {
|
||||
double max = Math.max(0.299 * Color.red(color), Math.max(0.587 * Color.green(color), 0.114 * Color.blue(color)));
|
||||
double min = Math.min(0.299 * Color.red(color), Math.min(0.587 * Color.green(color), 0.114 * Color.blue(color)));
|
||||
double diff = Math.abs(max - min);
|
||||
return diff > 20;
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
public static int getMixedColor(@ColorInt int color1, @ColorInt int color2) {
|
||||
return Color.rgb(
|
||||
(Color.red(color1) + Color.red(color2)) / 2,
|
||||
(Color.green(color1) + Color.green(color2)) / 2,
|
||||
(Color.blue(color1) + Color.blue(color2)) / 2
|
||||
);
|
||||
}
|
||||
|
||||
public static double getDifference(@ColorInt int color1, @ColorInt int color2) {
|
||||
double diff = Math.abs(0.299 * (Color.red(color1) - Color.red(color2)));
|
||||
diff += Math.abs(0.587 * (Color.green(color1) - Color.green(color2)));
|
||||
diff += Math.abs(0.114 * (Color.blue(color1) - Color.blue(color2)));
|
||||
return diff;
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
public static int getReadableText(@ColorInt int textColor, @ColorInt int backgroundColor) {
|
||||
return getReadableText(textColor, backgroundColor, 100);
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
public static int getReadableText(@ColorInt int textColor, @ColorInt int backgroundColor, int difference) {
|
||||
boolean isLight = isColorLight(backgroundColor);
|
||||
for (int i = 0; getDifference(textColor, backgroundColor) < difference && i < 100; i++) {
|
||||
textColor = getMixedColor(textColor, isLight ? Color.BLACK : Color.WHITE);
|
||||
}
|
||||
|
||||
return textColor;
|
||||
}
|
||||
|
||||
}
|
|
@ -7,16 +7,15 @@ import android.content.SharedPreferences.Editor;
|
|||
import android.content.res.TypedArray;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.google.android.material.bottomnavigation.LabelVisibilityMode;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import code.name.monkey.retromusic.App;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.helper.SortOrder;
|
||||
|
@ -61,7 +60,7 @@ public final class PreferenceUtil {
|
|||
public static final String HOME_ARTIST_GRID_STYLE = "home_artist_grid_style";
|
||||
public static final String ARTIST_GRID_STYLE = "artist_grid_style";
|
||||
public static final String TOGGLE_ADD_CONTROLS = "toggle_add_controls";
|
||||
public static final String ALBUM_COVER_STYLE = "album_cover_style";
|
||||
public static final String ALBUM_COVER_STYLE = "album_cover_style_id";
|
||||
public static final String ALBUM_COVER_TRANSFORM = "album_cover_transform";
|
||||
public static final String TAB_TEXT_MODE = "tab_text_mode";
|
||||
private static final String GENRE_SORT_ORDER = "genre_sort_order";
|
||||
|
@ -109,6 +108,7 @@ public final class PreferenceUtil {
|
|||
private static final String PAUSE_ON_ZERO_VOLUME = "pause_on_zero_volume";
|
||||
private static final String NOW_PLAYING_SCREEN = "now_playing_screen";
|
||||
private static final String SNOW_FALL_EFFECT = "snow_fall_effect";
|
||||
private static final String FILTER_SONG = "filter_song";
|
||||
private static PreferenceUtil sInstance;
|
||||
private final SharedPreferences mPreferences;
|
||||
|
||||
|
@ -140,6 +140,10 @@ public final class PreferenceUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public int getFilterLength() {
|
||||
return mPreferences.getInt(FILTER_SONG, 20);
|
||||
}
|
||||
|
||||
public boolean isSnowFall() {
|
||||
return mPreferences.getBoolean(SNOW_FALL_EFFECT, false);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class RetroColorUtil {
|
|||
int background = getSwatch(palette).getRgb();
|
||||
|
||||
if (inverse != -1) {
|
||||
return ColorUtils.getReadableText(inverse, background, 150);
|
||||
return ColorUtil.INSTANCE.getReadableText(inverse, background, 150);
|
||||
}
|
||||
return ColorUtil.INSTANCE.stripAlpha(getSwatch(palette).getTitleTextColor());
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ import android.content.res.ColorStateList
|
|||
import android.graphics.Color
|
||||
import android.util.AttributeSet
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.retromusic.R
|
||||
|
||||
|
@ -31,8 +33,20 @@ class ColorIconsImageView : AppCompatImageView {
|
|||
|
||||
private fun setIconBackgroundColor(color: Int) {
|
||||
setBackgroundResource(R.drawable.color_circle_gradient)
|
||||
backgroundTintList = ColorStateList.valueOf(ColorUtil.adjustAlpha(color, 0.3f))
|
||||
imageTintList = ColorStateList.valueOf(color)
|
||||
|
||||
val alpha = if (ATHUtil.isWindowBackgroundDark(context)) {
|
||||
1.0f
|
||||
} else {
|
||||
0.28f
|
||||
}
|
||||
val filterColor = if (ATHUtil.isWindowBackgroundDark(context)) {
|
||||
ThemeStore.textColorPrimary(context)
|
||||
} else {
|
||||
color
|
||||
}
|
||||
|
||||
backgroundTintList = ColorStateList.valueOf(ColorUtil.adjustAlpha(color, alpha))
|
||||
imageTintList = ColorStateList.valueOf(filterColor)
|
||||
requestLayout()
|
||||
invalidate()
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
<code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView
|
||||
style="@style/SubTitleTextAppearance"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/for_you" />
|
||||
android:text="@string/for_you"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -23,14 +23,14 @@
|
|||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
<code.name.monkey.retromusic.views.ColorIconsImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/abs_history_playlist"
|
||||
android:padding="12dp"
|
||||
app:srcCompat="@drawable/ic_access_time_white_24dp"
|
||||
app:tint="@color/md_blue_A700" />
|
||||
app:iconBackgroundColor="@color/md_blue_A700"
|
||||
app:srcCompat="@drawable/ic_access_time_white_24dp" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="match_parent"
|
||||
|
@ -49,14 +49,14 @@
|
|||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
<code.name.monkey.retromusic.views.ColorIconsImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/abs_last_added_playlist"
|
||||
android:padding="12dp"
|
||||
app:srcCompat="@drawable/ic_library_add_white_24dp"
|
||||
app:tint="@color/md_red_A700" />
|
||||
app:iconBackgroundColor="@color/md_red_A700"
|
||||
app:srcCompat="@drawable/ic_library_add_white_24dp" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="match_parent"
|
||||
|
@ -75,14 +75,14 @@
|
|||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
<code.name.monkey.retromusic.views.ColorIconsImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/abs_top_tracks_playlist"
|
||||
android:padding="12dp"
|
||||
app:srcCompat="@drawable/ic_trending_up_white_24dp"
|
||||
app:tint="@color/md_deep_purple_A700" />
|
||||
app:iconBackgroundColor="@color/md_deep_purple_A700"
|
||||
app:srcCompat="@drawable/ic_trending_up_white_24dp" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="match_parent"
|
||||
|
@ -101,14 +101,14 @@
|
|||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
<code.name.monkey.retromusic.views.ColorIconsImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/abs_shuffle"
|
||||
android:padding="12dp"
|
||||
app:srcCompat="@drawable/ic_shuffle_white_24dp"
|
||||
app:tint="@color/md_green_A700" />
|
||||
app:iconBackgroundColor="@color/md_green_A700"
|
||||
app:srcCompat="@drawable/ic_shuffle_white_24dp" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
android:layout_height="1dp"
|
||||
android:layout_columnSpan="2"
|
||||
android:layout_gravity="fill_horizontal"
|
||||
android:background="@color/md_divider_white"
|
||||
android:background="@color/md_white_1000"
|
||||
tools:ignore="Orientation"/>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
<string name="action_scan">Scan</string>
|
||||
<string name="action_scan_directory">Scan directory</string>
|
||||
<string name="action_search">Search</string>
|
||||
<string name="set">Set</string>
|
||||
<string name="action_set">Start</string>
|
||||
<string name="action_set_as_ringtone">Set as ringtone</string>
|
||||
<string name="action_set_as_start_directory">Set as start directory</string>
|
||||
|
@ -593,4 +594,8 @@
|
|||
<string name="send_crash_log">Send crash log</string>
|
||||
<string name="pinterest_page">Pinterest</string>
|
||||
<string name="pinterest_page_summary">Hmm</string>
|
||||
<string name="pref_filter_song_title">Filter song length</string>
|
||||
<string name="md_error_label">Error</string>
|
||||
<string name="md_storage_perm_error">Permission error</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -1,79 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="Theme.RetroMusic.Base.Black" parent="@style/Theme.RetroMusic.Base">
|
||||
|
||||
<item name="dividerColor">#18FFFFFF</item>
|
||||
|
||||
<item name="defaultFooterColor">@color/md_grey_800</item>
|
||||
|
||||
<item name="cardBackgroundColor">@color/md_grey_900</item>
|
||||
|
||||
<item name="md_background_color">@color/md_grey_900</item>
|
||||
|
||||
<item name="android:windowBackground">@color/md_black_1000</item>
|
||||
|
||||
<item name="colorPrimary">@android:color/black</item>
|
||||
<item name="android:colorPrimary">@android:color/black</item>
|
||||
|
||||
<item name="bottomSheetDialogTheme">@style/BottomSheetDialog</item>
|
||||
|
||||
|
||||
<item name="android:windowActivityTransitions">true</item>
|
||||
<item name="android:windowExitTransition">@transition/grid_exit</item>
|
||||
<item name="android:windowEnterTransition">@transition/grid_exit</item>
|
||||
|
||||
<item name="android:windowSharedElementEnterTransition">@transition/grid_exit</item>
|
||||
<item name="android:windowSharedElementExitTransition">@transition/grid_exit</item>
|
||||
<item name="android:fontFamily">@font/circular</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.RetroMusic.Base.Light" parent="Theme.MaterialComponents.Light.NoActionBar">
|
||||
<item name="android:windowActionBarOverlay">true</item>
|
||||
<item name="windowActionBarOverlay">true</item>
|
||||
|
||||
<item name="md_dark_theme">false</item>
|
||||
|
||||
<item name="roundSelector">@drawable/round_selector</item>
|
||||
<item name="rectSelector">@drawable/rect_selector</item>
|
||||
<item name="rectSelectorStrong">@drawable/rect_selector_strong</item>
|
||||
|
||||
<item name="cardBackgroundColor">@color/md_white_1000</item>
|
||||
|
||||
<item name="defaultFooterColor">@color/md_grey_500</item>
|
||||
|
||||
<item name="dividerColor">@color/md_divider_black</item>
|
||||
<item name="iconColor">@color/ate_secondary_text_light</item>
|
||||
|
||||
<item name="toolbarPopupTheme">@style/ThemeOverlay.AppCompat.Light</item>
|
||||
|
||||
<!-- just in case-->
|
||||
<item name="android:windowBackground">@color/md_white_1000</item>
|
||||
<item name="colorAccent">@android:color/black</item>
|
||||
<item name="colorPrimary">@color/md_white_1000</item>
|
||||
|
||||
<!-- necessary to find the overflow button later in the layout-->
|
||||
<item name="android:actionOverflowButtonStyle">@style/Widget.ActionButton.Overflow</item>
|
||||
|
||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
|
||||
|
||||
<item name="bottomSheetDialogTheme">@style/BottomSheetDialog</item>
|
||||
|
||||
<item name="android:windowActivityTransitions">true</item>
|
||||
<item name="android:windowExitTransition">@transition/grid_exit</item>
|
||||
<item name="android:windowEnterTransition">@transition/grid_exit</item>
|
||||
|
||||
<item name="android:windowSharedElementEnterTransition">@transition/grid_exit</item>
|
||||
<item name="android:windowSharedElementExitTransition">@transition/grid_exit</item>
|
||||
<item name="android:fontFamily">@font/circular</item>
|
||||
</style>
|
||||
|
||||
<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>
|
||||
|
||||
<item name="android:windowActionBarOverlay">true</item>
|
||||
<item name="windowActionBarOverlay">true</item>
|
||||
|
||||
<item name="md_dark_theme">true</item>
|
||||
|
||||
<item name="roundSelector">@drawable/round_selector_dark</item>
|
||||
<item name="rectSelector">@drawable/rect_selector_dark</item>
|
||||
|
@ -83,7 +20,7 @@
|
|||
|
||||
<item name="defaultFooterColor">@color/md_grey_800</item>
|
||||
|
||||
<item name="dividerColor">@color/md_divider_white</item>
|
||||
<item name="dividerColor">@color/md_grey_800</item>
|
||||
<item name="iconColor">@color/ate_secondary_text_dark</item>
|
||||
|
||||
<item name="toolbarPopupTheme">@style/ThemeOverlay.AppCompat</item>
|
||||
|
@ -116,6 +53,79 @@
|
|||
</style>
|
||||
|
||||
|
||||
<style name="Theme.RetroMusic.Base.Black" parent="@style/Theme.RetroMusic.Base">
|
||||
|
||||
<item name="dividerColor">#18FFFFFF</item>
|
||||
|
||||
<item name="defaultFooterColor">@color/md_grey_800</item>
|
||||
|
||||
<item name="cardBackgroundColor">@color/md_grey_900</item>
|
||||
|
||||
<item name="md_background_color">@color/md_grey_900</item>
|
||||
|
||||
<item name="android:windowBackground">@color/md_black_1000</item>
|
||||
|
||||
<item name="colorPrimary">@android:color/black</item>
|
||||
<item name="android:colorPrimary">@android:color/black</item>
|
||||
|
||||
<item name="bottomSheetDialogTheme">@style/BottomSheetDialog</item>
|
||||
|
||||
|
||||
<item name="android:windowActivityTransitions">true</item>
|
||||
<item name="android:windowExitTransition">@transition/grid_exit</item>
|
||||
<item name="android:windowEnterTransition">@transition/grid_exit</item>
|
||||
|
||||
<item name="android:windowSharedElementEnterTransition">@transition/grid_exit</item>
|
||||
<item name="android:windowSharedElementExitTransition">@transition/grid_exit</item>
|
||||
<item name="android:fontFamily">@font/circular</item>
|
||||
</style>
|
||||
|
||||
<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>
|
||||
|
||||
<item name="android:windowActionBarOverlay">true</item>
|
||||
<item name="windowActionBarOverlay">true</item>
|
||||
|
||||
|
||||
<item name="roundSelector">@drawable/round_selector</item>
|
||||
<item name="rectSelector">@drawable/rect_selector</item>
|
||||
<item name="rectSelectorStrong">@drawable/rect_selector_strong</item>
|
||||
|
||||
<item name="cardBackgroundColor">@color/md_white_1000</item>
|
||||
|
||||
<item name="defaultFooterColor">@color/md_grey_500</item>
|
||||
|
||||
<item name="dividerColor">@color/md_grey_200</item>
|
||||
<item name="iconColor">@color/ate_secondary_text_light</item>
|
||||
|
||||
<item name="toolbarPopupTheme">@style/ThemeOverlay.AppCompat.Light</item>
|
||||
|
||||
<!-- just in case-->
|
||||
<item name="android:windowBackground">@color/md_white_1000</item>
|
||||
<item name="colorAccent">@android:color/black</item>
|
||||
<item name="colorPrimary">@color/md_white_1000</item>
|
||||
|
||||
<!-- necessary to find the overflow button later in the layout-->
|
||||
<item name="android:actionOverflowButtonStyle">@style/Widget.ActionButton.Overflow</item>
|
||||
|
||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
|
||||
|
||||
<item name="bottomSheetDialogTheme">@style/BottomSheetDialog</item>
|
||||
|
||||
<item name="android:windowActivityTransitions">true</item>
|
||||
<item name="android:windowExitTransition">@transition/grid_exit</item>
|
||||
<item name="android:windowEnterTransition">@transition/grid_exit</item>
|
||||
|
||||
<item name="android:windowSharedElementEnterTransition">@transition/grid_exit</item>
|
||||
<item name="android:windowSharedElementExitTransition">@transition/grid_exit</item>
|
||||
<item name="android:fontFamily">@font/circular</item>
|
||||
</style>
|
||||
|
||||
|
||||
<style name="MusicProgressSliderParent">
|
||||
<item name="android:progressDrawable">@android:color/transparent</item>
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
android:title="@string/pref_keep_pause_on_zero_volume_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<!-- <code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="now_playing_screen"
|
||||
android:summary="@string/pref_now_playing_screen_summary"
|
||||
android:title="@string/pref_now_playing_screen_title"
|
||||
app:iconSpaceReserved="false" />-->
|
||||
<SeekBarPreference
|
||||
android:defaultValue="30"
|
||||
android:key="filter_song"
|
||||
android:max="60"
|
||||
android:title="@string/pref_filter_song_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
|
||||
android:defaultValue="false"
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
android:summary="@string/pref_summary_gapless_playback"
|
||||
android:title="@string/pref_title_gapless_playback" />
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEListPreference
|
||||
<code.name.monkey.retromusic.preferences.MaterialListPreference
|
||||
android:defaultValue="system"
|
||||
app:iconSpaceReserved="false"
|
||||
android:entries="@array/pref_equalizer_types_titles"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<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.ATEListPreference
|
||||
<code.name.monkey.retromusic.preferences.MaterialListPreference
|
||||
android:defaultValue="0"
|
||||
android:entries="@array/pref_grid_style_list_titles"
|
||||
android:entryValues="@array/pref_grid_style_list_values"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<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.ATEListPreference
|
||||
<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"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
android:summary="@string/pref_summary_ignore_media_store_artwork"
|
||||
android:title="@string/pref_title_ignore_media_store_artwork" />
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEListPreference
|
||||
<code.name.monkey.retromusic.preferences.MaterialListPreference
|
||||
android:defaultValue="only_wifi"
|
||||
app:iconSpaceReserved="false"
|
||||
android:entries="@array/pref_auto_download_images_titles"
|
||||
|
|
|
@ -12,13 +12,11 @@
|
|||
android:title="@string/pref_title_album_cover_style"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEListPreference
|
||||
<code.name.monkey.retromusic.preferences.MaterialListPreference
|
||||
android:defaultValue="0"
|
||||
android:entries="@array/pref_album_cover_transform_entities"
|
||||
android:entryValues="@array/pref_album_cover_transform_values"
|
||||
android:key="album_cover_transform"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null"
|
||||
android:title="@string/pref_title_album_cover_transform"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory android:title="@string/pref_header_playlists">
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEListPreference
|
||||
<code.name.monkey.retromusic.preferences.MaterialListPreference
|
||||
android:defaultValue="this_month"
|
||||
android:entries="@array/pref_playlists_last_added_interval_titles"
|
||||
android:entryValues="@array/pref_playlists_last_added_interval_values"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<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.ATEListPreference
|
||||
<code.name.monkey.retromusic.preferences.MaterialListPreference
|
||||
android:defaultValue="0"
|
||||
android:entries="@array/pref_grid_style_list_titles"
|
||||
android:entryValues="@array/pref_grid_style_list_values"
|
||||
|
@ -12,7 +12,7 @@
|
|||
android:title="@string/pref_title_album_grid_style"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEListPreference
|
||||
<code.name.monkey.retromusic.preferences.MaterialListPreference
|
||||
android:defaultValue="0"
|
||||
android:entries="@array/pref_grid_style_list_titles"
|
||||
android:entryValues="@array/pref_grid_style_list_values"
|
||||
|
@ -23,7 +23,7 @@
|
|||
app:iconSpaceReserved="false" />
|
||||
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEListPreference
|
||||
<code.name.monkey.retromusic.preferences.MaterialListPreference
|
||||
android:defaultValue="0"
|
||||
android:entries="@array/pref_home_grid_style_list_titles"
|
||||
android:entryValues="@array/pref_home_grid_style_list_values"
|
||||
|
@ -43,7 +43,7 @@
|
|||
android:title="@string/pref_album_detail_style"
|
||||
app:iconSpaceReserved="false" />-->
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEListPreference
|
||||
<code.name.monkey.retromusic.preferences.MaterialListPreference
|
||||
android:defaultValue="0"
|
||||
android:entries="@array/pref_tab_text_mode_titles"
|
||||
android:entryValues="@array/pref_tab_text_mode_values"
|
||||
|
|
|
@ -33,7 +33,9 @@ dependencies {
|
|||
implementation 'androidx.preference:preference:1.0.0'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
// Used for the list preference classes
|
||||
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
|
||||
implementation 'com.afollestad.material-dialogs:commons:0.9.6.0'
|
||||
implementation "com.afollestad.material-dialogs:core:$materialDialog"
|
||||
implementation "com.afollestad.material-dialogs:core:$materialDialog"
|
||||
implementation 'com.afollestad.material-dialogs:input:2.0.0'
|
||||
implementation 'com.afollestad.material-dialogs:color:2.0.0'
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,189 @@
|
|||
package code.name.monkey.appthemehelper
|
||||
|
||||
/**
|
||||
* Designed and developed by Aidan Follestad (@afollestad)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import android.graphics.Color.parseColor
|
||||
|
||||
val PRIMARY_COLORS = intArrayOf(
|
||||
parseColor("#F44336"), parseColor("#E91E63"), parseColor("#9C27B0"),
|
||||
parseColor("#673AB7"), parseColor("#3F51B5"), parseColor("#2196F3"),
|
||||
parseColor("#03A9F4"), parseColor("#00BCD4"), parseColor("#009688"),
|
||||
parseColor("#4CAF50"), parseColor("#8BC34A"), parseColor("#CDDC39"),
|
||||
parseColor("#FFEB3B"), parseColor("#FFC107"), parseColor("#FF9800"),
|
||||
parseColor("#FF5722"), parseColor("#795548"), parseColor("#9E9E9E"),
|
||||
parseColor("#607D8B")
|
||||
)
|
||||
|
||||
val PRIMARY_COLORS_SUB = arrayOf(
|
||||
intArrayOf(
|
||||
parseColor("#FFEBEE"), parseColor("#FFCDD2"), parseColor("#EF9A9A"),
|
||||
parseColor("#E57373"), parseColor("#EF5350"), parseColor("#F44336"),
|
||||
parseColor("#E53935"), parseColor("#D32F2F"), parseColor("#C62828"),
|
||||
parseColor("#B71C1C")
|
||||
), intArrayOf(
|
||||
parseColor("#FCE4EC"), parseColor("#F8BBD0"), parseColor("#F48FB1"),
|
||||
parseColor("#F06292"), parseColor("#EC407A"), parseColor("#E91E63"),
|
||||
parseColor("#D81B60"), parseColor("#C2185B"), parseColor("#AD1457"),
|
||||
parseColor("#880E4F")
|
||||
), intArrayOf(
|
||||
parseColor("#F3E5F5"), parseColor("#E1BEE7"), parseColor("#CE93D8"),
|
||||
parseColor("#BA68C8"), parseColor("#AB47BC"), parseColor("#9C27B0"),
|
||||
parseColor("#8E24AA"), parseColor("#7B1FA2"), parseColor("#6A1B9A"),
|
||||
parseColor("#4A148C")
|
||||
), intArrayOf(
|
||||
parseColor("#EDE7F6"), parseColor("#D1C4E9"), parseColor("#B39DDB"),
|
||||
parseColor("#9575CD"), parseColor("#7E57C2"), parseColor("#673AB7"),
|
||||
parseColor("#5E35B1"), parseColor("#512DA8"), parseColor("#4527A0"),
|
||||
parseColor("#311B92")
|
||||
), intArrayOf(
|
||||
parseColor("#E8EAF6"), parseColor("#C5CAE9"), parseColor("#9FA8DA"),
|
||||
parseColor("#7986CB"), parseColor("#5C6BC0"), parseColor("#3F51B5"),
|
||||
parseColor("#3949AB"), parseColor("#303F9F"), parseColor("#283593"),
|
||||
parseColor("#1A237E")
|
||||
), intArrayOf(
|
||||
parseColor("#E3F2FD"), parseColor("#BBDEFB"), parseColor("#90CAF9"),
|
||||
parseColor("#64B5F6"), parseColor("#42A5F5"), parseColor("#2196F3"),
|
||||
parseColor("#1E88E5"), parseColor("#1976D2"), parseColor("#1565C0"),
|
||||
parseColor("#0D47A1")
|
||||
), intArrayOf(
|
||||
parseColor("#E1F5FE"), parseColor("#B3E5FC"), parseColor("#81D4FA"),
|
||||
parseColor("#4FC3F7"), parseColor("#29B6F6"), parseColor("#03A9F4"),
|
||||
parseColor("#039BE5"), parseColor("#0288D1"), parseColor("#0277BD"),
|
||||
parseColor("#01579B")
|
||||
), intArrayOf(
|
||||
parseColor("#E0F7FA"), parseColor("#B2EBF2"), parseColor("#80DEEA"),
|
||||
parseColor("#4DD0E1"), parseColor("#26C6DA"), parseColor("#00BCD4"),
|
||||
parseColor("#00ACC1"), parseColor("#0097A7"), parseColor("#00838F"),
|
||||
parseColor("#006064")
|
||||
), intArrayOf(
|
||||
parseColor("#E0F2F1"), parseColor("#B2DFDB"), parseColor("#80CBC4"),
|
||||
parseColor("#4DB6AC"), parseColor("#26A69A"), parseColor("#009688"),
|
||||
parseColor("#00897B"), parseColor("#00796B"), parseColor("#00695C"),
|
||||
parseColor("#004D40")
|
||||
), intArrayOf(
|
||||
parseColor("#E8F5E9"), parseColor("#C8E6C9"), parseColor("#A5D6A7"),
|
||||
parseColor("#81C784"), parseColor("#66BB6A"), parseColor("#4CAF50"),
|
||||
parseColor("#43A047"), parseColor("#388E3C"), parseColor("#2E7D32"),
|
||||
parseColor("#1B5E20")
|
||||
), intArrayOf(
|
||||
parseColor("#F1F8E9"), parseColor("#DCEDC8"), parseColor("#C5E1A5"),
|
||||
parseColor("#AED581"), parseColor("#9CCC65"), parseColor("#8BC34A"),
|
||||
parseColor("#7CB342"), parseColor("#689F38"), parseColor("#558B2F"),
|
||||
parseColor("#33691E")
|
||||
), intArrayOf(
|
||||
parseColor("#F9FBE7"), parseColor("#F0F4C3"), parseColor("#E6EE9C"),
|
||||
parseColor("#DCE775"), parseColor("#D4E157"), parseColor("#CDDC39"),
|
||||
parseColor("#C0CA33"), parseColor("#AFB42B"), parseColor("#9E9D24"),
|
||||
parseColor("#827717")
|
||||
), intArrayOf(
|
||||
parseColor("#FFFDE7"), parseColor("#FFF9C4"), parseColor("#FFF59D"),
|
||||
parseColor("#FFF176"), parseColor("#FFEE58"), parseColor("#FFEB3B"),
|
||||
parseColor("#FDD835"), parseColor("#FBC02D"), parseColor("#F9A825"),
|
||||
parseColor("#F57F17")
|
||||
), intArrayOf(
|
||||
parseColor("#FFF8E1"), parseColor("#FFECB3"), parseColor("#FFE082"),
|
||||
parseColor("#FFD54F"), parseColor("#FFCA28"), parseColor("#FFC107"),
|
||||
parseColor("#FFB300"), parseColor("#FFA000"), parseColor("#FF8F00"),
|
||||
parseColor("#FF6F00")
|
||||
), intArrayOf(
|
||||
parseColor("#FFF3E0"), parseColor("#FFE0B2"), parseColor("#FFCC80"),
|
||||
parseColor("#FFB74D"), parseColor("#FFA726"), parseColor("#FF9800"),
|
||||
parseColor("#FB8C00"), parseColor("#F57C00"), parseColor("#EF6C00"),
|
||||
parseColor("#E65100")
|
||||
), intArrayOf(
|
||||
parseColor("#FBE9E7"), parseColor("#FFCCBC"), parseColor("#FFAB91"),
|
||||
parseColor("#FF8A65"), parseColor("#FF7043"), parseColor("#FF5722"),
|
||||
parseColor("#F4511E"), parseColor("#E64A19"), parseColor("#D84315"),
|
||||
parseColor("#BF360C")
|
||||
), intArrayOf(
|
||||
parseColor("#EFEBE9"), parseColor("#D7CCC8"), parseColor("#BCAAA4"),
|
||||
parseColor("#A1887F"), parseColor("#8D6E63"), parseColor("#795548"),
|
||||
parseColor("#6D4C41"), parseColor("#5D4037"), parseColor("#4E342E"),
|
||||
parseColor("#3E2723")
|
||||
), intArrayOf(
|
||||
parseColor("#FAFAFA"), parseColor("#F5F5F5"), parseColor("#EEEEEE"),
|
||||
parseColor("#E0E0E0"), parseColor("#BDBDBD"), parseColor("#9E9E9E"),
|
||||
parseColor("#757575"), parseColor("#616161"), parseColor("#424242"),
|
||||
parseColor("#212121")
|
||||
), intArrayOf(
|
||||
parseColor("#ECEFF1"), parseColor("#CFD8DC"), parseColor("#B0BEC5"),
|
||||
parseColor("#90A4AE"), parseColor("#78909C"), parseColor("#607D8B"),
|
||||
parseColor("#546E7A"), parseColor("#455A64"), parseColor("#37474F"),
|
||||
parseColor("#263238")
|
||||
)
|
||||
)
|
||||
|
||||
val ACCENT_COLORS = intArrayOf(
|
||||
parseColor("#FF1744"), parseColor("#F50057"), parseColor("#D500F9"),
|
||||
parseColor("#651FFF"), parseColor("#3D5AFE"), parseColor("#2979FF"),
|
||||
parseColor("#00B0FF"), parseColor("#00E5FF"), parseColor("#1DE9B6"),
|
||||
parseColor("#00E676"), parseColor("#76FF03"), parseColor("#C6FF00"),
|
||||
parseColor("#FFEA00"), parseColor("#FFC400"), parseColor("#FF9100"),
|
||||
parseColor("#FF3D00")
|
||||
)
|
||||
|
||||
val ACCENT_COLORS_SUB = arrayOf(
|
||||
intArrayOf(
|
||||
parseColor("#FF8A80"), parseColor("#FF5252"), parseColor("#FF1744"),
|
||||
parseColor("#D50000")
|
||||
), intArrayOf(
|
||||
parseColor("#FF80AB"), parseColor("#FF4081"), parseColor("#F50057"),
|
||||
parseColor("#C51162")
|
||||
), intArrayOf(
|
||||
parseColor("#EA80FC"), parseColor("#E040FB"), parseColor("#D500F9"),
|
||||
parseColor("#AA00FF")
|
||||
), intArrayOf(
|
||||
parseColor("#B388FF"), parseColor("#7C4DFF"), parseColor("#651FFF"),
|
||||
parseColor("#6200EA")
|
||||
), intArrayOf(
|
||||
parseColor("#8C9EFF"), parseColor("#536DFE"), parseColor("#3D5AFE"),
|
||||
parseColor("#304FFE")
|
||||
), intArrayOf(
|
||||
parseColor("#82B1FF"), parseColor("#448AFF"), parseColor("#2979FF"),
|
||||
parseColor("#2962FF")
|
||||
), intArrayOf(
|
||||
parseColor("#80D8FF"), parseColor("#40C4FF"), parseColor("#00B0FF"),
|
||||
parseColor("#0091EA")
|
||||
), intArrayOf(
|
||||
parseColor("#84FFFF"), parseColor("#18FFFF"), parseColor("#00E5FF"),
|
||||
parseColor("#00B8D4")
|
||||
), intArrayOf(
|
||||
parseColor("#A7FFEB"), parseColor("#64FFDA"), parseColor("#1DE9B6"),
|
||||
parseColor("#00BFA5")
|
||||
), intArrayOf(
|
||||
parseColor("#B9F6CA"), parseColor("#69F0AE"), parseColor("#00E676"),
|
||||
parseColor("#00C853")
|
||||
), intArrayOf(
|
||||
parseColor("#CCFF90"), parseColor("#B2FF59"), parseColor("#76FF03"),
|
||||
parseColor("#64DD17")
|
||||
), intArrayOf(
|
||||
parseColor("#F4FF81"), parseColor("#EEFF41"), parseColor("#C6FF00"),
|
||||
parseColor("#AEEA00")
|
||||
), intArrayOf(
|
||||
parseColor("#FFFF8D"), parseColor("#FFFF00"), parseColor("#FFEA00"),
|
||||
parseColor("#FFD600")
|
||||
), intArrayOf(
|
||||
parseColor("#FFE57F"), parseColor("#FFD740"), parseColor("#FFC400"),
|
||||
parseColor("#FFAB00")
|
||||
), intArrayOf(
|
||||
parseColor("#FFD180"), parseColor("#FFAB40"), parseColor("#FF9100"),
|
||||
parseColor("#FF6D00")
|
||||
), intArrayOf(
|
||||
parseColor("#FF9E80"), parseColor("#FF6E40"), parseColor("#FF3D00"),
|
||||
parseColor("#DD2C00")
|
||||
)
|
||||
)
|
|
@ -1,35 +0,0 @@
|
|||
package code.name.monkey.appthemehelper.common.prefs
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import code.name.monkey.appthemehelper.R
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.prefs.MaterialDialogPreference
|
||||
|
||||
|
||||
/**
|
||||
* @author Aidan Follestad (afollestad)
|
||||
*/
|
||||
class ATEDialogPreference : MaterialDialogPreference {
|
||||
|
||||
constructor(context: Context) : super(context) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||
init()
|
||||
}
|
||||
|
||||
|
||||
private fun init() {
|
||||
layoutResource = R.layout.ate_preference_custom
|
||||
}
|
||||
}
|
|
@ -2,13 +2,13 @@ package code.name.monkey.appthemehelper.common.prefs
|
|||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import androidx.preference.EditTextPreference
|
||||
|
||||
import com.afollestad.materialdialogs.prefs.MaterialEditTextPreference
|
||||
|
||||
/**
|
||||
* @author Aidan Follestad (afollestad)
|
||||
*/
|
||||
class ATEEditTextPreference : MaterialEditTextPreference {
|
||||
class ATEEditTextPreference : EditTextPreference {
|
||||
|
||||
constructor(context: Context) : super(context) {
|
||||
init()
|
||||
|
|
|
@ -2,14 +2,13 @@ package code.name.monkey.appthemehelper.common.prefs
|
|||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
|
||||
import com.afollestad.materialdialogs.prefs.MaterialListPreference
|
||||
import android.preference.ListPreference
|
||||
import code.name.monkey.appthemehelper.R
|
||||
|
||||
/**
|
||||
* @author Aidan Follestad (afollestad)
|
||||
*/
|
||||
class ATEListPreference : MaterialListPreference {
|
||||
class ATEListPreference : ListPreference {
|
||||
|
||||
constructor(context: Context) : super(context) {
|
||||
init()
|
||||
|
@ -31,5 +30,7 @@ class ATEListPreference : MaterialListPreference {
|
|||
layoutResource = R.layout.ate_preference_custom
|
||||
if (summary == null || summary.toString().trim { it <= ' ' }.isEmpty())
|
||||
summary = "%s"
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package code.name.monkey.appthemehelper.common.prefs
|
||||
|
||||
import android.content.Context
|
||||
import android.preference.ListPreference
|
||||
import android.util.AttributeSet
|
||||
import code.name.monkey.appthemehelper.R
|
||||
import com.afollestad.materialdialogs.prefs.MaterialListPreference
|
||||
|
||||
/**
|
||||
* @author Aidan Follestad (afollestad)
|
||||
*/
|
||||
class ATEMultiSelectPreference : MaterialListPreference {
|
||||
class ATEMultiSelectPreference : ListPreference {
|
||||
|
||||
constructor(context: Context) : super(context) {
|
||||
init()
|
||||
|
|
|
@ -5,11 +5,11 @@ import android.content.Context
|
|||
import android.os.Build
|
||||
import android.preference.Preference
|
||||
import android.preference.SwitchPreference
|
||||
import androidx.appcompat.widget.SwitchCompat
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Switch
|
||||
import androidx.appcompat.widget.SwitchCompat
|
||||
|
||||
import code.name.monkey.appthemehelper.ATH
|
||||
import code.name.monkey.appthemehelper.R
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
package code.name.monkey.appthemehelper.common.prefs.supportv7
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import androidx.preference.CheckBoxPreference
|
||||
import code.name.monkey.appthemehelper.R
|
||||
|
||||
|
||||
/**
|
||||
* @author Aidan Follestad (afollestad)
|
||||
*/
|
||||
class ATECheckBoxPreference : CheckBoxPreference {
|
||||
|
||||
constructor(context: Context) : super(context) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||
init()
|
||||
}
|
||||
|
||||
private fun init() {
|
||||
layoutResource = R.layout.ate_preference_custom_support
|
||||
widgetLayoutResource = R.layout.ate_preference_checkbox
|
||||
}
|
||||
}
|
|
@ -1,9 +1,8 @@
|
|||
package code.name.monkey.appthemehelper.common.prefs.supportv7
|
||||
|
||||
import android.content.Context
|
||||
import androidx.preference.ListPreference
|
||||
import android.util.AttributeSet
|
||||
|
||||
import androidx.preference.ListPreference
|
||||
import code.name.monkey.appthemehelper.R
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
package code.name.monkey.appthemehelper.common.prefs.supportv7
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.dialogs.ATEEditTextPreferenceDialogFragmentCompat
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.dialogs.ATEListPreferenceDialogFragmentCompat
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.dialogs.ATEPreferenceDialogFragment
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
@SuppressLint("RestrictedApi")
|
||||
abstract class ATEPreferenceFragmentCompat : PreferenceFragmentCompat() {
|
||||
|
||||
override fun onDisplayPreferenceDialog(preference: Preference) {
|
||||
if (this.callbackFragment is PreferenceFragmentCompat.OnPreferenceDisplayDialogCallback) {
|
||||
(this.callbackFragment as PreferenceFragmentCompat.OnPreferenceDisplayDialogCallback).onPreferenceDisplayDialog(this, preference)
|
||||
return
|
||||
}
|
||||
|
||||
if (this.activity is PreferenceFragmentCompat.OnPreferenceDisplayDialogCallback) {
|
||||
(this.activity as PreferenceFragmentCompat.OnPreferenceDisplayDialogCallback).onPreferenceDisplayDialog(this, preference)
|
||||
return
|
||||
}
|
||||
|
||||
if (this.fragmentManager!!.findFragmentByTag("android.support.v7.preference.PreferenceFragment.DIALOG") == null) {
|
||||
val dialogFragment = onCreatePreferenceDialog(preference)
|
||||
|
||||
if (dialogFragment != null) {
|
||||
dialogFragment.setTargetFragment(this, 0)
|
||||
dialogFragment.show(this.fragmentManager!!, "android.support.v7.preference.PreferenceFragment.DIALOG")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
super.onDisplayPreferenceDialog(preference)
|
||||
}
|
||||
|
||||
open fun onCreatePreferenceDialog(preference: Preference): DialogFragment? {
|
||||
if (preference is ATEEditTextPreference) {
|
||||
return ATEEditTextPreferenceDialogFragmentCompat.newInstance(preference.getKey())
|
||||
} else if (preference is ATEListPreference) {
|
||||
return ATEListPreferenceDialogFragmentCompat.newInstance(preference.getKey())
|
||||
} else if (preference is ATEDialogPreference) {
|
||||
return ATEPreferenceDialogFragment.newInstance(preference.getKey())
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package code.name.monkey.appthemehelper.common.prefs.supportv7.dialogs
|
||||
|
||||
import android.os.Bundle
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEEditTextPreference
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
class ATEEditTextPreferenceDialogFragmentCompat : ATEPreferenceDialogFragment(), MaterialDialog.InputCallback {
|
||||
|
||||
private var input: CharSequence? = null
|
||||
|
||||
private val editTextPreference: ATEEditTextPreference
|
||||
get() = preference as ATEEditTextPreference
|
||||
|
||||
override fun onPrepareDialogBuilder(builder: MaterialDialog.Builder) {
|
||||
super.onPrepareDialogBuilder(builder)
|
||||
builder.input("", editTextPreference.text, this)
|
||||
}
|
||||
|
||||
override fun needInputMethod(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onDialogClosed(positiveResult: Boolean) {
|
||||
if (positiveResult) {
|
||||
val value = input!!.toString()
|
||||
if (this.editTextPreference.callChangeListener(value)) {
|
||||
this.editTextPreference.text = value
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onInput(dialog: MaterialDialog, input: CharSequence) {
|
||||
this.input = input
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
fun newInstance(key: String): ATEEditTextPreferenceDialogFragmentCompat {
|
||||
val fragment = ATEEditTextPreferenceDialogFragmentCompat()
|
||||
val b = Bundle(1)
|
||||
b.putString(ATEPreferenceDialogFragment.ARG_KEY, key)
|
||||
fragment.arguments = b
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
package code.name.monkey.appthemehelper.common.prefs.supportv7.dialogs
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.preference.ListPreference
|
||||
import android.view.View
|
||||
|
||||
import com.afollestad.materialdialogs.DialogAction
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEListPreference
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
class ATEListPreferenceDialogFragmentCompat : ATEPreferenceDialogFragment(), MaterialDialog.ListCallbackSingleChoice {
|
||||
private var mClickedDialogEntryIndex: Int = 0
|
||||
|
||||
private val listPreference: ATEListPreference
|
||||
get() = preference as ATEListPreference
|
||||
|
||||
override fun onPrepareDialogBuilder(builder: MaterialDialog.Builder) {
|
||||
super.onPrepareDialogBuilder(builder)
|
||||
|
||||
val preference = listPreference
|
||||
|
||||
if (preference.entries == null || preference.entryValues == null) {
|
||||
throw IllegalStateException(
|
||||
"ListPreference requires an entries array and an entryValues array.")
|
||||
}
|
||||
|
||||
mClickedDialogEntryIndex = preference.findIndexOfValue(preference.value)
|
||||
builder.items(*preference.entries)
|
||||
.alwaysCallSingleChoiceCallback()
|
||||
.itemsCallbackSingleChoice(mClickedDialogEntryIndex, this)
|
||||
|
||||
/*
|
||||
* The typical interaction for list-based dialogs is to have
|
||||
* click-on-an-item dismiss the dialog instead of the user having to
|
||||
* press 'Ok'.
|
||||
*/
|
||||
builder.positiveText("")
|
||||
builder.negativeText("")
|
||||
builder.neutralText("")
|
||||
}
|
||||
|
||||
override fun onDialogClosed(positiveResult: Boolean) {
|
||||
val preference = listPreference
|
||||
if (positiveResult && mClickedDialogEntryIndex >= 0 &&
|
||||
preference.entryValues != null) {
|
||||
val value = preference.entryValues[mClickedDialogEntryIndex].toString()
|
||||
if (preference.callChangeListener(value)) {
|
||||
preference.value = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSelection(dialog: MaterialDialog, itemView: View, which: Int, text: CharSequence): Boolean {
|
||||
mClickedDialogEntryIndex = which
|
||||
onClick(dialog, DialogAction.POSITIVE)
|
||||
dismiss()
|
||||
return true
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
fun newInstance(key: String): ATEListPreferenceDialogFragmentCompat {
|
||||
val fragment = ATEListPreferenceDialogFragmentCompat()
|
||||
val b = Bundle(1)
|
||||
b.putString(ATEPreferenceDialogFragment.ARG_KEY, key)
|
||||
fragment.arguments = b
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
package code.name.monkey.appthemehelper.common.prefs.supportv7.dialogs
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.DialogInterface
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.preference.DialogPreference
|
||||
import com.afollestad.materialdialogs.DialogAction
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
open class ATEPreferenceDialogFragment : DialogFragment(), MaterialDialog.SingleButtonCallback {
|
||||
private var mWhichButtonClicked: DialogAction? = null
|
||||
var preference: DialogPreference? = null
|
||||
private set
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val rawFragment = this.targetFragment
|
||||
if (rawFragment !is DialogPreference.TargetFragment) {
|
||||
throw IllegalStateException("Target fragment must implement TargetFragment interface")
|
||||
} else {
|
||||
val fragment = rawFragment as DialogPreference.TargetFragment?
|
||||
val key = this.arguments!!.getString(ARG_KEY)
|
||||
this.preference = fragment!!.findPreference(key) as DialogPreference
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val context = this.activity
|
||||
val builder = MaterialDialog.Builder(context!!)
|
||||
.title(this.preference!!.dialogTitle)
|
||||
.icon(this.preference!!.dialogIcon)
|
||||
.onAny(this)
|
||||
.positiveText(this.preference!!.positiveButtonText)
|
||||
.negativeText(this.preference!!.negativeButtonText)
|
||||
|
||||
builder.content(this.preference!!.dialogMessage)
|
||||
this.onPrepareDialogBuilder(builder)
|
||||
val dialog = builder.build()
|
||||
if (this.needInputMethod()) {
|
||||
this.requestInputMethod(dialog)
|
||||
}
|
||||
|
||||
return dialog
|
||||
}
|
||||
|
||||
protected open fun onPrepareDialogBuilder(builder: MaterialDialog.Builder) {}
|
||||
|
||||
protected open fun needInputMethod(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
private fun requestInputMethod(dialog: Dialog) {
|
||||
val window = dialog.window
|
||||
window!!.setSoftInputMode(5)
|
||||
}
|
||||
|
||||
override fun onClick(dialog: MaterialDialog, which: DialogAction) {
|
||||
mWhichButtonClicked = which
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface?) {
|
||||
super.onDismiss(dialog)
|
||||
onDialogClosed(mWhichButtonClicked == DialogAction.POSITIVE)
|
||||
}
|
||||
|
||||
open fun onDialogClosed(positiveResult: Boolean) {
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val ARG_KEY = "key"
|
||||
|
||||
fun newInstance(key: String): ATEPreferenceDialogFragment {
|
||||
val fragment = ATEPreferenceDialogFragment()
|
||||
val b = Bundle(1)
|
||||
b.putString(ARG_KEY, key)
|
||||
fragment.arguments = b
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
}
|
|
@ -71,4 +71,67 @@ object ColorUtil {
|
|||
val b = Color.blue(color1) * inverseRatio + Color.blue(color2) * ratio
|
||||
return Color.argb(a.toInt(), r.toInt(), g.toInt(), b.toInt())
|
||||
}
|
||||
|
||||
|
||||
private fun getColorDarkness(@ColorInt color: Int): Double {
|
||||
return if (color == Color.BLACK)
|
||||
1.0
|
||||
else if (color == Color.WHITE || color == Color.TRANSPARENT)
|
||||
0.0
|
||||
else
|
||||
1 - (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color)) / 255
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
fun getInverseColor(@ColorInt color: Int): Int {
|
||||
return 0xFFFFFF - color or -0x1
|
||||
}
|
||||
|
||||
fun isColorSaturated(@ColorInt color: Int): Boolean {
|
||||
val max = Math.max(0.299 * Color.red(color), Math.max(0.587 * Color.green(color), 0.114 * Color.blue(color)))
|
||||
val min = Math.min(0.299 * Color.red(color), Math.min(0.587 * Color.green(color), 0.114 * Color.blue(color)))
|
||||
val diff = Math.abs(max - min)
|
||||
return diff > 20
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
fun getMixedColor(@ColorInt color1: Int, @ColorInt color2: Int): Int {
|
||||
return Color.rgb(
|
||||
(Color.red(color1) + Color.red(color2)) / 2,
|
||||
(Color.green(color1) + Color.green(color2)) / 2,
|
||||
(Color.blue(color1) + Color.blue(color2)) / 2
|
||||
)
|
||||
}
|
||||
|
||||
fun getDifference(@ColorInt color1: Int, @ColorInt color2: Int): Double {
|
||||
var diff = Math.abs(0.299 * (Color.red(color1) - Color.red(color2)))
|
||||
diff += Math.abs(0.587 * (Color.green(color1) - Color.green(color2)))
|
||||
diff += Math.abs(0.114 * (Color.blue(color1) - Color.blue(color2)))
|
||||
return diff
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
fun getReadableText(@ColorInt textColor: Int, @ColorInt backgroundColor: Int): Int {
|
||||
return getReadableText(textColor, backgroundColor, 100)
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
fun getReadableText(@ColorInt textColor: Int, @ColorInt backgroundColor: Int, difference: Int): Int {
|
||||
var textColor = textColor
|
||||
val isLight = isColorLight(backgroundColor)
|
||||
var i = 0
|
||||
while (getDifference(textColor, backgroundColor) < difference && i < 100) {
|
||||
textColor = getMixedColor(textColor, if (isLight) Color.BLACK else Color.WHITE)
|
||||
i++
|
||||
}
|
||||
|
||||
return textColor
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
fun getContrastColor(@ColorInt color: Int): Int {
|
||||
// Counting the perceptive luminance - human eye favors green color...
|
||||
val a = 1 - (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color)) / 255
|
||||
return if (a < 0.5) Color.BLACK else Color.WHITE
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
package code.name.monkey.appthemehelper.util
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
|
||||
import com.afollestad.materialdialogs.internal.ThemeSingleton
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
|
||||
|
||||
object MaterialDialogsUtil {
|
||||
|
||||
fun updateMaterialDialogsThemeSingleton(context: Context) {
|
||||
val md = ThemeSingleton.get()
|
||||
md.titleColor = ThemeStore.textColorPrimary(context)
|
||||
md.contentColor = ThemeStore.textColorSecondary(context)
|
||||
md.itemColor = md.titleColor
|
||||
md.widgetColor = ThemeStore.accentColor(context)
|
||||
md.linkColor = ColorStateList.valueOf(md.widgetColor)
|
||||
md.positiveColor = ColorStateList.valueOf(md.widgetColor)
|
||||
md.neutralColor = ColorStateList.valueOf(md.widgetColor)
|
||||
md.negativeColor = ColorStateList.valueOf(md.widgetColor)
|
||||
md.darkTheme = ATHUtil.isWindowBackgroundDark(context)
|
||||
}
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView android:id="@android:id/title"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingTop="16dp"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
tools:ignore="RtlSymmetry" />
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<code.name.monkey.appthemehelper.common.views.ATECheckBox android:id="@android:id/checkbox"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<code.name.monkey.appthemehelper.common.views.ATECheckBox xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:layout_margin="6dp"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:focusable="false" />
|
|
@ -16,56 +16,56 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="@dimen/ate_preference_inset"
|
||||
android:layout_marginStart="@dimen/ate_preference_inset"
|
||||
android:layout_marginLeft="@dimen/ate_preference_inset"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:layout_marginBottom="12dip"
|
||||
android:layout_marginEnd="6dip"
|
||||
android:layout_marginLeft="@dimen/ate_preference_inset"
|
||||
android:layout_marginRight="6dip"
|
||||
android:layout_marginStart="@dimen/ate_preference_inset"
|
||||
android:layout_marginLeft="@dimen/ate_preference_inset"
|
||||
android:layout_marginTop="12dip"
|
||||
android:layout_marginEnd="6dip"
|
||||
android:layout_marginRight="6dip"
|
||||
android:layout_marginBottom="12dip"
|
||||
android:layout_weight="1">
|
||||
|
||||
<code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:ellipsize="marquee"
|
||||
android:fadingEdge="horizontal"
|
||||
android:singleLine="true"
|
||||
android:textSize="@dimen/ate_default_textsize_subheading"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
|
||||
tools:text="Title" />
|
||||
|
||||
<code.name.monkey.appthemehelper.common.views.ATESecondaryTextView
|
||||
android:id="@android:id/summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@android:id/title"
|
||||
android:layout_alignStart="@android:id/title"
|
||||
android:layout_below="@android:id/title"
|
||||
android:layout_alignStart="@android:id/title"
|
||||
android:layout_alignLeft="@android:id/title"
|
||||
android:layout_marginTop="2dp"
|
||||
android:maxLines="4"
|
||||
android:textSize="@dimen/ate_default_textsize_body"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2"
|
||||
tools:text="Summary" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<!-- Preference should place its actual preference widget here. -->
|
||||
<code.name.monkey.appthemehelper.common.views.ATESwitch xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/switchWidget"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:button="@drawable/ate_switch"
|
||||
android:clickable="false"
|
||||
android:focusable="false"/>
|
||||
android:id="@+id/switchWidget"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:button="@drawable/ate_switch"
|
||||
android:clickable="false"
|
||||
android:focusable="false" />
|
||||
|
||||
</LinearLayout><!-- From: file:/home/jitpack/build/commons/src/main/res/layout/md_preference_custom.xml -->
|
|
@ -3,13 +3,13 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:baselineAligned="false"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:orientation="horizontal"
|
||||
android:paddingEnd="?android:attr/scrollbarSize"
|
||||
android:paddingRight="?android:attr/scrollbarSize"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
tools:ignore="RtlSymmetry,UnusedAttribute">
|
||||
|
||||
<ImageView
|
||||
|
@ -17,44 +17,44 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="@dimen/ate_preference_inset"
|
||||
android:layout_marginStart="@dimen/ate_preference_inset"
|
||||
android:layout_marginLeft="@dimen/ate_preference_inset"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:layout_marginBottom="12dip"
|
||||
android:layout_marginEnd="6dip"
|
||||
android:layout_marginLeft="@dimen/ate_preference_inset"
|
||||
android:layout_marginRight="6dip"
|
||||
android:layout_marginStart="@dimen/ate_preference_inset"
|
||||
android:layout_marginLeft="@dimen/ate_preference_inset"
|
||||
android:layout_marginTop="12dip"
|
||||
android:layout_marginEnd="6dip"
|
||||
android:layout_marginRight="6dip"
|
||||
android:layout_marginBottom="12dip"
|
||||
android:layout_weight="1">
|
||||
|
||||
<code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:ellipsize="marquee"
|
||||
android:fadingEdge="horizontal"
|
||||
android:singleLine="true"
|
||||
android:textSize="@dimen/ate_default_textsize_subheading"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
|
||||
tools:text="Title" />
|
||||
|
||||
<code.name.monkey.appthemehelper.common.views.ATESecondaryTextView
|
||||
android:id="@android:id/summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@android:id/title"
|
||||
android:layout_alignStart="@android:id/title"
|
||||
android:layout_below="@android:id/title"
|
||||
android:layout_alignStart="@android:id/title"
|
||||
android:layout_alignLeft="@android:id/title"
|
||||
android:layout_marginTop="2dp"
|
||||
android:maxLines="4"
|
||||
android:textSize="@dimen/ate_default_textsize_body"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2"
|
||||
tools:text="Summary" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
23
appthemehelper/src/main/res/layout/ate_preference_list.xml
Normal file
23
appthemehelper/src/main/res/layout/ate_preference_list.xml
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/dialogTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline6" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp" />
|
||||
|
||||
<ListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
|
@ -6,4 +6,5 @@
|
|||
android:background="@null"
|
||||
android:button="@drawable/ate_switch"
|
||||
android:clickable="false"
|
||||
android:focusable="false" />
|
||||
android:focusable="false"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1" />
|
|
@ -5,4 +5,5 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:focusable="false" />
|
||||
android:focusable="false"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1" />
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/custom_list_view_row_table_row"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="10dip"
|
||||
android:paddingTop="8dip"
|
||||
android:paddingRight="10dip"
|
||||
android:paddingBottom="8dip">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:padding="0dip">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/custom_list_view_row_text_view"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="22dip"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="#000000"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/custom_list_view_row_subtext_view"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="18dip"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="#000000"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/custom_list_view_row_selected_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dip"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@drawable/ic_toggle_switch" />
|
||||
</TableRow>
|
|
@ -7,9 +7,6 @@
|
|||
<attr name="ateKey_pref" format="string" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="ATECheckBoxPreference">
|
||||
<attr name="ateKey_pref_checkBox" format="string" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="ATESwitchPreference">
|
||||
<attr name="ateKey_pref_switch" format="string" />
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.3.21'
|
||||
ext.kotlin_version = '1.3.11'
|
||||
ext {
|
||||
supportLibVersion = '1.0.0'
|
||||
firebase = "11.8.0"
|
||||
retrofit = "2.3.0"
|
||||
materialDialog = "0.9.6.0"
|
||||
materialDialog = "2.0.0"
|
||||
}
|
||||
repositories {
|
||||
jcenter()
|
||||
|
|
Loading…
Reference in a new issue