Commit 4fe6c6e0911ddff1362e2ebd28522b3a02751ae2

Authored by 韩亚云
2 parents 52f94a04 801f67e2

Merge branch 'master' of bj.gitlab.cnlive.com:cnlive-team/ModulePedometer

config.gradle
@@ -21,7 +21,7 @@ ext { @@ -21,7 +21,7 @@ ext {
21 //编译方式 21 //编译方式
22 debug : false, 22 debug : false,
23 //版本号 23 //版本号
24 - version: "0.7.2", 24 + version: "0.7.8",
25 //Lib库前缀 25 //Lib库前缀
26 packeg : "com.cnlive.module", 26 packeg : "com.cnlive.module",
27 //Lib库名称 27 //Lib库名称
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunningMapFragmentView.java
@@ -303,8 +303,8 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener @@ -303,8 +303,8 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
303 public void onClick(View view) { 303 public void onClick(View view) {
304 //先获取打点数量 304 //先获取打点数量
305 int canTakePointCount = CollStepUtil.getCollImportPointSize(getContext(), CollCommonInfo.getUserId(getContext())); 305 int canTakePointCount = CollStepUtil.getCollImportPointSize(getContext(), CollCommonInfo.getUserId(getContext()));
306 - if (0 == canTakePointCount) {  
307 - AlertUtil.showDeftToast(getContext(), "您尚未打点,请打点后结束"); 306 + if (canTakePointCount<2) {
  307 + AlertUtil.showDeftToast(getContext(), "请至少打两个点后结束");
308 } else { 308 } else {
309 if (null != followMyLocation) { 309 if (null != followMyLocation) {
310 currentImportLatLng = new LatLng(followMyLocation.latitude, followMyLocation.longitude); 310 currentImportLatLng = new LatLng(followMyLocation.latitude, followMyLocation.longitude);
@@ -653,28 +653,31 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener @@ -653,28 +653,31 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
653 fragment.binding.ivGpsState.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_3)); 653 fragment.binding.ivGpsState.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_3));
654 } 654 }
655 } 655 }
656 - if (followMyLocation == null || followMyLocation.latitude == 0 || followMyLocation.longitude == 0) { 656 + //过滤定位精度
  657 + if (location.getRadius() > Constant.LOCA_ACCURACY) {
657 return; 658 return;
658 } 659 }
659 - MapStatus.Builder builder = new MapStatus.Builder();  
660 - mCurrentAccracy = location.getRadius();  
661 - followMyLocation = new MyLocationData.Builder()  
662 - .accuracy(location.getRadius())  
663 - // 此处设置开发者获取到的方向信息,顺时针0-360  
664 - .direction(mCurrentDirection).latitude(location.getLatitude())  
665 - .longitude(location.getLongitude()).build();  
666 //第一次定位 660 //第一次定位
667 if (isFirstLoc) { 661 if (isFirstLoc) {
668 isFirstLoc = false; 662 isFirstLoc = false;
  663 + mCurrentAccracy = location.getRadius();
  664 + followMyLocation = new MyLocationData.Builder()
  665 + .accuracy(location.getRadius())
  666 + // 此处设置开发者获取到的方向信息,顺时针0-360
  667 + .direction(mCurrentDirection).latitude(location.getLatitude())
  668 + .longitude(location.getLongitude()).build();
669 baiduMap.setMyLocationData(followMyLocation); 669 baiduMap.setMyLocationData(followMyLocation);
  670 + MapStatus.Builder builder = new MapStatus.Builder();
670 builder.target(new LatLng(followMyLocation.latitude, followMyLocation.longitude)).zoom(DEFULT_ZOOM); 671 builder.target(new LatLng(followMyLocation.latitude, followMyLocation.longitude)).zoom(DEFULT_ZOOM);
671 baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); 672 baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
672 } else { 673 } else {
673 //不是第一次定位状态 674 //不是第一次定位状态
674 - //过滤定位精度  
675 - if (location.getRadius() > Constant.LOCA_ACCURACY) {  
676 - return;  
677 - } 675 + mCurrentAccracy = location.getRadius();
  676 + followMyLocation = new MyLocationData.Builder()
  677 + .accuracy(location.getRadius())
  678 + // 此处设置开发者获取到的方向信息,顺时针0-360
  679 + .direction(mCurrentDirection).latitude(location.getLatitude())
  680 + .longitude(location.getLongitude()).build();
678 if (null != currentWalkPoints) { 681 if (null != currentWalkPoints) {
679 if (currentWalkPoints.size() > 0) { 682 if (currentWalkPoints.size() > 0) {
680 //进行判断 683 //进行判断
@@ -689,7 +692,6 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener @@ -689,7 +692,6 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
689 currentWalkPoints.add(new LatLng(location.getLatitude(), 692 currentWalkPoints.add(new LatLng(location.getLatitude(),
690 location.getLongitude())); 693 location.getLongitude()));
691 } 694 }
692 -  
693 //判断当前集合列表是否可以划线(至少两个点) 695 //判断当前集合列表是否可以划线(至少两个点)
694 if (currentWalkPoints != null && currentWalkPoints.size() > 1) { 696 if (currentWalkPoints != null && currentWalkPoints.size() > 1) {
695 //判断当前是否已经在地图上画点 697 //判断当前是否已经在地图上画点
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollTraceListDetailFragmentView.java
@@ -204,7 +204,7 @@ public class CollTraceListDetailFragmentView implements MvpView, OnFenceListener @@ -204,7 +204,7 @@ public class CollTraceListDetailFragmentView implements MvpView, OnFenceListener
204 startLocation.setPointName(eventShoeLinesBean.getStartLocation()); 204 startLocation.setPointName(eventShoeLinesBean.getStartLocation());
205 startLocation.setLatitude(0); 205 startLocation.setLatitude(0);
206 startLocation.setLongitude(0); 206 startLocation.setLongitude(0);
207 - }else { 207 + } else {
208 startLocation = new CollectPoint(); 208 startLocation = new CollectPoint();
209 startLocation.setPointName(""); 209 startLocation.setPointName("");
210 startLocation.setLatitude(0); 210 startLocation.setLatitude(0);
@@ -217,7 +217,7 @@ public class CollTraceListDetailFragmentView implements MvpView, OnFenceListener @@ -217,7 +217,7 @@ public class CollTraceListDetailFragmentView implements MvpView, OnFenceListener
217 endLocation.setPointName(eventShoeLinesBean.getEndLocation()); 217 endLocation.setPointName(eventShoeLinesBean.getEndLocation());
218 endLocation.setLatitude(0); 218 endLocation.setLatitude(0);
219 endLocation.setLongitude(0); 219 endLocation.setLongitude(0);
220 - }else { 220 + } else {
221 endLocation = new CollectPoint(); 221 endLocation = new CollectPoint();
222 endLocation.setPointName(""); 222 endLocation.setPointName("");
223 endLocation.setLatitude(0); 223 endLocation.setLatitude(0);
@@ -253,7 +253,7 @@ public class CollTraceListDetailFragmentView implements MvpView, OnFenceListener @@ -253,7 +253,7 @@ public class CollTraceListDetailFragmentView implements MvpView, OnFenceListener
253 //设置用户头像 253 //设置用户头像
254 if (!TextUtils.isEmpty(eventShoeLinesBean.getUserMsg().getImage())) { 254 if (!TextUtils.isEmpty(eventShoeLinesBean.getUserMsg().getImage())) {
255 GlideApp.with(getContext()).load(eventShoeLinesBean.getUserMsg().getImage()).into(fragment.binding.includeFinishUserInfo.qmIvIcon); 255 GlideApp.with(getContext()).load(eventShoeLinesBean.getUserMsg().getImage()).into(fragment.binding.includeFinishUserInfo.qmIvIcon);
256 - }else { 256 + } else {
257 GlideApp.with(getContext()).load(getContext().getResources().getString(R.string.default_face_url)).into(fragment.binding.includeFinishUserInfo.qmIvIcon); 257 GlideApp.with(getContext()).load(getContext().getResources().getString(R.string.default_face_url)).into(fragment.binding.includeFinishUserInfo.qmIvIcon);
258 } 258 }
259 //设置用户行走公里 259 //设置用户行走公里
@@ -414,7 +414,7 @@ public class CollTraceListDetailFragmentView implements MvpView, OnFenceListener @@ -414,7 +414,7 @@ public class CollTraceListDetailFragmentView implements MvpView, OnFenceListener
414 if (5102 == createFenceResponse.getStatus()) { 414 if (5102 == createFenceResponse.getStatus()) {
415 QMUITipDialogUtil.dismessDialog(); 415 QMUITipDialogUtil.dismessDialog();
416 QMUITipDialogUtil.failedDialog(fragment.getActivity(), createFenceResponse.getMessage(), 1); 416 QMUITipDialogUtil.failedDialog(fragment.getActivity(), createFenceResponse.getMessage(), 1);
417 - } else { 417 + } else if (0 == createFenceResponse.getStatus()) {
418 if (null != eventShoeLinesBean) { 418 if (null != eventShoeLinesBean) {
419 QMUITipDialogUtil.dismessDialog(); 419 QMUITipDialogUtil.dismessDialog();
420 if (null == fragment.getPresenter() || null == getContext()) { 420 if (null == fragment.getPresenter() || null == getContext()) {
@@ -422,6 +422,9 @@ public class CollTraceListDetailFragmentView implements MvpView, OnFenceListener @@ -422,6 +422,9 @@ public class CollTraceListDetailFragmentView implements MvpView, OnFenceListener
422 } 422 }
423 fragment.getPresenter().bindingShoeLine(getContext(), eventShoeLinesBean.getId(), eventShoeLinesBean.getEventId(), createFenceResponse.getFenceId() + "", eventShoeLinesBean.getEventName(), position); 423 fragment.getPresenter().bindingShoeLine(getContext(), eventShoeLinesBean.getId(), eventShoeLinesBean.getEventId(), createFenceResponse.getFenceId() + "", eventShoeLinesBean.getEventName(), position);
424 } 424 }
  425 + } else {
  426 + QMUITipDialogUtil.dismessDialog();
  427 + QMUITipDialogUtil.failedDialog(fragment.getActivity(), createFenceResponse.getMessage(), 1);
425 } 428 }
426 } 429 }
427 430
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/StartTraceFragmentView.java
@@ -347,8 +347,6 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { @@ -347,8 +347,6 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener {
347 option.setCoorType("gcj02"); // 设置坐标类型 347 option.setCoorType("gcj02"); // 设置坐标类型
348 //可选,默认false,设置是否开启Gps定位 348 //可选,默认false,设置是否开启Gps定位
349 option.setOpenGps(true); 349 option.setOpenGps(true);
350 - //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者,该模式下开发者无需再关心定位间隔是多少,定位SDK本身发现位置变化就会及时回调给开发者  
351 - option.setOpenAutoNotifyMode();  
352 //可选,默认高精度,设置定位模式,高精度,低功耗,仅设备 350 //可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
353 option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); 351 option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
354 //可选,设置是否需要地址信息,默认不需要 352 //可选,设置是否需要地址信息,默认不需要
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/receivers/CollServiceReceiver.java
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint; @@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
4 import android.content.BroadcastReceiver; 4 import android.content.BroadcastReceiver;
5 import android.content.Context; 5 import android.content.Context;
6 import android.content.Intent; 6 import android.content.Intent;
  7 +import android.media.AudioManager;
7 import android.os.Build; 8 import android.os.Build;
8 import android.os.PowerManager; 9 import android.os.PowerManager;
9 import android.util.Log; 10 import android.util.Log;
@@ -35,6 +36,9 @@ public class CollServiceReceiver extends BroadcastReceiver { @@ -35,6 +36,9 @@ public class CollServiceReceiver extends BroadcastReceiver {
35 @Override 36 @Override
36 public void onReceive(Context context, Intent intent) { 37 public void onReceive(Context context, Intent intent) {
37 Log.e(TAG, "接收到广播:" + intent.getAction()); 38 Log.e(TAG, "接收到广播:" + intent.getAction());
  39 + if (null!=context){
  40 + initSound(context);
  41 + }
38 //todo 这里判断要保活的服务 42 //todo 这里判断要保活的服务
39 boolean isRunStepService = CollCommonInfo.getIsRunStepService(context); 43 boolean isRunStepService = CollCommonInfo.getIsRunStepService(context);
40 if (isRunStepService) { 44 if (isRunStepService) {
@@ -97,7 +101,16 @@ public class CollServiceReceiver extends BroadcastReceiver { @@ -97,7 +101,16 @@ public class CollServiceReceiver extends BroadcastReceiver {
97 101
98 } 102 }
99 } 103 }
100 - 104 + private void initSound(Context context) {
  105 + try {
  106 + AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
  107 + int currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
  108 + if (0 == currentVolume) {
  109 + audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 1, AudioManager.FLAG_PLAY_SOUND);
  110 + }
  111 + } catch (Exception e) {
  112 + }
  113 + }
101 // /** 114 // /**
102 // * 发送关闭广播 115 // * 发送关闭广播
103 // */ 116 // */
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/activity/CollRunRaceDetailActivity.java
@@ -71,7 +71,7 @@ public class CollRunRaceDetailActivity extends QMUIFragmentActivity { @@ -71,7 +71,7 @@ public class CollRunRaceDetailActivity extends QMUIFragmentActivity {
71 super.onResume(); 71 super.onResume();
72 boolean isSet = CheckUtil.isIgnoringBatteryOptimizationss(this); 72 boolean isSet = CheckUtil.isIgnoringBatteryOptimizationss(this);
73 if (!isSet) { 73 if (!isSet) {
74 - isSet = CheckUtil.isIgnoringBatteryOptimizationss(this); 74 + CheckUtil.toSetIgnore(this);
75 } 75 }
76 76
77 } 77 }
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/activity/StartCollectTraceActivity.java
@@ -75,11 +75,13 @@ public class StartCollectTraceActivity extends QMUIFragmentActivity { @@ -75,11 +75,13 @@ public class StartCollectTraceActivity extends QMUIFragmentActivity {
75 } else { 75 } else {
76 boolean isSetBattery = CheckUtil.isIgnoringBatteryOptimizationss(StartCollectTraceActivity.this); 76 boolean isSetBattery = CheckUtil.isIgnoringBatteryOptimizationss(StartCollectTraceActivity.this);
77 if (!isSetBattery) { 77 if (!isSetBattery) {
78 - isSetBattery = CheckUtil.isIgnoringBatteryOptimizationss(StartCollectTraceActivity.this); 78 + CheckUtil.toSetIgnore(this);
79 } else { 79 } else {
80 getPermissionsWithTip(); 80 getPermissionsWithTip();
81 } 81 }
82 } 82 }
  83 + } else {
  84 + NotificationUtil.goToSettingNo(this);
83 } 85 }
84 } 86 }
85 87
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RegistrationInfoView.java
@@ -135,7 +135,7 @@ public class RegistrationInfoView implements MvpView, OnDateSetListener { @@ -135,7 +135,7 @@ public class RegistrationInfoView implements MvpView, OnDateSetListener {
135 if(millseconds < System.currentTimeMillis()){ 135 if(millseconds < System.currentTimeMillis()){
136 String birthday = DateTimeUtil.formatDateTime(millseconds, "yyyy-MM-dd"); 136 String birthday = DateTimeUtil.formatDateTime(millseconds, "yyyy-MM-dd");
137 CommonInfo.setBirthday(fragment.getActivity(),birthday,userId); 137 CommonInfo.setBirthday(fragment.getActivity(),birthday,userId);
138 - fragment.binding.birthday.setText(DateTimeUtil.formatDateTime(millseconds, "yyyy-MM-dd")); 138 + fragment.binding.birthday.setText(birthday);
139 }else { 139 }else {
140 AlertUtil.showDeftToast(fragment.getActivity(),"无法选择该日期"); 140 AlertUtil.showDeftToast(fragment.getActivity(),"无法选择该日期");
141 } 141 }
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunMainFragmentView.java
@@ -641,8 +641,7 @@ public class RunMainFragmentView implements MvpView { @@ -641,8 +641,7 @@ public class RunMainFragmentView implements MvpView {
641 Log.e(TAG, "setSQLPauseTime: "); 641 Log.e(TAG, "setSQLPauseTime: ");
642 // if (needWriteDataFlag) { 642 // if (needWriteDataFlag) {
643 //将当前计时器时间戳写入数据库 643 //将当前计时器时间戳写入数据库
644 - if (!TextUtils.isEmpty(id)) {  
645 - UserStepEntity userStepEntity = StepUtil.getUserStepData(fragment.getActivity(), uid); 644 + UserStepEntity userStepEntity = StepUtil.getUserStepData(fragment.getActivity(), id);
646 if (userStepEntity != null) { 645 if (userStepEntity != null) {
647 userStepEntity.setChronometerBase(fragment.binding.chronometer.getBase()); 646 userStepEntity.setChronometerBase(fragment.binding.chronometer.getBase());
648 //设置当前暂停的时间戳 647 //设置当前暂停的时间戳
@@ -654,7 +653,6 @@ public class RunMainFragmentView implements MvpView { @@ -654,7 +653,6 @@ public class RunMainFragmentView implements MvpView {
654 //更新数据 653 //更新数据
655 StepUtil.updateStepData(fragment.getActivity(), userStepEntity); 654 StepUtil.updateStepData(fragment.getActivity(), userStepEntity);
656 } 655 }
657 - }  
658 // } 656 // }
659 } 657 }
660 658
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunningMapFragmentView.java
@@ -397,7 +397,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { @@ -397,7 +397,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
397 MapStatus.Builder builder = new MapStatus.Builder(); 397 MapStatus.Builder builder = new MapStatus.Builder();
398 //不是第一次定位状态 398 //不是第一次定位状态
399 if (!isFirstLoc) { 399 if (!isFirstLoc) {
400 - if (currentPoints.size() > 0) { 400 + if (null != currentPoints && currentPoints.size() > 0) {
401 //进行判断 401 //进行判断
402 LatLng lastLatLng = currentPoints.get(currentPoints.size() - 1); 402 LatLng lastLatLng = currentPoints.get(currentPoints.size() - 1);
403 LatLng curLatLng = new LatLng(location.getLatitude(), 403 LatLng curLatLng = new LatLng(location.getLatitude(),
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/receivers/ServiceReceiver.java
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint; @@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
4 import android.content.BroadcastReceiver; 4 import android.content.BroadcastReceiver;
5 import android.content.Context; 5 import android.content.Context;
6 import android.content.Intent; 6 import android.content.Intent;
  7 +import android.media.AudioManager;
7 import android.os.Build; 8 import android.os.Build;
8 import android.os.PowerManager; 9 import android.os.PowerManager;
9 import android.util.Log; 10 import android.util.Log;
@@ -36,6 +37,9 @@ public class ServiceReceiver extends BroadcastReceiver { @@ -36,6 +37,9 @@ public class ServiceReceiver extends BroadcastReceiver {
36 @Override 37 @Override
37 public void onReceive(Context context, Intent intent) { 38 public void onReceive(Context context, Intent intent) {
38 Log.e(TAG, "接收到广播:" + intent.getAction()); 39 Log.e(TAG, "接收到广播:" + intent.getAction());
  40 + if (null != context) {
  41 + initSound(context);
  42 + }
39 //todo 这里判断要保活的服务 43 //todo 这里判断要保活的服务
40 boolean isRunStepService = CommonInfo.getIsRunStepService(context); 44 boolean isRunStepService = CommonInfo.getIsRunStepService(context);
41 if (isRunStepService) { 45 if (isRunStepService) {
@@ -45,7 +49,7 @@ public class ServiceReceiver extends BroadcastReceiver { @@ -45,7 +49,7 @@ public class ServiceReceiver extends BroadcastReceiver {
45 } else { 49 } else {
46 context.startService(new Intent(context, StepService.class)); 50 context.startService(new Intent(context, StepService.class));
47 } 51 }
48 - }else { 52 + } else {
49 Log.e(TAG, "计步服务已经在运行"); 53 Log.e(TAG, "计步服务已经在运行");
50 54
51 } 55 }
@@ -56,7 +60,7 @@ public class ServiceReceiver extends BroadcastReceiver { @@ -56,7 +60,7 @@ public class ServiceReceiver extends BroadcastReceiver {
56 if (StepService.mClient != null && StepService.mTrace != null && StepService.traceListener != null) { 60 if (StepService.mClient != null && StepService.mTrace != null && StepService.traceListener != null) {
57 StepService.mClient.startTrace(StepService.mTrace, StepService.traceListener); 61 StepService.mClient.startTrace(StepService.mTrace, StepService.traceListener);
58 } 62 }
59 - }else { 63 + } else {
60 Log.e(TAG, "鹰眼服务已经在运行"); 64 Log.e(TAG, "鹰眼服务已经在运行");
61 65
62 } 66 }
@@ -99,6 +103,16 @@ public class ServiceReceiver extends BroadcastReceiver { @@ -99,6 +103,16 @@ public class ServiceReceiver extends BroadcastReceiver {
99 } 103 }
100 } 104 }
101 105
  106 + private void initSound(Context context) {
  107 + try {
  108 + AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
  109 + int currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
  110 + if (0 == currentVolume) {
  111 + audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 1, AudioManager.FLAG_PLAY_SOUND);
  112 + }
  113 + } catch (Exception e) {
  114 + }
  115 + }
102 // /** 116 // /**
103 // * 发送关闭广播 117 // * 发送关闭广播
104 // */ 118 // */
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/RunRaceDetailActivity.java
@@ -142,11 +142,13 @@ public class RunRaceDetailActivity extends QMUIFragmentActivity { @@ -142,11 +142,13 @@ public class RunRaceDetailActivity extends QMUIFragmentActivity {
142 } else { 142 } else {
143 boolean isSetBattery = CheckUtil.isIgnoringBatteryOptimizationss(RunRaceDetailActivity.this); 143 boolean isSetBattery = CheckUtil.isIgnoringBatteryOptimizationss(RunRaceDetailActivity.this);
144 if (!isSetBattery) { 144 if (!isSetBattery) {
145 - isSetBattery = CheckUtil.isIgnoringBatteryOptimizationss(RunRaceDetailActivity.this); 145 + CheckUtil.toSetIgnore(this);
146 } else { 146 } else {
147 getPermissionsWithTip(); 147 getPermissionsWithTip();
148 } 148 }
149 } 149 }
  150 + }else {
  151 + NotificationUtil.goToSettingNo(this);
150 } 152 }
151 153
152 } 154 }
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/CheckUtil.java
@@ -7,6 +7,7 @@ import android.content.pm.PackageManager; @@ -7,6 +7,7 @@ import android.content.pm.PackageManager;
7 import android.net.Uri; 7 import android.net.Uri;
8 import android.os.PowerManager; 8 import android.os.PowerManager;
9 import android.provider.Settings; 9 import android.provider.Settings;
  10 +import android.widget.Toast;
10 11
11 import com.cnlive.libs.base.util.AlertUtil; 12 import com.cnlive.libs.base.util.AlertUtil;
12 13
@@ -21,27 +22,34 @@ public class CheckUtil { @@ -21,27 +22,34 @@ public class CheckUtil {
21 * @return 22 * @return
22 */ 23 */
23 public static boolean isIgnoringBatteryOptimizationss(Activity context) { 24 public static boolean isIgnoringBatteryOptimizationss(Activity context) {
24 - String carrier = android.os.Build.MANUFACTURER;  
25 - if (!"smartisan".equals(carrier)) {  
26 - PowerManager powerManager = (PowerManager) context.getSystemService(POWER_SERVICE);  
27 - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {  
28 - boolean hasIgnored = powerManager.isIgnoringBatteryOptimizations(context.getPackageName());  
29 - if (!hasIgnored) {  
30 - Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);  
31 - intent.setData(Uri.parse("package:" + context.getPackageName()));  
32 - PackageManager pm = context.getPackageManager();  
33 - if (intent.resolveActivity(pm) != null) {  
34 - context.startActivity(intent);  
35 - }  
36 - AlertUtil.showDeftToast(context, "请选择允许加入电池优化白名单,否则将会影响您的正常使用!");  
37 - return false;  
38 - } else {  
39 - return true; 25 + try {
  26 + String carrier = android.os.Build.MANUFACTURER;
  27 + if (!"smartisan".equals(carrier)) {
  28 + PowerManager powerManager = (PowerManager) context.getSystemService(POWER_SERVICE);
  29 + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
  30 + boolean hasIgnored = powerManager.isIgnoringBatteryOptimizations(context.getPackageName());
  31 + return hasIgnored;
40 } 32 }
  33 + } else {
  34 + return true;
41 } 35 }
42 - } else { 36 + return false;
  37 + } catch (Exception e) {
43 return true; 38 return true;
44 } 39 }
45 - return false; 40 + }
  41 +
  42 + public static void toSetIgnore(Activity context) {
  43 + try {
  44 + Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
  45 + intent.setData(Uri.parse("package:" + context.getPackageName()));
  46 + PackageManager pm = context.getPackageManager();
  47 + if (intent.resolveActivity(pm) != null) {
  48 + context.startActivity(intent);
  49 + AlertUtil.showDeftToast(context, "请选择允许加入电池优化白名单,否则将会影响您的正常使用!");
  50 +
  51 + }
  52 + } catch (Exception e) {
  53 + }
46 } 54 }
47 } 55 }
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/NotificationUtil.java
@@ -20,13 +20,10 @@ public class NotificationUtil { @@ -20,13 +20,10 @@ public class NotificationUtil {
20 //监测通知权限是否打开 20 //监测通知权限是否打开
21 notificationManagerCompat = NotificationManagerCompat.from(activity); 21 notificationManagerCompat = NotificationManagerCompat.from(activity);
22 isOpen = notificationManagerCompat.areNotificationsEnabled(); 22 isOpen = notificationManagerCompat.areNotificationsEnabled();
23 - if (!isOpen) {  
24 - goToSettingNo(activity);  
25 - }  
26 return isOpen; 23 return isOpen;
27 } 24 }
28 25
29 - private static void goToSettingNo(Activity activity) { 26 + public static void goToSettingNo(Activity activity) {
30 Toast.makeText(activity, "您尚未开启通知权限,无法进行计步", Toast.LENGTH_LONG).show(); 27 Toast.makeText(activity, "您尚未开启通知权限,无法进行计步", Toast.LENGTH_LONG).show();
31 Intent intent1 = new Intent(); 28 Intent intent1 = new Intent();
32 try { 29 try {