Skip to content

Commit 58578ee

Browse files
committed
convert config to kotlin
1 parent 40b60be commit 58578ee

File tree

3 files changed

+35
-49
lines changed

3 files changed

+35
-49
lines changed

app/src/main/java/com/simplemobiletools/filemanager/Config.java

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.simplemobiletools.filemanager
2+
3+
import android.content.Context
4+
import android.content.SharedPreferences
5+
6+
class Config(context: Context) {
7+
private val mPrefs: SharedPreferences
8+
9+
companion object {
10+
fun newInstance(context: Context): Config {
11+
return Config(context)
12+
}
13+
}
14+
15+
init {
16+
mPrefs = context.getSharedPreferences(Constants.PREFS_KEY, Context.MODE_PRIVATE)
17+
}
18+
19+
var isFirstRun: Boolean
20+
get() = mPrefs.getBoolean(Constants.IS_FIRST_RUN, true)
21+
set(firstRun) = mPrefs.edit().putBoolean(Constants.IS_FIRST_RUN, firstRun).apply()
22+
23+
var isDarkTheme: Boolean
24+
get() = mPrefs.getBoolean(Constants.IS_DARK_THEME, false)
25+
set(isDarkTheme) = mPrefs.edit().putBoolean(Constants.IS_DARK_THEME, isDarkTheme).apply()
26+
27+
var showHidden: Boolean
28+
get() = mPrefs.getBoolean(Constants.SHOW_HIDDEN, false)
29+
set(show) = mPrefs.edit().putBoolean(Constants.SHOW_HIDDEN, show).apply()
30+
31+
var treeUri: String
32+
get() = mPrefs.getString(Constants.TREE_URI, "")
33+
set(uri) = mPrefs.edit().putString(Constants.TREE_URI, uri).apply()
34+
}

app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
8181
super.onViewCreated(view, savedInstanceState);
8282
if (mStates == null)
8383
mStates = new HashMap<>();
84-
mConfig = Config.newInstance(getContext());
84+
mConfig = Config.Companion.newInstance(getContext());
8585
mShowHidden = mConfig.getShowHidden();
8686
mItems = new ArrayList<>();
8787
mToBeDeleted = new ArrayList<>();

0 commit comments

Comments
 (0)