Skip to content

Commit

Permalink
add: 增加设备zClock_Matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
a2633063 committed Dec 13, 2020
1 parent d7b51d6 commit 7d10e4e
Show file tree
Hide file tree
Showing 14 changed files with 1,586 additions and 16 deletions.
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@
android:name=".deviceItem.clock.ClockLinkActivity"
android:label="zClock配网"
android:screenOrientation="portrait" />
<activity
android:name=".deviceItem.clockMatrix.ClockMatrixLinkActivity"
android:label="zClock配网"
android:screenOrientation="portrait" />
<activity
android:name=".deviceItem.mops.MOPSLinkActivity"
android:label="zMOPS配网"
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/zyc/zcontrol/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import com.zyc.zcontrol.deviceItem.DeviceClass.DeviceA1;
import com.zyc.zcontrol.deviceItem.DeviceClass.DeviceButtonMate;
import com.zyc.zcontrol.deviceItem.DeviceClass.DeviceClock;
import com.zyc.zcontrol.deviceItem.DeviceClass.DeviceClockMatrix;
import com.zyc.zcontrol.deviceItem.DeviceClass.DeviceDC1;
import com.zyc.zcontrol.deviceItem.DeviceClass.DeviceM1;
import com.zyc.zcontrol.deviceItem.DeviceClass.DeviceMOPS;
Expand Down Expand Up @@ -1136,6 +1137,8 @@ private Device returnDeviceClass(String name, String mac, int type) {
return new DeviceClock(name, mac);
case Device.TYPE_MOPS:
return new DeviceMOPS(name, mac);
case Device.TYPE_CLOCK_MATRIX:
return new DeviceClockMatrix(name, mac);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public class Device {
public final static int TYPE_CLOCK = 6;
public final static int TYPE_MOPS = 7;
public final static int TYPE_RGBW = 8;
public final static int TYPE_COUNT = 9;
public final static int TYPE_CLOCK_MATRIX = 9;
public final static int TYPE_COUNT = 10;

//设备名称
public final static String[] TypeName = new String[]{
Expand All @@ -43,6 +44,7 @@ public class Device {
"zClock时钟", //6
"zMOPS插座", //7
"zRGBW灯", //8
"zClock点阵时钟", //9
};
//设备链接地址
public final static String[] TypeUri = new String[]{
Expand All @@ -55,6 +57,7 @@ public class Device {
"https://github.com/a2633063/zClock", //6
"https://github.com/a2633063/zMOPS", //7
"https://github.com/a2633063/zRGBW", //8
"https://github.com/a2633063/zClock_Matrix", //9
};
//设备图标
public final static @DrawableRes
Expand All @@ -67,7 +70,8 @@ public class Device {
R.drawable.device_icon_zs7,//5
R.drawable.device_icon_zclock,//6
R.drawable.device_icon_zmops,//7
R.drawable.device_icon_zrgbw,//4
R.drawable.device_icon_zrgbw,//8
R.drawable.device_icon_ongoing,//9
};

//设备对应配对页面
Expand All @@ -82,6 +86,7 @@ public class Device {
ClockLinkActivity.class,
MOPSLinkActivity.class,
null,
null,
};
//endregion

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.zyc.zcontrol.deviceItem.DeviceClass;

import android.preference.PreferenceFragment;

import com.zyc.zcontrol.deviceItem.clockMatrix.ClockMatrixFragment;
import com.zyc.zcontrol.deviceItem.clockMatrix.ClockMatrixSettingFragment;

import androidx.fragment.app.Fragment;

public class DeviceClockMatrix extends Device {

public DeviceClockMatrix(String name, String mac) {
super(TYPE_CLOCK_MATRIX, name, mac);
}

//region 必须重构的函数
public String[] getRecvMqttTopic() {
String[] topic = new String[3];
topic[0] = "device/zclock_matrix/" + getMac() + "/state";
topic[1] = "device/zclock_matrix/" + getMac() + "/sensor";
topic[2] = "device/zclock_matrix/" + getMac() + "/availability";
return topic;
}

public String getSendMqttTopic() {
return "device/zclock_matrix/" + getMac() + "/set";
}


Fragment fragment;
PreferenceFragment settingFragment;

public Fragment getFragment() {
if (fragment == null) {
fragment = new ClockMatrixFragment(this);
}
return fragment;
}

public PreferenceFragment getSettingFragment() {
if (settingFragment == null) {
settingFragment = new ClockMatrixSettingFragment(this);
}
return settingFragment;
}
//endregion


}
Original file line number Diff line number Diff line change
Expand Up @@ -180,24 +180,10 @@ public void onRefresh() {
}


// region 文本

private View.OnClickListener MainTextListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getContext(), ClockPlugActivity.class);
intent.putExtra("plug_name", ((TextView) v).getText());
intent.putExtra("mac", device.getMac());
intent.putExtra("plug_id", (v.getId()) % 4);
startActivity(intent);
}
};
//endregion
//endregion

void Send(String message) {
boolean udp = getActivity().getSharedPreferences("Setting_" + device.getMac(), 0).getBoolean("always_UDP", false);
boolean oldProtocol = getActivity().getSharedPreferences("Setting_" + device.getMac(), 0).getBoolean("old_protocol", false);

super.Send(udp, device.getSendMqttTopic(), message);
}
Expand Down
Loading

0 comments on commit 7d10e4e

Please sign in to comment.