Skip to content

Commit f47ef0e

Browse files
committed
update
1 parent 1dd4750 commit f47ef0e

20 files changed

+673
-504
lines changed

app/build.gradle

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ android {
55

66
defaultConfig {
77
applicationId "com.espressif.espblufi"
8-
minSdkVersion 18
8+
minSdkVersion 21
99
targetSdkVersion 29
10-
versionCode 20
11-
versionName "1.4.3"
10+
versionCode 21
11+
versionName "1.5.0"
1212
}
1313
buildTypes {
1414
release {
@@ -30,10 +30,8 @@ dependencies {
3030
implementation 'androidx.gridlayout:gridlayout:1.0.0'
3131
implementation 'androidx.preference:preference:1.1.0'
3232

33-
implementation 'io.reactivex.rxjava2:rxjava:2.2.12'
33+
implementation 'io.reactivex.rxjava2:rxjava:2.2.14'
3434
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
3535

36-
implementation 'xxj.phiman:xxjtools:1.0.1'
37-
3836
implementation project(':blufilibrary')
3937
}

app/src/main/AndroidManifest.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@
1010
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
1111
<uses-permission android:name="android.permission.INTERNET" />
1212

13+
<uses-feature
14+
android:name="android.hardware.bluetooth_le"
15+
android:required="true" />
16+
1317
<application
1418
android:name=".app.BlufiApp"
1519
android:allowBackup="true"
20+
android:fullBackupContent="@xml/backup_descriptor"
1621
android:icon="@mipmap/ic_launcher"
1722
android:label="@string/app_name"
1823
android:supportsRtl="true"
@@ -35,8 +40,8 @@
3540
android:theme="@style/AppTheme.NoActionBar" />
3641
<activity
3742
android:name=".ui.ConfigureOptionsActivity"
38-
android:screenOrientation="portrait"
3943
android:label="@string/configure_title"
44+
android:screenOrientation="portrait"
4045
android:theme="@style/AppTheme.NoActionBar" />
4146
<activity
4247
android:name=".ui.SettingsActivity"

app/src/main/java/com/espressif/espblufi/app/BlufiApp.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@
66

77
import com.espressif.espblufi.constants.SettingsConstants;
88

9-
import java.util.HashMap;
109
import java.util.HashSet;
1110
import java.util.Set;
1211

1312
public class BlufiApp extends Application {
1413
private static BlufiApp instance;
1514

16-
private final HashMap<String, Object> mCache = new HashMap<>();
17-
1815
private SharedPreferences mSettingsShared;
1916

2017
public static BlufiApp getInstance() {
@@ -35,11 +32,9 @@ public void onCreate() {
3532
@Override
3633
public void onTerminate() {
3734
super.onTerminate();
38-
39-
mCache.clear();
4035
}
4136

42-
public boolean settingsPut(String key, Object value) {
37+
public void settingsPut(String key, Object value) {
4338
SharedPreferences.Editor editor = mSettingsShared.edit();
4439
if (value instanceof String) {
4540
editor.putString(key, (String) value);
@@ -59,11 +54,10 @@ public boolean settingsPut(String key, Object value) {
5954
}
6055
editor.putStringSet(key, newSet);
6156
} else {
62-
return false;
57+
throw new IllegalArgumentException("Unsupported value type");
6358
}
6459

6560
editor.apply();
66-
return true;
6761
}
6862

6963
public Object settingsGet(String key, Object defaultValue) {
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package com.espressif.espblufi.app;
2+
3+
import android.util.Log;
4+
5+
public class BlufiLog {
6+
private final String mTag;
7+
private Level mLevel = Level.V;
8+
9+
/**
10+
* @param cls The tag will use simple name of the cls.
11+
*/
12+
public BlufiLog(Class cls) {
13+
mTag = String.format("[%s]", cls.getSimpleName());
14+
}
15+
16+
/**
17+
* Set the print lowest level. It will set {@link Level#NIL} if the level is null.
18+
*
19+
* @param level The lowest level can print log.
20+
*/
21+
public void setLevel(Level level) {
22+
if (level == null) {
23+
mLevel = Level.NIL;
24+
} else {
25+
mLevel = level;
26+
}
27+
}
28+
29+
/**
30+
* Send a {@link Level#V} log message.
31+
*
32+
* @param msg The message you would like logged.
33+
*/
34+
public void v(String msg) {
35+
if (mLevel.ordinal() <= Level.V.ordinal()) {
36+
Log.v(mTag, msg);
37+
}
38+
}
39+
40+
/**
41+
* Send a {@link Level#V} log message.
42+
*
43+
* @param msg The message you would like logged.
44+
*/
45+
public void d(String msg) {
46+
if (mLevel.ordinal() <= Level.D.ordinal()) {
47+
Log.d(mTag, msg);
48+
}
49+
}
50+
51+
/**
52+
* Send a {@link Level#I} log message.
53+
*
54+
* @param msg The message you would like logged.
55+
*/
56+
public void i(String msg) {
57+
if (mLevel.ordinal() <= Level.I.ordinal()) {
58+
Log.i(mTag, msg);
59+
}
60+
}
61+
62+
/**
63+
* Send a {@link Level#W} log message.
64+
*
65+
* @param msg The message you would like logged.
66+
*/
67+
public void w(String msg) {
68+
if (mLevel.ordinal() <= Level.W.ordinal()) {
69+
Log.w(mTag, msg);
70+
}
71+
}
72+
73+
/**
74+
* Send a {@link Level#E} log message.
75+
*
76+
* @param msg The message you would like logged.
77+
*/
78+
public void e(String msg) {
79+
if (mLevel.ordinal() <= Level.E.ordinal()) {
80+
Log.e(mTag, msg);
81+
}
82+
}
83+
84+
/**
85+
* The level allow logged
86+
*/
87+
public enum Level {
88+
V, D, I, W, E, NIL
89+
}
90+
}

app/src/main/java/com/espressif/espblufi/constants/BlufiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ public final class BlufiConstants {
1717

1818
public static final int DEFAULT_MTU_LENGTH = 128;
1919
public static final int MIN_MTU_LENGTH = 15;
20+
public static final int MAX_MTU_LENGTH = 512;
2021
}

0 commit comments

Comments
 (0)