Skip to content

Commit

Permalink
✨ 2.0.1.370,减少代码修复问题优化功能,实现NFC和华为函数的全自动
Browse files Browse the repository at this point in the history
  • Loading branch information
Hny0305Lin committed Jul 27, 2022
1 parent 995519e commit 9386cbb
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 232 deletions.
4 changes: 2 additions & 2 deletions HaohanyhHAMOSProjectY Android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
minSdk 26
targetSdk 32
versionCode 1
//2.0版本第362次测试
versionName "2.0.362.2022.0724.Haohanyh.Basin"
//2.0.1版本第370次测试
versionName "2.0.1.370.2022.0724.Haohanyh.Basin"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ public void CreateStringToSearchDeviceIoTDAneedget(String content) {
* ▍和中华人民共和国澳门特别行政区《网络安全法》
* ▍(浩瀚银河旗下网站和等服务不会以任何形式收集敏感信息和大数据分析,并在遵守情况下最大限度公开用户上传数据)
* 浩瀚银河数据保存地址:https://oranme-cdn.haohanyh.com/HAMOS/ProjectY/Device_info.json
* 浩瀚银河CDN图形界面地址:https://oranme-cdn.haohanyh.com/files.php?HAMOS/ProjectY#Device_info.json
* 本函数无任何上传到浩瀚银河的任何操作,仅为JSON数据下载判断行为,可安全使用
* 浩瀚银河服务器已能做到7x24不间断运行,不会影响大量用户生产环境。
*/
Expand Down Expand Up @@ -320,6 +321,7 @@ public boolean HaohanyhOranMeCDNDecideData(String Url, String S_data_device_id,
If_data_node_id = jsonObj.getString("node_id");
If_data_product_id = jsonObj.getString("product_id");
If_S_data_product_name = jsonObj.getString("product_name");

if((S_data_device_id.equals(If_S_data_device_id)) && (data_node_id.equals(If_data_node_id)) && (data_product_id.equals(If_data_product_id)) && (S_data_product_name.equals(If_S_data_product_name))){
Log.v("浩瀚银河:","恭喜您,华为云IoTDA上面有您的设备");
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/* 受Haohanyh Computer Software Products Open Source LICENSE保护 https://git.haohanyh.top:3001/Haohanyh/LICENSE */
package com.haohanyh.hamos.projecty;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;

import androidx.annotation.Nullable;
Expand All @@ -20,50 +19,32 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
nfcHelper = new NFCHelper(this);
}


@Override
protected void onResume() {
super.onResume();
//判断设备是否支持NFC功能
if (nfcHelper.isSupportNFC()) {
if (nfcHelper.SupportNFC()) {
//判断设备是否开启NFC功能
if (nfcHelper.isEnableNFC()) {
//注册FNC监听器
nfcHelper.registerNFC(this);
if (nfcHelper.EnableNFC()) {
//注册NFC监听器
nfcHelper.RegisterNFC(this);
} else {
nfcHelper.showFNCSetting(this);
nfcHelper.GoToNFCSetting(this);
}
} else {
showToast("当前设备不支持NFC功能");
Toast.makeText(BaseNFCActivity.this,"当前设备不支持NFC功能",Toast.LENGTH_SHORT).show();
}
}


@Override
protected void onPause() {
super.onPause();
nfcHelper.unRegisterNFC(this);
nfcHelper.UnRegisterNFC(this);
}

@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
log("Action: " + intent.getAction());

}

public void start(Class clazz) {
startActivity(new Intent(this, clazz));
}

public void showToast(String content) {
if (TextUtils.isEmpty(content))
return;
Toast.makeText(this, content, Toast.LENGTH_SHORT).show();

}

public void log(String content) {
Log.e(getClass().getSimpleName(), content);
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* 受Haohanyh Computer Software Products Open Source LICENSE保护 https://git.haohanyh.top:3001/Haohanyh/LICENSE */
package com.haohanyh.hamos.projecty;

import static com.haohanyh.hamos.huawei.Huawei.GetHuawei;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* 受Haohanyh Computer Software Products Open Source LICENSE保护 https://git.haohanyh.top:3001/Haohanyh/LICENSE */
package com.haohanyh.hamos.projecty;

import static com.haohanyh.hamos.projecty.MainActivity.getToBearPiJSON;
Expand All @@ -7,14 +8,14 @@
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

import androidx.annotation.Nullable;

import java.nio.charset.Charset;

public class NFCActivity extends BaseNFCActivity {
//初始化两个变量,这个很重要,一个是我们打印目前的参数到GUI页面,一个是判断是否可写数据到小熊派
public EditText NfcData;
private boolean isWrite = false;

Expand All @@ -27,6 +28,11 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
NfcData.post(new Runnable() {@Override public void run() { NfcData.setText(getToBearPiJSON());NfcData.setText(SSRJSON()); }});
}

/*
* 这个很重要,如果用户填写的值组成JSON,没有满为4的倍数(如176,不是4的倍数)
* 那么这个函数就是在JSON最有花括号"}"前,添加相对应的空格而不影响JSON数据
* 已经经过多轮灰度测试,暂时没有问题
*/
private String SSRJSON() {
Log.v("浩瀚银河:","目前JSON文本情况:"+NfcData.getText().toString()+","+"目前JSON在GB2312情况下字节数:"+NfcData.getText().toString().getBytes(Charset.forName("gb2312")).length);
//正确(4的倍数),就按兵不动;反之(非4倍数),就添加空格。
Expand All @@ -40,20 +46,14 @@ private String SSRJSON() {
json = json + " ";
}
Log.e("浩瀚银河:","现在您可以点击写入按钮了");
isWrite = true;
return json + "}";
}
Log.e("浩瀚银河:","现在您可以点击写入按钮了");
isWrite = true;
return NfcData.getText().toString();
}

public void onClick(View view) {
switch (view.getId()) {
case R.id.bt_write_text:
isWrite = true;
break;
}
}

@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Expand Down
Loading

0 comments on commit 9386cbb

Please sign in to comment.