-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from ergoplatform/release/2.0.x
2.0.2215
- Loading branch information
Showing
68 changed files
with
846 additions
and
443 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 11 additions & 10 deletions
21
android/src/main/java/org/ergoplatform/android/Preferences.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,49 @@ | ||
package org.ergoplatform.android | ||
|
||
import android.content.Context | ||
import android.content.SharedPreferences | ||
import androidx.appcompat.app.AppCompatDelegate | ||
import org.ergoplatform.persistance.* | ||
|
||
const val KEY_DAYNIGHTMODE = "dayNightMode" | ||
|
||
class Preferences(val context: Context) : PreferencesProvider() { | ||
private fun getSharedPrefs(context: Context) = | ||
class Preferences(context: Context) : PreferencesProvider() { | ||
private val prefs: SharedPreferences = | ||
context.getSharedPreferences(NAME_SHAREDPREFS, Context.MODE_PRIVATE) | ||
|
||
override fun getString(key: String, default: String): String { | ||
return getSharedPrefs(context).getString(key, default) ?: default | ||
return prefs.getString(key, default) ?: default | ||
} | ||
|
||
override fun saveString(key: String, value: String) { | ||
getSharedPrefs(context).edit().putString(key, value).apply() | ||
prefs.edit().putString(key, value).apply() | ||
} | ||
|
||
override fun getLong(key: String, default: Long): Long { | ||
return getSharedPrefs(context).getLong(key, default) | ||
return prefs.getLong(key, default) | ||
} | ||
|
||
override fun saveLong(key: String, value: Long) { | ||
getSharedPrefs(context).edit().putLong(key, value).apply() | ||
prefs.edit().putLong(key, value).apply() | ||
} | ||
|
||
override fun getFloat(key: String, default: Float): Float { | ||
return getSharedPrefs(context).getFloat(key, default) | ||
return prefs.getFloat(key, default) | ||
} | ||
|
||
override fun saveFloat(key: String, value: Float) { | ||
getSharedPrefs(context).edit().putFloat(key, value).apply() | ||
prefs.edit().putFloat(key, value).apply() | ||
} | ||
|
||
var dayNightMode: Int | ||
get() { | ||
return getSharedPrefs(context).getInt( | ||
return prefs.getInt( | ||
KEY_DAYNIGHTMODE, | ||
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM | ||
) | ||
} | ||
set(mode) { | ||
getSharedPrefs(context).edit().putInt(KEY_DAYNIGHTMODE, mode).apply() | ||
prefs.edit().putInt(KEY_DAYNIGHTMODE, mode).apply() | ||
AppCompatDelegate.setDefaultNightMode(mode) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.