mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-26 08:17:39 +00:00
Dialog fix and trivial stuffs
This commit is contained in:
parent
c7e64f40f9
commit
b064c124e7
@ -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(
|
||||
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(bootImage, keepEncChkbox.isChecked(), keepVerityChkbox.isChecked()),
|
||||
new MagiskDlReceiver(finalBootImage, keepEncChkbox.isChecked(), keepVerityChkbox.isChecked()),
|
||||
StatusFragment.magiskLink,
|
||||
"Magisk-v" + String.valueOf(StatusFragment.remoteMagiskVersion) + ".zip");
|
||||
Utils.getLegalFilename(filename)))
|
||||
.setNegativeButton(R.string.no_thanks, null)
|
||||
.show();
|
||||
});
|
||||
if (blockDetectionDone.isTriggered) {
|
||||
updateUI();
|
||||
|
@ -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);
|
||||
|
@ -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<ReposAdapter.ViewHolder>
|
||||
|
||||
private List<Repo> mUpdateRepos, mInstalledRepos, mOthersRepos;
|
||||
private View mView;
|
||||
private Context context;
|
||||
private AlertDialog.Builder builder;
|
||||
private Context mContext;
|
||||
|
||||
public ReposAdapter(List<Repo> update, List<Repo> installed, List<Repo> others) {
|
||||
mUpdateRepos = update;
|
||||
@ -47,14 +45,7 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
|
||||
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<ReposAdapter.ViewHolder>
|
||||
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<ReposAdapter.ViewHolder>
|
||||
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<ReposAdapter.ViewHolder>
|
||||
.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<ReposAdapter.ViewHolder>
|
||||
|
||||
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);
|
||||
|
@ -14,7 +14,7 @@
|
||||
<string name="magisk_version">المثبت Magisk v%1$s</string>
|
||||
<string name="magisk_version_error">هل قمت بتثبيت Magisk؟</string>
|
||||
|
||||
<string name="magisk_update_available">Magisk v%1$s تحديث!</string>
|
||||
<string name="magisk_update_available">Magisk v%1$.1f تحديث!</string>
|
||||
<string name="cannot_check_updates">لا يمكن التحقق من التحديثات</string>
|
||||
<string name="up_to_date">أحدث إصدار من %1$s مثبت</string>
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
<string name="magisk_version">已安装 Magisk v%1$s</string>
|
||||
<string name="magisk_version_error">你是否已安装 Magisk?</string>
|
||||
|
||||
<string name="magisk_update_available">Magisk 可更新到 v%1$s!</string>
|
||||
<string name="magisk_update_available">Magisk 可更新到 v%1$.1f!</string>
|
||||
<string name="cannot_check_updates">无法检查更新</string>
|
||||
<string name="up_to_date">已安装最新版本的 %1$s</string>
|
||||
|
||||
|
@ -85,7 +85,8 @@
|
||||
<string name="no_thanks">No thanks</string>
|
||||
<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">Go to \"Install\" section</string>
|
||||
<string name="download_install">Download and install</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>
|
||||
<string name="manual_install_1">Zip file placed in %1$s</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user