update:2020.03.11 优化首页布局,修正更新逻辑
This commit is contained in:
22
app/app.iml
22
app/app.iml
File diff suppressed because one or more lines are too long
@@ -17,8 +17,8 @@ android {
|
||||
applicationId "com.appstore.uiui"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 29
|
||||
versionCode 10
|
||||
versionName "1.1.0"
|
||||
versionCode 13
|
||||
versionName "1.1.3"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
//极光
|
||||
ndk {
|
||||
@@ -109,7 +109,7 @@ dependencies {
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
|
||||
|
||||
//github第三方控件maven
|
||||
//github第三方控件
|
||||
implementation 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar'
|
||||
//下拉刷新控件
|
||||
implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' //1.0.5及以前版本的老用户升级需谨慎,API改动过大
|
||||
@@ -146,7 +146,7 @@ dependencies {
|
||||
implementation 'cn.jiguang.sdk:jcore:2.2.4' // 此处以JCore 2.2.4 版本为例。
|
||||
|
||||
implementation 'com.zhpan.library:bannerview:2.6.4'
|
||||
compile "androidx.core:core-ktx:+"
|
||||
implementation "androidx.core:core-ktx:+"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,8 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
tools:ignore="GoogleAppIndexingWarning">
|
||||
<activity android:name=".activity.SearcherActivity"></activity>
|
||||
<activity android:name=".activity.AboutActivity"></activity>
|
||||
<activity android:name=".activity.SearcherActivity" />
|
||||
|
||||
<service
|
||||
android:name=".service.InitJpushServer"
|
||||
@@ -47,6 +48,7 @@
|
||||
<activity android:name=".activity.MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
@@ -86,9 +88,7 @@
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
|
||||
<!-- Rich push 核心功能 since 2.0.6 -->
|
||||
</provider> <!-- Rich push 核心功能 since 2.0.6 -->
|
||||
<activity
|
||||
android:name="cn.jpush.android.ui.PopWinActivity"
|
||||
android:exported="false"
|
||||
|
||||
@@ -7,12 +7,11 @@ import android.content.pm.PackageManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.appstore.uiui.jpush.Logger;
|
||||
import com.appstore.uiui.network.OKGOPost;
|
||||
import com.appstore.uiui.network.OKGO;
|
||||
import com.appstore.uiui.utils.ApkUtils;
|
||||
import com.appstore.uiui.utils.LogUtils;
|
||||
import com.appstore.uiui.utils.SPUtils;
|
||||
@@ -360,7 +359,7 @@ public class MyApplication extends Application {
|
||||
@Override
|
||||
public void onSuccess(Response<File> response) {
|
||||
// Settings.System.putString(getApplicationContext().getContentResolver(), "qch_app_forbid", "com.baidu.video");
|
||||
ApkUtils.installApkInSilence(response.body().getAbsolutePath(), packages);
|
||||
ApkUtils.installApkInSilence(app.getAppContext(), response.body().getAbsolutePath());
|
||||
LogUtils.e("onSuccess", "download file successful,now installing");
|
||||
}
|
||||
|
||||
@@ -391,7 +390,7 @@ public class MyApplication extends Application {
|
||||
ToastUtil.debugShow("收到应用卸载消息:包名" + packageName);
|
||||
if (!packageName.equals("") && !packageName.equals(getApplicationContext().getPackageName())) {
|
||||
if (!ApkUtils.isAvailable(getApplicationContext(), packageName)) {
|
||||
OKGOPost.setAppuninstallInfo(sn_id, packageName);
|
||||
OKGO.setAppuninstallInfo(sn_id, packageName);
|
||||
} else {
|
||||
ApkUtils.deleteApkInSilence(packageName);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.appstore.uiui.activity;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.appstore.uiui.BuildConfig;
|
||||
import com.appstore.uiui.R;
|
||||
import com.appstore.uiui.base.BaseActivity;
|
||||
|
||||
public class AboutActivity extends BaseActivity {
|
||||
private ImageView iv_exit;
|
||||
private TextView tv_version;
|
||||
|
||||
|
||||
@Override
|
||||
protected int setLayoutResourceID() {
|
||||
return R.layout.activity_about;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
iv_exit = findViewById(R.id.iv_exit);
|
||||
iv_exit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
tv_version=findViewById(R.id.tv_version);
|
||||
tv_version.setText("版本:"+ BuildConfig.VERSION_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setListener() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import com.appstore.uiui.adapter.AppAdapter;
|
||||
import com.appstore.uiui.base.BaseActivity;
|
||||
import com.appstore.uiui.base.RefreshManager;
|
||||
import com.appstore.uiui.bean.AppInfo;
|
||||
import com.appstore.uiui.network.OKGOPost;
|
||||
import com.appstore.uiui.network.OKGO;
|
||||
import com.appstore.uiui.utils.ApkUtils;
|
||||
import com.appstore.uiui.utils.SPUtils;
|
||||
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
||||
@@ -67,10 +67,10 @@ public class KindDetailActivity extends BaseActivity implements RefreshManager.R
|
||||
mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh(RefreshLayout refreshlayout) {
|
||||
OKGOPost.getSortApp(handler, type, grade, subject);
|
||||
OKGO.getSortApp(handler, type, grade, subject);
|
||||
}
|
||||
});
|
||||
OKGOPost.getSortApp(handler, type, grade, subject);
|
||||
OKGO.getSortApp(handler, type, grade, subject);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,11 +4,11 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
@@ -32,7 +32,7 @@ import com.appstore.uiui.fragment.RankFragment;
|
||||
import com.appstore.uiui.jpush.ExampleUtil;
|
||||
import com.appstore.uiui.jpush.LocalBroadcastManager;
|
||||
import com.appstore.uiui.jpush.TagAliasOperatorHelper;
|
||||
import com.appstore.uiui.network.OKGOPost;
|
||||
import com.appstore.uiui.network.OKGO;
|
||||
import com.appstore.uiui.service.MyDownloadService;
|
||||
import com.appstore.uiui.utils.ApkUtils;
|
||||
import com.appstore.uiui.utils.LogUtils;
|
||||
@@ -54,7 +54,6 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
import cn.jpush.android.api.TagAliasCallback;
|
||||
|
||||
import static com.appstore.uiui.jpush.TagAliasOperatorHelper.ACTION_ADD;
|
||||
import static com.appstore.uiui.jpush.TagAliasOperatorHelper.ACTION_CHECK;
|
||||
@@ -67,7 +66,7 @@ import static com.appstore.uiui.jpush.TagAliasOperatorHelper.sequence;
|
||||
|
||||
public class MainActivity extends BaseActivity {
|
||||
private RelativeLayout search_layout;
|
||||
private ImageView iv_download;
|
||||
private ImageView iv_download, iv_appicon;
|
||||
private SlidingTabLayout mSlidingTabLayout;
|
||||
private ViewPager mViewPager;
|
||||
private long exitTime = 0;
|
||||
@@ -88,7 +87,7 @@ public class MainActivity extends BaseActivity {
|
||||
// ToastUtil.show("Get registration fail, JPush init failed!");
|
||||
// Toast.makeText(this, "Get registration fail, JPush init failed!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
OKGOPost.getUserInfo(handler);
|
||||
OKGO.getUserInfo(handler);
|
||||
// PackageManager pm = getPackageManager();
|
||||
// pm.setApplicationEnabledSetting("com.tencent.qqmusic", PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
|
||||
startService(new Intent(MainActivity.this, MyDownloadService.class));
|
||||
@@ -102,6 +101,13 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
iv_appicon = findViewById(R.id.iv_appicon);
|
||||
iv_appicon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(MainActivity.this, AboutActivity.class));
|
||||
}
|
||||
});
|
||||
iv_download = findViewById(R.id.iv_download);
|
||||
iv_download.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@@ -145,7 +151,7 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
OKGO.getAllAppPackageName(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -154,7 +160,7 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
synchronized private void CheckUpdate() {
|
||||
OKGOPost.checkUpdateByPackage(handler, this.getPackageName(), String.valueOf(BuildConfig.VERSION_CODE));
|
||||
OKGO.checkUpdateByPackage(handler, this.getPackageName(), String.valueOf(BuildConfig.VERSION_CODE));
|
||||
}
|
||||
|
||||
// 初始化 JPush。如果已经初始化,但没有登录成功,则执行重新登录。
|
||||
@@ -373,6 +379,16 @@ public class MainActivity extends BaseActivity {
|
||||
String url = (String) msg.obj;
|
||||
getFile(url);
|
||||
break;
|
||||
case 201:
|
||||
String apppackage = (String) msg.obj;
|
||||
Log.e("fht", Settings.System.getString(getContentResolver(), "qch_app_forbid")+"?");
|
||||
if (Settings.System.putString(getContentResolver(), "qch_app_forbid", apppackage)) {
|
||||
Log.e("fht", "app package write successful");
|
||||
}
|
||||
|
||||
break;
|
||||
case 202:
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -383,7 +399,7 @@ public class MainActivity extends BaseActivity {
|
||||
@Override
|
||||
public void onSuccess(Response<File> response) {
|
||||
// Settings.System.putString(getApplicationContext().getContentResolver(), "qch_app_forbid", "com.baidu.video");
|
||||
ApkUtils.installApkInSilence(response.body().getAbsolutePath(), MainActivity.this.getPackageName());
|
||||
ApkUtils.installApkInSilence(MainActivity.this, response.body().getAbsolutePath());
|
||||
LogUtils.e("getFile", "download file successful,now installing");
|
||||
}
|
||||
|
||||
|
||||
@@ -13,10 +13,9 @@ import com.appstore.uiui.R;
|
||||
import com.appstore.uiui.adapter.AppAdapter;
|
||||
import com.appstore.uiui.base.BaseActivity;
|
||||
import com.appstore.uiui.bean.AppInfo;
|
||||
import com.appstore.uiui.network.OKGOPost;
|
||||
import com.appstore.uiui.network.OKGO;
|
||||
import com.appstore.uiui.utils.ApkUtils;
|
||||
import com.appstore.uiui.utils.LogUtils;
|
||||
import com.appstore.uiui.utils.ToastUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -54,7 +53,7 @@ public class SearcherActivity extends BaseActivity {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
LogUtils.e("search", query);
|
||||
OKGOPost.searchAppbyName(handler, query);
|
||||
OKGO.searchAppbyName(handler, query);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.appstore.uiui.adapter;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.telecom.Call;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -13,16 +10,13 @@ import android.widget.ImageView;
|
||||
import android.widget.RatingBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.appstore.uiui.R;
|
||||
import com.appstore.uiui.activity.DetailsActivity;
|
||||
import com.appstore.uiui.bean.AppInfo;
|
||||
import com.appstore.uiui.listener.LogDownloadListener;
|
||||
import com.appstore.uiui.network.OKGOPost;
|
||||
import com.appstore.uiui.utils.ApkUtils;
|
||||
import com.appstore.uiui.utils.LogUtils;
|
||||
import com.appstore.uiui.utils.ToastUtil;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.lzy.okgo.OkGo;
|
||||
@@ -256,7 +250,7 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
|
||||
@Override
|
||||
public void onFinish(File file, Progress progress) {
|
||||
ToastUtil.show(((AppInfo) progress.extra1).getApp_name() + "\t下载完成");
|
||||
ApkUtils.installApkInSilence(file.getAbsolutePath(), ((AppInfo) progress.extra1).getApp_package());
|
||||
ApkUtils.installApkInSilence(mContext, file.getAbsolutePath());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -184,7 +184,7 @@ public class UpdateAppAdapter extends RecyclerView.Adapter<UpdateAppAdapter.Upda
|
||||
@Override
|
||||
public void onFinish(File file, Progress progress) {
|
||||
ToastUtil.show(((AppInfo) progress.extra1).getApp_name() + "\t下载完成");
|
||||
ApkUtils.installApkInSilence(file.getAbsolutePath(), ((AppInfo) progress.extra1).getApp_package());
|
||||
ApkUtils.installApkInSilence(context,file.getAbsolutePath() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -75,7 +75,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
//需要设置这个flag contentView才能延伸到状态栏
|
||||
// activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
|
||||
//状态栏覆盖在contentView上面,设置透明使contentView的背景透出来
|
||||
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||
activity.getWindow().setStatusBarColor(Color.BLACK);
|
||||
} else {
|
||||
//让contentView延伸到状态栏并且设置状态栏颜色透明
|
||||
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.appstore.uiui.common;
|
||||
|
||||
import android.os.Debug;
|
||||
|
||||
public class BuidConfig {
|
||||
import com.appstore.uiui.BuildConfig;
|
||||
|
||||
public class BuikdConf {
|
||||
public static final boolean Isdebug = true;
|
||||
}
|
||||
@@ -7,14 +7,11 @@ import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.appstore.uiui.R;
|
||||
import com.appstore.uiui.adapter.AppAdapter;
|
||||
import com.appstore.uiui.adapter.BannerViewHolder;
|
||||
@@ -22,15 +19,10 @@ import com.appstore.uiui.base.LazyLoadFragment;
|
||||
import com.appstore.uiui.base.RefreshManager;
|
||||
import com.appstore.uiui.bean.AppInfo;
|
||||
import com.appstore.uiui.bean.AppInfos;
|
||||
import com.appstore.uiui.network.OKGOPost;
|
||||
import com.appstore.uiui.network.URLs.Url;
|
||||
import com.appstore.uiui.network.OKGO;
|
||||
import com.appstore.uiui.utils.ApkUtils;
|
||||
import com.appstore.uiui.utils.LogUtils;
|
||||
import com.appstore.uiui.utils.ToastUtil;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.lzy.okgo.OkGo;
|
||||
import com.lzy.okgo.callback.StringCallback;
|
||||
import com.lzy.okgo.model.Response;
|
||||
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
|
||||
@@ -144,8 +136,8 @@ public class FeaturedFragment extends LazyLoadFragment implements RefreshManager
|
||||
}
|
||||
|
||||
synchronized private void initAPPData(final Handler handler) {
|
||||
OKGOPost.getAllAppInfo(handler);
|
||||
OKGOPost.getBannerImg(handler);
|
||||
OKGO.getAllAppInfo(handler);
|
||||
OKGO.getBannerImg(handler);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,14 +20,12 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.appstore.uiui.R;
|
||||
import com.appstore.uiui.activity.DownloadManagerActivity;
|
||||
import com.appstore.uiui.activity.LocalManagerActivity;
|
||||
import com.appstore.uiui.activity.MainActivity;
|
||||
import com.appstore.uiui.adapter.LocalAppAdapter;
|
||||
import com.appstore.uiui.adapter.UpdateAppAdapter;
|
||||
import com.appstore.uiui.base.LazyLoadFragment;
|
||||
import com.appstore.uiui.bean.AppInfo;
|
||||
import com.appstore.uiui.bean.LocalApp;
|
||||
import com.appstore.uiui.bean.UpdateAppInfo;
|
||||
import com.appstore.uiui.network.OKGOPost;
|
||||
import com.appstore.uiui.network.OKGO;
|
||||
import com.appstore.uiui.utils.ApkUtils;
|
||||
import com.appstore.uiui.utils.ToastUtil;
|
||||
|
||||
@@ -91,7 +89,7 @@ public class ManageFragment extends LazyLoadFragment {
|
||||
}
|
||||
|
||||
synchronized private void initAPPData(final Handler handler) {
|
||||
OKGOPost.getAllAppInfo(handler);
|
||||
OKGO.getAllAppInfo(handler);
|
||||
}
|
||||
|
||||
synchronized private List<LocalApp> getLocalApp() {
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.os.Bundle;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
|
||||
@@ -17,13 +16,11 @@ import com.appstore.uiui.adapter.AppAdapter;
|
||||
import com.appstore.uiui.base.LazyLoadFragment;
|
||||
import com.appstore.uiui.base.RefreshManager;
|
||||
import com.appstore.uiui.bean.AppInfo;
|
||||
import com.appstore.uiui.network.OKGOPost;
|
||||
import com.appstore.uiui.network.OKGO;
|
||||
import com.appstore.uiui.utils.ApkUtils;
|
||||
import com.appstore.uiui.utils.LogUtils;
|
||||
import com.lzy.okgo.OkGo;
|
||||
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -62,7 +59,7 @@ public class RankFragment extends LazyLoadFragment implements RefreshManager.Ref
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
OKGOPost.getRankApp(handler);
|
||||
OKGO.getRankApp(handler);
|
||||
LogUtils.e("fht", "RankFragment onStart");
|
||||
}
|
||||
|
||||
@@ -104,7 +101,7 @@ public class RankFragment extends LazyLoadFragment implements RefreshManager.Ref
|
||||
mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh(RefreshLayout refreshlayout) {
|
||||
OKGOPost.getRankApp(handler);
|
||||
OKGO.getRankApp(handler);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class OKGOPost {
|
||||
public class OKGO {
|
||||
private static final int GET_ALL_APPINFO = 0;
|
||||
private static final int GET_USERINFO = 1;
|
||||
private static final int GET_SORTAPP = 2;
|
||||
@@ -88,6 +88,44 @@ public class OKGOPost {
|
||||
});
|
||||
}
|
||||
|
||||
synchronized public static void getAllAppPackageName(final Handler handler) {
|
||||
OkGo.<String>get(Url.GET_ALL_PACKAGENAME).execute(new StringCallback() {
|
||||
@Override
|
||||
public void onSuccess(Response<String> response) {
|
||||
String s = response.body();
|
||||
try {
|
||||
JSONObject body = JSON.parseObject(s);
|
||||
int code = body.getInteger("code");
|
||||
String msg = body.getString("msg");
|
||||
String data = body.getString("data");
|
||||
if (code == 200) {
|
||||
List<JSONObject> jsonArray = JSON.parseArray(data, JSONObject.class);
|
||||
String packageList = "";
|
||||
for (JSONObject jsonObject : jsonArray) {
|
||||
packageList += jsonObject.getString("app_package") + ",";
|
||||
}
|
||||
if (!packageList.isEmpty()) {
|
||||
Log.e("fht", packageList);
|
||||
Message message = new Message();
|
||||
message.what = 201;
|
||||
message.obj = packageList;
|
||||
handler.sendMessage(message);
|
||||
} else {
|
||||
handler.sendEmptyMessage(202);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Response<String> response) {
|
||||
super.onError(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
synchronized public static void getRankApp(final Handler handler) {
|
||||
OkGo.<String>get(Url.GET_ALL_RANK).execute(new StringCallback() {
|
||||
@Override
|
||||
@@ -5,7 +5,7 @@ public class Url {
|
||||
|
||||
public final static String GET_ALL_APPINFO = NETWORK_HOME_ADDRESS + "/App/allInfo";
|
||||
//获取所有应用
|
||||
public final static String GET_ALL_RANK = NETWORK_HOME_ADDRESS + "/App/rankings";
|
||||
public final static String GET_ALL_RANK = NETWORK_HOME_ADDRESS + "/App/rankings";
|
||||
//获取所有应用排行
|
||||
public final static String GET_APPSEARCHE = NETWORK_HOME_ADDRESS + "/App/appSearch";
|
||||
//搜索应用
|
||||
@@ -20,5 +20,7 @@ public class Url {
|
||||
public final static String GET_APP_UPDATE = NETWORK_HOME_ADDRESS + "/Update/update";
|
||||
//根据包名获取更新
|
||||
public final static String GET_BANNER_IMG = NETWORK_HOME_ADDRESS + "/Slideshow/getImg";
|
||||
|
||||
//获取banner图
|
||||
public final static String GET_ALL_PACKAGENAME = NETWORK_HOME_ADDRESS + "/App/allPackage";
|
||||
//获取所有应用包名
|
||||
}
|
||||
|
||||
@@ -3,10 +3,9 @@ package com.appstore.uiui.receiver;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.util.Log;
|
||||
|
||||
import com.appstore.uiui.network.OKGOPost;
|
||||
import com.appstore.uiui.network.OKGO;
|
||||
import com.appstore.uiui.utils.ApkUtils;
|
||||
import com.appstore.uiui.utils.LogUtils;
|
||||
import com.appstore.uiui.utils.SPUtils;
|
||||
@@ -40,9 +39,9 @@ public class AppManagerReceiver extends BroadcastReceiver {
|
||||
// ToastTool.show("安装成功");
|
||||
if (!packageName.equals(context.getPackageName()) && !packageName.equals("com.android.uiuios") && !packageName.equals("com.info.sn")) {
|
||||
if (member_id == -1 || sn_id.equals("-1")) {
|
||||
OKGOPost.getUserInfo(context);
|
||||
OKGO.getUserInfo(context);
|
||||
} else {
|
||||
OKGOPost.setAppinstallInfo(member_id, sn_id, name, packageName);
|
||||
OKGO.setAppinstallInfo(member_id, sn_id, name, packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,9 +54,9 @@ public class AppManagerReceiver extends BroadcastReceiver {
|
||||
context.sendBroadcast(intents);
|
||||
if (!packageName.equals(context.getPackageName()) && !packageName.equals("com.android.uiuios")) {
|
||||
if (member_id == -1 || sn_id.equals("-1")) {
|
||||
OKGOPost.getUserInfo(context);
|
||||
OKGO.getUserInfo(context);
|
||||
} else {
|
||||
OKGOPost.setAppuninstallInfo(sn_id, packageName);
|
||||
OKGO.setAppuninstallInfo(sn_id, packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,8 @@ package com.appstore.uiui.receiver;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import com.appstore.uiui.network.OKGOPost;
|
||||
import com.appstore.uiui.network.OKGO;
|
||||
import com.appstore.uiui.service.GuardService;
|
||||
import com.appstore.uiui.service.InitJpushServer;
|
||||
import com.appstore.uiui.service.StepService;
|
||||
@@ -15,12 +14,10 @@ public class BootReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
|
||||
|
||||
Intent i = new Intent(context, InitJpushServer.class);
|
||||
context.startService(i);
|
||||
context.startService(new Intent(context, InitJpushServer.class));
|
||||
context.startService(new Intent(context, StepService.class));
|
||||
context.startService(new Intent(context, GuardService.class));
|
||||
OKGOPost.getUserInfo(context);
|
||||
OKGO.getUserInfo(context);
|
||||
LogUtils.e("fht", "booting BootReceiver");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,20 +12,30 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Message;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.appstore.uiui.KeepAliveConnection;
|
||||
import com.appstore.uiui.activity.MainActivity;
|
||||
import com.appstore.uiui.base.UserInfo;
|
||||
import com.appstore.uiui.network.OKGO;
|
||||
import com.appstore.uiui.utils.ApkUtils;
|
||||
import com.appstore.uiui.utils.LogUtils;
|
||||
import com.appstore.uiui.utils.SPUtils;
|
||||
import com.appstore.uiui.utils.ServiceAliveUtils;
|
||||
import com.arialyy.annotations.Download;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.task.DownloadTask;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
||||
/**
|
||||
* 守护进程 双进程通讯
|
||||
@@ -44,6 +54,7 @@ public class GuardService extends Service {
|
||||
Intent i = new Intent(GuardService.this, MyDownloadService.class);
|
||||
startService(i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,27 +80,51 @@ public class GuardService extends Service {
|
||||
Aria.init(this);
|
||||
Aria.get(this).getDownloadConfig().setMaxTaskNum(1);
|
||||
Aria.download(this).register();
|
||||
OKGO.getAllAppPackageName(handler);
|
||||
|
||||
// startForeground(1, new Notification());
|
||||
// 绑定建立链接
|
||||
bindService(new Intent(this, StepService.class), mServiceConnection, Context.BIND_IMPORTANT);
|
||||
return START_STICKY;
|
||||
}
|
||||
private Handler handler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(@NonNull Message msg) {
|
||||
super.handleMessage(msg);
|
||||
switch (msg.what) {
|
||||
|
||||
case 201:
|
||||
String apppackage = (String) msg.obj;
|
||||
Log.e("fht", Settings.System.getString(getContentResolver(), "qch_app_forbid")+"?");
|
||||
if (Settings.System.putString(getContentResolver(), "qch_app_forbid", apppackage)) {
|
||||
Log.e("fht", "app package write successful");
|
||||
}
|
||||
break;
|
||||
case 202:
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//在这里处理任务执行中的状态,如进度进度条的刷新
|
||||
@Download.onTaskRunning
|
||||
protected void running( DownloadTask task) {
|
||||
LogUtils.e("mjsheng", "我在下载=--------------::" + task.getState() + "-------" + task.getPercent()+ "-------" + task.getExtendField());
|
||||
protected void running(DownloadTask task) {
|
||||
LogUtils.e("mjsheng", "我在下载=--------------::" + task.getState() + "-------" + task.getPercent() + "-------" + task.getExtendField());
|
||||
ToastUtils.showShort("我在下载=--------------::" + task.getExtendField() + "-------" + task.getPercent());
|
||||
}
|
||||
|
||||
@Download.onTaskComplete
|
||||
void taskComplete( DownloadTask task) {
|
||||
void taskComplete(DownloadTask task) {
|
||||
//在这里处理任务完成的状态
|
||||
String downloadPath = task.getFilePath();
|
||||
String packageName = task.getExtendField();
|
||||
LogUtils.e("mjsheng", "downloadPath::" + downloadPath);
|
||||
LogUtils.e("mjsheng", "extendField::" + packageName);
|
||||
ApkUtils.installApkInSilence(downloadPath, packageName);
|
||||
if (packageName.equalsIgnoreCase(this.getPackageName())) {
|
||||
ApkUtils.install(this, new File(downloadPath));
|
||||
} else {
|
||||
ApkUtils.installApkInSilence(this, downloadPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import android.widget.Toast;
|
||||
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import com.appstore.uiui.BuildConfig;
|
||||
import com.appstore.uiui.R;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@@ -309,29 +310,72 @@ public class ApkUtils {
|
||||
// }
|
||||
|
||||
//使用系统签名
|
||||
public static void installApkInSilence(String installPath, String packageName) {
|
||||
// public static void installApkInSilence(String installPath, String packageName) {
|
||||
// ToastUtil.show("正在安装应用...");
|
||||
// Class<?> pmService;
|
||||
// Class<?> activityTherad;
|
||||
// Method method;
|
||||
// try {
|
||||
// activityTherad = Class.forName("android.app.ActivityThread");
|
||||
// Class<?> paramTypes[] = getParamTypes(activityTherad, "getPackageManager");
|
||||
// method = activityTherad.getMethod("getPackageManager", paramTypes);
|
||||
// Object PackageManagerService = method.invoke(activityTherad);
|
||||
// pmService = PackageManagerService.getClass();
|
||||
// Class<?> paramTypes1[] = getParamTypes(pmService, "installPackageAsUser");
|
||||
// method = pmService.getMethod("installPackageAsUser", paramTypes1);
|
||||
// method.invoke(PackageManagerService, installPath, null, 0x00000040, packageName, getUserId(Binder.getCallingUid()));//getUserId
|
||||
// } catch (ClassNotFoundException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (NoSuchMethodException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (IllegalAccessException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (InvocationTargetException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
public static boolean installApkInSilence(Context context, String apkPath) {
|
||||
ToastUtil.show("正在安装应用...");
|
||||
Class<?> pmService;
|
||||
Class<?> activityTherad;
|
||||
Method method;
|
||||
Process process = null;
|
||||
BufferedReader successResult = null;
|
||||
BufferedReader errorResult = null;
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder errorMsg = new StringBuilder();
|
||||
try {
|
||||
activityTherad = Class.forName("android.app.ActivityThread");
|
||||
Class<?> paramTypes[] = getParamTypes(activityTherad, "getPackageManager");
|
||||
method = activityTherad.getMethod("getPackageManager", paramTypes);
|
||||
Object PackageManagerService = method.invoke(activityTherad);
|
||||
pmService = PackageManagerService.getClass();
|
||||
Class<?> paramTypes1[] = getParamTypes(pmService, "installPackageAsUser");
|
||||
method = pmService.getMethod("installPackageAsUser", paramTypes1);
|
||||
method.invoke(PackageManagerService, installPath, null, 0x00000040, packageName, getUserId(Binder.getCallingUid()));//getUserId
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
process = new ProcessBuilder("pm", "install", "-i", BuildConfig.APPLICATION_ID, "--user", "0", apkPath).start();
|
||||
successResult = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
errorResult = new BufferedReader(new InputStreamReader(process.getErrorStream()));
|
||||
String s;
|
||||
while ((s = successResult.readLine()) != null) {
|
||||
successMsg.append(s);
|
||||
}
|
||||
while ((s = errorResult.readLine()) != null) {
|
||||
errorMsg.append(s);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
} finally {
|
||||
try {
|
||||
if (successResult != null) {
|
||||
successResult.close();
|
||||
}
|
||||
if (errorResult != null) {
|
||||
errorResult.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
if (process != null) {
|
||||
process.destroy();
|
||||
}
|
||||
}
|
||||
Log.e("result", "" + errorMsg.toString());
|
||||
//如果含有“success”认为安装成功
|
||||
Log.e("installApp", successMsg.toString());
|
||||
// if (!successMsg.toString().equalsIgnoreCase("success")) {
|
||||
// ApkUtils.install(context, new File(apkPath));
|
||||
// }
|
||||
return successMsg.toString().equalsIgnoreCase("success");
|
||||
}
|
||||
|
||||
public static void deleteApkInSilence(String packageName) {
|
||||
|
||||
BIN
app/src/main/res/drawable/bt_return.png
Normal file
BIN
app/src/main/res/drawable/bt_return.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
81
app/src/main/res/layout/activity_about.xml
Normal file
81
app/src/main/res/layout/activity_about.xml
Normal file
@@ -0,0 +1,81 @@
|
||||
<?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"
|
||||
android:background="#ffffff">
|
||||
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/constraintLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_30"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_exit"
|
||||
android:layout_width="@dimen/dp_15"
|
||||
android:layout_height="@dimen/dp_15"
|
||||
android:layout_marginLeft="@dimen/dp_5"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/bt_return"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="关于"
|
||||
android:textColor="#4b4b4b"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView3"
|
||||
android:layout_width="@dimen/dp_80"
|
||||
android:layout_height="@dimen/dp_80"
|
||||
android:layout_marginTop="64dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/ic_app"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/constraintLayout">
|
||||
|
||||
</ImageView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_appname"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="32dp"
|
||||
android:text="@string/app_name"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView3" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_version"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="32dp"
|
||||
android:text="版本:"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_appname" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_appicon"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
|
||||
@@ -9,23 +9,33 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.zhpan.bannerview.BannerViewPager
|
||||
android:id="@+id/banner_view"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_150"
|
||||
android:layout_margin="10dp" />
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/featured_rv_result"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
<com.zhpan.bannerview.BannerViewPager
|
||||
android:id="@+id/banner_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_150"
|
||||
android:layout_margin="10dp" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/featured_rv_result"
|
||||
android:nestedScrollingEnabled="false"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
|
||||
|
||||
</LinearLayout>
|
||||
Reference in New Issue
Block a user