Tweak notifications

This commit is contained in:
topjohnwu 2018-12-02 05:33:53 -05:00
parent 3402981ada
commit 857e6e8345
5 changed files with 19 additions and 9 deletions

View File

@ -76,7 +76,7 @@ class InstallMethodDialog extends AlertDialog.Builder {
.startDownload(new DownloadListener() {
@Override
public void onDownloadComplete() {
progress.defaultDone();
progress.dlDone();
SnackbarMaker.make(a,
a.getString(R.string.internal_storage, "/Download/" + filename),
Snackbar.LENGTH_LONG).show();

View File

@ -5,6 +5,8 @@ import android.widget.Toast;
import com.androidnetworking.interfaces.DownloadProgressListener;
import com.topjohnwu.magisk.Const;
import com.topjohnwu.magisk.Data;
import com.topjohnwu.magisk.MagiskManager;
import com.topjohnwu.magisk.R;
import com.topjohnwu.magisk.utils.Notifications;
import com.topjohnwu.magisk.utils.Utils;
@ -18,11 +20,12 @@ public class NotificationProgress implements DownloadProgressListener {
private long prevTime;
public NotificationProgress(String title) {
mgr = NotificationManagerCompat.from(Data.MM());
MagiskManager mm = Data.MM();
mgr = NotificationManagerCompat.from(mm);
builder = Notifications.progress(title);
mgr.notify(Const.ID.DOWNLOAD_PROGRESS_ID, builder.build());
prevTime = System.currentTimeMillis();
Utils.toast("Downloading " + title, Toast.LENGTH_SHORT);
Utils.toast(mm.getString(R.string.downloading_toast, title), Toast.LENGTH_SHORT);
}
@Override
@ -44,9 +47,13 @@ public class NotificationProgress implements DownloadProgressListener {
mgr.notify(Const.ID.DOWNLOAD_PROGRESS_ID, builder.build());
}
public void defaultDone() {
public void dlDone() {
builder.setProgress(0, 0, false);
builder.setContentText("Download done");
builder.setContentText(Data.MM().getString(R.string.download_complete));
update();
}
public void dismiss() {
mgr.cancel(Const.ID.DOWNLOAD_PROGRESS_ID);
}
}

View File

@ -50,7 +50,7 @@ public class UninstallDialog extends CustomAlertDialog {
.startDownload(new DownloadListener() {
@Override
public void onDownloadComplete() {
progress.defaultDone();
progress.dismiss();
Intent intent = new Intent(activity, Data.classMap.get(FlashActivity.class))
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.setData(Uri.fromFile(zip))

View File

@ -8,6 +8,7 @@ import com.androidnetworking.interfaces.DownloadListener;
import com.topjohnwu.magisk.Const;
import com.topjohnwu.magisk.Data;
import com.topjohnwu.magisk.MagiskManager;
import com.topjohnwu.magisk.R;
import com.topjohnwu.magisk.asyncs.PatchAPK;
import com.topjohnwu.magisk.components.NotificationProgress;
import com.topjohnwu.superuser.ShellUtils;
@ -72,7 +73,8 @@ public class DlInstallManager {
if (!mm.getPackageName().equals(Const.ORIG_PKG_NAME)) {
progress.getBuilder()
.setProgress(0, 0, true)
.setContentText("Patching APK");
.setContentTitle(mm.getString(R.string.hide_manager_toast))
.setContentText("");
progress.update();
patched = new File(apk.getParent(), "patched.apk");
try {
@ -83,7 +85,7 @@ public class DlInstallManager {
return;
}
}
progress.defaultDone();
progress.dismiss();
APKInstall.install(mm, patched);
}
}
@ -92,7 +94,7 @@ public class DlInstallManager {
@Override
public void onDownloadComplete(File apk, NotificationProgress progress) {
progress.defaultDone();
progress.dismiss();
Data.exportPrefs();
if (ShellUtils.fastCmdResult("pm install " + apk))
RootUtils.rmAndLaunch(Data.MM().getPackageName(), Const.ORIG_PKG_NAME);

View File

@ -122,6 +122,7 @@
<string name="download_file_error">Error downloading file</string>
<string name="downloading_toast">Downloading %1$s</string>
<string name="no_rw_storage">This feature will not work without permission to write external storage.</string>
<string name="download_complete">Download complete</string>
<!--Settings Activity -->
<string name="settings_general_category">General</string>