Fixing bugs

This commit is contained in:
h4h13 2019-09-28 23:22:49 +05:30
commit 2be114da11
110 changed files with 1049 additions and 1070 deletions

View file

@ -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 {

View file

@ -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");
}
}
}

View file

@ -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)
}
}

View file

@ -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)

View file

@ -91,7 +91,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
setStatusbarColorAuto()
setTaskDescriptionColorAuto()
setNavigationbarColorAuto()
setNavigationBarColorPrimary()
appBarLayout.setBackgroundColor(ThemeStore.primaryColor(this))
toolbar.apply {

View file

@ -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 ||

View file

@ -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()
}
}
})

View file

@ -31,7 +31,7 @@ class PurchaseActivity : AbsBaseActivity(), BillingProcessor.IBillingHandler {
setDrawUnderStatusBar()
setStatusbarColorAuto()
setNavigationbarColorAuto()
setNavigationBarColorPrimary()
setTaskDescriptionColorAuto()
setLightNavigationBar(true)

View file

@ -49,7 +49,7 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
searchPresenter.attachView(this)
setStatusbarColorAuto()
setNavigationbarColorAuto()
setNavigationBarColorPrimary()
setTaskDescriptionColorAuto()
setLightNavigationBar(true)

View file

@ -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()

View file

@ -59,7 +59,7 @@ class SupportDevelopmentActivity : AbsBaseActivity(), BillingProcessor.IBillingH
setContentView(R.layout.activity_donation)
setStatusbarColorAuto()
setNavigationbarColorAuto()
setNavigationBarColorPrimary()
setTaskDescriptionColorAuto()
setLightNavigationBar(true)

View file

@ -47,7 +47,7 @@ class UserInfoActivity : AbsBaseActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_user_info)
setStatusbarColorAuto()
setNavigationbarColorAuto()
setNavigationBarColorPrimary()
setTaskDescriptionColorAuto()
setLightNavigationBar(true)

View file

@ -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}",

View file

@ -58,7 +58,6 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), Sliding
super.onCreate(savedInstanceState)
setContentView(createContentView())
chooseFragmentForTheme()
setupSlidingUpPanel()

View file

@ -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) {