Browse Source

1.优化锁屏对话框布局并添加网络提示功能- 将锁屏对话框的主布局从 LinearLayout 改为 FrameLayout,以优化布局结构

2025_1_17_tb223fc
wangwanlei 1 week ago
parent
commit
d0bc327be1

+ 12
- 1
app/src/main/java/com/xhly/manageapp/ui/main/activity/MainActivity.kt View File

@@ -164,6 +164,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
164 164
     private var lockDialogEt:EditText?=null
165 165
     private var lockversionTv:TextView?=null
166 166
     private var lockDialogNetset:View?=null
167
+    private var lockDialogNetTips:View?=null
167 168
     //表示是否是设置wifi是的话,暂时隐藏锁屏弹窗
168 169
     private var goWifiFlag=false
169 170
 
@@ -965,7 +966,16 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
965 966
     }
966 967
     private fun postPwdDetail(code: String) {
967 968
         if (!NetworkUtils.isAvailable(this)) {
968
-
969
+            Toast.makeText(this, "没有网络", Toast.LENGTH_SHORT).show()
970
+            lockDialogNetTips?.let {
971
+                it.visibility= View.VISIBLE
972
+                lifecycleScope.launch(Dispatchers.IO){
973
+                    delay(2000)
974
+                    withContext(Dispatchers.Main){
975
+                        it.visibility= View.GONE
976
+                    }
977
+                }
978
+            }
969 979
             return
970 980
         }
971 981
         if (code.isNullOrBlank()) {
@@ -2155,6 +2165,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
2155 2165
              lockDialogTv=v.findViewById<TextView>(R.id.locktips_tv)
2156 2166
              lockversionTv=v.findViewById<TextView>(R.id.version_tv)
2157 2167
              lockDialogNetset=v.findViewById<View>(R.id.netset_llayout)
2168
+             lockDialogNetTips=v.findViewById<View>(R.id.tv_tips)
2158 2169
              lockllayout.setOnClickListener {
2159 2170
                  //限制最多1分钟请求一次策略,
2160 2171
                  if (lastTimeLong + 1 * 60 * 1000 < System.currentTimeMillis()) {

+ 95
- 80
app/src/main/res/layout/dialog_locklayout.xml View File

@@ -1,4 +1,4 @@
1
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
1
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
2 2
     xmlns:app="http://schemas.android.com/apk/res-auto"
3 3
     android:id="@+id/lock_llayout"
4 4
     android:layout_width="match_parent"
@@ -7,94 +7,109 @@
7 7
     android:gravity="center_horizontal"
8 8
     android:orientation="vertical">
9 9
 
10
-    <ImageView
11
-        android:layout_width="157dp"
12
-        android:layout_height="151dp"
13
-        android:layout_marginTop="104dp"
14
-        android:src="@drawable/icon_lock" />
10
+    <LinearLayout
11
+        android:layout_width="match_parent"
12
+        android:layout_height="match_parent"
13
+        android:gravity="center_horizontal"
14
+        android:orientation="vertical">
15 15
 
16
-    <FrameLayout
17
-        android:layout_width="wrap_content"
18
-        android:layout_height="53dp"
19
-        android:layout_marginTop="26dp">
16
+        <ImageView
17
+            android:layout_width="157dp"
18
+            android:layout_height="151dp"
19
+            android:layout_marginTop="104dp"
20
+            android:src="@drawable/icon_lock" />
20 21
 
21
-        <EditText
22
-            android:id="@+id/lock_et"
23
-            android:layout_width="357dp"
22
+        <FrameLayout
23
+            android:layout_width="wrap_content"
24 24
             android:layout_height="53dp"
25
-            android:background="@drawable/shape_shadow_bg"
26
-            android:hint="@string/passcode"
27
-            android:maxLength="20"
28
-            android:paddingLeft="28dp"
29
-            android:paddingRight="28dp"
30
-            android:singleLine="true"
31
-            android:textColor="@color/codetipscolor"
32
-            android:textColorHint="@color/codehintcolor"
33
-            android:textSize="16sp" />
25
+            android:layout_marginTop="26dp">
34 26
 
35
-        <androidx.cardview.widget.CardView
36
-            android:id="@+id/codeenter_cv"
37
-            android:layout_width="24dp"
38
-            android:layout_height="24dp"
39
-            android:layout_gravity="center_vertical|right"
40
-            android:layout_marginRight="18dp"
41
-            app:cardBackgroundColor="@color/white">
27
+            <EditText
28
+                android:id="@+id/lock_et"
29
+                android:layout_width="357dp"
30
+                android:layout_height="53dp"
31
+                android:background="@drawable/shape_shadow_bg"
32
+                android:hint="@string/passcode"
33
+                android:maxLength="20"
34
+                android:paddingLeft="28dp"
35
+                android:paddingRight="28dp"
36
+                android:singleLine="true"
37
+                android:textColor="@color/codetipscolor"
38
+                android:textColorHint="@color/codehintcolor"
39
+                android:textSize="16sp" />
42 40
 
43
-            <ImageView
44
-                android:layout_width="wrap_content"
45
-                android:layout_height="11dp"
46
-                android:layout_gravity="center"
47
-                android:src="@drawable/icon_etenter" />
48
-        </androidx.cardview.widget.CardView>
49
-    </FrameLayout>
41
+            <androidx.cardview.widget.CardView
42
+                android:id="@+id/codeenter_cv"
43
+                android:layout_width="24dp"
44
+                android:layout_height="24dp"
45
+                android:layout_gravity="center_vertical|right"
46
+                android:layout_marginRight="18dp"
47
+                app:cardBackgroundColor="@color/white">
48
+
49
+                <ImageView
50
+                    android:layout_width="wrap_content"
51
+                    android:layout_height="11dp"
52
+                    android:layout_gravity="center"
53
+                    android:src="@drawable/icon_etenter" />
54
+            </androidx.cardview.widget.CardView>
55
+        </FrameLayout>
56
+
57
+        <TextView
58
+            android:id="@+id/locktips_tv"
59
+            android:layout_width="wrap_content"
60
+            android:layout_height="wrap_content"
61
+            android:layout_marginTop="18dp"
62
+            android:text="@string/locktips"
63
+            android:textColor="@color/codetipscolor"
64
+            android:textSize="17sp" />
65
+
66
+    </LinearLayout>
50 67
 
51 68
     <TextView
52
-        android:id="@+id/locktips_tv"
69
+        android:id="@+id/version_tv"
53 70
         android:layout_width="wrap_content"
54 71
         android:layout_height="wrap_content"
55
-        android:layout_marginTop="18dp"
56
-        android:text="@string/locktips"
57
-        android:textColor="@color/codetipscolor"
58
-        android:textSize="17sp" />
59
-   <RelativeLayout
60
-       android:layout_width="match_parent"
61
-       android:layout_height="match_parent">
62
-       <TextView
63
-           android:id="@+id/version_tv"
64
-           android:layout_width="wrap_content"
65
-           android:layout_height="wrap_content"
66
-           android:layout_gravity="bottom|left"
67
-           android:layout_alignParentBottom="true"
68
-           android:layout_marginLeft="10dp"
69
-           android:layout_marginBottom="10dp"
70
-           android:textColor="#253A70"
71
-           android:textSize="8sp" />
72
+        android:layout_gravity="bottom|left"
73
+        android:layout_marginLeft="10dp"
74
+        android:layout_marginBottom="10dp"
75
+        android:textColor="#253A70"
76
+        android:textSize="8sp" />
72 77
 
73
-       <LinearLayout
74
-           android:id="@+id/netset_llayout"
75
-           android:layout_width="wrap_content"
76
-           android:layout_height="wrap_content"
77
-           android:layout_alignParentRight="true"
78
-           android:layout_marginRight="10dp"
79
-           android:layout_alignParentBottom="true"
80
-           android:layout_marginBottom="10dp"
81
-           android:paddingLeft="10dp"
82
-           android:paddingTop="10dp"
83
-           android:gravity="center"
84
-           android:orientation="horizontal">
85 78
 
86
-           <ImageView
87
-               android:layout_width="10dp"
88
-               android:layout_height="10dp"
89
-               android:layout_marginRight="3dp"
90
-               android:src="@drawable/icon_wifiset" />
79
+    <LinearLayout
80
+        android:id="@+id/netset_llayout"
81
+        android:layout_width="wrap_content"
82
+        android:layout_height="wrap_content"
83
+        android:layout_marginRight="10dp"
84
+        android:layout_marginBottom="10dp"
85
+        android:layout_gravity="bottom|right"
86
+        android:gravity="center"
87
+        android:orientation="horizontal"
88
+        android:paddingLeft="10dp"
89
+        android:paddingTop="10dp">
90
+
91
+        <ImageView
92
+            android:layout_width="10dp"
93
+            android:layout_height="10dp"
94
+            android:layout_marginRight="3dp"
95
+            android:src="@drawable/icon_wifiset" />
96
+
97
+        <TextView
98
+            android:layout_width="wrap_content"
99
+            android:layout_height="wrap_content"
100
+            android:text="@string/netset"
101
+            android:textColor="#253A70"
102
+            android:textSize="8sp" />
103
+    </LinearLayout>
91 104
 
92
-           <TextView
93
-               android:layout_width="wrap_content"
94
-               android:layout_height="wrap_content"
95
-               android:text="@string/netset"
96
-               android:textColor="#253A70"
97
-               android:textSize="8sp" />
98
-       </LinearLayout>
99
-   </RelativeLayout>
100
-</LinearLayout>
105
+    <TextView
106
+        android:id="@+id/tv_tips"
107
+        android:layout_width="wrap_content"
108
+        android:layout_height="wrap_content"
109
+        android:layout_gravity="center"
110
+        android:background="@color/black80"
111
+        android:padding="30dp"
112
+        android:visibility="gone"
113
+        android:text="@string/checknettips"
114
+        android:textColor="@color/white" />
115
+</FrameLayout>

Loading…
Cancel
Save