2018-07-28 22:52:40 +08:00
|
|
|
package com.topjohnwu.magisk.components;
|
|
|
|
|
|
|
|
import android.Manifest;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.support.annotation.NonNull;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
2018-07-31 17:42:35 +08:00
|
|
|
import com.topjohnwu.magisk.Const;
|
2018-07-31 17:41:54 +08:00
|
|
|
import com.topjohnwu.magisk.Data;
|
2018-07-28 22:52:40 +08:00
|
|
|
import com.topjohnwu.magisk.MagiskManager;
|
|
|
|
import com.topjohnwu.magisk.R;
|
|
|
|
import com.topjohnwu.magisk.asyncs.MarkDownWindow;
|
|
|
|
import com.topjohnwu.magisk.receivers.ManagerUpdate;
|
|
|
|
import com.topjohnwu.magisk.utils.Utils;
|
|
|
|
|
|
|
|
public class ManagerInstallDialog extends CustomAlertDialog {
|
|
|
|
|
|
|
|
public ManagerInstallDialog(@NonNull Activity activity) {
|
|
|
|
super(activity);
|
2018-08-01 14:30:59 +08:00
|
|
|
MagiskManager mm = Data.MM();
|
2018-07-28 22:52:40 +08:00
|
|
|
String filename = Utils.fmt("MagiskManager-v%s(%d).apk",
|
2018-07-31 17:41:54 +08:00
|
|
|
Data.remoteManagerVersionString, Data.remoteManagerVersionCode);
|
2018-07-28 22:52:40 +08:00
|
|
|
setTitle(mm.getString(R.string.repo_install_title, mm.getString(R.string.app_name)));
|
|
|
|
setMessage(mm.getString(R.string.repo_install_msg, filename));
|
|
|
|
setCancelable(true);
|
|
|
|
setPositiveButton(R.string.install, (d, i) -> activity.runWithPermission(
|
|
|
|
new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, () -> {
|
|
|
|
Intent intent = new Intent(mm, ManagerUpdate.class);
|
2018-07-31 17:41:54 +08:00
|
|
|
intent.putExtra(Const.Key.INTENT_SET_LINK, Data.managerLink);
|
2018-07-28 22:52:40 +08:00
|
|
|
intent.putExtra(Const.Key.INTENT_SET_FILENAME, filename);
|
|
|
|
mm.sendBroadcast(intent);
|
|
|
|
}))
|
|
|
|
.setNegativeButton(R.string.no_thanks, null);
|
2018-07-31 17:41:54 +08:00
|
|
|
if (!TextUtils.isEmpty(Data.managerNoteLink)) {
|
2018-07-28 22:52:40 +08:00
|
|
|
setNeutralButton(R.string.app_changelog, (d, i) ->
|
2018-07-31 17:41:54 +08:00
|
|
|
new MarkDownWindow(activity, null, Data.managerNoteLink).exec());
|
2018-07-28 22:52:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|