You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Added leanback activity that implements several functions which custom dialogs depend on
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package com.topjohnwu.magisk.view;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
@@ -19,11 +19,11 @@ import ru.noties.markwon.image.svg.SvgPlugin;
|
||||
|
||||
public class MarkDownWindow {
|
||||
|
||||
public static void show(Activity activity, String title, String url) {
|
||||
public static void show(Context activity, String title, String url) {
|
||||
Networking.get(url).getAsString(new Listener(activity, title));
|
||||
}
|
||||
|
||||
public static void show (Activity activity, String title, InputStream is) {
|
||||
public static void show(Context activity, String title, InputStream is) {
|
||||
try (Scanner s = new Scanner(is, "UTF-8")) {
|
||||
s.useDelimiter("\\A");
|
||||
new Listener(activity, title).onResponse(s.next());
|
||||
@@ -32,10 +32,10 @@ public class MarkDownWindow {
|
||||
|
||||
static class Listener implements ResponseListener<String> {
|
||||
|
||||
Activity activity;
|
||||
Context activity;
|
||||
String title;
|
||||
|
||||
Listener(Activity a, String t) {
|
||||
Listener(Context a, String t) {
|
||||
activity = a;
|
||||
title = t;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.topjohnwu.magisk.view.dialogs;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -52,11 +52,11 @@ public class CustomAlertDialog extends AlertDialog.Builder {
|
||||
|
||||
}
|
||||
|
||||
public CustomAlertDialog(@NonNull Activity context) {
|
||||
public CustomAlertDialog(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public CustomAlertDialog(@NonNull Activity context, @StyleRes int themeResId) {
|
||||
public CustomAlertDialog(@NonNull Context context, @StyleRes int themeResId) {
|
||||
super(context, themeResId);
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class CustomAlertDialog extends AlertDialog.Builder {
|
||||
vh.positive.setVisibility(View.VISIBLE);
|
||||
vh.positive.setText(text);
|
||||
positiveListener = listener;
|
||||
vh.positive.setOnClickListener((v) -> {
|
||||
vh.positive.setOnClickListener(v -> {
|
||||
if (positiveListener != null) {
|
||||
positiveListener.onClick(dialog, DialogInterface.BUTTON_POSITIVE);
|
||||
}
|
||||
@@ -108,7 +108,7 @@ public class CustomAlertDialog extends AlertDialog.Builder {
|
||||
vh.negative.setVisibility(View.VISIBLE);
|
||||
vh.negative.setText(text);
|
||||
negativeListener = listener;
|
||||
vh.negative.setOnClickListener((v) -> {
|
||||
vh.negative.setOnClickListener(v -> {
|
||||
if (negativeListener != null) {
|
||||
negativeListener.onClick(dialog, DialogInterface.BUTTON_NEGATIVE);
|
||||
}
|
||||
@@ -128,7 +128,7 @@ public class CustomAlertDialog extends AlertDialog.Builder {
|
||||
vh.neutral.setVisibility(View.VISIBLE);
|
||||
vh.neutral.setText(text);
|
||||
neutralListener = listener;
|
||||
vh.neutral.setOnClickListener((v) -> {
|
||||
vh.neutral.setOnClickListener(v -> {
|
||||
if (neutralListener != null) {
|
||||
neutralListener.onClick(dialog, DialogInterface.BUTTON_NEUTRAL);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.topjohnwu.magisk.ClassMap;
|
||||
import com.topjohnwu.magisk.Config;
|
||||
import com.topjohnwu.magisk.Const;
|
||||
import com.topjohnwu.magisk.R;
|
||||
import com.topjohnwu.magisk.ui.base.BaseActivity;
|
||||
import com.topjohnwu.magisk.ui.base.IBaseLeanback;
|
||||
import com.topjohnwu.magisk.ui.flash.FlashActivity;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
import com.topjohnwu.magisk.view.ProgressNotification;
|
||||
@@ -23,7 +23,7 @@ import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
class InstallMethodDialog extends AlertDialog.Builder {
|
||||
|
||||
InstallMethodDialog(BaseActivity activity, List<String> options) {
|
||||
<Ctxt extends Activity & IBaseLeanback> InstallMethodDialog(Ctxt activity, List<String> options) {
|
||||
super(activity);
|
||||
setTitle(R.string.select_method);
|
||||
setItems(options.toArray(new String[0]), (dialog, idx) -> {
|
||||
@@ -48,7 +48,7 @@ class InstallMethodDialog extends AlertDialog.Builder {
|
||||
});
|
||||
}
|
||||
|
||||
private void patchBoot(BaseActivity activity) {
|
||||
private <Ctxt extends Activity & IBaseLeanback> void patchBoot(Ctxt activity) {
|
||||
activity.runWithExternalRW(() -> {
|
||||
Utils.toast(R.string.patch_file_msg, Toast.LENGTH_LONG);
|
||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT)
|
||||
@@ -66,7 +66,7 @@ class InstallMethodDialog extends AlertDialog.Builder {
|
||||
});
|
||||
}
|
||||
|
||||
private void downloadOnly(BaseActivity activity) {
|
||||
private <Ctxt extends Activity & IBaseLeanback> void downloadOnly(Ctxt activity) {
|
||||
activity.runWithExternalRW(() -> {
|
||||
String filename = Utils.fmt("Magisk-v%s(%d).zip",
|
||||
Config.remoteMagiskVersionString, Config.remoteMagiskVersionCode);
|
||||
@@ -74,7 +74,7 @@ class InstallMethodDialog extends AlertDialog.Builder {
|
||||
ProgressNotification progress = new ProgressNotification(filename);
|
||||
Networking.get(Config.magiskLink)
|
||||
.setDownloadProgressListener(progress)
|
||||
.setErrorHandler(((conn, e) -> progress.dlFail()))
|
||||
.setErrorHandler((conn, e) -> progress.dlFail())
|
||||
.getAsFile(zip, f -> {
|
||||
progress.dlDone();
|
||||
SnackbarMaker.make(activity,
|
||||
@@ -84,7 +84,7 @@ class InstallMethodDialog extends AlertDialog.Builder {
|
||||
});
|
||||
}
|
||||
|
||||
private void installInactiveSlot(BaseActivity activity) {
|
||||
private <Ctxt extends Activity & IBaseLeanback> void installInactiveSlot(Ctxt activity) {
|
||||
new CustomAlertDialog(activity)
|
||||
.setTitle(R.string.warning)
|
||||
.setMessage(R.string.install_inactive_slot_msg)
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.topjohnwu.magisk.view.dialogs;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.topjohnwu.magisk.Config;
|
||||
import com.topjohnwu.magisk.R;
|
||||
import com.topjohnwu.magisk.ui.base.BaseActivity;
|
||||
import com.topjohnwu.magisk.ui.base.IBaseLeanback;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
import com.topjohnwu.magisk.view.MarkDownWindow;
|
||||
import com.topjohnwu.superuser.Shell;
|
||||
@@ -15,7 +16,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MagiskInstallDialog extends CustomAlertDialog {
|
||||
public MagiskInstallDialog(BaseActivity a) {
|
||||
public <Ctxt extends Activity & IBaseLeanback> MagiskInstallDialog(Ctxt a) {
|
||||
super(a);
|
||||
String filename = Utils.fmt("Magisk-v%s(%d).zip",
|
||||
Config.remoteMagiskVersionString, Config.remoteMagiskVersionCode);
|
||||
|
||||
Reference in New Issue
Block a user