From 557f401aa757594a5f84795ef32a29acbd801f34 Mon Sep 17 00:00:00 2001 From: xiaowusky <chenyangyang3858@dingtalk.com> Date: Thu, 23 Nov 2023 10:13:44 +0800 Subject: [PATCH] =?UTF-8?q?desc:=E6=B0=94=E6=B3=B5=E8=BD=AC=E9=80=9F?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=20TODO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 4 + .../watcher/ui/SettingActivity.kt | 3 + .../watcher/ui/SpeedSettingActivity.kt | 61 +++ app/src/main/res/layout/activity_setting.xml | 506 +++++++++--------- .../res/layout/activity_speed_setting.xml | 63 +++ app/src/main/res/values/strings.xml | 1 + 6 files changed, 399 insertions(+), 239 deletions(-) create mode 100644 app/src/main/java/com/yinuo/safetywatcher/watcher/ui/SpeedSettingActivity.kt create mode 100644 app/src/main/res/layout/activity_speed_setting.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5ff7689..99c1af4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -98,6 +98,10 @@ android:name=".watcher.ui.LightSettingActivity" android:exported="false" android:screenOrientation="landscape" /> + <activity + android:name=".watcher.ui.SpeedSettingActivity" + android:exported="false" + android:screenOrientation="landscape" /> <activity android:name=".watcher.ui.SensorThresholdSetActivity" android:exported="false" diff --git a/app/src/main/java/com/yinuo/safetywatcher/watcher/ui/SettingActivity.kt b/app/src/main/java/com/yinuo/safetywatcher/watcher/ui/SettingActivity.kt index 2e1af4b..f7a639c 100644 --- a/app/src/main/java/com/yinuo/safetywatcher/watcher/ui/SettingActivity.kt +++ b/app/src/main/java/com/yinuo/safetywatcher/watcher/ui/SettingActivity.kt @@ -49,6 +49,9 @@ class SettingActivity : NoOptionsActivity() { itemSensor.setOnClickListener { startActivity(Intent(this@SettingActivity, SensorActivity::class.java)) } + itemSpeed.setOnClickListener { + startActivity(Intent(this@SettingActivity, SpeedSettingActivity::class.java)) + } itemCloud.setOnClickListener { startActivity(Intent(this@SettingActivity, CloudActivity::class.java)) } diff --git a/app/src/main/java/com/yinuo/safetywatcher/watcher/ui/SpeedSettingActivity.kt b/app/src/main/java/com/yinuo/safetywatcher/watcher/ui/SpeedSettingActivity.kt new file mode 100644 index 0000000..222b46b --- /dev/null +++ b/app/src/main/java/com/yinuo/safetywatcher/watcher/ui/SpeedSettingActivity.kt @@ -0,0 +1,61 @@ +package com.yinuo.safetywatcher.watcher.ui + +import android.view.View +import android.widget.SeekBar +import android.widget.SeekBar.OnSeekBarChangeListener +import com.yinuo.safetywatcher.R +import com.yinuo.safetywatcher.databinding.ActivitySpeedSettingBinding +import com.yinuo.safetywatcher.watcher.base.NoOptionsActivity + +class SpeedSettingActivity : NoOptionsActivity() { + + private val mBinding by lazy { + ActivitySpeedSettingBinding.inflate(layoutInflater) + } + + override fun getTopBarTitle(): String? { + return getString(R.string.speed_setting) + } + + override fun generateContentView(): View { + return mBinding.root + } + + override fun initView() { + val initLight = 0 + mBinding.sbSpeed.progress = initLight + mBinding.tvSpeed.text = getShowPercent(initLight) + mBinding.sbSpeed.setOnSeekBarChangeListener(object : OnSeekBarChangeListener { + override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) { + mBinding.tvSpeed.text = getShowPercent(p1) + } + + override fun onStartTrackingTouch(p0: SeekBar?) { + } + + override fun onStopTrackingTouch(p0: SeekBar?) { + } + }) + mBinding.sbSpeed.keyProgressIncrement = 1 + + mBinding.tvCancel.setOnClickListener { + onBackPressed() + } + mBinding.tvConfirm.setOnClickListener { + setSpeed() + onBackPressed() + } + } + + /** + * 设置转速 + */ + private fun setSpeed() { + TODO("Not yet implemented") + } + + private fun getShowPercent(initLight: Int): CharSequence? { + val percent = (initLight/255f * 100).toInt() + return "$percent%" + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_setting.xml b/app/src/main/res/layout/activity_setting.xml index f35ed09..c2b3a49 100644 --- a/app/src/main/res/layout/activity_setting.xml +++ b/app/src/main/res/layout/activity_setting.xml @@ -1,255 +1,283 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" - tools:ignore="MissingDefaultResource"> + android:layout_height="match_parent"> <LinearLayout - android:id="@+id/item_time" android:layout_width="match_parent" - android:layout_height="@dimen/_108dp" - android:gravity="center_vertical" - android:orientation="horizontal" - android:focusable="true" - android:paddingStart="@dimen/_121dp"> - - <ImageView - android:layout_width="@dimen/_32dp" - android:layout_height="@dimen/_32dp" - android:src="@mipmap/ic_time" /> - - <TextView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginStart="@dimen/_21dp" - android:text="@string/time_setting" - android:textColor="@color/white" - android:textSize="@dimen/_36dp" /> - </LinearLayout> - - <View - android:layout_width="match_parent" - android:layout_height="@dimen/_2dp" - android:background="@color/_242f4d" /> - - <LinearLayout - android:id="@+id/item_light" - android:layout_width="match_parent" - android:layout_height="@dimen/_108dp" - android:focusable="true" - android:gravity="center_vertical" - android:orientation="horizontal" - android:paddingStart="@dimen/_121dp"> - - <ImageView - android:layout_width="@dimen/_32dp" - android:layout_height="@dimen/_32dp" - android:src="@mipmap/ic_sun" /> - - <TextView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginStart="@dimen/_21dp" - android:text="@string/light_setting" - android:textColor="@color/white" - android:textSize="@dimen/_36dp" /> - </LinearLayout> - - <View - android:layout_width="match_parent" - android:layout_height="@dimen/_2dp" - android:background="@color/_242f4d" /> - - <LinearLayout - android:id="@+id/item_query" - android:layout_width="match_parent" - android:layout_height="@dimen/_108dp" - android:focusable="true" - android:gravity="center_vertical" - android:orientation="horizontal" - android:paddingStart="@dimen/_121dp"> - - <ImageView - android:layout_width="@dimen/_32dp" - android:layout_height="@dimen/_32dp" - android:src="@mipmap/ic_query" /> - - <TextView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginStart="@dimen/_21dp" - android:text="@string/query_data" - android:textColor="@color/white" - android:textSize="@dimen/_36dp" /> - </LinearLayout> - - <View - android:layout_width="match_parent" - android:layout_height="@dimen/_2dp" - android:background="@color/_242f4d" /> + android:layout_height="wrap_content" + android:orientation="vertical" + tools:ignore="MissingDefaultResource"> - <LinearLayout - android:id="@+id/item_wraning" - android:layout_width="match_parent" - android:layout_height="@dimen/_108dp" - android:focusable="true" - android:gravity="center_vertical" - android:orientation="horizontal" - android:paddingStart="@dimen/_121dp"> - - <ImageView - android:layout_width="@dimen/_32dp" - android:layout_height="@dimen/_32dp" - android:src="@mipmap/ic_wraning" /> - - <TextView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginStart="@dimen/_21dp" - android:text="@string/warn_data" - android:textColor="@color/white" - android:textSize="@dimen/_36dp" /> - </LinearLayout> - - <View - android:layout_width="match_parent" - android:layout_height="@dimen/_2dp" - android:background="@color/_242f4d" /> - - <LinearLayout - android:id="@+id/item_video" - android:layout_width="match_parent" - android:layout_height="@dimen/_108dp" - android:focusable="true" - android:gravity="center_vertical" - android:orientation="horizontal" - android:paddingStart="@dimen/_121dp"> - - <ImageView - android:layout_width="@dimen/_32dp" - android:layout_height="@dimen/_32dp" - android:src="@mipmap/ic_video" /> - - <TextView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginStart="@dimen/_21dp" - android:text="@string/history_video" - android:textColor="@color/white" - android:textSize="@dimen/_36dp" /> - </LinearLayout> + <LinearLayout + android:id="@+id/item_time" + android:layout_width="match_parent" + android:layout_height="@dimen/_108dp" + android:focusable="true" + android:gravity="center_vertical" + android:orientation="horizontal" + android:paddingStart="@dimen/_121dp"> + + <ImageView + android:layout_width="@dimen/_32dp" + android:layout_height="@dimen/_32dp" + android:src="@mipmap/ic_time" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/_21dp" + android:text="@string/time_setting" + android:textColor="@color/white" + android:textSize="@dimen/_36dp" /> + </LinearLayout> + + <View + android:layout_width="match_parent" + android:layout_height="@dimen/_2dp" + android:background="@color/_242f4d" /> - <View - android:layout_width="match_parent" - android:layout_height="@dimen/_2dp" - android:background="@color/_242f4d" /> + <LinearLayout + android:id="@+id/item_light" + android:layout_width="match_parent" + android:layout_height="@dimen/_108dp" + android:focusable="true" + android:gravity="center_vertical" + android:orientation="horizontal" + android:paddingStart="@dimen/_121dp"> + + <ImageView + android:layout_width="@dimen/_32dp" + android:layout_height="@dimen/_32dp" + android:src="@mipmap/ic_sun" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/_21dp" + android:text="@string/light_setting" + android:textColor="@color/white" + android:textSize="@dimen/_36dp" /> + </LinearLayout> + + <View + android:layout_width="match_parent" + android:layout_height="@dimen/_2dp" + android:background="@color/_242f4d" /> - <LinearLayout - android:id="@+id/item_sensor" - android:layout_width="match_parent" - android:layout_height="@dimen/_108dp" - android:focusable="true" - android:gravity="center_vertical" - android:orientation="horizontal" - android:paddingStart="@dimen/_121dp"> - - <ImageView - android:layout_width="@dimen/_32dp" - android:layout_height="@dimen/_32dp" - android:src="@mipmap/ic_sensor" /> - - <TextView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginStart="@dimen/_21dp" - android:text="@string/sensor" - android:textColor="@color/white" - android:textSize="@dimen/_36dp" /> - </LinearLayout> + <LinearLayout + android:id="@+id/item_query" + android:layout_width="match_parent" + android:layout_height="@dimen/_108dp" + android:focusable="true" + android:gravity="center_vertical" + android:orientation="horizontal" + android:paddingStart="@dimen/_121dp"> + + <ImageView + android:layout_width="@dimen/_32dp" + android:layout_height="@dimen/_32dp" + android:src="@mipmap/ic_query" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/_21dp" + android:text="@string/query_data" + android:textColor="@color/white" + android:textSize="@dimen/_36dp" /> + </LinearLayout> + + <View + android:layout_width="match_parent" + android:layout_height="@dimen/_2dp" + android:background="@color/_242f4d" /> - <View - android:layout_width="match_parent" - android:layout_height="@dimen/_2dp" - android:background="@color/_242f4d" /> + <LinearLayout + android:id="@+id/item_wraning" + android:layout_width="match_parent" + android:layout_height="@dimen/_108dp" + android:focusable="true" + android:gravity="center_vertical" + android:orientation="horizontal" + android:paddingStart="@dimen/_121dp"> + + <ImageView + android:layout_width="@dimen/_32dp" + android:layout_height="@dimen/_32dp" + android:src="@mipmap/ic_wraning" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/_21dp" + android:text="@string/warn_data" + android:textColor="@color/white" + android:textSize="@dimen/_36dp" /> + </LinearLayout> + + <View + android:layout_width="match_parent" + android:layout_height="@dimen/_2dp" + android:background="@color/_242f4d" /> - <LinearLayout - android:id="@+id/item_cloud" - android:layout_width="match_parent" - android:layout_height="@dimen/_108dp" - android:focusable="true" - android:gravity="center_vertical" - android:orientation="horizontal" - android:paddingStart="@dimen/_121dp"> - - <ImageView - android:layout_width="@dimen/_32dp" - android:layout_height="@dimen/_32dp" - android:src="@mipmap/ic_cloud" /> - - <TextView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginStart="@dimen/_21dp" - android:text="@string/cloud" - android:textColor="@color/white" - android:textSize="@dimen/_36dp" /> - </LinearLayout> + <LinearLayout + android:id="@+id/item_video" + android:layout_width="match_parent" + android:layout_height="@dimen/_108dp" + android:focusable="true" + android:gravity="center_vertical" + android:orientation="horizontal" + android:paddingStart="@dimen/_121dp"> + + <ImageView + android:layout_width="@dimen/_32dp" + android:layout_height="@dimen/_32dp" + android:src="@mipmap/ic_video" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/_21dp" + android:text="@string/history_video" + android:textColor="@color/white" + android:textSize="@dimen/_36dp" /> + </LinearLayout> + + <View + android:layout_width="match_parent" + android:layout_height="@dimen/_2dp" + android:background="@color/_242f4d" /> - <View - android:layout_width="match_parent" - android:layout_height="@dimen/_2dp" - android:background="@color/_242f4d" /> + <LinearLayout + android:id="@+id/item_sensor" + android:layout_width="match_parent" + android:layout_height="@dimen/_108dp" + android:focusable="true" + android:gravity="center_vertical" + android:orientation="horizontal" + android:paddingStart="@dimen/_121dp"> + + <ImageView + android:layout_width="@dimen/_32dp" + android:layout_height="@dimen/_32dp" + android:src="@mipmap/ic_sensor" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/_21dp" + android:text="@string/sensor" + android:textColor="@color/white" + android:textSize="@dimen/_36dp" /> + </LinearLayout> + + <LinearLayout + android:id="@+id/item_speed" + android:layout_width="match_parent" + android:layout_height="@dimen/_108dp" + android:focusable="true" + android:gravity="center_vertical" + android:orientation="horizontal" + android:paddingStart="@dimen/_121dp"> + + <ImageView + android:layout_width="@dimen/_32dp" + android:layout_height="@dimen/_32dp" + android:src="@mipmap/ic_sensor" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/_21dp" + android:text="@string/speed_setting" + android:textColor="@color/white" + android:textSize="@dimen/_36dp" /> + </LinearLayout> + + <View + android:layout_width="match_parent" + android:layout_height="@dimen/_2dp" + android:background="@color/_242f4d" /> - <LinearLayout - android:id="@+id/item_net" - android:layout_width="match_parent" - android:layout_height="@dimen/_108dp" - android:focusable="true" - android:gravity="center_vertical" - android:orientation="horizontal" - android:paddingStart="@dimen/_121dp"> - - <ImageView - android:layout_width="@dimen/_32dp" - android:layout_height="@dimen/_32dp" - android:src="@mipmap/ic_net" /> - - <TextView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginStart="@dimen/_21dp" - android:text="@string/net_setting" - android:textColor="@color/white" - android:textSize="@dimen/_36dp" /> - </LinearLayout> + <LinearLayout + android:id="@+id/item_cloud" + android:layout_width="match_parent" + android:layout_height="@dimen/_108dp" + android:focusable="true" + android:gravity="center_vertical" + android:orientation="horizontal" + android:paddingStart="@dimen/_121dp"> + + <ImageView + android:layout_width="@dimen/_32dp" + android:layout_height="@dimen/_32dp" + android:src="@mipmap/ic_cloud" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/_21dp" + android:text="@string/cloud" + android:textColor="@color/white" + android:textSize="@dimen/_36dp" /> + </LinearLayout> + + <View + android:layout_width="match_parent" + android:layout_height="@dimen/_2dp" + android:background="@color/_242f4d" /> - <View - android:layout_width="match_parent" - android:layout_height="@dimen/_2dp" - android:background="@color/_242f4d" /> + <LinearLayout + android:id="@+id/item_net" + android:layout_width="match_parent" + android:layout_height="@dimen/_108dp" + android:focusable="true" + android:gravity="center_vertical" + android:orientation="horizontal" + android:paddingStart="@dimen/_121dp"> + + <ImageView + android:layout_width="@dimen/_32dp" + android:layout_height="@dimen/_32dp" + android:src="@mipmap/ic_net" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/_21dp" + android:text="@string/net_setting" + android:textColor="@color/white" + android:textSize="@dimen/_36dp" /> + </LinearLayout> + + <View + android:layout_width="match_parent" + android:layout_height="@dimen/_2dp" + android:background="@color/_242f4d" /> - <LinearLayout - android:id="@+id/item_recovery" - android:layout_width="match_parent" - android:layout_height="@dimen/_108dp" - android:focusable="true" - android:gravity="center_vertical" - android:orientation="horizontal" - android:paddingStart="@dimen/_121dp"> - - <ImageView - android:layout_width="@dimen/_32dp" - android:layout_height="@dimen/_32dp" - android:src="@mipmap/ic_recovery" /> - - <TextView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginStart="@dimen/_21dp" - android:text="@string/recovery_setting" - android:textColor="@color/white" - android:textSize="@dimen/_36dp" /> + <LinearLayout + android:id="@+id/item_recovery" + android:layout_width="match_parent" + android:layout_height="@dimen/_108dp" + android:focusable="true" + android:gravity="center_vertical" + android:orientation="horizontal" + android:paddingStart="@dimen/_121dp"> + + <ImageView + android:layout_width="@dimen/_32dp" + android:layout_height="@dimen/_32dp" + android:src="@mipmap/ic_recovery" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/_21dp" + android:text="@string/recovery_setting" + android:textColor="@color/white" + android:textSize="@dimen/_36dp" /> + </LinearLayout> </LinearLayout> -</LinearLayout> \ No newline at end of file +</ScrollView> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_speed_setting.xml b/app/src/main/res/layout/activity_speed_setting.xml new file mode 100644 index 0000000..5bde66d --- /dev/null +++ b/app/src/main/res/layout/activity_speed_setting.xml @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="center_horizontal" + android:orientation="vertical"> + + <RelativeLayout + android:layout_width="@dimen/_960dp" + android:layout_height="@dimen/_511dp" + android:layout_marginTop="@dimen/_201dp" + android:background="@drawable/warn_setting_btn_bg"> + + <SeekBar + android:id="@+id/sb_speed" + style="@style/LightSeekbarStyle" + android:focusable="true" + android:layout_width="@dimen/_630dp" + android:layout_height="@dimen/_100dp" + android:layout_marginStart="@dimen/_140dp" + android:layout_marginTop="@dimen/_160dp" + android:max="100" + android:min="0" + android:padding="0dp" + android:progress="20" /> + + <TextView + android:id="@+id/tv_speed" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentEnd="true" + android:layout_marginTop="@dimen/_185dp" + android:layout_marginEnd="@dimen/_121dp" + android:text="55%" + android:textColor="@color/white" + android:textSize="@dimen/_36dp" /> + + <TextView + android:id="@+id/tv_cancel" + android:layout_width="@dimen/_480dp" + android:layout_height="@dimen/_81dp" + android:layout_alignParentBottom="true" + android:background="@drawable/cancel_btn_bg" + android:gravity="center" + android:text="@string/cancel" + android:focusable="true" + android:textColor="@color/white_30" + android:textSize="@dimen/_36dp" /> + + <TextView + android:id="@+id/tv_confirm" + android:layout_width="@dimen/_480dp" + android:layout_height="@dimen/_81dp" + android:layout_alignParentEnd="true" + android:layout_alignParentBottom="true" + android:background="@drawable/confirm_btn_bg" + android:gravity="center" + android:text="@string/confirm" + android:focusable="true" + android:textColor="@color/white" + android:textSize="@dimen/_36dp" /> + </RelativeLayout> +</LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c67409f..067fd35 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -11,6 +11,7 @@ <string name="warn_data">报警数据</string> <string name="history_video">历史视频</string> <string name="sensor">传感器</string> + <string name="speed_setting">气泵转速设置</string> <string name="sensor_data">传感器数据详情</string> <string name="sensor_setting">传感器设置</string> <string name="sensor_threshold_setting">传感器阈值设置</string>