Skip to content

Commit

Permalink
fix: 配合更新zDC1固件v1.0.0
Browse files Browse the repository at this point in the history
add: zRGBW测试部分
add:mqtt clientID可手动配置(v0.12.6增加)

版本v0.12.7
  • Loading branch information
a2633063 committed Jan 8, 2020
1 parent 6742596 commit f237549
Show file tree
Hide file tree
Showing 31 changed files with 2,366 additions and 63 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId "com.zyc.zcontrol"
minSdkVersion 19
targetSdkVersion 28
versionCode 25
versionName "v0.12.6"
versionCode 27
versionName "v0.12.7"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion app/release/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":25,"versionName":"v0.12.6","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":27,"versionName":"v0.12.7","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
<activity
android:name=".controlItem.m1.M1PlugActivity"
android:label="定时" />
<activity
android:name=".controlItem.rgbw.RGBWTaskActivity"
android:label="定时" />
<activity
android:name=".controlItem.tc1.TC1PlugActivity"
android:label="插口" />
Expand Down
32 changes: 15 additions & 17 deletions app/src/main/java/com/zyc/StaticVariable.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,36 @@

public class StaticVariable {
//静态变量
public final static int TYPE_UNKNOWN =-1;
public final static int TYPE_BUTTON_MATE=0;
public final static int TYPE_TC1=1;
public final static int TYPE_DC1=2;
public final static int TYPE_A1=3;
public final static int TYPE_M1=4;
// public final static int TYPE_BUTTON=5;
public final static int TYPE_RGB=5;
public final static int TYPE_CLOCK=6;
public final static int TYPE_COUNT=7;

public final static String TYPE_NAME[]={
public final static int TYPE_UNKNOWN = -1;
public final static int TYPE_BUTTON_MATE = 0;
public final static int TYPE_TC1 = 1;
public final static int TYPE_DC1 = 2;
public final static int TYPE_A1 = 3;
public final static int TYPE_M1 = 4;
// public final static int TYPE_BUTTON=5;
public final static int TYPE_RGBW = 5;
public final static int TYPE_CLOCK = 6;
public final static int TYPE_COUNT = 7;

public final static String TYPE_NAME[] = {
"按键伴侣",//0
"智能排插zTC1",//1
"智能排插zDC1", //2
"空气净化器zA1", //3
"空气检测仪zM1", //4
"RGB灯", //
"zRGBW灯", //5
"时钟", //
// "智能按键",//1
};

public final static @DrawableRes
int TYPE_ICON[]={
int TYPE_ICON[] = {
R.drawable.ic_filter_1_black_24dp,//0
R.drawable.ic_filter_2_black_24dp,//1
R.drawable.ic_filter_3_black_24dp,//2
R.drawable.ic_filter_4_black_24dp,//3
R.drawable.ic_filter_5_black_24dp,//4
R.drawable.ic_filter_9_plus_black_24dp,//4
R.drawable.ic_filter_6_black_24dp,//5
R.drawable.ic_filter_9_plus_black_24dp,//4
};


}
4 changes: 4 additions & 0 deletions app/src/main/java/com/zyc/zcontrol/DeviceItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.zyc.zcontrol.controlItem.buttonmate.ButtonMateFragment;
import com.zyc.zcontrol.controlItem.dc1.DC1Fragment;
import com.zyc.zcontrol.controlItem.m1.M1Fragment;
import com.zyc.zcontrol.controlItem.rgbw.RGBWFragment;
import com.zyc.zcontrol.controlItem.tc1.TC1Fragment;


Expand Down Expand Up @@ -65,6 +66,9 @@ private void init()
case StaticVariable.TYPE_M1:
fragment=new M1Fragment(name,mac);
break;
case StaticVariable.TYPE_RGBW:
fragment=new RGBWFragment(name,mac);
break;
}
if(fragment==null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.zyc.zcontrol.controlItem.buttonmate.ButtonMateSettingFragment;
import com.zyc.zcontrol.controlItem.dc1.DC1SettingFragment;
import com.zyc.zcontrol.controlItem.m1.M1SettingFragment;
import com.zyc.zcontrol.controlItem.rgbw.RGBWSettingFragment;
import com.zyc.zcontrol.controlItem.tc1.TC1SettingFragment;

public class SettingActivity extends AppCompatActivity {
Expand Down Expand Up @@ -63,6 +64,9 @@ protected void onCreate(Bundle savedInstanceState) {
case StaticVariable.TYPE_M1:
prefFragment = new M1SettingFragment(name, mac);
break;
case StaticVariable.TYPE_RGBW:
prefFragment = new RGBWSettingFragment(name, mac);
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.LinearInterpolator;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.SeekBar;
Expand All @@ -40,7 +39,6 @@

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import static android.content.Context.BIND_AUTO_CREATE;
Expand Down Expand Up @@ -164,7 +162,7 @@ public void onClick(View v) {
//endregion

//region 拖动条 处理viewpage/SwipeRefreshLayout滑动冲突事件
seekBar = view.findViewById(R.id.seekBar);
seekBar = view.findViewById(R.id.seekBarR);
//region 处理viewpage/SwipeRefreshLayout滑动冲突事件
seekBar.setOnTouchListener(new View.OnTouchListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public DC1Fragment(String name, String mac) {
public void handleMessage(Message msg) {// handler接收到消息后就会执行此方法
switch (msg.what) {
case 1:
handler.removeMessages(1);
Send("{\"mac\": \"" + device_mac + "\","
+ "\"lock\":null,"
+ "\"plug_0\" : {\"on\" : null,\"setting\":{\"name\":null}},"
Expand Down Expand Up @@ -286,9 +287,16 @@ public void onClick(DialogInterface dialogInterface, int i) {

//endregion
void Send(String message) {
if(mConnectService==null) return;
boolean b = getActivity().getSharedPreferences("Setting_" + device_mac, 0).getBoolean("always_UDP", false);
mConnectService.Send(b ? null : "device/zdc1/set", message);
if (mConnectService == null) return;
boolean udp = getActivity().getSharedPreferences("Setting_" + device_mac, 0).getBoolean("always_UDP", false);
boolean oldProtocol = getActivity().getSharedPreferences("Setting_" + device_mac, 0).getBoolean("old_protocol", false);

String topic = null;
if (!udp) {
if (oldProtocol) topic = "device/zdc1/set";
else topic = "device/zdc1/" + device_mac + "/set";
}
mConnectService.Send(topic, message);
}

//数据接收处理函数
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,16 @@ public void onClick(View v) {

//region 数据接收发送处理函数
void Send(String message) {
boolean b = getSharedPreferences("Setting_" + device_mac, 0).getBoolean("always_UDP", false);
mConnectService.Send(b ? null : "device/zdc1/set", message);
}
if (mConnectService == null) return;
boolean udp = getSharedPreferences("Setting_" + device_mac, 0).getBoolean("always_UDP", false);
boolean oldProtocol = getSharedPreferences("Setting_" + device_mac, 0).getBoolean("old_protocol", false);

String topic = null;
if (!udp) {
if (oldProtocol) topic = "device/zdc1/set";
else topic = "device/zdc1/" + device_mac + "/set";
}
mConnectService.Send(topic, message); }

void Receive(String ip, int port, String message) {
//TODO 数据接收处理
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ public void run() {
otaInfo = new DC1OTAInfo();
Message msg = new Message();
msg.what = 0;
String res=WebService.WebConnect("https://gitee.com/api/v5/repos/a2633063/zDC1_public/releases/latest");
String res=WebService.WebConnect("https://gitee.com/api/v5/repos/a2633063/zDC1/releases/latest");
if(res==null || res.length()<100)
res=WebService.WebConnect("https://gitee.com/api/v5/repos/zhangyichen/zDC1_public/releases/latest");
res=WebService.WebConnect("https://gitee.com/api/v5/repos/zhangyichen/zDC1/releases/latest");
msg.obj=res;
handler.sendMessageDelayed(msg, 0);// 执行耗时的方法之后发送消给handler
}
Expand Down Expand Up @@ -414,8 +414,16 @@ public void onClick(DialogInterface dialogInterface, int i) {
//endregion

void Send(String message) {
boolean b = getActivity().getSharedPreferences("Setting_" + device_mac, 0).getBoolean("always_UDP", false);
mConnectService.Send(b ? null : "device/zdc1/set", message);
if (mConnectService == null) return;
boolean udp = getActivity().getSharedPreferences("Setting_" + device_mac, 0).getBoolean("always_UDP", false);
boolean oldProtocol = getActivity().getSharedPreferences("Setting_" + device_mac, 0).getBoolean("old_protocol", false);

String topic = null;
if (!udp) {
if (oldProtocol) topic = "device/zdc1/set";
else topic = "device/zdc1/" + device_mac + "/set";
}
mConnectService.Send(topic, message);
}

//数据接收处理函数
Expand Down
24 changes: 2 additions & 22 deletions app/src/main/java/com/zyc/zcontrol/controlItem/m1/M1Fragment.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.zyc.zcontrol.controlItem.m1;


import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
Expand All @@ -25,12 +24,8 @@
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.LinearInterpolator;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.SeekBar;
import android.widget.Switch;
import android.widget.TextView;

import com.zyc.zcontrol.ConnectService;
Expand All @@ -41,7 +36,6 @@

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import static android.content.Context.BIND_AUTO_CREATE;
Expand Down Expand Up @@ -149,7 +143,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
tvHumidity.setText(Html.fromHtml(exchange));

//region 拖动条 处理viewpage/SwipeRefreshLayout滑动冲突事件
seekBar = view.findViewById(R.id.seekBar);
seekBar = view.findViewById(R.id.seekBarR);
//region 处理viewpage/SwipeRefreshLayout滑动冲突事件
seekBar.setOnTouchListener(new View.OnTouchListener() {
@Override
Expand Down Expand Up @@ -179,7 +173,7 @@ public void onStopTrackingTouch(SeekBar seekBar) {

//endregion

tvBrightness=view.findViewById(R.id.tv_brightness);
tvBrightness=view.findViewById(R.id.textViewR);
tvBrightness.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down Expand Up @@ -243,20 +237,6 @@ public void onDestroy() {
super.onDestroy();
}

//region 按钮事件
// region 开关
private View.OnClickListener MainButtonListener = new View.OnClickListener() {

@Override
public void onClick(View arg0) {
Send("{\"mac\":\"" + device_mac + "\",\"on\":" + String.valueOf(((Switch) arg0).isChecked() ? 1 : 0) + "}");
}
};

//endregion
//endregion


void Send(String message) {
if (mConnectService == null) return;
if(getActivity()==null) Log.e(Tag,"getActivity");
Expand Down
Loading

0 comments on commit f237549

Please sign in to comment.