Browse Source

Update jar

master
陈福行 4 years ago
parent
commit
6e3f7abb4c

+ 0
- 10
.idea/codeStyles/Project.xml View File

@@ -27,16 +27,7 @@
<emptyLine />
</value>
</option>
<option name="RIGHT_MARGIN" value="100" />
<AndroidXmlCodeStyleSettings>
<option name="USE_CUSTOM_SETTINGS" value="true" />
</AndroidXmlCodeStyleSettings>
<JavaCodeStyleSettings>
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
<value />
</option>
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="android" withSubpackages="true" static="false" />
@@ -64,7 +55,6 @@
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
</XML>
<codeStyleSettings language="XML">
<option name="FORCE_REARRANGE_MODE" value="1" />
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>

+ 2
- 0
.idea/gradle.xml View File

@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="PLATFORM" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">

+ 25
- 0
.idea/jarRepositories.xml View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="BintrayJCenter" />
<option name="name" value="BintrayJCenter" />
<option name="url" value="https://jcenter.bintray.com/" />
</remote-repository>
<remote-repository>
<option name="id" value="Google" />
<option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository>
</component>
</project>

+ 234
- 117
app/src/main/java/aicare/net/cn/sdk/pabulumsdkrepositoryandroid/MainActivity.java View File

@@ -35,6 +35,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnCheckedChanged;
import butterknife.OnClick;
import cn.net.aicare.pabulumlibrary.PabulumSDK;
import cn.net.aicare.pabulumlibrary.bleprofile.BleProfileService;
import cn.net.aicare.pabulumlibrary.entity.FoodData;
import cn.net.aicare.pabulumlibrary.pabulum.PabulumService;
@@ -42,7 +43,6 @@ import cn.net.aicare.pabulumlibrary.utils.L;
import cn.net.aicare.pabulumlibrary.utils.PabulumBleConfig;
import cn.net.aicare.pabulumlibrary.utils.ParseData;


public class MainActivity extends BaseActivity implements SetRssiDialog.OnQueryListener {

private final static String TAG = MainActivity.class.getSimpleName();
@@ -60,6 +60,8 @@ public class MainActivity extends BaseActivity implements SetRssiDialog.OnQueryL
TextView tvShowVersion;
@BindView(R.id.rg_unit)
RadioGroup rgUnit;
@BindView(R.id.rg_unit_two)
RadioGroup rgUnitTwo;
@BindView(R.id.et_set_weight)
EditText etSetWeight;
@BindView(R.id.tv_show_result)
@@ -69,13 +71,9 @@ public class MainActivity extends BaseActivity implements SetRssiDialog.OnQueryL
@BindView(R.id.tv_show_time)
TextView tv_show_time;

@OnClick({R.id.btn_title_right, R.id.tv_show_state, R.id.btn_set_weight, R.id.btn_tare,
R.id.btn_power_off, R.id.btn_cal, R.id.btn_all_cal, R.id.btn_fat, R.id.btn_all_fat,
R.id.btn_pro, R.id.btn_all_pro, R.id.btn_car, R.id.btn_all_car, R.id.btn_fib,
R.id.btn_all_fib, R.id.btn_cho, R.id.btn_all_cho, R.id.btn_sod, R.id.btn_all_sod,
R.id.btn_sug, R.id.btn_all_sug, R.id.btn_write_value, R.id.btn_did,
R.id.btn_get_version, R.id.btn_start, R.id.btn_start_less, R.id.btn_pause,
R.id.btn_reset, R.id.btn_pause_less})
@OnClick({R.id.btn_title_right, R.id.tv_show_state, R.id.btn_set_weight, R.id.btn_tare, R.id.btn_power_off, R.id.btn_cal, R.id.btn_all_cal, R.id.btn_fat, R.id.btn_all_fat, R.id.btn_pro,
R.id.btn_all_pro, R.id.btn_car, R.id.btn_all_car, R.id.btn_fib, R.id.btn_all_fib, R.id.btn_cho, R.id.btn_all_cho, R.id.btn_sod, R.id.btn_all_sod, R.id.btn_sug, R.id.btn_all_sug,
R.id.btn_write_value, R.id.btn_did, R.id.btn_get_version, R.id.btn_start, R.id.btn_start_less, R.id.btn_pause, R.id.btn_reset, R.id.btn_pause_less, R.id.btn_get_units})
void onClick(View view) {
switch (view.getId()) {
case R.id.btn_title_right:
@@ -108,44 +106,50 @@ public class MainActivity extends BaseActivity implements SetRssiDialog.OnQueryL
handler.postDelayed(disconnectRunnable, 1000);
}
break;
//获取DID 2018-12-3
case R.id.btn_did:
if (binder != null) {
L.i(TAG, "点击请求获取did");
binder.getDid();
}
break;
//2019/4/29
case R.id.btn_start:
if (binder != null) {
L.i(TAG, "开始计时");
binder.startTime();
}
break; //2019/6/25
break; //2019/5/22
case R.id.btn_start_less:
if (binder != null) {
L.i(TAG, "倒计时开始");
binder.startTimeLess(180);
}
break;
//2019/6/25
case R.id.btn_pause:
if (binder != null) {
L.i(TAG, "Positive timing pause");
L.i(TAG, "正计时暂停");
binder.pauseTime(80);
}
break;
//2019/6/25
case R.id.btn_pause_less:
if (binder != null) {
L.i(TAG, "Countdown pause");
L.i(TAG, "倒计时暂停");
binder.pauseTimeLess(90);
}
break;
//2019/4/29
case R.id.btn_reset:
if (binder != null) {
L.i(TAG, "重置计时");
binder.resetTime();
}
break;
case R.id.btn_write_value:
if (binder != null) {
//透传数据测试
byte[] value = initRandomByteArr(new Random().nextInt(21));
L.e(TAG, "value: " + ParseData.arr2Str(value));
binder.writeValue(value);
@@ -153,8 +157,16 @@ public class MainActivity extends BaseActivity implements SetRssiDialog.OnQueryL
break;
case R.id.btn_get_version:
if (binder != null) {
L.i(TAG, "点击请求获取版本号");
binder.getVersion();

}
break;
case R.id.btn_get_units:
if (binder != null) {
L.i(TAG, "点击请求获取单位列表");
binder.getUnits();

}
break;
default:
@@ -178,7 +190,7 @@ public class MainActivity extends BaseActivity implements SetRssiDialog.OnQueryL
if (TextUtils.isEmpty(data)) {
T.showShort(this, R.string.pls_input_weight);
} else {
int wei = Integer.valueOf(data);
int wei = Integer.parseInt(data);
if (binder != null) {
switch (id) {
case R.id.btn_cal:
@@ -234,7 +246,7 @@ public class MainActivity extends BaseActivity implements SetRssiDialog.OnQueryL
}
}

@OnCheckedChanged({R.id.rb_g, R.id.rb_lb, R.id.rb_ml, R.id.rb_oz, R.id.rb_kg, R.id.rb_fg})
@OnCheckedChanged({R.id.rb_g, R.id.rb_lb, R.id.rb_ml, R.id.rb_oz, R.id.rb_kg, R.id.rb_fg, R.id.rb_ml_milk, R.id.rb_ml_water, R.id.rb_floz_milk, R.id.rb_floz_water, R.id.rb_lb_lb})
void onCheckedChange(RadioButton radioButton, boolean isChecked) {
if (isBleChangeUnit) {
isBleChangeUnit = false;
@@ -272,6 +284,31 @@ public class MainActivity extends BaseActivity implements SetRssiDialog.OnQueryL
binder.setUnit(PabulumBleConfig.UNIT_FG);
}
break;
case R.id.rb_ml_milk:
if (binder != null) {
binder.setUnit(PabulumBleConfig.UNIT_ML_MILK);
}
break;
case R.id.rb_ml_water:
if (binder != null) {
binder.setUnit(PabulumBleConfig.UNIT_ML_WATER);
}
break;
case R.id.rb_floz_milk:
if (binder != null) {
binder.setUnit(PabulumBleConfig.UNIT_FL_OZ_MILK);
}
break;
case R.id.rb_floz_water:
if (binder != null) {
binder.setUnit(PabulumBleConfig.UNIT_FL_OZ_WATER);
}
break;
case R.id.rb_lb_lb:
if (binder != null) {
binder.setUnit(PabulumBleConfig.UNIT_LB_LB);
}
break;
}
}
}
@@ -291,14 +328,16 @@ public class MainActivity extends BaseActivity implements SetRssiDialog.OnQueryL
super.onCreate(savedInstanceState);
L.isDebug = true;
setContentView(R.layout.main);
// PabulumSDK.getInstance().init(this, "66617c04a3bbc7d2", "001814ae6212dd8c4657444c4b");
PabulumSDK.getInstance().init(this);
initData();
ButterKnife.bind(this);
initViews();
if (!AppUtils.isLocServiceEnable(this)) {
T.showShort(this,this.getString(R.string.permissions_server));
T.showShort(this, this.getString(R.string.permissions_server));
}

if (ensureBLESupported()) {
if (ensureBLESupported()) {//判断设备是否支持BLE,true(支持),反之则反。

initPermissions();
}
@@ -321,7 +360,11 @@ public class MainActivity extends BaseActivity implements SetRssiDialog.OnQueryL
}



/**
* 设置状态信息
*
* @param object
*/
private void setState(Object object) {
if (object instanceof Integer) {
tvShowState.setText((Integer) object);
@@ -330,14 +373,17 @@ public class MainActivity extends BaseActivity implements SetRssiDialog.OnQueryL
}
}


/**
* 设置信号显示
*
* @param object
*/
private void setCurrentRssi(Object object) {
if (object == null) {
tvShowRssi.setText(R.string.no_rssi);
} else {
if (object instanceof Integer) {
tvShowRssi.setText(String.format(getResources().getString(R.string.current_rssi),
(Integer) object));
tvShowRssi.setText(String.format(getResources().getString(R.string.current_rssi), (Integer) object));
}
}
}
@@ -351,79 +397,77 @@ public class MainActivity extends BaseActivity implements SetRssiDialog.OnQueryL
@Override
protected void getTimeStatus(int status) {
//2019/4/29
Toast.makeText(MainActivity.this, "getTimeStatus:" + status, Toast.LENGTH_SHORT).show();
L.i(TAG, "获取操作状态:" + status);
Toast.makeText(MainActivity.this, "操作状态:" + status, Toast.LENGTH_SHORT).show();
}

@Override
protected void getCountdownStart(int time) {
//2019/5/22
Toast.makeText(MainActivity.this, "getCountdownStart:" + time, Toast.LENGTH_SHORT).show();
L.i(TAG, "倒计时开始:" + time);
Toast.makeText(MainActivity.this, "倒计时开始:" + time, Toast.LENGTH_SHORT).show();
}

@Override
protected void getSynTime(byte cmdType, int timeS) {
//2019/5/22
String tyepName="";
String tyepName = "";
switch (cmdType) {

case PabulumBleConfig.SYN_TIME:
tyepName="Time synchronization";
//时间同步
tyepName = "时间同步";
break;
case PabulumBleConfig.SYN_TIME_LESS:
tyepName="Countdown time synchronization";
//倒计时时间同步
tyepName = "倒计时时间同步";
break;
case PabulumBleConfig.TIMING_PAUSE:
tyepName="Positive timing pause";
Toast.makeText(MainActivity.this,"Positive timing pause", Toast.LENGTH_SHORT).show();
//正计时暂停时间同步
tyepName = "正计时暂停时间同步";
Toast.makeText(MainActivity.this, "正计时暂停", Toast.LENGTH_SHORT).show();
break;
case PabulumBleConfig.TIMING_PAUSE_LESS:
tyepName="Countdown pause";
Toast.makeText(MainActivity.this,"Countdown pause", Toast.LENGTH_SHORT).show();
//倒计时暂停时间同步
tyepName = "倒计时暂停时间同步";
Toast.makeText(MainActivity.this, "倒计时暂停", Toast.LENGTH_SHORT).show();
break;

}
L.i(TAG, "TIME:" + timeS + "||" + tyepName);
L.i(TAG, "获取时间同步:" + timeS + "||" + tyepName);
tv_show_time.setText("TIME:" + timeS);
}

@Override
protected void getBleDID(int did) {
L.i(TAG, "getBleDID:" + did);
tvShowDid.setText("DID:" + did);
}


@Override
protected void getUnits(int[] units) {
L.i(TAG, "支持的单位列表 = " + Arrays.toString(units));
}

@Override
protected void getErrCodes(int[] ints) {
super.getErrCodes(ints);
}
protected void getPenetrateData(byte[] data) {
L.i(TAG, "透传数据:" + ParseData.arr2Str(data));

@Override
protected void getStopAlarm() {
super.getStopAlarm();
}

@Override
protected void getPenetrateData(byte[] data) {
L.i(TAG, "透传数据:" + ParseData.arr2Str(data));
protected void getBleDID(int did) {
L.i(TAG, "获取did成功:" + did);
tvShowDid.setText("DID:" + did);
}

/**
* 设置右边title
*
* @param rssi
*/
private void setTitleRight(int rssi) {
btnTitleRight.setText(String.format(getResources().getString(R.string.default_rssi), rssi));
}

@Override
protected void onServiceBinded(BleProfileService.LocalBinder binder) {

protected void onServiceBinded(BleProfileService.LocalBinder binder) {//成功绑定服务
/*
获取服务的binder通过binder执行蓝牙操作
*/
this.binder = (PabulumService.PabulumBinder) binder;
this.binder.getDeviceAddress();
this.binder.getDeviceName();
this.binder.getDeviceAddress();//获取当前连接设备的蓝牙地址
this.binder.getDeviceName();//获取当前连接设备的名称
L.e(TAG, "onServiceBinded绑定服务成功:" + binder);
}

@Override
@@ -433,8 +477,7 @@ public class MainActivity extends BaseActivity implements SetRssiDialog.OnQueryL
case BleProfileService.STATE_CONNECTED:
L.e(TAG, "onDeviceConnected");
if (binder != null) {
setState(String.format(getResources().getString(R.string.current_device),
binder.getDeviceAddress()));
setState(String.format(getResources().getString(R.string.current_device), binder.getDeviceAddress()));
}
break;
case BleProfileService.STATE_DISCONNECTED:
@@ -449,10 +492,10 @@ public class MainActivity extends BaseActivity implements SetRssiDialog.OnQueryL
}
}, 1000);
break;
case BleProfileService.STATE_INDICATION_SUCCESS:
case BleProfileService.STATE_INDICATION_SUCCESS://订阅蓝牙服务成功
L.e(TAG, "onIndicationSuccess");
if (binder != null) {
binder.setUnit(preUnit);
binder.setUnit(preUnit);//设置单位(订阅成功后,同步APP单位到蓝牙,保持两端单位一致)
}
rgUnit.check(R.id.rb_g);
break;
@@ -464,7 +507,7 @@ public class MainActivity extends BaseActivity implements SetRssiDialog.OnQueryL
T.showLong(this, "msg = " + msg + "; code = " + errorCode);
}

private int countRssi = 0;
private int countRssi = 0;//判断是否需要断开

@Override
public void onReadRssi(int rssi) {
@@ -482,16 +525,25 @@ public class MainActivity extends BaseActivity implements SetRssiDialog.OnQueryL
}
}

private int countWei = 0;
private int countWei = 0;//判断数据是否稳定

@Override
protected void getUnit(byte unitType) {
protected void getUnit(byte unitType) {//秤返回的单位信息
L.e(TAG, "unitType = " + unitType);
preUnit = unitType;
showUnit(preUnit);
}


@Override
protected void getUnits(int[] units) {//支持的单位列表
L.e(TAG, "支持的单位列表 = " + Arrays.toString(units));
}

@Override
protected void getBleVersion(String version) {
L.e(TAG, "version = " + version);
T.showShort(this, "获取版本号成功");
setBleVersion(String.format(getResources().getString(R.string.ble_version), version));
}

@@ -508,7 +560,7 @@ public class MainActivity extends BaseActivity implements SetRssiDialog.OnQueryL
}

@Override
protected void bluetoothStateOn() {
protected void bluetoothStateOn() {//蓝牙已开启
super.bluetoothStateOn();
setState(R.string.ble_state_on);
L.e(TAG, "bluetoothStateOn");
@@ -525,7 +577,7 @@ public class MainActivity extends BaseActivity implements SetRssiDialog.OnQueryL

@Override
protected void getFoodData(FoodData foodData) {
if (foodData == null) {//2017-06-16
if (foodData == null) {//2017-06-16为空直接返回
return;
}
L.e(TAG, "weight = " + foodData.getData());
@@ -544,46 +596,108 @@ public class MainActivity extends BaseActivity implements SetRssiDialog.OnQueryL
if (foodData.getUnit() != preUnit) {
preUnit = foodData.getUnit();
isBleChangeUnit = true;
switch (preUnit) {
case PabulumBleConfig.UNIT_G:
rgUnit.check(R.id.rb_g);
break;
case PabulumBleConfig.UNIT_ML:
rgUnit.check(R.id.rb_ml);
break;
case PabulumBleConfig.UNIT_LB:
rgUnit.check(R.id.rb_lb);
break;
case PabulumBleConfig.UNIT_OZ:
rgUnit.check(R.id.rb_oz);
break;
case PabulumBleConfig.UNIT_KG:
rgUnit.check(R.id.rb_kg);
break;
case PabulumBleConfig.UNIT_FG:
rgUnit.check(R.id.rb_fg);
break;
}
showUnit(preUnit);
}
String unitStr = getUnitStr(preUnit);

tvShowResult.setText(preWeight+" "+unitStr + "\nType:" + foodData.getDeviceType()+ "\n" + foodData.getWeight() + "g");
}


private void showUnit(int preUnit) {
switch (preUnit) {
case PabulumBleConfig.UNIT_G:
rgUnit.check(R.id.rb_g);
break;
case PabulumBleConfig.UNIT_ML:
rgUnit.check(R.id.rb_ml);
break;
case PabulumBleConfig.UNIT_LB:
rgUnit.check(R.id.rb_lb);
break;
case PabulumBleConfig.UNIT_OZ:
rgUnit.check(R.id.rb_oz);
break;
case PabulumBleConfig.UNIT_KG:
rgUnit.check(R.id.rb_kg);
break;
case PabulumBleConfig.UNIT_FG:
rgUnit.check(R.id.rb_fg);
break;
case PabulumBleConfig.UNIT_ML_MILK:
rgUnitTwo.check(R.id.rb_ml_milk);
break;
case PabulumBleConfig.UNIT_ML_WATER:
rgUnitTwo.check(R.id.rb_ml_water);
break;
case PabulumBleConfig.UNIT_FL_OZ_MILK:
rgUnitTwo.check(R.id.rb_floz_milk);
break;
case PabulumBleConfig.UNIT_FL_OZ_WATER:
rgUnitTwo.check(R.id.rb_floz_water);
break;
case PabulumBleConfig.UNIT_LB_LB:
rgUnitTwo.check(R.id.rb_lb_lb);
break;
}
}

tvShowResult.setText(preWeight + "\n" + foodData.getDeviceType() + "\n" + foodData.getWeight());

private String getUnitStr(int preUnit) {
String unitStr=getString(R.string.unit_g);
switch (preUnit) {
case PabulumBleConfig.UNIT_G:
unitStr=getString(R.string.unit_g);
break;
case PabulumBleConfig.UNIT_ML:
unitStr=getString(R.string.unit_ml);
break;
case PabulumBleConfig.UNIT_LB:
unitStr=getString(R.string.unit_lb_oz);
break;
case PabulumBleConfig.UNIT_OZ:
unitStr=getString(R.string.unit_oz);
break;
case PabulumBleConfig.UNIT_KG:
unitStr=getString(R.string.unit_kg);
break;
case PabulumBleConfig.UNIT_FG:
unitStr=getString(R.string.unit_fg);
break;
case PabulumBleConfig.UNIT_ML_MILK:
unitStr=getString(R.string.unit_ml_milk);
break;
case PabulumBleConfig.UNIT_ML_WATER:
unitStr=getString(R.string.unit_ml_water);
break;
case PabulumBleConfig.UNIT_FL_OZ_MILK:
unitStr=getString(R.string.unit_oz_milk);
break;
case PabulumBleConfig.UNIT_FL_OZ_WATER:
unitStr=getString(R.string.unit_oz_water);
break;
case PabulumBleConfig.UNIT_LB_LB:
unitStr=getString(R.string.unit_lb);
break;
}
return unitStr;
}

@Override
protected void bluetoothStateOff() {
protected void bluetoothStateOff() {//蓝牙已关闭
super.bluetoothStateOff();
setState(R.string.ble_state_off);
L.e(TAG, "bluetoothStateOff");
}

@Override
protected void bluetoothTurningOff() {
protected void bluetoothTurningOff() {//蓝牙正在关闭
super.bluetoothTurningOff();
L.e(TAG, "bluetoothTurningOff");
}

@Override
protected void bluetoothTurningOn() {
protected void bluetoothTurningOn() {//蓝牙正在打开
super.bluetoothTurningOn();
L.e(TAG, "bluetoothTurningOn");
}
@@ -594,7 +708,7 @@ public class MainActivity extends BaseActivity implements SetRssiDialog.OnQueryL
L.e(TAG, "onDestroy");
stopScan();
if (binder != null) {
binder.disconnect();
binder.disconnect();//若Activity关闭时,不需要继续保持连接,可以在此断开连接
}
}

@@ -624,35 +738,36 @@ public class MainActivity extends BaseActivity implements SetRssiDialog.OnQueryL
}



/**
* 初始化请求权限
*/
private void initPermissions() {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, 1);
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, 1);
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
@NonNull int[] grantResults) {
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode != 1) {
return;
}
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
startScan();
startScan();//开始扫描
} else {

if (ActivityCompat.shouldShowRequestPermissionRationale(this, permissions[0])) {
new AlertDialog.Builder(this).setTitle(this.getString(R.string.hint)).setMessage(this.getString(R.string.permissions)).setPositiveButton(this.getString(R.string.query), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package",
getApplicationContext().getPackageName(), null);
intent.setData(uri);
startActivity(intent);
}
}).setNegativeButton(getString(R.string.cancel),
new DialogInterface.OnClickListener() {
//权限请求失败,但未选中“不再提示”选项
new AlertDialog.Builder(this).setTitle(this.getString(R.string.hint)).setMessage(this.getString(R.string.permissions))
.setPositiveButton(this.getString(R.string.query), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//引导用户至设置页手动授权
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", getApplicationContext().getPackageName(), null);
intent.setData(uri);
startActivity(intent);
}
}).setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (dialog != null) {
@@ -661,18 +776,20 @@ public class MainActivity extends BaseActivity implements SetRssiDialog.OnQueryL
}
}).show();
} else {
new AlertDialog.Builder(this).setTitle(this.getString(R.string.hint)).setMessage(this.getString(R.string.permissions)).setPositiveButton(this.getString(R.string.query), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package",
getApplicationContext().getPackageName(), null);
intent.setData(uri);
startActivity(intent);

}
}).setNegativeButton(getString(R.string.cancel),
new DialogInterface.OnClickListener() {
//权限请求失败,选中“不再提示”选项
// T.showShort(MainActivity.this, "获取权限失败");
new AlertDialog.Builder(this).setTitle(this.getString(R.string.hint)).setMessage(this.getString(R.string.permissions))
.setPositiveButton(this.getString(R.string.query), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//引导用户至设置页手动授权
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", getApplicationContext().getPackageName(), null);
intent.setData(uri);
startActivity(intent);

}
}).setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (dialog != null) {

+ 133
- 65
app/src/main/res/layout/main.xml View File

@@ -1,27 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/system_theme"
android:clipToPadding="true"
android:divider="@drawable/main_divider"
android:fitsSystemWindows="true"
android:orientation="vertical"
android:showDividers="middle">

<include layout="@layout/activity_title" />
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/system_theme"
android:clipToPadding="true"
android:divider="@drawable/main_divider"
android:fitsSystemWindows="true"
android:orientation="vertical"
android:showDividers="middle"
tools:ignore="ButtonStyle"
>

<include layout="@layout/activity_title"/>

<TextView
android:id="@+id/tv_show_state"
style="@style/Base_Text_View" />
style="@style/Base_Text_View"/>

<TextView
android:id="@+id/tv_show_rssi"
style="@style/Base_Text_View" />
style="@style/Base_Text_View"/>

<TextView
android:id="@+id/tv_show_version"
style="@style/Base_Text_View" />
style="@style/Base_Text_View"/>

<LinearLayout
android:layout_width="match_parent"
@@ -32,60 +35,97 @@
android:id="@+id/rg_unit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:gravity="center|start"
android:orientation="horizontal">

<RadioButton
android:id="@+id/rb_g"
style="@style/Base_Radio_Button"
android:text="g" />
android:text="g"/>

<RadioButton
android:id="@+id/rb_ml"
style="@style/Base_Radio_Button"
android:text="ml" />
android:text="ml"/>

<RadioButton
android:id="@+id/rb_lb"
style="@style/Base_Radio_Button"
android:text="lb" />
android:text="lb:oz"/>

<RadioButton
android:id="@+id/rb_oz"
style="@style/Base_Radio_Button"
android:text="oz" />
android:text="oz"/>

<RadioButton
android:id="@+id/rb_kg"
style="@style/Base_Radio_Button"
android:text="kg" />
android:text="kg"/>

<RadioButton
android:id="@+id/rb_fg"
style="@style/Base_Radio_Button"
android:text="斤" />
android:text="斤"/>


</RadioGroup>


</LinearLayout>

<LinearLayout
<RadioGroup
android:id="@+id/rg_unit_two"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|start"
android:orientation="horizontal">

<RadioButton
android:id="@+id/rb_ml_milk"
style="@style/Base_Radio_Button"
android:text="牛奶ml"/>

<RadioButton
android:id="@+id/rb_ml_water"
style="@style/Base_Radio_Button"
android:text="水ml"/>

<RadioButton
android:id="@+id/rb_floz_milk"
style="@style/Base_Radio_Button"
android:text="牛奶floz"/>

<RadioButton
android:id="@+id/rb_floz_water"
style="@style/Base_Radio_Button"
android:text="水floz"/>
<RadioButton
android:id="@+id/rb_lb_lb"
style="@style/Base_Radio_Button"
android:text="lb"/>

</RadioGroup>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">

<EditText
android:id="@+id/et_set_weight"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="@string/pls_input_weight"
android:inputType="number" />
android:inputType="number"/>

<Button
android:id="@+id/btn_set_weight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/set_weight" />
android:text="@string/set_weight"/>
</LinearLayout>

<LinearLayout
@@ -93,20 +133,22 @@
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:visibility="gone">
android:visibility="gone"

>

<Button
android:id="@+id/btn_cal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:text="卡路里" />
android:text="卡路里"/>

<Button
android:id="@+id/btn_all_cal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="总卡路里" />
android:text="总卡路里"/>

<Button
android:id="@+id/btn_sug"
@@ -114,13 +156,13 @@
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:text="糖" />
android:text="糖"/>

<Button
android:id="@+id/btn_all_sug"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="总糖" />
android:text="总糖"/>

</LinearLayout>

@@ -138,13 +180,13 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:text="脂肪" />
android:text="脂肪"/>

<Button
android:id="@+id/btn_all_fat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="总脂肪" />
android:text="总脂肪"/>

<Button
android:id="@+id/btn_pro"
@@ -152,13 +194,13 @@
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:text="蛋白质" />
android:text="蛋白质"/>

<Button
android:id="@+id/btn_all_pro"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="总蛋白质" />
android:text="总蛋白质"/>

</LinearLayout>

@@ -175,13 +217,13 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:text="碳水" />
android:text="碳水"/>

<Button
android:id="@+id/btn_all_car"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="总碳水" />
android:text="总碳水"/>

<Button
android:id="@+id/btn_fib"
@@ -189,13 +231,13 @@
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:text="纤维" />
android:text="纤维"/>

<Button
android:id="@+id/btn_all_fib"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="总纤维" />
android:text="总纤维"/>

</LinearLayout>

@@ -212,13 +254,13 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:text="胆固醇" />
android:text="胆固醇"/>

<Button
android:id="@+id/btn_all_cho"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="总胆固醇" />
android:text="总胆固醇"/>

<Button
android:id="@+id/btn_sod"
@@ -226,13 +268,13 @@
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:text="钠" />
android:text="钠"/>

<Button
android:id="@+id/btn_all_sod"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="总钠" />
android:text="总钠"/>

</LinearLayout>

@@ -247,54 +289,62 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:text="@string/zero" />
android:text="@string/zero"/>

<Button
android:id="@+id/btn_power_off"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/shut_down" />
android:text="@string/shut_down"/>

<Button
android:id="@+id/btn_write_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/write" />
android:text="@string/write"/>

<Button
android:id="@+id/btn_get_version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/get_version" />
android:text="@string/get_version"/>


</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">

<Button
android:id="@+id/btn_get_units"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/get_units"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal">
android:orientation="horizontal"
android:visibility="gone">

<Button
android:id="@+id/btn_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:text="@string/timing" />
android:text="@string/timing"/>

<Button
android:id="@+id/btn_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/reset" />
<Button
android:id="@+id/btn_did"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:text="DID" />
android:text="@string/reset"/>


</LinearLayout>

@@ -302,44 +352,62 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal">
android:orientation="horizontal"
android:visibility="gone">


<Button
android:id="@+id/btn_start_less"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/countdown" />
android:text="@string/countdown"/>

<Button
android:id="@+id/btn_pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pause" />
android:text="@string/pause"/>

<Button
android:id="@+id/btn_pause_less"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pause_less" />
android:text="@string/pause_less"
/>


</LinearLayout>

<TextView
android:id="@+id/tv_show_did"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18dp"
android:text="DID:"
/>
android:gravity="center_horizontal"
android:orientation="horizontal">

<TextView
android:id="@+id/tv_show_did"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="DID:"
android:textSize="18dp"
/>

<Button
android:id="@+id/btn_did"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:text="DID"/>
</LinearLayout>


<TextView
android:id="@+id/tv_show_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18dp"
android:text="TIME:"
android:textSize="18dp"
/>

<TextView
@@ -349,6 +417,6 @@
android:gravity="center"
android:textColor="@color/black_theme"
android:textSize="28sp"
android:textStyle="bold" />
android:textStyle="bold"/>
</LinearLayout>


+ 14
- 0
app/src/main/res/values-zh/strings.xml View File

@@ -42,4 +42,18 @@
<string name="hint">提示</string>
<string name="permissions">请求使用定位权限搜索蓝牙设备</string>
<string name="permissions_server">没有开启定位服务</string>

<string name="unit_g">g</string>
<string name="unit_ml">ml</string>
<string name="unit_lb_oz">lb:oz</string>
<string name="unit_oz">oz</string>
<string name="unit_kg">kg</string>
<string name="unit_fg">斤</string>
<string name="unit_ml_milk">ml(牛奶)</string>
<string name="unit_ml_water">ml(水)</string>
<string name="unit_oz_milk">oz(牛奶)</string>
<string name="unit_oz_water">oz(水)</string>
<string name="unit_lb">lb</string>


</resources>

+ 17
- 2
app/src/main/res/values/strings.xml View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">PabulumSDK</string>
<string name="app_name">Ipabulum SDK</string>

<string name="not_support_ble">Your device supports BLE!</string>
<string name="scan_ing">Scanning...</string>
@@ -31,6 +32,7 @@
<string name="zero">zero</string>
<string name="shut_down">Shut down</string>
<string name="get_version">Get version</string>
<string name="get_units">Get Units</string>
<string name="timing">Timing</string>
<string name="countdown">Countdown</string>
<string name="pause">Pause</string>
@@ -41,5 +43,18 @@
<string name="hint">Prompt</string>
<string name="permissions">Request to search for Bluetooth devices with targeting permissions</string>
<string name="permissions_server">Location service is not turned on</string>
<string name="get_units">getUnits</string>


<string name="unit_g">g</string>
<string name="unit_ml">ml</string>
<string name="unit_lb_oz">lb:oz</string>
<string name="unit_oz">oz</string>
<string name="unit_kg">kg</string>
<string name="unit_fg">斤</string>
<string name="unit_ml_milk">ml(milk)</string>
<string name="unit_ml_water">ml(water)</string>
<string name="unit_oz_milk">oz(milk)</string>
<string name="unit_oz_water">oz(water)</string>
<string name="unit_lb">lb</string>

</resources>

+ 1
- 1
pabulumlibrary/build.gradle View File

@@ -9,7 +9,7 @@ android {
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.2.6"
versionName "1.2.7"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"


BIN
pabulumlibrary/libs/AicareUtils.jar View File


BIN
pabulumlibrary/libs/PabulumLibrary.jar View File


BIN
pabulumlibrary/libs/arm64-v8a/libaicare-lib.so View File


BIN
pabulumlibrary/libs/armeabi-v7a/libaicare-lib.so View File


BIN
pabulumlibrary/libs/x86/libaicare-lib.so View File


BIN
pabulumlibrary/libs/x86_64/libaicare-lib.so View File


Loading…
Cancel
Save