6.6.2 - Alpha6 - 主页文档页面搜索时支持双向查找按钮
This commit is contained in:
@@ -37,8 +37,9 @@
|
||||
* `优化` 调色盘 HEX 输入控件增强剪贴板粘贴色值时的兼容性
|
||||
* `优化` 应用内页面导航栏设置为透明或半透明以增强视觉体验
|
||||
* `优化` UI 模式状态栏及导航栏默认为 `md_grey_50` 色值且设置为亮色模式
|
||||
* `优化` 应用主页 "文件" 标签支持通过长按切换浮动按钮可见状态
|
||||
* `优化` 应用主页抽屉无障碍服务开关支持与脚本代码同步
|
||||
* `优化` 主页抽屉无障碍服务开关支持与脚本代码同步
|
||||
* `优化` 主页文档页面搜索时支持双向查找按钮
|
||||
* `优化` 主页 "文件" 标签支持通过长按切换浮动按钮可见状态
|
||||
* `优化` 代码编辑器标题文字支持字体大小自适应
|
||||
* `优化` 日志页面浮动按钮可见状态与列表滚动操作联动
|
||||
* `优化` 脚本项目配置文件 project.json 支持更多打包选项 _[`issue #305`](http://issues.autojs6.com/305)_ _[`issue #306`](http://issues.autojs6.com/306)_
|
||||
|
||||
@@ -37,8 +37,9 @@
|
||||
* `优化` 调色盘 HEX 输入控件增强剪贴板粘贴色值时的兼容性
|
||||
* `优化` 应用内页面导航栏设置为透明或半透明以增强视觉体验
|
||||
* `优化` UI 模式状态栏及导航栏默认为 `md_grey_50` 色值且设置为亮色模式
|
||||
* `优化` 应用主页 "文件" 标签支持通过长按切换浮动按钮可见状态
|
||||
* `优化` 应用主页抽屉无障碍服务开关支持与脚本代码同步
|
||||
* `优化` 主页抽屉无障碍服务开关支持与脚本代码同步
|
||||
* `优化` 主页文档页面搜索时支持双向查找按钮
|
||||
* `优化` 主页 "文件" 标签支持通过长按切换浮动按钮可见状态
|
||||
* `优化` 代码编辑器标题文字支持字体大小自适应
|
||||
* `优化` 日志页面浮动按钮可见状态与列表滚动操作联动
|
||||
* `优化` 脚本项目配置文件 project.json 支持更多打包选项 _[`issue #305`](http://issues.autojs6.com/305)_ _[`issue #306`](http://issues.autojs6.com/306)_
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.greenrobot.eventbus.Subscribe
|
||||
* Modified by SuperMonster003 as of Mar 26, 2022.
|
||||
* Transformed by SuperMonster003 on Mar 31, 2023.
|
||||
*/
|
||||
open class DocumentationFragment : ViewPagerFragment(ROTATION_GONE), BackPressedHandler, ViewStatesManageable {
|
||||
class DocumentationFragment : ViewPagerFragment(ROTATION_GONE), BackPressedHandler, ViewStatesManageable {
|
||||
|
||||
private val binding by viewBinding(FragmentOnlineDocsBinding::bind)
|
||||
|
||||
@@ -99,7 +99,8 @@ open class DocumentationFragment : ViewPagerFragment(ROTATION_GONE), BackPressed
|
||||
mWebView.clearMatches()
|
||||
mPreviousQuery = null
|
||||
}
|
||||
event.isFindForward -> mWebView.findNext(false)
|
||||
event === QueryEvent.FIND_FORWARD -> mWebView.findNext(true)
|
||||
event.isFindBackward -> mWebView.findNext(false)
|
||||
event.query == mPreviousQuery -> mWebView.findNext(true)
|
||||
else -> {
|
||||
mWebView.findAllAsync(event.query)
|
||||
|
||||
@@ -15,6 +15,7 @@ import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.core.view.forEach
|
||||
import androidx.drawerlayout.widget.DrawerLayout
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
@@ -91,7 +92,6 @@ class MainActivity : BaseActivity(), DelegateHost, HostActivity {
|
||||
private val mBackPressObserver = BackPressedHandler.Observer()
|
||||
private val mForeGroundService = ForegroundService(this)
|
||||
private var mSearchViewItem: SearchViewItem? = null
|
||||
private var mDocsSearchItemExpanded = false
|
||||
private val mA11yTool = AccessibilityTool(this)
|
||||
|
||||
private val isCurrentPageDocs: Boolean
|
||||
@@ -369,40 +369,53 @@ class MainActivity : BaseActivity(), DelegateHost, HostActivity {
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_main, menu)
|
||||
mLogMenuItem = menu.findItem(R.id.action_log)
|
||||
mSearchMenuItem = menu.findItem(R.id.action_search)
|
||||
setUpSearchMenuItem(mSearchMenuItem)
|
||||
setUpSearchMenuItem(menu)
|
||||
setUpToolbarColors()
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == R.id.action_log) {
|
||||
if (mDocsSearchItemExpanded) {
|
||||
submitForwardQuery()
|
||||
} else {
|
||||
LogActivity.launch(this)
|
||||
}
|
||||
LogActivity.launch(this)
|
||||
return true
|
||||
}
|
||||
if (item.itemId == R.id.action_search_next) {
|
||||
submitForwardQuery()
|
||||
return true
|
||||
}
|
||||
if (item.itemId == R.id.action_search_prev) {
|
||||
submitBackwardQuery()
|
||||
return true
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
private fun setUpSearchMenuItem(searchMenuItem: MenuItem) {
|
||||
mSearchViewItem = object : SearchViewItem(this, searchMenuItem) {
|
||||
private fun setUpSearchMenuItem(menu: Menu) {
|
||||
mSearchMenuItem = menu.findItem(R.id.action_search)
|
||||
mSearchViewItem = object : SearchViewItem(this, mSearchMenuItem) {
|
||||
override fun onMenuItemActionExpand(item: MenuItem): Boolean {
|
||||
if (isCurrentPageDocs) {
|
||||
mDocsSearchItemExpanded = true
|
||||
mLogMenuItem.setIcon(R.drawable.ic_ali_up)
|
||||
menu.forEach {
|
||||
when (it.itemId) {
|
||||
R.id.action_search_next, R.id.action_search_prev -> {
|
||||
it.isVisible = isCurrentPageDocs
|
||||
}
|
||||
else -> it.isVisible = false
|
||||
}
|
||||
}
|
||||
mToolbar.onceGlobalLayout { setUpToolbarColors() }
|
||||
return super.onMenuItemActionExpand(item)
|
||||
}
|
||||
|
||||
override fun onMenuItemActionCollapse(item: MenuItem): Boolean {
|
||||
if (mDocsSearchItemExpanded) {
|
||||
mDocsSearchItemExpanded = false
|
||||
mLogMenuItem.setIcon(R.drawable.ic_ali_log)
|
||||
menu.forEach {
|
||||
when (it.itemId) {
|
||||
R.id.action_search_next, R.id.action_search_prev -> {
|
||||
it.isVisible = false
|
||||
}
|
||||
else -> it.isVisible = true
|
||||
}
|
||||
}
|
||||
mToolbar.onceGlobalLayout { setUpToolbarColors() }
|
||||
return super.onMenuItemActionCollapse(item)
|
||||
}
|
||||
}.apply {
|
||||
@@ -430,6 +443,11 @@ class MainActivity : BaseActivity(), DelegateHost, HostActivity {
|
||||
EventBus.getDefault().post(event)
|
||||
}
|
||||
|
||||
private fun submitBackwardQuery() {
|
||||
val event = QueryEvent.FIND_BACKWARD
|
||||
EventBus.getDefault().post(event)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
ViewUtils.configKeepScreenOnWhenInForeground(this)
|
||||
|
||||
@@ -6,15 +6,16 @@ package org.autojs.autojs.ui.main;
|
||||
public class QueryEvent {
|
||||
|
||||
public static final QueryEvent CLEAR = new QueryEvent(null);
|
||||
public static final QueryEvent FIND_FORWARD = new QueryEvent("", true);
|
||||
public static final QueryEvent FIND_FORWARD = new QueryEvent(null);
|
||||
public static final QueryEvent FIND_BACKWARD = new QueryEvent("", true);
|
||||
|
||||
private boolean mShouldCollapseSearchView = false;
|
||||
private final String mQuery;
|
||||
private final boolean mFindForward;
|
||||
private final boolean mFindBackward;
|
||||
|
||||
public QueryEvent(String query, boolean b) {
|
||||
public QueryEvent(String query, boolean findBackward) {
|
||||
mQuery = query;
|
||||
mFindForward = b;
|
||||
mFindBackward = findBackward;
|
||||
}
|
||||
|
||||
public QueryEvent(String query) {
|
||||
@@ -33,8 +34,8 @@ public class QueryEvent {
|
||||
return mShouldCollapseSearchView;
|
||||
}
|
||||
|
||||
public boolean isFindForward() {
|
||||
return mFindForward;
|
||||
public boolean isFindBackward() {
|
||||
return mFindBackward;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class ExplorerFragment : ViewPagerFragment(0), OnFloatingActionButtonClickListen
|
||||
private var mExplorerView: ExplorerView? = null
|
||||
private var mFloatingActionMenu: FloatingActionMenu? = null
|
||||
private var mIsCurrentPageFiles = false
|
||||
|
||||
|
||||
private var mBottomInset: Int = 0
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -173,6 +173,12 @@ class ExplorerFragment : ViewPagerFragment(0), OnFloatingActionButtonClickListen
|
||||
mExplorerView?.setFilter(null)
|
||||
return
|
||||
}
|
||||
if (event === QueryEvent.FIND_FORWARD) {
|
||||
return
|
||||
}
|
||||
if (event === QueryEvent.FIND_BACKWARD) {
|
||||
return
|
||||
}
|
||||
mExplorerView?.setFilter { item: ExplorerItem -> item.name.contains(event.query, true) }
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
android:id="@+id/action_log"
|
||||
android:icon="@drawable/ic_ali_log"
|
||||
android:title="@string/text_log"
|
||||
app:showAsAction="ifRoom" />
|
||||
app:showAsAction="always" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_search"
|
||||
@@ -16,6 +16,20 @@
|
||||
android:imeOptions="actionSearch"
|
||||
android:inputType="text"
|
||||
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
||||
app:showAsAction="ifRoom|collapseActionView" />
|
||||
app:showAsAction="always|collapseActionView" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_search_prev"
|
||||
android:icon="@drawable/ic_ali_up"
|
||||
android:title="@string/text_find_prev_simplified"
|
||||
android:visible="false"
|
||||
app:showAsAction="always" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_search_next"
|
||||
android:icon="@drawable/ic_ali_down"
|
||||
android:title="@string/text_find_next_simplified"
|
||||
android:visible="false"
|
||||
app:showAsAction="always" />
|
||||
|
||||
</menu>
|
||||
Reference in New Issue
Block a user