version:1.2.2
fix: update:必备组件手动下载,增加其他应用下载,对接灰度测试
This commit is contained in:
@@ -17,8 +17,8 @@ android {
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 29
|
||||
|
||||
versionCode 22
|
||||
versionName "1.2.1"
|
||||
versionCode 23
|
||||
versionName "1.2.2"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
|
||||
@@ -285,11 +285,14 @@
|
||||
android:exported="true"
|
||||
android:launchMode="standard"
|
||||
android:screenOrientation="sensorLandscape"
|
||||
android:theme="@style/ActivityTheme2">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
android:theme="@style/ActivityTheme2" />
|
||||
<activity
|
||||
android:name=".activity.app.OtherAppActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden|locale"
|
||||
android:exported="true"
|
||||
android:launchMode="standard"
|
||||
android:screenOrientation="sensorLandscape"
|
||||
android:theme="@style/ActivityTheme2" />
|
||||
|
||||
<receiver
|
||||
android:name=".receiver.BootReceiver"
|
||||
|
||||
136
app/src/main/java/com/xwad/os/activity/app/OtherAppActivity.java
Normal file
136
app/src/main/java/com/xwad/os/activity/app/OtherAppActivity.java
Normal file
@@ -0,0 +1,136 @@
|
||||
package com.xwad.os.activity.app;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import com.hjq.toast.Toaster;
|
||||
import com.xwad.os.R;
|
||||
import com.xwad.os.adapter.AppInfoAdapter;
|
||||
import com.xwad.os.base.mvvm.BaseMvvmActivity;
|
||||
import com.xwad.os.bean.AppInfo;
|
||||
import com.xwad.os.databinding.ActivityOtherAppBinding;
|
||||
import com.xwad.os.utils.ActivationUtil;
|
||||
import com.xwad.os.utils.ApkUtils;
|
||||
import com.xwad.os.utils.FileUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class OtherAppActivity extends BaseMvvmActivity<OtherAppViewModel, ActivityOtherAppBinding> {
|
||||
private static final String TAG = "DownloadActivity";
|
||||
|
||||
private AppInfoAdapter mAppInfoAdapter;
|
||||
private List<AppInfo> mAppInfos;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_other_app;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDataBinding() {
|
||||
mViewModel.setCtx(this);
|
||||
mViewModel.setLifecycle(getLifecycleSubject());
|
||||
mViewModel.setVDBinding(mViewDataBinding);
|
||||
mViewDataBinding.setClick(new BtnClick());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
mAppInfoAdapter = new AppInfoAdapter();
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 4);
|
||||
mViewDataBinding.rvContent.setLayoutManager(gridLayoutManager);
|
||||
mViewDataBinding.rvContent.setAdapter(mAppInfoAdapter);
|
||||
|
||||
registerAppChangedReceiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
mViewModel.mListMutableLiveData.observe(this, new Observer<List<AppInfo>>() {
|
||||
@Override
|
||||
public void onChanged(List<AppInfo> appInfos) {
|
||||
mAppInfos = appInfos;
|
||||
mAppInfoAdapter.setAppInfos(appInfos);
|
||||
if (appInfos == null || appInfos.isEmpty()) {
|
||||
mViewDataBinding.clContent.setVisibility(View.GONE);
|
||||
mViewDataBinding.llNodata.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mViewDataBinding.clContent.setVisibility(View.VISIBLE);
|
||||
mViewDataBinding.llNodata.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
mViewModel.getAdminApp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mAppChangedReceiver != null) {
|
||||
unregisterReceiver(mAppChangedReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
private AppChangedReceiver mAppChangedReceiver;
|
||||
|
||||
private void registerAppChangedReceiver() {
|
||||
if (mAppChangedReceiver == null) {
|
||||
mAppChangedReceiver = new AppChangedReceiver();
|
||||
}
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
|
||||
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
|
||||
filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
|
||||
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
|
||||
filter.addDataScheme("package");
|
||||
registerReceiver(mAppChangedReceiver, filter);
|
||||
}
|
||||
|
||||
class AppChangedReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
Log.e("AppChangedReceiver", "onReceive: " + action);
|
||||
if (TextUtils.isEmpty(action)) {
|
||||
return;
|
||||
}
|
||||
mAppInfoAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public class BtnClick {
|
||||
public void exit(View view) {
|
||||
finish();
|
||||
}
|
||||
|
||||
public void downloadApp(View view) {
|
||||
if (mAppInfos == null || mAppInfos.isEmpty()) {
|
||||
Toaster.show("没有要下载的应用");
|
||||
} else {
|
||||
if (ActivationUtil.getInstance().isActivation()) {
|
||||
mAppInfos.forEach(new Consumer<AppInfo>() {
|
||||
@Override
|
||||
public void accept(AppInfo appInfo) {
|
||||
if (appInfo.getIs_must_components_down() == 1) {
|
||||
if (!ApkUtils.isAvailable(OtherAppActivity.this, appInfo.getApp_package())) {
|
||||
FileUtils.ariaDownload(OtherAppActivity.this, appInfo.getApp_url(), appInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.xwad.os.activity.app;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.xwad.os.base.mvvm.BaseViewModel;
|
||||
import com.xwad.os.bean.AppInfo;
|
||||
import com.xwad.os.bean.BaseResponse;
|
||||
import com.xwad.os.databinding.ActivityOtherAppBinding;
|
||||
import com.xwad.os.network.NetInterfaceManager;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
public class OtherAppViewModel extends BaseViewModel<ActivityOtherAppBinding, ActivityEvent> {
|
||||
|
||||
@Override
|
||||
public ActivityOtherAppBinding getVDBinding() {
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
||||
}
|
||||
|
||||
public MutableLiveData<List<AppInfo>> mListMutableLiveData = new MutableLiveData<>();
|
||||
|
||||
public void getAdminApp() {
|
||||
NetInterfaceManager.getInstance().get365AdminAppObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<AppInfo>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getAdminApp", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<AppInfo>> listBaseResponse) {
|
||||
Log.e("getAdminApp", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code == 200) {
|
||||
List<AppInfo> appInfoList = listBaseResponse.data;
|
||||
List<AppInfo> forceAppInfoList = appInfoList.stream()
|
||||
.filter(new Predicate<AppInfo>() {
|
||||
@Override
|
||||
public boolean test(AppInfo appInfo) {
|
||||
return appInfo.getIs_must_components() == 0;
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
mListMutableLiveData.setValue(forceAppInfoList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getAdminApp", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getAdminApp", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,9 @@ import android.view.View;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import com.hjq.toast.Toaster;
|
||||
import com.xwad.os.R;
|
||||
import com.xwad.os.activity.app.OtherAppActivity;
|
||||
import com.xwad.os.adapter.AppInfoAdapter;
|
||||
import com.xwad.os.base.mvvm.BaseMvvmActivity;
|
||||
import com.xwad.os.bean.AppInfo;
|
||||
@@ -26,8 +28,8 @@ import java.util.function.Consumer;
|
||||
public class DownloadActivity extends BaseMvvmActivity<DownloadViewModel, ActivityDownloadBinding> {
|
||||
private static final String TAG = "DownloadActivity";
|
||||
|
||||
|
||||
private AppInfoAdapter mAppInfoAdapter;
|
||||
private List<AppInfo> mAppInfos;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@@ -57,25 +59,14 @@ public class DownloadActivity extends BaseMvvmActivity<DownloadViewModel, Activi
|
||||
mViewModel.mListMutableLiveData.observe(this, new Observer<List<AppInfo>>() {
|
||||
@Override
|
||||
public void onChanged(List<AppInfo> appInfos) {
|
||||
mAppInfos = appInfos;
|
||||
mAppInfoAdapter.setAppInfos(appInfos);
|
||||
if (appInfos == null || appInfos.isEmpty()) {
|
||||
mViewDataBinding.rvContent.setVisibility(View.GONE);
|
||||
mViewDataBinding.clContent.setVisibility(View.GONE);
|
||||
mViewDataBinding.llNodata.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mViewDataBinding.rvContent.setVisibility(View.VISIBLE);
|
||||
mViewDataBinding.clContent.setVisibility(View.VISIBLE);
|
||||
mViewDataBinding.llNodata.setVisibility(View.GONE);
|
||||
if (ActivationUtil.getInstance().isActivation()) {
|
||||
appInfos.forEach(new Consumer<AppInfo>() {
|
||||
@Override
|
||||
public void accept(AppInfo appInfo) {
|
||||
if (appInfo.getIs_must_components_down() == 1) {
|
||||
if (!ApkUtils.isAvailable(DownloadActivity.this, appInfo.getApp_package())) {
|
||||
FileUtils.ariaDownload(DownloadActivity.this, appInfo.getApp_url(), appInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -123,5 +114,28 @@ public class DownloadActivity extends BaseMvvmActivity<DownloadViewModel, Activi
|
||||
public void exit(View view) {
|
||||
finish();
|
||||
}
|
||||
|
||||
public void openOtherApp(View view) {
|
||||
startActivity(new Intent(DownloadActivity.this, OtherAppActivity.class));
|
||||
}
|
||||
|
||||
public void downloadApp(View view) {
|
||||
if (mAppInfos == null || mAppInfos.isEmpty()) {
|
||||
Toaster.show("没有要下载的应用");
|
||||
} else {
|
||||
if (ActivationUtil.getInstance().isActivation()) {
|
||||
mAppInfos.forEach(new Consumer<AppInfo>() {
|
||||
@Override
|
||||
public void accept(AppInfo appInfo) {
|
||||
if (appInfo.getIs_must_components_down() == 1) {
|
||||
if (ApkUtils.isUpdate(DownloadActivity.this, appInfo)) {
|
||||
FileUtils.ariaDownload(DownloadActivity.this, appInfo.getApp_url(), appInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.xwad.os.bean.BaseResponse;
|
||||
import com.xwad.os.databinding.ActivityDownloadBinding;
|
||||
import com.xwad.os.network.NetInterfaceManager;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -36,7 +37,7 @@ public class DownloadViewModel extends BaseViewModel<ActivityDownloadBinding, Ac
|
||||
public MutableLiveData<List<AppInfo>> mListMutableLiveData = new MutableLiveData<>();
|
||||
|
||||
public void getAdminApp() {
|
||||
NetInterfaceManager.getInstance().getAdminAppObservable()
|
||||
NetInterfaceManager.getInstance().get365AdminAppObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<AppInfo>>>() {
|
||||
@Override
|
||||
@@ -49,12 +50,25 @@ public class DownloadViewModel extends BaseViewModel<ActivityDownloadBinding, Ac
|
||||
Log.e("getAdminApp", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code == 200) {
|
||||
List<AppInfo> appInfoList = listBaseResponse.data;
|
||||
List<AppInfo> forceAppInfoList = appInfoList.stream().filter(new Predicate<AppInfo>() {
|
||||
@Override
|
||||
public boolean test(AppInfo appInfo) {
|
||||
return appInfo.getIs_must_components() == 1;
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
List<AppInfo> forceAppInfoList = appInfoList.stream()
|
||||
.sorted(new Comparator<AppInfo>() {
|
||||
@Override
|
||||
public int compare(AppInfo o1, AppInfo o2) {
|
||||
if ("com.jxw.launcher".equals(o1.getApp_package()) && !"com.jxw.launcher".equals(o2.getApp_package())) {
|
||||
return -1;
|
||||
} else if (!"com.jxw.launcher".equals(o1.getApp_package()) && "com.jxw.launcher".equals(o2.getApp_package())) {
|
||||
return 1;
|
||||
} else {
|
||||
return o1.getApp_package().compareTo(o2.getApp_package()); // 非目标包名按字母排序
|
||||
}
|
||||
}
|
||||
})
|
||||
.filter(new Predicate<AppInfo>() {
|
||||
@Override
|
||||
public boolean test(AppInfo appInfo) {
|
||||
return appInfo.getIs_must_components() == 1;
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
mListMutableLiveData.setValue(forceAppInfoList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class AppInfoAdapter extends RecyclerView.Adapter<AppInfoAdapter.Holder>
|
||||
ApkUtils.openPackage(mContext, appInfo.getApp_package());
|
||||
} else {
|
||||
if (ActivationUtil.getInstance().isActivation()) {
|
||||
OpenApkUtils.getInstance().showDownloadDialog(mContext, appInfo.getApp_package(), appInfo.getApp_name());
|
||||
OpenApkUtils.getInstance().showDownloadDialog(mContext, appInfo);
|
||||
} else {
|
||||
Toaster.show("请先激活设备");
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.xwad.os.utils.ActivationUtil;
|
||||
import com.xwad.os.utils.ApkUtils;
|
||||
import com.xwad.os.utils.FileUtils;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
@@ -157,6 +158,18 @@ public class AccountViewModel extends BaseViewModel<FragmentAccountBinding, Frag
|
||||
if (listBaseResponse.code == 200) {
|
||||
List<AppInfo> appInfoList = listBaseResponse.data;
|
||||
appInfoList.stream()
|
||||
.sorted(new Comparator<AppInfo>() {
|
||||
@Override
|
||||
public int compare(AppInfo o1, AppInfo o2) {
|
||||
if ("com.jxw.launcher".equals(o1.getApp_package()) && !"com.jxw.launcher".equals(o2.getApp_package())) {
|
||||
return -1;
|
||||
} else if (!"com.jxw.launcher".equals(o1.getApp_package()) && "com.jxw.launcher".equals(o2.getApp_package())) {
|
||||
return 1;
|
||||
} else {
|
||||
return o1.getApp_package().compareTo(o2.getApp_package()); // 非目标包名按字母排序
|
||||
}
|
||||
}
|
||||
})
|
||||
.filter(new Predicate<AppInfo>() {
|
||||
@Override
|
||||
public boolean test(AppInfo appInfo) {
|
||||
|
||||
@@ -563,6 +563,13 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<AppInfo>>> get365AdminAppObservable() {
|
||||
return mRetrofit.create(AppApi.class)
|
||||
.getAdminApp(Utils.getSerial(), "11", BuildConfig.APPLICATION_ID)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<AppIcon>>> getAppIconObservable() {
|
||||
return mRetrofit.create(GetAppIconApi.class)
|
||||
.getAppIcon(Utils.getSerial())
|
||||
|
||||
@@ -19,6 +19,13 @@ public interface AppApi {
|
||||
@Query("sn") String sn
|
||||
);
|
||||
|
||||
@GET(UrlAddress.GET_ADMIN_APP)
|
||||
Observable<BaseResponse<List<AppInfo>>> getAdminApp(
|
||||
@Query("sn") String sn,
|
||||
@Query("class_id") String class_id,
|
||||
@Query("desktop_package") String desktop_package
|
||||
);
|
||||
|
||||
@GET(UrlAddress.APP_FORCE_INSTALL)
|
||||
Observable<BaseResponse<AppInfo>> getAdminApp(
|
||||
@Query("desktop_app_package") String desktop_app_package,
|
||||
|
||||
@@ -54,6 +54,8 @@ public class MainSContact {
|
||||
void getTestApp();
|
||||
/*获取管理员应用*/
|
||||
void getAdminApp();
|
||||
|
||||
void getAdminAppDownload();
|
||||
/*获取id管控*/
|
||||
void getAppInside();
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@ package com.xwad.os.service.main;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
@@ -22,6 +25,7 @@ import com.xwad.os.utils.FileUtils;
|
||||
import com.xwad.os.utils.ServiceAliveUtils;
|
||||
import com.xwad.os.utils.Utils;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
@@ -145,53 +149,6 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
});
|
||||
}
|
||||
|
||||
public void getAdminAppDownload() {
|
||||
NetInterfaceManager.getInstance().getAdminAppObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<AppInfo>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getAdminAppDownload", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<AppInfo>> listBaseResponse) {
|
||||
Log.e("getAdminAppDownload", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code == 200) {
|
||||
List<AppInfo> appInfoList = listBaseResponse.data;
|
||||
appInfoList.stream()
|
||||
.filter(new Predicate<AppInfo>() {
|
||||
@Override
|
||||
public boolean test(AppInfo appInfo) {
|
||||
return appInfo.getIs_must_components() == 1;
|
||||
}
|
||||
})
|
||||
.forEach(new Consumer<AppInfo>() {
|
||||
@Override
|
||||
public void accept(AppInfo appInfo) {
|
||||
if (appInfo.getIs_must_components_down() == 1) {
|
||||
if (!ApkUtils.isAvailable(mContext, appInfo.getApp_package())) {
|
||||
FileUtils.ariaDownload(mContext, appInfo.getApp_url(), appInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getAdminAppDownload", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getAdminAppDownload", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getAppInfo(String pkg) {
|
||||
NetInterfaceManager.getInstance().getAdminAppObservable(pkg)
|
||||
.subscribe(new Observer<BaseResponse<AppInfo>>() {
|
||||
@@ -331,12 +288,68 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void getTestApp() {
|
||||
NetInterfaceManager.getInstance().getTestAppObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<AppInfo>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getTestApp", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<AppInfo>> listBaseResponse) {
|
||||
Log.e("getTestApp", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code == 200) {
|
||||
List<AppInfo> appInfos = listBaseResponse.data;
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
appInfos.forEach(new Consumer<AppInfo>() {
|
||||
@Override
|
||||
public void accept(AppInfo appInfo) {
|
||||
String packages = appInfo.getApp_package();
|
||||
long app_version_code = appInfo.getApp_version_code();
|
||||
PackageInfo packageInfo = null;
|
||||
try {
|
||||
packageInfo = pm.getPackageInfo(packages, 0);
|
||||
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (packageInfo != null) {
|
||||
long appVersionCode;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
appVersionCode = packageInfo.getLongVersionCode();
|
||||
} else {
|
||||
appVersionCode = packageInfo.versionCode;
|
||||
}
|
||||
if (app_version_code > appVersionCode) {
|
||||
FileUtils.ariaDownload(mContext, appInfo.getApp_url(), appInfo);
|
||||
} else {
|
||||
Log.e("getTestApp", "intallApk: " + packages + " is up to date");
|
||||
}
|
||||
} else {
|
||||
FileUtils.ariaDownload(mContext, appInfo.getApp_url(), appInfo);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getTestApp", "onError: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getTestApp", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAdminApp() {
|
||||
NetInterfaceManager.getInstance().getAdminAppObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<AppInfo>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -368,6 +381,66 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAdminAppDownload() {
|
||||
NetInterfaceManager.getInstance().getAdminAppObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<AppInfo>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getAdminAppDownload", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<AppInfo>> listBaseResponse) {
|
||||
Log.e("getAdminAppDownload", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code == 200) {
|
||||
List<AppInfo> appInfoList = listBaseResponse.data;
|
||||
appInfoList.stream()
|
||||
.sorted(new Comparator<AppInfo>() {
|
||||
@Override
|
||||
public int compare(AppInfo o1, AppInfo o2) {
|
||||
if ("com.jxw.launcher".equals(o1.getApp_package()) && !"com.jxw.launcher".equals(o2.getApp_package())) {
|
||||
return -1;
|
||||
} else if (!"com.jxw.launcher".equals(o1.getApp_package()) && "com.jxw.launcher".equals(o2.getApp_package())) {
|
||||
return 1;
|
||||
} else {
|
||||
return o1.getApp_package().compareTo(o2.getApp_package()); // 非目标包名按字母排序
|
||||
}
|
||||
}
|
||||
})
|
||||
.filter(new Predicate<AppInfo>() {
|
||||
@Override
|
||||
public boolean test(AppInfo appInfo) {
|
||||
return appInfo.getIs_must_components() == 1;
|
||||
}
|
||||
})
|
||||
.forEach(new Consumer<AppInfo>() {
|
||||
@Override
|
||||
public void accept(AppInfo appInfo) {
|
||||
if (appInfo.getIs_must_components_down() == 1) {
|
||||
if (!ApkUtils.isAvailable(mContext, appInfo.getApp_package())) {
|
||||
// FileUtils.ariaDownload(mContext, appInfo.getApp_url(), appInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getAdminAppDownload", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getAdminAppDownload", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAppInside() {
|
||||
|
||||
|
||||
@@ -96,6 +96,7 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
|
||||
mPresenter.updateDeviceInfo();
|
||||
mPresenter.getAppIcon();
|
||||
mPresenter.getScreenLock();
|
||||
mPresenter.getTestApp();
|
||||
mPresenter.getAdminApp();
|
||||
mPresenter.getSystemSettings();
|
||||
mPresenter.getLockScreenPwd();
|
||||
|
||||
@@ -1283,13 +1283,13 @@ public class JgyUtils {
|
||||
boolean noti = mMMKV.decodeBool(CommonConfig.ALLOW_NOTIFICATION, true);
|
||||
Log.e(TAG, "startServices: noti = " + noti);
|
||||
// if (noti) {
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// long time = System.currentTimeMillis();
|
||||
// mContext.startForegroundService(new Intent(mContext, MainService.class));
|
||||
mContext.startForegroundService(new Intent(mContext, MainService.class));
|
||||
// Log.e(TAG, "setDefault: startServices time = " + (System.currentTimeMillis() - time) + "ms");
|
||||
// } else {
|
||||
} else {
|
||||
mContext.startService(new Intent(mContext, MainService.class));
|
||||
// }
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -859,6 +859,48 @@ public class OpenApkUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public void showDownloadDialog(Activity context, AppInfo appInfo) {
|
||||
Dialog dialog = new Dialog(context, R.style.ActionSheet);
|
||||
Window window = dialog.getWindow();
|
||||
View inflate = ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.download_dialog, null);
|
||||
TextView textView = inflate.findViewById(R.id.download_cancel);
|
||||
TextView textView2 = inflate.findViewById(R.id.tag_title);
|
||||
if (!TextUtils.isEmpty(appInfo.getApp_name())) {
|
||||
textView2.setText("未安装\"" + appInfo.getApp_name() + "\"\n下载后可继续使用!");
|
||||
}
|
||||
TextView textView3 = inflate.findViewById(R.id.download_ok);
|
||||
textView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
textView3.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
FileUtils.ariaDownload(mContext, appInfo.getApp_url(), appInfo);
|
||||
Intent intent = new Intent(mContext, DownloadService.class);
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// mContext.startForegroundService(intent);
|
||||
// } else {
|
||||
mContext.startService(intent);
|
||||
// }
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
WindowManager.LayoutParams attributes = window.getAttributes();
|
||||
attributes.x = 0;
|
||||
attributes.y = 0;
|
||||
attributes.gravity = Gravity.CENTER;
|
||||
dialog.onWindowAttributesChanged(attributes);
|
||||
dialog.setCanceledOnTouchOutside(true);
|
||||
dialog.setContentView(inflate);
|
||||
window.setDimAmount(0.6f);
|
||||
dialog.show();
|
||||
window.setAttributes(attributes);
|
||||
}
|
||||
|
||||
|
||||
public void showDownloadDialog(Activity context, String pkg, String appName) {
|
||||
Dialog dialog = new Dialog(context, R.style.ActionSheet);
|
||||
Window window = dialog.getWindow();
|
||||
|
||||
9
app/src/main/res/drawable/ic_download_all.xml
Normal file
9
app/src/main/res/drawable/ic_download_all.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="50dp"
|
||||
android:height="50dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:pathData="M512,22C241.38,22 22,241.38 22,512s219.38,490 490,490 490,-219.38 490,-490S782.62,22 512,22zM710.12,563.35l-173.9,173.91c-0.78,1 -1.61,1.97 -2.53,2.88 -5.99,5.99 -13.84,8.95 -21.69,8.91 -7.84,0.05 -15.7,-2.92 -21.69,-8.91 -0.92,-0.92 -1.76,-1.88 -2.53,-2.88l-173.9,-173.9c-11.88,-11.88 -11.88,-31.14 0,-43.02 11.88,-11.88 31.14,-11.88 43.03,0L481.58,645L481.58,305.37c0,-16.8 13.62,-30.42 30.42,-30.42 16.8,0 30.42,13.62 30.42,30.42L542.42,645L667.1,520.33c11.88,-11.88 31.14,-11.88 43.03,0 11.88,11.88 11.88,31.14 -0.01,43.02z"
|
||||
android:fillColor="#2c2c2c" />
|
||||
</vector>
|
||||
@@ -1,6 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context=".activity.download.DownloadActivity">
|
||||
|
||||
<data>
|
||||
|
||||
@@ -43,25 +45,72 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:paddingBottom="@dimen/x5"
|
||||
android:singleLine="true"
|
||||
android:tag="binding_1"
|
||||
android:text="学王365必备组件下载"
|
||||
android:text="必备组件下载"
|
||||
android:textColor="@color/res_text_color1"
|
||||
android:textSize="@dimen/x50"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/img_download"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginEnd="@dimen/y60"
|
||||
android:duplicateParentState="true"
|
||||
android:maxLines="1"
|
||||
android:onClick="@{click::openOtherApp}"
|
||||
android:singleLine="true"
|
||||
android:text="其他应用下载"
|
||||
android:textColor="@color/res_text_color1"
|
||||
android:textSize="@dimen/x40"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_content"
|
||||
style="@style/recycler_view_style"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/title_bar" />
|
||||
app:layout_constraintTop_toBottomOf="@id/title_bar">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_content"
|
||||
style="@style/recycler_view_style"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toTopOf="@+id/download_ok"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/download_ok"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginBottom="32dp"
|
||||
android:background="@drawable/download_ok_bg"
|
||||
android:gravity="center"
|
||||
android:onClick="@{click::downloadApp}"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:text="点击一键下载必备组件"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_nodata"
|
||||
@@ -69,6 +118,7 @@
|
||||
android:layout_height="0dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/title_bar">
|
||||
|
||||
|
||||
107
app/src/main/res/layout/activity_other_app.xml
Normal file
107
app/src/main/res/layout/activity_other_app.xml
Normal file
@@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout 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"
|
||||
tools:context=".activity.app.OtherAppActivity">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="click"
|
||||
type="com.xwad.os.activity.app.OtherAppActivity.BtnClick" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#d4dfff"
|
||||
android:tag="layout/activity_home_0">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/title_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/x160"
|
||||
android:background="@drawable/icon_btk"
|
||||
android:tag="layout/book_layout_title_bar_0"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img_back"
|
||||
android:layout_width="@dimen/y100"
|
||||
android:layout_height="@dimen/x100"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="@dimen/y60"
|
||||
android:duplicateParentState="true"
|
||||
android:onClick="@{click::exit}"
|
||||
android:src="@drawable/icon_back1"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:paddingBottom="@dimen/x5"
|
||||
android:singleLine="true"
|
||||
android:tag="binding_1"
|
||||
android:text="其他应用下载"
|
||||
android:textColor="@color/res_text_color1"
|
||||
android:textSize="@dimen/x50"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/title_bar">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_content"
|
||||
style="@style/recycler_view_style"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginBottom="32dp"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_nodata"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/title_bar">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="@dimen/y589"
|
||||
android:layout_height="@dimen/x524"
|
||||
android:src="@drawable/icon_qst" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/x43"
|
||||
android:text="@string/no_content_available_the_moment"
|
||||
android:textColor="@color/res_text_color1"
|
||||
android:textSize="@dimen/x36" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
@@ -20,10 +20,11 @@
|
||||
android:layout_width="14dp"
|
||||
android:layout_height="14dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:visibility="gone"
|
||||
android:layout_marginStart="32dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/ic_download"
|
||||
android:src="@drawable/ic_download_all"
|
||||
app:layout_constraintStart_toStartOf="@+id/iv_app_icon"
|
||||
app:layout_constraintTop_toTopOf="@+id/iv_app_icon" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user