settings reorganization;
implement long press on emoji button for fast text; some deprecations fixed; some typos fixed; etc
This commit is contained in:
@@ -89,12 +89,20 @@ object AppSettings {
|
||||
)
|
||||
set(value) = put(SettingsKeys.KEY_USE_CONTACT_NAMES, value)
|
||||
|
||||
var enablePullToRefresh: Boolean
|
||||
var showEmojiButton: Boolean
|
||||
get() = get(
|
||||
SettingsKeys.KEY_ENABLE_PULL_TO_REFRESH,
|
||||
SettingsKeys.DEFAULT_VALUE_ENABLE_PULL_TO_REFRESH
|
||||
SettingsKeys.KEY_SHOW_EMOJI_BUTTON,
|
||||
SettingsKeys.DEFAULT_VALUE_KEY_SHOW_EMOJI_BUTTON
|
||||
)
|
||||
set(value) = put(SettingsKeys.KEY_ENABLE_PULL_TO_REFRESH, value)
|
||||
set(value) = put(SettingsKeys.KEY_SHOW_EMOJI_BUTTON, value)
|
||||
|
||||
var enableHaptic: Boolean
|
||||
get() = get(
|
||||
SettingsKeys.KEY_ENABLE_HAPTIC,
|
||||
SettingsKeys.DEFAULT_ENABLE_HAPTIC
|
||||
)
|
||||
set(value) = put(SettingsKeys.KEY_ENABLE_HAPTIC, value)
|
||||
|
||||
}
|
||||
|
||||
object Appearance {
|
||||
@@ -126,6 +134,13 @@ object AppSettings {
|
||||
)
|
||||
set(value) = put(SettingsKeys.KEY_USE_DYNAMIC_COLORS, value)
|
||||
|
||||
var useSystemFont: Boolean
|
||||
get() = get(
|
||||
SettingsKeys.KEY_USE_SYSTEM_FONT,
|
||||
SettingsKeys.DEFAULT_USE_SYSTEM_FONT
|
||||
)
|
||||
set(value) = put(SettingsKeys.KEY_USE_SYSTEM_FONT, value)
|
||||
|
||||
var appLanguage: String
|
||||
get() = get(
|
||||
SettingsKeys.KEY_APPEARANCE_LANGUAGE,
|
||||
@@ -152,6 +167,29 @@ object AppSettings {
|
||||
set(value) = put(SettingsKeys.KEY_ACTIVITY_SEND_ONLINE_STATUS, value)
|
||||
}
|
||||
|
||||
object Experimental {
|
||||
var longPollInBackground: Boolean
|
||||
get() = get(
|
||||
SettingsKeys.KEY_LONG_POLL_IN_BACKGROUND,
|
||||
SettingsKeys.DEFAULT_LONG_POLL_IN_BACKGROUND
|
||||
)
|
||||
set(value) = put(SettingsKeys.KEY_LONG_POLL_IN_BACKGROUND, value)
|
||||
|
||||
var showTimeInActionMessages: Boolean
|
||||
get() = get(
|
||||
SettingsKeys.KEY_SHOW_TIME_IN_ACTION_MESSAGES,
|
||||
SettingsKeys.DEFAULT_SHOW_TIME_IN_ACTION_MESSAGES
|
||||
)
|
||||
set(value) = put(SettingsKeys.KEY_SHOW_TIME_IN_ACTION_MESSAGES, value)
|
||||
|
||||
var useBlur: Boolean
|
||||
get() = get(
|
||||
SettingsKeys.KEY_USE_BLUR,
|
||||
SettingsKeys.DEFAULT_USE_BLUR
|
||||
)
|
||||
set(value) = put(SettingsKeys.KEY_USE_BLUR, value)
|
||||
}
|
||||
|
||||
object Debug {
|
||||
var showAlertAfterCrash: Boolean
|
||||
get() = get(
|
||||
@@ -160,41 +198,6 @@ object AppSettings {
|
||||
)
|
||||
set(value) = put(SettingsKeys.KEY_DEBUG_SHOW_CRASH_ALERT, value)
|
||||
|
||||
var longPollInBackground: Boolean
|
||||
get() = get(
|
||||
SettingsKeys.KEY_FEATURES_LONG_POLL_IN_BACKGROUND,
|
||||
SettingsKeys.DEFAULT_VALUE_FEATURES_LONG_POLL_IN_BACKGROUND
|
||||
)
|
||||
set(value) = put(SettingsKeys.KEY_FEATURES_LONG_POLL_IN_BACKGROUND, value)
|
||||
|
||||
var useBlur: Boolean
|
||||
get() = get(
|
||||
SettingsKeys.KEY_APPEARANCE_USE_BLUR,
|
||||
SettingsKeys.DEFAULT_VALUE_KEY_APPEARANCE_USE_BLUR
|
||||
)
|
||||
set(value) = put(SettingsKeys.KEY_APPEARANCE_USE_BLUR, value)
|
||||
|
||||
var showEmojiButton: Boolean
|
||||
get() = get(
|
||||
SettingsKeys.KEY_SHOW_EMOJI_BUTTON,
|
||||
SettingsKeys.DEFAULT_VALUE_KEY_SHOW_EMOJI_BUTTON
|
||||
)
|
||||
set(value) = put(SettingsKeys.KEY_SHOW_EMOJI_BUTTON, value)
|
||||
|
||||
var showTimeInActionMessages: Boolean
|
||||
get() = get(
|
||||
SettingsKeys.KEY_APPEARANCE_SHOW_TIME_IN_ACTION_MESSAGES,
|
||||
SettingsKeys.DEFAULT_VALUE_APPEARANCE_SHOW_TIME_IN_ACTION_MESSAGES
|
||||
)
|
||||
set(value) = put(SettingsKeys.KEY_APPEARANCE_SHOW_TIME_IN_ACTION_MESSAGES, value)
|
||||
|
||||
var enableHaptic: Boolean
|
||||
get() = get(
|
||||
SettingsKeys.KEY_DEBUG_ENABLE_HAPTIC,
|
||||
SettingsKeys.DEFAULT_DEBUG_ENABLE_HAPTIC
|
||||
)
|
||||
set(value) = put(SettingsKeys.KEY_DEBUG_ENABLE_HAPTIC, value)
|
||||
|
||||
var networkLogLevel: LogLevel
|
||||
get() = get(
|
||||
SettingsKeys.KEY_DEBUG_NETWORK_LOG_LEVEL,
|
||||
@@ -202,13 +205,6 @@ object AppSettings {
|
||||
).let(LogLevel::parse)
|
||||
set(level) = put(SettingsKeys.KEY_DEBUG_NETWORK_LOG_LEVEL, level.value)
|
||||
|
||||
var useSystemFont: Boolean
|
||||
get() = get(
|
||||
SettingsKeys.KEY_DEBUG_USE_SYSTEM_FONT,
|
||||
SettingsKeys.DEFAULT_DEBUG_USE_SYSTEM_FONT
|
||||
)
|
||||
set(value) = put(SettingsKeys.KEY_DEBUG_USE_SYSTEM_FONT, value)
|
||||
|
||||
var showDebugCategory: Boolean
|
||||
get() = get(
|
||||
SettingsKeys.KEY_SHOW_DEBUG_CATEGORY,
|
||||
|
||||
@@ -7,11 +7,9 @@ object SettingsKeys {
|
||||
const val KEY_ACCOUNT_LOGOUT = "account_logout"
|
||||
|
||||
const val KEY_GENERAL = "general"
|
||||
const val KEY_USE_CONTACT_NAMES = "general_use_contact_names"
|
||||
const val KEY_USE_CONTACT_NAMES = "use_contact_names"
|
||||
const val DEFAULT_VALUE_USE_CONTACT_NAMES = false
|
||||
const val KEY_ENABLE_PULL_TO_REFRESH = "general_pull_to_refresh"
|
||||
const val DEFAULT_VALUE_ENABLE_PULL_TO_REFRESH = false
|
||||
const val KEY_SHOW_EMOJI_BUTTON = "general_show_emoji_button"
|
||||
const val KEY_SHOW_EMOJI_BUTTON = "show_emoji_button"
|
||||
const val DEFAULT_VALUE_KEY_SHOW_EMOJI_BUTTON = false
|
||||
|
||||
const val KEY_APPEARANCE = "appearance"
|
||||
@@ -23,20 +21,20 @@ object SettingsKeys {
|
||||
const val DEFAULT_VALUE_APPEARANCE_AMOLED_THEME = false
|
||||
const val KEY_USE_DYNAMIC_COLORS = "appearance_use_dynamic_colors"
|
||||
const val DEFAULT_VALUE_USE_DYNAMIC_COLORS = false
|
||||
const val KEY_APPEARANCE_COLOR_SCHEME = "appearance_color_scheme"
|
||||
const val DEFAULT_VALUE_APPEARANCE_COLOR_SCHEME = 0
|
||||
const val KEY_COLOR_SCHEME = "appearance_color_scheme"
|
||||
const val DEFAULT_COLOR_SCHEME = 0
|
||||
const val KEY_APPEARANCE_LANGUAGE = "appearance_language"
|
||||
const val DEFAULT_APPEARANCE_LANGUAGE = ""
|
||||
const val KEY_APPEARANCE_USE_BLUR = "appearance_use_blur"
|
||||
const val DEFAULT_VALUE_KEY_APPEARANCE_USE_BLUR = false
|
||||
const val KEY_APPEARANCE_SHOW_TIME_IN_ACTION_MESSAGES =
|
||||
"appearance_show_time_in_action_messages"
|
||||
const val DEFAULT_VALUE_APPEARANCE_SHOW_TIME_IN_ACTION_MESSAGES = false
|
||||
const val KEY_USE_BLUR = "use_blur"
|
||||
const val DEFAULT_USE_BLUR = false
|
||||
const val KEY_SHOW_TIME_IN_ACTION_MESSAGES =
|
||||
"show_time_in_action_messages"
|
||||
const val DEFAULT_SHOW_TIME_IN_ACTION_MESSAGES = false
|
||||
|
||||
const val KEY_FEATURES_FAST_TEXT = "features_fast_text"
|
||||
const val DEFAULT_VALUE_FEATURES_FAST_TEXT = "¯\\_(ツ)_/¯"
|
||||
const val KEY_FEATURES_LONG_POLL_IN_BACKGROUND = "features_lp_background"
|
||||
const val DEFAULT_VALUE_FEATURES_LONG_POLL_IN_BACKGROUND = false
|
||||
const val KEY_LONG_POLL_IN_BACKGROUND = "lp_background"
|
||||
const val DEFAULT_LONG_POLL_IN_BACKGROUND = false
|
||||
|
||||
const val KEY_ACTIVITY_SEND_ONLINE_STATUS = "activity_send_online_status"
|
||||
const val DEFAULT_VALUE_KEY_ACTIVITY_SEND_ONLINE_STATUS = false
|
||||
@@ -45,12 +43,12 @@ object SettingsKeys {
|
||||
const val KEY_DEBUG_SHOW_CRASH_ALERT = "debug_show_crash_alert"
|
||||
const val KEY_DEBUG_HIDE_DEBUG_LIST = "debug_hide_debug_list"
|
||||
const val KEY_ENABLE_ANIMATIONS_IN_MESSAGES = "debug_enable_animations_in_messages"
|
||||
const val KEY_DEBUG_ENABLE_HAPTIC = "debug_enable_haptic"
|
||||
const val DEFAULT_DEBUG_ENABLE_HAPTIC = true
|
||||
const val KEY_ENABLE_HAPTIC = "enable_haptic"
|
||||
const val DEFAULT_ENABLE_HAPTIC = true
|
||||
const val KEY_DEBUG_NETWORK_LOG_LEVEL = "debug_network_log_level"
|
||||
const val DEFAULT_NETWORK_LOG_LEVEL = 0
|
||||
const val KEY_DEBUG_USE_SYSTEM_FONT = "debug_use_system_font"
|
||||
const val DEFAULT_DEBUG_USE_SYSTEM_FONT = false
|
||||
const val KEY_USE_SYSTEM_FONT = "use_system_font"
|
||||
const val DEFAULT_USE_SYSTEM_FONT = false
|
||||
|
||||
const val KEY_SHOW_DEBUG_CATEGORY = "show_debug_category"
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import kotlinx.coroutines.flow.StateFlow
|
||||
interface UserSettings {
|
||||
|
||||
val useContactNames: StateFlow<Boolean>
|
||||
val enablePullToRefresh: StateFlow<Boolean>
|
||||
|
||||
val enableMultiline: StateFlow<Boolean>
|
||||
val darkMode: StateFlow<DarkMode>
|
||||
@@ -28,7 +27,6 @@ interface UserSettings {
|
||||
val showDebugCategory: StateFlow<Boolean>
|
||||
|
||||
fun onUseContactNamesChanged(use: Boolean)
|
||||
fun onEnablePullToRefreshChanged(enable: Boolean)
|
||||
|
||||
fun onEnableMultilineChanged(enable: Boolean)
|
||||
fun onDarkModeChanged(mode: DarkMode)
|
||||
@@ -52,7 +50,6 @@ interface UserSettings {
|
||||
class UserSettingsImpl : UserSettings {
|
||||
|
||||
override val useContactNames = MutableStateFlow(AppSettings.General.useContactNames)
|
||||
override val enablePullToRefresh = MutableStateFlow(AppSettings.General.enablePullToRefresh)
|
||||
|
||||
override val enableMultiline = MutableStateFlow(AppSettings.Appearance.enableMultiline)
|
||||
override val darkMode = MutableStateFlow(AppSettings.Appearance.darkMode)
|
||||
@@ -65,22 +62,18 @@ class UserSettingsImpl : UserSettings {
|
||||
override val sendOnlineStatus = MutableStateFlow(AppSettings.Activity.sendOnlineStatus)
|
||||
|
||||
override val showAlertAfterCrash = MutableStateFlow(AppSettings.Debug.showAlertAfterCrash)
|
||||
override val longPollInBackground = MutableStateFlow(AppSettings.Debug.longPollInBackground)
|
||||
override val useBlur = MutableStateFlow(AppSettings.Debug.useBlur)
|
||||
override val showEmojiButton = MutableStateFlow(AppSettings.Debug.showEmojiButton)
|
||||
override val longPollInBackground = MutableStateFlow(AppSettings.Experimental.longPollInBackground)
|
||||
override val useBlur = MutableStateFlow(AppSettings.Experimental.useBlur)
|
||||
override val showEmojiButton = MutableStateFlow(AppSettings.General.showEmojiButton)
|
||||
override val showTimeInActionMessages =
|
||||
MutableStateFlow(AppSettings.Debug.showTimeInActionMessages)
|
||||
override val useSystemFont = MutableStateFlow(AppSettings.Debug.useSystemFont)
|
||||
MutableStateFlow(AppSettings.Experimental.showTimeInActionMessages)
|
||||
override val useSystemFont = MutableStateFlow(AppSettings.Appearance.useSystemFont)
|
||||
override val showDebugCategory = MutableStateFlow(AppSettings.Debug.showDebugCategory)
|
||||
|
||||
override fun onUseContactNamesChanged(use: Boolean) {
|
||||
useContactNames.value = use
|
||||
}
|
||||
|
||||
override fun onEnablePullToRefreshChanged(enable: Boolean) {
|
||||
enablePullToRefresh.value = enable
|
||||
}
|
||||
|
||||
override fun onEnableMultilineChanged(enable: Boolean) {
|
||||
enableMultiline.value = enable
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package dev.meloda.fast.ui.components
|
||||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.Indication
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material.ripple.rememberRipple
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.IconButtonColors
|
||||
import androidx.compose.material3.IconButtonDefaults
|
||||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.LocalUseFallbackRippleImplementation
|
||||
import androidx.compose.material3.minimumInteractiveComponentSize
|
||||
import androidx.compose.material3.ripple
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.Stable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun IconButton(
|
||||
onClick: () -> Unit = {},
|
||||
onLongClick: (() -> Unit)? = null,
|
||||
modifier: Modifier = Modifier,
|
||||
enabled: Boolean = true,
|
||||
colors: IconButtonColors = IconButtonDefaults.iconButtonColors(),
|
||||
interactionSource: MutableInteractionSource? = null,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
Box(
|
||||
modifier =
|
||||
modifier
|
||||
.minimumInteractiveComponentSize()
|
||||
.size(IconButtonTokens.StateLayerSize)
|
||||
.clip(IconButtonTokens.StateLayerShape)
|
||||
.background(color = colors.containerColor(enabled))
|
||||
.combinedClickable(
|
||||
onClick = onClick,
|
||||
onLongClick = onLongClick,
|
||||
enabled = enabled,
|
||||
interactionSource = interactionSource,
|
||||
indication = rippleOrFallbackImplementation(
|
||||
bounded = false,
|
||||
radius = IconButtonTokens.StateLayerSize / 2
|
||||
)
|
||||
),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
val contentColor = colors.contentColor(enabled)
|
||||
CompositionLocalProvider(LocalContentColor provides contentColor, content = content)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
internal fun rippleOrFallbackImplementation(
|
||||
bounded: Boolean = true,
|
||||
radius: Dp = Dp.Unspecified,
|
||||
color: Color = Color.Unspecified
|
||||
): Indication {
|
||||
return if (LocalUseFallbackRippleImplementation.current) {
|
||||
rememberRipple(bounded, radius, color)
|
||||
} else {
|
||||
ripple(bounded, radius, color)
|
||||
}
|
||||
}
|
||||
|
||||
internal object IconButtonTokens {
|
||||
val StateLayerShape = CircleShape
|
||||
val StateLayerSize = 40.0.dp
|
||||
}
|
||||
|
||||
@Stable
|
||||
internal fun IconButtonColors.containerColor(enabled: Boolean): Color =
|
||||
if (enabled) containerColor else disabledContainerColor
|
||||
|
||||
@Stable
|
||||
internal fun IconButtonColors.contentColor(enabled: Boolean): Color =
|
||||
if (enabled) contentColor else disabledContentColor
|
||||
@@ -182,7 +182,7 @@
|
||||
<string name="settings_appearance_multiline_summary">Заголовок чата и текст сообщения смогут занимать несколько строчек</string>
|
||||
<string name="settings_features_title">Фичи</string>
|
||||
<string name="settings_features_fast_text_title">Fast текст</string>
|
||||
<string name="settings_features_long_poll_in_background_title">[WIP] LongPoll в фоне</string>
|
||||
<string name="settings_features_long_poll_in_background_title">LongPoll в фоне</string>
|
||||
<string name="settings_features_long_poll_in_background_summary">Ваши сообщения будут обновляться, даже если приложение находится в фоне</string>
|
||||
<string name="settings_activity_title">Активность</string>
|
||||
<string name="settings_activity_send_online_title">Быть «в сети»</string>
|
||||
|
||||
@@ -240,8 +240,8 @@
|
||||
<string name="settings_appearance_multiline_summary">The title of the conversation and the text of the message can take up multiple lines</string>
|
||||
<string name="settings_features_title">Features</string>
|
||||
<string name="settings_features_fast_text_title">Fast text</string>
|
||||
<string name="settings_features_long_poll_in_background_title">[WIP] LongPoll in background</string>
|
||||
<string name="settings_features_long_poll_in_background_summary">Your messages will be updates even when app is not on the screen</string>
|
||||
<string name="settings_features_long_poll_in_background_title">LongPoll in background</string>
|
||||
<string name="settings_features_long_poll_in_background_summary">Your messages will be updating even when app is not on the screen</string>
|
||||
<string name="settings_activity_title">Activity</string>
|
||||
<string name="settings_activity_send_online_title">Send online status</string>
|
||||
<string name="settings_activity_send_online_summary">Online status will be sent every five minutes</string>
|
||||
|
||||
Reference in New Issue
Block a user