Skip to content

Commit 5d9d4b4

Browse files
committed
[优化] MD3视觉效果
1 parent 1d847a8 commit 5d9d4b4

File tree

9 files changed

+45
-11
lines changed

9 files changed

+45
-11
lines changed

app/src/main/java/com/yenaly/han1meviewer/ui/activity/LoginActivity.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class LoginActivity : FrameActivity() {
3939

4040
private lateinit var binding: ActivityLoginBinding
4141

42-
private val dialog by unsafeLazy { LoginDialog(R.layout.dialog_login) }
42+
private val dialog = unsafeLazy { LoginDialog(R.layout.dialog_login) }
4343

4444
override fun setUiStyle() {
4545
enableEdgeToEdge(
@@ -80,6 +80,9 @@ class LoginActivity : FrameActivity() {
8080

8181
override fun onDestroy() {
8282
super.onDestroy()
83+
if (dialog.isInitialized()) {
84+
dialog.value.dismiss()
85+
}
8386
binding.wvLogin.removeAllViews()
8487
binding.wvLogin.destroy()
8588
binding.unbind()
@@ -144,7 +147,7 @@ class LoginActivity : FrameActivity() {
144147
// #issue-160: 修复字段销毁后调用引发的错误
145148
if (!isDestroyed && !isFinishing) {
146149
binding.srlLogin.finishRefresh()
147-
dialog.show()
150+
dialog.value.show()
148151
}
149152
}
150153
}
@@ -212,5 +215,9 @@ class LoginActivity : FrameActivity() {
212215
fun show() {
213216
dialog.show()
214217
}
218+
219+
fun dismiss() {
220+
dialog.dismiss()
221+
}
215222
}
216223
}

app/src/main/res/xml/settings_h_keyframe.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto">
44

5-
<SwitchPreferenceCompat
5+
<com.yenaly.yenaly_libs.base.preference.MaterialSwitchPreference
66
app:defaultValue="true"
77
app:iconSpaceReserved="false"
88
app:key="h_keyframes_enable"
@@ -27,14 +27,14 @@
2727
app:key="shared_h_keyframes_category"
2828
app:title="@string/shared">
2929

30-
<SwitchPreferenceCompat
30+
<com.yenaly.yenaly_libs.base.preference.MaterialSwitchPreference
3131
app:defaultValue="true"
3232
app:iconSpaceReserved="false"
3333
app:key="shared_h_keyframes_enable"
3434
app:summary="@string/shared_h_keyframes_enable_tip"
3535
app:title="@string/shared_h_keyframes_enable" />
3636

37-
<SwitchPreferenceCompat
37+
<com.yenaly.yenaly_libs.base.preference.MaterialSwitchPreference
3838
app:defaultValue="false"
3939
app:iconSpaceReserved="false"
4040
app:key="shared_h_keyframes_use_first"
@@ -54,7 +54,7 @@
5454
app:key="h_keyframe_custom_category"
5555
app:title="@string/custom">
5656

57-
<SwitchPreferenceCompat
57+
<com.yenaly.yenaly_libs.base.preference.MaterialSwitchPreference
5858
app:defaultValue="false"
5959
app:iconSpaceReserved="false"
6060
app:key="show_comment_when_countdown"

app/src/main/res/xml/settings_home.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
app:key="update"
5656
app:title="@string/check_update" />
5757

58-
<SwitchPreferenceCompat
58+
<com.yenaly.yenaly_libs.base.preference.MaterialSwitchPreference
5959
app:defaultValue="false"
6060
app:key="use_ci_update_channel"
6161
app:summary="@string/use_ci_update_channel_summary"

app/src/main/res/xml/settings_network.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
app:key="proxy"
1212
app:title="@string/proxy" />
1313

14-
<SwitchPreferenceCompat
14+
<com.yenaly.yenaly_libs.base.preference.MaterialSwitchPreference
1515
app:iconSpaceReserved="false"
1616
app:key="use_built_in_hosts"
1717
app:summary="@string/use_built_in_hosts_summary"

app/src/main/res/xml/settings_player.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
app:title="@string/switch_player_kernel"
99
app:useSimpleSummaryProvider="true" />
1010

11-
<SwitchPreferenceCompat
11+
<com.yenaly.yenaly_libs.base.preference.MaterialSwitchPreference
1212
app:defaultValue="true"
1313
app:iconSpaceReserved="false"
1414
app:key="show_bottom_progress"

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ lifecycleLiveDataKtx = "2.8.4"
2828
roomRuntime = "2.6.1"
2929
roomKtx = "2.6.1"
3030
roomCompiler = "2.6.1"
31-
navigationFragmentKtx = "2.7.7"
32-
navigationUiKtx = "2.7.7"
31+
navigationFragmentKtx = "2.8.0"
32+
navigationUiKtx = "2.8.0"
3333
preferenceKtx = "1.2.1"
3434
workRuntime = "2.9.1"
3535
workRuntimeKtx = "2.9.1"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.yenaly.yenaly_libs.base.preference
2+
3+
import android.content.Context
4+
import android.util.AttributeSet
5+
import androidx.preference.SwitchPreferenceCompat
6+
import com.yenaly.yenaly_libs.R
7+
8+
open class MaterialSwitchPreference @JvmOverloads constructor(
9+
context: Context, attrs: AttributeSet? = null,
10+
): SwitchPreferenceCompat(context, attrs) {
11+
init {
12+
widgetLayoutResource = R.layout.yenaly_preference_switch_widget
13+
}
14+
}

yenaly_libs/src/main/java/com/yenaly/yenaly_libs/base/settings/YenalySettingsFragment.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.yenaly.yenaly_libs.base.settings
22

3+
import android.graphics.drawable.Drawable
34
import android.os.Bundle
45
import android.util.Log
56
import androidx.annotation.XmlRes
@@ -28,6 +29,10 @@ abstract class YenalySettingsFragment(@XmlRes private val xmlRes: Int) :
2829
bindDataObservers()
2930
}
3031

32+
override fun setDivider(divider: Drawable?) {
33+
super.setDivider(null)
34+
}
35+
3136
/**
3237
* 用于绑定数据观察器 (optional)
3338
*/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<com.google.android.material.materialswitch.MaterialSwitch xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:id="@+id/switchWidget"
4+
android:layout_width="wrap_content"
5+
android:layout_height="wrap_content"
6+
android:background="@null"
7+
android:clickable="false"
8+
android:focusable="false" />

0 commit comments

Comments
 (0)