feat: 开关参数设置页面

This commit is contained in:
niushuai233 2022-10-20 14:36:08 +08:00
parent be9375f71c
commit 269c3433f4
8 changed files with 185 additions and 14 deletions

View File

@ -38,6 +38,12 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!--开关参数设置-->
<activity android:name=".ui.powerswitch.PowerSwitchSetParamActivity" android:exported="false">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -1,8 +1,6 @@
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;
@ -91,8 +89,14 @@ public abstract class BaseActivity extends AppCompatActivity {
* @author niushuai
* @date: 2022/10/19 14:47
*/
protected void activityButtonMoreSetClickListener(BaseActivity activity, Class<? extends BaseActivity> clazz, Map<String, String> withData) {
findViewById(R.id.activity_title_more_set).setOnClickListener(view -> ActivityUtil.startActivity(activity, clazz, withData));
protected void activityButtonMoreSetClickListener(boolean display, BaseActivity activity, Class<? extends BaseActivity> clazz, Map<String, String> withData) {
View moreSetView = findViewById(R.id.activity_title_more_set);
if (!display) {
moreSetView.setVisibility(View.GONE);
return;
}
moreSetView.setOnClickListener(view -> ActivityUtil.startActivity(activity, clazz, withData));
}
}

View File

@ -23,8 +23,6 @@ public class PowerSwitchActivity extends BaseActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 隐藏自带的标题栏
getSupportActionBar().hide();
binding = ActivityPowerSwitchBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
@ -69,7 +67,7 @@ public class PowerSwitchActivity extends BaseActivity {
// 标题栏 更多设置
HashMap<String, String> withData = new HashMap<>(1);
withData.put(Keys.ID, device.getId());
super.activityButtonMoreSetClickListener(this, PowerSwitchSetActivity.class, withData);
super.activityButtonMoreSetClickListener(true, this, PowerSwitchSetActivity.class, withData);
}

View File

@ -1,16 +1,17 @@
package cc.niushuai.project.devcontrol.ui.powerswitch;
import android.os.Bundle;
import android.view.ViewGroup;
import android.view.View;
import android.widget.Toast;
import java.util.HashMap;
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.ActivityUtil;
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 {
@ -19,7 +20,6 @@ public class PowerSwitchSetActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().hide();
binding = ActivityPowerSwitchSetBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
@ -31,11 +31,32 @@ public class PowerSwitchSetActivity extends BaseActivity {
@Override
protected void init() {
this.device = GlobalVariables.getDeviceInfo(getIntentDeviceId());
super.setTitle(getString(R.string.set), StrUtil.EMPTY);
super.setTitle(getString(R.string.set), null);
}
@Override
protected void addListener() {
super.activityButtonBackClickListener(this);
super.activityButtonMoreSetClickListener(false, null, null, null);
binding.powerSwitchSetActivityItemIconChangeOutside.setOnClickListener(this::outsideIconChangeClickListener);
binding.powerSwitchSetActivityItemParamSetOutside.setOnClickListener(this::outsideParamSetClickListener);
binding.powerSwitchSetActivityItemLogViewOutside.setOnClickListener(this::outsideLogViewClickListener);
}
private void outsideIconChangeClickListener(View view) {
Toast.makeText(this, "更换图标暂未实现哦", Toast.LENGTH_SHORT).show();
}
private void outsideParamSetClickListener(View view) {
HashMap<String, String> withData = new HashMap<>(1);
withData.put(Keys.ID, device.getId());
ActivityUtil.startActivity(this, PowerSwitchSetParamActivity.class, withData);
}
private void outsideLogViewClickListener(View view) {
Toast.makeText(this, "日志暂未实现哦", Toast.LENGTH_SHORT).show();
}
}

View File

@ -0,0 +1,52 @@
package cc.niushuai.project.devcontrol.ui.powerswitch;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import androidx.annotation.Nullable;
import cc.niushuai.project.devcontrol.R;
import cc.niushuai.project.devcontrol.base.ui.BaseActivity;
import cc.niushuai.project.devcontrol.base.util.GlobalVariables;
import cc.niushuai.project.devcontrol.databinding.ActivityPowerSwitchSetParamBinding;
public class PowerSwitchSetParamActivity extends BaseActivity {
private ActivityPowerSwitchSetParamBinding binding;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityPowerSwitchSetParamBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
this.init();
this.addListener();
}
@Override
protected void init() {
device = GlobalVariables.getDeviceInfo(getIntentDeviceId());
super.setTitle(getString(R.string.power_switch_set_paramSet), null);
}
@Override
protected void addListener() {
// 隐藏更多按钮
super.activityButtonBackClickListener(this);
super.activityButtonMoreSetClickListener(false, null, null, null);
// 保存监听事件
binding.powerSwitchSetActivityItemParamSetBtnSave.setOnClickListener(this::btnSaveParamClickListener);
}
private void btnSaveParamClickListener(View view) {
Toast.makeText(this, "已保存", Toast.LENGTH_SHORT).show();
}
}

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 填充的颜色 -->
<solid android:color="#0091EA" />
<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners android:radius="100dip" />
<!-- paddingButton里面的文字与Button边界的间隔 -->
<padding
android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp" />
</shape>

View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/activity_common_title" />
<LinearLayout
android:id="@+id/power_switch_set_activity_item_paramSet_linear1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="@id/activity_layout_title"
android:layout_margin="10dp">
<TextView
android:id="@id/power_switch_set_activity_item_paramSet_open_tv"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/power_switch_set_paramSet_open"
android:textSize="16dp" />
<EditText
android:id="@id/power_switch_set_activity_item_paramSet_open_ev"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="9" />
</LinearLayout>
<LinearLayout
android:id="@+id/power_switch_set_activity_item_paramSet_linear2"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="@id/power_switch_set_activity_item_paramSet_linear1"
android:layout_margin="10dp">
<TextView
android:id="@id/power_switch_set_activity_item_paramSet_close_tv"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/power_switch_set_paramSet_close"
android:textSize="16dp" />
<EditText
android:id="@id/power_switch_set_activity_item_paramSet_close_ev"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="9" />
</LinearLayout>
<Button
android:id="@id/power_switch_set_activity_item_paramSet_btn_save"
style="?android:borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/power_switch_set_activity_item_paramSet_linear2"
android:layout_marginLeft="30dp"
android:layout_marginTop="10dp"
android:layout_marginRight="30dp"
android:background="@drawable/shape_round"
android:text="@string/save"
android:textColor="@color/white"
android:textSize="16dp" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -10,5 +10,5 @@
<color name="gray">#FFAFAFAF</color>
<color name="main_bg_color">#F6F6F6</color>
<color name="empty">#00FF0000</color>
<color name="btn_green">#83FF4D</color>
<color name="btn_blue">#449EFF</color>
</resources>