From cdc66bf56db8ac342bd454f0b6f797c0a0e79597 Mon Sep 17 00:00:00 2001 From: yuqian Date: Fri, 29 Aug 2025 15:29:30 +0800 Subject: [PATCH] add network --- .idea/.gitignore | 3 + .idea/AndroidProjectSystem.xml | 6 + .idea/compiler.xml | 6 + .idea/deploymentTargetSelector.xml | 10 + .idea/gradle.xml | 19 + .idea/migrations.xml | 10 + .idea/misc.xml | 10 + .idea/runConfigurations.xml | 17 + .idea/vcs.xml | 6 + .../devcheck/custom/SignalStrengthView.kt | 66 + .../devcheck/dashboard/NetworkFragment.kt | 65 + .../devcheck/dialog/ShowLoadFragment.kt | 39 + .../device/devcheck/main/MainActivity.kt | 3 +- app/src/main/res/layout/fragment_network.xml | 1238 +++++++++++++++++ .../main/res/layout/fragment_show_load.xml | 45 + .../main/res/layout/fragment_system_show.xml | 171 ++- app/src/main/res/values/strings.xml | 67 + app/src/main/res/values/styles.xml | 19 + 18 files changed, 1724 insertions(+), 76 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/AndroidProjectSystem.xml create mode 100644 .idea/compiler.xml create mode 100644 .idea/deploymentTargetSelector.xml create mode 100644 .idea/gradle.xml create mode 100644 .idea/migrations.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/runConfigurations.xml create mode 100644 .idea/vcs.xml create mode 100644 app/src/main/java/com/tools/device/devcheck/custom/SignalStrengthView.kt create mode 100644 app/src/main/java/com/tools/device/devcheck/dashboard/NetworkFragment.kt create mode 100644 app/src/main/java/com/tools/device/devcheck/dialog/ShowLoadFragment.kt create mode 100644 app/src/main/res/layout/fragment_network.xml create mode 100644 app/src/main/res/layout/fragment_show_load.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/AndroidProjectSystem.xml b/.idea/AndroidProjectSystem.xml new file mode 100644 index 0000000..4a53bee --- /dev/null +++ b/.idea/AndroidProjectSystem.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..b86273d --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml new file mode 100644 index 0000000..b268ef3 --- /dev/null +++ b/.idea/deploymentTargetSelector.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..639c779 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/migrations.xml b/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..74dd639 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..16660f1 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/tools/device/devcheck/custom/SignalStrengthView.kt b/app/src/main/java/com/tools/device/devcheck/custom/SignalStrengthView.kt new file mode 100644 index 0000000..c6413f2 --- /dev/null +++ b/app/src/main/java/com/tools/device/devcheck/custom/SignalStrengthView.kt @@ -0,0 +1,66 @@ +package com.tools.device.devcheck.custom + +import android.content.Context +import android.graphics.Canvas +import android.graphics.Color +import android.graphics.Paint +import android.graphics.RectF +import android.util.AttributeSet +import android.view.View +import androidx.core.graphics.toColorInt + +class SignalStrengthView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : View(context, attrs, defStyleAttr) { + + private val barPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { + style = Paint.Style.FILL + } + + private val inactiveColor = "#eeeeee".toColorInt() + private val activeColor = "#1E8C29".toColorInt() + + private var strengthLevel: Int = 0 + private val maxBars = 5 + + // 设置信号强度 (0-5) + fun setStrength(level: Int) { + strengthLevel = level.coerceIn(0, maxBars) + invalidate() // 触发重绘 + } + + // 获取当前信号强度 + fun getStrength(): Int = strengthLevel + + override fun onDraw(canvas: Canvas) { + super.onDraw(canvas) + + val width = width.toFloat() + val height = height.toFloat() + + // 计算每个柱状条的宽度和间距 + val barWidth = width / (maxBars * 2 - 1) + val spacing = barWidth/4 + + // 绘制5个柱状条 + for (i in 0 until maxBars) { + // 确定柱状条的颜色 + val color = if (i < strengthLevel) activeColor else inactiveColor + barPaint.color = color + + // 计算柱状条的位置和高度 + val left = i * (barWidth + spacing) + val barHeight = height * (i + 1) / maxBars + val top = height - barHeight + val right = left + barWidth + val bottom = height + + // 绘制圆角矩形柱状条 + val rect = RectF(left, top, right, bottom) + val cornerRadius = barWidth / 4 + canvas.drawRoundRect(rect, cornerRadius, cornerRadius, barPaint) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/tools/device/devcheck/dashboard/NetworkFragment.kt b/app/src/main/java/com/tools/device/devcheck/dashboard/NetworkFragment.kt new file mode 100644 index 0000000..c905612 --- /dev/null +++ b/app/src/main/java/com/tools/device/devcheck/dashboard/NetworkFragment.kt @@ -0,0 +1,65 @@ +package com.tools.device.devcheck.dashboard + +import android.os.Bundle +import androidx.fragment.app.Fragment +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import com.tools.device.devcheck.R +import com.tools.device.devcheck.databinding.FragmentNetworkBinding +import com.tools.device.devcheck.dialog.ShowLoadFragment + +class NetworkFragment : Fragment() { + + private var status=1//0:未连接,1:已连接 +private lateinit var binding:FragmentNetworkBinding + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + } + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + // Inflate the layout for this fragment + binding = FragmentNetworkBinding.inflate(inflater, container, false) + binding.signalStrength.setStrength(4) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + if(status==0){ + binding.noConnect.visibility=View.VISIBLE + binding.connectData.visibility=View.GONE + binding.wifiDev1.text="Disconnected" + binding.wifiList.visibility=View.GONE + binding.llPubShow.visibility=View.GONE + }else{ + binding.noConnect.visibility=View.GONE + binding.connectData.visibility=View.VISIBLE + binding.wifiDev1.text="Connected" + binding.wifiList.visibility=View.VISIBLE + binding.llPubShow.visibility=View.VISIBLE + } + binding.pubShow.setOnClickListener{ + val tag = "showLoadFragment" + if (requireActivity().supportFragmentManager.findFragmentByTag(tag) == null) { + val showLoadFragment = ShowLoadFragment() + showLoadFragment.show(requireActivity().supportFragmentManager, tag) + } + } + } + + companion object { + + @JvmStatic + fun newInstance() = + NetworkFragment().apply { + arguments = Bundle().apply { + + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/tools/device/devcheck/dialog/ShowLoadFragment.kt b/app/src/main/java/com/tools/device/devcheck/dialog/ShowLoadFragment.kt new file mode 100644 index 0000000..a0c8d29 --- /dev/null +++ b/app/src/main/java/com/tools/device/devcheck/dialog/ShowLoadFragment.kt @@ -0,0 +1,39 @@ +package com.tools.device.devcheck.dialog + +import android.app.Dialog +import android.graphics.Color +import android.os.Bundle +import androidx.fragment.app.Fragment +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.core.graphics.drawable.toDrawable +import androidx.fragment.app.DialogFragment +import com.tools.device.devcheck.R +import com.tools.device.devcheck.databinding.FragmentShowLoadBinding + +class ShowLoadFragment : DialogFragment() { + private lateinit var binding:FragmentShowLoadBinding + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + binding = FragmentShowLoadBinding.inflate(inflater, container, false) + binding.ok.setOnClickListener{ + dismiss() + } + return binding.root + } + + override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { + val dialog=super.onCreateDialog(savedInstanceState) + // 设置宽度匹配父容器 + dialog.window?.apply { + setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) + setBackgroundDrawable(Color.TRANSPARENT.toDrawable()) + } + return dialog + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/tools/device/devcheck/main/MainActivity.kt b/app/src/main/java/com/tools/device/devcheck/main/MainActivity.kt index fb97329..59cb027 100644 --- a/app/src/main/java/com/tools/device/devcheck/main/MainActivity.kt +++ b/app/src/main/java/com/tools/device/devcheck/main/MainActivity.kt @@ -8,6 +8,7 @@ import com.google.android.material.tabs.TabLayoutMediator import com.tools.device.devcheck.base.BaseActivity import com.tools.device.devcheck.R import com.tools.device.devcheck.dashboard.DashboardFragment +import com.tools.device.devcheck.dashboard.NetworkFragment import com.tools.device.devcheck.dashboard.SystemShowFragment import com.tools.device.devcheck.databinding.ActivityMainBinding @@ -27,7 +28,7 @@ class MainActivity : BaseActivity() { DashboardFragment.newInstance(), SystemShowFragment.newInstance(), DashboardFragment.newInstance(), - DashboardFragment.newInstance(), + NetworkFragment.newInstance(), DashboardFragment.newInstance(), DashboardFragment.newInstance(), DashboardFragment.newInstance() diff --git a/app/src/main/res/layout/fragment_network.xml b/app/src/main/res/layout/fragment_network.xml new file mode 100644 index 0000000..d3e0a06 --- /dev/null +++ b/app/src/main/res/layout/fragment_network.xml @@ -0,0 +1,1238 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_show_load.xml b/app/src/main/res/layout/fragment_show_load.xml new file mode 100644 index 0000000..007fdea --- /dev/null +++ b/app/src/main/res/layout/fragment_show_load.xml @@ -0,0 +1,45 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_system_show.xml b/app/src/main/res/layout/fragment_system_show.xml index e15e2a4..1d8623c 100644 --- a/app/src/main/res/layout/fragment_system_show.xml +++ b/app/src/main/res/layout/fragment_system_show.xml @@ -32,7 +32,7 @@ style="@style/TextBig" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="设备" + android:text="@string/device" tools:ignore="RelativeOverlap" /> + + + + Cancel Settings + Device + Product + Model + Motherboard + Manufacturer + Baseband + Operating System + Android Version + API + Security Patch Level + Version Number + Fingerprint + Build Time + Initial Release + Architecture + Instruction Set Architecture + Treble + Root Access + Google Play Services + SSL Version + Language + Time Zone + USB Debugging + Kernel + DRM + ClearKey CDM + Vendor + Version + Widevine + Algorithm + Device ID + Security Level + Highest HDCP Level + Identifier + Google Services Framework ID + Connection + Hardware + DHCP + BSSID + Function + Connection Speed + Frequency + Frequency Band + Channel + Standard + DHCP Server + DHCP Lease Time + Gateway + Subnet Mask + DNS1 + DNS2 + Public IP + Show + ok + Mobile Data + Dual SIM dual standby + eSIM + SIM card 1 + SIM card 2 + Default value + Nation + Data + Voice + Short message + Roaming + Network type + Support \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index f7534ba..6b73515 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -60,4 +60,23 @@ @color/module_title_color + + + + + + + \ No newline at end of file