From b58c7ba7c50c4e2a05725f9724280c553c956669 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 16 Feb 2017 17:50:36 +0800 Subject: [PATCH] Add download button to repo, close #99 --- .../topjohnwu/magisk/adapters/ReposAdapter.java | 14 ++++++++++++-- .../topjohnwu/magisk/asyncs/ProcessMagiskZip.java | 4 ++-- .../topjohnwu/magisk/asyncs/ProcessRepoZip.java | 10 ++++++---- app/src/main/res/values-ar/strings.xml | 4 ++-- app/src/main/res/values-de/strings.xml | 4 ++-- app/src/main/res/values-ko/strings.xml | 4 ++-- app/src/main/res/values-pl/strings.xml | 4 ++-- app/src/main/res/values-pt/strings.xml | 4 ++-- app/src/main/res/values-ru/strings.xml | 4 ++-- app/src/main/res/values-zh-rCN/strings.xml | 4 ++-- app/src/main/res/values-zh-rTW/strings.xml | 6 ++++-- app/src/main/res/values/strings.xml | 6 ++++-- 12 files changed, 42 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java b/app/src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java index e90134ac6..b35bfc74c 100644 --- a/app/src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java +++ b/app/src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java @@ -60,12 +60,22 @@ public class ReposAdapter extends RecyclerView.Adapter .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(), diff --git a/app/src/main/java/com/topjohnwu/magisk/asyncs/ProcessMagiskZip.java b/app/src/main/java/com/topjohnwu/magisk/asyncs/ProcessMagiskZip.java index ea623d566..abca9c78c 100644 --- a/app/src/main/java/com/topjohnwu/magisk/asyncs/ProcessMagiskZip.java +++ b/app/src/main/java/com/topjohnwu/magisk/asyncs/ProcessMagiskZip.java @@ -31,8 +31,8 @@ public class ProcessMagiskZip extends ParallelTask { @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 diff --git a/app/src/main/java/com/topjohnwu/magisk/asyncs/ProcessRepoZip.java b/app/src/main/java/com/topjohnwu/magisk/asyncs/ProcessRepoZip.java index a4eb642b5..16e134fe4 100644 --- a/app/src/main/java/com/topjohnwu/magisk/asyncs/ProcessRepoZip.java +++ b/app/src/main/java/com/topjohnwu/magisk/asyncs/ProcessRepoZip.java @@ -21,17 +21,19 @@ public class ProcessRepoZip extends ParallelTask { 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 { 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); diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 9b53b635d..c3f191874 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -69,8 +69,8 @@ هل تريد إعادة التشغيل الآن؟ إعادة التشغيل تثبيت - فك الضغط عن الملف المضغوط … - معالجة الملف المضغوط … + فك الضغط عن الملف المضغوط … + معالجة الملف المضغوط … "تثبيت %1$s …" لا يوجد Magisk مثبت! هل ترغب في تنزيل وتثبيت Magisk؟ diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 1734916f9..2081b7f4d 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -102,8 +102,8 @@ Neustart Kopiere Zip ins temp-Verzeichnis Installiere - Entpacke Zip-Datei… - Verarbeite Zip-Datei… + Entpacke Zip-Datei… + Verarbeite Zip-Datei… "Installiere %1$s…" Magisk ist nicht installiert! Möchtest du Magisk herunterladen und installieren? diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 542316497..00325b330 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -100,8 +100,8 @@ 다시 시작 임시 디렉터리에 zip 파일 복사 중 설치 중 - zip 파일 압축 해제 중… - zip 파일 처리 중… + zip 파일 압축 해제 중… + zip 파일 처리 중… "%1$s 설치 중…" Magisk가 설치되어 있지 않습니다! Magisk를 다운로드하고 설치하시겠습니까? diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 44319b9ba..e089c2cc5 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -103,8 +103,8 @@ Restart Kopiowanie zip do katalogu temp Instalacja - Rozpakowywanie pliku zip … - Przetwarzanie pliku zip … + Rozpakowywanie pliku zip … + Przetwarzanie pliku zip … "Instalowanie %1$s …" Brak zainstalowanego Magisk! Chcesz pobrać i zainstalować Magisk? diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 4c1b31ad9..3acfd5df9 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -98,8 +98,8 @@ Reiniciar Copiando zip para diretório temporário Instalando - Descompactando arquivo zip … - Processando arquivo zip … + Descompactando arquivo zip … + Processando arquivo zip … "Instalando %1$s …" Magisk Não Instalado! Você quer baixar e instalar o Magisk? diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index bb9cb8ac0..35d200b08 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -97,8 +97,8 @@ Перезагрузка Копирование архива во временную директорию Установка - Распаковка zip-файла… - Обработка zip-файла… + Распаковка zip-файла… + Обработка zip-файла… "Установка %1$s…" Magisk не установлен! Вы хотите скачать и установить Magisk? diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 6b9baf7cd..e96973c67 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -98,8 +98,8 @@ 重启 正在复制 zip 到临时目录 正在安装 - 正在解压 zip 文件 … - 正在处理 zip 文件 … + 正在解压 zip 文件 … + 正在处理 zip 文件 … "正在安装 %1$s …" 未安装 Magisk! 你想要下载并安装 Magisk 吗? diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 13569d1fb..020983fa9 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -98,8 +98,8 @@ 重啟 正在復制 zip 到暫存目錄 正在安裝 - 正在解壓 zip 文件 … - 正在處理 zip 文件 … + 正在解壓 zip 文件 … + 正在處理 zip 文件 … "正在安裝 %1$s …" 未安裝 Magisk! 你想要下載並安裝 Magisk 嗎? @@ -186,5 +186,7 @@ Zip 已被儲存到:[內部儲存空間]%1$1 處裡失敗 + 下載 + 處理中 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index faaccd30a..2a4bb0ac5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -94,6 +94,7 @@ Install %1$s Do you want to install %1$s ? Download & install + Download Go to \"Install\" section Error downloading file Installation error! @@ -103,8 +104,8 @@ Reboot Copying zip to temp directory Installing - Unzipping zip file … - Processing zip file … + Unzipping zip file … + Processing zip file … "Installing %1$s …" No Magisk Installed! Do you want to download and install Magisk? @@ -121,6 +122,7 @@ I understand Process error The zip is stored in:\n[Internal Storage]%1$s + Processing General