version:2.3
fix: update:固定横屏,增加家庭空间
This commit is contained in:
@@ -22,9 +22,9 @@
|
||||
<!-- 允许访问网络,必选权限 -->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<!-- 允许获取精确位置,精准定位必选 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<!-- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />-->
|
||||
<!-- 允许获取粗略位置,粗略定位必选 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<!-- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />-->
|
||||
<!-- 允许获取设备和运营商信息,用于问题排查和网络定位(无gps情况下的定位),若需网络定位功能则必选 -->
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<!-- 允许获取网络状态,用于网络定位(无gps情况下的定位),若需网络定位功能则必选 -->
|
||||
@@ -34,9 +34,9 @@
|
||||
<!-- 允许获取wifi状态改变,用于网络定位(无gps情况下的定位),若需网络定位功能则必选 -->
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||
<!-- 后台获取位置信息,若需后台定位则必选 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
|
||||
<!-- <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />-->
|
||||
<!-- 用于申请调用A-GPS模块,卫星定位加速 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
|
||||
<!-- <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />-->
|
||||
<!-- 允许写设备缓存,用于问题排查 -->
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
||||
<!-- 允许写入扩展存储,用于写入缓存定位数据 -->
|
||||
@@ -91,6 +91,7 @@
|
||||
android:launchMode="singleTask"
|
||||
android:resizeableActivity="true"
|
||||
android:resumeWhilePausing="true"
|
||||
android:screenOrientation="userLandscape"
|
||||
android:stateNotNeeded="true"
|
||||
android:taskAffinity="com.example.taskaffinity.newtask"
|
||||
android:windowSoftInputMode="adjustPan">
|
||||
@@ -106,7 +107,7 @@
|
||||
</activity>
|
||||
<activity android:name=".activity.contact.ContactActivity" />
|
||||
<activity
|
||||
android:name=".activity.code.HealthCodeActivity"
|
||||
android:name=".activity.code.FamilySpaceActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="sensorPortrait" />
|
||||
<activity
|
||||
@@ -171,14 +172,17 @@
|
||||
<intent-filter>
|
||||
<action android:name="android.service.notification.NotificationListenerService" />
|
||||
</intent-filter>
|
||||
</service> <!-- 声明service组件 -->
|
||||
<service
|
||||
android:name="com.baidu.location.f"
|
||||
android:enabled="true"
|
||||
android:process=":remote" /> <!-- 应用的其它配置 -->
|
||||
<uses-library
|
||||
android:name="org.apache.http.legacy"
|
||||
android:required="false" />
|
||||
</service>
|
||||
|
||||
<!-- <!– 声明service组件 –>-->
|
||||
<!-- <service-->
|
||||
<!-- android:name="com.baidu.location.f"-->
|
||||
<!-- android:enabled="true"-->
|
||||
<!-- android:process=":remote" /> -->
|
||||
<!-- <!– 应用的其它配置 –>-->
|
||||
<!-- <uses-library-->
|
||||
<!-- android:name="org.apache.http.legacy"-->
|
||||
<!-- android:required="false" />-->
|
||||
|
||||
<activity
|
||||
android:name="com.tencent.android.tpush.TpnsActivity"
|
||||
|
||||
31
app/src/main/aidl/com/uiuios/sn/IGetInfoInterface.aidl
Normal file
31
app/src/main/aidl/com/uiuios/sn/IGetInfoInterface.aidl
Normal file
@@ -0,0 +1,31 @@
|
||||
// IGetInfoInterface.aidl
|
||||
package com.uiuios.sn;
|
||||
|
||||
// Declare any non-default types here with import statements
|
||||
|
||||
interface IGetInfoInterface {
|
||||
/**
|
||||
* Demonstrates some basic types that you can use as parameters
|
||||
* and return values in AIDL.
|
||||
*/
|
||||
void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat,
|
||||
double aDouble, String aString);
|
||||
|
||||
//获取sn
|
||||
String getSerial();
|
||||
//获取用户信息
|
||||
String getUserInfo();
|
||||
//获取隐藏APP
|
||||
List<String> getHideAPP();
|
||||
//获取禁止打开的APP
|
||||
List<String> getForbidAPP();
|
||||
|
||||
//获取app设置
|
||||
String getAppTimeControl();
|
||||
//获取整机设置
|
||||
String getSnTimeControl();
|
||||
//获取系统设置
|
||||
String getSetting();
|
||||
//获取定位结果
|
||||
String getMapResult();
|
||||
}
|
||||
@@ -30,11 +30,10 @@ import android.widget.TextView;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.baidu.location.BDAbstractLocationListener;
|
||||
import com.baidu.location.BDLocation;
|
||||
import com.baidu.location.LocationClient;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.manager.AmapManager;
|
||||
import com.uiuios.aios.config.CommonConfig;
|
||||
import com.uiuios.aios.manager.RemoteManager;
|
||||
import com.uiuios.aios.utils.BrightnessUtils;
|
||||
import com.uiuios.aios.view.RulerSeekBar;
|
||||
|
||||
@@ -726,49 +725,18 @@ public class ControlActivity extends AppCompatActivity {
|
||||
});
|
||||
}
|
||||
|
||||
private LocationClient locationClient;
|
||||
|
||||
private void getLocation() {
|
||||
BDLocation bdLocation = AmapManager.getInstance().getNowMapLocation();
|
||||
if (bdLocation != null) {
|
||||
if (bdLocation.getLocType() == BDLocation.TypeGpsLocation // GPS定位结果
|
||||
|| bdLocation.getLocType() == BDLocation.TypeNetWorkLocation // 网络定位结果
|
||||
|| bdLocation.getLocType() == BDLocation.TypeOffLineLocation) {// 离线定位结果
|
||||
tv_location.setText(bdLocation.getAddrStr());
|
||||
} else {
|
||||
tv_location.setText("未知");
|
||||
}
|
||||
String addr = MMKV.defaultMMKV().decodeString(CommonConfig.MAP_ADDRESS_KEY);
|
||||
|
||||
if (TextUtils.isEmpty(addr)) {
|
||||
tv_location.setText("未知");
|
||||
} else {
|
||||
tv_location.setText("定位失败");
|
||||
tv_location.setText(addr);
|
||||
}
|
||||
startLocation();
|
||||
cl_location.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
startLocation();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void startLocation() {
|
||||
if (locationClient == null) {
|
||||
locationClient = AmapManager.getInstance().getLocationClient();
|
||||
}
|
||||
locationClient.stop();
|
||||
locationClient.start();
|
||||
locationClient.registerLocationListener(new BDAbstractLocationListener() {
|
||||
@Override
|
||||
public void onReceiveLocation(BDLocation bdLocation) {
|
||||
switch (bdLocation.getLocType()) {
|
||||
case BDLocation.TypeGpsLocation:// GPS定位结果
|
||||
case BDLocation.TypeNetWorkLocation:// 网络定位结果
|
||||
case BDLocation.TypeOffLineLocation:// 离线定位结果
|
||||
tv_location.setText(bdLocation.getAddrStr());
|
||||
break;
|
||||
default:
|
||||
tv_location.setText("定位失败");
|
||||
break;
|
||||
}
|
||||
RemoteManager.getInstance().getLocation();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ import com.tencent.mmkv.MMKV;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.Contact;
|
||||
import com.uiuios.aios.config.CommonConfig;
|
||||
import com.uiuios.aios.disklrucache.CacheHelper;
|
||||
import com.uiuios.aios.manager.AmapManager;
|
||||
import com.uiuios.aios.network.NetInterfaceManager;
|
||||
import com.uiuios.aios.network.URLAddress;
|
||||
import com.uiuios.aios.receiver.BootReceiver;
|
||||
@@ -97,9 +97,9 @@ public class EmergencyActivity extends AppCompatActivity {
|
||||
Log.e(TAG, "accept: " + (time - aLong - 1));
|
||||
} else {
|
||||
MMKV mmkv = MMKV.defaultMMKV();
|
||||
String longitude = mCacheHelper.getAsString(AmapManager.LONGITUDE_KEY);
|
||||
String latitude = mCacheHelper.getAsString(AmapManager.LATITUDE_KEY);
|
||||
String address = mCacheHelper.getAsString(AmapManager.ADDRESS_KEY);
|
||||
String longitude = mCacheHelper.getAsString(CommonConfig.MAP_LONGITUDE_KEY);
|
||||
String latitude = mCacheHelper.getAsString(CommonConfig.MAP_LATITUDE_KEY);
|
||||
String address = mCacheHelper.getAsString(CommonConfig.MAP_ADDRESS_KEY);
|
||||
NetInterfaceManager.getInstance()
|
||||
.getSOSRecordObservable(longitude, latitude, address)
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
|
||||
@@ -22,7 +22,12 @@ import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class QuickAppActivity extends BaseActivity {
|
||||
public static final String QUICK_APP_KEY = "QuickAppKey";
|
||||
private static final String TAG = QuickAppActivity.class.getSimpleName();
|
||||
|
||||
public static final String QUICK_APP_KEY = "QuickAppPackageKey";
|
||||
public static final String QUICK_APP_REFRESH_KEY = "QuickAppRefreshKey";
|
||||
public static final String QUICK_APP_ENABLED_KEY = "QuickAppEnabledKey";
|
||||
|
||||
private AppSelectedAdapter mAppSelectedAdapter;
|
||||
|
||||
@BindView(R.id.rv_goods)
|
||||
|
||||
@@ -23,7 +23,10 @@ import java.util.List;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class HealthCodeActivity extends BaseActivity implements HealthCodeContact.CodeView {
|
||||
public class FamilySpaceActivity extends BaseActivity implements FamilySpaceContact.CodeView {
|
||||
|
||||
@BindView(R.id.iv_back)
|
||||
ImageView iv_back;
|
||||
@BindView(R.id.viewPager)
|
||||
ViewPager mViewPager;
|
||||
@BindView(R.id.magicIndicator)
|
||||
@@ -31,21 +34,22 @@ public class HealthCodeActivity extends BaseActivity implements HealthCodeContac
|
||||
@BindView(R.id.iv_nodata)
|
||||
ImageView iv_nodata;
|
||||
|
||||
private HealthCodePresenter mPresenter;
|
||||
private FamilySpacePresenter mPresenter;
|
||||
private HealthCodeAdapter mHealthCodeAdapter;
|
||||
private ScaleCircleNavigator scaleCircleNavigator;
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_code;
|
||||
return R.layout.activity_family_space;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
mPresenter = new HealthCodePresenter(this);
|
||||
mPresenter = new FamilySpacePresenter(this);
|
||||
mPresenter.attachView(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
iv_back.setOnClickListener(view -> finish());
|
||||
mHealthCodeAdapter = new HealthCodeAdapter();
|
||||
mViewPager.setAdapter(mHealthCodeAdapter);
|
||||
scaleCircleNavigator = new ScaleCircleNavigator(this);
|
||||
@@ -6,7 +6,7 @@ import com.uiuios.aios.bean.HealthCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HealthCodeContact {
|
||||
public class FamilySpaceContact {
|
||||
public interface Presenter extends BasePresenter<CodeView> {
|
||||
void getHealthCode();
|
||||
}
|
||||
@@ -13,9 +13,9 @@ import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
public class HealthCodePresenter implements HealthCodeContact.Presenter {
|
||||
private static final String TAG = HealthCodePresenter.class.getSimpleName();
|
||||
private HealthCodeContact.CodeView mView;
|
||||
public class FamilySpacePresenter implements FamilySpaceContact.Presenter {
|
||||
private static final String TAG = FamilySpacePresenter.class.getSimpleName();
|
||||
private FamilySpaceContact.CodeView mView;
|
||||
|
||||
private Context mContext;
|
||||
|
||||
@@ -29,14 +29,14 @@ public class HealthCodePresenter implements HealthCodeContact.Presenter {
|
||||
return lifecycle;
|
||||
}
|
||||
|
||||
HealthCodePresenter(Context context) {
|
||||
FamilySpacePresenter(Context context) {
|
||||
this.mContext = context;
|
||||
Log.e(TAG, "MainPresenter: " + context.getClass());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void attachView(@NonNull HealthCodeContact.CodeView view) {
|
||||
public void attachView(@NonNull FamilySpaceContact.CodeView view) {
|
||||
this.mView = view;
|
||||
}
|
||||
|
||||
@@ -63,11 +63,14 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
|
||||
private FragmentManager mFragmentManager;
|
||||
private FragmentTransaction mFragmentTransaction;
|
||||
|
||||
private ScaleCircleNavigator scaleCircleNavigator;
|
||||
private BaseFragmentPagerAdapter mBaseFragmentPagerAdapter;
|
||||
|
||||
private List<Fragment> mFragments;
|
||||
private CustomFragment mCustomFragment;
|
||||
private SecondFragment mSecondFragment;
|
||||
|
||||
private boolean is_twoscreen = false;
|
||||
private int appListIndex = 1;
|
||||
private int defaultCurrent = 0;
|
||||
|
||||
@@ -5,14 +5,13 @@ import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.baidu.location.BDLocation;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.qweather.sdk.bean.weather.WeatherDailyBean;
|
||||
import com.qweather.sdk.view.QWeather;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiuios.aios.manager.AmapManager;
|
||||
import com.uiuios.aios.manager.RemoteManager;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
@@ -58,11 +57,7 @@ public class WeatherPresenter implements WeatherContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void getLocation() {
|
||||
BDLocation bdLocation = AmapManager.getInstance().getNowMapLocation();
|
||||
String location = "未知";
|
||||
if (bdLocation != null) {
|
||||
location = bdLocation.getCity() + "\t" + bdLocation.getDistrict();
|
||||
}
|
||||
String location = RemoteManager.getInstance().getCityDistrict();
|
||||
mView.setLocation(location);
|
||||
}
|
||||
|
||||
@@ -78,7 +73,7 @@ public class WeatherPresenter implements WeatherContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void getWeather() {
|
||||
QWeather.getWeather7D(mContext, AmapManager.getInstance().getLocation(), new QWeather.OnResultWeatherDailyListener() {
|
||||
QWeather.getWeather7D(mContext, RemoteManager.getInstance().getLocationTude(), new QWeather.OnResultWeatherDailyListener() {
|
||||
@Override
|
||||
public void onError(Throwable throwable) {
|
||||
Log.e("getWeather", "onError: " + throwable.getMessage());
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.uiuios.aios.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -18,6 +20,7 @@ import com.uiuios.aios.bean.AppSelectBean;
|
||||
import java.util.List;
|
||||
|
||||
public class AppSelectedAdapter extends RecyclerView.Adapter<AppSelectedAdapter.Holder> {
|
||||
private static final String TAG = AppSelectedAdapter.class.getSimpleName();
|
||||
|
||||
private Context mContext;
|
||||
private List<AppSelectBean> mAppSelectBeans;
|
||||
@@ -53,11 +56,12 @@ public class AppSelectedAdapter extends RecyclerView.Adapter<AppSelectedAdapter.
|
||||
if (position != selecedPosition) {
|
||||
holder.iv_select.setImageDrawable(mContext.getDrawable(R.drawable.icon_selected));
|
||||
selecedPosition = position;
|
||||
mMMKV.putString(QuickAppActivity.QUICK_APP_KEY, appSelectBean.getPackageName());
|
||||
Settings.Global.putString(mContext.getContentResolver(), QuickAppActivity.QUICK_APP_KEY, appSelectBean.getPackageName());
|
||||
} else {
|
||||
holder.iv_select.setImageDrawable(mContext.getDrawable(R.drawable.icon_unselected));
|
||||
selecedPosition = -1;
|
||||
mMMKV.putString(QuickAppActivity.QUICK_APP_KEY, "");
|
||||
Settings.Global.putString(mContext.getContentResolver(),QuickAppActivity.QUICK_APP_KEY, "");
|
||||
Log.e(TAG, "setQuickApp: empty");
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@@ -15,18 +15,18 @@ import com.tencent.android.tpush.XGPushConfig;
|
||||
import com.tencent.android.tpush.XGPushManager;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiuios.aios.BuildConfig;
|
||||
import com.uiuios.aios.alarm.AlarmUtils;
|
||||
import com.uiuios.aios.manager.ConnectManager;
|
||||
import com.uiuios.aios.manager.RemoteManager;
|
||||
import com.uiuios.aios.network.NetInterfaceManager;
|
||||
import com.uiuios.aios.service.main.MainService;
|
||||
import com.uiuios.aios.alarm.AlarmUtils;
|
||||
import com.uiuios.aios.manager.AmapManager;
|
||||
import com.uiuios.aios.utils.AppUsedTimeUtils;
|
||||
import com.uiuios.aios.utils.JGYUtils;
|
||||
import com.uiuios.aios.utils.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class BaseApplication extends Application {
|
||||
private static final String TAG = BaseApplication.class.getSimpleName();
|
||||
|
||||
@@ -65,9 +65,10 @@ public class BaseApplication extends Application {
|
||||
HeConfig.init("HE2210211540591362", "fe42a7bb59b14eefb27eea4fb2c40e99");
|
||||
//切换至开发版服务
|
||||
HeConfig.switchToDevService();
|
||||
AmapManager.init(this);
|
||||
RemoteManager.init(this);
|
||||
ConnectManager.init(this);
|
||||
NetInterfaceManager.init(this);
|
||||
JGYUtils.init(this);
|
||||
startService(new Intent(this, MainService.class));
|
||||
}
|
||||
|
||||
|
||||
134
app/src/main/java/com/uiuios/aios/bean/MapBean.java
Normal file
134
app/src/main/java/com/uiuios/aios/bean/MapBean.java
Normal file
@@ -0,0 +1,134 @@
|
||||
package com.uiuios.aios.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class MapBean implements Serializable {
|
||||
private static final long serialVersionUID = -4356064111098876676L;
|
||||
|
||||
double longitude;
|
||||
double latitude;
|
||||
String adcode;
|
||||
String address;
|
||||
String city;
|
||||
String cityCode;
|
||||
String country;
|
||||
String countryCode;
|
||||
String district;
|
||||
String province;
|
||||
String street;
|
||||
String streetNumber;
|
||||
String town;
|
||||
String locationDescribe;
|
||||
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLongitude(double longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setLatitude(double latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public String getAdcode() {
|
||||
return adcode;
|
||||
}
|
||||
|
||||
public void setAdcode(String adcode) {
|
||||
this.adcode = adcode;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getCityCode() {
|
||||
return cityCode;
|
||||
}
|
||||
|
||||
public void setCityCode(String cityCode) {
|
||||
this.cityCode = cityCode;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public String getCountryCode() {
|
||||
return countryCode;
|
||||
}
|
||||
|
||||
public void setCountryCode(String countryCode) {
|
||||
this.countryCode = countryCode;
|
||||
}
|
||||
|
||||
public String getDistrict() {
|
||||
return district;
|
||||
}
|
||||
|
||||
public void setDistrict(String district) {
|
||||
this.district = district;
|
||||
}
|
||||
|
||||
public String getProvince() {
|
||||
return province;
|
||||
}
|
||||
|
||||
public void setProvince(String province) {
|
||||
this.province = province;
|
||||
}
|
||||
|
||||
public String getStreet() {
|
||||
return street;
|
||||
}
|
||||
|
||||
public void setStreet(String street) {
|
||||
this.street = street;
|
||||
}
|
||||
|
||||
public String getStreetNumber() {
|
||||
return streetNumber;
|
||||
}
|
||||
|
||||
public void setStreetNumber(String streetNumber) {
|
||||
this.streetNumber = streetNumber;
|
||||
}
|
||||
|
||||
public String getTown() {
|
||||
return town;
|
||||
}
|
||||
|
||||
public void setTown(String town) {
|
||||
this.town = town;
|
||||
}
|
||||
|
||||
public String getLocationDescribe() {
|
||||
return locationDescribe;
|
||||
}
|
||||
|
||||
public void setLocationDescribe(String locationDescribe) {
|
||||
this.locationDescribe = locationDescribe;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.uiuios.aios.config;
|
||||
|
||||
public class CommonConfig {
|
||||
public static final String MAP_LOCATION_JSON_KEY = "MAPLOCATION_JSON_STRING";
|
||||
public static final String MAP_LONGITUDE_KEY = "map_longitude_key";
|
||||
public static final String MAP_LATITUDE_KEY = "map_latitude_key";
|
||||
public static final String MAP_ADDRESS_KEY = "map_address_key";
|
||||
public static final String MAP_ERROR_KEY = "map_error_key";
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.uiuios.aios.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
@@ -21,6 +22,7 @@ import com.google.gson.JsonObject;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.activity.code.FamilySpaceActivity;
|
||||
import com.uiuios.aios.base.BaseFragment;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.DesktopIcon;
|
||||
@@ -182,6 +184,9 @@ public class AppListFragment extends BaseFragment {
|
||||
Log.e(TAG, "onItemClick: " + desktopIcon.getPackageName());
|
||||
switch (desktopIcon.getPackageName()) {
|
||||
case "aios.exit":
|
||||
case "aios.family":
|
||||
startActivity(new Intent(mContext, FamilySpaceActivity.class));
|
||||
break;
|
||||
case "com.android.dialer":
|
||||
int qch_call_forbid = Settings.System.getInt(mContext.getContentResolver(), "aole_call_forbid", 0);
|
||||
if (qch_call_forbid == 1) {
|
||||
|
||||
@@ -34,9 +34,6 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.baidu.location.BDAbstractLocationListener;
|
||||
import com.baidu.location.BDLocation;
|
||||
import com.baidu.location.LocationClient;
|
||||
import com.blankj.utilcode.util.NetworkUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
@@ -54,7 +51,7 @@ import com.uiuios.aios.activity.ControlActivity;
|
||||
import com.uiuios.aios.activity.EmergencyActivity;
|
||||
import com.uiuios.aios.activity.QuickAppActivity;
|
||||
import com.uiuios.aios.activity.alarm.AlarmClockActivity;
|
||||
import com.uiuios.aios.activity.code.HealthCodeActivity;
|
||||
import com.uiuios.aios.activity.code.FamilySpaceActivity;
|
||||
import com.uiuios.aios.activity.contact.ContactActivity;
|
||||
import com.uiuios.aios.activity.weather.WeatherActivity;
|
||||
import com.uiuios.aios.adapter.NotificationAdapter;
|
||||
@@ -63,15 +60,13 @@ import com.uiuios.aios.alarm.AlarmUtils;
|
||||
import com.uiuios.aios.base.BaseFragment;
|
||||
import com.uiuios.aios.bean.AlarmClockData;
|
||||
import com.uiuios.aios.bean.AlarmItem;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.Contact;
|
||||
import com.uiuios.aios.bean.HealthCode;
|
||||
import com.uiuios.aios.bean.SnInfo;
|
||||
import com.uiuios.aios.bean.UserAvatarInfo;
|
||||
import com.uiuios.aios.dialog.PasswordDialog;
|
||||
import com.uiuios.aios.dialog.SingleDialog;
|
||||
import com.uiuios.aios.disklrucache.CacheHelper;
|
||||
import com.uiuios.aios.manager.AmapManager;
|
||||
import com.uiuios.aios.manager.RemoteManager;
|
||||
import com.uiuios.aios.network.NetInterfaceManager;
|
||||
import com.uiuios.aios.network.URLAddress;
|
||||
import com.uiuios.aios.tpush.MessageReceiver;
|
||||
@@ -89,9 +84,6 @@ import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
|
||||
/**
|
||||
@@ -234,7 +226,9 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
|
||||
@Override
|
||||
public void fetchData() {
|
||||
Log.e(TAG, "fetchData: ");
|
||||
initData();
|
||||
RemoteManager.getInstance().getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -289,6 +283,25 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
return isOnline;
|
||||
}
|
||||
|
||||
private RefreshBroadcastReceiver mRefreshBroadcastReceiver;
|
||||
|
||||
private void registerRefreshReceiver() {
|
||||
if (mRefreshBroadcastReceiver == null) {
|
||||
mRefreshBroadcastReceiver = new RefreshBroadcastReceiver();
|
||||
}
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(QuickAppActivity.QUICK_APP_REFRESH_KEY);
|
||||
mContext.registerReceiver(mRefreshBroadcastReceiver, filter);
|
||||
}
|
||||
|
||||
class RefreshBroadcastReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.e(TAG, "onReceive: " + intent.getAction());
|
||||
setQuickApp();
|
||||
}
|
||||
}
|
||||
|
||||
private void registerAlarmClockReceiver() {
|
||||
if (null == mAlarmClockReceiver) {
|
||||
mAlarmClockReceiver = new AlarmClockReceiver();
|
||||
@@ -393,6 +406,7 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
|
||||
private void initView() {
|
||||
Log.e(TAG, "initView: " + Utils.getBatteryLevel(mContext));
|
||||
registerRefreshReceiver();
|
||||
registerBatteryReceiver();
|
||||
registerAlarmClockReceiver();
|
||||
wifi_ssid.requestFocus();
|
||||
@@ -507,7 +521,10 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (TextUtils.isEmpty(quickAppPackagesName)) {
|
||||
startActivity(new Intent(mContext, QuickAppActivity.class));
|
||||
int is_quick = Settings.Global.getInt(mContext.getContentResolver(), QuickAppActivity.QUICK_APP_ENABLED_KEY, 0);
|
||||
if (is_quick == 0) {
|
||||
startActivity(new Intent(mContext, QuickAppActivity.class));
|
||||
}
|
||||
} else {
|
||||
ApkUtils.openPackage(mContext, quickAppPackagesName);
|
||||
}
|
||||
@@ -516,7 +533,12 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
cl_app.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
startActivity(new Intent(mContext, QuickAppActivity.class));
|
||||
int is_quick = Settings.Global.getInt(mContext.getContentResolver(), QuickAppActivity.QUICK_APP_ENABLED_KEY, 0);
|
||||
if (is_quick == 0) {
|
||||
startActivity(new Intent(mContext, QuickAppActivity.class));
|
||||
} else {
|
||||
ToastUtil.show("已在小程序设置");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@@ -692,7 +714,7 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
private String quickAppPackagesName;
|
||||
|
||||
private void setQuickApp() {
|
||||
quickAppPackagesName = mMMKV.getString(QuickAppActivity.QUICK_APP_KEY, "");
|
||||
quickAppPackagesName = Settings.Global.getString(mCRv, QuickAppActivity.QUICK_APP_KEY);
|
||||
if (!TextUtils.isEmpty(quickAppPackagesName)) {
|
||||
ApplicationInfo applicationInfo = null;
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
@@ -780,28 +802,9 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
}
|
||||
|
||||
private void initAmap() {
|
||||
LocationClient locationClient = AmapManager.getInstance().getLocationClient();
|
||||
locationClient.stop();
|
||||
locationClient.start();
|
||||
locationClient.registerLocationListener(new BDAbstractLocationListener() {
|
||||
@Override
|
||||
public void onReceiveLocation(BDLocation bdLocation) {
|
||||
Log.e(TAG, "onReceiveLocation: ");
|
||||
switch (bdLocation.getLocType()) {
|
||||
case BDLocation.TypeGpsLocation:// GPS定位结果
|
||||
case BDLocation.TypeNetWorkLocation:// 网络定位结果
|
||||
case BDLocation.TypeOffLineLocation:// 离线定位结果
|
||||
String city = bdLocation.getCity();
|
||||
tv_location.setText(city);
|
||||
getweather(bdLocation.getLongitude(), bdLocation.getLatitude());
|
||||
break;
|
||||
default:
|
||||
BDLocation location = AmapManager.getInstance().getNowMapLocation();
|
||||
getweather(location.getLongitude(), location.getLatitude());
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
String city = RemoteManager.getInstance().getCity();
|
||||
tv_location.setText(city);
|
||||
getweather(RemoteManager.getInstance().getLongitude(), RemoteManager.getInstance().getLatitude());
|
||||
}
|
||||
|
||||
private void getAlarm() {
|
||||
@@ -892,7 +895,7 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
NetInterfaceManager.getInstance().getHealthCode(new NetInterfaceManager.HealthCodeCallback() {
|
||||
@Override
|
||||
public void setHealthCode(List<HealthCode> healthCode) {
|
||||
startActivity(new Intent(mContext, HealthCodeActivity.class));
|
||||
startActivity(new Intent(mContext, FamilySpaceActivity.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.uiuios.aios.bean.ArticleInfo;
|
||||
import com.uiuios.aios.bean.DemandBean;
|
||||
import com.uiuios.aios.bean.GoodsInfo;
|
||||
import com.uiuios.aios.network.NetInterfaceManager;
|
||||
import com.uiuios.aios.utils.JGYUtils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
@@ -119,7 +120,7 @@ public class SecondFragment extends BaseFragment implements SecondContact.View,
|
||||
@BindView(R.id.tv_info_more)
|
||||
TextView tv_info_more;
|
||||
|
||||
private android.view.View rootView;
|
||||
private View rootView;
|
||||
private Context mContext;
|
||||
private ContentResolver mCRv;
|
||||
private SecondPresenter mPresenter;
|
||||
@@ -144,7 +145,9 @@ public class SecondFragment extends BaseFragment implements SecondContact.View,
|
||||
|
||||
@Override
|
||||
public void onConnected(NetworkUtils.NetworkType networkType) {
|
||||
initData();
|
||||
if (JGYUtils.getInstance().isScreenOn()) {
|
||||
initData();
|
||||
}
|
||||
}
|
||||
|
||||
public SecondFragment() {
|
||||
@@ -181,12 +184,12 @@ public class SecondFragment extends BaseFragment implements SecondContact.View,
|
||||
|
||||
@Override
|
||||
public void fetchData() {
|
||||
|
||||
initData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public android.view.View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
rootView = inflater.inflate(R.layout.fragment_second, container, false);
|
||||
mContext = rootView.getContext();
|
||||
@@ -196,7 +199,6 @@ public class SecondFragment extends BaseFragment implements SecondContact.View,
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
ButterKnife.bind(this, rootView);
|
||||
initView();
|
||||
initData();
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@@ -212,15 +214,15 @@ public class SecondFragment extends BaseFragment implements SecondContact.View,
|
||||
rv_activity.setLayoutManager(new LinearLayoutManager(mContext));
|
||||
rv_activity.setAdapter(mActivityAdapter);
|
||||
|
||||
cl_activity.setOnClickListener(new android.view.View.OnClickListener() {
|
||||
cl_activity.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(android.view.View view) {
|
||||
public void onClick(View view) {
|
||||
openApp(0);
|
||||
}
|
||||
});
|
||||
cl_demand.setOnClickListener(new android.view.View.OnClickListener() {
|
||||
cl_demand.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(android.view.View view) {
|
||||
public void onClick(View view) {
|
||||
openApp(1);
|
||||
}
|
||||
});
|
||||
@@ -255,16 +257,16 @@ public class SecondFragment extends BaseFragment implements SecondContact.View,
|
||||
NetInterfaceManager.getInstance().getDemandList(true, lifecycleSubject, new NetInterfaceManager.DemandListCallback() {
|
||||
@Override
|
||||
public void setDemandList(List<DemandBean> demandBeans) {
|
||||
cl4.setVisibility(android.view.View.VISIBLE);
|
||||
iv4.setVisibility(android.view.View.GONE);
|
||||
cl4.setVisibility(View.VISIBLE);
|
||||
iv4.setVisibility(View.GONE);
|
||||
DemandBean demandBean = demandBeans.get(0);
|
||||
setDemand(demandBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void noData() {
|
||||
cl4.setVisibility(android.view.View.GONE);
|
||||
iv4.setVisibility(android.view.View.VISIBLE);
|
||||
cl4.setVisibility(View.GONE);
|
||||
iv4.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -325,10 +327,10 @@ public class SecondFragment extends BaseFragment implements SecondContact.View,
|
||||
@Override
|
||||
public void setGoods(List<GoodsInfo> goodsInfos) {
|
||||
if (goodsInfos != null && goodsInfos.size() != 0) {
|
||||
iv1.setVisibility(android.view.View.GONE);
|
||||
iv1.setVisibility(View.GONE);
|
||||
mGoodsAdapter.setGoodsInfoList(goodsInfos);
|
||||
} else {
|
||||
iv1.setVisibility(android.view.View.VISIBLE);
|
||||
iv1.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,23 +338,23 @@ public class SecondFragment extends BaseFragment implements SecondContact.View,
|
||||
public void setArticle(List<ArticleInfo> articleInfoList) {
|
||||
if (articleInfoList != null && articleInfoList.size() != 0) {
|
||||
// cl2.setVisibility(View.VISIBLE);
|
||||
iv2.setVisibility(android.view.View.GONE);
|
||||
iv2.setVisibility(View.GONE);
|
||||
mArticleAdapter.setArticleBeanList(articleInfoList);
|
||||
} else {
|
||||
// cl2.setVisibility(View.GONE);
|
||||
iv2.setVisibility(android.view.View.VISIBLE);
|
||||
iv2.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActivityList(List<ActivityBean> activityList) {
|
||||
if (activityList != null && activityList.size() != 0) {
|
||||
// cl3.setVisibility(android.view.View.VISIBLE);
|
||||
iv3.setVisibility(android.view.View.GONE);
|
||||
// cl3.setVisibility(View.VISIBLE);
|
||||
iv3.setVisibility(View.GONE);
|
||||
mActivityAdapter.setActivityBeans(activityList);
|
||||
} else {
|
||||
// cl3.setVisibility(android.view.View.GONE);
|
||||
iv3.setVisibility(android.view.View.VISIBLE);
|
||||
// cl3.setVisibility(View.GONE);
|
||||
iv3.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,410 +0,0 @@
|
||||
package com.uiuios.aios.manager;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.baidu.location.BDAbstractLocationListener;
|
||||
import com.baidu.location.BDLocation;
|
||||
import com.baidu.location.LocationClient;
|
||||
import com.baidu.location.LocationClientOption;
|
||||
import com.blankj.utilcode.util.SPUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiuios.aios.disklrucache.CacheHelper;
|
||||
import com.uiuios.aios.utils.GsonUtils;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public class AmapManager {
|
||||
private static final String TAG = AmapManager.class.getSimpleName();
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static AmapManager sInstance;
|
||||
private Context mContext;
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private LocationClient mLocationClient = null;
|
||||
private LocationClientOption mOption;
|
||||
private BDLocation mLocation;
|
||||
private CacheHelper mCacheHelper;
|
||||
|
||||
private static final String AMAPLOCATION_JSON_KEY = "MAPLOCATION_JSON_STRING";
|
||||
public static final String LONGITUDE_KEY = "map_longitude_key";
|
||||
public static final String LATITUDE_KEY = "map_latitude_key";
|
||||
public static final String ADDRESS_KEY = "map_address_key";
|
||||
public static final String ERROR_KEY = "map_error_key";
|
||||
|
||||
private AmapManager(Context context) {
|
||||
this.mContext = context;
|
||||
this.mCacheHelper = new CacheHelper(context);
|
||||
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+gps");
|
||||
initAmap();
|
||||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
if (context == null) {
|
||||
throw new RuntimeException("Context is NULL");
|
||||
}
|
||||
if (sInstance == null) {
|
||||
sInstance = new AmapManager(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static AmapManager getInstance() {
|
||||
if (sInstance == null) {
|
||||
throw new IllegalStateException("You must be init AmapManager first");
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void initAmap() {
|
||||
if (mLocationClient == null) {
|
||||
mLocationClient = new LocationClient(mContext);
|
||||
}
|
||||
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+gps");
|
||||
mLocationClient.setLocOption(getDefaultLocationClientOption());
|
||||
mLocationClient.registerLocationListener(mListener);
|
||||
mLocationClient.stop();
|
||||
mLocationClient.start();
|
||||
}
|
||||
|
||||
|
||||
public LocationClient getLocationClient() {
|
||||
if (mLocationClient == null) {
|
||||
initAmap();
|
||||
}
|
||||
return mLocationClient;
|
||||
}
|
||||
|
||||
public BDLocation getNowMapLocation() {
|
||||
if (mLocation == null) {
|
||||
String aMapLocationjson = SPUtils.getInstance().getString(AMAPLOCATION_JSON_KEY,"");
|
||||
if (TextUtils.isEmpty(aMapLocationjson)) {
|
||||
return null;
|
||||
}
|
||||
Type type = new TypeToken<BDLocation>() {
|
||||
}.getType();
|
||||
try {
|
||||
BDLocation bdLocation = new Gson().fromJson(aMapLocationjson, type);
|
||||
return bdLocation;
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "getNowMapLocation: " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return this.mLocation;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
BDLocation bdLocation = getNowMapLocation();
|
||||
if (bdLocation == null) {
|
||||
return "0,0";
|
||||
} else {
|
||||
String location = bdLocation.getLongitude() + "," + bdLocation.getLatitude();
|
||||
Log.e(TAG, "getLocation: " + location);
|
||||
return location;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return DefaultLocationClientOption 默认O设置
|
||||
*/
|
||||
public LocationClientOption getDefaultLocationClientOption() {
|
||||
if (mOption == null) {
|
||||
mOption = new LocationClientOption();
|
||||
mOption.setCoorType("bd09ll"); // 可选,默认gcj02,设置返回的定位结果坐标系,如果配合百度地图使用,建议设置为bd09ll;
|
||||
mOption.setScanSpan(0); // 可选,默认0,即仅定位一次,设置发起连续定位请求的间隔需要大于等于1000ms才是有效的
|
||||
mOption.setIsNeedAddress(true); // 可选,设置是否需要地址信息,默认不需要
|
||||
mOption.setIsNeedLocationDescribe(true); // 可选,设置是否需要地址描述
|
||||
mOption.setNeedDeviceDirect(false); // 可选,设置是否需要设备方向结果
|
||||
mOption.setLocationNotify(false); // 可选,默认false,设置是否当gps有效时按照1S1次频率输出GPS结果
|
||||
mOption.setIgnoreKillProcess(true); // 可选,默认true,定位SDK内部是一个SERVICE,并放到了独立进程,设置是否在stop
|
||||
mOption.setIsNeedLocationDescribe(true); // 可选,默认false,设置是否需要位置语义化结果,可以在BDLocation
|
||||
mOption.setIsNeedLocationPoiList(true); // 可选,默认false,设置是否需要POI结果,可以在BDLocation
|
||||
mOption.SetIgnoreCacheException(false); // 可选,默认false,设置是否收集CRASH信息,默认收集
|
||||
mOption.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); // 可选,默认高精度,设置定位模式,高精度,低功耗,仅设备,模糊
|
||||
mOption.setIsNeedAltitude(false); // 可选,默认false,设置定位时是否需要海拔信息,默认不需要,除基础定位版本都可用
|
||||
// 可选,设置首次定位时选择定位速度优先还是定位准确性优先,默认为速度优先
|
||||
// mOption.setFirstLocType(LocationClientOption.FirstLocType.SPEED_IN_FIRST_LOC);
|
||||
}
|
||||
return mOption;
|
||||
}
|
||||
|
||||
|
||||
/*****
|
||||
*
|
||||
* 定位结果回调,重写onReceiveLocation方法,可以直接拷贝如下代码到自己工程中修改
|
||||
*
|
||||
*/
|
||||
private BDAbstractLocationListener mListener = new BDAbstractLocationListener() {
|
||||
|
||||
/**
|
||||
* 定位请求回调函数
|
||||
* @param location 定位结果
|
||||
*/
|
||||
@Override
|
||||
public void onReceiveLocation(BDLocation location) {
|
||||
if (null != location) {
|
||||
switch (location.getLocType()) {
|
||||
case BDLocation.TypeGpsLocation:// GPS定位结果
|
||||
case BDLocation.TypeNetWorkLocation:// 网络定位结果
|
||||
case BDLocation.TypeOffLineLocation:// 离线定位结果
|
||||
SPUtils.getInstance().put(AMAPLOCATION_JSON_KEY, GsonUtils.toJsonString(location));
|
||||
Log.e(TAG, "onLocationChanged: " + "定位成功");
|
||||
Log.e(TAG, "onLocationChanged: longitude = " + location.getLongitude());
|
||||
Log.e(TAG, "onLocationChanged: latitude = " + location.getLatitude());
|
||||
Log.e(TAG, "onLocationChanged: " + location.getAddrStr() + location.getLocationDescribe());
|
||||
mCacheHelper.put(ADDRESS_KEY, location.getAddrStr() + location.getLocationDescribe());
|
||||
mCacheHelper.put(LONGITUDE_KEY, location.getLongitude());
|
||||
mCacheHelper.put(LATITUDE_KEY, location.getLatitude());
|
||||
mCacheHelper.put(ERROR_KEY, "-");
|
||||
break;
|
||||
case BDLocation.TypeServerError:
|
||||
Log.e(TAG, "onReceiveLocation: " + "服务端网络定位失败");
|
||||
mCacheHelper.put(ERROR_KEY, "服务端网络定位失败,可以反馈IMEI号和大体定位时间到loc-bugs@baidu.com,会有人追查原因");
|
||||
break;
|
||||
case BDLocation.TypeNetWorkException:
|
||||
Log.e(TAG, "onReceiveLocation: " + "网络不同导致定位失败,请检查网络是否通畅");
|
||||
mCacheHelper.put(ERROR_KEY, "网络不同导致定位失败,请检查网络是否通畅");
|
||||
break;
|
||||
case BDLocation.TypeCriteriaException:
|
||||
Log.e(TAG, "onReceiveLocation: " + "无法获取有效定位依据导致定位失败");
|
||||
mCacheHelper.put(ERROR_KEY, "无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机");
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
// if (null != location && location.getLocType() != BDLocation.TypeServerError) {
|
||||
// StringBuffer sb = new StringBuffer(256);
|
||||
// sb.append("time : ");
|
||||
// /**
|
||||
// * 时间也可以使用systemClock.elapsedRealtime()方法 获取的是自从开机以来,每次回调的时间;
|
||||
// * location.getTime() 是指服务端出本次结果的时间,如果位置不发生变化,则时间不变
|
||||
// */
|
||||
// sb.append(location.getTime());
|
||||
// sb.append("\nsysTime : ");
|
||||
// sb.append(SystemClock.elapsedRealtime());
|
||||
// sb.append("\nlocType : ");// 定位类型
|
||||
// sb.append(location.getLocType());
|
||||
// sb.append("\nlocType description : ");// *****对应的定位类型说明*****
|
||||
// sb.append(location.getLocTypeDescription());
|
||||
// sb.append("\nlatitude : ");// 纬度
|
||||
// sb.append(location.getLatitude());
|
||||
// sb.append("\nlongtitude : ");// 经度
|
||||
// sb.append(location.getLongitude());
|
||||
// sb.append("\nradius : ");// 半径
|
||||
// sb.append(location.getRadius());
|
||||
// sb.append("\nCountryCode : ");// 国家码
|
||||
// sb.append(location.getCountryCode());
|
||||
// sb.append("\nProvince : ");// 获取省份
|
||||
// sb.append(location.getProvince());
|
||||
// sb.append("\nCountry : ");// 国家名称
|
||||
// sb.append(location.getCountry());
|
||||
// sb.append("\ncitycode : ");// 城市编码
|
||||
// sb.append(location.getCityCode());
|
||||
// sb.append("\ncity : ");// 城市
|
||||
// sb.append(location.getCity());
|
||||
// sb.append("\nDistrict : ");// 区
|
||||
// sb.append(location.getDistrict());
|
||||
// sb.append("\nTown : ");// 获取镇信息
|
||||
// sb.append(location.getTown());
|
||||
// sb.append("\nStreet : ");// 街道
|
||||
// sb.append(location.getStreet());
|
||||
// sb.append("\naddr : ");// 地址信息
|
||||
// sb.append(location.getAddrStr());
|
||||
// sb.append("\nStreetNumber : ");// 获取街道号码
|
||||
// sb.append(location.getStreetNumber());
|
||||
// sb.append("\nUserIndoorState: ");// *****返回用户室内外判断结果*****
|
||||
// sb.append(location.getUserIndoorState());
|
||||
// sb.append("\nDirection(not all devices have value): ");
|
||||
// sb.append(location.getDirection());// 方向
|
||||
// sb.append("\nlocationdescribe: ");
|
||||
// sb.append(location.getLocationDescribe());// 位置语义化信息
|
||||
// sb.append("\nPoi: ");// POI信息
|
||||
// if (location.getPoiList() != null && !location.getPoiList().isEmpty()) {
|
||||
// for (int i = 0; i < location.getPoiList().size(); i++) {
|
||||
// Poi poi = (Poi) location.getPoiList().get(i);
|
||||
// sb.append("poiName:");
|
||||
// sb.append(poi.getName() + ", ");
|
||||
// sb.append("poiTag:");
|
||||
// sb.append(poi.getTags() + "\n");
|
||||
// }
|
||||
// }
|
||||
// if (location.getPoiRegion() != null) {
|
||||
// sb.append("PoiRegion: ");// 返回定位位置相对poi的位置关系,仅在开发者设置需要POI信息时才会返回,在网络不通或无法获取时有可能返回null
|
||||
// PoiRegion poiRegion = location.getPoiRegion();
|
||||
// sb.append("DerectionDesc:"); // 获取POIREGION的位置关系,ex:"内"
|
||||
// sb.append(poiRegion.getDerectionDesc() + "; ");
|
||||
// sb.append("Name:"); // 获取POIREGION的名字字符串
|
||||
// sb.append(poiRegion.getName() + "; ");
|
||||
// sb.append("Tags:"); // 获取POIREGION的类型
|
||||
// sb.append(poiRegion.getTags() + "; ");
|
||||
// sb.append("\nSDK版本: ");
|
||||
// }
|
||||
//// int permission = checkPermission(getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION);
|
||||
//// sb.append("\npermsission: " + permission);
|
||||
//// sb.append(locationService.getSDKVersion()); // 获取SDK版本
|
||||
// if (location.getLocType() == BDLocation.TypeGpsLocation) {// GPS定位结果
|
||||
// sb.append("\nspeed : ");
|
||||
// sb.append(location.getSpeed());// 速度 单位:km/h
|
||||
// sb.append("\nsatellite : ");
|
||||
// sb.append(location.getSatelliteNumber());// 卫星数目
|
||||
// sb.append("\nheight : ");
|
||||
// sb.append(location.getAltitude());// 海拔高度 单位:米
|
||||
// sb.append("\ngps status : ");
|
||||
// sb.append(location.getGpsAccuracyStatus());// *****gps质量判断*****
|
||||
// sb.append("\ndescribe : ");
|
||||
// sb.append("gps定位成功");
|
||||
// } else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {// 网络定位结果
|
||||
// // 运营商信息
|
||||
// if (location.hasAltitude()) {// *****如果有海拔高度*****
|
||||
// sb.append("\nheight : ");
|
||||
// sb.append(location.getAltitude());// 单位:米
|
||||
// }
|
||||
// sb.append("\noperationers : ");// 运营商信息
|
||||
// sb.append(location.getOperators());
|
||||
// sb.append("\ndescribe : ");
|
||||
// sb.append("网络定位成功");
|
||||
// } else if (location.getLocType() == BDLocation.TypeOffLineLocation) {// 离线定位结果
|
||||
// sb.append("\ndescribe : ");
|
||||
// sb.append("离线定位成功,离线定位结果也是有效的");
|
||||
// } else if (location.getLocType() == BDLocation.TypeServerError) {
|
||||
// sb.append("\ndescribe : ");
|
||||
// sb.append("服务端网络定位失败,可以反馈IMEI号和大体定位时间到loc-bugs@baidu.com,会有人追查原因");
|
||||
// } else if (location.getLocType() == BDLocation.TypeNetWorkException) {
|
||||
// sb.append("\ndescribe : ");
|
||||
// sb.append("网络不同导致定位失败,请检查网络是否通畅");
|
||||
// } else if (location.getLocType() == BDLocation.TypeCriteriaException) {
|
||||
// sb.append("\ndescribe : ");
|
||||
// sb.append("无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机");
|
||||
// }
|
||||
//// logMsg(sb.toString(), tag);
|
||||
// Log.e(TAG, "onReceiveLocation: " + sb);
|
||||
// }
|
||||
Log.e(TAG, "AmapAddress: " + mCacheHelper.getAsString(ADDRESS_KEY));
|
||||
Log.e(TAG, "AmapError: " + mCacheHelper.getAsString(ERROR_KEY));
|
||||
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "-network");
|
||||
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "-gps");
|
||||
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.ASSISTED_GPS_ENABLED, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectHotSpotMessage(String s, int i) {
|
||||
super.onConnectHotSpotMessage(s, i);
|
||||
}
|
||||
|
||||
/**
|
||||
* 回调定位诊断信息,开发者可以根据相关信息解决定位遇到的一些问题
|
||||
* @param locType 当前定位类型
|
||||
* @param diagnosticType 诊断类型(1~9)
|
||||
* @param diagnosticMessage 具体的诊断信息释义
|
||||
*/
|
||||
@Override
|
||||
public void onLocDiagnosticMessage(int locType, int diagnosticType, String diagnosticMessage) {
|
||||
super.onLocDiagnosticMessage(locType, diagnosticType, diagnosticMessage);
|
||||
// int tag = 2;
|
||||
StringBuffer sb = new StringBuffer(256);
|
||||
sb.append("诊断结果: ");
|
||||
if (locType == BDLocation.TypeNetWorkLocation) {
|
||||
if (diagnosticType == 1) {
|
||||
sb.append("网络定位成功,没有开启GPS,建议打开GPS会更好");
|
||||
sb.append("\n" + diagnosticMessage);
|
||||
} else if (diagnosticType == 2) {
|
||||
sb.append("网络定位成功,没有开启Wi-Fi,建议打开Wi-Fi会更好");
|
||||
sb.append("\n" + diagnosticMessage);
|
||||
}
|
||||
} else if (locType == BDLocation.TypeOffLineLocationFail) {
|
||||
if (diagnosticType == 3) {
|
||||
sb.append("定位失败,请您检查您的网络状态");
|
||||
sb.append("\n" + diagnosticMessage);
|
||||
}
|
||||
} else if (locType == BDLocation.TypeCriteriaException) {
|
||||
if (diagnosticType == 4) {
|
||||
sb.append("定位失败,无法获取任何有效定位依据");
|
||||
sb.append("\n" + diagnosticMessage);
|
||||
} else if (diagnosticType == 5) {
|
||||
sb.append("定位失败,无法获取有效定位依据,请检查运营商网络或者Wi-Fi网络是否正常开启,尝试重新请求定位");
|
||||
sb.append(diagnosticMessage);
|
||||
} else if (diagnosticType == 6) {
|
||||
sb.append("定位失败,无法获取有效定位依据,请尝试插入一张sim卡或打开Wi-Fi重试");
|
||||
sb.append("\n" + diagnosticMessage);
|
||||
} else if (diagnosticType == 7) {
|
||||
sb.append("定位失败,飞行模式下无法获取有效定位依据,请关闭飞行模式重试");
|
||||
sb.append("\n" + diagnosticMessage);
|
||||
} else if (diagnosticType == 9) {
|
||||
sb.append("定位失败,无法获取任何有效定位依据");
|
||||
sb.append("\n" + diagnosticMessage);
|
||||
}
|
||||
} else if (locType == BDLocation.TypeServerError) {
|
||||
if (diagnosticType == 8) {
|
||||
sb.append("定位失败,请确认您定位的开关打开状态,是否赋予APP定位权限");
|
||||
sb.append("\n" + diagnosticMessage);
|
||||
}
|
||||
}
|
||||
Log.e(TAG, "onLocationChanged: " + "定位失败");
|
||||
mCacheHelper.put(ERROR_KEY, sb.toString());
|
||||
Log.e(TAG, "onLocDiagnosticMessage: " + sb);
|
||||
// logMsg(sb.toString(), tag);
|
||||
}
|
||||
};
|
||||
|
||||
// public AMapLocationClient getLocationClient() {
|
||||
// if (null == locationClient) {
|
||||
// initAmap();
|
||||
// }
|
||||
// return locationClient;
|
||||
// }
|
||||
|
||||
// public void initAmap() {
|
||||
// locationClient = new AMapLocationClient(mContext);
|
||||
// AMapLocationClientOption option = new AMapLocationClientOption();
|
||||
// option.setLocationPurpose(AMapLocationClientOption.AMapLocationPurpose.SignIn);
|
||||
// option.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
|
||||
// option.setNeedAddress(true);
|
||||
// //获取一次定位结果:
|
||||
// //该方法默认为false。
|
||||
// option.setOnceLocation(true);
|
||||
// //获取最近3s内精度最高的一次定位结果:
|
||||
// //设置setOnceLocationLatest(boolean b)接口为true,启动定位时SDK会返回最近3s内精度最高的一次定位结果。
|
||||
// // 如果设置其为true,setOnceLocation(boolean b)接口也会被设置为true,反之不会,默认为false。
|
||||
// option.setOnceLocationLatest(true);
|
||||
// locationClient.setLocationOption(option);
|
||||
// //设置定位模式为AMapLocationMode.Hight_Accuracy,高精度模式。
|
||||
// //设置定位监听
|
||||
// locationClient.setLocationListener(new AMapLocationListener() {
|
||||
//
|
||||
// @Override
|
||||
// public void onLocationChanged(AMapLocation aMapLocation) {
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// //errCode等于0代表定位成功,其他的为定位失败,具体的可以参照官网定位错误码说明
|
||||
// if (aMapLocation.getErrorCode() == 0) {
|
||||
// Log.e(TAG, "onLocationChanged: " + "定位成功");
|
||||
// Log.e(TAG, "onLocationChanged: " + aMapLocation.getAddress());
|
||||
// sb.append(aMapLocation.getAddress()).append("\n");
|
||||
// mMMKV.encode( ADDRESS_KEY, aMapLocation.getAddress());
|
||||
// mMMKV.encode( LONGITUDE_KEY, aMapLocation.getLongitude());
|
||||
// mMMKV.encode( LATITUDE_KEY, aMapLocation.getLatitude());
|
||||
// mMMKV.encode( ERROR_KEY, "");
|
||||
// } else {
|
||||
// //定位失败
|
||||
// sb.append("定位失败" + "\n");
|
||||
// Log.e(TAG, "onLocationChanged: " + "定位失败");
|
||||
// mMMKV.encode( ERROR_KEY, String.valueOf(aMapLocation.getErrorInfo()));
|
||||
// }
|
||||
// Log.e(TAG, (String) SPUtils.get(mContext, ADDRESS_KEY, "-"));
|
||||
// Log.e(TAG, (String) SPUtils.get(mContext, ERROR_KEY, "-"));
|
||||
// Log.e(TAG, "amap: " + sb.toString());
|
||||
// }
|
||||
// });
|
||||
// //设置场景模式后最好调用一次stop,再调用start以保证场景模式生效
|
||||
// locationClient.stopLocation();
|
||||
// locationClient.startLocation();
|
||||
// Log.e(TAG, "initAmap: " + "startLocation");
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
165
app/src/main/java/com/uiuios/aios/manager/RemoteManager.java
Normal file
165
app/src/main/java/com/uiuios/aios/manager/RemoteManager.java
Normal file
@@ -0,0 +1,165 @@
|
||||
package com.uiuios.aios.manager;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiuios.aios.bean.MapBean;
|
||||
import com.uiuios.aios.config.CommonConfig;
|
||||
import com.uiuios.aios.disklrucache.CacheHelper;
|
||||
import com.uiuios.sn.IGetInfoInterface;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public class RemoteManager {
|
||||
private static final String TAG = RemoteManager.class.getSimpleName();
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static RemoteManager sInstance;
|
||||
private Context mContext;
|
||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||
private CacheHelper mCacheHelper;
|
||||
|
||||
private IGetInfoInterface getInfoInterface;
|
||||
private ServiceConnection mIGetInfoConnection;
|
||||
|
||||
|
||||
private RemoteManager(Context context) {
|
||||
if (context == null) {
|
||||
throw new RuntimeException("Context is NULL");
|
||||
}
|
||||
this.mContext = context;
|
||||
this.mCacheHelper = new CacheHelper(context);
|
||||
mIGetInfoConnection = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
Log.e(TAG, "onServiceConnected: mIGetInfoConnection");
|
||||
getInfoInterface = IGetInfoInterface.Stub.asInterface(service);
|
||||
getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
Log.e(TAG, "onServiceDisconnected: mIGetInfoConnection");
|
||||
getInfoInterface = null;
|
||||
bindInfoService();
|
||||
}
|
||||
};
|
||||
bindInfoService();
|
||||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
if (sInstance == null) {
|
||||
Log.e(TAG, "init: ");
|
||||
sInstance = new RemoteManager(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static RemoteManager getInstance() {
|
||||
if (sInstance == null) {
|
||||
throw new IllegalStateException("You must be init RemoteManager first");
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private void bindInfoService() {
|
||||
if (getInfoInterface == null) {
|
||||
//这是连接aidl服务的代码
|
||||
Intent intent = new Intent();
|
||||
intent.setAction("com.uiuios.sn.IGetInfoInterface");
|
||||
intent.setPackage("com.uiuios.sn");
|
||||
intent.setComponent(new ComponentName("com.uiuios.sn", "com.uiuios.sn.service.RemoteService"));
|
||||
mContext.bindService(intent, mIGetInfoConnection, Context.BIND_AUTO_CREATE);
|
||||
}
|
||||
}
|
||||
|
||||
public void getLocation() {
|
||||
if (getInfoInterface != null) {
|
||||
try {
|
||||
String jsonString = getInfoInterface.getMapResult();
|
||||
mMMKV.encode(CommonConfig.MAP_LOCATION_JSON_KEY, jsonString);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "getMapResult: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
bindInfoService();
|
||||
}
|
||||
}
|
||||
|
||||
public MapBean getMapBean() {
|
||||
String jsonString = mMMKV.decodeString(CommonConfig.MAP_LOCATION_JSON_KEY);
|
||||
if (TextUtils.isEmpty(jsonString)) {
|
||||
return null;
|
||||
} else {
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<MapBean>() {
|
||||
}.getType();
|
||||
MapBean mapBean = gson.fromJson(jsonString, type);
|
||||
mMMKV.encode(CommonConfig.MAP_ADDRESS_KEY, mapBean.getAddress() + mapBean.getLocationDescribe());
|
||||
mMMKV.encode(CommonConfig.MAP_LONGITUDE_KEY, mapBean.getLongitude());
|
||||
mMMKV.encode(CommonConfig.MAP_LATITUDE_KEY, mapBean.getLatitude());
|
||||
return mapBean;
|
||||
}
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
MapBean mapBean = getMapBean();
|
||||
if (mapBean == null) {
|
||||
getLocation();
|
||||
return "北京";
|
||||
} else {
|
||||
return mapBean.getCity();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getCityDistrict() {
|
||||
MapBean mapBean = getMapBean();
|
||||
if (mapBean == null) {
|
||||
getLocation();
|
||||
return "北京";
|
||||
} else {
|
||||
return mapBean.getCity() + "\t" + mapBean.getDistrict();
|
||||
}
|
||||
}
|
||||
|
||||
public double getLongitude() {
|
||||
MapBean mapBean = getMapBean();
|
||||
if (mapBean == null) {
|
||||
getLocation();
|
||||
return 0.0;
|
||||
} else {
|
||||
return mapBean.getLongitude();
|
||||
}
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
MapBean mapBean = getMapBean();
|
||||
if (mapBean == null) {
|
||||
getLocation();
|
||||
return 0.0;
|
||||
} else {
|
||||
return mapBean.getLatitude();
|
||||
}
|
||||
}
|
||||
|
||||
public String getLocationTude() {
|
||||
MapBean mapBean = getMapBean();
|
||||
if (mapBean == null) {
|
||||
getLocation();
|
||||
return "0.0";
|
||||
} else {
|
||||
return mapBean.getLongitude() + "," + mapBean.getLatitude();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
package com.uiuios.aios.utils;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.app.role.RoleManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageInstaller;
|
||||
@@ -13,9 +11,6 @@ import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.os.Process;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -23,6 +18,7 @@ import android.util.Log;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.uiuios.aios.BuildConfig;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.bean.DesktopIcon;
|
||||
import com.uiuios.aios.receiver.InstallResultReceiver;
|
||||
|
||||
@@ -33,13 +29,10 @@ import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
@@ -232,6 +225,13 @@ public class ApkUtils {
|
||||
desktopIcons.add(DesktopIcon.creatDesktopIcon(context, applicationInfo));
|
||||
}
|
||||
}
|
||||
|
||||
DesktopIcon familyIcon = new DesktopIcon();
|
||||
familyIcon.setIcon(context.getDrawable(R.drawable.icon_family_space));
|
||||
familyIcon.setLable("家庭空间");
|
||||
familyIcon.setPackageName("aios.family");
|
||||
desktopIcons.add(0, familyIcon);
|
||||
|
||||
return desktopIcons;
|
||||
}
|
||||
|
||||
@@ -334,6 +334,8 @@ public class ApkUtils {
|
||||
ComponentName cn = new ComponentName(packageName, className);
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(cn);
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
if (context != null) {
|
||||
context.startActivity(intent);
|
||||
return true;
|
||||
|
||||
43
app/src/main/java/com/uiuios/aios/utils/JGYUtils.java
Normal file
43
app/src/main/java/com/uiuios/aios/utils/JGYUtils.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package com.uiuios.aios.utils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.os.PowerManager;
|
||||
|
||||
|
||||
public class JGYUtils {
|
||||
private static final String TAG = JGYUtils.class.getSimpleName();
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static JGYUtils sInstance;
|
||||
private Context mContext;
|
||||
private ContentResolver resolver;
|
||||
|
||||
private JGYUtils(Context context) {
|
||||
if (context == null) {
|
||||
throw new RuntimeException("Context is NULL");
|
||||
}
|
||||
this.mContext = context;
|
||||
this.resolver = mContext.getContentResolver();
|
||||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new JGYUtils(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static JGYUtils getInstance() {
|
||||
if (sInstance == null) {
|
||||
throw new IllegalStateException("You must be init JGYUtils first");
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public boolean isScreenOn() {
|
||||
PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
|
||||
//true为打开,false为关闭
|
||||
return powerManager.isInteractive();
|
||||
}
|
||||
}
|
||||
BIN
app/src/main/res/drawable-hdpi/icon_family_space.png
Normal file
BIN
app/src/main/res/drawable-hdpi/icon_family_space.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.8 KiB |
@@ -1,40 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".activity.code.HealthCodeActivity">
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/viewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/magicIndicator"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<net.lucode.hackware.magicindicator.MagicIndicator
|
||||
android:id="@+id/magicIndicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="16dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_nodata"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="160dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/nodata"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
84
app/src/main/res/layout-land/activity_family_space.xml
Normal file
84
app/src/main/res/layout-land/activity_family_space.xml
Normal file
@@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".activity.code.FamilySpaceActivity">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/constraintLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_32"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_back"
|
||||
android:layout_width="@dimen/dp_20"
|
||||
android:layout_height="@dimen/dp_20"
|
||||
android:layout_marginStart="8dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/back_white"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView5"
|
||||
android:layout_width="@dimen/dp_20"
|
||||
android:layout_height="@dimen/dp_20"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/icon_family_space"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/iv_back"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="家庭空间"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_18"
|
||||
android:layout_marginStart="@dimen/dp_4"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/imageView5"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/viewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/magicIndicator"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/constraintLayout" />
|
||||
|
||||
<net.lucode.hackware.magicindicator.MagicIndicator
|
||||
android:id="@+id/magicIndicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="16dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_nodata"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="160dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/nodata"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,40 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".activity.code.HealthCodeActivity">
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/viewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/magicIndicator"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<net.lucode.hackware.magicindicator.MagicIndicator
|
||||
android:id="@+id/magicIndicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="16dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_nodata"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="160dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/nodata"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
84
app/src/main/res/layout-port/activity_family_space.xml
Normal file
84
app/src/main/res/layout-port/activity_family_space.xml
Normal file
@@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".activity.code.FamilySpaceActivity">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/constraintLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_32"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_back"
|
||||
android:layout_width="@dimen/dp_20"
|
||||
android:layout_height="@dimen/dp_20"
|
||||
android:layout_marginStart="8dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/back_white"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView5"
|
||||
android:layout_width="@dimen/dp_20"
|
||||
android:layout_height="@dimen/dp_20"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/icon_family_space"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/iv_back"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="家庭空间"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_18"
|
||||
android:layout_marginStart="@dimen/dp_4"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/imageView5"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/viewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/magicIndicator"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/constraintLayout" />
|
||||
|
||||
<net.lucode.hackware.magicindicator.MagicIndicator
|
||||
android:id="@+id/magicIndicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="16dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_nodata"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="160dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/nodata"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user