diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/base/ui/BaseActivity.java b/app/src/main/java/cc/niushuai/project/devcontrol/base/ui/BaseActivity.java index 33bf599..33aca8c 100644 --- a/app/src/main/java/cc/niushuai/project/devcontrol/base/ui/BaseActivity.java +++ b/app/src/main/java/cc/niushuai/project/devcontrol/base/ui/BaseActivity.java @@ -1,5 +1,10 @@ package cc.niushuai.project.devcontrol.base.ui; +import android.view.View; +import android.view.ViewGroup; +import android.widget.RelativeLayout; +import android.widget.TextView; + import androidx.appcompat.app.AppCompatActivity; import java.util.Map; @@ -8,6 +13,8 @@ import cc.niushuai.project.devcontrol.R; import cc.niushuai.project.devcontrol.base.entity.device.DeviceInfo; import cc.niushuai.project.devcontrol.base.util.ActivityUtil; import cc.niushuai.project.devcontrol.base.util.Keys; +import cc.niushuai.project.devcontrol.base.util.UiUtil; +import cn.hutool.core.util.StrUtil; /** * Activity基类 @@ -31,6 +38,30 @@ public abstract class BaseActivity extends AppCompatActivity { */ protected abstract void init(); + /** + * 设置title + * + * @author niushuai + * @date: 2022/10/20 10:13 + */ + protected void setTitle(String title, String subTitle) { + // 标题名称 + TextView titleTextView = findViewById(R.id.activity_title_name); + titleTextView.setText(title); + + // 副标题名称 + TextView descTextView = findViewById(R.id.activity_title_description); + if (StrUtil.isNotEmpty(subTitle)) { + descTextView.setText(subTitle); + } else { + // 不显示副标题 + descTextView.setVisibility(View.GONE); + + // 主标题 修改高度为50dp + titleTextView.getLayoutParams().height = UiUtil.dip2px(this, 50); + } + } + /** * 监听器事件统一设置入口 * diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/base/util/UiUtil.java b/app/src/main/java/cc/niushuai/project/devcontrol/base/util/UiUtil.java new file mode 100644 index 0000000..0259371 --- /dev/null +++ b/app/src/main/java/cc/niushuai/project/devcontrol/base/util/UiUtil.java @@ -0,0 +1,14 @@ +package cc.niushuai.project.devcontrol.base.util; + +import android.content.Context; +import android.content.res.Resources; +import android.util.TypedValue; + +public class UiUtil { + + public static int dip2px(Context context, float dipValue) { + Resources r = context.getResources(); + return (int) TypedValue.applyDimension( + TypedValue.COMPLEX_UNIT_DIP, dipValue, r.getDisplayMetrics()); + } +} diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchActivity.java b/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchActivity.java index 411cd59..864f324 100644 --- a/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchActivity.java +++ b/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchActivity.java @@ -44,21 +44,12 @@ public class PowerSwitchActivity extends BaseActivity { @Override protected void init() { - DeviceInfo data = GlobalVariables.getDeviceInfo(getIntentDeviceId()); - if (null != data) { - this.device = data; - // 标题名称 - TextView titleTextView = findViewById(R.id.activity_title_name); - titleTextView.setText(device.getName()); - - // 副标题名称 - TextView descTextView = findViewById(R.id.activity_title_description); - descTextView.setText(device.getDescription()); - - // 开关底部的名称 - TextView contentTextTextView = findViewById(R.id.power_switch_activity_content_text); - contentTextTextView.setText(device.getName()); - } + this.device = GlobalVariables.getDeviceInfo(getIntentDeviceId()); + // 标题名称 + super.setTitle(this.device.getName(), this.device.getDescription()); + // 开关底部的名称 + TextView contentTextTextView = findViewById(R.id.power_switch_activity_content_text); + contentTextTextView.setText(device.getName()); } /** diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchSetActivity.java b/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchSetActivity.java index 57ee556..b4519e0 100644 --- a/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchSetActivity.java +++ b/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchSetActivity.java @@ -1,13 +1,16 @@ package cc.niushuai.project.devcontrol.ui.powerswitch; import android.os.Bundle; +import android.view.ViewGroup; +import cc.niushuai.project.devcontrol.R; import cc.niushuai.project.devcontrol.base.entity.device.DeviceInfo; import cc.niushuai.project.devcontrol.base.ui.BaseActivity; import cc.niushuai.project.devcontrol.base.util.GlobalVariables; import cc.niushuai.project.devcontrol.base.util.Keys; import cc.niushuai.project.devcontrol.databinding.ActivityPowerSwitchBinding; import cc.niushuai.project.devcontrol.databinding.ActivityPowerSwitchSetBinding; +import cn.hutool.core.util.StrUtil; public class PowerSwitchSetActivity extends BaseActivity { @@ -20,10 +23,19 @@ public class PowerSwitchSetActivity extends BaseActivity { binding = ActivityPowerSwitchSetBinding.inflate(getLayoutInflater()); setContentView(binding.getRoot()); + + this.init(); + this.addListener(); } @Override protected void init() { - device = GlobalVariables.getDeviceInfo(getIntentDeviceId()); + this.device = GlobalVariables.getDeviceInfo(getIntentDeviceId()); + super.setTitle(getString(R.string.set), StrUtil.EMPTY); + } + + @Override + protected void addListener() { + } } \ No newline at end of file diff --git a/app/src/main/res/drawable/divider.xml b/app/src/main/res/drawable/divider.xml new file mode 100644 index 0000000..93f9d9c --- /dev/null +++ b/app/src/main/res/drawable/divider.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_next.xml b/app/src/main/res/drawable/ic_next.xml new file mode 100644 index 0000000..77487bb --- /dev/null +++ b/app/src/main/res/drawable/ic_next.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_next_16.xml b/app/src/main/res/drawable/ic_next_16.xml new file mode 100644 index 0000000..c020d02 --- /dev/null +++ b/app/src/main/res/drawable/ic_next_16.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_power_switch_set.xml b/app/src/main/res/layout/activity_power_switch_set.xml index 95294bd..530fe1c 100644 --- a/app/src/main/res/layout/activity_power_switch_set.xml +++ b/app/src/main/res/layout/activity_power_switch_set.xml @@ -4,11 +4,107 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:background="@color/main_bg_color" tools:context=".ui.powerswitch.PowerSwitchSetActivity"> + tools:layout_editor_absoluteX="0dp" + tools:layout_editor_absoluteY="0dp"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/ids.xml b/app/src/main/res/values/ids.xml index 8fbbd7f..628da80 100644 --- a/app/src/main/res/values/ids.xml +++ b/app/src/main/res/values/ids.xml @@ -2,11 +2,13 @@ + + @@ -34,6 +36,24 @@ + + + + + + + + + + + + + + + + + + \ 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 9fa1160..a9e0070 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,6 +1,16 @@ 终端控制器 + + + 菜单 + 设备 + 设置 + 日志 + 确定 + 取消 + + Hello blank fragment Hello blank textview 1 @@ -16,4 +26,13 @@ 日志 设置 + + + + + 更换图标 + 参数设置 + 日志 + + \ No newline at end of file diff --git a/iconfront/下一步.svg b/iconfront/下一步.svg new file mode 100644 index 0000000..bdca84d --- /dev/null +++ b/iconfront/下一步.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/iconfront/下一步_16.svg b/iconfront/下一步_16.svg new file mode 100644 index 0000000..f387b33 --- /dev/null +++ b/iconfront/下一步_16.svg @@ -0,0 +1 @@ + \ No newline at end of file