From c456b8eb46a03f5314f4331b821985e1ecfedbf4 Mon Sep 17 00:00:00 2001 From: SuperMonster003 Date: Sat, 29 Mar 2025 00:30:25 +0800 Subject: [PATCH] =?UTF-8?q?6.6.2=20-=20Alpha5=20-=20=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E8=89=B2=E8=AE=BE=E7=BD=AE=E9=A1=B5=E9=9D=A2=E6=96=B0=E5=B8=83?= =?UTF-8?q?=E5=B1=80=E6=94=AF=E6=8C=81=E5=AE=9A=E4=BD=8D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../theme/app/ColorLibrariesActivity.kt | 28 +-- .../autojs/theme/app/ColorLibraryActivity.kt | 160 +++++++++++++++++- .../theme/app/ColorSelectBaseActivity.kt | 66 +++++++- .../theme/app/ColorSettingRecyclerView.kt | 16 +- .../autojs/ui/widget/SearchViewItem.java | 6 + .../layout/mt_activity_color_libraries.xml | 5 +- .../res/layout/mt_activity_color_library.xml | 3 + version.properties | 6 +- 8 files changed, 241 insertions(+), 49 deletions(-) diff --git a/app/src/main/java/org/autojs/autojs/theme/app/ColorLibrariesActivity.kt b/app/src/main/java/org/autojs/autojs/theme/app/ColorLibrariesActivity.kt index 9cb5e567..223ba383 100644 --- a/app/src/main/java/org/autojs/autojs/theme/app/ColorLibrariesActivity.kt +++ b/app/src/main/java/org/autojs/autojs/theme/app/ColorLibrariesActivity.kt @@ -11,7 +11,6 @@ import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.TextView -import android.widget.Toast import androidx.appcompat.widget.SearchView import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager @@ -57,7 +56,7 @@ class ColorLibrariesActivity : ColorSelectBaseActivity() { it.layoutManager = LinearLayoutManager(this) it.adapter = ColorLibraryAdapter(colorLibraries) { library -> val intent = Intent(this, ColorLibraryActivity::class.java) - intent.putExtra("LIBRARY_ID", library.id) + intent.putExtra(INTENT_IDENTIFIER_LIBRARY_ID, library.id) startActivity(intent) }.also { mAdapter = it } it.addItemDecoration(DividerItemDecoration(this, VERTICAL)) @@ -98,10 +97,6 @@ class ColorLibrariesActivity : ColorSelectBaseActivity() { mAdapter.updateData(filteredLibraries) } - // 定位功能可以通过工具栏中的 "action_locate_current_theme_color" 按钮实现, - // 按钮点击后找到包含当前主题色的颜色库在列表中的位置, - // 然后调用 RecyclerView 的 scrollToPosition() 方法跳转到该项 - override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) { R.id.action_color_palette -> { showColorPicker() @@ -157,24 +152,15 @@ class ColorLibrariesActivity : ColorSelectBaseActivity() { private fun savePrefsForLegacy(color: Int) { Pref.putInt(KEY_CUSTOM_COLOR, color or -0x1000000) - Pref.putInt(KEY_SELECTED_COLOR_INDEX, customColorPosition) + Pref.putInt(KEY_LEGACY_SELECTED_COLOR_INDEX, customColorPosition) } - private fun locateCurrentThemeColor() { - // 假设当前主题颜色保存在 ThemeColorManager 中,可以通过它查找对应颜色库 - val currentColor = ThemeColorManager.colorPrimary - // 简单示例:遍历 colorLibraries,找到第一个包含该颜色的库 - val targetIndex = colorLibraries.indexOfFirst { library -> - library.colors.any { colorItem -> - getColor(colorItem.colorRes) == currentColor - } - } - if (targetIndex >= 0) { - val recyclerView: RecyclerView = findViewById(R.id.color_libraries_recycler_view) - recyclerView.smoothScrollToPosition(targetIndex) - } else { - Toast.makeText(this, "未找到当前颜色所在的颜色库", Toast.LENGTH_SHORT).show() + checkAndGetTargetInfoForThemeColorLocate()?.let { target -> + Intent(this, ColorLibraryActivity::class.java).apply { + putExtra(INTENT_IDENTIFIER_LIBRARY_ID, target.libraryId) + putExtra(INTENT_IDENTIFIER_COLOR_ITEM_ID_SCROLL_TO, target.libraryItemId) + }.let { startActivity(it) } } } diff --git a/app/src/main/java/org/autojs/autojs/theme/app/ColorLibraryActivity.kt b/app/src/main/java/org/autojs/autojs/theme/app/ColorLibraryActivity.kt index 4064c7df..c1c70235 100644 --- a/app/src/main/java/org/autojs/autojs/theme/app/ColorLibraryActivity.kt +++ b/app/src/main/java/org/autojs/autojs/theme/app/ColorLibraryActivity.kt @@ -1,7 +1,13 @@ package org.autojs.autojs.theme.app +import android.animation.Animator +import android.animation.AnimatorListenerAdapter +import android.animation.ArgbEvaluator +import android.animation.ValueAnimator import android.annotation.SuppressLint +import android.content.Intent import android.content.res.ColorStateList +import android.graphics.drawable.ColorDrawable import android.os.Bundle import android.view.LayoutInflater import android.view.Menu @@ -14,8 +20,10 @@ import androidx.annotation.ColorInt import androidx.appcompat.widget.SearchView import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.LinearSmoothScroller import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView.VERTICAL +import androidx.recyclerview.widget.ThemeColorRecyclerView import org.autojs.autojs.core.image.ColorItems import org.autojs.autojs.core.pref.Pref import org.autojs.autojs.theme.ThemeChangeNotifier @@ -26,10 +34,14 @@ import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.COLOR_LIBRAR import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.ColorItem import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.ColorLibrary import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.colorLibraries +import org.autojs.autojs.util.ColorUtils import org.autojs.autojs.util.ViewUtils +import org.autojs.autojs.util.ViewUtils.onceGlobalLayout import org.autojs.autojs.util.ViewUtils.setMenuIconsColorByColorLuminance import org.autojs.autojs6.R import org.autojs.autojs6.databinding.MtActivityColorLibraryBinding +import kotlin.properties.Delegates +import androidx.core.graphics.ColorUtils as AndroidColorUtils @SuppressLint("NotifyDataSetChanged") class ColorLibraryActivity : ColorSelectBaseActivity() { @@ -39,17 +51,21 @@ class ColorLibraryActivity : ColorSelectBaseActivity() { private lateinit var mAdapter: ColorItemAdapter private lateinit var mLibrary: ColorLibrary + private var mInitiallyIdScrollTo by Delegates.notNull() + private var mSelectedPosition = SELECT_NONE private var mSelectedColor: Int? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - val libraryId = intent.getIntExtra("LIBRARY_ID", -1) + val libraryId = intent.getIntExtra(INTENT_IDENTIFIER_LIBRARY_ID, -1) val library = colorLibraries.find { it.id == libraryId }?.also { lib -> mLibrary = lib } ?: throw RuntimeException("Unknown library id: $libraryId") + mInitiallyIdScrollTo = intent.getIntExtra(INTENT_IDENTIFIER_COLOR_ITEM_ID_SCROLL_TO, -1) + MtActivityColorLibraryBinding.inflate(layoutInflater).let { binding = it setContentView(it.root) @@ -91,15 +107,21 @@ class ColorLibraryActivity : ColorSelectBaseActivity() { ThemeColorManager.setThemeColor(selectedColor) ThemeChangeNotifier.notifyThemeChanged() }.also { mAdapter = it } + it.addItemDecoration(DividerItemDecoration(this, VERTICAL)) ViewUtils.excludePaddingClippableViewFromNavigationBar(it) + setUpSelectedPosition() + + it.onceGlobalLayout { + scrollToPositionOnceIfNeeded(it) + } } } private fun setUpSelectedPosition() { when (Pref.getInt(KEY_SELECTED_COLOR_LIBRARY_ID, SELECT_NONE)) { - SELECT_NONE -> when (val legacyIndex = Pref.getInt(KEY_SELECTED_COLOR_INDEX, SELECT_NONE)) { + SELECT_NONE -> when (val legacyIndex = Pref.getInt(KEY_LEGACY_SELECTED_COLOR_INDEX, SELECT_NONE)) { customColorPosition -> Unit SELECT_NONE, defaultColorPosition -> when (mLibrary.id) { COLOR_LIBRARY_DEFAULT_COLORS_ID -> { @@ -122,6 +144,91 @@ class ColorLibraryActivity : ColorSelectBaseActivity() { } } + private fun scrollToPositionOnceIfNeeded(recyclerView: ThemeColorRecyclerView) { + if (mInitiallyIdScrollTo < 0) return + val targetPosition = mLibrary.colors.indexOfFirst { it.id == mInitiallyIdScrollTo } + if (targetPosition < 0) { + mInitiallyIdScrollTo = -1 + return + } + val targetItem = mLibrary.colors[targetPosition] + + if (recyclerView.findViewHolderForAdapterPosition(targetPosition) != null) { + highlightColorItem(recyclerView, targetPosition, targetItem) + } else { + recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() { + override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { + if (newState == RecyclerView.SCROLL_STATE_IDLE) { + recyclerView.removeOnScrollListener(this) + highlightColorItem(recyclerView, targetPosition, targetItem) + } + } + }) + } + + val layoutManager = recyclerView.layoutManager as? LinearLayoutManager + layoutManager?.let { manager -> + val smoothScroller = object : LinearSmoothScroller(this) { + override fun getVerticalSnapPreference() = SNAP_TO_START + }.apply { this.targetPosition = targetPosition } + manager.startSmoothScroll(smoothScroller) + } ?: recyclerView.smoothScrollToPosition(targetPosition) + + mInitiallyIdScrollTo = -1 + } + + private fun highlightColorItem(recyclerView: RecyclerView, targetPosition: Int, targetItem: ColorItem) { + val viewHolder = recyclerView.findViewHolderForAdapterPosition(targetPosition) + viewHolder?.itemView?.let { itemView -> + val originalColor = (itemView.background as? ColorDrawable)?.color ?: getColor(R.color.window_background) + + val highlightColor = ColorUtils.adjustColorForContrast( + originalColor, getColor(targetItem.colorRes), 1.6, + ) + + when (val tag = itemView.tag) { + !is ValueAnimator -> { + startAnimateForSetBackgroundColor(itemView, originalColor, highlightColor, 300, true) + } + else -> tag.cancel() + } + } + } + + private fun startAnimateForSetBackgroundColor(view: View, fromColor: Int, toColor: Int, duration: Long, reverse: Boolean = false) { + val alpha = 0.3 + val animator = ValueAnimator.ofObject( + ArgbEvaluator(), + fromColor.let { AndroidColorUtils.setAlphaComponent(it, (alpha * 255).toInt()) }, + toColor.let { AndroidColorUtils.setAlphaComponent(it, (alpha * 255).toInt()) }, + ) + animator.duration = duration + animator.addUpdateListener { animation -> + val animatedValue = animation.animatedValue as Int + view.setBackgroundColor(animatedValue) + } + animator.addListener(object : AnimatorListenerAdapter() { + override fun onAnimationEnd(animation: Animator) { + if (reverse) { + view.postDelayed({ + if (view.tag == null) return@postDelayed + startAnimateForSetBackgroundColor(view, toColor, fromColor, 1300) + }, 1000) + } else { + view.tag = null + } + } + + override fun onAnimationCancel(animation: Animator) { + view.tag = null + view.setBackgroundColor(getColor(R.color.window_background)) + } + }) + view.tag = animator + + animator.start() + } + private fun savePrefsForLibraries(library: ColorLibrary?, colorItem: ColorItem) { Pref.putInt(KEY_SELECTED_COLOR_LIBRARY_ID, library?.id ?: -1) Pref.putInt(KEY_SELECTED_COLOR_LIBRARY_ITEM_ID, colorItem.id) @@ -131,25 +238,25 @@ class ColorLibraryActivity : ColorSelectBaseActivity() { when (library?.id) { COLOR_LIBRARY_DEFAULT_COLORS_ID -> { if (getColor(colorItem.colorRes) == getColor(R.color.theme_color_default)) { - Pref.putInt(KEY_SELECTED_COLOR_INDEX, defaultColorPosition) + Pref.putInt(KEY_LEGACY_SELECTED_COLOR_INDEX, defaultColorPosition) } else { - Pref.putInt(KEY_SELECTED_COLOR_INDEX, SELECT_NONE) + Pref.putInt(KEY_LEGACY_SELECTED_COLOR_INDEX, SELECT_NONE) } } COLOR_LIBRARY_MATERIAL_COLORS_ID -> { val index = colorItem.id if (index !in ColorItems.MATERIAL_COLORS.indices) { - Pref.putInt(KEY_SELECTED_COLOR_INDEX, SELECT_NONE) + Pref.putInt(KEY_LEGACY_SELECTED_COLOR_INDEX, SELECT_NONE) } else { val fixedIndex = maxOf( defaultColorPosition, customColorPosition, ) + 1 + index - Pref.putInt(KEY_SELECTED_COLOR_INDEX, fixedIndex) + Pref.putInt(KEY_LEGACY_SELECTED_COLOR_INDEX, fixedIndex) } } else -> { - Pref.putInt(KEY_SELECTED_COLOR_INDEX, SELECT_NONE) + Pref.putInt(KEY_LEGACY_SELECTED_COLOR_INDEX, SELECT_NONE) } } } @@ -196,12 +303,40 @@ class ColorLibraryActivity : ColorSelectBaseActivity() { true } R.id.action_locate_current_theme_color -> { - // locateCurrentColorLibrary() + locateCurrentThemeColor() true } else -> super.onOptionsItemSelected(item) } + private fun locateCurrentThemeColor() { + val target = checkAndGetTargetInfoForThemeColorLocate() ?: return + val targetLibraryId = target.libraryId + val targetIndex = target.libraryItemId + when (targetLibraryId) { + mLibrary.id -> { + val recyclerView = binding.colorLibraryRecyclerView + val viewHolder = recyclerView.findViewHolderForAdapterPosition(targetIndex) + + viewHolder?.itemView?.let { itemView -> + (itemView.tag as? ValueAnimator)?.cancel() + itemView.setBackgroundColor(getColor(R.color.window_background)) + } + + mInitiallyIdScrollTo = targetIndex + scrollToPositionOnceIfNeeded(recyclerView) + } + else -> { + val intent = Intent(this, ColorLibraryActivity::class.java).apply { + putExtra(INTENT_IDENTIFIER_LIBRARY_ID, targetLibraryId) + putExtra(INTENT_IDENTIFIER_COLOR_ITEM_ID_SCROLL_TO, targetIndex) + } + startActivity(intent) + this.finish() + } + } + } + inner class ColorItemAdapter( private var items: List, private val onItemClick: (ColorItem, View) -> Unit, @@ -220,6 +355,15 @@ class ColorLibraryActivity : ColorSelectBaseActivity() { override fun onBindViewHolder(holder: ColorViewHolder, position: Int) { val item = items[position] + + when (val tag = holder.itemView.tag) { + is ValueAnimator -> { + tag.cancel() + holder.itemView.tag = null + holder.itemView.setBackgroundColor(getColor(R.color.window_background)) + } + } + holder.bind(item, position) holder.itemView.setOnClickListener { onItemClick(item, holder.itemView) } } diff --git a/app/src/main/java/org/autojs/autojs/theme/app/ColorSelectBaseActivity.kt b/app/src/main/java/org/autojs/autojs/theme/app/ColorSelectBaseActivity.kt index fe97f2d6..797366d7 100644 --- a/app/src/main/java/org/autojs/autojs/theme/app/ColorSelectBaseActivity.kt +++ b/app/src/main/java/org/autojs/autojs/theme/app/ColorSelectBaseActivity.kt @@ -9,6 +9,7 @@ import android.view.ViewAnimationUtils import androidx.appcompat.widget.Toolbar import com.google.android.material.appbar.AppBarLayout import io.codetail.widget.RevealFrameLayout +import org.autojs.autojs.annotation.ReservedForCompatibility import org.autojs.autojs.core.image.ColorItems import org.autojs.autojs.core.pref.Pref import org.autojs.autojs.theme.ThemeColorManager @@ -107,18 +108,67 @@ abstract class ColorSelectBaseActivity : BaseActivity() { mAppBarContainer = appBarContainer } + protected fun checkAndGetTargetInfoForThemeColorLocate(): TargetInfoForLocate? { + val targetLibraryId = Pref.getInt(KEY_SELECTED_COLOR_LIBRARY_ID, -1) + if (targetLibraryId == COLOR_LIBRARY_CUSTOM_COLOR_ID) { + ViewUtils.showToast(this, "当前主题色为自定义颜色", true) + // 提示 + // 当前主题色为自定义颜色 + // + // HEX: #FF3300 + // RGB: 255, 0, 0 + // HSL: 0, 0, 0.14 + // + // 使用调色盘可查看或修改自定义主题颜色 + // 调色盘 关闭 + return null + } + val targetLibrary = colorLibraries.find { it.id == targetLibraryId } + if (targetLibrary == null) { + ViewUtils.showToast(this, "主题色库定位失败", true) + // 定位失败 + // 无法定位主题色所在颜色库 + // + // Target lib ID: targetLibraryId + // Color libs IDs: [ colorLibraries.sorted().joinToString(", ") { "${it.id}" } ] + // 复制信息 关闭 + return null + } + val targetIndex = Pref.getInt(KEY_SELECTED_COLOR_LIBRARY_ITEM_ID, -1) + if (targetIndex !in targetLibrary.colors.indices) { + ViewUtils.showToast(this, "主题色条目定位失败", true) + // 定位失败 + // 无法确定主题色条目的索引值 + // + // Target index: targetLibraryId + // Color indicies: [ 0..90 ] (注意 90 为 size - 1) + // 复制信息 关闭 + return null + } + return TargetInfoForLocate(targetLibraryId, targetIndex) + } + interface OnItemClickListener { fun onItemClick(v: View?, position: Int) } + data class TargetInfoForLocate(val libraryId: Int, val libraryItemId: Int) + companion object { const val SELECT_NONE = -1 - val KEY_CUSTOM_COLOR = "${ColorSettingRecyclerView::class.java.name}.COLOR_SETTING_CUSTOM_COLOR" - val KEY_SELECTED_COLOR_INDEX = "${ColorSettingRecyclerView::class.java.name}.SELECTED_COLOR_INDEX" - val KEY_SELECTED_COLOR_LIBRARY_ID = "${ColorSettingRecyclerView::class.java.name}.SELECTED_COLOR_LIBRARY_ID" - val KEY_SELECTED_COLOR_LIBRARY_ITEM_ID = "${ColorSettingRecyclerView::class.java.name}.SELECTED_COLOR_LIBRARY_ITEM_ID" + @ReservedForCompatibility + const val KEY_CUSTOM_COLOR = "org.autojs.autojs.theme.app.ColorSettingRecyclerView.COLOR_SETTING_CUSTOM_COLOR" + + @ReservedForCompatibility + const val KEY_LEGACY_SELECTED_COLOR_INDEX = "org.autojs.autojs.theme.app.ColorSettingRecyclerView.SELECTED_COLOR_INDEX" + + const val KEY_SELECTED_COLOR_LIBRARY_ID = "SELECTED_COLOR_LIBRARY_ID" + const val KEY_SELECTED_COLOR_LIBRARY_ITEM_ID = "SELECTED_COLOR_LIBRARY_ITEM_ID" + + const val INTENT_IDENTIFIER_LIBRARY_ID = "LIBRARY_ID" + const val INTENT_IDENTIFIER_COLOR_ITEM_ID_SCROLL_TO = "INTENT_IDENTIFIER_COLOR_ITEM_ID_SCROLL_TO" val customColorPosition: Int get() = /* return mColors.size() - 1; */ 0 @@ -130,7 +180,7 @@ abstract class ColorSelectBaseActivity : BaseActivity() { get() = Pref.getBoolean(R.string.key_color_select_activity_legacy_layout, false) set(value) = Pref.putBoolean(R.string.key_color_select_activity_legacy_layout, value) - val colorItems by lazy { + val colorItemsLegacy by lazy { mutableListOf>().apply { add(customColorPosition, R.color.custom_color_default to R.string.mt_custom) add(defaultColorPosition, R.color.theme_color_default to R.string.theme_color_default) @@ -160,13 +210,13 @@ abstract class ColorSelectBaseActivity : BaseActivity() { @JvmStatic fun getCurrentColorSummary(context: Context, isBrief: Boolean = false): String = when { - isLegacyLayout -> when (val index = Pref.getInt(KEY_SELECTED_COLOR_INDEX, defaultColorPosition)) { + isLegacyLayout -> when (val index = Pref.getInt(KEY_LEGACY_SELECTED_COLOR_INDEX, defaultColorPosition)) { SELECT_NONE -> { val colorInt = ThemeColorManager.colorPrimary ColorUtils.toString(colorInt).uppercase() } else -> { - val colorItem = colorItems[index] + val colorItem = colorItemsLegacy[index] val (colorRes, nameRes) = colorItem val name = context.getString(nameRes) val colorInt = when (index) { @@ -187,7 +237,7 @@ abstract class ColorSelectBaseActivity : BaseActivity() { identifier = context.getString(R.string.mt_custom) } SELECT_NONE -> { - val legacyIndex = Pref.getInt(KEY_SELECTED_COLOR_INDEX, SELECT_NONE) + val legacyIndex = Pref.getInt(KEY_LEGACY_SELECTED_COLOR_INDEX, SELECT_NONE) when (legacyIndex) { customColorPosition -> identifier = context.getString(R.string.color_library_identifier_custom) SELECT_NONE, defaultColorPosition -> identifier = context.getString(R.string.color_library_identifier_default_colors) diff --git a/app/src/main/java/org/autojs/autojs/theme/app/ColorSettingRecyclerView.kt b/app/src/main/java/org/autojs/autojs/theme/app/ColorSettingRecyclerView.kt index 956f8208..99200df8 100644 --- a/app/src/main/java/org/autojs/autojs/theme/app/ColorSettingRecyclerView.kt +++ b/app/src/main/java/org/autojs/autojs/theme/app/ColorSettingRecyclerView.kt @@ -24,11 +24,11 @@ import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.COLOR_LIBRAR import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.COLOR_LIBRARY_DEFAULT_COLORS_ID import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.COLOR_LIBRARY_MATERIAL_COLORS_ID import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.colorLibraries -import org.autojs.autojs.theme.app.ColorSelectBaseActivity.Companion.KEY_SELECTED_COLOR_INDEX +import org.autojs.autojs.theme.app.ColorSelectBaseActivity.Companion.KEY_LEGACY_SELECTED_COLOR_INDEX import org.autojs.autojs.theme.app.ColorSelectBaseActivity.Companion.KEY_SELECTED_COLOR_LIBRARY_ID import org.autojs.autojs.theme.app.ColorSelectBaseActivity.Companion.KEY_SELECTED_COLOR_LIBRARY_ITEM_ID import org.autojs.autojs.theme.app.ColorSelectBaseActivity.Companion.SELECT_NONE -import org.autojs.autojs.theme.app.ColorSelectBaseActivity.Companion.colorItems +import org.autojs.autojs.theme.app.ColorSelectBaseActivity.Companion.colorItemsLegacy import org.autojs.autojs.theme.app.ColorSelectBaseActivity.Companion.customColorPosition import org.autojs.autojs.theme.app.ColorSelectBaseActivity.Companion.defaultColorPosition import org.autojs.autojs.util.ViewUtils @@ -50,7 +50,7 @@ class ColorSettingRecyclerView : ThemeColorRecyclerView { get() = when { mSelectedPosition < 0 -> null mSelectedPosition == customColorPosition -> customColor - else -> context.getColor(colorItems[mSelectedPosition].first) + else -> context.getColor(colorItemsLegacy[mSelectedPosition].first) }?.let { ThemeColor(it) } private val customColor: Int @@ -93,7 +93,7 @@ class ColorSettingRecyclerView : ThemeColorRecyclerView { } private fun savePrefsForLegacy() { - Pref.putInt(KEY_SELECTED_COLOR_INDEX, mSelectedPosition) + Pref.putInt(KEY_LEGACY_SELECTED_COLOR_INDEX, mSelectedPosition) } private fun savePrefsForLibraries() { @@ -122,8 +122,8 @@ class ColorSettingRecyclerView : ThemeColorRecyclerView { } fun setUpSelectedPosition(currentColor: Int) { - val selectedIndex = Pref.getInt(KEY_SELECTED_COLOR_INDEX, SELECT_NONE) - colorItems.getOrNull(selectedIndex)?.let { + val selectedIndex = Pref.getInt(KEY_LEGACY_SELECTED_COLOR_INDEX, SELECT_NONE) + colorItemsLegacy.getOrNull(selectedIndex)?.let { setSelectedPosition(selectedIndex) } ?: when (currentColor) { context.getColor(R.color.theme_color_default) -> { @@ -162,7 +162,7 @@ class ColorSettingRecyclerView : ThemeColorRecyclerView { } override fun onBindViewHolder(holder: ViewHolder, position: Int) { - val colorItem = colorItems[position] + val colorItem = colorItemsLegacy[position] val (colorRes, nameRes) = colorItem val color = when (position) { customColorPosition -> customColor @@ -176,7 +176,7 @@ class ColorSettingRecyclerView : ThemeColorRecyclerView { } } - override fun getItemCount() = colorItems.size + override fun getItemCount() = colorItemsLegacy.size } diff --git a/app/src/main/java/org/autojs/autojs/ui/widget/SearchViewItem.java b/app/src/main/java/org/autojs/autojs/ui/widget/SearchViewItem.java index eaf4d56f..b5d13c8e 100644 --- a/app/src/main/java/org/autojs/autojs/ui/widget/SearchViewItem.java +++ b/app/src/main/java/org/autojs/autojs/ui/widget/SearchViewItem.java @@ -25,6 +25,7 @@ public class SearchViewItem implements MenuItemCompat.OnActionExpandListener, Se private final Activity mActivity; private EditText mTextview; private ImageView mCloseButtonView; + private ImageView mSearchGoButtonView; public SearchViewItem(Activity activity, MenuItem searchMenuItem) { mActivity = activity; @@ -34,9 +35,11 @@ public class SearchViewItem implements MenuItemCompat.OnActionExpandListener, Se if (searchView == null) { return; } + searchView.setSubmitButtonEnabled(true); searchView.setSearchableInfo(searchManager.getSearchableInfo(activity.getComponentName())); mTextview = searchView.findViewById(androidx.appcompat.R.id.search_src_text); mCloseButtonView = searchView.findViewById(androidx.appcompat.R.id.search_close_btn); + mSearchGoButtonView = searchView.findViewById(androidx.appcompat.R.id.search_go_btn); initThemeColors(); MenuItemCompat.setOnActionExpandListener(searchMenuItem, this); searchView.setOnQueryTextListener(this); @@ -54,6 +57,9 @@ public class SearchViewItem implements MenuItemCompat.OnActionExpandListener, Se if (mCloseButtonView != null) { mCloseButtonView.setColorFilter(fullColor); } + if (mSearchGoButtonView != null) { + mSearchGoButtonView.setColorFilter(fullColor); + } } public void setQueryCallback(QueryCallback queryCallback) { diff --git a/app/src/main/res/layout/mt_activity_color_libraries.xml b/app/src/main/res/layout/mt_activity_color_libraries.xml index 5ea09791..ab59c735 100644 --- a/app/src/main/res/layout/mt_activity_color_libraries.xml +++ b/app/src/main/res/layout/mt_activity_color_libraries.xml @@ -32,10 +32,13 @@ - \ No newline at end of file diff --git a/app/src/main/res/layout/mt_activity_color_library.xml b/app/src/main/res/layout/mt_activity_color_library.xml index ebb0b08d..b3beb635 100644 --- a/app/src/main/res/layout/mt_activity_color_library.xml +++ b/app/src/main/res/layout/mt_activity_color_library.xml @@ -36,6 +36,9 @@ android:id="@+id/color_library_recycler_view" android:layout_width="match_parent" android:layout_height="match_parent" + android:fadeScrollbars="true" + android:scrollbarDefaultDelayBeforeFade="600" + android:scrollbarFadeDuration="500" android:scrollbars="vertical" /> \ No newline at end of file diff --git a/version.properties b/version.properties index 04b7e509..12fba32b 100644 --- a/version.properties +++ b/version.properties @@ -1,5 +1,5 @@ -#Fri Mar 28 10:17:08 CST 2025 -BUILD_TIME=1743128228067 +#Fri Mar 28 21:05:28 CST 2025 +BUILD_TIME=1743167128518 COMPILE_SDK_VERSION=35 JAVA_VERSION=23 JAVA_VERSION_MIN_RADICAL=0 @@ -17,6 +17,6 @@ RAPID_OCR_OPENCV_MOBILE_LABEL_VERSION=13 RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3 TARGET_SDK_VERSION=35 TARGET_SDK_VERSION_INRT=29 -VERSION_BUILD=3066 +VERSION_BUILD=3070 VERSION_NAME=6.6.2 Alpha5 VSCODE_EXT_REQUIRED_VERSION=1.0.8