From 179fc32bc6fb6afd7dcec8a541ebfdc68f03e0e7 Mon Sep 17 00:00:00 2001 From: "Rui Zhao (renyuneyun)" Date: Tue, 20 Feb 2018 00:04:12 +0000 Subject: [PATCH] Move `SettingsHelper` to outer package --- app/src/main/java/ryey/easer/EaserApplication.java | 3 +-- .../main/java/ryey/easer/{core => }/SettingsHelper.java | 7 ++++++- app/src/main/java/ryey/easer/core/EHService.java | 1 + app/src/main/java/ryey/easer/core/Lotus.java | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) rename app/src/main/java/ryey/easer/{core => }/SettingsHelper.java (73%) diff --git a/app/src/main/java/ryey/easer/EaserApplication.java b/app/src/main/java/ryey/easer/EaserApplication.java index 12c1bc27..b00a259f 100644 --- a/app/src/main/java/ryey/easer/EaserApplication.java +++ b/app/src/main/java/ryey/easer/EaserApplication.java @@ -17,8 +17,7 @@ public void onCreate() { Logger.addLogAdapter(new AndroidLogAdapter()); - if (PreferenceManager.getDefaultSharedPreferences(getApplicationContext()). - getBoolean(getString(R.string.key_pref_logging), false)) { + if (SettingsHelper.logging(this)) { if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { Logger.addLogAdapter(new DiskLogAdapter()); diff --git a/app/src/main/java/ryey/easer/core/SettingsHelper.java b/app/src/main/java/ryey/easer/SettingsHelper.java similarity index 73% rename from app/src/main/java/ryey/easer/core/SettingsHelper.java rename to app/src/main/java/ryey/easer/SettingsHelper.java index 901b6942..d26f8d71 100644 --- a/app/src/main/java/ryey/easer/core/SettingsHelper.java +++ b/app/src/main/java/ryey/easer/SettingsHelper.java @@ -1,4 +1,4 @@ -package ryey.easer.core; +package ryey.easer; import android.content.Context; import android.preference.PreferenceManager; @@ -18,4 +18,9 @@ public static boolean passiveMode(Context context) { .getBoolean(context.getString(R.string.key_pref_passive_mode), true); } + public static boolean logging(Context context) { + return PreferenceManager.getDefaultSharedPreferences(context). + getBoolean(context.getString(R.string.key_pref_logging), false); + } + } diff --git a/app/src/main/java/ryey/easer/core/EHService.java b/app/src/main/java/ryey/easer/core/EHService.java index 56eeb888..a456e767 100644 --- a/app/src/main/java/ryey/easer/core/EHService.java +++ b/app/src/main/java/ryey/easer/core/EHService.java @@ -35,6 +35,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import ryey.easer.SettingsHelper; import ryey.easer.core.data.EventTree; import ryey.easer.core.data.storage.EventDataStorage; diff --git a/app/src/main/java/ryey/easer/core/Lotus.java b/app/src/main/java/ryey/easer/core/Lotus.java index 8c918b7d..87617581 100644 --- a/app/src/main/java/ryey/easer/core/Lotus.java +++ b/app/src/main/java/ryey/easer/core/Lotus.java @@ -35,6 +35,7 @@ import java.util.Locale; import java.util.concurrent.ExecutorService; +import ryey.easer.SettingsHelper; import ryey.easer.commons.plugindef.eventplugin.AbstractSlot; import ryey.easer.commons.plugindef.eventplugin.EventData; import ryey.easer.commons.plugindef.eventplugin.EventPlugin;