From 2284c20ab3e9353f2faf430902d4ede5a2db1343 Mon Sep 17 00:00:00 2001 From: Billy Brawner Date: Sat, 17 Aug 2019 13:36:21 -0500 Subject: [PATCH] Remove Constants file --- .../wbrawner/simplemarkdown/utility/Constants.java | 13 ------------- .../com/wbrawner/simplemarkdown/utility/Utils.java | 4 +++- .../simplemarkdown/view/activity/MainActivity.kt | 8 +++++++- .../java/com/wbrawner/simplemarkdown/UtilsTest.java | 3 +-- 4 files changed, 11 insertions(+), 17 deletions(-) delete mode 100644 app/src/main/java/com/wbrawner/simplemarkdown/utility/Constants.java diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/utility/Constants.java b/app/src/main/java/com/wbrawner/simplemarkdown/utility/Constants.java deleted file mode 100644 index 446543b..0000000 --- a/app/src/main/java/com/wbrawner/simplemarkdown/utility/Constants.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.wbrawner.simplemarkdown.utility; - -@SuppressWarnings("WeakerAccess") -public class Constants { - // Request codes - public static final int REQUEST_OPEN_FILE = 1; - public static final int REQUEST_SAVE_FILE = 2; - public static final int REQUEST_NEW_FILE = 3; - public static final int REQUEST_DARK_MODE = 4; - - // Settings keys - public static final String KEY_AUTOSAVE = "autosave"; -} diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/utility/Utils.java b/app/src/main/java/com/wbrawner/simplemarkdown/utility/Utils.java index e17d01b..7a9b6be 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/utility/Utils.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/utility/Utils.java @@ -15,10 +15,12 @@ import java.io.IOException; public class Utils { + public static final String KEY_AUTOSAVE = "autosave"; + public static boolean isAutosaveEnabled(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); return prefs.getBoolean( - Constants.KEY_AUTOSAVE, + KEY_AUTOSAVE, true ); } diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MainActivity.kt b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MainActivity.kt index 8ccdf00..106933c 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MainActivity.kt +++ b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MainActivity.kt @@ -19,7 +19,6 @@ import androidx.core.app.ActivityCompat import com.wbrawner.simplemarkdown.MarkdownApplication import com.wbrawner.simplemarkdown.R import com.wbrawner.simplemarkdown.presentation.MarkdownPresenter -import com.wbrawner.simplemarkdown.utility.Constants.* import com.wbrawner.simplemarkdown.utility.ErrorHandler import com.wbrawner.simplemarkdown.utility.Utils import com.wbrawner.simplemarkdown.view.adapter.EditPagerAdapter @@ -286,4 +285,11 @@ class MainActivity : AppCompatActivity(), ActivityCompat.OnRequestPermissionsRes cancel() } } + + companion object { + // Request codes + const val REQUEST_OPEN_FILE = 1 + const val REQUEST_SAVE_FILE = 2 + const val REQUEST_DARK_MODE = 4 + } } diff --git a/app/src/test/java/com/wbrawner/simplemarkdown/UtilsTest.java b/app/src/test/java/com/wbrawner/simplemarkdown/UtilsTest.java index 1ddce0a..32a48b6 100644 --- a/app/src/test/java/com/wbrawner/simplemarkdown/UtilsTest.java +++ b/app/src/test/java/com/wbrawner/simplemarkdown/UtilsTest.java @@ -4,7 +4,6 @@ import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; -import com.wbrawner.simplemarkdown.utility.Constants; import com.wbrawner.simplemarkdown.utility.Utils; import org.junit.After; @@ -43,7 +42,7 @@ public class UtilsTest { @Test public void isAutosaveEnabled() throws Exception { assertTrue(Utils.isAutosaveEnabled(context)); - sharedPreferences.edit().putBoolean(Constants.KEY_AUTOSAVE, false).apply(); + sharedPreferences.edit().putBoolean(Utils.KEY_AUTOSAVE, false).apply(); assertFalse(Utils.isAutosaveEnabled(context)); }