6.6.3 - Alpha2 - 优化主页抽屉在横向屏幕或超宽屏幕的宽度适应性

This commit is contained in:
SuperMonster003
2025-05-09 17:16:17 +08:00
parent 76d0f3a809
commit a89b1f014d
3 changed files with 103 additions and 88 deletions

View File

@@ -20,6 +20,7 @@
"README.md 中部分语言日期格式不正确的问题" "README.md 中部分语言日期格式不正确的问题"
], ],
"improvement": [ "improvement": [
"主页抽屉在横向屏幕或超宽屏幕的宽度适应性",
"关于应用与开发者页面增加水平布局及小屏布局适配", "关于应用与开发者页面增加水平布局及小屏布局适配",
"文件管理器浮动按钮展开后点击其他区域可自动隐藏", "文件管理器浮动按钮展开后点击其他区域可自动隐藏",
"打包单文件时自动读取并勾选已安装应用的声明权限 _[`issue #362`](http://issues.autojs6.com/362)_", "打包单文件时自动读取并勾选已安装应用的声明权限 _[`issue #362`](http://issues.autojs6.com/362)_",

View File

@@ -38,6 +38,7 @@ import org.autojs.autojs.ui.fragment.BindingDelegates.viewBinding
import org.autojs.autojs.ui.main.MainActivity import org.autojs.autojs.ui.main.MainActivity
import org.autojs.autojs.ui.settings.AboutActivity import org.autojs.autojs.ui.settings.AboutActivity
import org.autojs.autojs.ui.settings.PreferencesActivity import org.autojs.autojs.ui.settings.PreferencesActivity
import org.autojs.autojs.util.DisplayUtils
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
@@ -47,6 +48,7 @@ import org.autojs.autojs6.databinding.FragmentDrawerBinding
import org.greenrobot.eventbus.EventBus import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe import org.greenrobot.eventbus.Subscribe
import java.lang.ref.WeakReference import java.lang.ref.WeakReference
import kotlin.math.roundToInt
/** /**
* Created by Stardust on Jan 30, 2017. * Created by Stardust on Jan 30, 2017.
@@ -390,11 +392,21 @@ open class DrawerFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
mDrawerMenu = binding.drawerMenu mDrawerMenu = binding.drawerMenu
configureDrawerWidth()
initMenuItems() initMenuItems()
initMenuItemStates() initMenuItemStates()
setupListeners() setupListeners()
} }
private fun configureDrawerWidth() {
val screenWidthDp = resources.configuration.screenWidthDp
val targetWidthPx = 288f.coerceIn(
screenWidthDp * 0.4f,
screenWidthDp * 0.9f,
).let { DisplayUtils.dpToPx(it) }.roundToInt()
binding.drawerMenuContainer.layoutParams.width = targetWidthPx
}
private fun setupListeners() { private fun setupListeners() {
binding.settings.setOnClickListener { view -> binding.settings.setOnClickListener { view ->
startActivity( startActivity(

View File

@@ -1,119 +1,121 @@
<?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:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="288dp" xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent" android:id="@+id/drawer_menu_container"
android:background="?android:windowBackground" android:layout_width="wrap_content"
android:clickable="true" android:layout_height="match_parent"
android:fitsSystemWindows="true" android:background="?android:windowBackground"
android:importantForAccessibility="no" android:clickable="true"
android:orientation="vertical" android:fitsSystemWindows="true"
android:focusable="true"> android:focusable="true"
android:importantForAccessibility="no"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/drawer_menu" android:id="@+id/drawer_menu"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" /> android:layout_weight="1" />
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:background="?android:divider" /> android:background="?android:divider" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="41dp" android:layout_height="41dp"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:baselineAligned="false"> android:baselineAligned="false">
<LinearLayout <LinearLayout
android:id="@+id/settings" android:id="@+id/settings"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:background="?selectableItemBackground" android:background="?selectableItemBackground"
android:gravity="center" android:gravity="center"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView
android:layout_width="16dp" android:layout_width="16dp"
android:layout_height="16dp" android:layout_height="16dp"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginEnd="10dp" android:layout_marginEnd="10dp"
android:src="@drawable/ic_ali_settings" android:src="@drawable/ic_ali_settings"
app:tint="?android:textColorPrimary" app:tint="?android:textColorPrimary"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginEnd="4dp" android:layout_marginEnd="4dp"
android:gravity="center" android:gravity="center"
android:text="@string/text_settings" android:text="@string/text_settings"
android:textColor="?android:textColorPrimary" android:textColor="?android:textColorPrimary"
android:textSize="15sp" /> android:textSize="15sp" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/restart" android:id="@+id/restart"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:background="?selectableItemBackground" android:background="?selectableItemBackground"
android:gravity="center" android:gravity="center"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView
android:layout_width="16dp" android:layout_width="16dp"
android:layout_height="16dp" android:layout_height="16dp"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginEnd="10dp" android:layout_marginEnd="10dp"
android:src="@drawable/ic_refresh_white_24dp" android:src="@drawable/ic_refresh_white_24dp"
app:tint="?android:textColorPrimary" app:tint="?android:textColorPrimary"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginEnd="4dp" android:layout_marginEnd="4dp"
android:gravity="center" android:gravity="center"
android:text="@string/text_restart_app" android:text="@string/text_restart_app"
android:textColor="?android:textColorPrimary" android:textColor="?android:textColorPrimary"
android:textSize="15sp" /> android:textSize="15sp" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/exit" android:id="@+id/exit"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:background="?selectableItemBackground" android:background="?selectableItemBackground"
android:gravity="center" android:gravity="center"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView
android:layout_width="16dp" android:layout_width="16dp"
android:layout_height="16dp" android:layout_height="16dp"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginEnd="10dp" android:layout_marginEnd="10dp"
android:src="@drawable/ic_ali_exit" android:src="@drawable/ic_ali_exit"
app:tint="?android:textColorPrimary" app:tint="?android:textColorPrimary"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginEnd="4dp" android:layout_marginEnd="4dp"
android:textColor="?android:textColorPrimary" android:textColor="?android:textColorPrimary"
android:gravity="center" android:gravity="center"
android:text="@string/text_exit" android:text="@string/text_exit"
android:textSize="15sp" /> android:textSize="15sp" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>