Fixing bugs
This commit is contained in:
commit
2be114da11
110 changed files with 1049 additions and 1070 deletions
|
@ -86,11 +86,5 @@ class App : MultiDexApplication() {
|
|||
|
||||
const val PRO_VERSION_PRODUCT_ID = "pro_version"
|
||||
|
||||
|
||||
/*val context: Context
|
||||
get() = (instance as App).applicationContext*/
|
||||
|
||||
/*val isProVersion: Boolean
|
||||
get() = BuildConfig.DEBUG || instance.billingProcessor.isPurchased(PRO_VERSION_PRODUCT_ID)*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import android.view.View
|
|||
import androidx.core.app.ShareCompat
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import code.name.monkey.retromusic.Constants.APP_INSTAGRAM_LINK
|
||||
import code.name.monkey.retromusic.Constants.APP_TELEGRAM_LINK
|
||||
import code.name.monkey.retromusic.Constants.APP_TWITTER_LINK
|
||||
|
@ -23,7 +25,10 @@ import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
|||
import code.name.monkey.retromusic.adapter.ContributorAdapter
|
||||
import code.name.monkey.retromusic.model.Contributor
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
import com.afollestad.materialdialogs.list.listItems
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
|
@ -59,11 +64,12 @@ class AboutActivity : AbsBaseActivity(), View.OnClickListener {
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_about)
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setNavigationBarColorPrimary()
|
||||
setLightNavigationBar(true)
|
||||
|
||||
loadContributors()
|
||||
setSupportActionBar(toolbar)
|
||||
ToolbarContentTintHelper.colorBackButton(toolbar, ATHUtil.resolveColor(this, R.attr.colorOnSurface))
|
||||
appVersion.text = getAppVersion()
|
||||
setUpView()
|
||||
}
|
||||
|
@ -77,12 +83,6 @@ class AboutActivity : AbsBaseActivity(), View.OnClickListener {
|
|||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
private fun setUpToolbar() {
|
||||
//appBarLayout.setBackgroundColor(ThemeStore.primaryColor(this))
|
||||
//toolbar.setBackgroundColor(ThemeStore.primaryColor(this))
|
||||
//ToolbarContentTintHelper.colorBackButton(toolbar, ThemeStore.textColorSecondary(this))
|
||||
}
|
||||
|
||||
private fun openUrl(url: String) {
|
||||
val i = Intent(Intent.ACTION_VIEW)
|
||||
i.data = Uri.parse(url)
|
||||
|
@ -126,15 +126,17 @@ class AboutActivity : AbsBaseActivity(), View.OnClickListener {
|
|||
}
|
||||
|
||||
private fun showChangeLogOptions() {
|
||||
MaterialDialog(this).show {
|
||||
listItems(items = listOf("Telegram Channel", "App")) { _, position, _ ->
|
||||
if (position == 0) {
|
||||
openUrl(TELEGRAM_CHANGE_LOG)
|
||||
} else {
|
||||
NavigationUtil.gotoWhatNews(this@AboutActivity)
|
||||
MaterialDialog(this, BottomSheet(LayoutMode.WRAP_CONTENT))
|
||||
.show {
|
||||
cornerRadius(PreferenceUtil.getInstance(this@AboutActivity).dialogCorner)
|
||||
listItems(items = listOf("Telegram Channel", "App")) { _, position, _ ->
|
||||
if (position == 0) {
|
||||
openUrl(TELEGRAM_CHANGE_LOG)
|
||||
} else {
|
||||
NavigationUtil.gotoWhatNews(this@AboutActivity)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getAppVersion(): String {
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.activities;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
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;
|
||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity;
|
||||
|
||||
import static code.name.monkey.appthemehelper.util.ATHUtil.INSTANCE;
|
||||
|
||||
/**
|
||||
* Created by hemanths on 2019-09-27.
|
||||
*/
|
||||
public class LicenseActivity extends AbsBaseActivity {
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
onBackPressed();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private String colorToCSS(int color) {
|
||||
return String.format("rgb(%d, %d, %d)", Color.red(color), Color.green(color), Color.blue(color)); // on API 29, WebView doesn't load with hex colors
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_license);
|
||||
setStatusbarColorAuto();
|
||||
setNavigationBarColorPrimary();
|
||||
setTaskDescriptionColorAuto();
|
||||
setLightNavigationBar(true);
|
||||
|
||||
ToolbarContentTintHelper.colorBackButton(findViewById(R.id.toolbar), ATHUtil.INSTANCE.resolveColor(this, R.attr.colorOnSurface));
|
||||
WebView webView = findViewById(R.id.license);
|
||||
try {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
InputStream json = getAssets().open("index.html");
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(json, StandardCharsets.UTF_8));
|
||||
String str;
|
||||
while ((str = in.readLine()) != null)
|
||||
buf.append(str);
|
||||
in.close();
|
||||
|
||||
// Inject color values for WebView body background and links
|
||||
final boolean isDark = INSTANCE.isWindowBackgroundDark(this);
|
||||
final String backgroundColor = colorToCSS(INSTANCE.resolveColor(this, R.attr.md_background_color, Color.parseColor(isDark ? "#424242" : "#ffffff")));
|
||||
final String contentColor = colorToCSS(Color.parseColor(isDark ? "#ffffff" : "#000000"));
|
||||
final String changeLog = buf.toString()
|
||||
.replace("{style-placeholder}",
|
||||
String.format("body { background-color: %s; color: %s; }", backgroundColor, contentColor))
|
||||
.replace("{link-color}", colorToCSS(ThemeStore.Companion.accentColor(this)))
|
||||
.replace("{link-color-active}", colorToCSS(ColorUtil.INSTANCE.lightenColor(ThemeStore.Companion.accentColor(this))));
|
||||
|
||||
webView.loadData(changeLog, "text/html", "UTF-8");
|
||||
} catch (Throwable e) {
|
||||
webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", "UTF-8");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package code.name.monkey.retromusic.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
||||
import code.name.monkey.retromusic.extensions.applyToolbar
|
||||
import kotlinx.android.synthetic.main.activity_license.*
|
||||
import kotlinx.android.synthetic.main.activity_license.appBarLayout
|
||||
import kotlinx.android.synthetic.main.activity_license.toolbar
|
||||
import kotlinx.android.synthetic.main.activity_playing_queue.*
|
||||
|
||||
class LicenseActivity : AbsBaseActivity() {
|
||||
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == android.R.id.home) {
|
||||
onBackPressed()
|
||||
return true
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_license)
|
||||
|
||||
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
|
||||
license.loadUrl("file:///android_asset/index.html")
|
||||
applyToolbar(toolbar)
|
||||
appBarLayout.setBackgroundColor(ThemeStore.primaryColor(this))
|
||||
setSupportActionBar(toolbar)
|
||||
}
|
||||
}
|
|
@ -36,11 +36,11 @@ class LockScreenActivity : AbsMusicServiceActivity() {
|
|||
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON)
|
||||
}
|
||||
setDrawUnderStatusBar()
|
||||
setContentView(R.layout.activity_lock_screen_old_style)
|
||||
setContentView(R.layout.activity_lock_screen)
|
||||
|
||||
hideStatusBar()
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setNavigationBarColorPrimary()
|
||||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
|
|||
|
||||
setStatusbarColorAuto()
|
||||
setTaskDescriptionColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setNavigationBarColorPrimary()
|
||||
|
||||
appBarLayout.setBackgroundColor(ThemeStore.primaryColor(this))
|
||||
toolbar.apply {
|
||||
|
|
|
@ -66,7 +66,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
|
|||
if (savedInstanceState == null) {
|
||||
selectedFragment(PreferenceUtil.getInstance(this).lastPage)
|
||||
} else {
|
||||
restoreCurrentFragment();
|
||||
restoreCurrentFragment()
|
||||
}
|
||||
|
||||
checkShowChangelog()
|
||||
|
@ -222,6 +222,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
|
|||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
||||
if (key == PreferenceUtil.GENERAL_THEME ||
|
||||
key==PreferenceUtil.BLACK_THEME||
|
||||
key == PreferenceUtil.ADAPTIVE_COLOR_APP ||
|
||||
key == PreferenceUtil.DOMINANT_COLOR ||
|
||||
key == PreferenceUtil.USER_NAME ||
|
||||
|
|
|
@ -41,10 +41,10 @@ class PlayingQueueActivity : AbsMusicServiceActivity() {
|
|||
savedInstanceState: Bundle?
|
||||
) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(code.name.monkey.retromusic.R.layout.activity_playing_queue)
|
||||
setContentView(R.layout.activity_playing_queue)
|
||||
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setNavigationBarColorPrimary()
|
||||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
|
||||
|
@ -92,9 +92,9 @@ class PlayingQueueActivity : AbsMusicServiceActivity() {
|
|||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
super.onScrolled(recyclerView, dx, dy)
|
||||
if (dy > 0) {
|
||||
clearQueue.shrink( )
|
||||
clearQueue.shrink()
|
||||
} else if (dy < 0) {
|
||||
clearQueue.extend( )
|
||||
clearQueue.extend()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -31,7 +31,7 @@ class PurchaseActivity : AbsBaseActivity(), BillingProcessor.IBillingHandler {
|
|||
setDrawUnderStatusBar()
|
||||
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setNavigationBarColorPrimary()
|
||||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
|
|||
searchPresenter.attachView(this)
|
||||
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setNavigationBarColorPrimary()
|
||||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
|
||||
|
|
|
@ -20,9 +20,8 @@ class SettingsActivity : AbsBaseActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_settings)
|
||||
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setNavigationBarColorPrimary()
|
||||
setLightNavigationBar(true)
|
||||
|
||||
setupToolbar()
|
||||
|
|
|
@ -59,7 +59,7 @@ class SupportDevelopmentActivity : AbsBaseActivity(), BillingProcessor.IBillingH
|
|||
setContentView(R.layout.activity_donation)
|
||||
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setNavigationBarColorPrimary()
|
||||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class UserInfoActivity : AbsBaseActivity() {
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_user_info)
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setNavigationBarColorPrimary()
|
||||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public class WhatsNewActivity extends AbsBaseActivity {
|
|||
setContentView(R.layout.activity_whats_new);
|
||||
|
||||
setStatusbarColorAuto();
|
||||
setNavigationbarColorAuto();
|
||||
setNavigationBarColorPrimary();
|
||||
setTaskDescriptionColorAuto();
|
||||
|
||||
webView = findViewById(R.id.webView);
|
||||
|
@ -78,7 +78,7 @@ public class WhatsNewActivity extends AbsBaseActivity {
|
|||
|
||||
// Inject color values for WebView body background and links
|
||||
final boolean isDark = INSTANCE.isWindowBackgroundDark(this);
|
||||
final String backgroundColor = colorToCSS(INSTANCE.resolveColor(this, R.attr.md_background_color, Color.parseColor(isDark ? "#424242" : "#ffffff")));
|
||||
final String backgroundColor = colorToCSS(INSTANCE.resolveColor(this, R.attr.colorPrimary, Color.parseColor(isDark ? "#424242" : "#ffffff")));
|
||||
final String contentColor = colorToCSS(Color.parseColor(isDark ? "#ffffff" : "#000000"));
|
||||
final String changeLog = buf.toString()
|
||||
.replace("{style-placeholder}",
|
||||
|
|
|
@ -58,7 +58,6 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), Sliding
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(createContentView())
|
||||
|
||||
|
||||
chooseFragmentForTheme()
|
||||
setupSlidingUpPanel()
|
||||
|
||||
|
|
|
@ -19,13 +19,14 @@ import code.name.monkey.appthemehelper.util.VersionUtils
|
|||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import code.name.monkey.retromusic.util.ThemeManager
|
||||
|
||||
abstract class AbsThemeActivity : ATHActivity(), Runnable {
|
||||
|
||||
private val handler = Handler()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setTheme(PreferenceUtil.getInstance(this).generalTheme)
|
||||
setTheme(ThemeManager.getThemeResValue(this))
|
||||
hideStatusBar()
|
||||
super.onCreate(savedInstanceState)
|
||||
//MaterialDialogsUtil.updateMaterialDialogsThemeSingleton(this)
|
||||
|
@ -109,7 +110,7 @@ abstract class AbsThemeActivity : ATHActivity(), Runnable {
|
|||
|
||||
fun setStatusbarColorAuto() {
|
||||
// we don't want to use statusbar color because we are doing the color darkening on our own to support KitKat
|
||||
setStatusbarColor(ThemeStore.primaryColor(this))
|
||||
setStatusbarColor(ATHUtil.resolveColor(this, R.attr.colorPrimary))
|
||||
}
|
||||
|
||||
open fun setTaskDescriptionColor(@ColorInt color: Int) {
|
||||
|
@ -117,7 +118,7 @@ abstract class AbsThemeActivity : ATHActivity(), Runnable {
|
|||
}
|
||||
|
||||
fun setTaskDescriptionColorAuto() {
|
||||
setTaskDescriptionColor(ThemeStore.primaryColor(this))
|
||||
setTaskDescriptionColor(ATHUtil.resolveColor(this, R.attr.colorPrimary))
|
||||
}
|
||||
|
||||
open fun setNavigationbarColor(color: Int) {
|
||||
|
@ -128,8 +129,12 @@ abstract class AbsThemeActivity : ATHActivity(), Runnable {
|
|||
}
|
||||
}
|
||||
|
||||
open fun setNavigationBarColorPrimary() {
|
||||
ATH.setNavigationbarColor(this, ATHUtil.resolveColor(this, R.attr.colorPrimary))
|
||||
}
|
||||
|
||||
fun setNavigationbarColorAuto() {
|
||||
setNavigationbarColor(ThemeStore.navigationBarColor(this))
|
||||
setNavigationbarColor(ATHUtil.resolveColor(this, R.attr.colorSurface))
|
||||
}
|
||||
|
||||
open fun setLightStatusbar(enabled: Boolean) {
|
||||
|
|
|
@ -49,6 +49,7 @@ class OptionsSheetDialogFragment : DialogFragment(), View.OnClickListener {
|
|||
private lateinit var materialDialog: MaterialDialog
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
|
||||
val layout = LayoutInflater.from(context).inflate(R.layout.fragment_main_options, null)
|
||||
actionSettings = layout.findViewById(R.id.actionSettings)
|
||||
actionRate = layout.findViewById(R.id.actionRate)
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.util.Objects;
|
|||
|
||||
import code.name.monkey.appthemehelper.ThemeStore;
|
||||
import code.name.monkey.appthemehelper.common.ATHToolbarActivity;
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil;
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog;
|
||||
|
@ -145,10 +146,7 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private void setupToolbar() {
|
||||
//int primaryColor = ThemeStore.Companion.primaryColor(getContext());
|
||||
//TintHelper.setTintAuto(contentContainer, primaryColor, true);
|
||||
//appBarLayout.setBackgroundColor(primaryColor);
|
||||
//toolbar.setBackgroundColor(RetroColorUtil.toolbarColor(getMainActivity()));
|
||||
toolbar.setBackgroundColor(RetroColorUtil.toolbarColor(getMainActivity()));
|
||||
toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
|
||||
toolbar.setOnClickListener(v -> {
|
||||
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(getMainActivity(), toolbarContainer, getString(R.string.transition_toolbar));
|
||||
|
@ -156,6 +154,8 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
});
|
||||
getMainActivity().setSupportActionBar(toolbar);
|
||||
toolbar.setNavigationOnClickListener(v -> showMainMenu(OptionsSheetDialogFragment.LIBRARY));
|
||||
ToolbarContentTintHelper.colorBackButton(toolbar, ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorOnSurface));
|
||||
toolbar.setTitleTextColor(ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorOnSecondary));
|
||||
}
|
||||
|
||||
private Fragment getCurrentFragment() {
|
||||
|
|
|
@ -225,7 +225,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
|||
}
|
||||
|
||||
private void setUpAppbarColor() {
|
||||
int primaryColor = ThemeStore.Companion.primaryColor(getContext());
|
||||
int primaryColor = ThemeStore.Companion.primaryColor(requireContext());
|
||||
getMainActivity().setSupportActionBar(toolbar);
|
||||
TintHelper.setTintAuto(container, primaryColor, true);
|
||||
appBarLayout.setBackgroundColor(primaryColor);
|
||||
|
@ -234,8 +234,8 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
|||
toolbar.setNavigationOnClickListener(v -> {
|
||||
showMainMenu(OptionsSheetDialogFragment.FOLDER);
|
||||
});
|
||||
breadCrumbs.setActivatedContentColor(ToolbarContentTintHelper.toolbarTitleColor(getActivity(), ColorUtil.INSTANCE.darkenColor(primaryColor)));
|
||||
breadCrumbs.setDeactivatedContentColor(ToolbarContentTintHelper.toolbarSubtitleColor(getActivity(),
|
||||
breadCrumbs.setActivatedContentColor(ToolbarContentTintHelper.toolbarTitleColor(requireActivity(), ColorUtil.INSTANCE.darkenColor(primaryColor)));
|
||||
breadCrumbs.setDeactivatedContentColor(ToolbarContentTintHelper.toolbarSubtitleColor(requireActivity(),
|
||||
ColorUtil.INSTANCE.darkenColor(primaryColor)));
|
||||
appBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> getMainActivity().setLightStatusbar(!ATHUtil.INSTANCE.isWindowBackgroundDark(getContext())));
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
|||
|
||||
checkPadding()
|
||||
|
||||
userInfoContainer.setOnClickListener {
|
||||
userImage.setOnClickListener {
|
||||
NavigationUtil.goToUserInfo(requireActivity())
|
||||
}
|
||||
titleWelcome.setTextColor(ThemeStore.textColorPrimary(requireContext()))
|
||||
|
|
|
@ -44,7 +44,7 @@ class MainSettingsFragment : Fragment(), View.OnClickListener {
|
|||
R.id.imageSettings -> inflateFragment(ImageSettingFragment(), R.string.pref_header_images)
|
||||
R.id.notificationSettings -> inflateFragment(NotificationSettingsFragment(), R.string.notification)
|
||||
R.id.otherSettings -> inflateFragment(OtherSettingsFragment(), R.string.others)
|
||||
R.id.aboutSettings -> NavigationUtil.goToAbout(activity!!)
|
||||
R.id.aboutSettings -> NavigationUtil.goToAbout(requireActivity())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ class MainSettingsFragment : Fragment(), View.OnClickListener {
|
|||
buyProContainer.apply {
|
||||
if (!App.isProVersion()) show() else hide()
|
||||
setOnClickListener {
|
||||
NavigationUtil.goToProVersion(context)
|
||||
NavigationUtil.goToProVersion(requireContext())
|
||||
}
|
||||
}
|
||||
buyPremium.setOnClickListener {
|
||||
|
|
|
@ -14,16 +14,15 @@
|
|||
|
||||
package code.name.monkey.retromusic.fragments.settings
|
||||
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.TwoStatePreference
|
||||
import code.name.monkey.appthemehelper.ACCENT_COLORS
|
||||
import code.name.monkey.appthemehelper.ACCENT_COLORS_SUB
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEColorPreference
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||
import code.name.monkey.retromusic.R
|
||||
|
@ -46,19 +45,7 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
|
|||
setSummary(it)
|
||||
it.setOnPreferenceChangeListener { _, newValue ->
|
||||
val theme = newValue as String
|
||||
setSummary(generalTheme, newValue)
|
||||
val color = when (theme) {
|
||||
"light" -> Color.WHITE
|
||||
"black" -> Color.BLACK
|
||||
"dark" -> ContextCompat.getColor(requireContext(), R.color.md_grey_900)
|
||||
else -> Color.WHITE
|
||||
}
|
||||
|
||||
ThemeStore.editTheme(requireContext())
|
||||
.activityTheme(PreferenceUtil.getThemeResFromPrefValue(theme))
|
||||
.primaryColor(color)
|
||||
.commit()
|
||||
|
||||
setSummary(it, newValue)
|
||||
ThemeStore.markChanged(requireContext())
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
||||
|
@ -87,6 +74,17 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
|
|||
}
|
||||
return@setOnPreferenceClickListener true
|
||||
}
|
||||
val blackTheme: ATESwitchPreference? = findPreference("black_theme")
|
||||
blackTheme?.setOnPreferenceChangeListener { _, _ ->
|
||||
ThemeStore.markChanged(requireContext())
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
||||
requireActivity().setTheme(PreferenceUtil.getThemeResFromPrefValue("black"))
|
||||
DynamicShortcutManager(requireContext()).updateDynamicShortcuts()
|
||||
}
|
||||
requireActivity().recreate()
|
||||
true
|
||||
}
|
||||
|
||||
val colorAppShortcuts: TwoStatePreference = findPreference("should_color_app_shortcuts")!!
|
||||
if (!VersionUtils.hasNougatMR()) {
|
||||
|
|
|
@ -57,6 +57,7 @@ import code.name.monkey.retromusic.transform.VerticalStackTransformer;
|
|||
|
||||
public final class PreferenceUtil {
|
||||
public static final String LIBRARY_CATEGORIES = "library_categories";
|
||||
public static final String BLACK_THEME = "black_theme";
|
||||
public static final String DIALOG_CORNER = "dialog_corner";
|
||||
public static final String KEEP_SCREEN_ON = "keep_screen_on";
|
||||
public static final String TOGGLE_HOME_BANNER = "toggle_home_banner";
|
||||
|
@ -141,6 +142,7 @@ public final class PreferenceUtil {
|
|||
private static PreferenceUtil sInstance;
|
||||
private final SharedPreferences mPreferences;
|
||||
|
||||
|
||||
private PreferenceUtil(@NonNull final Context context) {
|
||||
mPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
}
|
||||
|
@ -158,8 +160,6 @@ public final class PreferenceUtil {
|
|||
switch (themePrefValue) {
|
||||
case "light":
|
||||
return R.style.Theme_RetroMusic_Light;
|
||||
case "black":
|
||||
return R.style.Theme_RetroMusic_Black;
|
||||
case "dark":
|
||||
default:
|
||||
return R.style.Theme_RetroMusic;
|
||||
|
@ -176,6 +176,10 @@ public final class PreferenceUtil {
|
|||
editor.apply();
|
||||
}
|
||||
|
||||
public boolean isBlackMode() {
|
||||
return mPreferences.getBoolean(BLACK_THEME, false);
|
||||
}
|
||||
|
||||
public String getUserBio() {
|
||||
return mPreferences.getString(USER_BIO, "");
|
||||
}
|
||||
|
@ -565,6 +569,13 @@ public final class PreferenceUtil {
|
|||
editor.apply();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getGeneralThemeValue() {
|
||||
if (isBlackMode()) return "black";
|
||||
else
|
||||
return mPreferences.getString(GENERAL_THEME, "dark");
|
||||
}
|
||||
|
||||
public String getBaseTheme() {
|
||||
return mPreferences.getString(GENERAL_THEME, "dark");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package code.name.monkey.retromusic.util
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration.UI_MODE_NIGHT_MASK
|
||||
import android.content.res.Configuration.UI_MODE_NIGHT_YES
|
||||
import android.os.PowerManager
|
||||
import androidx.annotation.StyleRes
|
||||
import code.name.monkey.retromusic.R
|
||||
|
||||
/**
|
||||
* @author Paolo Valerdi
|
||||
*/
|
||||
object ThemeManager {
|
||||
|
||||
@StyleRes
|
||||
fun getThemeResValue(context: Context): Int = when (PreferenceUtil.getInstance(context).generalThemeValue) {
|
||||
"light" -> R.style.Theme_RetroMusic_Light
|
||||
"auto" -> if (isSystemDarkModeEnabled(context)) R.style.Theme_RetroMusic else R.style.Theme_RetroMusic_Light
|
||||
"black" -> R.style.Theme_RetroMusic_Black
|
||||
else -> R.style.Theme_RetroMusic
|
||||
/**
|
||||
* To add a toggle for amoled theme just add an if statement such as
|
||||
* if(PreferenceUtil.getInstance(context).useAmoled) blablabla
|
||||
*/
|
||||
}
|
||||
|
||||
private fun isSystemDarkModeEnabled(context: Context): Boolean {
|
||||
val isBatterySaverEnabled = (context.getSystemService(Context.POWER_SERVICE) as PowerManager?)?.isPowerSaveMode
|
||||
?: false
|
||||
val isDarkModeEnabled = (context.resources.configuration.uiMode and UI_MODE_NIGHT_MASK) == UI_MODE_NIGHT_YES
|
||||
|
||||
return isBatterySaverEnabled or isDarkModeEnabled
|
||||
}
|
||||
|
||||
}
|
|
@ -32,7 +32,6 @@ class BottomNavigationBarTinted @JvmOverloads constructor(
|
|||
|
||||
init {
|
||||
labelVisibilityMode = PreferenceUtil.getInstance(context).tabTitleMode
|
||||
setBackgroundColor(ThemeStore.primaryColor(context))
|
||||
selectedItemId = PreferenceUtil.getInstance(context).lastPage
|
||||
|
||||
val iconColor = ATHUtil.resolveColor(context, R.attr.iconColor)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue