mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Enhancement - optional transparent homoglyph encoding of a few characters in certain languages for more compact and efficient text messages (#4491)
This commit is contained in:
parent
6ec2ed76ca
commit
4303bfaac4
10 changed files with 297 additions and 4 deletions
|
|
@ -36,6 +36,7 @@ import androidx.compose.foundation.rememberScrollState
|
|||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.rounded.KeyboardArrowRight
|
||||
import androidx.compose.material.icons.filled.Abc
|
||||
import androidx.compose.material.icons.filled.BugReport
|
||||
import androidx.compose.material.icons.rounded.AppSettingsAlt
|
||||
import androidx.compose.material.icons.rounded.FormatPaint
|
||||
|
|
@ -102,6 +103,7 @@ import org.meshtastic.core.strings.theme
|
|||
import org.meshtastic.core.strings.theme_dark
|
||||
import org.meshtastic.core.strings.theme_light
|
||||
import org.meshtastic.core.strings.theme_system
|
||||
import org.meshtastic.core.strings.use_homoglyph_characters_encoding
|
||||
import org.meshtastic.core.ui.component.DropDownPreference
|
||||
import org.meshtastic.core.ui.component.ListItem
|
||||
import org.meshtastic.core.ui.component.MainAppBar
|
||||
|
|
@ -315,6 +317,15 @@ fun SettingsScreen(
|
|||
onClick = { settingsViewModel.setProvideLocation(!provideLocation) },
|
||||
)
|
||||
|
||||
val homoglyphEncodingEnabled by
|
||||
viewModel.homoglyphEncodingEnabledFlow.collectAsStateWithLifecycle(false)
|
||||
SwitchListItem(
|
||||
text = stringResource(Res.string.use_homoglyph_characters_encoding),
|
||||
checked = homoglyphEncodingEnabled,
|
||||
leadingIcon = Icons.Default.Abc,
|
||||
onClick = { viewModel.toggleHomoglyphCharactersEncodingEnabled() },
|
||||
)
|
||||
|
||||
val settingsLauncher =
|
||||
rememberLauncherForActivityResult(contract = ActivityResultContracts.StartActivityForResult()) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ import org.meshtastic.core.model.Position
|
|||
import org.meshtastic.core.model.util.toChannelSet
|
||||
import org.meshtastic.core.navigation.SettingsRoutes
|
||||
import org.meshtastic.core.prefs.analytics.AnalyticsPrefs
|
||||
import org.meshtastic.core.prefs.homoglyph.HomoglyphPrefs
|
||||
import org.meshtastic.core.prefs.map.MapConsentPrefs
|
||||
import org.meshtastic.core.service.ConnectionState
|
||||
import org.meshtastic.core.service.IMeshService
|
||||
|
|
@ -117,6 +118,7 @@ constructor(
|
|||
private val locationRepository: LocationRepository,
|
||||
private val mapConsentPrefs: MapConsentPrefs,
|
||||
private val analyticsPrefs: AnalyticsPrefs,
|
||||
private val homoglyphEncodingPrefs: HomoglyphPrefs,
|
||||
) : ViewModel() {
|
||||
private val meshService: IMeshService?
|
||||
get() = serviceRepository.meshService
|
||||
|
|
@ -127,6 +129,12 @@ constructor(
|
|||
analyticsPrefs.analyticsAllowed = !analyticsPrefs.analyticsAllowed
|
||||
}
|
||||
|
||||
val homoglyphEncodingEnabledFlow = homoglyphEncodingPrefs.getHomoglyphEncodingEnabledChangesFlow()
|
||||
|
||||
fun toggleHomoglyphCharactersEncodingEnabled() {
|
||||
homoglyphEncodingPrefs.homoglyphEncodingEnabled = !homoglyphEncodingPrefs.homoglyphEncodingEnabled
|
||||
}
|
||||
|
||||
private val destNum =
|
||||
savedStateHandle.get<Int>("destNum")
|
||||
?: runCatching { savedStateHandle.toRoute<SettingsRoutes.Settings>().destNum }.getOrNull()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue