33import android .content .Context ;
44import android .content .SharedPreferences ;
55
6+ import androidx .preference .PreferenceManager ;
7+
68import com .codedead .deadhash .R ;
79
810public class SettingsContainer {
@@ -16,7 +18,7 @@ public class SettingsContainer {
1618 private boolean calculateSha512 ;
1719 private boolean calculateCrc32 ;
1820 private int reviewTimes ;
19- private int theme ;
21+ private String theme ;
2022
2123 /**
2224 * Initialize a new SettingsContainer
@@ -34,15 +36,6 @@ public String getLanguageCode() {
3436 return languageCode ;
3537 }
3638
37- /**
38- * Set the language code
39- *
40- * @param languageCode The language code
41- */
42- public void setLanguageCode (final String languageCode ) {
43- this .languageCode = languageCode ;
44- }
45-
4639 /**
4740 * Get whether MD5 hashes should be calculated
4841 *
@@ -52,15 +45,6 @@ public boolean isCalculateMd5() {
5245 return calculateMd5 ;
5346 }
5447
55- /**
56- * Set whether MD5 hashes should be calculated
57- *
58- * @param calculateMd5 True if MD5 hashes should be calculated, otherwise false
59- */
60- public void setCalculateMd5 (final boolean calculateMd5 ) {
61- this .calculateMd5 = calculateMd5 ;
62- }
63-
6448 /**
6549 * Get whether SHA1 hashes should be calculated
6650 *
@@ -70,15 +54,6 @@ public boolean isCalculateSha1() {
7054 return calculateSha1 ;
7155 }
7256
73- /**
74- * Set whether SHA1 hashes should be calculated
75- *
76- * @param calculateSha1 True if SHA1 hashes should be calculated, otherwise false
77- */
78- public void setCalculateSha1 (final boolean calculateSha1 ) {
79- this .calculateSha1 = calculateSha1 ;
80- }
81-
8257 /**
8358 * Get whether SHA224 hashes should be calculated
8459 *
@@ -88,15 +63,6 @@ public boolean isCalculateSha224() {
8863 return calculateSha224 ;
8964 }
9065
91- /**
92- * Set whether SHA224 hashes should be calculated
93- *
94- * @param calculateSha224 True if SHA224 hashes should be calculated, otherwise false
95- */
96- public void setCalculateSha224 (final boolean calculateSha224 ) {
97- this .calculateSha224 = calculateSha224 ;
98- }
99-
10066 /**
10167 * Get whether SHA256 hashes should be calculated
10268 *
@@ -106,15 +72,6 @@ public boolean isCalculateSha256() {
10672 return calculateSha256 ;
10773 }
10874
109- /**
110- * Set whether SHA256 hashes should be calculated
111- *
112- * @param calculateSha256 True if SHA256 hashes should be calculated, otherwise false
113- */
114- public void setCalculateSha256 (final boolean calculateSha256 ) {
115- this .calculateSha256 = calculateSha256 ;
116- }
117-
11875 /**
11976 * Get whether SHA384 hashes should be calculated
12077 *
@@ -124,15 +81,6 @@ public boolean isCalculateSha384() {
12481 return calculateSha384 ;
12582 }
12683
127- /**
128- * Set whether SHA384 hashes should be calculated
129- *
130- * @param calculateSha384 True if SHA384 hashes should be calculated, otherwise false
131- */
132- public void setCalculateSha384 (final boolean calculateSha384 ) {
133- this .calculateSha384 = calculateSha384 ;
134- }
135-
13684 /**
13785 * Get whether SHA512 hashes should be calculated
13886 *
@@ -142,15 +90,6 @@ public boolean isCalculateSha512() {
14290 return calculateSha512 ;
14391 }
14492
145- /**
146- * Set whether SHA512 hashes should be calculated
147- *
148- * @param calculateSha512 True if SHA512 hashes should be calculated, otherwise false
149- */
150- public void setCalculateSha512 (final boolean calculateSha512 ) {
151- this .calculateSha512 = calculateSha512 ;
152- }
153-
15493 /**
15594 * Get whether CRC32 values should be calculated
15695 *
@@ -160,15 +99,6 @@ public boolean isCalculateCrc32() {
16099 return calculateCrc32 ;
161100 }
162101
163- /**
164- * Set whether CRC32 values should be calculated
165- *
166- * @param calculateCrc32 True if CRC32 values should be calculated, otherwise false
167- */
168- public void setCalculateCrc32 (final boolean calculateCrc32 ) {
169- this .calculateCrc32 = calculateCrc32 ;
170- }
171-
172102 /**
173103 * Get the amount of times a user has been asked to review the application
174104 *
@@ -195,28 +125,20 @@ public void setReviewTimes(final int reviewTimes) {
195125 *
196126 * @return The theme index
197127 */
198- public int getTheme () {
128+ public String getTheme () {
199129 return theme ;
200130 }
201131
202- /**
203- * Set the theme index
204- *
205- * @param theme The theme index
206- */
207- public void setTheme (final int theme ) {
208- this .theme = theme ;
209- }
210-
211132 /**
212133 * Load the settings
213134 *
214135 * @param context The Context that can be used to load the settings
215136 */
216137 public void loadSettings (final Context context ) {
217- if (context == null ) throw new NullPointerException ("Context cannot be null!" );
138+ if (context == null )
139+ throw new NullPointerException ("Context cannot be null!" );
218140
219- final SharedPreferences sharedPreferences = context . getSharedPreferences (context .getString ( R . string . preferences_file_key ), Context . MODE_PRIVATE );
141+ final SharedPreferences sharedPreferences = PreferenceManager . getDefaultSharedPreferences (context .getApplicationContext () );
220142
221143 languageCode = sharedPreferences .getString ("language" , "en" );
222144 calculateMd5 = sharedPreferences .getBoolean ("md5" , true );
@@ -227,7 +149,7 @@ public void loadSettings(final Context context) {
227149 calculateSha512 = sharedPreferences .getBoolean ("sha512" , true );
228150 calculateCrc32 = sharedPreferences .getBoolean ("crc32" , true );
229151 reviewTimes = sharedPreferences .getInt ("reviewTimes" , 0 );
230- theme = sharedPreferences .getInt ("theme" , 0 );
152+ theme = sharedPreferences .getString ("theme" , "2" );
231153 }
232154
233155 /**
@@ -250,7 +172,7 @@ public void saveSettings(final Context context) {
250172 edit .putBoolean ("sha512" , isCalculateSha512 ());
251173 edit .putBoolean ("crc32" , isCalculateCrc32 ());
252174 edit .putInt ("reviewTimes" , getReviewTimes ());
253- edit .putInt ("theme" , getTheme ());
175+ edit .putString ("theme" , getTheme ());
254176
255177 edit .apply ();
256178 }
0 commit comments