Bläddra i källkod

1.登录页面添加同步时间和网络设置跳转

20241218TB223FC(测试jar包)
wangwanlei 10 månader sedan
förälder
incheckning
5220b41bec

+ 6
- 1
app/src/main/java/com/xhly/manageapp/network/UriAdress.kt Visa fil

@@ -52,7 +52,7 @@ object UriAdress {
52 52
     const val PADDETAILADD = "/deviceDetail/add"
53 53
 
54 54
     /**
55
-     *用来统计版本更新消息,而不是用来版本更新
55
+     *用来统计版本更新消息,而不是用来版本更新(每次更新和安装都调用)
56 56
      */
57 57
     const val CLIENT_ADD = "/client/add"
58 58
 
@@ -90,4 +90,9 @@ object UriAdress {
90 90
      * 修改密码
91 91
      */
92 92
     const val EDITPWD="/user/edit_pwd"
93
+
94
+    /**
95
+     * 同步时间
96
+     */
97
+    const val SYNCTIME="/tool/milli"
93 98
 }

+ 12
- 0
app/src/main/java/com/xhly/manageapp/ui/login/activity/LoginActivity.kt Visa fil

@@ -3,8 +3,10 @@ package com.xhly.manageapp.ui.login.activity
3 3
 import BaseActivity
4 4
 import android.Manifest
5 5
 import android.annotation.SuppressLint
6
+import android.content.Intent
6 7
 import android.graphics.Color
7 8
 import android.os.Build
9
+import android.provider.Settings
8 10
 import android.view.View
9 11
 import android.widget.Button
10 12
 import android.widget.EditText
@@ -62,6 +64,10 @@ class LoginActivity : BaseActivity<LoginViewModel, ActivityLoginBinding>() {
62 64
                 Toast(getString(R.string.codeerror))
63 65
             }
64 66
         }
67
+        viewModel.timeResultData.observe(this){
68
+            ManageApplication.setSysTime(it)
69
+            Toast(getString(R.string.syncsucess))
70
+        }
65 71
         startWorkManager()
66 72
     }
67 73
 
@@ -96,6 +102,12 @@ class LoginActivity : BaseActivity<LoginViewModel, ActivityLoginBinding>() {
96 102
         mBinding.loginClayout.setOnClickListener {
97 103
             hiddenSoft(mBinding.accountEt)
98 104
         }
105
+        mBinding.netsetLlayout.setOnClickListener {
106
+            startActivity(Intent(Settings.ACTION_WIFI_SETTINGS))
107
+        }
108
+        mBinding.synctimeLlayout.setOnClickListener {
109
+               viewModel.postSyncTime()
110
+        }
99 111
         onBackPressedDispatcher.addCallback {
100 112
             //屏蔽返回
101 113
         }

+ 6
- 0
app/src/main/java/com/xhly/manageapp/ui/login/netservice/LoginService.kt Visa fil

@@ -40,4 +40,10 @@ interface LoginService {
40 40
      */
41 41
     @POST(UriAdress.EDITPWD)
42 42
     suspend fun postEditPwd(@Body map:HashMap<String,Any>):ResponseData<Any>
43
+
44
+    /**
45
+     * 同步服务器时间
46
+     */
47
+    @POST(UriAdress.SYNCTIME)
48
+    suspend fun postSyncTime():ResponseData<Long>
43 49
 }

Binär
app/src/main/res/drawable/icon_synctime.png Visa fil


Binär
app/src/main/res/drawable/icon_wifiset.png Visa fil


+ 52
- 0
app/src/main/res/layout/activity_login.xml Visa fil

@@ -125,10 +125,62 @@
125 125
                     android:background="@drawable/icon_login"
126 126
                     android:text="@string/loginnow"
127 127
                     android:textColor="@color/white"
128
+                    android:textSize="21sp"
128 129
                     app:layout_constraintLeft_toLeftOf="parent"
129 130
                     app:layout_constraintRight_toRightOf="parent"
130 131
                     app:layout_constraintTop_toTopOf="parent" />
131 132
 
133
+                <LinearLayout
134
+                    android:layout_width="match_parent"
135
+                    android:layout_height="wrap_content"
136
+                    android:layout_marginTop="10dp"
137
+                    android:gravity="center"
138
+                    android:orientation="horizontal"
139
+                    app:layout_constraintLeft_toLeftOf="parent"
140
+                    app:layout_constraintRight_toRightOf="parent"
141
+                    app:layout_constraintTop_toBottomOf="@id/login_btn">
142
+
143
+                    <LinearLayout
144
+                        android:id="@+id/netset_llayout"
145
+                        android:layout_width="wrap_content"
146
+                        android:layout_height="wrap_content"
147
+                        android:layout_marginRight="29dp"
148
+                        android:gravity="center"
149
+                        android:orientation="horizontal">
150
+
151
+                        <ImageView
152
+                            android:layout_width="21dp"
153
+                            android:layout_height="21dp"
154
+                            android:src="@drawable/icon_wifiset" />
155
+
156
+                        <TextView
157
+                            android:layout_width="wrap_content"
158
+                            android:layout_height="wrap_content"
159
+                            android:text="@string/netset"
160
+                            android:textColor="@color/codetipscolor"
161
+                            android:textSize="19sp" />
162
+                    </LinearLayout>
163
+
164
+                    <LinearLayout
165
+                        android:id="@+id/synctime_llayout"
166
+                        android:layout_width="wrap_content"
167
+                        android:layout_height="wrap_content"
168
+                        android:gravity="center"
169
+                        android:orientation="horizontal">
170
+
171
+                        <ImageView
172
+                            android:layout_width="21dp"
173
+                            android:layout_height="21dp"
174
+                            android:src="@drawable/icon_synctime" />
175
+
176
+                        <TextView
177
+                            android:layout_width="wrap_content"
178
+                            android:layout_height="wrap_content"
179
+                            android:text="@string/synctime"
180
+                            android:textColor="@color/codetipscolor"
181
+                            android:textSize="19sp" />
182
+                    </LinearLayout>
183
+                </LinearLayout>
132 184
             </androidx.constraintlayout.widget.ConstraintLayout>
133 185
         </androidx.core.widget.NestedScrollView>
134 186
     </androidx.constraintlayout.widget.ConstraintLayout>

+ 4
- 1
app/src/main/res/values/strings.xml Visa fil

@@ -28,7 +28,7 @@
28 28
     <string name="newcodetips">请输入新密码</string>
29 29
     <string name="enternewcodetips">请输入确认新密码</string>
30 30
     <string name="codetips">密码必须是6-16位的英文字母、数字组合</string>
31
-    <string name="locktips">您的设备已违规或者被管理员限制使用,请联系管理员</string>
31
+    <string name="locktips">您的设备已违规或者被管理员锁定,请联系管理员</string>
32 32
     <string name="codeerror">密码不正确。</string>
33 33
     <string name="durationtips">当前使用时间过长,请休息后再使用。\n</string>
34 34
     <string name="openrotation">自动旋转已开启</string>
@@ -37,4 +37,7 @@
37 37
     <string name="clearend">清理缓存完成。</string>
38 38
     <string name="loginout">注销</string>
39 39
     <string name="appstore">星火应用商店</string>
40
+    <string name="netset">网络设置</string>
41
+    <string name="synctime">同步时间</string>
42
+    <string name="syncsucess">同步完成。</string>
40 43
 </resources>

Laddar…
Avbryt
Spara