Add notification settings

This commit is contained in:
topjohnwu 2017-02-22 04:58:03 +08:00
parent 8ed9634adf
commit e94219c5a3
8 changed files with 22 additions and 21 deletions

View File

@ -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'

View File

@ -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))

View File

@ -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<V
}
@OnClick(R.id.magisk_status_container)
public void magisk() {
((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) {}
public void gotoInstall() {
((MainActivity) getActivity()).navigate(R.id.install);
}
private int defaultColor;
@ -110,14 +104,7 @@ public class StatusFragment extends Fragment implements CallbackEvent.Listener<V
.setTitle(R.string.no_magisk_title)
.setMessage(R.string.no_magisk_msg)
.setCancelable(true)
.setPositiveButton(R.string.goto_install, (dialogInterface, i) -> {
((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();
}

View File

@ -48,7 +48,8 @@ public class CheckUpdates extends ParallelTask<Void, Void, Void> {
@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))

View File

@ -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);
}

View File

@ -191,5 +191,7 @@
<string name="version_none">(無)</string>
<string name="manual_boot_image">請手動選取 boot 映像位置</string>
<string name="cannot_auto_detect">(無法自動偵測)</string>
<string name="settings_notification_summary">有更新的時候顯示通知</string>
<string name="settings_notification_title">更新通知</string>
</resources>

View File

@ -131,6 +131,8 @@
<string name="settings_general_category">General</string>
<string name="settings_dark_theme_title">Dark Theme</string>
<string name="settings_dark_theme_summary">Enable dark theme</string>
<string name="settings_notification_title">Update Notification</string>
<string name="settings_notification_summary">Show update notifications when new version is available</string>
<string name="settings_clear_cache_title">Clear Repo Cache</string>
<string name="settings_clear_cache_summary">Clear the cached information for online repos, forces the app to refresh online</string>

View File

@ -10,6 +10,11 @@
android:summary="@string/settings_dark_theme_summary"
android:key="dark_theme" />
<CheckBoxPreference
android:title="@string/settings_notification_title"
android:summary="@string/settings_notification_summary"
android:key="notification" />
<Preference
android:key="clear"
android:title="@string/settings_clear_cache_title"