parent
098cc3acde
commit
45e61d9a46
@ -1,8 +1,15 @@ |
||||
package net.pokeranalytics.android.calculus |
||||
|
||||
import android.content.Context |
||||
import android.graphics.Color |
||||
import androidx.core.content.ContextCompat |
||||
|
||||
class StatFormat(text: String, color: Int = Color.WHITE) { |
||||
class TextFormat(text: String, color: Int? = null) { |
||||
var text: String = text |
||||
var color: Int = color |
||||
private var color: Int? = color |
||||
|
||||
fun getColor(context: Context) : Int { |
||||
this.color?.let { return ContextCompat.getColor(context, it) } |
||||
return Color.WHITE |
||||
} |
||||
} |
||||
@ -0,0 +1,41 @@ |
||||
package net.pokeranalytics.android.util |
||||
|
||||
import android.content.Context |
||||
import android.preference.PreferenceManager |
||||
import java.util.* |
||||
|
||||
class Preferences { |
||||
|
||||
enum class Keys(identifier: String) { |
||||
CURRENCY_LANGUAGE("CurrencyLanguage") |
||||
} |
||||
|
||||
companion object { |
||||
|
||||
fun setString(key: Keys, value: String, context: Context) { |
||||
var preferences = PreferenceManager.getDefaultSharedPreferences(context) |
||||
var editor = preferences.edit() |
||||
editor.putString(key.toString(), value) |
||||
editor.commit() |
||||
} |
||||
|
||||
fun getString(key: Keys, context: Context) : String? { |
||||
var preferences = PreferenceManager.getDefaultSharedPreferences(context) |
||||
return preferences.getString(key.name, null) |
||||
} |
||||
|
||||
fun setCurrencyLanguage(language: String, context: Context) { |
||||
Preferences.setString(Keys.CURRENCY_LANGUAGE, language, context) |
||||
} |
||||
|
||||
fun getCurrencyLocale(context : Context) : Locale { |
||||
val currencyLanguage = Preferences.getString(Keys.CURRENCY_LANGUAGE, context) |
||||
if (currencyLanguage != null) { |
||||
return Locale(currencyLanguage) |
||||
} |
||||
return Locale.getDefault() |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue