Bladeren bron

连接失败页面

zhaoyadi 7 maanden geleden
bovenliggende
commit
d5381c43a5

+ 8 - 18
xiaodou/src/main/java/com/luojigou/product/xiaodou/XDConnectActivity.kt

@@ -7,19 +7,14 @@ import android.content.IntentFilter
 import android.net.wifi.ScanResult
 import android.os.Bundle
 import androidx.core.content.ContextCompat
-import androidx.fragment.app.Fragment
 import com.luojigou.product.R
 import com.luojigou.product.base.BaseActivity
+import com.luojigou.product.wifi.ssid
 import com.luojigou.product.xiaodou.connect.XDConnectConnectingFragment
-import com.luojigou.product.xiaodou.connect.XDConnectErrorFragment
 import com.luojigou.product.xiaodou.connect.XDConnectFailFragment
-import com.luojigou.product.xiaodou.connect.XDConnectNotFoundFragment
-import com.luojigou.product.xiaodou.connect.XDConnectPasswordErrorFragment
 import com.luojigou.product.xiaodou.connect.XDConnectPasswordFragment
 import com.luojigou.product.xiaodou.connect.XDConnectPasswordSsidFragment
 import com.luojigou.product.xiaodou.connect.XDConnectSuccessFragment
-import com.luojigou.product.xiaodou.connect.XDConnectTimeoutFragment
-import com.luojigou.product.wifi.ssid
 
 class XDConnectActivity : BaseActivity() {
     companion object {
@@ -34,26 +29,22 @@ class XDConnectActivity : BaseActivity() {
         }
     }
 
-    private val timeoutFragment = XDConnectTimeoutFragment()
-    private val errorFragment = XDConnectErrorFragment()
-    private val successFragment = XDConnectSuccessFragment()
     private val connectingFragment = XDConnectConnectingFragment()
+    private val successFragment = XDConnectSuccessFragment()
     private val failFragment = XDConnectFailFragment()
-    private val notFoundFragment = XDConnectNotFoundFragment()
-    private val passwordErrorFragment = XDConnectPasswordErrorFragment()
 
     private val connectReceiver = object : BroadcastReceiver() {
         override fun onReceive(context: Context?, intent: Intent) {
             setFragment(
                 when (intent.action) {
-                    XDConnectService.ACTION_CONNECT_WIFI_RESULT_TIMEOUT -> timeoutFragment
-                    XDConnectService.ACTION_CONNECT_WIFI_RESULT_ERROR -> errorFragment
+                    XDConnectService.ACTION_CONNECT_WIFI_RESULT_TIMEOUT -> failFragment
+                    XDConnectService.ACTION_CONNECT_WIFI_RESULT_ERROR -> failFragment
                     XDConnectService.ACTION_CONNECT_WIFI_RESULT_SUCCESS -> successFragment
                     XDConnectService.ACTION_CONNECT_WIFI_RESULT_CONNECTING -> connectingFragment
                     XDConnectService.ACTION_CONNECT_WIFI_RESULT_FAIL -> failFragment
-                    XDConnectService.ACTION_CONNECT_WIFI_RESULT_NOT_FOUND -> notFoundFragment
-                    XDConnectService.ACTION_CONNECT_WIFI_RESULT_PASSWORD_ERROR -> passwordErrorFragment
-                    else -> errorFragment
+                    XDConnectService.ACTION_CONNECT_WIFI_RESULT_NOT_FOUND -> failFragment
+                    XDConnectService.ACTION_CONNECT_WIFI_RESULT_PASSWORD_ERROR -> failFragment
+                    else -> failFragment
                 }
             )
         }
@@ -61,8 +52,7 @@ class XDConnectActivity : BaseActivity() {
 
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
-        setTitle("连接Wi-Fi")
-//        setFragment(connectingFragment)
+        setTitle("连接Wi-Fi") //        setFragment(connectingFragment)
 
         val intentFilter = IntentFilter()
         intentFilter.apply {

+ 1 - 1
xiaodou/src/main/java/com/luojigou/product/xiaodou/XDConnectService.kt

@@ -161,7 +161,7 @@ class XDConnectService : Service() {
             result.apply {
                 if (device.name == null) return
 
-                if (!device.name.startsWith("XiaoDouAI")) return
+//                if (!device.name.startsWith("XiaoDouAI")) return
 
                 val device = XDScanBLEDevice(
                     name = device.name ?: "unknown",

+ 0 - 18
xiaodou/src/main/java/com/luojigou/product/xiaodou/connect/XDConnectErrorFragment.kt

@@ -1,18 +0,0 @@
-package com.luojigou.product.xiaodou.connect
-
-import android.os.Bundle
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import androidx.fragment.app.Fragment
-import com.luojigou.product.R
-
-class XDConnectErrorFragment : Fragment() {
-    override fun onCreateView(
-        inflater: LayoutInflater,
-        container: ViewGroup?,
-        savedInstanceState: Bundle?
-    ): View? {
-        return inflater.inflate(R.layout.fragment_connect_error, container, false)
-    }
-}

+ 0 - 18
xiaodou/src/main/java/com/luojigou/product/xiaodou/connect/XDConnectNotFoundFragment.kt

@@ -1,18 +0,0 @@
-package com.luojigou.product.xiaodou.connect
-
-import android.os.Bundle
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import androidx.fragment.app.Fragment
-import com.luojigou.product.R
-
-class XDConnectNotFoundFragment : Fragment() {
-    override fun onCreateView(
-        inflater: LayoutInflater,
-        container: ViewGroup?,
-        savedInstanceState: Bundle?
-    ): View? {
-        return inflater.inflate(R.layout.fragment_connect_not_found, container, false)
-    }
-}

+ 0 - 18
xiaodou/src/main/java/com/luojigou/product/xiaodou/connect/XDConnectPasswordErrorFragment.kt

@@ -1,18 +0,0 @@
-package com.luojigou.product.xiaodou.connect
-
-import android.os.Bundle
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import androidx.fragment.app.Fragment
-import com.luojigou.product.R
-
-class XDConnectPasswordErrorFragment : Fragment() {
-    override fun onCreateView(
-        inflater: LayoutInflater,
-        container: ViewGroup?,
-        savedInstanceState: Bundle?
-    ): View? {
-        return inflater.inflate(R.layout.fragment_connect_password_error, container, false)
-    }
-}

+ 0 - 18
xiaodou/src/main/java/com/luojigou/product/xiaodou/connect/XDConnectTimeoutFragment.kt

@@ -1,18 +0,0 @@
-package com.luojigou.product.xiaodou.connect
-
-import android.os.Bundle
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import androidx.fragment.app.Fragment
-import com.luojigou.product.R
-
-class XDConnectTimeoutFragment : Fragment() {
-    override fun onCreateView(
-        inflater: LayoutInflater,
-        container: ViewGroup?,
-        savedInstanceState: Bundle?
-    ): View? {
-        return inflater.inflate(R.layout.fragment_connect_timeout, container, false)
-    }
-}

+ 47 - 25
xiaodou/src/main/res/layout/fragment_connect_fail.xml

@@ -1,31 +1,53 @@
 <?xml version="1.0" encoding="utf-8"?>
-<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    xmlns:app="http://schemas.android.com/apk/res-auto">
+    android:orientation="vertical">
 
-    <ImageView
-        android:id="@+id/pb_connecting"
-        android:layout_width="320dp"
-        android:layout_height="400dp"
-        android:paddingLeft="140dp"
-        android:paddingTop="180dp"
-        android:paddingRight="140dp"
-        android:paddingBottom="180dp"
-        android:src="@android:drawable/stat_notify_error"
-        android:background="@android:color/holo_red_dark"
-        app:layout_constraintBottom_toBottomOf="parent"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintRight_toRightOf="parent"
-        app:layout_constraintTop_toTopOf="parent" />
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1"
+        android:orientation="vertical">
 
-    <TextView
-        android:id="@+id/tv_connecting"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:text="连接失败"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintRight_toRightOf="parent"
-        app:layout_constraintTop_toBottomOf="@id/pb_connecting" />
+        <View
+            android:layout_width="match_parent"
+            android:layout_height="48dp" />
+
+        <TextView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginVertical="8dp"
+            android:gravity="center"
+            android:text="配置失败"
+            android:textFontWeight="600"
+            android:textSize="14pt" />
+
+        <ImageView
+            android:layout_width="240dp"
+            android:layout_height="0dp"
+            android:layout_gravity="center"
+            android:layout_weight="1"
+            android:scaleType="fitCenter"
+            android:src="@mipmap/failure" />
 
-</androidx.constraintlayout.widget.ConstraintLayout>
+        <TextView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:lineHeight="18dp"
+            android:paddingHorizontal="20dp"
+            android:text="可能的原因:\n1. 配置的WIFI网络不存在\n2. 配置的WIFI密码有错误\n3. 选择配置网络的设备有误\n"
+            android:textSize="14dp" />
+
+        <View
+            android:layout_width="match_parent"
+            android:layout_height="64dp" />
+    </LinearLayout>
+
+    <Button
+        android:id="@+id/btn_intro_request"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_margin="16dp"
+        android:text="重新设置" />
+</LinearLayout>

BIN
xiaodou/src/main/res/mipmap/failure.png