Remove Constants file

This commit is contained in:
Billy Brawner 2019-08-17 13:36:21 -05:00 committed by William Brawner
parent 3fe3cdec68
commit 2284c20ab3
4 changed files with 11 additions and 17 deletions

View file

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

View file

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

View file

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

View file

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