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);

View File

@ -69,8 +69,8 @@
<string name="reboot_msg">هل تريد إعادة التشغيل الآن؟</string>
<string name="reboot">إعادة التشغيل</string>
<string name="zip_install_progress_title">تثبيت</string>
<string name="zip_install_unzip_zip_msg">فك الضغط عن الملف المضغوط …</string>
<string name="zip_install_process_zip_msg">معالجة الملف المضغوط …</string>
<string name="zip_unzip_msg">فك الضغط عن الملف المضغوط …</string>
<string name="zip_process_msg">معالجة الملف المضغوط …</string>
<string name="zip_install_progress_msg">"تثبيت %1$s …"</string>
<string name="no_magisk_title">لا يوجد Magisk مثبت!</string>
<string name="no_magisk_msg">هل ترغب في تنزيل وتثبيت Magisk؟</string>

View File

@ -102,8 +102,8 @@
<string name="reboot">Neustart</string>
<string name="copying_msg">Kopiere Zip ins temp-Verzeichnis</string>
<string name="zip_install_progress_title">Installiere</string>
<string name="zip_install_unzip_zip_msg">Entpacke Zip-Datei…</string>
<string name="zip_install_process_zip_msg">Verarbeite Zip-Datei…</string>
<string name="zip_unzip_msg">Entpacke Zip-Datei…</string>
<string name="zip_process_msg">Verarbeite Zip-Datei…</string>
<string name="zip_install_progress_msg">"Installiere %1$s…"</string>
<string name="no_magisk_title">Magisk ist nicht installiert!</string>
<string name="no_magisk_msg">Möchtest du Magisk herunterladen und installieren?</string>

View File

@ -100,8 +100,8 @@
<string name="reboot">다시 시작</string>
<string name="copying_msg">임시 디렉터리에 zip 파일 복사 중</string>
<string name="zip_install_progress_title">설치 중</string>
<string name="zip_install_unzip_zip_msg">zip 파일 압축 해제 중…</string>
<string name="zip_install_process_zip_msg">zip 파일 처리 중…</string>
<string name="zip_unzip_msg">zip 파일 압축 해제 중…</string>
<string name="zip_process_msg">zip 파일 처리 중…</string>
<string name="zip_install_progress_msg">"%1$s 설치 중…"</string>
<string name="no_magisk_title">Magisk가 설치되어 있지 않습니다!</string>
<string name="no_magisk_msg">Magisk를 다운로드하고 설치하시겠습니까?</string>

View File

@ -103,8 +103,8 @@
<string name="reboot">Restart</string>
<string name="copying_msg">Kopiowanie zip do katalogu temp</string>
<string name="zip_install_progress_title">Instalacja</string>
<string name="zip_install_unzip_zip_msg">Rozpakowywanie pliku zip …</string>
<string name="zip_install_process_zip_msg">Przetwarzanie pliku zip …</string>
<string name="zip_unzip_msg">Rozpakowywanie pliku zip …</string>
<string name="zip_process_msg">Przetwarzanie pliku zip …</string>
<string name="zip_install_progress_msg">"Instalowanie %1$s …"</string>
<string name="no_magisk_title">Brak zainstalowanego Magisk!</string>
<string name="no_magisk_msg">Chcesz pobrać i zainstalować Magisk?</string>

View File

@ -98,8 +98,8 @@
<string name="reboot">Reiniciar</string>
<string name="copying_msg">Copiando zip para diretório temporário</string>
<string name="zip_install_progress_title">Instalando</string>
<string name="zip_install_unzip_zip_msg">Descompactando arquivo zip …</string>
<string name="zip_install_process_zip_msg">Processando arquivo zip …</string>
<string name="zip_unzip_msg">Descompactando arquivo zip …</string>
<string name="zip_process_msg">Processando arquivo zip …</string>
<string name="zip_install_progress_msg">"Instalando %1$s …"</string>
<string name="no_magisk_title">Magisk Não Instalado!</string>
<string name="no_magisk_msg">Você quer baixar e instalar o Magisk?</string>

View File

@ -97,8 +97,8 @@
<string name="reboot">Перезагрузка</string>
<string name="copying_msg">Копирование архива во временную директорию</string>
<string name="zip_install_progress_title">Установка</string>
<string name="zip_install_unzip_zip_msg">Распаковка zip-файла…</string>
<string name="zip_install_process_zip_msg">Обработка zip-файла…</string>
<string name="zip_unzip_msg">Распаковка zip-файла…</string>
<string name="zip_process_msg">Обработка zip-файла…</string>
<string name="zip_install_progress_msg">"Установка %1$s…"</string>
<string name="no_magisk_title">Magisk не установлен!</string>
<string name="no_magisk_msg">Вы хотите скачать и установить Magisk?</string>

View File

@ -98,8 +98,8 @@
<string name="reboot">重启</string>
<string name="copying_msg">正在复制 zip 到临时目录</string>
<string name="zip_install_progress_title">正在安装</string>
<string name="zip_install_unzip_zip_msg">正在解压 zip 文件 …</string>
<string name="zip_install_process_zip_msg">正在处理 zip 文件 …</string>
<string name="zip_unzip_msg">正在解压 zip 文件 …</string>
<string name="zip_process_msg">正在处理 zip 文件 …</string>
<string name="zip_install_progress_msg">"正在安装 %1$s …"</string>
<string name="no_magisk_title">未安装 Magisk</string>
<string name="no_magisk_msg">你想要下载并安装 Magisk 吗?</string>

View File

@ -98,8 +98,8 @@
<string name="reboot">重啟</string>
<string name="copying_msg">正在復制 zip 到暫存目錄</string>
<string name="zip_install_progress_title">正在安裝</string>
<string name="zip_install_unzip_zip_msg">正在解壓 zip 文件 …</string>
<string name="zip_install_process_zip_msg">正在處理 zip 文件 …</string>
<string name="zip_unzip_msg">正在解壓 zip 文件 …</string>
<string name="zip_process_msg">正在處理 zip 文件 …</string>
<string name="zip_install_progress_msg">"正在安裝 %1$s …"</string>
<string name="no_magisk_title">未安裝 Magisk</string>
<string name="no_magisk_msg">你想要下載並安裝 Magisk 嗎?</string>
@ -186,5 +186,7 @@
<string name="internal_storage">Zip 已被儲存到:[內部儲存空間]%1$1</string>
<string name="ok"></string>
<string name="process_error">處裡失敗</string>
<string name="download">下載</string>
<string name="zip_process_title">處理中</string>
</resources>

View File

@ -94,6 +94,7 @@
<string name="repo_install_title">Install %1$s</string>
<string name="repo_install_msg">Do you want to install %1$s ?</string>
<string name="download_install">Download &amp; install</string>
<string name="download">Download</string>
<string name="goto_install">Go to \"Install\" section</string>
<string name="download_file_error">Error downloading file</string>
<string name="install_error">Installation error!</string>
@ -103,8 +104,8 @@
<string name="reboot">Reboot</string>
<string name="copying_msg">Copying zip to temp directory</string>
<string name="zip_install_progress_title">Installing</string>
<string name="zip_install_unzip_zip_msg">Unzipping zip file …</string>
<string name="zip_install_process_zip_msg">Processing zip file …</string>
<string name="zip_unzip_msg">Unzipping zip file …</string>
<string name="zip_process_msg">Processing zip file …</string>
<string name="zip_install_progress_msg">"Installing %1$s …"</string>
<string name="no_magisk_title">No Magisk Installed!</string>
<string name="no_magisk_msg">Do you want to download and install Magisk?</string>
@ -121,6 +122,7 @@
<string name="understand">I understand</string>
<string name="process_error">Process error</string>
<string name="internal_storage">The zip is stored in:\n[Internal Storage]%1$s</string>
<string name="zip_process_title">Processing</string>
<!--Settings Activity -->
<string name="settings_general_category">General</string>