| | |
| | | import androidx.fragment.app.FragmentTransaction; |
| | | |
| | | import android.Manifest; |
| | | import android.app.Activity; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.pm.PackageManager; |
| | |
| | | import com.hdl.photovoltaic.utils.AppManagerUtils; |
| | | import com.hdl.photovoltaic.utils.GPSManagerUtils; |
| | | import com.hdl.photovoltaic.utils.PermissionUtils; |
| | | import com.hdl.photovoltaic.utils.SharedPreUtils; |
| | | import com.hdl.photovoltaic.widget.ConfirmationCancelDialog; |
| | | import com.hdl.photovoltaic.widget.ConfirmationTipDialog; |
| | | import com.hdl.sdk.link.HDLLinkLocalSdk; |
| | |
| | | @Override |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | setStatusBarTranslucent(); |
| | | |
| | | |
| | | getWindow().setNavigationBarColor(getColor(R.color.text_FF1C1C1E)); |
| | | //初始化碎片 |
| | | initFragment(savedInstanceState); |
| | | //初始化 |
| | |
| | | * 开启通知权限 |
| | | */ |
| | | private void notificationSet() { |
| | | boolean isBoolean = PermissionUtils.isNotificationEnabled(_mActivity); |
| | | if (!isBoolean) { |
| | | ConfirmationCancelDialog confirmationCancelDialog = new ConfirmationCancelDialog(_mActivity); |
| | | confirmationCancelDialog.setTitle(getString(R.string.loading_title_tip)); |
| | | confirmationCancelDialog.setContent(getString(R.string.no_permissions_unable_to_receive_push)); |
| | | confirmationCancelDialog.setConfirmation(getString(R.string.go_to_settings)); |
| | | confirmationCancelDialog.show(); |
| | | confirmationCancelDialog.isHideTitle(true); |
| | | confirmationCancelDialog.setYesOnclickListener(new ConfirmationCancelDialog.onYesOnclickListener() { |
| | | @Override |
| | | public void Confirm() { |
| | | confirmationCancelDialog.dismiss(); |
| | | PermissionUtils.openNotificationSettings(_mActivity); |
| | | String key = "isOpenNotificationEnabled"; |
| | | boolean isCancel = SharedPreUtils.getBoolean(key); |
| | | if (!isCancel) { |
| | | boolean isBoolean = PermissionUtils.isNotificationEnabled(_mActivity); |
| | | if (!isBoolean) { |
| | | ConfirmationCancelDialog confirmationCancelDialog = new ConfirmationCancelDialog(_mActivity); |
| | | confirmationCancelDialog.setTitle(getString(R.string.loading_title_tip)); |
| | | confirmationCancelDialog.setContent(getString(R.string.no_permissions_unable_to_receive_push)); |
| | | confirmationCancelDialog.setConfirmation(getString(R.string.go_to_settings)); |
| | | confirmationCancelDialog.show(); |
| | | confirmationCancelDialog.isHideTitle(true); |
| | | confirmationCancelDialog.setYesOnclickListener(new ConfirmationCancelDialog.onYesOnclickListener() { |
| | | @Override |
| | | public void Confirm() { |
| | | SharedPreUtils.putBoolean(key, true); |
| | | confirmationCancelDialog.dismiss(); |
| | | PermissionUtils.openNotificationSettings(_mActivity); |
| | | |
| | | } |
| | | }); |
| | | confirmationCancelDialog.setNoOnclickListener(new ConfirmationCancelDialog.onNoOnclickListener() { |
| | | @Override |
| | | public void Cancel() { |
| | | confirmationCancelDialog.dismiss(); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | confirmationCancelDialog.setNoOnclickListener(new ConfirmationCancelDialog.onNoOnclickListener() { |
| | | @Override |
| | | public void Cancel() { |
| | | SharedPreUtils.putBoolean(key, true); |
| | | confirmationCancelDialog.dismiss(); |
| | | } |
| | | }); |
| | | |
| | | } else { |
| | | SharedPreUtils.putBoolean(key, true); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | this.notificationSet(); |
| | | //ACCESS_FINE_LOCATION 允许使用GPS定位 |
| | | //ACCESS_COARSE_LOCATION 允许使用WIFI热点或基站来获取粗略的定位 |
| | | String[] ary = PermissionUtils.checkPermission(_mActivity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}); |
| | | if (ary.length > 0) { |
| | | this.requestPermissions(ary, PermissionUtils.STATUS_SUCCESS); |
| | | } else { |
| | | locationUpdates(); |
| | | } |
| | | // String[] ary = PermissionUtils.checkPermission(_mActivity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}); |
| | | // if (ary.length > 0) { |
| | | // this.requestPermissions(ary, PermissionUtils.STATUS_SUCCESS); |
| | | // } else { |
| | | // locationUpdates(); |
| | | // } |
| | | } |
| | | |
| | | @Override |
| | |
| | | allTopicsListener = new EventListener() { |
| | | @Override |
| | | public void onMessage(Object msg) { |
| | | |
| | | |
| | | if (msg == null) { |
| | | return; |
| | |
| | | uniCallBackBaseBean.setData(topicArray[1]); |
| | | HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); |
| | | HdlLogLogic.print(linkResponse.getTopic() + new Gson().toJson(linkResponse.getData()), true); |
| | | } else if (linkResponse.getTopic().endsWith("/app/thing/property/send")) { |
| | | //设备状态变更topic:/user/${homeId}/app/thing/property/send |
| | | if (linkResponse.getData() == null) { |
| | | HdlLogLogic.print("设备状态变更--->数据为空", false); |
| | | return; |
| | | } |
| | | HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean(); |
| | | uniCallBackBaseBean.setType(linkResponse.getTopic()); |
| | | uniCallBackBaseBean.setData(linkResponse.getData()); |
| | | HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); |
| | | } |
| | | } |
| | | } |