Skip to content

Commit

Permalink
更新SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
liuwenzheng committed Jan 10, 2018
1 parent c380410 commit c45f466
Show file tree
Hide file tree
Showing 73 changed files with 1,007 additions and 788 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0.0.7"
versionName "1.0.0"
}

sourceSets {
Expand Down Expand Up @@ -43,6 +43,6 @@ dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
compile 'com.jakewharton:butterknife:7.0.0'
compile 'com.android.support:support-v4:23.1.0'
compile project(path: ':beaconsupport')
compile project(path: ':mokosupport')

}
4 changes: 2 additions & 2 deletions app/src/main/java/com/moko/beacon/BaseApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import android.content.Intent;

import com.moko.beacon.service.BeaconService;
import com.moko.beaconsupport.beacon.BeaconModule;
import com.moko.support.MokoSupport;

/**
* @Date 2017/12/7 0007
Expand All @@ -16,7 +16,7 @@ public class BaseApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
BeaconModule.getInstance().init(getApplicationContext());
MokoSupport.getInstance().init(getApplicationContext());
// 启动蓝牙服务
startService(new Intent(this, BeaconService.class));
}
Expand Down
10 changes: 1 addition & 9 deletions app/src/main/java/com/moko/beacon/BeaconConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,12 @@ public class BeaconConstants {
public static final String PATTERN_MM_DD_2 = "MM-dd";
public static final String PATTERN_YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";
// action
public static final String ACTION_CONNECT_SUCCESS = "ACTION_CONNECT_SUCCESS";
public static final String ACTION_CONNECT_DISCONNECTED = "ACTION_CONNECT_DISCONNECTED";
public static final String ACTION_RESPONSE_SUCCESS = "ACTION_RESPONSE_SUCCESS";
public static final String ACTION_RESPONSE_TIMEOUT = "ACTION_RESPONSE_TIMEOUT";
public static final String ACTION_RESPONSE_FINISH = "ACTION_RESPONSE_FINISH";
// sp
public static final String SP_NAME = "sp_name_beacon";

public static final String SP_KEY_DEVICE_ADDRESS = "sp_key_device_address";
// extra_key
// 设备列表
public static final String EXTRA_KEY_RESPONSE_ORDER_TYPE = "EXTRA_KEY_RESPONSE_ORDER_TYPE";
public static final String EXTRA_KEY_RESPONSE_VALUE = "EXTRA_KEY_RESPONSE_VALUE";
// 设备列表\
public static final String EXTRA_KEY_DEVICE_PARAM = "EXTRA_KEY_DEVICE_PARAM";
public static final String EXTRA_KEY_DEVICE_INFO = "EXTRA_KEY_DEVICE_INFO";
public static final String EXTRA_KEY_DEVICE_UUID = "EXTRA_KEY_DEVICE_UUID";
Expand All @@ -34,7 +27,6 @@ public class BeaconConstants {
public static final String EXTRA_KEY_DEVICE_CONNECTION_MODE = "EXTRA_KEY_DEVICE_CONNECTION_MODE";
public static final String EXTRA_KEY_DEVICE_PASSWORD = "EXTRA_KEY_DEVICE_PASSWORD";
// request_code
public static final int REQUEST_CODE_ENABLE_BT = 1001;
public static final int REQUEST_CODE_DEVICE_INFO = 101;
public static final int REQUEST_CODE_SET_UUID = 102;
public static final int REQUEST_CODE_SET_MAJOR = 103;
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/moko/beacon/activity/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import android.os.SystemClock;
import android.support.v4.app.FragmentActivity;

import com.moko.beaconsupport.log.LogModule;
import com.moko.support.log.LogModule;


public class BaseActivity extends FragmentActivity {

Expand Down
67 changes: 34 additions & 33 deletions app/src/main/java/com/moko/beacon/activity/DeviceInfoActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
import com.moko.beacon.entity.BeaconParam;
import com.moko.beacon.service.BeaconService;
import com.moko.beacon.utils.ToastUtils;
import com.moko.beaconsupport.beacon.BeaconModule;
import com.moko.beaconsupport.entity.OrderType;
import com.moko.beaconsupport.task.OrderTask;
import com.moko.beaconsupport.utils.Utils;
import com.moko.support.MokoConstants;
import com.moko.support.MokoSupport;
import com.moko.support.entity.OrderType;
import com.moko.support.task.OrderTask;
import com.moko.support.utils.Utils;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -79,7 +80,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
finish();
return;
}
if (BeaconModule.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
if (MokoSupport.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
tvConnState.setText(getString(R.string.device_info_conn_status_connected));
} else {
tvConnState.setText(getString(R.string.device_info_conn_status_disconnect));
Expand Down Expand Up @@ -115,7 +116,7 @@ public void onReceive(Context context, Intent intent) {
if (intent != null) {
abortBroadcast();
String action = intent.getAction();
if (BeaconConstants.ACTION_CONNECT_SUCCESS.equals(action)) {
if (MokoConstants.ACTION_CONNECT_SUCCESS.equals(action)) {
tvConnState.setText(getString(R.string.device_info_conn_status_connected));
// 读取全部可读数据
mBeaconService.mHandler.postDelayed(new Runnable() {
Expand All @@ -125,15 +126,15 @@ public void run() {
}
}, 1000);
}
if (BeaconConstants.ACTION_CONNECT_DISCONNECTED.equals(action)) {
if (MokoConstants.ACTION_CONNECT_DISCONNECTED.equals(action)) {
tvConnState.setText(getString(R.string.device_info_conn_status_disconnect));
ToastUtils.showToast(DeviceInfoActivity.this, "Connect Failed");
dismissLoadingProgressDialog();
dismissSyncProgressDialog();
}
if (BeaconConstants.ACTION_RESPONSE_TIMEOUT.equals(action)) {
if (MokoConstants.ACTION_RESPONSE_TIMEOUT.equals(action)) {
}
if (BeaconConstants.ACTION_RESPONSE_FINISH.equals(action)) {
if (MokoConstants.ACTION_RESPONSE_FINISH.equals(action)) {
mBeaconService.mHandler.postDelayed(new Runnable() {
@Override
public void run() {
Expand All @@ -143,9 +144,9 @@ public void run() {
}, 1000);

}
if (BeaconConstants.ACTION_RESPONSE_SUCCESS.equals(action)) {
OrderType orderType = (OrderType) intent.getSerializableExtra(BeaconConstants.EXTRA_KEY_RESPONSE_ORDER_TYPE);
byte[] value = intent.getByteArrayExtra(BeaconConstants.EXTRA_KEY_RESPONSE_VALUE);
if (MokoConstants.ACTION_RESPONSE_SUCCESS.equals(action)) {
OrderType orderType = (OrderType) intent.getSerializableExtra(MokoConstants.EXTRA_KEY_RESPONSE_ORDER_TYPE);
byte[] value = intent.getByteArrayExtra(MokoConstants.EXTRA_KEY_RESPONSE_VALUE);
switch (orderType) {
case battery:
mBeaconParam.battery = Integer.parseInt(Utils.bytesToHexString(value), 16) + "";
Expand Down Expand Up @@ -278,17 +279,17 @@ public void onServiceConnected(ComponentName name, IBinder service) {
mBeaconService = ((BeaconService.LocalBinder) service).getService();
// 注册广播接收器
IntentFilter filter = new IntentFilter();
filter.addAction(BeaconConstants.ACTION_CONNECT_SUCCESS);
filter.addAction(BeaconConstants.ACTION_CONNECT_DISCONNECTED);
filter.addAction(BeaconConstants.ACTION_RESPONSE_SUCCESS);
filter.addAction(BeaconConstants.ACTION_RESPONSE_TIMEOUT);
filter.addAction(BeaconConstants.ACTION_RESPONSE_FINISH);
filter.addAction(MokoConstants.ACTION_CONNECT_SUCCESS);
filter.addAction(MokoConstants.ACTION_CONNECT_DISCONNECTED);
filter.addAction(MokoConstants.ACTION_RESPONSE_SUCCESS);
filter.addAction(MokoConstants.ACTION_RESPONSE_TIMEOUT);
filter.addAction(MokoConstants.ACTION_RESPONSE_FINISH);
filter.setPriority(200);
registerReceiver(mReceiver, filter);
if (!BeaconModule.getInstance().isBluetoothOpen()) {
if (!MokoSupport.getInstance().isBluetoothOpen()) {
// 蓝牙未打开,开启蓝牙
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, BeaconConstants.REQUEST_CODE_ENABLE_BT);
startActivityForResult(enableBtIntent, MokoConstants.REQUEST_CODE_ENABLE_BT);
}
}

Expand All @@ -307,8 +308,8 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
}

private void back() {
if (BeaconModule.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
BeaconModule.getInstance().disConnectBle();
if (MokoSupport.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
MokoSupport.getInstance().disConnectBle();
}
finish();
}
Expand All @@ -322,13 +323,13 @@ public void onClick(View view) {
back();
break;
case R.id.tv_conn_state:
if (!BeaconModule.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
if (!MokoSupport.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
mBeaconService.connDevice(mBeaconParam.iBeaconMAC);
showLoadingProgressDialog(getString(R.string.dialog_connecting));
}
break;
case R.id.rl_ibeacon_uuid:
if (!BeaconModule.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
if (!MokoSupport.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
ToastUtils.showToast(this, getString(R.string.alert_click_reconnect));
return;
}
Expand All @@ -337,7 +338,7 @@ public void onClick(View view) {
startActivityForResult(intent, BeaconConstants.REQUEST_CODE_SET_UUID);
break;
case R.id.rl_ibeacon_major:
if (!BeaconModule.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
if (!MokoSupport.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
ToastUtils.showToast(this, getString(R.string.alert_click_reconnect));
return;
}
Expand All @@ -346,7 +347,7 @@ public void onClick(View view) {
startActivityForResult(intent, BeaconConstants.REQUEST_CODE_SET_MAJOR);
break;
case R.id.rl_ibeacon_minor:
if (!BeaconModule.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
if (!MokoSupport.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
ToastUtils.showToast(this, getString(R.string.alert_click_reconnect));
return;
}
Expand All @@ -355,7 +356,7 @@ public void onClick(View view) {
startActivityForResult(intent, BeaconConstants.REQUEST_CODE_SET_MINOR);
break;
case R.id.rl_ibeacon_measure_power:
if (!BeaconModule.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
if (!MokoSupport.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
ToastUtils.showToast(this, getString(R.string.alert_click_reconnect));
return;
}
Expand All @@ -364,7 +365,7 @@ public void onClick(View view) {
startActivityForResult(intent, BeaconConstants.REQUEST_CODE_SET_MEASURE_POWER);
break;
case R.id.rl_ibeacon_transmission:
if (!BeaconModule.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
if (!MokoSupport.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
ToastUtils.showToast(this, getString(R.string.alert_click_reconnect));
return;
}
Expand All @@ -373,7 +374,7 @@ public void onClick(View view) {
startActivityForResult(intent, BeaconConstants.REQUEST_CODE_SET_TRANSMISSION);
break;
case R.id.rl_ibeacon_broadcasting_interval:
if (!BeaconModule.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
if (!MokoSupport.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
ToastUtils.showToast(this, getString(R.string.alert_click_reconnect));
return;
}
Expand All @@ -382,7 +383,7 @@ public void onClick(View view) {
startActivityForResult(intent, BeaconConstants.REQUEST_CODE_SET_BROADCASTINTERVAL);
break;
case R.id.rl_ibeacon_serialID:
if (!BeaconModule.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
if (!MokoSupport.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
ToastUtils.showToast(this, getString(R.string.alert_click_reconnect));
return;
}
Expand All @@ -391,7 +392,7 @@ public void onClick(View view) {
startActivityForResult(intent, BeaconConstants.REQUEST_CODE_SET_DEVICE_ID);
break;
case R.id.rl_ibeacon_device_name:
if (!BeaconModule.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
if (!MokoSupport.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
ToastUtils.showToast(this, getString(R.string.alert_click_reconnect));
return;
}
Expand All @@ -400,7 +401,7 @@ public void onClick(View view) {
startActivityForResult(intent, BeaconConstants.REQUEST_CODE_SET_IBEACON_NAME);
break;
case R.id.rl_ibeacon_device_conn_mode:
if (!BeaconModule.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
if (!MokoSupport.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
ToastUtils.showToast(this, getString(R.string.alert_click_reconnect));
return;
}
Expand All @@ -409,15 +410,15 @@ public void onClick(View view) {
startActivityForResult(intent, BeaconConstants.REQUEST_CODE_SET_CONNECTION_MODE);
break;
case R.id.rl_ibeacon_change_password:
if (!BeaconModule.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
if (!MokoSupport.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
ToastUtils.showToast(this, getString(R.string.alert_click_reconnect));
return;
}
intent = new Intent(this, SetPasswordActivity.class);
startActivityForResult(intent, BeaconConstants.REQUEST_CODE_SET_PASSWORD);
break;
case R.id.rl_ibeacon_device_info:
if (!BeaconModule.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
if (!MokoSupport.getInstance().isConnDevice(this, mBeaconParam.iBeaconMAC)) {
ToastUtils.showToast(this, getString(R.string.alert_click_reconnect));
return;
}
Expand Down
Loading

0 comments on commit c45f466

Please sign in to comment.