convert config to kotlin

This commit is contained in:
tibbi
2016-11-13 23:40:14 +01:00
parent a911c8f97d
commit 0444d3f0ad
7 changed files with 46 additions and 66 deletions

View File

@ -0,0 +1,38 @@
package com.simplemobiletools.notes
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 fontSize: Int
get() = mPrefs.getInt(Constants.FONT_SIZE, Constants.FONT_SIZE_MEDIUM)
set(size) = mPrefs.edit().putInt(Constants.FONT_SIZE, size).apply()
var currentNoteId: Int
get() = mPrefs.getInt(Constants.CURRENT_NOTE_ID, 1)
set(id) = mPrefs.edit().putInt(Constants.CURRENT_NOTE_ID, id).apply()
var widgetNoteId: Int
get() = mPrefs.getInt(Constants.WIDGET_NOTE_ID, 1)
set(id) = mPrefs.edit().putInt(Constants.WIDGET_NOTE_ID, id).apply()
}