Add download button to repo, close #99

This commit is contained in:
topjohnwu
2017-02-16 17:50:36 +08:00
parent 8c5acd1a0a
commit b58c7ba7c5
12 changed files with 42 additions and 26 deletions

View File

@ -60,12 +60,22 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
.setTitle(mContext.getString(R.string.repo_install_title, repo.getName()))
.setMessage(mContext.getString(R.string.repo_install_msg, filename))
.setCancelable(true)
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> Utils.dlAndReceive(
.setPositiveButton(R.string.download_install, (d, i) -> Utils.dlAndReceive(
mContext,
new DownloadReceiver() {
@Override
public void onDownloadDone(Uri uri) {
new ProcessRepoZip(activity, uri).exec();
new ProcessRepoZip(activity, uri, true).exec();
}
},
repo.getZipUrl(),
Utils.getLegalFilename(filename)))
.setNeutralButton(R.string.download, (d, i) -> Utils.dlAndReceive(
mContext,
new DownloadReceiver() {
@Override
public void onDownloadDone(Uri uri) {
new ProcessRepoZip(activity, uri, false).exec();
}
},
repo.getZipUrl(),

View File

@ -31,8 +31,8 @@ public class ProcessMagiskZip extends ParallelTask<Void, Void, Boolean> {
@Override
protected void onPreExecute() {
progressDialog = ProgressDialog.show(activity,
activity.getString(R.string.zip_install_progress_title),
activity.getString(R.string.zip_install_unzip_zip_msg));
activity.getString(R.string.zip_process_title),
activity.getString(R.string.zip_unzip_msg));
}
@Override

View File

@ -21,17 +21,19 @@ public class ProcessRepoZip extends ParallelTask<Void, Void, Boolean> {
private Uri mUri;
private ProgressDialog progressDialog;
private boolean mInstall;
public ProcessRepoZip(Activity context, Uri uri) {
public ProcessRepoZip(Activity context, Uri uri, boolean install) {
super(context);
mUri = uri;
mInstall = install;
}
@Override
protected void onPreExecute() {
progressDialog = ProgressDialog.show(activity,
activity.getString(R.string.zip_install_progress_title),
activity.getString(R.string.zip_install_process_zip_msg));
activity.getString(R.string.zip_process_title),
activity.getString(R.string.zip_process_msg));
}
@Override
@ -101,7 +103,7 @@ public class ProcessRepoZip extends ParallelTask<Void, Void, Boolean> {
protected void onPostExecute(Boolean result) {
progressDialog.dismiss();
if (result) {
if (Shell.rootAccess())
if (Shell.rootAccess() && mInstall)
new FlashZip(activity, mUri).exec();
else
Utils.showUriSnack(activity, mUri);