Skip to content
Snippets Groups Projects
Commit ed83aa65 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Further autocomplete changes

parent 4aed197d
Branches
Tags
No related merge requests found
package de.kuschku.quasseldroid_ng.ui.settings.data
import android.support.annotation.StyleRes
import de.kuschku.quasseldroid_ng.R
data class AppearanceSettings(
val showPrefix: ShowPrefixMode = ShowPrefixMode.HIGHEST,
val colorizeNicknames: ColorizeNicknamesMode = ColorizeNicknamesMode.ALL_BUT_MINE,
val inputEnter: InputEnterMode = InputEnterMode.EMOJI,
val colorizeMirc: Boolean = true,
val useMonospace: Boolean = false,
val showSeconds: Boolean = false,
val use24hClock: Boolean = true,
val showHostmask: Boolean = false,
val showLag: Boolean = true,
val theme: Theme = Theme.QUASSEL_LIGHT
) {
enum class ColorizeNicknamesMode {
ALL,
ALL_BUT_MINE,
NONE;
companion object {
private val map = values().associateBy { it.name }
fun of(name: String) = map[name]
}
}
enum class InputEnterMode {
EMOJI,
SEND;
companion object {
private val map = values().associateBy { it.name }
fun of(name: String) = map[name]
}
}
enum class ShowPrefixMode {
ALL,
HIGHEST,
NONE;
companion object {
private val map = values().associateBy { it.name }
fun of(name: String) = map[name]
}
}
enum class Theme(@StyleRes val style: Int) {
QUASSEL_LIGHT(R.style.Theme_ChatTheme_Quassel_Light),
QUASSEL_DARK(R.style.Theme_ChatTheme_Quassel_Dark),
AMOLED(R.style.Theme_ChatTheme_Amoled),
SOLARIZED_LIGHT(R.style.Theme_ChatTheme_Solarized_Light),
SOLARIZED_DARK(R.style.Theme_ChatTheme_Solarized_Dark),
GRUVBOX_LIGHT(R.style.Theme_ChatTheme_Gruvbox_Light),
GRUVBOX_DARK(R.style.Theme_ChatTheme_Gruvbox_Dark);
companion object {
private val map = values().associateBy { it.name }
fun of(name: String) = map[name]
}
}
companion object {
val DEFAULT = AppearanceSettings()
}
}
\ No newline at end of file
package de.kuschku.quasseldroid_ng.ui.settings.data
data class BacklogSettings(
val dynamicAmount: Int = 20
) {
companion object {
val DEFAULT = BacklogSettings()
}
}
\ No newline at end of file
package de.kuschku.quasseldroid_ng.ui.settings.data
data class ConnectionSettings(
val showNotification: Boolean = true
) {
companion object {
val DEFAULT = ConnectionSettings()
}
}
\ No newline at end of file
package de.kuschku.quasseldroid_ng.ui.settings.data
import android.content.Context
import de.kuschku.quasseldroid_ng.R
import de.kuschku.quasseldroid_ng.ui.settings.data.AppearanceSettings.*
import de.kuschku.quasseldroid_ng.util.helper.sharedPreferences
object Settings {
fun appearance(context: Context) = context.sharedPreferences {
AppearanceSettings(
theme = Theme.of(
getString(
context.getString(R.string.preference_theme_key),
""
)
) ?: AppearanceSettings.DEFAULT.theme,
useMonospace = getBoolean(
context.getString(R.string.preference_monospace_key),
AppearanceSettings.DEFAULT.useMonospace
),
showSeconds = getBoolean(
context.getString(R.string.preference_show_seconds_key),
AppearanceSettings.DEFAULT.showSeconds
),
use24hClock = getBoolean(
context.getString(R.string.preference_use_24h_clock_key),
AppearanceSettings.DEFAULT.use24hClock
),
showPrefix = ShowPrefixMode.of(
getString(
context.getString(R.string.preference_show_prefix_key),
""
)
) ?: AppearanceSettings.DEFAULT.showPrefix,
colorizeNicknames = ColorizeNicknamesMode.of(
getString(
context.getString(R.string.preference_colorize_nicknames_key),
""
)
) ?: AppearanceSettings.DEFAULT.colorizeNicknames,
inputEnter = InputEnterMode.of(
getString(
context.getString(R.string.preference_input_enter_key),
""
)
) ?: AppearanceSettings.DEFAULT.inputEnter,
colorizeMirc = getBoolean(
context.getString(R.string.preference_colorize_mirc_key),
AppearanceSettings.DEFAULT.colorizeMirc
),
showHostmask = getBoolean(
context.getString(R.string.preference_hostmask_key),
AppearanceSettings.DEFAULT.showHostmask
),
showLag = getBoolean(
context.getString(R.string.preference_show_lag_key),
AppearanceSettings.DEFAULT.showLag
)
)
}
fun backlog(context: Context) = context.sharedPreferences {
BacklogSettings(
dynamicAmount = getString(
context.getString(R.string.preference_dynamic_fetch_key),
BacklogSettings.DEFAULT.dynamicAmount.toString()
).toIntOrNull() ?: BacklogSettings.DEFAULT.dynamicAmount
)
}
fun connection(context: Context) = context.sharedPreferences {
ConnectionSettings(
showNotification = getBoolean(
context.getString(R.string.preference_show_notification_key),
ConnectionSettings.DEFAULT.showNotification
)
)
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment