From e94219c5a3a230f1da91d16b7dce5610f5434bf4 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Wed, 22 Feb 2017 04:58:03 +0800 Subject: [PATCH] Add notification settings --- app/build.gradle | 8 ++++---- .../com/topjohnwu/magisk/MagiskManager.java | 3 +++ .../com/topjohnwu/magisk/StatusFragment.java | 19 +++---------------- .../topjohnwu/magisk/asyncs/CheckUpdates.java | 3 ++- .../magisk/services/UpdateCheckService.java | 1 + app/src/main/res/values-zh-rTW/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/app_settings.xml | 5 +++++ 8 files changed, 22 insertions(+), 21 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 2e3fed0f5..dffc9f459 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -47,10 +47,10 @@ repositories { dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') - compile 'com.android.support:recyclerview-v7:25.1.1' - compile 'com.android.support:cardview-v7:25.1.1' - compile 'com.android.support:design:25.1.1' - compile 'com.android.support:support-v4:25.1.1' + compile 'com.android.support:recyclerview-v7:25.2.0' + compile 'com.android.support:cardview-v7:25.2.0' + compile 'com.android.support:design:25.2.0' + compile 'com.android.support:support-v4:25.2.0' compile 'com.jakewharton:butterknife:8.5.1' compile 'com.github.clans:fab:1.6.4' compile 'com.thoughtbot:expandablerecyclerview:1.4' diff --git a/app/src/main/java/com/topjohnwu/magisk/MagiskManager.java b/app/src/main/java/com/topjohnwu/magisk/MagiskManager.java index 6e056c0d4..c1543b8b0 100644 --- a/app/src/main/java/com/topjohnwu/magisk/MagiskManager.java +++ b/app/src/main/java/com/topjohnwu/magisk/MagiskManager.java @@ -63,6 +63,7 @@ public class MagiskManager extends Application { public boolean magiskHide; public boolean isDarkTheme; + public boolean updateNotification; public int suRequestTimeout; public int suLogTimeout = 14; public int suAccessState; @@ -92,6 +93,7 @@ public class MagiskManager extends Application { devLogging = prefs.getBoolean("developer_logging", false); shellLogging = prefs.getBoolean("shell_logging", false); magiskHide = prefs.getBoolean("magiskhide", false); + updateNotification = prefs.getBoolean("notification", true); // Always start a new root shell manually, just for safety Shell.init(); updateMagiskInfo(); @@ -101,6 +103,7 @@ public class MagiskManager extends Application { prefs.edit() .putBoolean("dark_theme", isDarkTheme) .putBoolean("magiskhide", magiskHide) + .putBoolean("notification", updateNotification) .putBoolean("busybox", Utils.commandExists("busybox")) .putBoolean("hosts", new File("/magisk/.core/hosts").exists()) .putBoolean("disable", Utils.itemExist(MAGISK_DISABLE_FILE)) diff --git a/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java b/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java index 1eaabc472..ffc63ee7e 100644 --- a/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java @@ -2,7 +2,6 @@ package com.topjohnwu.magisk; import android.os.Bundle; import android.support.annotation.Nullable; -import android.support.v4.app.FragmentTransaction; import android.support.v4.widget.SwipeRefreshLayout; import android.view.LayoutInflater; import android.view.View; @@ -65,13 +64,8 @@ public class StatusFragment extends Fragment implements CallbackEvent.Listener { - ((MainActivity) getActivity()).navigationView.setCheckedItem(R.id.install); - FragmentTransaction transaction = getFragmentManager().beginTransaction(); - transaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); - try { - transaction.replace(R.id.content_frame, new InstallFragment(), "install").commit(); - } catch (IllegalStateException ignored) {} - }) + .setPositiveButton(R.string.goto_install, (d, i) -> gotoInstall()) .setNegativeButton(R.string.no_thanks, null) .show(); } diff --git a/app/src/main/java/com/topjohnwu/magisk/asyncs/CheckUpdates.java b/app/src/main/java/com/topjohnwu/magisk/asyncs/CheckUpdates.java index 6e11782a8..f5c1e9dd7 100644 --- a/app/src/main/java/com/topjohnwu/magisk/asyncs/CheckUpdates.java +++ b/app/src/main/java/com/topjohnwu/magisk/asyncs/CheckUpdates.java @@ -48,7 +48,8 @@ public class CheckUpdates extends ParallelTask { @Override protected void onPostExecute(Void v) { - if (magiskManager.magiskVersion < magiskManager.remoteMagiskVersion && showNotification) { + if (magiskManager.magiskVersion < magiskManager.remoteMagiskVersion + && showNotification && magiskManager.updateNotification) { NotificationCompat.Builder builder = new NotificationCompat.Builder(magiskManager); builder.setSmallIcon(R.drawable.ic_magisk) .setContentTitle(magiskManager.getString(R.string.magisk_update_title)) diff --git a/app/src/main/java/com/topjohnwu/magisk/services/UpdateCheckService.java b/app/src/main/java/com/topjohnwu/magisk/services/UpdateCheckService.java index f07154ac6..a3a9af478 100644 --- a/app/src/main/java/com/topjohnwu/magisk/services/UpdateCheckService.java +++ b/app/src/main/java/com/topjohnwu/magisk/services/UpdateCheckService.java @@ -12,6 +12,7 @@ public class UpdateCheckService extends JobService { @Override protected Void doInBackground(Void... voids) { magiskManager.updateMagiskInfo(); + magiskManager.updateNotification = magiskManager.prefs.getBoolean("notification", true); return super.doInBackground(voids); } diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 8ebc98a0e..e9a019c45 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -191,5 +191,7 @@ (無) 請手動選取 boot 映像位置 (無法自動偵測) + 有更新的時候顯示通知 + 更新通知 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bfc3b3b40..d306c2bd2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -131,6 +131,8 @@ General Dark Theme Enable dark theme + Update Notification + Show update notifications when new version is available Clear Repo Cache Clear the cached information for online repos, forces the app to refresh online diff --git a/app/src/main/res/xml/app_settings.xml b/app/src/main/res/xml/app_settings.xml index 7856dab78..9774ba8f9 100644 --- a/app/src/main/res/xml/app_settings.xml +++ b/app/src/main/res/xml/app_settings.xml @@ -10,6 +10,11 @@ android:summary="@string/settings_dark_theme_summary" android:key="dark_theme" /> + +