6.6.2 - Alpha3 - 控件文字图标根据主题色亮度值自动切换颜色
This commit is contained in:
1 parent
ce4f990046
commit
b1c17f1222
35 files changed
+853
-436
No files matched your search
@@ -17,6 +17,7 @@
|
|||||||
"精简打包应用模板 APK 文件大小",
|
"精简打包应用模板 APK 文件大小",
|
||||||
"打包页面支持 Pinyin 库选项",
|
"打包页面支持 Pinyin 库选项",
|
||||||
"打包应用主活动页面优化状态栏背景及文字颜色",
|
"打包应用主活动页面优化状态栏背景及文字颜色",
|
||||||
|
"控件的文字及图标根据主题色亮度值自动切换合适的颜色",
|
||||||
"脚本项目配置文件 project.json 支持更多打包选项 _[`issue #305`](http://issues.autojs6.com/305)_ _[`issue #306`](http://issues.autojs6.com/306)_",
|
"脚本项目配置文件 project.json 支持更多打包选项 _[`issue #305`](http://issues.autojs6.com/305)_ _[`issue #306`](http://issues.autojs6.com/306)_",
|
||||||
"脚本项目配置文件 project.json 支持选项名称宽松匹配及别名兼容",
|
"脚本项目配置文件 project.json 支持选项名称宽松匹配及别名兼容",
|
||||||
"APK 文件类型信息对话框增加文件大小与签名方案信息",
|
"APK 文件类型信息对话框增加文件大小与签名方案信息",
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class App : MultiDexApplication() {
|
|||||||
val crashHandler = CrashHandler(ErrorReportActivity::class.java)
|
val crashHandler = CrashHandler(ErrorReportActivity::class.java)
|
||||||
|
|
||||||
val strategy = CrashReport.UserStrategy(applicationContext)
|
val strategy = CrashReport.UserStrategy(applicationContext)
|
||||||
strategy.crashHandleCallback = crashHandler
|
strategy.setCrashHandleCallback(crashHandler)
|
||||||
|
|
||||||
CrashReport.initCrashReport(applicationContext, BUGLY_APP_ID, false, strategy)
|
CrashReport.initCrashReport(applicationContext, BUGLY_APP_ID, false, strategy)
|
||||||
|
|
||||||
@@ -115,7 +115,6 @@ class App : MultiDexApplication() {
|
|||||||
else -> ViewUtils.MODE.DAY
|
else -> ViewUtils.MODE.DAY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> ViewUtils.MODE.NULL
|
else -> ViewUtils.MODE.NULL
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -221,7 +220,7 @@ class App : MultiDexApplication() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||||
ViewUtils.onConfigurationChanged(newConfig)
|
ViewUtils.onConfigurationChangedForNightMode(newConfig)
|
||||||
EventBus.getDefault().post(newConfig)
|
EventBus.getDefault().post(newConfig)
|
||||||
FloatyWindowManger.getCircularMenu()?.savePosition(newConfig)
|
FloatyWindowManger.getCircularMenu()?.savePosition(newConfig)
|
||||||
super.onConfigurationChanged(newConfig)
|
super.onConfigurationChanged(newConfig)
|
||||||
|
|||||||
@@ -1,72 +1,56 @@
|
|||||||
package org.autojs.autojs.core.image;
|
package org.autojs.autojs.core.image
|
||||||
|
|
||||||
import android.graphics.Color;
|
import androidx.annotation.ColorInt
|
||||||
|
import org.autojs.autojs.annotation.ScriptInterface
|
||||||
import androidx.annotation.ColorInt;
|
import org.autojs.autojs.util.ColorUtils
|
||||||
|
|
||||||
import org.autojs.autojs.util.ColorUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Stardust on Dec 31, 2017.
|
* Created by Stardust on Dec 31, 2017.
|
||||||
|
* Transformed by SuperMonster003 on Mar 8, 2025.
|
||||||
*/
|
*/
|
||||||
public class Colors {
|
@Suppress("FunctionName")
|
||||||
|
class Colors {
|
||||||
|
|
||||||
public int rgb(int red, int green, int blue) {
|
@ScriptInterface
|
||||||
return Color.rgb(red, green, blue);
|
fun rgb(red: Int, green: Int, blue: Int) = ColorUtils.rgb(red, green, blue)
|
||||||
}
|
|
||||||
|
|
||||||
public int argb(int alpha, int red, int green, int blue) {
|
@ScriptInterface
|
||||||
return Color.argb(alpha, red, green, blue);
|
fun argb(alpha: Int, red: Int, green: Int, blue: Int) = ColorUtils.argb(alpha, red, green, blue)
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see <a href="https://www.w3.org/TR/WCAG20/#relativeluminancedef">W3C Recommendation</a>
|
* @see ColorUtils.luminance
|
||||||
*/
|
*/
|
||||||
public double luminance(@ColorInt int color) {
|
@ScriptInterface
|
||||||
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
fun luminance(@ColorInt color: Int) = ColorUtils.luminance(color)
|
||||||
// ? Color.luminance(Color.pack(color))
|
|
||||||
// : Color.luminance(color);
|
|
||||||
return androidx.core.graphics.ColorUtils.calculateLuminance(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int parseColor(String colorString) {
|
@ScriptInterface
|
||||||
return Color.parseColor(colorString);
|
fun parseColor(colorString: String?) = ColorUtils.parseColor(colorString)
|
||||||
}
|
|
||||||
|
|
||||||
public String toString(int color) {
|
@ScriptInterface
|
||||||
return ColorUtils.toString(color);
|
fun toString(color: Int) = ColorUtils.toString(color)
|
||||||
}
|
|
||||||
|
|
||||||
public void RGBToHSV(int red, int green, int blue, float[] hsv) {
|
@ScriptInterface
|
||||||
Color.RGBToHSV(red, green, blue, hsv);
|
fun RGBToHSV(red: Int, green: Int, blue: Int, hsv: FloatArray?) = ColorUtils.RGBToHSV(red, green, blue, hsv)
|
||||||
}
|
|
||||||
|
|
||||||
public void colorToHSV(int color, float[] hsv) {
|
@ScriptInterface
|
||||||
Color.colorToHSV(color, hsv);
|
fun colorToHSV(color: Int, hsv: FloatArray?) = ColorUtils.colorToHSV(color, hsv)
|
||||||
}
|
|
||||||
|
|
||||||
public int HSVToColor(float[] hsv) {
|
@ScriptInterface
|
||||||
return Color.HSVToColor(hsv);
|
fun HSVToColor(hsv: FloatArray?) = ColorUtils.HSVToColor(hsv)
|
||||||
}
|
|
||||||
|
|
||||||
public int HSVToColor(int alpha, float[] hsv) {
|
@ScriptInterface
|
||||||
return Color.HSVToColor(alpha, hsv);
|
fun HSVToColor(alpha: Int, hsv: FloatArray?) = ColorUtils.HSVToColor(alpha, hsv)
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(int c1, int c2) {
|
@ScriptInterface
|
||||||
return (c1 & 0xffffff) == (c2 & 0xffffff);
|
fun equals(c1: Int, c2: Int) = ColorUtils.equals(c1, c2)
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(int c1, String c2) {
|
@ScriptInterface
|
||||||
return equals(c1, parseColor(c2));
|
fun equals(c1: Int, c2: String?) = ColorUtils.equals(c1, c2)
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(String c1, int c2) {
|
@ScriptInterface
|
||||||
return equals(parseColor(c1), c2);
|
fun equals(c1: String?, c2: Int) = ColorUtils.equals(c1, c2)
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(String c1, String c2) {
|
@ScriptInterface
|
||||||
return equals(parseColor(c1), parseColor(c2));
|
fun equals(c1: String?, c2: String?) = ColorUtils.equals(c1, c2)
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ import org.autojs.autojs.core.pref.Pref.getInt
|
|||||||
import org.autojs.autojs.core.pref.Pref.putInt
|
import org.autojs.autojs.core.pref.Pref.putInt
|
||||||
import org.autojs.autojs.extension.ArrayExtensions.toHashCode
|
import org.autojs.autojs.extension.ArrayExtensions.toHashCode
|
||||||
import org.autojs.autojs.theme.ThemeColorManager.defaultThemeColor
|
import org.autojs.autojs.theme.ThemeColorManager.defaultThemeColor
|
||||||
|
import org.autojs.autojs.util.ColorUtils
|
||||||
import org.autojs.autojs6.R
|
import org.autojs.autojs6.R
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,6 +37,10 @@ class ThemeColor {
|
|||||||
@ScriptInterface
|
@ScriptInterface
|
||||||
fun getColorPrimaryDark() = colorPrimaryDark
|
fun getColorPrimaryDark() = colorPrimaryDark
|
||||||
|
|
||||||
|
fun isLuminanceLight() = ColorUtils.isLuminanceLight(colorPrimary)
|
||||||
|
|
||||||
|
fun isLuminanceDark() = ColorUtils.isLuminanceDark(colorPrimary)
|
||||||
|
|
||||||
constructor()
|
constructor()
|
||||||
|
|
||||||
constructor(color: Int) : this(color, color, color)
|
constructor(color: Int) : this(color, color, color)
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import android.view.View
|
|||||||
import org.autojs.autojs.util.ColorUtils
|
import org.autojs.autojs.util.ColorUtils
|
||||||
import org.autojs.autojs6.R
|
import org.autojs.autojs6.R
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
import java.util.LinkedList
|
import java.util.*
|
||||||
import java.util.Vector
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Stardust on May 10, 2016.
|
* Created by Stardust on May 10, 2016.
|
||||||
@@ -28,6 +27,12 @@ object ThemeColorManager {
|
|||||||
ThemeColor.fromPreferences()?.let { currentThemeColor = it } ?: setThemeColor(defaultThemeColor)
|
ThemeColor.fromPreferences()?.let { currentThemeColor = it } ?: setThemeColor(defaultThemeColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun isThemeColorLuminanceLight() = currentThemeColor.isLuminanceLight()
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun isThemeColorLuminanceDark() = currentThemeColor.isLuminanceDark()
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun add(colorMutable: ThemeColorMutable) = ThemeColorMutableManager.add(colorMutable)
|
fun add(colorMutable: ThemeColorMutable) = ThemeColorMutableManager.add(colorMutable)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package org.autojs.autojs.theme
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
|
||||||
|
object ThemeChangeNotifier {
|
||||||
|
|
||||||
|
private val _themeChanged = MutableLiveData<Unit>()
|
||||||
|
|
||||||
|
val themeChanged: LiveData<Unit> get() = _themeChanged
|
||||||
|
|
||||||
|
fun notifyThemeChanged() {
|
||||||
|
_themeChanged.postValue(Unit)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,37 +1,23 @@
|
|||||||
package org.autojs.autojs.theme.app
|
package org.autojs.autojs.theme.app
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.res.ColorStateList
|
import android.graphics.PorterDuff
|
||||||
|
import android.graphics.PorterDuffColorFilter
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.AttributeSet
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.OnClickListener
|
|
||||||
import android.view.ViewAnimationUtils
|
import android.view.ViewAnimationUtils
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.ImageView
|
|
||||||
import android.widget.TextView
|
|
||||||
import androidx.annotation.ColorInt
|
|
||||||
import androidx.appcompat.widget.Toolbar
|
|
||||||
import androidx.fragment.app.FragmentActivity
|
|
||||||
import androidx.recyclerview.widget.DividerItemDecoration
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import androidx.recyclerview.widget.ThemeColorRecyclerView
|
|
||||||
import com.google.android.material.appbar.AppBarLayout
|
import com.google.android.material.appbar.AppBarLayout
|
||||||
import com.jaredrummler.android.colorpicker.ColorPickerDialog
|
|
||||||
import com.jaredrummler.android.colorpicker.ColorPickerDialogListener
|
|
||||||
import org.autojs.autojs.core.pref.Pref
|
import org.autojs.autojs.core.pref.Pref
|
||||||
|
import org.autojs.autojs.theme.ThemeChangeNotifier
|
||||||
import org.autojs.autojs.theme.ThemeColor
|
import org.autojs.autojs.theme.ThemeColor
|
||||||
import org.autojs.autojs.theme.ThemeColorHelper
|
|
||||||
import org.autojs.autojs.theme.ThemeColorManager
|
import org.autojs.autojs.theme.ThemeColorManager
|
||||||
import org.autojs.autojs.ui.BaseActivity
|
import org.autojs.autojs.ui.BaseActivity
|
||||||
import org.autojs.autojs.util.ColorUtils
|
import org.autojs.autojs.util.ColorUtils
|
||||||
import org.autojs.autojs.util.StringUtils.key
|
import org.autojs.autojs.util.StringUtils.key
|
||||||
import org.autojs.autojs.util.ViewUtils.appendSystemUiVisibility
|
import org.autojs.autojs.util.ViewUtils
|
||||||
import org.autojs.autojs6.R
|
import org.autojs.autojs6.R
|
||||||
|
import org.autojs.autojs6.databinding.MtActivityColorSelectBinding
|
||||||
import kotlin.math.hypot
|
import kotlin.math.hypot
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,6 +27,10 @@ import kotlin.math.hypot
|
|||||||
*/
|
*/
|
||||||
class ColorSelectActivity : BaseActivity() {
|
class ColorSelectActivity : BaseActivity() {
|
||||||
|
|
||||||
|
override val handleStatusBarThemeColorAutomatically = false
|
||||||
|
|
||||||
|
private var binding: MtActivityColorSelectBinding? = null
|
||||||
|
|
||||||
private lateinit var mAppBarLayout: AppBarLayout
|
private lateinit var mAppBarLayout: AppBarLayout
|
||||||
private lateinit var mTitle: String
|
private lateinit var mTitle: String
|
||||||
private lateinit var mColorSettingRecyclerView: ColorSettingRecyclerView
|
private lateinit var mColorSettingRecyclerView: ColorSettingRecyclerView
|
||||||
@@ -55,28 +45,33 @@ class ColorSelectActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
handleIntent()
|
handleIntent()
|
||||||
setUpUI()
|
binding = MtActivityColorSelectBinding.inflate(layoutInflater).also {
|
||||||
appendSystemUiVisibility(this, View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE)
|
setUpUI(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
binding = null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleIntent() {
|
private fun handleIntent() {
|
||||||
mTitle = intent.getStringExtra("title") ?: getString(R.string.mt_color_picker_title)
|
mTitle = intent.getStringExtra("title") ?: getString(R.string.mt_color_picker_title)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpUI() {
|
private fun setUpUI(binding: MtActivityColorSelectBinding) {
|
||||||
setContentView(R.layout.mt_activity_color_select)
|
setContentView(binding.root)
|
||||||
mCurrentColor = ThemeColorManager.colorPrimary
|
mCurrentColor = ThemeColorManager.colorPrimary
|
||||||
mAppBarLayout = findViewById<AppBarLayout?>(R.id.appBar).apply { setBackgroundColor(mCurrentColor) }
|
mAppBarLayout = binding.appBar.apply { setBackgroundColor(mCurrentColor) }
|
||||||
setUpToolbar()
|
setUpToolbar(binding)
|
||||||
setUpColorSettingRecyclerView()
|
setUpColorSettingRecyclerView(binding)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpToolbar() {
|
private fun setUpToolbar(binding: MtActivityColorSelectBinding) {
|
||||||
findViewById<Toolbar>(R.id.toolbar).also { toolbar ->
|
binding.toolbar.also { toolbar ->
|
||||||
toolbar.title = mTitle
|
toolbar.title = mTitle
|
||||||
setSupportActionBar(toolbar)
|
setSupportActionBar(toolbar)
|
||||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
@@ -84,26 +79,53 @@ class ColorSelectActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpColorSettingRecyclerView() {
|
private fun setUpColorSettingRecyclerView(binding: MtActivityColorSelectBinding) {
|
||||||
mColorSettingRecyclerView = findViewById<ColorSettingRecyclerView?>(R.id.color_setting_recycler_view)
|
mColorSettingRecyclerView = binding.colorSettingRecyclerView.apply {
|
||||||
.apply {
|
setCustomColor()
|
||||||
setCustomColor()
|
setSelectedColor(mCurrentColor)
|
||||||
setSelectedColor(mCurrentColor)
|
setOnItemClickListener(mOnItemClickListener)
|
||||||
setOnItemClickListener(mOnItemClickListener)
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun finish() {
|
override fun finish() {
|
||||||
mColorSettingRecyclerView.selectedThemeColor?.let {
|
mColorSettingRecyclerView.selectedThemeColor?.let {
|
||||||
ThemeColorManager.setThemeColor(it.colorPrimary)
|
ThemeColorManager.setThemeColor(it.colorPrimary)
|
||||||
Pref.putString(key(R.string.key_theme_color), getColorString(this))
|
Pref.putString(key(R.string.key_theme_color), getColorString(this))
|
||||||
|
ThemeChangeNotifier.notifyThemeChanged()
|
||||||
}
|
}
|
||||||
super.finish()
|
super.finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun initThemeColors() {
|
||||||
|
super.initThemeColors()
|
||||||
|
setUpToolbarColors()
|
||||||
|
setUpStatusBarIconLight()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpToolbarColors() {
|
||||||
|
val toolbar = binding!!.toolbar
|
||||||
|
val aimColor = when {
|
||||||
|
ColorUtils.isLuminanceLight(mCurrentColor) -> getColor(R.color.day)
|
||||||
|
else -> getColor(R.color.night)
|
||||||
|
}
|
||||||
|
toolbar.setTitleTextColor(aimColor)
|
||||||
|
toolbar.setSubtitleTextColor(aimColor)
|
||||||
|
toolbar.navigationIcon?.let { navigationIcon ->
|
||||||
|
navigationIcon.colorFilter = PorterDuffColorFilter(aimColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpStatusBarIconLight() {
|
||||||
|
ViewUtils.setStatusBarIconLight(this, ColorUtils.isLuminanceDark(mCurrentColor))
|
||||||
|
}
|
||||||
|
|
||||||
private fun setColorWithAnimation(view: View, colorTo: Int) {
|
private fun setColorWithAnimation(view: View, colorTo: Int) {
|
||||||
findViewById<View>(R.id.appBarContainer).setBackgroundColor(mCurrentColor)
|
binding!!.appBarContainer.setBackgroundColor(mCurrentColor)
|
||||||
view.setBackgroundColor(colorTo)
|
view.setBackgroundColor(colorTo)
|
||||||
|
mCurrentColor = colorTo
|
||||||
|
|
||||||
|
initThemeColors()
|
||||||
|
|
||||||
ViewAnimationUtils.createCircularReveal(
|
ViewAnimationUtils.createCircularReveal(
|
||||||
/* view = */ view,
|
/* view = */ view,
|
||||||
/* centerX = */ view.left,
|
/* centerX = */ view.left,
|
||||||
@@ -111,13 +133,12 @@ class ColorSelectActivity : BaseActivity() {
|
|||||||
/* startRadius = */ 0f,
|
/* startRadius = */ 0f,
|
||||||
/* endRadius = */ hypot(view.width.toDouble(), view.height.toDouble()).toFloat()
|
/* endRadius = */ hypot(view.width.toDouble(), view.height.toDouble()).toFloat()
|
||||||
).apply {
|
).apply {
|
||||||
duration = 500
|
duration = 500L
|
||||||
start()
|
start()
|
||||||
}
|
}
|
||||||
mCurrentColor = colorTo
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ColorItem(var name: String, var themeColor: ThemeColor) {
|
class ColorItem(var name: String, var themeColor: ThemeColor) {
|
||||||
constructor(name: String, color: Int) : this(name, ThemeColor(color))
|
constructor(name: String, color: Int) : this(name, ThemeColor(color))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +173,7 @@ class ColorSelectActivity : BaseActivity() {
|
|||||||
return "${colorItem.name} [${ColorUtils.toString(colorItem.themeColor.colorPrimary).uppercase()}]"
|
return "${colorItem.name} [${ColorUtils.toString(colorItem.themeColor.colorPrimary).uppercase()}]"
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getColorItems(context: Context): List<ColorItem> = ArrayList<Pair</* nameRes */ Int, /* colorInt */ Int>>()
|
internal fun getColorItems(context: Context): List<ColorItem> = ArrayList<Pair</* nameRes */ Int, /* colorInt */ Int>>()
|
||||||
.apply {
|
.apply {
|
||||||
add(customColorPosition, Pair(Pref.getInt(KEY_CUSTOM_COLOR, context.getColor(R.color.md_blue_grey_800)), R.string.mt_custom))
|
add(customColorPosition, Pair(Pref.getInt(KEY_CUSTOM_COLOR, context.getColor(R.color.md_blue_grey_800)), R.string.mt_custom))
|
||||||
add(defaultColorPosition, Pair(context.getColor(R.color.theme_color_default), R.string.theme_color_default))
|
add(defaultColorPosition, Pair(context.getColor(R.color.theme_color_default), R.string.theme_color_default))
|
||||||
@@ -160,147 +181,6 @@ class ColorSelectActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
.map { (colorInt, nameRes) -> ColorItem(context.getString(nameRes), colorInt) }
|
.map { (colorInt, nameRes) -> ColorItem(context.getString(nameRes), colorInt) }
|
||||||
|
|
||||||
class ColorSettingRecyclerView : ThemeColorRecyclerView {
|
|
||||||
|
|
||||||
private var mOnItemClickListener: OnItemClickListener? = null
|
|
||||||
|
|
||||||
private var mSelectedPosition = SELECT_NONE
|
|
||||||
|
|
||||||
val selectedThemeColor: ThemeColor?
|
|
||||||
get() = getColorItems(context)[mSelectedPosition].themeColor.takeUnless { mSelectedPosition < 0 }
|
|
||||||
|
|
||||||
private val customColor: Int
|
|
||||||
get() = Pref.getInt(KEY_CUSTOM_COLOR, context.getColor(R.color.md_blue_grey_800))
|
|
||||||
|
|
||||||
private val mActualOnItemClickListener = OnClickListener { v ->
|
|
||||||
getChildViewHolder(v)?.let { holder ->
|
|
||||||
val pos = holder.bindingAdapterPosition
|
|
||||||
if (pos == customColorPosition) {
|
|
||||||
showColorPicker(v)
|
|
||||||
} else {
|
|
||||||
setSelectedPosition(pos)
|
|
||||||
mOnItemClickListener?.onItemClick(v, pos)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(context: Context) : super(context)
|
|
||||||
|
|
||||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
|
||||||
|
|
||||||
constructor(context: Context, attrs: AttributeSet?, defStyle: Int) : super(context, attrs, defStyle)
|
|
||||||
|
|
||||||
init {
|
|
||||||
adapter = Adapter()
|
|
||||||
layoutManager = LinearLayoutManager(context)
|
|
||||||
addItemDecoration(DividerItemDecoration(context, VERTICAL))
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
|
||||||
fun setSelectedPosition(currentPosition: Int) {
|
|
||||||
if (mSelectedPosition != SELECT_NONE) {
|
|
||||||
adapter!!.notifyItemChanged(mSelectedPosition)
|
|
||||||
mSelectedPosition = currentPosition
|
|
||||||
adapter!!.notifyItemChanged(currentPosition)
|
|
||||||
} else {
|
|
||||||
mSelectedPosition = currentPosition
|
|
||||||
adapter!!.notifyDataSetChanged()
|
|
||||||
}
|
|
||||||
Pref.putInt(KEY_SELECTED_COLOR_INDEX, mSelectedPosition)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setSelectedColor(colorPrimary: Int) {
|
|
||||||
for ((i, colorItem) in getColorItems(context).withIndex()) {
|
|
||||||
if (colorItem.themeColor.colorPrimary == colorPrimary) {
|
|
||||||
return Unit.also { setSelectedPosition(i) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mSelectedPosition = SELECT_NONE
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setCustomColor(color: Int) {
|
|
||||||
getColorItems(context)[customColorPosition].themeColor.colorPrimary = color
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setCustomColor() {
|
|
||||||
setCustomColor(customColor)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun showColorPicker(v: View) {
|
|
||||||
ColorPickerDialog.newBuilder()
|
|
||||||
.setAllowCustom(true)
|
|
||||||
.setAllowPresets(false)
|
|
||||||
.setDialogType(ColorPickerDialog.TYPE_CUSTOM)
|
|
||||||
.setShowAlphaSlider(false)
|
|
||||||
.setDialogTitle(R.string.mt_color_picker_title)
|
|
||||||
.setColor(customColor)
|
|
||||||
.create()
|
|
||||||
.apply {
|
|
||||||
setColorPickerDialogListener(object : ColorPickerDialogListener {
|
|
||||||
override fun onColorSelected(dialogId: Int, @ColorInt color: Int) {
|
|
||||||
val c = color or -0x1000000
|
|
||||||
Pref.putInt(KEY_CUSTOM_COLOR, c)
|
|
||||||
setCustomColor(c)
|
|
||||||
setSelectedPosition(customColorPosition)
|
|
||||||
mOnItemClickListener?.onItemClick(v, customColorPosition)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDialogDismissed(dialogId: Int) {}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
.show((context as FragmentActivity).supportFragmentManager, "Tag")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setOnItemClickListener(onItemClickListener: OnItemClickListener?) {
|
|
||||||
mOnItemClickListener = onItemClickListener
|
|
||||||
}
|
|
||||||
|
|
||||||
private inner class Adapter : RecyclerView.Adapter<ViewHolder>() {
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
|
||||||
return ViewHolder(LayoutInflater.from(context).inflate(R.layout.mt_color_setting_recycler_view_item, parent, false))
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
|
||||||
val item = getColorItems(context)[position]
|
|
||||||
holder.apply {
|
|
||||||
setColor(item.themeColor.colorPrimary)
|
|
||||||
name.text = item.name
|
|
||||||
name.setTextColor(context.getColor(R.color.color_selector_item_text))
|
|
||||||
setChecked(mSelectedPosition == position)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getItemCount() = getColorItems(context).size
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
|
||||||
|
|
||||||
var color: ImageView
|
|
||||||
var name: TextView
|
|
||||||
|
|
||||||
init {
|
|
||||||
itemView.setOnClickListener(mActualOnItemClickListener)
|
|
||||||
color = itemView.findViewById(R.id.color)
|
|
||||||
name = itemView.findViewById(R.id.name)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setChecked(checked: Boolean) {
|
|
||||||
if (checked) {
|
|
||||||
color.setImageResource(R.drawable.mt_ic_check_white_36dp)
|
|
||||||
color.imageTintList = ColorStateList.valueOf(context.getColor(R.color.night_day))
|
|
||||||
} else {
|
|
||||||
color.setImageDrawable(null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setColor(c: Int) = ThemeColorHelper.setBackgroundColor(color, c)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
package org.autojs.autojs.theme.app
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.res.ColorStateList
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.View.OnClickListener
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.annotation.ColorInt
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
|
import androidx.recyclerview.widget.DividerItemDecoration
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import androidx.recyclerview.widget.ThemeColorRecyclerView
|
||||||
|
import com.jaredrummler.android.colorpicker.ColorPickerDialog
|
||||||
|
import com.jaredrummler.android.colorpicker.ColorPickerDialogListener
|
||||||
|
import org.autojs.autojs.core.pref.Pref
|
||||||
|
import org.autojs.autojs.theme.ThemeColor
|
||||||
|
import org.autojs.autojs.theme.ThemeColorHelper
|
||||||
|
import org.autojs.autojs.util.ColorUtils
|
||||||
|
import org.autojs.autojs6.R
|
||||||
|
|
||||||
|
class ColorSettingRecyclerView : ThemeColorRecyclerView {
|
||||||
|
|
||||||
|
constructor(context: Context) : super(context)
|
||||||
|
|
||||||
|
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||||
|
|
||||||
|
constructor(context: Context, attrs: AttributeSet?, defStyle: Int) : super(context, attrs, defStyle)
|
||||||
|
|
||||||
|
private var mOnItemClickListener: ColorSelectActivity.OnItemClickListener? = null
|
||||||
|
|
||||||
|
private var mSelectedPosition = ColorSelectActivity.SELECT_NONE
|
||||||
|
|
||||||
|
val selectedThemeColor: ThemeColor?
|
||||||
|
get() = ColorSelectActivity.getColorItems(context)[mSelectedPosition].themeColor.takeUnless { mSelectedPosition < 0 }
|
||||||
|
|
||||||
|
private val customColor: Int
|
||||||
|
get() = Pref.getInt(ColorSelectActivity.KEY_CUSTOM_COLOR, context.getColor(R.color.md_blue_grey_800))
|
||||||
|
|
||||||
|
private val mActualOnItemClickListener = OnClickListener { v ->
|
||||||
|
getChildViewHolder(v)?.let { holder ->
|
||||||
|
val pos = holder.bindingAdapterPosition
|
||||||
|
if (pos == ColorSelectActivity.customColorPosition) {
|
||||||
|
showColorPicker(v)
|
||||||
|
} else {
|
||||||
|
setSelectedPosition(pos)
|
||||||
|
mOnItemClickListener?.onItemClick(v, pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
adapter = Adapter()
|
||||||
|
layoutManager = LinearLayoutManager(context)
|
||||||
|
addItemDecoration(DividerItemDecoration(context, VERTICAL))
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
|
fun setSelectedPosition(currentPosition: Int) {
|
||||||
|
if (mSelectedPosition != ColorSelectActivity.SELECT_NONE) {
|
||||||
|
adapter!!.notifyItemChanged(mSelectedPosition)
|
||||||
|
mSelectedPosition = currentPosition
|
||||||
|
adapter!!.notifyItemChanged(currentPosition)
|
||||||
|
} else {
|
||||||
|
mSelectedPosition = currentPosition
|
||||||
|
adapter!!.notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
Pref.putInt(ColorSelectActivity.KEY_SELECTED_COLOR_INDEX, mSelectedPosition)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setSelectedColor(colorPrimary: Int) {
|
||||||
|
for ((i, colorItem) in ColorSelectActivity.getColorItems(context).withIndex()) {
|
||||||
|
if (colorItem.themeColor.colorPrimary == colorPrimary) {
|
||||||
|
setSelectedPosition(i)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mSelectedPosition = ColorSelectActivity.SELECT_NONE
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setCustomColor(color: Int) {
|
||||||
|
ColorSelectActivity.getColorItems(context)[ColorSelectActivity.customColorPosition].themeColor.colorPrimary = color
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setCustomColor() {
|
||||||
|
setCustomColor(customColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showColorPicker(v: View) {
|
||||||
|
ColorPickerDialog.newBuilder()
|
||||||
|
.setAllowCustom(true)
|
||||||
|
.setAllowPresets(false)
|
||||||
|
.setDialogType(ColorPickerDialog.TYPE_CUSTOM)
|
||||||
|
.setShowAlphaSlider(false)
|
||||||
|
.setDialogTitle(R.string.mt_color_picker_title)
|
||||||
|
.setColor(customColor)
|
||||||
|
.create()
|
||||||
|
.apply {
|
||||||
|
setColorPickerDialogListener(object : ColorPickerDialogListener {
|
||||||
|
override fun onColorSelected(dialogId: Int, @ColorInt color: Int) {
|
||||||
|
val c = color or -0x1000000
|
||||||
|
Pref.putInt(ColorSelectActivity.KEY_CUSTOM_COLOR, c)
|
||||||
|
setCustomColor(c)
|
||||||
|
setSelectedPosition(ColorSelectActivity.customColorPosition)
|
||||||
|
mOnItemClickListener?.onItemClick(v, ColorSelectActivity.customColorPosition)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDialogDismissed(dialogId: Int) {}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
.show((context as FragmentActivity).supportFragmentManager, "Tag")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setOnItemClickListener(onItemClickListener: ColorSelectActivity.OnItemClickListener?) {
|
||||||
|
mOnItemClickListener = onItemClickListener
|
||||||
|
}
|
||||||
|
|
||||||
|
private inner class Adapter : RecyclerView.Adapter<ViewHolder>() {
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
|
return ViewHolder(LayoutInflater.from(context).inflate(R.layout.mt_color_setting_recycler_view_item, parent, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
|
val item = ColorSelectActivity.getColorItems(context)[position]
|
||||||
|
holder.apply {
|
||||||
|
setColor(item.themeColor.colorPrimary)
|
||||||
|
nameView.text = item.name
|
||||||
|
nameView.setTextColor(context.getColor(R.color.color_selector_item_text))
|
||||||
|
setChecked(mSelectedPosition == position)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount() = ColorSelectActivity.getColorItems(context).size
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||||
|
|
||||||
|
var colorView: ImageView
|
||||||
|
var nameView: TextView
|
||||||
|
|
||||||
|
init {
|
||||||
|
itemView.setOnClickListener(mActualOnItemClickListener)
|
||||||
|
colorView = itemView.findViewById(R.id.color)
|
||||||
|
nameView = itemView.findViewById(R.id.name)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setChecked(checked: Boolean) {
|
||||||
|
if (checked) {
|
||||||
|
colorView.setImageResource(R.drawable.mt_ic_check_white_36dp)
|
||||||
|
val selectedThemeColorRes = selectedThemeColor?.colorPrimary?.let {
|
||||||
|
if (ColorUtils.isLuminanceLight(it)) R.color.day else R.color.night
|
||||||
|
} ?: R.color.night_day
|
||||||
|
colorView.imageTintList = ColorStateList.valueOf(context.getColor(selectedThemeColorRes))
|
||||||
|
} else {
|
||||||
|
colorView.setImageDrawable(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setColor(c: Int) = ThemeColorHelper.setBackgroundColor(colorView, c)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+9
-1
@@ -9,6 +9,8 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
|||||||
import org.autojs.autojs.theme.ThemeColor;
|
import org.autojs.autojs.theme.ThemeColor;
|
||||||
import org.autojs.autojs.theme.ThemeColorManager;
|
import org.autojs.autojs.theme.ThemeColorManager;
|
||||||
import org.autojs.autojs.theme.ThemeColorMutable;
|
import org.autojs.autojs.theme.ThemeColorMutable;
|
||||||
|
import org.autojs.autojs.util.ColorUtils;
|
||||||
|
import org.autojs.autojs6.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Stardust on Aug 16, 2016.
|
* Created by Stardust on Aug 16, 2016.
|
||||||
@@ -35,7 +37,13 @@ public class ThemeColorFloatingActionButton extends FloatingActionButton impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setThemeColor(ThemeColor color) {
|
public void setThemeColor(ThemeColor color) {
|
||||||
setBackgroundTintList(ColorStateList.valueOf(color.colorAccent));
|
int colorAccent = color.colorAccent;
|
||||||
|
setBackgroundTintList(ColorStateList.valueOf(colorAccent));
|
||||||
|
var tintColorRes = ColorUtils.isLuminanceLight(colorAccent)
|
||||||
|
? R.color.fab_tint_dark
|
||||||
|
: R.color.fab_tint_light;
|
||||||
|
var tintColor = getResources().getColor(tintColorRes, null);
|
||||||
|
setImageTintList(ColorStateList.valueOf(tintColor));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
package org.autojs.autojs.theme.widget;
|
package org.autojs.autojs.theme.widget;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.ColorStateList;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.PorterDuffColorFilter;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
import org.autojs.autojs.theme.ThemeColor;
|
import org.autojs.autojs.theme.ThemeColor;
|
||||||
import org.autojs.autojs.theme.ThemeColorManager;
|
import org.autojs.autojs.theme.ThemeColorManager;
|
||||||
import org.autojs.autojs.theme.ThemeColorMutable;
|
import org.autojs.autojs.theme.ThemeColorMutable;
|
||||||
@@ -40,7 +42,43 @@ public class ThemeColorToolbar extends Toolbar implements ThemeColorMutable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setThemeColor(ThemeColor color) {
|
public void setThemeColor(ThemeColor color) {
|
||||||
setBackgroundColor(color.colorPrimary);
|
getViewTreeObserver().addOnGlobalLayoutListener(() -> applyThemeColor(color));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyThemeColor(ThemeColor color) {
|
||||||
|
int colorPrimary = color.colorPrimary;
|
||||||
|
setBackgroundColor(colorPrimary);
|
||||||
|
|
||||||
|
int aimColor;
|
||||||
|
int popupTheme;
|
||||||
|
if (ThemeColorManager.isThemeColorLuminanceLight()) {
|
||||||
|
aimColor = getResources().getColor(R.color.day, null);
|
||||||
|
popupTheme = R.style.PopupMenuThemeLight;
|
||||||
|
} else {
|
||||||
|
aimColor = getResources().getColor(R.color.night, null);
|
||||||
|
popupTheme = R.style.PopupMenuThemeDark;
|
||||||
|
}
|
||||||
|
|
||||||
|
setTitleTextColor(aimColor);
|
||||||
|
setSubtitleTextColor(aimColor);
|
||||||
|
|
||||||
|
Drawable navigationIcon = getNavigationIcon();
|
||||||
|
if (navigationIcon != null) {
|
||||||
|
navigationIcon.setColorFilter(new PorterDuffColorFilter(aimColor, PorterDuff.Mode.SRC_IN));
|
||||||
|
setNavigationIcon(navigationIcon);
|
||||||
|
}
|
||||||
|
Drawable collapseIcon = getCollapseIcon();
|
||||||
|
if (collapseIcon != null) {
|
||||||
|
collapseIcon.setColorFilter(new PorterDuffColorFilter(aimColor, PorterDuff.Mode.SRC_IN));
|
||||||
|
setCollapseIcon(collapseIcon);
|
||||||
|
}
|
||||||
|
Drawable overflowIcon = getOverflowIcon();
|
||||||
|
if (overflowIcon != null) {
|
||||||
|
overflowIcon.setColorFilter(new PorterDuffColorFilter(aimColor, PorterDuff.Mode.SRC_IN));
|
||||||
|
setOverflowIcon(overflowIcon);
|
||||||
|
}
|
||||||
|
|
||||||
|
setPopupTheme(popupTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,11 +5,15 @@ package org.autojs.autojs.ui
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
import android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
import android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||||
|
import android.view.View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||||
|
import android.view.WindowManager
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import org.autojs.autojs.core.accessibility.AccessibilityTool
|
import org.autojs.autojs.core.accessibility.AccessibilityTool
|
||||||
import org.autojs.autojs.core.pref.Language
|
import org.autojs.autojs.core.pref.Language
|
||||||
|
import org.autojs.autojs.theme.ThemeChangeNotifier
|
||||||
import org.autojs.autojs.theme.ThemeColorManager
|
import org.autojs.autojs.theme.ThemeColorManager
|
||||||
import org.autojs.autojs.util.LocaleUtils
|
import org.autojs.autojs.util.LocaleUtils
|
||||||
import org.autojs.autojs.util.ViewUtils
|
import org.autojs.autojs.util.ViewUtils
|
||||||
@@ -21,27 +25,22 @@ import org.autojs.autojs6.BuildConfig
|
|||||||
*/
|
*/
|
||||||
abstract class BaseActivity : AppCompatActivity() {
|
abstract class BaseActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
open val handleStatusBarThemeColorAutomatically = true
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
if (ViewUtils.isAutoNightModeEnabled) {
|
@Suppress("DEPRECATION")
|
||||||
val isNightModeYes = ViewUtils.isNightModeYes(this)
|
ViewUtils.appendSystemUiVisibility(this, SYSTEM_UI_FLAG_LAYOUT_STABLE or SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
|
||||||
if (ViewUtils.isNightModeEnabled != isNightModeYes) {
|
|
||||||
ViewUtils.isNightModeEnabled = isNightModeYes
|
|
||||||
val mode = when (isNightModeYes) {
|
|
||||||
true -> ViewUtils.MODE.NIGHT
|
|
||||||
else -> ViewUtils.MODE.DAY
|
|
||||||
}
|
|
||||||
ViewUtils.setDefaultNightMode(mode)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!BuildConfig.isInrt) {
|
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
|
||||||
ViewUtils.makeBarsAdaptToNightMode(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
setApplicationLocale(this)
|
setApplicationLocale(this)
|
||||||
|
|
||||||
|
ThemeChangeNotifier.themeChanged.observe(this) {
|
||||||
|
initThemeColors()
|
||||||
|
}
|
||||||
|
|
||||||
// @Dubious by SuperMonster003 on Oct 28, 2024.
|
// @Dubious by SuperMonster003 on Oct 28, 2024.
|
||||||
// ! Is it property to start a11y service automatically here?
|
// ! Is it property to start a11y service automatically here?
|
||||||
// ! zh-CN: 无障碍服务自启动放在这里是否合适?
|
// ! zh-CN: 无障碍服务自启动放在这里是否合适?
|
||||||
@@ -62,11 +61,11 @@ abstract class BaseActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
if (!BuildConfig.isInrt) {
|
initThemeColors()
|
||||||
if (window.decorView.systemUiVisibility and SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN == 0) {
|
if (handleStatusBarThemeColorAutomatically && !BuildConfig.isInrt) {
|
||||||
ThemeColorManager.addActivityStatusBar(this)
|
ThemeColorManager.addActivityStatusBar(this)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
setUpStatusBarIconLightByThemeColor()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
@@ -74,8 +73,20 @@ abstract class BaseActivity : AppCompatActivity() {
|
|||||||
LocaleUtils.syncPrefWithCurrentStateIfNeeded(this)
|
LocaleUtils.syncPrefWithCurrentStateIfNeeded(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun initThemeColors() {
|
||||||
|
/* Empty body. */
|
||||||
|
}
|
||||||
|
|
||||||
fun setToolbarAsBack(titleRes: Int) = ViewUtils.setToolbarAsBack(this, titleRes)
|
fun setToolbarAsBack(titleRes: Int) = ViewUtils.setToolbarAsBack(this, titleRes)
|
||||||
|
|
||||||
fun setToolbarAsBack(title: String?) = ViewUtils.setToolbarAsBack(this, title)
|
fun setToolbarAsBack(title: String?) = ViewUtils.setToolbarAsBack(this, title)
|
||||||
|
|
||||||
|
protected fun setUpStatusBarIconLightByNightMode() {
|
||||||
|
ViewUtils.setStatusBarIconLight(this, ViewUtils.isNightModeEnabled)
|
||||||
|
}
|
||||||
|
|
||||||
|
protected fun setUpStatusBarIconLightByThemeColor() {
|
||||||
|
ViewUtils.setStatusBarIconLight(this, ThemeColorManager.isThemeColorLuminanceDark())
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -717,7 +717,7 @@ open class ExplorerView : ThemeColorSwipeRefreshLayout, SwipeRefreshLayout.OnRef
|
|||||||
mFirstChar.setIcon(ExplorerViewHelper.getIcon(item))
|
mFirstChar.setIcon(ExplorerViewHelper.getIcon(item))
|
||||||
when (item.type) {
|
when (item.type) {
|
||||||
FileUtils.TYPE.JAVASCRIPT, FileUtils.TYPE.AUTO -> mFirstChar
|
FileUtils.TYPE.JAVASCRIPT, FileUtils.TYPE.AUTO -> mFirstChar
|
||||||
.setIconTextColorNightDay()
|
.setIconTextByThemeColorLuminance()
|
||||||
.setStrokeThemeColor()
|
.setStrokeThemeColor()
|
||||||
.setFillThemeColor()
|
.setFillThemeColor()
|
||||||
else -> mFirstChar
|
else -> mFirstChar
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class ExplorerItemViewHolder extends BindableViewHolder<Object> {
|
|||||||
|
|
||||||
switch (explorerItem.getType()) {
|
switch (explorerItem.getType()) {
|
||||||
case JAVASCRIPT, AUTO -> firstCharIconBinding.firstChar
|
case JAVASCRIPT, AUTO -> firstCharIconBinding.firstChar
|
||||||
.setIconTextColorNightDay()
|
.setIconTextByThemeColorLuminance()
|
||||||
.setStrokeThemeColor()
|
.setStrokeThemeColor()
|
||||||
.setFillColorDayNight();
|
.setFillColorDayNight();
|
||||||
default -> firstCharIconBinding.firstChar
|
default -> firstCharIconBinding.firstChar
|
||||||
|
|||||||
@@ -5,7 +5,12 @@ import android.annotation.SuppressLint
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
|
import android.content.res.ColorStateList
|
||||||
|
import android.graphics.PorterDuff
|
||||||
|
import android.graphics.PorterDuffColorFilter
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
import android.os.Process
|
import android.os.Process
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
@@ -14,11 +19,13 @@ import android.view.MenuItem
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions
|
import androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions
|
||||||
import androidx.appcompat.app.ActionBarDrawerToggle
|
import androidx.appcompat.app.ActionBarDrawerToggle
|
||||||
|
import androidx.core.view.forEach
|
||||||
import androidx.drawerlayout.widget.DrawerLayout
|
import androidx.drawerlayout.widget.DrawerLayout
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.viewpager.widget.ViewPager
|
import androidx.viewpager.widget.ViewPager
|
||||||
import androidx.viewpager.widget.ViewPager.SimpleOnPageChangeListener
|
import androidx.viewpager.widget.ViewPager.SimpleOnPageChangeListener
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
import com.google.android.material.tabs.TabLayout
|
||||||
import com.huaban.analysis.jieba.CharsDictionaryDatabase
|
import com.huaban.analysis.jieba.CharsDictionaryDatabase
|
||||||
import com.huaban.analysis.jieba.PhrasesDictionaryDatabase
|
import com.huaban.analysis.jieba.PhrasesDictionaryDatabase
|
||||||
import com.huaban.analysis.jieba.WordDictionaryDatabase
|
import com.huaban.analysis.jieba.WordDictionaryDatabase
|
||||||
@@ -40,7 +47,9 @@ import org.autojs.autojs.permission.ManageAllFilesPermission
|
|||||||
import org.autojs.autojs.permission.PostNotificationPermission
|
import org.autojs.autojs.permission.PostNotificationPermission
|
||||||
import org.autojs.autojs.runtime.api.WrappedShizuku
|
import org.autojs.autojs.runtime.api.WrappedShizuku
|
||||||
import org.autojs.autojs.service.ForegroundService
|
import org.autojs.autojs.service.ForegroundService
|
||||||
|
import org.autojs.autojs.theme.ThemeColorManager
|
||||||
import org.autojs.autojs.theme.ThemeColorManager.addViewBackground
|
import org.autojs.autojs.theme.ThemeColorManager.addViewBackground
|
||||||
|
import org.autojs.autojs.theme.widget.ThemeColorToolbar
|
||||||
import org.autojs.autojs.ui.BaseActivity
|
import org.autojs.autojs.ui.BaseActivity
|
||||||
import org.autojs.autojs.ui.doc.DocumentationFragment
|
import org.autojs.autojs.ui.doc.DocumentationFragment
|
||||||
import org.autojs.autojs.ui.enhancedfloaty.FloatyService
|
import org.autojs.autojs.ui.enhancedfloaty.FloatyService
|
||||||
@@ -54,6 +63,7 @@ import org.autojs.autojs.ui.main.task.TaskManagerFragment
|
|||||||
import org.autojs.autojs.ui.settings.PreferencesActivity
|
import org.autojs.autojs.ui.settings.PreferencesActivity
|
||||||
import org.autojs.autojs.ui.widget.DrawerAutoClose
|
import org.autojs.autojs.ui.widget.DrawerAutoClose
|
||||||
import org.autojs.autojs.ui.widget.SearchViewItem
|
import org.autojs.autojs.ui.widget.SearchViewItem
|
||||||
|
import org.autojs.autojs.util.StringUtils.key
|
||||||
import org.autojs.autojs.util.UpdateUtils
|
import org.autojs.autojs.util.UpdateUtils
|
||||||
import org.autojs.autojs.util.ViewUtils
|
import org.autojs.autojs.util.ViewUtils
|
||||||
import org.autojs.autojs.util.WorkingDirectoryUtils
|
import org.autojs.autojs.util.WorkingDirectoryUtils
|
||||||
@@ -67,12 +77,18 @@ import org.greenrobot.eventbus.EventBus
|
|||||||
*/
|
*/
|
||||||
class MainActivity : BaseActivity(), DelegateHost, HostActivity {
|
class MainActivity : BaseActivity(), DelegateHost, HostActivity {
|
||||||
|
|
||||||
|
override val handleStatusBarThemeColorAutomatically = false
|
||||||
|
|
||||||
private var binding: ActivityMainBinding? = null
|
private var binding: ActivityMainBinding? = null
|
||||||
|
|
||||||
private lateinit var mViewPager: ViewPager
|
private lateinit var mViewPager: ViewPager
|
||||||
private lateinit var mFab: FloatingActionButton
|
private lateinit var mFab: FloatingActionButton
|
||||||
|
private lateinit var mTab: TabLayout
|
||||||
|
private lateinit var mToolbar: ThemeColorToolbar
|
||||||
private lateinit var mPagerAdapter: StoredFragmentPagerAdapter
|
private lateinit var mPagerAdapter: StoredFragmentPagerAdapter
|
||||||
private lateinit var mLogMenuItem: MenuItem
|
private lateinit var mLogMenuItem: MenuItem
|
||||||
|
private lateinit var mSearchMenuItem: MenuItem
|
||||||
|
private lateinit var mActionBarDrawerToggle: ActionBarDrawerToggle
|
||||||
|
|
||||||
private val mActivityResultMediator = OnActivityResultDelegate.Mediator()
|
private val mActivityResultMediator = OnActivityResultDelegate.Mediator()
|
||||||
private val mRequestPermissionCallbacks = RequestPermissionCallbacks()
|
private val mRequestPermissionCallbacks = RequestPermissionCallbacks()
|
||||||
@@ -119,14 +135,19 @@ class MainActivity : BaseActivity(), DelegateHost, HostActivity {
|
|||||||
setContentView(it.root)
|
setContentView(it.root)
|
||||||
mViewPager = it.viewpager
|
mViewPager = it.viewpager
|
||||||
mFab = it.fab
|
mFab = it.fab
|
||||||
|
mTab = it.tab
|
||||||
|
mToolbar = it.toolbar
|
||||||
addViewBackground(it.appBar)
|
addViewBackground(it.appBar)
|
||||||
setUpToolbar(it, drawerLayout)
|
setUpToolbar(drawerLayout)
|
||||||
setUpTabViewPager(it)
|
setUpTabViewPager(it)
|
||||||
registerBackPressHandlers(drawerLayout)
|
registerBackPressHandlers(drawerLayout)
|
||||||
}
|
}
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
ViewUtils.appendSystemUiVisibility(this, View.SYSTEM_UI_FLAG_LAYOUT_STABLE)
|
Pref.registerOnSharedPreferenceChangeListener { _, key ->
|
||||||
ViewUtils.registerOnSharedPreferenceChangeListener(this)
|
if (key == key(R.string.key_keep_screen_on_when_in_foreground)) {
|
||||||
|
ViewUtils.configKeepScreenOnWhenInForeground(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WorkingDirectoryUtils.determineIfNeeded()
|
WorkingDirectoryUtils.determineIfNeeded()
|
||||||
ExplorerView.clearViewStates()
|
ExplorerView.clearViewStates()
|
||||||
@@ -162,27 +183,37 @@ class MainActivity : BaseActivity(), DelegateHost, HostActivity {
|
|||||||
mBackPressObserver.registerHandler(DoublePressExit(this, R.string.text_press_again_to_exit))
|
mBackPressObserver.registerHandler(DoublePressExit(this, R.string.text_press_again_to_exit))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpToolbar(binding: ActivityMainBinding, drawerLayout: DrawerLayout) {
|
private fun setUpToolbar(drawerLayout: DrawerLayout) {
|
||||||
val toolbar = binding.toolbar.also {
|
val toolbar = mToolbar.also {
|
||||||
setSupportActionBar(it)
|
setSupportActionBar(it)
|
||||||
it.setTitle(R.string.app_name)
|
it.setTitle(R.string.app_name)
|
||||||
it.setOnLongClickListener { true.also { PreferencesActivity.launch(this) } }
|
it.setOnLongClickListener { true.also { PreferencesActivity.launch(this) } }
|
||||||
}
|
}
|
||||||
|
|
||||||
object : ActionBarDrawerToggle(
|
mActionBarDrawerToggle = object : ActionBarDrawerToggle(
|
||||||
this,
|
this,
|
||||||
drawerLayout,
|
drawerLayout,
|
||||||
toolbar,
|
toolbar,
|
||||||
R.string.text_drawer_open,
|
R.string.text_drawer_open,
|
||||||
R.string.text_drawer_close
|
R.string.text_drawer_close
|
||||||
) {
|
) {
|
||||||
|
override fun onDrawerSlide(drawerView: View, slideOffset: Float) {
|
||||||
|
super.onDrawerSlide(drawerView, slideOffset)
|
||||||
|
when {
|
||||||
|
slideOffset > 0.5 -> setUpStatusBarIconLightByNightMode()
|
||||||
|
else -> setUpStatusBarIconLightByThemeColor()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDrawerOpened(drawerView: View) {
|
override fun onDrawerOpened(drawerView: View) {
|
||||||
super.onDrawerOpened(drawerView)
|
super.onDrawerOpened(drawerView)
|
||||||
|
sIsActionBarDrawerOpened = true
|
||||||
EventBus.getDefault().post(object : OnDrawerOpened {})
|
EventBus.getDefault().post(object : OnDrawerOpened {})
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDrawerClosed(drawerView: View) {
|
override fun onDrawerClosed(drawerView: View) {
|
||||||
super.onDrawerClosed(drawerView)
|
super.onDrawerClosed(drawerView)
|
||||||
|
sIsActionBarDrawerOpened = false
|
||||||
EventBus.getDefault().post(object : OnDrawerClosed {})
|
EventBus.getDefault().post(object : OnDrawerClosed {})
|
||||||
}
|
}
|
||||||
}.also {
|
}.also {
|
||||||
@@ -224,6 +255,67 @@ class MainActivity : BaseActivity(), DelegateHost, HostActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun initThemeColors() {
|
||||||
|
super.initThemeColors()
|
||||||
|
setUpToolbarColors()
|
||||||
|
setUpTabLayoutColors()
|
||||||
|
setUpStatusBarIconLight()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onWindowFocusChanged(hasFocus: Boolean) {
|
||||||
|
super.onWindowFocusChanged(hasFocus)
|
||||||
|
if (hasFocus) {
|
||||||
|
setUpStatusBarIconLight()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpToolbarColors() {
|
||||||
|
val aimColor = when {
|
||||||
|
ThemeColorManager.isThemeColorLuminanceLight() -> getColor(R.color.day)
|
||||||
|
else -> getColor(R.color.night)
|
||||||
|
}
|
||||||
|
mToolbar.menu.forEach { menuItem ->
|
||||||
|
menuItem.icon?.colorFilter = PorterDuffColorFilter(aimColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
mSearchViewItem?.initThemeColors()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpTabLayoutColors() {
|
||||||
|
val tabNormalColor: Int
|
||||||
|
val tabSelectedColor: Int
|
||||||
|
val tabSelectedIndicatorColor: Int
|
||||||
|
when {
|
||||||
|
ThemeColorManager.isThemeColorLuminanceLight() -> {
|
||||||
|
tabNormalColor = getColor(R.color.tab_text_dark)
|
||||||
|
tabSelectedColor = getColor(R.color.tab_selected_text_dark)
|
||||||
|
tabSelectedIndicatorColor = getColor(R.color.tab_indicator_dark)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
tabNormalColor = getColor(R.color.tab_text_light)
|
||||||
|
tabSelectedColor = getColor(R.color.tab_selected_text_light)
|
||||||
|
tabSelectedIndicatorColor = getColor(R.color.tab_indicator_light)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mTab.setTabTextColors(tabNormalColor, tabSelectedColor)
|
||||||
|
mTab.setSelectedTabIndicatorColor(tabSelectedIndicatorColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpStatusBarIconLight() {
|
||||||
|
if (shouldChangeStatusBarIconLight()) {
|
||||||
|
Handler(Looper.getMainLooper()).post {
|
||||||
|
if (sIsActionBarDrawerOpened) {
|
||||||
|
setUpStatusBarIconLightByNightMode()
|
||||||
|
} else {
|
||||||
|
setUpStatusBarIconLightByThemeColor()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun shouldChangeStatusBarIconLight(): Boolean {
|
||||||
|
return ViewUtils.isNightModeEnabled == ViewUtils.isStatusBarIconDark(this)
|
||||||
|
}
|
||||||
|
|
||||||
fun rebirth() {
|
fun rebirth() {
|
||||||
packageManager.getLaunchIntentForPackage(packageName)?.let {
|
packageManager.getLaunchIntentForPackage(packageName)?.let {
|
||||||
startActivity(Intent.makeRestartActivityTask(it.component))
|
startActivity(Intent.makeRestartActivityTask(it.component))
|
||||||
@@ -290,7 +382,9 @@ class MainActivity : BaseActivity(), DelegateHost, HostActivity {
|
|||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
menuInflater.inflate(R.menu.menu_main, menu)
|
menuInflater.inflate(R.menu.menu_main, menu)
|
||||||
mLogMenuItem = menu.findItem(R.id.action_log)
|
mLogMenuItem = menu.findItem(R.id.action_log)
|
||||||
setUpSearchMenuItem(menu.findItem(R.id.action_search))
|
mSearchMenuItem = menu.findItem(R.id.action_search)
|
||||||
|
setUpSearchMenuItem(mSearchMenuItem)
|
||||||
|
setUpToolbarColors()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,6 +403,7 @@ class MainActivity : BaseActivity(), DelegateHost, HostActivity {
|
|||||||
private fun setUpSearchMenuItem(searchMenuItem: MenuItem) {
|
private fun setUpSearchMenuItem(searchMenuItem: MenuItem) {
|
||||||
mSearchViewItem = object : SearchViewItem(this, searchMenuItem) {
|
mSearchViewItem = object : SearchViewItem(this, searchMenuItem) {
|
||||||
override fun onMenuItemActionExpand(item: MenuItem): Boolean {
|
override fun onMenuItemActionExpand(item: MenuItem): Boolean {
|
||||||
|
setUpToolbarCollapseIconColor()
|
||||||
if (isCurrentPageDocs) {
|
if (isCurrentPageDocs) {
|
||||||
mDocsSearchItemExpanded = true
|
mDocsSearchItemExpanded = true
|
||||||
mLogMenuItem.setIcon(R.drawable.ic_ali_up)
|
mLogMenuItem.setIcon(R.drawable.ic_ali_up)
|
||||||
@@ -340,6 +435,18 @@ class MainActivity : BaseActivity(), DelegateHost, HostActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setUpToolbarCollapseIconColor() {
|
||||||
|
val collapseIcon = mToolbar.collapseIcon
|
||||||
|
if (collapseIcon != null) {
|
||||||
|
val isThemeColorLuminanceLight = ThemeColorManager.isThemeColorLuminanceLight()
|
||||||
|
val fullColor = getColor(if (isThemeColorLuminanceLight) R.color.day_full else R.color.night_full)
|
||||||
|
collapseIcon.setTintList(ColorStateList.valueOf(fullColor))
|
||||||
|
collapseIcon.setTint(fullColor)
|
||||||
|
collapseIcon.colorFilter = PorterDuffColorFilter(fullColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
mToolbar.collapseIcon = collapseIcon
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun submitForwardQuery() {
|
private fun submitForwardQuery() {
|
||||||
val event = QueryEvent.FIND_FORWARD
|
val event = QueryEvent.FIND_FORWARD
|
||||||
EventBus.getDefault().post(event)
|
EventBus.getDefault().post(event)
|
||||||
@@ -354,12 +461,12 @@ class MainActivity : BaseActivity(), DelegateHost, HostActivity {
|
|||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
binding = null
|
binding = null
|
||||||
mSearchViewItem = null
|
mSearchViewItem = null
|
||||||
EventBus.getDefault().unregister(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private val TAG = MainActivity::class.java.simpleName
|
private val TAG = MainActivity::class.java.simpleName
|
||||||
|
private var sIsActionBarDrawerOpened = false
|
||||||
|
|
||||||
var shouldRecreateMainActivity = false
|
var shouldRecreateMainActivity = false
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ import org.autojs.autojs.ui.settings.PreferencesActivity
|
|||||||
import org.autojs.autojs.util.NetworkUtils
|
import org.autojs.autojs.util.NetworkUtils
|
||||||
import org.autojs.autojs.util.ViewUtils
|
import org.autojs.autojs.util.ViewUtils
|
||||||
import org.autojs.autojs.util.ViewUtils.MODE
|
import org.autojs.autojs.util.ViewUtils.MODE
|
||||||
import org.autojs.autojs.util.ViewUtils.isNightModeYes
|
|
||||||
import org.autojs.autojs6.BuildConfig
|
import org.autojs.autojs6.BuildConfig
|
||||||
import org.autojs.autojs6.R
|
import org.autojs.autojs6.R
|
||||||
import org.autojs.autojs6.databinding.FragmentDrawerBinding
|
import org.autojs.autojs6.databinding.FragmentDrawerBinding
|
||||||
@@ -273,7 +272,7 @@ open class DrawerFragment : Fragment() {
|
|||||||
object : DrawerMenuItemCustomHelper(mContext) {
|
object : DrawerMenuItemCustomHelper(mContext) {
|
||||||
override fun toggle(): Boolean = runCatching {
|
override fun toggle(): Boolean = runCatching {
|
||||||
val isTurningOn = !isActive
|
val isTurningOn = !isActive
|
||||||
val isNightModeYes = isNightModeYes(resources.configuration)
|
val isNightModeYes = ViewUtils.isNightModeYes(resources.configuration)
|
||||||
val mode = when {
|
val mode = when {
|
||||||
isTurningOn -> MODE.FOLLOW
|
isTurningOn -> MODE.FOLLOW
|
||||||
isNightModeYes -> MODE.NIGHT
|
isNightModeYes -> MODE.NIGHT
|
||||||
@@ -281,7 +280,7 @@ open class DrawerFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
ViewUtils.setDefaultNightMode(mode)
|
ViewUtils.setDefaultNightMode(mode)
|
||||||
if (isTurningOn) {
|
if (isTurningOn) {
|
||||||
ViewUtils.isNightModeEnabled = isNightModeYes
|
ViewUtils.isNightModeEnabled = ViewUtils.isSystemDarkModeEnabled(mContext)
|
||||||
Pref.putString(R.string.key_night_mode, MODE.FOLLOW.key)
|
Pref.putString(R.string.key_night_mode, MODE.FOLLOW.key)
|
||||||
} else {
|
} else {
|
||||||
when (isNightModeYes) {
|
when (isNightModeYes) {
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ package org.autojs.autojs.ui.settings
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import org.autojs.autojs.app.GlobalAppContext
|
import org.autojs.autojs.app.GlobalAppContext
|
||||||
|
import org.autojs.autojs.theme.ThemeColorManager
|
||||||
import org.autojs.autojs.ui.BaseActivity
|
import org.autojs.autojs.ui.BaseActivity
|
||||||
import org.autojs.autojs6.R
|
import org.autojs.autojs6.R
|
||||||
import org.autojs.autojs6.databinding.ActivityPreferencesBinding
|
import org.autojs.autojs6.databinding.ActivityPreferencesBinding
|
||||||
@@ -14,7 +16,7 @@ import org.autojs.autojs6.databinding.ActivityPreferencesBinding
|
|||||||
*/
|
*/
|
||||||
open class PreferencesActivity : BaseActivity() {
|
open class PreferencesActivity : BaseActivity() {
|
||||||
|
|
||||||
private lateinit var binding: ActivityPreferencesBinding
|
private var binding: ActivityPreferencesBinding? = null
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@@ -34,6 +36,22 @@ open class PreferencesActivity : BaseActivity() {
|
|||||||
.commit()
|
.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onStart() {
|
||||||
|
super.onStart()
|
||||||
|
binding!!.toolbar.navigationIcon?.let {
|
||||||
|
val aimColor = when {
|
||||||
|
ThemeColorManager.isThemeColorLuminanceLight() -> ContextCompat.getColor(this, R.color.day)
|
||||||
|
else -> ContextCompat.getColor(this, R.color.night)
|
||||||
|
}
|
||||||
|
it.setTint(aimColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
binding = null
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
|||||||
@@ -17,12 +17,15 @@ import org.autojs.autojs6.R
|
|||||||
@SuppressLint("CustomSplashScreen")
|
@SuppressLint("CustomSplashScreen")
|
||||||
class SplashActivity : BaseActivity() {
|
class SplashActivity : BaseActivity() {
|
||||||
|
|
||||||
|
override val handleStatusBarThemeColorAutomatically = false
|
||||||
|
|
||||||
private var mAlreadyEnterNextActivity = false
|
private var mAlreadyEnterNextActivity = false
|
||||||
private var mPaused = false
|
private var mPaused = false
|
||||||
|
|
||||||
private lateinit var mHandler: Handler
|
private lateinit var mHandler: Handler
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_splash)
|
setContentView(R.layout.activity_splash)
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
@@ -30,7 +33,6 @@ class SplashActivity : BaseActivity() {
|
|||||||
mHandler.postDelayed({ enterNextActivity() }, INIT_TIMEOUT)
|
mHandler.postDelayed({ enterNextActivity() }, INIT_TIMEOUT)
|
||||||
|
|
||||||
FloatyWindowManger.hideCircularMenuIfNeeded()
|
FloatyWindowManger.hideCircularMenuIfNeeded()
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import android.view.Gravity
|
|||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
import androidx.annotation.ColorRes
|
import androidx.annotation.ColorRes
|
||||||
|
import org.autojs.autojs.theme.ThemeColorManager
|
||||||
import org.autojs.autojs.theme.ThemeColorManagerCompat
|
import org.autojs.autojs.theme.ThemeColorManagerCompat
|
||||||
import org.autojs.autojs.util.FileUtils
|
import org.autojs.autojs.util.FileUtils
|
||||||
import org.autojs.autojs6.R
|
import org.autojs.autojs6.R
|
||||||
@@ -71,6 +72,13 @@ class FirstCharView : TextView {
|
|||||||
|
|
||||||
fun setIconTextColorRes(@ColorRes colorRes: Int) = also { setTextColor(convertColorResToInt(colorRes)) }
|
fun setIconTextColorRes(@ColorRes colorRes: Int) = also { setTextColor(convertColorResToInt(colorRes)) }
|
||||||
|
|
||||||
|
fun setIconTextByThemeColorLuminance() = also {
|
||||||
|
when {
|
||||||
|
ThemeColorManager.isThemeColorLuminanceLight() -> setIconTextColorRes(R.color.day)
|
||||||
|
else -> setIconTextColorRes(R.color.night)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun setIconTextThemeColor() = setIconTextColor(ThemeColorManagerCompat.getColorPrimary())
|
fun setIconTextThemeColor() = setIconTextColor(ThemeColorManagerCompat.getColorPrimary())
|
||||||
|
|
||||||
fun setIconTextColorDayNight() = setIconTextColorRes(COLOR_RES_DAY_NIGHT)
|
fun setIconTextColorDayNight() = setIconTextColorRes(COLOR_RES_DAY_NIGHT)
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import android.app.SearchManager;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageView;
|
||||||
import androidx.appcompat.widget.SearchView;
|
import androidx.appcompat.widget.SearchView;
|
||||||
import androidx.core.view.MenuItemCompat;
|
import androidx.core.view.MenuItemCompat;
|
||||||
|
import org.autojs.autojs.theme.ThemeColorManager;
|
||||||
import org.autojs.autojs6.R;
|
import org.autojs.autojs6.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,8 +22,12 @@ public class SearchViewItem implements MenuItemCompat.OnActionExpandListener, Se
|
|||||||
|
|
||||||
private QueryCallback mQueryCallback;
|
private QueryCallback mQueryCallback;
|
||||||
private final MenuItem mSearchMenuItem;
|
private final MenuItem mSearchMenuItem;
|
||||||
|
private final Activity mActivity;
|
||||||
|
private EditText mTextview;
|
||||||
|
private ImageView mCloseButtonView;
|
||||||
|
|
||||||
public SearchViewItem(Activity activity, MenuItem searchMenuItem) {
|
public SearchViewItem(Activity activity, MenuItem searchMenuItem) {
|
||||||
|
mActivity = activity;
|
||||||
mSearchMenuItem = searchMenuItem;
|
mSearchMenuItem = searchMenuItem;
|
||||||
SearchManager searchManager = (SearchManager) activity.getSystemService(Context.SEARCH_SERVICE);
|
SearchManager searchManager = (SearchManager) activity.getSystemService(Context.SEARCH_SERVICE);
|
||||||
SearchView searchView = (SearchView) searchMenuItem.getActionView();
|
SearchView searchView = (SearchView) searchMenuItem.getActionView();
|
||||||
@@ -31,14 +35,27 @@ public class SearchViewItem implements MenuItemCompat.OnActionExpandListener, Se
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
searchView.setSearchableInfo(searchManager.getSearchableInfo(activity.getComponentName()));
|
searchView.setSearchableInfo(searchManager.getSearchableInfo(activity.getComponentName()));
|
||||||
EditText textview = searchView.findViewById(androidx.appcompat.R.id.search_src_text);
|
mTextview = searchView.findViewById(androidx.appcompat.R.id.search_src_text);
|
||||||
if (textview != null) {
|
mCloseButtonView = searchView.findViewById(androidx.appcompat.R.id.search_close_btn);
|
||||||
textview.setHintTextColor(activity.getColor(R.color.night_day));
|
initThemeColors();
|
||||||
}
|
|
||||||
MenuItemCompat.setOnActionExpandListener(searchMenuItem, this);
|
MenuItemCompat.setOnActionExpandListener(searchMenuItem, this);
|
||||||
searchView.setOnQueryTextListener(this);
|
searchView.setOnQueryTextListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void initThemeColors() {
|
||||||
|
boolean isThemeColorLuminanceLight = ThemeColorManager.isThemeColorLuminanceLight();
|
||||||
|
int fullColor = mActivity.getColor(isThemeColorLuminanceLight ? R.color.day_full : R.color.night_full);
|
||||||
|
int hintColor = mActivity.getColor(isThemeColorLuminanceLight ? R.color.day : R.color.night);
|
||||||
|
|
||||||
|
if (mTextview != null) {
|
||||||
|
mTextview.setTextColor(fullColor);
|
||||||
|
mTextview.setHintTextColor(hintColor);
|
||||||
|
}
|
||||||
|
if (mCloseButtonView != null) {
|
||||||
|
mCloseButtonView.setColorFilter(fullColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setQueryCallback(QueryCallback queryCallback) {
|
public void setQueryCallback(QueryCallback queryCallback) {
|
||||||
mQueryCallback = queryCallback;
|
mQueryCallback = queryCallback;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import android.graphics.Color
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
import androidx.annotation.ColorRes
|
import androidx.annotation.ColorRes
|
||||||
|
import androidx.core.graphics.ColorUtils
|
||||||
import org.autojs.autojs.app.GlobalAppContext
|
import org.autojs.autojs.app.GlobalAppContext
|
||||||
import org.autojs.autojs.core.image.ColorTable
|
import org.autojs.autojs.core.image.ColorTable
|
||||||
import org.autojs.autojs.theme.ThemeColor
|
import org.autojs.autojs.theme.ThemeColor
|
||||||
@@ -17,6 +18,7 @@ import kotlin.math.pow
|
|||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
import kotlin.text.RegexOption.IGNORE_CASE
|
import kotlin.text.RegexOption.IGNORE_CASE
|
||||||
|
|
||||||
|
@Suppress("FunctionName")
|
||||||
object ColorUtils {
|
object ColorUtils {
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
@@ -514,12 +516,120 @@ object ColorUtils {
|
|||||||
return tmp.toInt()
|
return tmp.toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toColorStateList(color: String): ColorStateList {
|
fun toColorStateList(color: String) = ColorStateList.valueOf(toInt(color))
|
||||||
return ColorStateList.valueOf(toInt(color))
|
|
||||||
|
fun toColorStateList(view: View, color: String) = ColorStateList.valueOf(parse(view, color))
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun rgb(red: Int, green: Int, blue: Int): Int = Color.rgb(red, green, blue)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun argb(alpha: Int, red: Int, green: Int, blue: Int): Int = Color.argb(alpha, red, green, blue)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the relative luminance of a color based on the W3C WCAG 2.0 definition.
|
||||||
|
* This method employs a perceptual brightness calculation, which considers how human eyes perceive light
|
||||||
|
* and visibly similar changes in brightness. It differs from a simple brightness calculation by employing
|
||||||
|
* gamma correction and converting RGB color information to the CIE XYZ color space.
|
||||||
|
*
|
||||||
|
* zh-CN:
|
||||||
|
*
|
||||||
|
* 计算颜色相对亮度 (luminance), 基于 W3C WCAG 2.0 的定义.
|
||||||
|
* 本方法采用了一种符合人眼感知的亮度计算方式, 考虑到人眼对不同颜色的光敏感性的非线性特性以及视网膜对亮度变化的感知效果.
|
||||||
|
* 与简单的线性明度计算不同, 本方法通过加入伽马矫正 (Gamma Correction) 和将 RGB 颜色转化到 CIE XYZ 色彩空间来实现更真实的感官亮度评估.
|
||||||
|
*
|
||||||
|
* Differences from basic brightness calculation:
|
||||||
|
* 1. Gamma Correction: Adjusts the linear RGB color channels to account for human vision's non-linear
|
||||||
|
* response to light intensity. This step improves the representation of perceptual brightness.
|
||||||
|
* 2. CIE XYZ Color Space: To better model human color perception, color information is converted
|
||||||
|
* from RGB to the XYZ color space, which defines brightness, chromaticity, and hue more accurately.
|
||||||
|
*
|
||||||
|
* zh-CN:
|
||||||
|
*
|
||||||
|
* 与基本明度计算的区别:
|
||||||
|
* 1. 伽马矫正 (Gamma Correction): 对 RGB 通道值进行非线性调整, 以匹配人眼对亮度强度的非线性响应. 此步骤可提高感知亮度的准确性.
|
||||||
|
* 2. CIE XYZ 色彩空间: 将颜色从 RGB 转换到 XYZ 色彩空间, 该空间定义了更符合人类视觉感知的 [亮度/色度/色调] 信息.
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* This method adheres to the W3C Web Content Accessibility Guidelines (WCAG 2.0) definition of relative
|
||||||
|
* luminance, suitable for evaluating color contrast ratios to ensure text readability and accessibility.
|
||||||
|
* For example, it is commonly used in validating color combinations for web accessibility or UI design.
|
||||||
|
*
|
||||||
|
* zh-CN:
|
||||||
|
*
|
||||||
|
* 用法:
|
||||||
|
* 本方法遵循 W3C <<网络内容无障碍指南2.0>> (WCAG 2.0) 中定义的 "相对亮度" 概念,
|
||||||
|
* 适用于评估颜色对比度, 从而确保文本可读性和无障碍性设计.
|
||||||
|
* 例如, 在验证网页颜色组合或 UI 设计中的颜色对比是否满足无障碍标准中, 广泛使用此方法.
|
||||||
|
*
|
||||||
|
* Implementation notes:
|
||||||
|
* Internally, this method uses [androidx.core.graphics.ColorUtils.calculateLuminance], which follows
|
||||||
|
* the WCAG standard. On `Android O` or higher, alternative system solutions such as [Color.luminance]
|
||||||
|
* may also be used.
|
||||||
|
*
|
||||||
|
* zh-CN:
|
||||||
|
*
|
||||||
|
* 实现说明:
|
||||||
|
* 此方法对内调用了 [androidx.core.graphics.ColorUtils.calculateLuminance], 其实现遵循 WCAG 标准.
|
||||||
|
* 对于 `Android O` 及其以上版本, 也可以替代性地使用系统方法如 [Color.luminance].
|
||||||
|
*
|
||||||
|
* @param color The input color, in ARGB format. (zh-CN: 输入颜色, 以 ARGB 格式表示).
|
||||||
|
* @return The relative luminance of the color, following WCAG 2.0 standards. (zh-CN: 返回该颜色的相对亮度, 符合 WCAG 2.0 标准).
|
||||||
|
*
|
||||||
|
* @see <a href="https://www.w3.org/TR/WCAG20/#relativeluminancedef">W3C Recommendation</a>
|
||||||
|
*/
|
||||||
|
@JvmStatic
|
||||||
|
fun luminance(@ColorInt color: Int): Double {
|
||||||
|
// @Hint by SuperMonster003 on Jan 21, 2023.
|
||||||
|
// ! Compatibility solution.
|
||||||
|
// ! zh-CN: 兼容方案.
|
||||||
|
// # return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
||||||
|
// # ? Color.luminance(Color.pack(color))
|
||||||
|
// # : Color.luminance(color);
|
||||||
|
return ColorUtils.calculateLuminance(color)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toColorStateList(view: View, color: String): ColorStateList {
|
/**
|
||||||
return ColorStateList.valueOf(parse(view, color))
|
* @see <a href=https://stackoverflow.com/
|
||||||
|
* questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color>
|
||||||
|
* How to decide font color in white or black depending on background color?
|
||||||
|
* </a>
|
||||||
|
*/
|
||||||
|
@JvmStatic
|
||||||
|
fun isLuminanceLight(@ColorInt color: Int) = luminance(color) > 0.179
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun isLuminanceDark(@ColorInt color: Int) = !isLuminanceLight(color)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun parseColor(colorString: String?): Int = Color.parseColor(colorString)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun RGBToHSV(red: Int, green: Int, blue: Int, hsv: FloatArray?) {
|
||||||
|
Color.RGBToHSV(red, green, blue, hsv)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun colorToHSV(color: Int, hsv: FloatArray?) {
|
||||||
|
Color.colorToHSV(color, hsv)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun HSVToColor(hsv: FloatArray?) = Color.HSVToColor(hsv)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun HSVToColor(alpha: Int, hsv: FloatArray?) = Color.HSVToColor(alpha, hsv)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun equals(c1: Int, c2: Int) = (c1 and 0xffffff) == (c2 and 0xffffff)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun equals(c1: Int, c2: String?) = equals(c1, parseColor(c2))
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun equals(c1: String?, c2: Int) = equals(parseColor(c1), c2)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun equals(c1: String?, c2: String?) = equals(parseColor(c1), parseColor(c2))
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,13 +2,17 @@
|
|||||||
|
|
||||||
package org.autojs.autojs.util
|
package org.autojs.autojs.util
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
import android.app.UiModeManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.ContextWrapper
|
import android.content.ContextWrapper
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.content.res.Configuration.UI_MODE_NIGHT_MASK
|
import android.content.res.Configuration.UI_MODE_NIGHT_MASK
|
||||||
import android.content.res.Configuration.UI_MODE_NIGHT_YES
|
import android.content.res.Configuration.UI_MODE_NIGHT_YES
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
import android.graphics.PorterDuff
|
||||||
|
import android.graphics.PorterDuffColorFilter
|
||||||
import android.graphics.Rect
|
import android.graphics.Rect
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
@@ -26,6 +30,7 @@ import androidx.core.view.WindowInsetsControllerCompat
|
|||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import org.autojs.autojs.app.GlobalAppContext
|
import org.autojs.autojs.app.GlobalAppContext
|
||||||
import org.autojs.autojs.core.pref.Pref
|
import org.autojs.autojs.core.pref.Pref
|
||||||
|
import org.autojs.autojs.theme.ThemeColorManager
|
||||||
import org.autojs.autojs.util.StringUtils.key
|
import org.autojs.autojs.util.StringUtils.key
|
||||||
import org.autojs.autojs6.R
|
import org.autojs.autojs6.R
|
||||||
|
|
||||||
@@ -79,6 +84,7 @@ object ViewUtils {
|
|||||||
// ! zh-CN (translated by SuperMonster003 on Jul 29, 2024):
|
// ! zh-CN (translated by SuperMonster003 on Jul 29, 2024):
|
||||||
// ! 在一些设备上无法正常获取结果.
|
// ! 在一些设备上无法正常获取结果.
|
||||||
// ! 参阅: https://github.com/hyb1996/Auto.js/issues/268
|
// ! 参阅: https://github.com/hyb1996/Auto.js/issues/268
|
||||||
|
@SuppressLint("InternalInsetResource", "DiscouragedApi")
|
||||||
fun getStatusBarHeightLegacy(context: Context): Int {
|
fun getStatusBarHeightLegacy(context: Context): Int {
|
||||||
return context.resources.getIdentifier("status_bar_height", "dimen", "android").let { resourceId ->
|
return context.resources.getIdentifier("status_bar_height", "dimen", "android").let { resourceId ->
|
||||||
when (resourceId > 0) {
|
when (resourceId > 0) {
|
||||||
@@ -141,6 +147,32 @@ object ViewUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun hasSystemUiVisibility(activity: Activity, flags: Int): Boolean {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
return activity.window.decorView.systemUiVisibility and flags == flags
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun isStatusBarIconLight(activity: Activity): Boolean {
|
||||||
|
return !isStatusBarIconDark(activity)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun isStatusBarIconDark(activity: Activity): Boolean {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
return hasSystemUiVisibility(activity, View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
fun setStatusBarIconLight(activity: Activity, isLight: Boolean) {
|
||||||
|
when {
|
||||||
|
isStatusBarIconLight(activity) == isLight -> return
|
||||||
|
isLight -> removeSystemUiVisibility(activity, View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)
|
||||||
|
else -> appendSystemUiVisibility(activity, View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun appendWindowFlags(activity: Activity, flags: Int) {
|
private fun appendWindowFlags(activity: Activity, flags: Int) {
|
||||||
activity.window.addFlags(flags)
|
activity.window.addFlags(flags)
|
||||||
}
|
}
|
||||||
@@ -161,21 +193,14 @@ object ViewUtils {
|
|||||||
val isConfigTakenAsLight = !isConfigDark
|
val isConfigTakenAsLight = !isConfigDark
|
||||||
|
|
||||||
getWindowInsetsController(activity).apply {
|
getWindowInsetsController(activity).apply {
|
||||||
isAppearanceLightStatusBars = isConfigDark
|
isAppearanceLightStatusBars = isConfigTakenAsLight
|
||||||
isAppearanceLightNavigationBars = isConfigTakenAsLight
|
isAppearanceLightNavigationBars = isConfigTakenAsLight
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
activity.window.navigationBarColor = when {
|
fun isSystemDarkModeEnabled(context: Context): Boolean {
|
||||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.O && isConfigTakenAsLight -> {
|
val uiModeManager = context.getSystemService(Context.UI_MODE_SERVICE) as UiModeManager
|
||||||
// @Hint by SuperMonster003 on Sep 9, 2022.
|
return uiModeManager.nightMode == UiModeManager.MODE_NIGHT_YES
|
||||||
// ! On devices running with Android 7.x and with dark theme disabled,
|
|
||||||
// ! navigation bar would be white background with white buttons.
|
|
||||||
// ! zh-CN:
|
|
||||||
// ! 在安卓 7.x 设备, 暗色主题禁用时, 导航栏背景是白色, 上面的按钮也是白色.
|
|
||||||
activity.getColor(R.color.navigation_bar_background_before_android_o)
|
|
||||||
}
|
|
||||||
else -> Color.TRANSPARENT
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@@ -197,7 +222,7 @@ object ViewUtils {
|
|||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onConfigurationChanged(configuration: Configuration) {
|
fun onConfigurationChangedForNightMode(configuration: Configuration) {
|
||||||
if (isAutoNightModeEnabled) {
|
if (isAutoNightModeEnabled) {
|
||||||
val isNightModeYes = isNightModeYes(configuration)
|
val isNightModeYes = isNightModeYes(configuration)
|
||||||
if (isNightModeEnabled != isNightModeYes) {
|
if (isNightModeEnabled != isNightModeYes) {
|
||||||
@@ -213,15 +238,19 @@ object ViewUtils {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun setToolbarAsBack(activity: AppCompatActivity, title: String?) {
|
fun setToolbarAsBack(activity: AppCompatActivity, title: String?) {
|
||||||
activity.apply {
|
val toolbar = activity.findViewById<Toolbar>(R.id.toolbar)
|
||||||
findViewById<Toolbar>(R.id.toolbar).let { toolbar ->
|
toolbar.title = title
|
||||||
toolbar.title = title
|
activity.setSupportActionBar(toolbar)
|
||||||
setSupportActionBar(toolbar)
|
activity.supportActionBar?.let { actionBar ->
|
||||||
supportActionBar?.let { actionBar ->
|
toolbar.setNavigationOnClickListener { activity.finish() }
|
||||||
toolbar.setNavigationOnClickListener { finish() }
|
actionBar.setDisplayHomeAsUpEnabled(true)
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true)
|
}
|
||||||
}
|
toolbar.navigationIcon?.let { navigationIcon ->
|
||||||
}
|
val navigationIconColor = when {
|
||||||
|
ThemeColorManager.isThemeColorLuminanceLight() -> R.color.day
|
||||||
|
else -> R.color.night
|
||||||
|
}.let { activity.resources.getColor(it, null) }
|
||||||
|
navigationIcon.colorFilter = PorterDuffColorFilter(navigationIconColor, PorterDuff.Mode.SRC_IN)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,14 +326,6 @@ object ViewUtils {
|
|||||||
isKeepScreenOnWhenInForegroundEnabled = true
|
isKeepScreenOnWhenInForegroundEnabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
fun registerOnSharedPreferenceChangeListener(activity: Activity) {
|
|
||||||
Pref.registerOnSharedPreferenceChangeListener { _, key ->
|
|
||||||
if (key == key(R.string.key_keep_screen_on_when_in_foreground)) {
|
|
||||||
configKeepScreenOnWhenInForeground(activity)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun configKeepScreenOnWhenInForeground(activity: Activity) {
|
fun configKeepScreenOnWhenInForeground(activity: Activity) {
|
||||||
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON.let { flags ->
|
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON.let { flags ->
|
||||||
if (isKeepScreenOnWhenInForegroundEnabled) {
|
if (isKeepScreenOnWhenInForegroundEnabled) {
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:theme="@style/AppTheme.AppBarOverlay">
|
android:theme="@style/AppTheme.AppBarOverlay"
|
||||||
|
android:fitsSystemWindows="true">
|
||||||
|
|
||||||
<org.autojs.autojs.theme.widget.ThemeColorToolbar
|
<org.autojs.autojs.theme.widget.ThemeColorToolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
@@ -17,9 +18,8 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?attr/actionBarSize"
|
||||||
android:background="?attr/colorPrimary"
|
android:background="?attr/colorPrimary"
|
||||||
app:popupTheme="@style/AppTheme.PopupOverlay">
|
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||||
|
|
||||||
</org.autojs.autojs.theme.widget.ThemeColorToolbar>
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -30,5 +30,6 @@
|
|||||||
android:scrollbars="vertical"
|
android:scrollbars="vertical"
|
||||||
android:textColor="@android:color/secondary_text_light"
|
android:textColor="@android:color/secondary_text_light"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
tools:text="@string/text_error"/>
|
tools:text="@string/text_error" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -1,46 +1,46 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:theme="@style/AppTheme.AppBarOverlay"
|
android:theme="@style/AppTheme.AppBarOverlay"
|
||||||
android:fitsSystemWindows="true">
|
android:fitsSystemWindows="true">
|
||||||
|
|
||||||
<org.autojs.autojs.theme.widget.ThemeColorToolbar
|
<org.autojs.autojs.theme.widget.ThemeColorToolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?attr/actionBarSize"
|
||||||
android:background="?attr/colorPrimary"
|
android:background="?attr/colorPrimary"
|
||||||
android:theme="@style/ToolBarStyle"
|
android:theme="@style/ToolBarStyle"
|
||||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:paddingStart="4dp"
|
android:paddingStart="4dp"
|
||||||
android:paddingEnd="2dp">
|
android:paddingEnd="2dp">
|
||||||
|
|
||||||
<org.autojs.autojs.core.console.ConsoleView
|
<org.autojs.autojs.core.console.ConsoleView
|
||||||
android:id="@+id/console"
|
android:id="@+id/console"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
<org.autojs.autojs.theme.widget.ThemeColorFloatingActionButton
|
<org.autojs.autojs.theme.widget.ThemeColorFloatingActionButton
|
||||||
android:id="@+id/fab"
|
android:id="@+id/fab"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom|end"
|
android:layout_gravity="bottom|end"
|
||||||
android:layout_margin="@dimen/fab_margin"
|
android:layout_margin="@dimen/fab_margin"
|
||||||
app:srcCompat="@drawable/ic_clear_white_48dp"
|
app:srcCompat="@drawable/ic_clear_white_48dp"
|
||||||
app:backgroundTint="?attr/colorPrimary"
|
app:backgroundTint="?attr/colorPrimary"
|
||||||
android:tint="@color/toolbar_text" />
|
android:tint="@color/toolbar_text" />
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.drawerlayout.widget.DrawerLayout
|
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/drawer_layout"
|
android:id="@+id/drawer_layout"
|
||||||
@@ -37,10 +36,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:tabGravity="fill"
|
app:tabGravity="fill"
|
||||||
app:tabMaxWidth="0dp"
|
app:tabMaxWidth="0dp"
|
||||||
app:tabIndicatorColor="@color/tab_indicator"
|
app:tabMode="fixed" />
|
||||||
app:tabMode="fixed"
|
|
||||||
app:tabSelectedTextColor="@color/tab_selected_text"
|
|
||||||
app:tabTextColor="@color/tab_text" />
|
|
||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
@@ -57,7 +53,6 @@
|
|||||||
android:layout_gravity="end|bottom"
|
android:layout_gravity="end|bottom"
|
||||||
android:layout_margin="16dp"
|
android:layout_margin="16dp"
|
||||||
android:src="@drawable/ic_add_white_48dp"
|
android:src="@drawable/ic_add_white_48dp"
|
||||||
android:tint="@color/toolbar_text"
|
|
||||||
app:backgroundTint="?attr/colorPrimary"
|
app:backgroundTint="?attr/colorPrimary"
|
||||||
app:layout_anchor="@id/viewpager"
|
app:layout_anchor="@id/viewpager"
|
||||||
app:layout_anchorGravity="bottom|end"
|
app:layout_anchorGravity="bottom|end"
|
||||||
@@ -84,7 +79,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="start"
|
android:layout_gravity="start"
|
||||||
android:fitsSystemWindows="false"
|
android:fitsSystemWindows="true"
|
||||||
tools:layout="@layout/fragment_drawer" />
|
tools:layout="@layout/fragment_drawer" />
|
||||||
|
|
||||||
</androidx.drawerlayout.widget.DrawerLayout>
|
</androidx.drawerlayout.widget.DrawerLayout>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fitsSystemWindows="true"
|
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="128dp"
|
||||||
android:layout_height="128dp"
|
android:layout_gravity="center|bottom"
|
||||||
android:layout_gravity="center|bottom"
|
android:gravity="center"
|
||||||
android:gravity="center"
|
android:fitsSystemWindows="true"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/logo"
|
android:id="@+id/logo"
|
||||||
android:layout_width="72dp"
|
android:layout_width="72dp"
|
||||||
android:layout_height="72dp"
|
android:layout_height="72dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:src="@drawable/autojs6_material" />
|
android:src="@drawable/autojs6_material" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
android:layout_height="32dp"
|
android:layout_height="32dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_marginTop="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:layout_marginStart="2dp"
|
android:layout_marginStart="2dp"
|
||||||
android:src="@drawable/autojs6" />
|
android:src="@drawable/autojs6" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="?android:windowBackground"
|
android:background="?android:windowBackground"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:fitsSystemWindows="false"
|
android:fitsSystemWindows="true"
|
||||||
android:importantForAccessibility="no"
|
android:importantForAccessibility="no"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:focusable="true">
|
android:focusable="true">
|
||||||
|
|||||||
@@ -1,42 +1,42 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<io.codetail.widget.RevealFrameLayout
|
<io.codetail.widget.RevealFrameLayout
|
||||||
android:id="@+id/appBarContainer"
|
android:id="@+id/appBarContainer"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:id="@+id/appBar"
|
android:id="@+id/appBar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:theme="@style/MtAppTheme.AppBarOverlay"
|
android:theme="@style/MtAppTheme.AppBarOverlay"
|
||||||
android:clipToPadding="true"
|
android:clipToPadding="true"
|
||||||
android:fitsSystemWindows="true">
|
android:fitsSystemWindows="true">
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
<androidx.appcompat.widget.Toolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?attr/actionBarSize"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:theme="@style/ToolBarStyle"
|
android:theme="@style/ToolBarStyle"
|
||||||
app:contentInsetStartWithNavigation="@dimen/toolbar_content_inset_start_with_navigation"
|
app:contentInsetStartWithNavigation="@dimen/toolbar_content_inset_start_with_navigation"
|
||||||
app:popupTheme="@style/MtAppTheme.PopupOverlay"
|
app:popupTheme="@style/MtAppTheme.PopupOverlay"
|
||||||
tools:title="@string/text_sample_string" />
|
tools:title="@string/text_sample_string" />
|
||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
</io.codetail.widget.RevealFrameLayout>
|
</io.codetail.widget.RevealFrameLayout>
|
||||||
|
|
||||||
<view
|
<view
|
||||||
android:id="@+id/color_setting_recycler_view"
|
android:id="@+id/color_setting_recycler_view"
|
||||||
class="org.autojs.autojs.theme.app.ColorSelectActivity$Companion$ColorSettingRecyclerView"
|
class="org.autojs.autojs.theme.app.ColorSettingRecyclerView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -6,14 +6,12 @@
|
|||||||
android:id="@+id/action_log"
|
android:id="@+id/action_log"
|
||||||
android:icon="@drawable/ic_ali_log"
|
android:icon="@drawable/ic_ali_log"
|
||||||
android:title="@string/text_log"
|
android:title="@string/text_log"
|
||||||
android:iconTint="@color/toolbar_text"
|
|
||||||
app:showAsAction="ifRoom" />
|
app:showAsAction="ifRoom" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_search"
|
android:id="@+id/action_search"
|
||||||
android:icon="@drawable/ic_search_white_36dp"
|
android:icon="@drawable/ic_search_white_36dp"
|
||||||
android:title="@string/text_search"
|
android:title="@string/text_search"
|
||||||
android:iconTint="@color/toolbar_text"
|
|
||||||
android:imeOptions="actionSearch"
|
android:imeOptions="actionSearch"
|
||||||
android:inputType="text"
|
android:inputType="text"
|
||||||
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<color name="day_night">#DEBFBFBF</color>
|
<color name="day_night">@color/dusk</color>
|
||||||
<color name="day_night_full">#BFBFBF</color>
|
<color name="day_night_full">@color/dusk_full</color>
|
||||||
<color name="day_night_alpha_70">#B3BFBFBF</color>
|
<color name="day_night_alpha_70">#B3BFBFBF</color>
|
||||||
<color name="day_night_alpha_30">#4DBFBFBF</color>
|
<color name="day_night_alpha_30">#4DBFBFBF</color>
|
||||||
<color name="day_night_alpha_20">#33BFBFBF</color>
|
<color name="day_night_alpha_20">#33BFBFBF</color>
|
||||||
<color name="night_day">#DE252525</color>
|
<color name="night_day">@color/dawn</color>
|
||||||
<color name="night_day_full">#252525</color>
|
<color name="night_day_full">@color/dawn_full</color>
|
||||||
<color name="window_background">#212121</color>
|
<color name="window_background">@color/day_full</color>
|
||||||
<color name="window_background_selected">#3B3B3B</color>
|
<color name="window_background_selected">#3B3B3B</color>
|
||||||
<color name="text_color_primary">@color/day_night</color>
|
<color name="text_color_primary">@color/day_night</color>
|
||||||
<color name="text_color_primary_full">@color/day_night_full</color>
|
<color name="text_color_primary_full">@color/day_night_full</color>
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
<color name="dialog_button_failure">@color/dialog_button_error</color>
|
<color name="dialog_button_failure">@color/dialog_button_error</color>
|
||||||
|
|
||||||
<color name="item_background">#333333</color>
|
<color name="item_background">#333333</color>
|
||||||
<color name="item_background_dark">#252525</color>
|
<color name="item_background_dark">@color/dawn_full</color>
|
||||||
|
|
||||||
<color name="divider">#191919</color>
|
<color name="divider">#191919</color>
|
||||||
<color name="divider_functions_keyboard">#303030</color>
|
<color name="divider_functions_keyboard">#303030</color>
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
<color name="project_toolbar_button">#A9AAAB</color>
|
<color name="project_toolbar_button">#A9AAAB</color>
|
||||||
<color name="project_toolbar_title">#A9AAAB</color>
|
<color name="project_toolbar_title">#A9AAAB</color>
|
||||||
|
|
||||||
<color name="layout_window_bubble_bg">#DE212121</color>
|
<color name="layout_window_bubble_bg">@color/day</color>
|
||||||
<color name="layout_hierarchy_window_node_bounds">#FF6659</color>
|
<color name="layout_hierarchy_window_node_bounds">#FF6659</color>
|
||||||
<color name="layout_node_info_view_decoration_line">#1BF5F5F5</color>
|
<color name="layout_node_info_view_decoration_line">#1BF5F5F5</color>
|
||||||
<color name="layout_hierarchy_window_background">#CC102027</color>
|
<color name="layout_hierarchy_window_background">#CC102027</color>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
<item name="windowNoTitle">true</item>
|
<item name="windowNoTitle">true</item>
|
||||||
<item name="windowActionBar">false</item>
|
<item name="windowActionBar">false</item>
|
||||||
<item name="android:windowBackground">@color/window_background</item>
|
<item name="android:windowBackground">@color/window_background</item>
|
||||||
|
<item name="android:navigationBarColor">@color/window_background</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<resources>
|
|
||||||
|
|
||||||
<style name="AppTheme.FullScreen" parent="AppTheme">
|
|
||||||
<item name="windowNoTitle">true</item>
|
|
||||||
<item name="windowActionBar">false</item>
|
|
||||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
|
||||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
</resources>
|
|
||||||
@@ -1,13 +1,21 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<color name="day_night">#DE212121</color>
|
<color name="day">#DE212121</color>
|
||||||
<color name="day_night_full">#212121</color>
|
<color name="day_full">#212121</color>
|
||||||
|
<color name="night">#DEFBFBFB</color>
|
||||||
|
<color name="night_full">#FBFBFB</color>
|
||||||
|
<color name="dawn">#DE252525</color>
|
||||||
|
<color name="dawn_full">#252525</color>
|
||||||
|
<color name="dusk">#DEBFBFBF</color>
|
||||||
|
<color name="dusk_full">#BFBFBF</color>
|
||||||
|
<color name="day_night">@color/day</color>
|
||||||
|
<color name="day_night_full">@color/day_full</color>
|
||||||
<color name="day_night_alpha_70">#B3212121</color>
|
<color name="day_night_alpha_70">#B3212121</color>
|
||||||
<color name="day_night_alpha_30">#4D212121</color>
|
<color name="day_night_alpha_30">#4D212121</color>
|
||||||
<color name="day_night_alpha_20">#33212121</color>
|
<color name="day_night_alpha_20">#33212121</color>
|
||||||
<color name="night_day">#DEFBFBFB</color>
|
<color name="night_day">@color/night</color>
|
||||||
<color name="night_day_full">#FBFBFB</color>
|
<color name="night_day_full">@color/night_full</color>
|
||||||
<color name="window_background">#FFFFFF</color>
|
<color name="window_background">#FFFFFF</color>
|
||||||
<color name="window_background_selected">#E5E5E5</color>
|
<color name="window_background_selected">#E5E5E5</color>
|
||||||
<color name="text_color_primary">@color/day_night</color>
|
<color name="text_color_primary">@color/day_night</color>
|
||||||
@@ -112,10 +120,18 @@
|
|||||||
<color name="market_button_unselected">#939393</color>
|
<color name="market_button_unselected">#939393</color>
|
||||||
|
|
||||||
<color name="tab_indicator">#A0FFFFFF</color>
|
<color name="tab_indicator">#A0FFFFFF</color>
|
||||||
|
<color name="tab_indicator_light">#A0FFFFFF</color>
|
||||||
|
<color name="tab_indicator_dark">#80202020</color>
|
||||||
<color name="tab_text">#A0FFFFFF</color>
|
<color name="tab_text">#A0FFFFFF</color>
|
||||||
|
<color name="tab_text_light">#A0FFFFFF</color>
|
||||||
|
<color name="tab_text_dark">#A0202020</color>
|
||||||
<color name="tab_selected_text">#FFFFFF</color>
|
<color name="tab_selected_text">#FFFFFF</color>
|
||||||
|
<color name="tab_selected_text_light">#FFFFFF</color>
|
||||||
|
<color name="tab_selected_text_dark">#111214</color>
|
||||||
|
|
||||||
<color name="toolbar_text">@color/night_day</color>
|
<color name="toolbar_text">@color/night_day</color>
|
||||||
|
<color name="fab_tint_light">@color/night</color>
|
||||||
|
<color name="fab_tint_dark">@color/day</color>
|
||||||
<color name="toolbar_disabled">#6EE0E0E0</color>
|
<color name="toolbar_disabled">#6EE0E0E0</color>
|
||||||
|
|
||||||
<color name="prefTextColorPrimary">#282C2F</color>
|
<color name="prefTextColorPrimary">#282C2F</color>
|
||||||
@@ -135,7 +151,7 @@
|
|||||||
<color name="color_selector_item_text">#DE111214</color>
|
<color name="color_selector_item_text">#DE111214</color>
|
||||||
<color name="floating_action_menu_label_bg">#CCE0E0E0</color>
|
<color name="floating_action_menu_label_bg">#CCE0E0E0</color>
|
||||||
<color name="navigation_bar_background">@color/window_background</color>
|
<color name="navigation_bar_background">@color/window_background</color>
|
||||||
<color name="navigation_bar_background_before_android_o">#212121</color>
|
<color name="navigation_bar_background_before_android_o">@color/day_full</color>
|
||||||
<color name="swipe_refresh_background">#F8F8F8</color>
|
<color name="swipe_refresh_background">#F8F8F8</color>
|
||||||
<color name="circular_menu_icon_red">#ef5350</color>
|
<color name="circular_menu_icon_red">#ef5350</color>
|
||||||
<color name="circular_menu_icon_white">#ffffff</color>
|
<color name="circular_menu_icon_white">#ffffff</color>
|
||||||
|
|||||||
@@ -18,6 +18,11 @@
|
|||||||
<item name="actionOverflowMenuStyle">@style/OverflowMenu</item>
|
<item name="actionOverflowMenuStyle">@style/OverflowMenu</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="ToolBarStyleRaw" parent="ThemeOverlay.AppCompat.DayNight.ActionBar">
|
||||||
|
<item name="searchViewStyle">@style/SearchViewActionBar</item>
|
||||||
|
<item name="titleMarginStart">0dp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="ToolBarStyle" parent="ThemeOverlay.AppCompat.DayNight.ActionBar">
|
<style name="ToolBarStyle" parent="ThemeOverlay.AppCompat.DayNight.ActionBar">
|
||||||
<item name="searchViewStyle">@style/SearchViewActionBar</item>
|
<item name="searchViewStyle">@style/SearchViewActionBar</item>
|
||||||
<item name="android:textColorPrimary">@color/toolbar_text</item>
|
<item name="android:textColorPrimary">@color/toolbar_text</item>
|
||||||
@@ -48,12 +53,15 @@
|
|||||||
<style name="AppTheme.FullScreen" parent="AppTheme">
|
<style name="AppTheme.FullScreen" parent="AppTheme">
|
||||||
<item name="windowNoTitle">true</item>
|
<item name="windowNoTitle">true</item>
|
||||||
<item name="windowActionBar">false</item>
|
<item name="windowActionBar">false</item>
|
||||||
|
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||||
|
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="AppTheme.Splash" parent="@android:style/Theme.NoTitleBar.Fullscreen">
|
<style name="AppTheme.Splash" parent="@android:style/Theme.NoTitleBar.Fullscreen">
|
||||||
<item name="windowNoTitle">true</item>
|
<item name="windowNoTitle">true</item>
|
||||||
<item name="windowActionBar">false</item>
|
<item name="windowActionBar">false</item>
|
||||||
<item name="android:windowBackground">@color/window_background</item>
|
<item name="android:windowBackground">@color/window_background</item>
|
||||||
|
<item name="android:navigationBarColor">@color/window_background</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="AppTheme.Settings" parent="AppTheme">
|
<style name="AppTheme.Settings" parent="AppTheme">
|
||||||
@@ -91,7 +99,7 @@
|
|||||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.DayNight.ActionBar" />
|
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.DayNight.ActionBar" />
|
||||||
|
|
||||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.DayNight.ActionBar">
|
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.DayNight.ActionBar">
|
||||||
<item name="android:textColorPrimary">#212121</item>
|
<item name="android:textColorPrimary">@color/day_full</item>
|
||||||
<item name="android:textColorSecondary">@color/colorAccent</item>
|
<item name="android:textColorSecondary">@color/colorAccent</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
@@ -105,7 +113,7 @@
|
|||||||
<style name="MtAppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.DayNight.ActionBar" />
|
<style name="MtAppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.DayNight.ActionBar" />
|
||||||
|
|
||||||
<style name="MtAppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.DayNight.ActionBar">
|
<style name="MtAppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.DayNight.ActionBar">
|
||||||
<item name="android:textColorPrimary">#212121</item>
|
<item name="android:textColorPrimary">@color/day_full</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="ConsoleTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
<style name="ConsoleTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||||
@@ -138,6 +146,16 @@
|
|||||||
<item name="android:tint">@color/day_night</item>
|
<item name="android:tint">@color/day_night</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="PopupMenuThemeLight" parent="AppTheme.PopupOverlay">
|
||||||
|
<item name="android:textColor">@color/day</item>
|
||||||
|
<item name="android:tint">@color/day</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="PopupMenuThemeDark" parent="AppTheme.PopupOverlay">
|
||||||
|
<item name="android:textColor">@color/dusk</item>
|
||||||
|
<item name="android:tint">@color/dusk</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="SearchViewActionBar" parent="@style/Widget.AppCompat.SearchView.ActionBar" />
|
<style name="SearchViewActionBar" parent="@style/Widget.AppCompat.SearchView.ActionBar" />
|
||||||
|
|
||||||
<style name="Material3DarkTheme" parent="@style/Theme.Material3.Dark" />
|
<style name="Material3DarkTheme" parent="@style/Theme.Material3.Dark" />
|
||||||
|
|||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
#Tue Mar 04 14:52:06 CST 2025
|
#Sat Mar 08 23:16:11 CST 2025
|
||||||
BUILD_TIME=1741071126094
|
BUILD_TIME=1741446971737
|
||||||
COMPILE_SDK_VERSION=35
|
COMPILE_SDK_VERSION=35
|
||||||
JAVA_VERSION=23
|
JAVA_VERSION=23
|
||||||
JAVA_VERSION_MIN_RADICAL=0
|
JAVA_VERSION_MIN_RADICAL=0
|
||||||
@@ -17,6 +17,6 @@ RAPID_OCR_OPENCV_MOBILE_LABEL_VERSION=13
|
|||||||
RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3
|
RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3
|
||||||
TARGET_SDK_VERSION=35
|
TARGET_SDK_VERSION=35
|
||||||
TARGET_SDK_VERSION_INRT=29
|
TARGET_SDK_VERSION_INRT=29
|
||||||
VERSION_BUILD=2989
|
VERSION_BUILD=3001
|
||||||
VERSION_NAME=6.6.2 Alpha3
|
VERSION_NAME=6.6.2 Alpha3
|
||||||
VSCODE_EXT_REQUIRED_VERSION=1.0.8
|
VSCODE_EXT_REQUIRED_VERSION=1.0.8
|
||||||
Reference in new issue
Block a user