Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
XuXiangJun committed Nov 7, 2019
1 parent 1dd4750 commit f47ef0e
Show file tree
Hide file tree
Showing 20 changed files with 673 additions and 504 deletions.
10 changes: 4 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ android {

defaultConfig {
applicationId "com.espressif.espblufi"
minSdkVersion 18
minSdkVersion 21
targetSdkVersion 29
versionCode 20
versionName "1.4.3"
versionCode 21
versionName "1.5.0"
}
buildTypes {
release {
Expand All @@ -30,10 +30,8 @@ dependencies {
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'androidx.preference:preference:1.1.0'

implementation 'io.reactivex.rxjava2:rxjava:2.2.12'
implementation 'io.reactivex.rxjava2:rxjava:2.2.14'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'

implementation 'xxj.phiman:xxjtools:1.0.1'

implementation project(':blufilibrary')
}
7 changes: 6 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />

<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="true" />

<application
android:name=".app.BlufiApp"
android:allowBackup="true"
android:fullBackupContent="@xml/backup_descriptor"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
Expand All @@ -35,8 +40,8 @@
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".ui.ConfigureOptionsActivity"
android:screenOrientation="portrait"
android:label="@string/configure_title"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".ui.SettingsActivity"
Expand Down
10 changes: 2 additions & 8 deletions app/src/main/java/com/espressif/espblufi/app/BlufiApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@

import com.espressif.espblufi.constants.SettingsConstants;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

public class BlufiApp extends Application {
private static BlufiApp instance;

private final HashMap<String, Object> mCache = new HashMap<>();

private SharedPreferences mSettingsShared;

public static BlufiApp getInstance() {
Expand All @@ -35,11 +32,9 @@ public void onCreate() {
@Override
public void onTerminate() {
super.onTerminate();

mCache.clear();
}

public boolean settingsPut(String key, Object value) {
public void settingsPut(String key, Object value) {
SharedPreferences.Editor editor = mSettingsShared.edit();
if (value instanceof String) {
editor.putString(key, (String) value);
Expand All @@ -59,11 +54,10 @@ public boolean settingsPut(String key, Object value) {
}
editor.putStringSet(key, newSet);
} else {
return false;
throw new IllegalArgumentException("Unsupported value type");
}

editor.apply();
return true;
}

public Object settingsGet(String key, Object defaultValue) {
Expand Down
90 changes: 90 additions & 0 deletions app/src/main/java/com/espressif/espblufi/app/BlufiLog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package com.espressif.espblufi.app;

import android.util.Log;

public class BlufiLog {
private final String mTag;
private Level mLevel = Level.V;

/**
* @param cls The tag will use simple name of the cls.
*/
public BlufiLog(Class cls) {
mTag = String.format("[%s]", cls.getSimpleName());
}

/**
* Set the print lowest level. It will set {@link Level#NIL} if the level is null.
*
* @param level The lowest level can print log.
*/
public void setLevel(Level level) {
if (level == null) {
mLevel = Level.NIL;
} else {
mLevel = level;
}
}

/**
* Send a {@link Level#V} log message.
*
* @param msg The message you would like logged.
*/
public void v(String msg) {
if (mLevel.ordinal() <= Level.V.ordinal()) {
Log.v(mTag, msg);
}
}

/**
* Send a {@link Level#V} log message.
*
* @param msg The message you would like logged.
*/
public void d(String msg) {
if (mLevel.ordinal() <= Level.D.ordinal()) {
Log.d(mTag, msg);
}
}

/**
* Send a {@link Level#I} log message.
*
* @param msg The message you would like logged.
*/
public void i(String msg) {
if (mLevel.ordinal() <= Level.I.ordinal()) {
Log.i(mTag, msg);
}
}

/**
* Send a {@link Level#W} log message.
*
* @param msg The message you would like logged.
*/
public void w(String msg) {
if (mLevel.ordinal() <= Level.W.ordinal()) {
Log.w(mTag, msg);
}
}

/**
* Send a {@link Level#E} log message.
*
* @param msg The message you would like logged.
*/
public void e(String msg) {
if (mLevel.ordinal() <= Level.E.ordinal()) {
Log.e(mTag, msg);
}
}

/**
* The level allow logged
*/
public enum Level {
V, D, I, W, E, NIL
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ public final class BlufiConstants {

public static final int DEFAULT_MTU_LENGTH = 128;
public static final int MIN_MTU_LENGTH = 15;
public static final int MAX_MTU_LENGTH = 512;
}
Loading

0 comments on commit f47ef0e

Please sign in to comment.