Skip to content

Commit

Permalink
add:tc1激活码激活功能
Browse files Browse the repository at this point in the history
  • Loading branch information
a2633063 committed May 19, 2019
1 parent 35ea530 commit a6ee429
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 33 deletions.
29 changes: 0 additions & 29 deletions .idea/codeStyles/Project.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class TC1SettingFragment extends PreferenceFragment {
//endregion

Preference fw_version;
Preference lock;
Preference restart;
EditTextPreference name_preference;

Expand Down Expand Up @@ -168,6 +169,7 @@ public void onCreate(Bundle savedInstanceState) {
//
// CheckBoxPreference mEtPreference = (CheckBoxPreference) findPreference("theme");
fw_version = findPreference("fw_version");
lock = findPreference("lock");
restart = findPreference("restart");
name_preference = (EditTextPreference) findPreference("name");

Expand Down Expand Up @@ -201,7 +203,13 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
}
});
//endregion

lock.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
unlock();
return false;
}
});

//region 版本
fw_version.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
Expand Down Expand Up @@ -298,6 +306,28 @@ public void onDestroy() {
super.onDestroy();
}

//region 弹窗激活
void unlock() {

final EditText et = new EditText(getActivity());
new AlertDialog.Builder(getActivity()).setTitle("请输入激活码")
.setView(et)
.setMessage("激活码免费提供,如果您为此花钱购买,那您被骗了~\n索要激活码请至项目主页中查看作者联系方式.(关于页面中有项目地址)")
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
String lockStr = et.getText().toString();
Send("{\"mac\":\"" + device_mac + "\",\"lock\":\"" + lockStr + "\"}");
}
}).setNegativeButton("取消", null).show();

}

//endregion




void Send(String message) {
boolean b = getActivity().getSharedPreferences("Setting_" + device_mac, 0).getBoolean("always_UDP", false);
mConnectService.Send(b ? null : "device/ztc1/set", message);
Expand Down Expand Up @@ -335,6 +365,15 @@ void Receive(String topic, String message) {
fw_version.setSummary(version);
}
//endregion
//region 激活
if (jsonObject.has("lock")) {
if (jsonObject.getBoolean("lock")) {
lock.setSummary("已激活");
} else {
lock.setSummary("未激活");
}
}
//endregion
//region ota结果/进度
if (jsonObject.has("ota_progress")) {
int ota_progress = jsonObject.getInt("ota_progress");
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/xml/tc1_setting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<Preference
android:key="fw_version"
android:title="当前版本(点击检查新版本)"/>
<Preference
android:key="lock"
android:title="激活状态"/>
<Preference
android:key="restart"
android:title="重启设备"/>
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.android.tools.build:gradle:3.4.0'


// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Feb 23 16:06:26 CST 2019
#Tue May 14 11:47:59 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

0 comments on commit a6ee429

Please sign in to comment.