diff --git a/app/src/main/java/com/topjohnwu/magisk/InstallFragment.java b/app/src/main/java/com/topjohnwu/magisk/InstallFragment.java index 909b1ba6c..5d5a86d70 100644 --- a/app/src/main/java/com/topjohnwu/magisk/InstallFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/InstallFragment.java @@ -14,6 +14,8 @@ import android.widget.Spinner; import android.widget.TextView; import com.topjohnwu.magisk.receivers.MagiskDlReceiver; +import com.topjohnwu.magisk.receivers.RepoDlReceiver; +import com.topjohnwu.magisk.utils.Async; import com.topjohnwu.magisk.utils.CallbackHandler; import com.topjohnwu.magisk.utils.Utils; @@ -49,11 +51,19 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi if (bootImage == null) { bootImage = blockList.get(spinner.getSelectedItemPosition() - 1); } - Utils.dlAndReceive( - getActivity(), - new MagiskDlReceiver(bootImage, keepEncChkbox.isChecked(), keepVerityChkbox.isChecked()), - StatusFragment.magiskLink, - "Magisk-v" + String.valueOf(StatusFragment.remoteMagiskVersion) + ".zip"); + String filename = "Magisk-v" + String.valueOf(StatusFragment.remoteMagiskVersion) + ".zip"; + String finalBootImage = bootImage; + MainActivity.alertBuilder + .setTitle(getString(R.string.repo_install_title, getString(R.string.magisk))) + .setMessage(getString(R.string.repo_install_msg, filename)) + .setCancelable(true) + .setPositiveButton(R.string.download_install, (dialogInterface, i) -> Utils.dlAndReceive( + getActivity(), + new MagiskDlReceiver(finalBootImage, keepEncChkbox.isChecked(), keepVerityChkbox.isChecked()), + StatusFragment.magiskLink, + Utils.getLegalFilename(filename))) + .setNegativeButton(R.string.no_thanks, null) + .show(); }); if (blockDetectionDone.isTriggered) { updateUI(); diff --git a/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java b/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java index c81cca231..68e366db4 100644 --- a/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java @@ -94,12 +94,12 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis updateSafetyNetUI(); } - if (magiskVersion < 0) { + if (magiskVersion < 0 && Shell.rootAccess()) { MainActivity.alertBuilder .setTitle(R.string.no_magisk_title) .setMessage(R.string.no_magisk_msg) .setCancelable(true) - .setPositiveButton(R.string.download_install, (dialogInterface, i) -> { + .setPositiveButton(R.string.goto_install, (dialogInterface, i) -> { ((MainActivity) getActivity()).navigationView.setCheckedItem(R.id.install); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); 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 17866cc1a..52c542e24 100644 --- a/app/src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java +++ b/app/src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java @@ -6,8 +6,6 @@ import android.animation.ValueAnimator; import android.content.Context; import android.content.Intent; import android.net.Uri; -import android.preference.PreferenceManager; -import android.support.v7.app.AlertDialog; import android.support.v7.widget.RecyclerView; import android.util.DisplayMetrics; import android.view.LayoutInflater; @@ -19,6 +17,7 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; +import com.topjohnwu.magisk.MainActivity; import com.topjohnwu.magisk.R; import com.topjohnwu.magisk.module.Repo; import com.topjohnwu.magisk.receivers.RepoDlReceiver; @@ -34,8 +33,7 @@ public class ReposAdapter extends RecyclerView.Adapter private List mUpdateRepos, mInstalledRepos, mOthersRepos; private View mView; - private Context context; - private AlertDialog.Builder builder; + private Context mContext; public ReposAdapter(List update, List installed, List others) { mUpdateRepos = update; @@ -47,14 +45,7 @@ public class ReposAdapter extends RecyclerView.Adapter public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { mView = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_repo, parent, false); ButterKnife.bind(this, mView); - context = parent.getContext(); - - String theme = PreferenceManager.getDefaultSharedPreferences(context).getString("theme", ""); - if (theme.equals("Dark")) { - builder = new AlertDialog.Builder(context, R.style.AlertDialog_dh); - } else { - builder = new AlertDialog.Builder(context); - } + mContext = parent.getContext(); return new ViewHolder(mView); } @@ -81,7 +72,7 @@ public class ReposAdapter extends RecyclerView.Adapter holder.versionName.setText(versionName); } if (author != null) { - holder.author.setText(context.getString(R.string.author, author)); + holder.author.setText(mContext.getString(R.string.author, author)); } if (description != null) { holder.description.setText(description); @@ -90,12 +81,12 @@ public class ReposAdapter extends RecyclerView.Adapter View.OnClickListener listener = view -> { if (view.getId() == holder.updateImage.getId()) { String filename = repo.getName() + "-" + repo.getVersion() + ".zip"; - builder - .setTitle(context.getString(R.string.repo_install_title, repo.getName())) - .setMessage(context.getString(R.string.repo_install_msg, filename)) + MainActivity.alertBuilder + .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( - context, + mContext, new RepoDlReceiver(), repo.getZipUrl(), Utils.getLegalFilename(filename))) @@ -103,13 +94,13 @@ public class ReposAdapter extends RecyclerView.Adapter .show(); } if ((view.getId() == holder.changeLog.getId()) && (!repo.getLogUrl().equals(""))) { - new WebWindow(context.getString(R.string.changelog), repo.getLogUrl(), context); + new WebWindow(mContext.getString(R.string.changelog), repo.getLogUrl(), mContext); } if ((view.getId() == holder.authorLink.getId()) && (!repo.getSupportUrl().equals(""))) { - context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(repo.getDonateUrl()))); + mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(repo.getDonateUrl()))); } if ((view.getId() == holder.supportLink.getId()) && (!repo.getSupportUrl().equals(""))) { - context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(repo.getSupportUrl()))); + mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(repo.getSupportUrl()))); } }; @@ -145,7 +136,7 @@ public class ReposAdapter extends RecyclerView.Adapter public ViewHolder(View itemView) { super(itemView); - WindowManager windowmanager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); + WindowManager windowmanager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); ButterKnife.bind(this, itemView); DisplayMetrics dimension = new DisplayMetrics(); windowmanager.getDefaultDisplay().getMetrics(dimension); diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index a13c790f2..515592bc0 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -14,7 +14,7 @@ المثبت Magisk v%1$s هل قمت بتثبيت Magisk؟ - Magisk v%1$s تحديث! + Magisk v%1$.1f تحديث! لا يمكن التحقق من التحديثات أحدث إصدار من %1$s مثبت diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index c01634c1e..eb26637ea 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -14,7 +14,7 @@ 已安装 Magisk v%1$s 你是否已安装 Magisk? - Magisk 可更新到 v%1$s! + Magisk 可更新到 v%1$.1f! 无法检查更新 已安装最新版本的 %1$s diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bc8ed0a65..5dad42772 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -85,7 +85,8 @@ No thanks Install %1$s Do you want to install %1$s ? - Go to \"Install\" section + Download and install + Go to \"Install\" section Error downloading file Installation error! Zip file placed in %1$s