2018-07-28 22:52:40 +08:00
|
|
|
package com.topjohnwu.magisk.components;
|
|
|
|
|
|
|
|
import android.app.Activity;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.support.annotation.NonNull;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
|
|
|
import com.topjohnwu.magisk.FlashActivity;
|
2018-07-31 16:57:52 +08:00
|
|
|
import com.topjohnwu.magisk.Global;
|
2018-07-28 22:52:40 +08:00
|
|
|
import com.topjohnwu.magisk.MagiskManager;
|
|
|
|
import com.topjohnwu.magisk.R;
|
|
|
|
import com.topjohnwu.magisk.asyncs.RestoreImages;
|
|
|
|
import com.topjohnwu.magisk.receivers.DownloadReceiver;
|
|
|
|
import com.topjohnwu.magisk.utils.Const;
|
2018-07-30 20:37:00 +08:00
|
|
|
import com.topjohnwu.magisk.utils.Download;
|
2018-07-28 22:52:40 +08:00
|
|
|
import com.topjohnwu.magisk.utils.Utils;
|
|
|
|
|
|
|
|
public class UninstallDialog extends CustomAlertDialog {
|
|
|
|
|
|
|
|
public UninstallDialog(@NonNull Activity activity) {
|
|
|
|
super(activity);
|
|
|
|
MagiskManager mm = Utils.getMagiskManager(activity);
|
|
|
|
setTitle(R.string.uninstall_magisk_title);
|
|
|
|
setMessage(R.string.uninstall_magisk_msg);
|
|
|
|
setNeutralButton(R.string.restore_img, (d, i) -> new RestoreImages(activity).exec());
|
2018-07-31 03:51:11 +08:00
|
|
|
if (!TextUtils.isEmpty(Global.uninstallerLink)) {
|
2018-07-28 22:52:40 +08:00
|
|
|
setPositiveButton(R.string.complete_uninstall, (d, i) ->
|
2018-07-30 20:37:00 +08:00
|
|
|
Download.receive(activity, new DownloadReceiver() {
|
2018-07-28 22:52:40 +08:00
|
|
|
@Override
|
|
|
|
public void onDownloadDone(Context context, Uri uri) {
|
|
|
|
Intent intent = new Intent(context, FlashActivity.class)
|
|
|
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
|
|
.setData(uri)
|
|
|
|
.putExtra(Const.Key.FLASH_ACTION, Const.Value.UNINSTALL);
|
|
|
|
context.startActivity(intent);
|
|
|
|
}
|
2018-07-31 03:51:11 +08:00
|
|
|
}, Global.uninstallerLink, "magisk-uninstaller.zip"));
|
2018-07-28 22:52:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|