| | |
| | | //从内存里面获取不到语言,获取当前系统的; |
| | | String str = getResources().getConfiguration().locale.getCountry(); |
| | | if (str.equals("CN") || str.equals("TW")) { |
| | | UserConfigManage.getInstance().setCurrentAppLanguage(LocalManageUtil.cn); |
| | | UserConfigManage.getInstance().setCurrentAppLanguage(LocalManageUtil.zh); |
| | | } else { |
| | | UserConfigManage.getInstance().setCurrentAppLanguage(LocalManageUtil.en); |
| | | } |
| | |
| | | HDLLinkPMSdk.initWithAppKey(getInstance(), AppConfigManage.getAppKey(), AppConfigManage.getAppSecret(), AppConfigManage.getAPPRegionUrl()); |
| | | //2.设置打印 |
| | | HDLLinkPMSdk.setLogEnabled(isLogEnabled); |
| | | //3.配置接口请求语言 |
| | | Locale locale = LocalManageUtil.getSystemLocale(this); |
| | | if (!locale.getLanguage().equals("zh")) { |
| | | HDLLinkPMSdk.setLanguage("en"); |
| | | } else { |
| | | HDLLinkPMSdk.setLanguage("cn"); |
| | | if (TextUtils.isEmpty(UserConfigManage.getInstance().getCurrentAppLanguage())) { |
| | | //默认配置接口请求语言是中文 |
| | | UserConfigManage.getInstance().setCurrentAppLanguage(LocalManageUtil.zh); |
| | | } |
| | | //3.配置接口请求语言 |
| | | HDLLinkPMSdk.setLanguage(UserConfigManage.getInstance().getCurrentAppLanguage()); |
| | | |
| | | // //3.配置接口请求语言 |
| | | // Locale locale = LocalManageUtil.getSystemLocale(this); |
| | | // if (!locale.getLanguage().equals("zh")) { |
| | | // HDLLinkPMSdk.setLanguage("en"); |
| | | // } else { |
| | | // HDLLinkPMSdk.setLanguage("zh"); |
| | | // } |
| | | // HDLLinkPMSdk.setLanguage("en");//强制使用英文 |
| | | //4.监听登出处理 |
| | | HDLLinkPMUser.getInstance().setOnReloginListener(new IOnReloginListener() { |
| | |
| | | HdlLogLogic.print("测试Mqtt连接服务端失败--->"); |
| | | } |
| | | } |
| | | |
| | | public void appLocationInfo() { |
| | | LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); |
| | | if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { |
| | | // TODO: Consider calling |
| | | // ActivityCompat#requestPermissions |
| | | // here to request the missing permissions, and then overriding |
| | | // public void onRequestPermissionsResult(int requestCode, String[] permissions, |
| | | // int[] grantResults) |
| | | // to handle the case where the user grants the permission. See the documentation |
| | | // for ActivityCompat#requestPermissions for more details. |
| | | return; |
| | | } |
| | | //开始定位服务,minTimeMs最小时间间隔(单位为毫秒),minDistanceM最小距离间隔(单位为米)、最小时间间隔(单位为毫秒)等参数。 |
| | | locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, new LocationListener() { |
| | | @Override |
| | | public void onLocationChanged(@NonNull Location location) { |
| | | // 当位置发生变化时调用此方法 |
| | | double latitude = location.getLatitude(); // 获取纬度 |
| | | double longitude = location.getLongitude(); // 获取经度 |
| | | |
| | | HdlLogLogic.print("纬度--->" + latitude, true); |
| | | HdlLogLogic.print("经度--->" + longitude, true); |
| | | // 这里可以根据需求处理获取到的经纬度数据 |
| | | } |
| | | |
| | | public void onStatusChanged(String provider, int status, Bundle extras) { |
| | | } |
| | | |
| | | public void onProviderEnabled(String provider) { |
| | | } |
| | | |
| | | public void onProviderDisabled(String provider) { |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | * @param mac 设备mac |
| | | * @param date 日期 |
| | | * @param time 时间 |
| | | * @param timezone 时区 |
| | | * @param linkCallBack 回调update |
| | | */ |
| | | public void editGatewayTime(String mac, String date, String time, LinkCallBack<Boolean> linkCallBack) { |
| | | public void editGatewayTime(String mac, String date, String time, String timezone, LinkCallBack<Boolean> linkCallBack) { |
| | | String requestUrl = TopicApi.SET_GATEWAY_TIME_EDIT; |
| | | JsonObject json = new JsonObject(); |
| | | json.addProperty("date", date);// "2020-08-15" |
| | | json.addProperty("time", time);//"17:25:20" |
| | | json.addProperty("timezone", timezone);//时区(语雀https://hdl-gz.yuque.com/wnkbmh/cdrglh/yckkyp#qWOPS) |
| | | |
| | | TcpClient.getInstance().sendDataToLinkGateway(mac, requestUrl, json, "", new HDLLinkCallBack() { |
| | | @Override |
| | | public void onSuccess(String msg) { |
| | |
| | | //ACCESS_COARSE_LOCATION 允许使用WIFI热点或基站来获取粗略的定位 |
| | | if (ActivityCompat.checkSelfPermission(HDLApp.getInstance(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(HDLApp.getInstance(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { |
| | | jsonObject.addProperty("result", -2);//没有位置信息权限 |
| | | jsonObject.addProperty("des", "没有位置信息权限"); |
| | | uniCallbackData(jsonObject.toString(), callback); |
| | | return; |
| | | } |
| | | |
| | | // 判断设备是否支持定位功能 |
| | | if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { |
| | | jsonObject.addProperty("result", -1);//不支持定位功能 |
| | | jsonObject.addProperty("result", -1);//没开启定位功能 |
| | | jsonObject.addProperty("des", "没开启定位功能"); |
| | | //提示用户打开定位功能或者引导用户去系统设置页面打开定位功能 |
| | | uniCallbackData(jsonObject.toString(), callback); |
| | | return; |
| | |
| | | Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); |
| | | if (location == null) { |
| | | jsonObject.addProperty("result", -3);//没有位置信息权限 |
| | | jsonObject.addProperty("des", "没开启定位功能"); |
| | | uniCallbackData(jsonObject.toString(), callback); |
| | | return; |
| | | } |
| | | jsonObject.addProperty("result", 0);//不支持定位功能 |
| | | jsonObject.addProperty("result", 0); |
| | | jsonObject.addProperty("des", "成功"); |
| | | jsonObject.addProperty("longitude", location.getLongitude());//经度 |
| | | jsonObject.addProperty("latitude", location.getLatitude());//纬度 |
| | | uniCallbackData(jsonObject.toString(), callback); |
| | |
| | | String mac = getKeyValue("mac", getKeyValue("data", data)); |
| | | String date = getKeyValue("date", getKeyValue("data", data)); |
| | | String time = getKeyValue("time", getKeyValue("data", data)); |
| | | HdlDeviceLogic.getInstance().editGatewayTime(mac, date, time, new LinkCallBack<Boolean>() { |
| | | String timezone = getKeyValue("timezone", getKeyValue("data", data)); |
| | | HdlDeviceLogic.getInstance().editGatewayTime(mac, date, time, timezone, new LinkCallBack<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | uniCallbackData(true, callback); |
| | |
| | | viewBinding.homeLoginInstallUserTv.setSelected(UserConfigManage.getInstance().isBAccount()); |
| | | viewBinding.homeLoginPrivacyCheckIv.setSelected(UserConfigManage.getInstance().isAcceiptPolicy()); |
| | | setStringDifferentColors(viewBinding.homeLoginPrivacyTv); |
| | | if (UserConfigManage.getInstance().getCurrentAppLanguage().equals(LocalManageUtil.cn)) { |
| | | if (UserConfigManage.getInstance().getCurrentAppLanguage().equals(LocalManageUtil.zh)) { |
| | | viewBinding.homeLoginLanguageTv.setText("简体中文"); |
| | | } else { |
| | | viewBinding.homeLoginLanguageTv.setText("English"); |
| | |
| | | private String noon;//正午时间 |
| | | private String broadcast_time;//广播时间间隔 |
| | | private String localtimestamp;//本地时间时间戳 |
| | | private String zone;//时区 |
| | | |
| | | |
| | | private String timezone;//时区 |
| | | private DstBean dst; |
| | | |
| | | public String getDate() { |
| | |
| | | this.localtimestamp = localtimestamp; |
| | | } |
| | | |
| | | public String getZone() { |
| | | return zone == null ? "" : zone; |
| | | public String getTimezone() { |
| | | return timezone == null ? "" : timezone; |
| | | } |
| | | |
| | | public void setZone(String zone) { |
| | | this.zone = zone; |
| | | public void setTimezone(String timezone) { |
| | | this.timezone = timezone; |
| | | } |
| | | |
| | | public DstBean getDst() { |
| | |
| | | viewBinding.toolbarTopFragmentHouseListRl.topBackBtn.setVisibility(View.VISIBLE); |
| | | viewBinding.toolbarTopFragmentHouseListRl.topBarView.setBackgroundColor(getResources().getColor(R.color.text_FFFFFFFF, null)); |
| | | |
| | | if (UserConfigManage.getInstance().getCurrentAppLanguage().equals(LocalManageUtil.cn)) { |
| | | if (UserConfigManage.getInstance().getCurrentAppLanguage().equals(LocalManageUtil.zh)) { |
| | | //中文 |
| | | if (this.typeIntValue == 0) { |
| | | //用户协议 |
| | |
| | | */ |
| | | public class LocalManageUtil { |
| | | |
| | | public static final String cn = "cn";//中文 |
| | | public static final String zh = "zh";//中文你 |
| | | public static final String en = "en";//英文 |
| | | |
| | | // private static Locale mLocale; |
| | |
| | | LanguageAdapter.ItemData zh = new LanguageAdapter.ItemData(); |
| | | zh.setState(false); |
| | | zh.setTitle("简体中文"); |
| | | zh.setLanguage(LocalManageUtil.cn); |
| | | zh.setLanguage(LocalManageUtil.zh); |
| | | list.add(zh); |
| | | LanguageAdapter.ItemData en = new LanguageAdapter.ItemData(); |
| | | en.setState(false); |
| | |
| | | // Locale locale = context.getResources().getConfiguration().locale; |
| | | // String language = locale.getLanguage(); |
| | | String language = UserConfigManage.getInstance().getCurrentAppLanguage(); |
| | | return language.equals(cn); |
| | | return language.equals(zh); |
| | | } |
| | | |
| | | public static List<NationBean> getNationBeans() { |