update:2020.03.16 更新布局,优化下载问题,加入字体

This commit is contained in:
2020-03-16 18:10:17 +08:00
parent 82f08853f5
commit 553999f7ec
52 changed files with 472 additions and 123 deletions

View File

@@ -17,8 +17,8 @@ android {
applicationId "com.appstore.uiui"
minSdkVersion 23
targetSdkVersion 29
versionCode 13
versionName "1.1.3"
versionCode 15
versionName "1.1.5"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
//极光
ndk {
@@ -149,6 +149,8 @@ dependencies {
implementation "androidx.core:core-ktx:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
//更换字体框架
}
repositories {

View File

@@ -26,14 +26,15 @@
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_app"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:launchMode="singleTask"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".activity.AboutActivity"></activity>
<activity android:name=".activity.CopyrightActivity"></activity>
<activity android:name=".activity.AboutActivity" />
<activity android:name=".activity.SearcherActivity" />
<service
@@ -69,7 +70,7 @@
android:name=".receiver.AppManagerReceiver"
android:enabled="true"
android:exported="true">
<intent-filter android:priority="10000">
<intent-filter android:priority="1000">
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />

Binary file not shown.

View File

@@ -36,6 +36,7 @@ import java.io.File;
import cn.jpush.android.api.CustomMessage;
import cn.jpush.android.api.JPushInterface;
import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
/**
* Created by asus on 2017/10/27.
@@ -58,7 +59,7 @@ public class MyApplication extends Application {
@NonNull
@Override
public RefreshHeader createRefreshHeader(@NonNull Context context, @NonNull RefreshLayout layout) {
layout.setPrimaryColorsId(R.color.backgroundcolor, android.R.color.white);//全局设置主题颜色
layout.setPrimaryColorsId(R.color.download, R.color.green);//全局设置主题颜色
return new ClassicsHeader(context);//.setTimeFormat(new DynamicTimeFormat("更新于 %s"));//指定为经典Header默认是 贝塞尔雷达Header
}
});
@@ -90,6 +91,16 @@ public class MyApplication extends Application {
if (!isDebug(this)) {
catchException();
}
//全局字体初始化
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
// .setDefaultFontPath("fonts/1234.ttf")
// .setDefaultFontPath("fonts/SourceHanSansCN-ExtraLight.ttf")
.setDefaultFontPath("fonts/test.ttf")
.setFontAttrId(R.attr.fontPath)
.build()
);
}
public boolean isDebug(Context context) {
@@ -357,9 +368,14 @@ public class MyApplication extends Application {
OkGo.<File>get(url)
.execute(new FileCallback() {
@Override
public void onSuccess(Response<File> response) {
public void onSuccess(final Response<File> response) {
// Settings.System.putString(getApplicationContext().getContentResolver(), "qch_app_forbid", "com.baidu.video");
ApkUtils.installApkInSilence(app.getAppContext(), response.body().getAbsolutePath());
new Thread(new Runnable() {
@Override
public void run() {
ApkUtils.installApkInSilence(app.getAppContext(), response.body().getAbsolutePath());
}
}).start();
LogUtils.e("onSuccess", "download file successful,now installing");
}

View File

@@ -1,5 +1,7 @@
package com.appstore.uiui.activity;
import android.content.Intent;
import android.graphics.Paint;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
@@ -10,7 +12,7 @@ import com.appstore.uiui.base.BaseActivity;
public class AboutActivity extends BaseActivity {
private ImageView iv_exit;
private TextView tv_version;
private TextView tv_version, tv_copyright;
@Override
@@ -27,8 +29,17 @@ public class AboutActivity extends BaseActivity {
finish();
}
});
tv_version=findViewById(R.id.tv_version);
tv_version.setText("版本:"+ BuildConfig.VERSION_NAME);
tv_version = findViewById(R.id.tv_version);
tv_version.setText("版本:" + BuildConfig.VERSION_NAME);
tv_copyright = findViewById(R.id.tv_copyright);
tv_copyright.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); //下划线
tv_copyright.getPaint().setAntiAlias(true);//抗锯齿
tv_copyright.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(AboutActivity.this, CopyrightActivity.class));
}
});
}
@Override

View File

@@ -0,0 +1,33 @@
package com.appstore.uiui.activity;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.appstore.uiui.R;
import com.appstore.uiui.base.BaseActivity;
public class CopyrightActivity extends BaseActivity {
@Override
protected int setLayoutResourceID() {
return R.layout.activity_copyright;
}
@Override
protected void initView() {
}
@Override
protected void initData() {
}
@Override
protected void setListener() {
}
}

View File

@@ -1,5 +1,9 @@
package com.appstore.uiui.activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
@@ -14,13 +18,15 @@ import com.appstore.uiui.adapter.ImageAdapter;
import com.appstore.uiui.base.BaseActivity;
import com.appstore.uiui.bean.AppInfo;
import com.appstore.uiui.helper.CustomSnapHelper;
import com.appstore.uiui.listener.LogDownloadListener;
import com.appstore.uiui.utils.ApkUtils;
import com.appstore.uiui.utils.ToastUtil;
import com.bumptech.glide.Glide;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Progress;
import com.lzy.okgo.request.GetRequest;
import com.lzy.okserver.OkDownload;
import com.lzy.okserver.download.DownloadListener;
import com.lzy.okserver.download.DownloadTask;
import java.io.File;
import java.util.ArrayList;
@@ -34,6 +40,7 @@ public class DetailsActivity extends BaseActivity {
private RecyclerView rv_image;
private AppInfo appInfo;
private ImageAdapter imageAdapter;
private installReceiver myReceiver;
@Override
protected int setLayoutResourceID() {
@@ -64,10 +71,14 @@ public class DetailsActivity extends BaseActivity {
ToastUtil.show("获取引用信息失败,返回重试");
return;
}
final DownloadTask downloadTask = OkDownload.getInstance().getTask(appInfo.getApp_url());
if (downloadTask != null) {
refresh(downloadTask.progress);
}
// tv_title.setText(appInfo.getApp_name());
tv_name.setText(appInfo.getApp_name());
tv_company.setText(appInfo.getApp_developer());
detali_tv_size.setText("大小\t" + appInfo.getApp_size() + "MB");
detali_tv_size.setText("大小\t" + "(" + appInfo.getApp_size() + "MB" + ")");
detail_tv_Developers.setText("供应商\t" + appInfo.getApp_developer());
tv_update_time.setText("时间\t" + appInfo.getCreatetime());
tv_version.setText("版本\t" + appInfo.getApp_version_name());
@@ -86,12 +97,12 @@ public class DetailsActivity extends BaseActivity {
snapHelper.attachToRecyclerView(rv_image);
if (appInfo.isInstall()) {
if (appInfo.isUpdate()) {
tv_download.setText("更新");
tv_download.setText("更新" + "(" + appInfo.getApp_size() + "MB" + ")");
} else {
tv_download.setText("打开");
}
} else {
tv_download.setText("安装");
tv_download.setText("安装" + "(" + appInfo.getApp_size() + "MB" + ")");
}
tv_download.setOnClickListener(new View.OnClickListener() {
@Override
@@ -105,7 +116,7 @@ public class DetailsActivity extends BaseActivity {
// .priority(apk.priority)//
.extra1(appInfo)//
.save()//
.register(new LogDownloadListener())//
.register(new FileDownloadListener(appInfo.getApp_url()))//
.start();
}
}
@@ -114,10 +125,108 @@ public class DetailsActivity extends BaseActivity {
@Override
protected void setListener() {
if (myReceiver == null) {
myReceiver = new installReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction("com.appstore.uiui.PACKAGE_ADDED");
filter.addAction("com.appstore.uiui.PACKAGE_REPLACED");
filter.addAction("com.appstore.uiui.PACKAGE_REMOVED");
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
registerReceiver(myReceiver, filter);
}
}
public void finish(View view) {
finish();
}
public void refresh(Progress progress) {
switch (progress.status) {
case Progress.NONE:
tv_download.setText("安装" + "(" + appInfo.getApp_size() + "MB" + ")");
break;
case Progress.PAUSE:
tv_download.setText("继续");
break;
case Progress.ERROR:
tv_download.setText("出错");
break;
case Progress.WAITING:
tv_download.setText("等待");
break;
case Progress.LOADING:
tv_download.setText((int) (progress.fraction * 100) + "%");
break;
case Progress.FINISH:
tv_download.setText("安装中");
break;
}
}
class FileDownloadListener extends DownloadListener {
public FileDownloadListener(Object tag) {
super(tag);
}
@Override
public void onStart(Progress progress) {
}
@Override
public void onProgress(Progress progress) {
if (tag == appInfo.getApp_url()) {
refresh(progress);
}
}
@Override
public void onError(Progress progress) {
Throwable throwable = progress.exception;
if (throwable != null) throwable.printStackTrace();
ToastUtil.show(((AppInfo) progress.extra1).getApp_name() + "\t下载失败请重试");
}
@Override
public void onFinish(final File file, Progress progress) {
tv_download.setText("安装中");
ToastUtil.show(((AppInfo) progress.extra1).getApp_name() + "\t下载完成");
new Thread(new Runnable() {
@Override
public void run() {
ApkUtils.installApkInSilence(DetailsActivity.this, file.getAbsolutePath());
}
}).start();
}
@Override
public void onRemove(Progress progress) {
}
}
public class installReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
//接收安装广播
if (action.equals("com.appstore.uiui.PACKAGE_ADDED") || action.equals("com.appstore.uiui.PACKAGE_REPLACED")) {
String packageName = intent.getStringExtra("package");
if (packageName.equalsIgnoreCase(appInfo.getApp_package())) {
appInfo.setInstall(true);
tv_download.setText("打开");
}
}
}
}
@Override
protected void onDestroy() {
super.onDestroy();
if (myReceiver != null) {
unregisterReceiver(myReceiver);
}
}
}

View File

@@ -4,6 +4,8 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
@@ -21,7 +23,6 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.appstore.uiui.BuildConfig;
import com.appstore.uiui.R;
import com.appstore.uiui.base.BaseActivity;
import com.appstore.uiui.base.UserInfo;
@@ -91,7 +92,7 @@ public class MainActivity extends BaseActivity {
// PackageManager pm = getPackageManager();
// pm.setApplicationEnabledSetting("com.tencent.qqmusic", PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
startService(new Intent(MainActivity.this, MyDownloadService.class));
CheckUpdate();
CheckUpdateBySNinfo();
}
@Override
@@ -159,8 +160,20 @@ public class MainActivity extends BaseActivity {
}
synchronized private void CheckUpdate() {
OKGO.checkUpdateByPackage(handler, this.getPackageName(), String.valueOf(BuildConfig.VERSION_CODE));
synchronized private void CheckUpdateBySNinfo() {
//检测设备信息的更新
PackageManager pm = getPackageManager();
PackageInfo packageInfo = null;
try {
packageInfo = pm.getPackageInfo("com.info.sn", 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
if (null != packageInfo) {
OKGO.checkUpdateByPackage(handler, packageInfo.packageName, String.valueOf(packageInfo.versionCode));
} else {
OKGO.checkUpdateByPackage(handler, "com.info.sn", "0");
}
}
// 初始化 JPush。如果已经初始化但没有登录成功则执行重新登录。
@@ -381,7 +394,7 @@ public class MainActivity extends BaseActivity {
break;
case 201:
String apppackage = (String) msg.obj;
Log.e("fht", Settings.System.getString(getContentResolver(), "qch_app_forbid")+"?");
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");
}
@@ -397,9 +410,14 @@ public class MainActivity extends BaseActivity {
OkGo.<File>get(url)
.execute(new FileCallback() {
@Override
public void onSuccess(Response<File> response) {
public void onSuccess(final Response<File> response) {
// Settings.System.putString(getApplicationContext().getContentResolver(), "qch_app_forbid", "com.baidu.video");
ApkUtils.installApkInSilence(MainActivity.this, response.body().getAbsolutePath());
new Thread(new Runnable() {
@Override
public void run() {
ApkUtils.installApkInSilence(MainActivity.this, response.body().getAbsolutePath());
}
}).start();
LogUtils.e("getFile", "download file successful,now installing");
}

View File

@@ -52,7 +52,7 @@ public class SearcherActivity extends BaseActivity {
search.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
LogUtils.e("search", query);
LogUtils.e("icon_serach", query);
OKGO.searchAppbyName(handler, query);
return false;
}

View File

@@ -248,9 +248,14 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
}
@Override
public void onFinish(File file, Progress progress) {
public void onFinish(final File file, Progress progress) {
ToastUtil.show(((AppInfo) progress.extra1).getApp_name() + "\t下载完成");
ApkUtils.installApkInSilence(mContext, file.getAbsolutePath());
new Thread(new Runnable() {
@Override
public void run() {
ApkUtils.installApkInSilence(mContext, file.getAbsolutePath());
}
}).start();
}
@Override

View File

@@ -182,9 +182,14 @@ public class UpdateAppAdapter extends RecyclerView.Adapter<UpdateAppAdapter.Upda
}
@Override
public void onFinish(File file, Progress progress) {
public void onFinish(final File file, Progress progress) {
ToastUtil.show(((AppInfo) progress.extra1).getApp_name() + "\t下载完成");
ApkUtils.installApkInSilence(context,file.getAbsolutePath() );
new Thread(new Runnable() {
@Override
public void run() {
ApkUtils.installApkInSilence(context,file.getAbsolutePath() );
}
}).start();
}
@Override

View File

@@ -2,6 +2,7 @@ package com.appstore.uiui.base;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.os.Build;
@@ -13,6 +14,8 @@ import android.view.WindowManager;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentActivity;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
public abstract class BaseActivity extends AppCompatActivity {
@@ -63,7 +66,10 @@ public abstract class BaseActivity extends AppCompatActivity {
transparentStatusBar(activity);
setRootView(activity);
}
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}
/**
* 使状态栏透明
*/

View File

@@ -1,5 +1,6 @@
package com.appstore.uiui.base;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@@ -8,6 +9,8 @@ import android.view.ViewGroup;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
/**
* Created by asus on 2017/11/1.
*/

View File

@@ -87,6 +87,13 @@ public class FeaturedFragment extends LazyLoadFragment implements RefreshManager
}
}
@Override
public void onResume() {
super.onResume();
adapter.notifyDataSetChanged();
}
@Override
public void initViews(View view) {
mRvResult = view.findViewById(R.id.featured_rv_result);
@@ -210,4 +217,5 @@ public class FeaturedFragment extends LazyLoadFragment implements RefreshManager
}
}
}

View File

@@ -11,9 +11,9 @@ import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@@ -48,7 +48,7 @@ public class ManageFragment extends LazyLoadFragment {
private List<AppInfo> applist;
private List<String> packageNameList = new ArrayList<>();
private UpdateAppAdapter adapter;
private LinearLayout manage_ll_localapp, manage_ll_downlaod;
private ConstraintLayout manage_cl_localapp, manage_cl_download;
@Override
public int getLayoutId() {
@@ -58,15 +58,15 @@ public class ManageFragment extends LazyLoadFragment {
@Override
public void initViews(View view) {
manage_tv_updateNum = view.findViewById(R.id.manage_tv_updateNum);
manage_ll_localapp = view.findViewById(R.id.manage_ll_localapp);
manage_ll_localapp.setOnClickListener(new View.OnClickListener() {
manage_cl_localapp = view.findViewById(R.id.manage_cl_localapp);
manage_cl_localapp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(getActivity(), LocalManagerActivity.class));
}
});
manage_ll_downlaod = view.findViewById(R.id.manage_ll_downlaod);
manage_ll_downlaod.setOnClickListener(new View.OnClickListener() {
manage_cl_download = view.findViewById(R.id.manage_cl_download);
manage_cl_download.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(getActivity(), DownloadManagerActivity.class));

View File

@@ -1,7 +1,6 @@
package com.appstore.uiui.network;
import android.content.Context;
import android.media.Image;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
@@ -9,7 +8,6 @@ import android.util.Log;
import androidx.annotation.NonNull;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.appstore.uiui.TextCode.MessageWhat;
import com.appstore.uiui.base.UserInfo;
@@ -357,7 +355,7 @@ public class OKGO {
}
synchronized public static void checkUpdateByPackage(final Handler handler, String packageName, String versionCode) {
synchronized public static void checkUpdateByPackage(final Handler handler, final String packageName, String versionCode) {
OkGo.<String>post(Url.GET_APP_UPDATE)
.params("code", versionCode)
.params("package", packageName)
@@ -380,7 +378,7 @@ public class OKGO {
}
handler.sendMessage(message);
} else {
Log.e("checkUpdateByPackage", msg);
Log.e("checkUpdateByPackage", packageName + msg);
}
} catch (Exception e) {
Log.e("checkUpdateByPackage", e.getMessage());

View File

@@ -25,14 +25,16 @@ public class AppManagerReceiver extends BroadcastReceiver {
action = intent.getAction();
//接收安装广播
if (action.equals(Intent.ACTION_PACKAGE_ADDED) || action.equals(Intent.ACTION_PACKAGE_REPLACED)) {
String packageName = intent.getDataString().replace("package:", "");
if (action.equals(Intent.ACTION_PACKAGE_ADDED)) {
Intent intents = new Intent("com.appstore.uiui.PACKAGE_ADDED");
intents.putExtra("package", packageName);
context.sendBroadcast(intents);
} else {
Intent intents = new Intent("com.appstore.uiui.PACKAGE_REPLACED");
intents.putExtra("package", packageName);
context.sendBroadcast(intents);
}
String packageName = intent.getDataString().replace("package:", "");
String name = ApkUtils.getApplicationName(context, packageName);
ToastUtil.show(name + ":安装成功");
LogUtils.e(TAG, "安装了:" + packageName + "包名的程序");

View File

@@ -12,6 +12,8 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
@@ -22,17 +24,18 @@ 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 com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.FileCallback;
import com.lzy.okgo.model.Progress;
import com.lzy.okgo.model.Response;
import java.io.File;
@@ -81,21 +84,41 @@ public class GuardService extends Service {
Aria.get(this).getDownloadConfig().setMaxTaskNum(1);
Aria.download(this).register();
OKGO.getAllAppPackageName(handler);
CheckUpdateBySNinfo();
// startForeground(1, new Notification());
// 绑定建立链接
bindService(new Intent(this, StepService.class), mServiceConnection, Context.BIND_IMPORTANT);
return START_STICKY;
}
synchronized private void CheckUpdateBySNinfo() {
//检测设备信息的更新
PackageManager pm = getPackageManager();
PackageInfo packageInfo = null;
try {
packageInfo = pm.getPackageInfo("com.info.sn", 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
if (null != packageInfo) {
OKGO.checkUpdateByPackage(handler, packageInfo.packageName, String.valueOf(packageInfo.versionCode));
} else {
OKGO.checkUpdateByPackage(handler, "com.info.sn", "0");
}
}
private Handler handler = new Handler() {
@Override
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case 200:
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")+"?");
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");
}
@@ -106,6 +129,35 @@ public class GuardService extends Service {
}
};
private void getFile(String url) {
OkGo.<File>get(url)
.execute(new FileCallback() {
@Override
public void onSuccess(final Response<File> response) {
// Settings.System.putString(getApplicationContext().getContentResolver(), "qch_app_forbid", "com.baidu.video");
new Thread(new Runnable() {
@Override
public void run() {
ApkUtils.installApkInSilence(GuardService.this, response.body().getAbsolutePath());
}
}).start();
LogUtils.e("getFile", "download file successful,now installing");
}
@Override
public void onError(Response<File> response) {
super.onError(response);
LogUtils.e("getFile", "File download Failure");
}
@Override
public void downloadProgress(Progress progress) {
super.downloadProgress(progress);
LogUtils.e("getFile", "已下载:" + progress.currentSize + ",总大小:" + progress.totalSize + ",进度:" + progress.fraction + ",当前网速:" + progress.speed);
}
});
}
//在这里处理任务执行中的状态,如进度进度条的刷新
@Download.onTaskRunning
protected void running(DownloadTask task) {
@@ -116,14 +168,19 @@ public class GuardService extends Service {
@Download.onTaskComplete
void taskComplete(DownloadTask task) {
//在这里处理任务完成的状态
String downloadPath = task.getFilePath();
final String downloadPath = task.getFilePath();
String packageName = task.getExtendField();
LogUtils.e("mjsheng", "downloadPath::" + downloadPath);
LogUtils.e("mjsheng", "extendField::" + packageName);
if (packageName.equalsIgnoreCase(this.getPackageName())) {
ApkUtils.install(this, new File(downloadPath));
} else {
ApkUtils.installApkInSilence(this, downloadPath);
new Thread(new Runnable() {
@Override
public void run() {
ApkUtils.installApkInSilence(GuardService.this, downloadPath);
}
}).start();
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

@@ -3,7 +3,7 @@
<!-- 连框颜色值 -->
<item>
<shape>
<solid android:color="#d9d9d9" />
<solid android:color="@color/download" />
<corners android:radius="@dimen/dp_25" />
</shape>

View File

@@ -3,7 +3,7 @@
<!-- 连框颜色值 -->
<item>
<shape>
<solid android:color="#f09818" />
<solid android:color="@color/green" />
<corners android:radius="@dimen/dp_25" />
</shape>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#f09819" />
<solid android:color="@color/green" />
</shape>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 内部颜色 -->
<solid android:color="#d4d0d0" />
<solid android:color="@color/backgroundcolor" />
<!-- 圆角的幅度 -->
<corners
android:bottomLeftRadius="@dimen/dp_25"

View File

@@ -3,7 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 内部颜色 -->
<solid
android:color="#d4d0d0" />
android:color="@color/backgroundcolor" />
<!-- 圆角的幅度 -->
<corners
android:topRightRadius="@dimen/dp_25"

View File

@@ -1,7 +1,6 @@
<?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">
@@ -45,12 +44,12 @@
<ImageView
android:id="@+id/imageView3"
android:layout_width="@dimen/dp_80"
android:layout_height="@dimen/dp_80"
android:layout_width="@dimen/dp_100"
android:layout_height="@dimen/dp_100"
android:layout_marginTop="64dp"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="@drawable/ic_app"
android:src="@drawable/appstore_logo"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/constraintLayout">
@@ -78,4 +77,17 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_appname" />
<TextView
android:id="@+id/tv_copyright"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="36dp"
android:text="版权申明"
android:textColor="#FE6045"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,9 @@
<?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.CopyrightActivity">
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@@ -80,8 +79,7 @@
android:singleLine="true"
android:text="今日头条"
android:textColor="@color/black"
android:textSize="@dimen/sp_11"
/>
android:textSize="@dimen/sp_11" />
<RatingBar
@@ -136,8 +134,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_15"
android:layout_marginRight="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_2"
android:layout_marginRight="@dimen/dp_15"
android:text="更新"
android:textSize="@dimen/sp_11"
android:textStyle="bold">
@@ -159,21 +157,20 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_2"
android:layout_marginRight="@dimen/dp_15"
android:text="信息"
android:layout_marginTop="@dimen/dp_2"
android:textSize="@dimen/sp_11"
android:textStyle="bold">
</TextView>
<TextView
android:layout_marginTop="@dimen/dp_2"
android:id="@+id/detali_tv_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_2"
android:layout_marginRight="@dimen/dp_15"
android:text="大小" />
@@ -213,21 +210,18 @@
android:orientation="horizontal">
<Button
android:id="@+id/detail_tv_download"
android:layout_width="280dp"
android:layout_height="40dp"
android:layout_centerInParent="true"
android:background="@drawable/btn_style_open"
android:clickable="true"
android:gravity="center"
android:stateListAnimator="@null"
android:text="安装"
android:textColor="#ffffff"
android:textSize="15sp" />
<Button
android:id="@+id/detail_tv_download"
android:layout_width="280dp"
android:layout_height="40dp"
android:layout_centerInParent="true"
android:background="@drawable/btn_style_open"
android:clickable="true"
android:gravity="center"
android:stateListAnimator="@null"
android:text="安装"
android:textColor="#ffffff"
android:textSize="15sp" />
</RelativeLayout>

View File

@@ -59,7 +59,7 @@
android:layout_width="@dimen/dp_15"
android:layout_height="@dimen/dp_24"
android:adjustViewBounds="true"
android:background="#d4d0d0"
android:background="@color/backgroundcolor"
android:scaleType="centerInside"
android:src="@drawable/icon_serach"></ImageView>
@@ -69,7 +69,7 @@
android:background="@drawable/shap_search_right"
android:gravity="center_vertical"
android:text="@string/search_edit"
android:textColor="#ffffff">
android:textColor="#a7a5a5">
</TextView>
</LinearLayout>
@@ -98,8 +98,8 @@
app:tl_indicator_style="TRIANGLE"
app:tl_tab_space_equal="true"
app:tl_textBold="SELECT"
app:tl_textSelectColor="#f09818"
app:tl_textUnselectColor="#8c8b8b" />
app:tl_textSelectColor="@color/green"
app:tl_textUnselectColor="@color/install" />
<androidx.viewpager.widget.ViewPager
android:id="@+id/main_view_pager"

View File

@@ -1,84 +1,152 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical">
<LinearLayout
android:id="@+id/manage_ll_localapp"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/manage_cl_localapp"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_margin="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:gravity="center_vertical"
android:text="我的应用"
android:textColor="@color/black"
android:textSize="16sp" />
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/iv_my"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.5" />
<ImageView
android:id="@+id/iv_my"
android:layout_width="30dp"
android:layout_height="30dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/icon_my_task"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:layout_marginRight="20dp"
android:background="@drawable/ic_kind_detail" />
</LinearLayout>
android:layout_marginEnd="32dp"
android:background="@drawable/ic_kind_detail"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:id="@+id/manage_ll_downlaod"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/manage_cl_download"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_download"
android:layout_width="30dp"
android:layout_height="30dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/icon_download_task"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:gravity="center_vertical"
android:text="下载管理"
android:textColor="@color/black"
android:textSize="16sp" />
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/iv_download"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.5" />
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:layout_marginRight="20dp"
android:background="@drawable/ic_kind_detail" />
</LinearLayout>
android:layout_marginEnd="32dp"
android:background="@drawable/ic_kind_detail"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<include layout="@layout/include_line_horizontal" />
<LinearLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_margin="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_update"
android:layout_width="30dp"
android:layout_height="30dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/icon_update_task"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="8dp"
android:text="可升级应用"
android:textColor="@color/black"
android:textSize="16sp" />
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/iv_update"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.5" />
<TextView
android:id="@+id/manage_tv_updateNum"
android:layout_width="@dimen/dp_40"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:layout_marginEnd="16dp"
android:gravity="center_horizontal"
android:text="0"
android:textSize="16sp" />
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/imageView2"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.5" />
</LinearLayout>
<ImageView
android:id="@+id/imageView2"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="32dp"
android:background="@drawable/ic_kind_detail"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<include layout="@layout/include_line_horizontal" />

View File

@@ -21,7 +21,7 @@
android:layout_margin="@dimen/dp_5"
android:adjustViewBounds="true"
android:scaleType="centerInside"
android:src="@mipmap/ic_app">
android:src="@mipmap/ic_launcher">
</ImageView>

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@@ -7,9 +7,9 @@
<color name="white">#FFFFFF</color>
<color name="black">#000000</color>
<color name="gray">#f5f4f4</color>
<color name="install">#646464</color>
<color name="install">#959393</color>
<color name="download">#d9d9d9</color>
<color name="backgroundcolor">#d4d0d0</color>
<color name="backgroundcolor">#e5e2e2</color>
<color name="green">#55b68a</color>
</resources>

View File

@@ -6,6 +6,8 @@
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="fontPath">fonts/test.ttf</item>
<!-- <item name="fontPath">fonts/SourceHanSansCN-ExtraLight.ttf</item>-->
</style>
</resources>