convert config to kotlin
This commit is contained in:
parent
40b60be6ba
commit
58578ee36d
|
@ -1,48 +0,0 @@
|
|||
package com.simplemobiletools.filemanager;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
public class Config {
|
||||
private SharedPreferences mPrefs;
|
||||
|
||||
public static Config newInstance(Context context) {
|
||||
return new Config(context);
|
||||
}
|
||||
|
||||
public Config(Context context) {
|
||||
mPrefs = context.getSharedPreferences(Constants.PREFS_KEY, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
public boolean getIsFirstRun() {
|
||||
return mPrefs.getBoolean(Constants.IS_FIRST_RUN, true);
|
||||
}
|
||||
|
||||
public void setIsFirstRun(boolean firstRun) {
|
||||
mPrefs.edit().putBoolean(Constants.IS_FIRST_RUN, firstRun).apply();
|
||||
}
|
||||
|
||||
public boolean getIsDarkTheme() {
|
||||
return mPrefs.getBoolean(Constants.IS_DARK_THEME, false);
|
||||
}
|
||||
|
||||
public void setIsDarkTheme(boolean isDarkTheme) {
|
||||
mPrefs.edit().putBoolean(Constants.IS_DARK_THEME, isDarkTheme).apply();
|
||||
}
|
||||
|
||||
public boolean getShowHidden() {
|
||||
return mPrefs.getBoolean(Constants.SHOW_HIDDEN, false);
|
||||
}
|
||||
|
||||
public void setShowHidden(boolean show) {
|
||||
mPrefs.edit().putBoolean(Constants.SHOW_HIDDEN, show).apply();
|
||||
}
|
||||
|
||||
public String getTreeUri() {
|
||||
return mPrefs.getString(Constants.TREE_URI, "");
|
||||
}
|
||||
|
||||
public void setTreeUri(String uri) {
|
||||
mPrefs.edit().putString(Constants.TREE_URI, uri).apply();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.simplemobiletools.filemanager
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
|
||||
class Config(context: Context) {
|
||||
private val mPrefs: SharedPreferences
|
||||
|
||||
companion object {
|
||||
fun newInstance(context: Context): Config {
|
||||
return Config(context)
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
mPrefs = context.getSharedPreferences(Constants.PREFS_KEY, Context.MODE_PRIVATE)
|
||||
}
|
||||
|
||||
var isFirstRun: Boolean
|
||||
get() = mPrefs.getBoolean(Constants.IS_FIRST_RUN, true)
|
||||
set(firstRun) = mPrefs.edit().putBoolean(Constants.IS_FIRST_RUN, firstRun).apply()
|
||||
|
||||
var isDarkTheme: Boolean
|
||||
get() = mPrefs.getBoolean(Constants.IS_DARK_THEME, false)
|
||||
set(isDarkTheme) = mPrefs.edit().putBoolean(Constants.IS_DARK_THEME, isDarkTheme).apply()
|
||||
|
||||
var showHidden: Boolean
|
||||
get() = mPrefs.getBoolean(Constants.SHOW_HIDDEN, false)
|
||||
set(show) = mPrefs.edit().putBoolean(Constants.SHOW_HIDDEN, show).apply()
|
||||
|
||||
var treeUri: String
|
||||
get() = mPrefs.getString(Constants.TREE_URI, "")
|
||||
set(uri) = mPrefs.edit().putString(Constants.TREE_URI, uri).apply()
|
||||
}
|
|
@ -81,7 +81,7 @@ public class ItemsFragment extends android.support.v4.app.Fragment
|
|||
super.onViewCreated(view, savedInstanceState);
|
||||
if (mStates == null)
|
||||
mStates = new HashMap<>();
|
||||
mConfig = Config.newInstance(getContext());
|
||||
mConfig = Config.Companion.newInstance(getContext());
|
||||
mShowHidden = mConfig.getShowHidden();
|
||||
mItems = new ArrayList<>();
|
||||
mToBeDeleted = new ArrayList<>();
|
||||
|
|
Loading…
Reference in New Issue