Adds a simplified version to the UI.

This commit is contained in:
Vitor Pamplona 2024-03-12 15:50:15 -04:00
parent 6ff5787e60
commit e5d4b2a145
5 changed files with 66 additions and 10 deletions

View File

@ -34,6 +34,7 @@ data class Settings(
val automaticallyShowProfilePictures: ConnectivityType = ConnectivityType.ALWAYS,
val dontShowPushNotificationSelector: Boolean = false,
val dontAskForNotificationPermissions: Boolean = false,
val featureSet: FeatureSetType = FeatureSetType.COMPLETE,
)
enum class ThemeType(val screenCode: Int, val resourceId: Int) {
@ -59,6 +60,11 @@ enum class ConnectivityType(val prefCode: Boolean?, val screenCode: Int, val res
NEVER(false, 2, R.string.connectivity_type_never),
}
enum class FeatureSetType(val screenCode: Int, val resourceId: Int) {
COMPLETE(0, R.string.ui_feature_set_type_complete),
SIMPLIFIED(1, R.string.ui_feature_set_type_simplified),
}
fun parseConnectivityType(code: Boolean?): ConnectivityType {
return when (code) {
ConnectivityType.ALWAYS.prefCode -> ConnectivityType.ALWAYS
@ -81,6 +87,16 @@ fun parseConnectivityType(screenCode: Int): ConnectivityType {
}
}
fun parseFeatureSetType(screenCode: Int): FeatureSetType {
return when (screenCode) {
FeatureSetType.COMPLETE.screenCode -> FeatureSetType.COMPLETE
FeatureSetType.SIMPLIFIED.screenCode -> FeatureSetType.SIMPLIFIED
else -> {
FeatureSetType.COMPLETE
}
}
}
enum class BooleanType(val prefCode: Boolean?, val screenCode: Int, val reourceId: Int) {
ALWAYS(null, 0, R.string.connectivity_type_always),
NEVER(false, 1, R.string.connectivity_type_never),

View File

@ -58,6 +58,7 @@ import androidx.lifecycle.map
import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.model.AddressableNote
import com.vitorpamplona.amethyst.model.Channel
import com.vitorpamplona.amethyst.model.FeatureSetType
import com.vitorpamplona.amethyst.model.Note
import com.vitorpamplona.amethyst.ui.components.GenericLoadable
import com.vitorpamplona.amethyst.ui.components.ObserveDisplayNip05Status
@ -665,10 +666,8 @@ fun InnerNoteWithReactions(
Column(Modifier.fillMaxWidth()) {
val showSecondRow =
baseNote.event !is RepostEvent &&
baseNote.event !is GenericRepostEvent &&
!isBoostedNote &&
!isQuotedNote
baseNote.event !is RepostEvent && baseNote.event !is GenericRepostEvent &&
!isBoostedNote && !isQuotedNote && accountViewModel.settings.featureSet != FeatureSetType.SIMPLIFIED
NoteBody(
baseNote = baseNote,
showAuthorPicture = isQuotedNote,
@ -1234,10 +1233,12 @@ private fun BadgeBox(
accountViewModel: AccountViewModel,
nav: (String) -> Unit,
) {
if (baseNote.event is RepostEvent || baseNote.event is GenericRepostEvent) {
baseNote.replyTo?.lastOrNull()?.let { RelayBadges(it, accountViewModel, nav) }
} else {
RelayBadges(baseNote, accountViewModel, nav)
if (accountViewModel.settings.featureSet != FeatureSetType.SIMPLIFIED) {
if (baseNote.event is RepostEvent || baseNote.event is GenericRepostEvent) {
baseNote.replyTo?.lastOrNull()?.let { RelayBadges(it, accountViewModel, nav) }
} else {
RelayBadges(baseNote, accountViewModel, nav)
}
}
}

View File

@ -35,6 +35,7 @@ import androidx.window.layout.DisplayFeature
import com.vitorpamplona.amethyst.LocalPreferences
import com.vitorpamplona.amethyst.model.BooleanType
import com.vitorpamplona.amethyst.model.ConnectivityType
import com.vitorpamplona.amethyst.model.FeatureSetType
import com.vitorpamplona.amethyst.model.Settings
import com.vitorpamplona.amethyst.model.ThemeType
import kotlinx.coroutines.Dispatchers
@ -52,6 +53,7 @@ class SettingsState() {
var automaticallyShowProfilePictures by mutableStateOf(ConnectivityType.ALWAYS)
var dontShowPushNotificationSelector by mutableStateOf<Boolean>(false)
var dontAskForNotificationPermissions by mutableStateOf<Boolean>(false)
var featureSet by mutableStateOf(FeatureSetType.COMPLETE)
var isOnMobileData: State<Boolean> = mutableStateOf(false)
@ -113,8 +115,8 @@ class SharedPreferencesViewModel : ViewModel() {
sharedPrefs.automaticallyHideNavigationBars = savedSettings.automaticallyHideNavigationBars
sharedPrefs.automaticallyShowProfilePictures = savedSettings.automaticallyShowProfilePictures
sharedPrefs.dontShowPushNotificationSelector = savedSettings.dontShowPushNotificationSelector
sharedPrefs.dontAskForNotificationPermissions =
savedSettings.dontAskForNotificationPermissions
sharedPrefs.dontAskForNotificationPermissions = savedSettings.dontAskForNotificationPermissions
sharedPrefs.featureSet = savedSettings.featureSet
updateLanguageInTheUI()
}
@ -181,6 +183,13 @@ class SharedPreferencesViewModel : ViewModel() {
}
}
fun updateFeatureSetType(newFeatureSetType: FeatureSetType) {
if (sharedPrefs.featureSet != newFeatureSetType) {
sharedPrefs.featureSet = newFeatureSetType
saveSharedSettings()
}
}
fun dontShowPushNotificationSelector() {
if (sharedPrefs.dontShowPushNotificationSelector == false) {
sharedPrefs.dontShowPushNotificationSelector = true
@ -226,6 +235,7 @@ class SharedPreferencesViewModel : ViewModel() {
sharedPrefs.automaticallyShowProfilePictures,
sharedPrefs.dontShowPushNotificationSelector,
sharedPrefs.dontAskForNotificationPermissions,
sharedPrefs.featureSet,
),
)
}

View File

@ -47,9 +47,11 @@ import androidx.compose.ui.unit.dp
import androidx.core.os.LocaleListCompat
import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.model.ConnectivityType
import com.vitorpamplona.amethyst.model.FeatureSetType
import com.vitorpamplona.amethyst.model.ThemeType
import com.vitorpamplona.amethyst.model.parseBooleanType
import com.vitorpamplona.amethyst.model.parseConnectivityType
import com.vitorpamplona.amethyst.model.parseFeatureSetType
import com.vitorpamplona.amethyst.model.parseThemeType
import com.vitorpamplona.amethyst.ui.components.PushNotificationSettingsRow
import com.vitorpamplona.amethyst.ui.screen.SharedPreferencesViewModel
@ -141,6 +143,12 @@ fun SettingsScreen(sharedPreferencesViewModel: SharedPreferencesViewModel) {
TitleExplainer(stringResource(ConnectivityType.NEVER.resourceId)),
)
val featureItems =
persistentListOf(
TitleExplainer(stringResource(FeatureSetType.COMPLETE.resourceId)),
TitleExplainer(stringResource(FeatureSetType.SIMPLIFIED.resourceId)),
)
val showImagesIndex = sharedPreferencesViewModel.sharedPrefs.automaticallyShowImages.screenCode
val videoIndex = sharedPreferencesViewModel.sharedPrefs.automaticallyStartPlayback.screenCode
val linkIndex = sharedPreferencesViewModel.sharedPrefs.automaticallyShowUrlPreview.screenCode
@ -156,6 +164,9 @@ fun SettingsScreen(sharedPreferencesViewModel: SharedPreferencesViewModel) {
val languageList = remember { languageEntries.keys.map { TitleExplainer(it) }.toImmutableList() }
val languageIndex = getLanguageIndex(languageEntries, sharedPreferencesViewModel)
val featureSetIndex =
sharedPreferencesViewModel.sharedPrefs.featureSet.screenCode
Column(
Modifier.fillMaxSize()
.padding(top = Size10dp, start = Size20dp, end = Size20dp)
@ -237,6 +248,17 @@ fun SettingsScreen(sharedPreferencesViewModel: SharedPreferencesViewModel) {
Spacer(modifier = HalfVertSpacer)
SettingsRow(
R.string.ui_style,
R.string.ui_style_description,
featureItems,
featureSetIndex,
) {
sharedPreferencesViewModel.updateFeatureSetType(parseFeatureSetType(it))
}
Spacer(modifier = HalfVertSpacer)
PushNotificationSettingsRow(sharedPreferencesViewModel)
}
}

View File

@ -505,6 +505,9 @@
<string name="connectivity_type_wifi_only">Wifi-only</string>
<string name="connectivity_type_never">Never</string>
<string name="ui_feature_set_type_complete">Complete</string>
<string name="ui_feature_set_type_simplified">Simplified</string>
<string name="system">System</string>
<string name="light">Light</string>
<string name="dark">Dark</string>
@ -516,6 +519,10 @@
<string name="automatically_show_url_preview">URL Preview</string>
<string name="automatically_hide_nav_bars">Immersive Scrolling</string>
<string name="automatically_hide_nav_bars_description">Hide Nav Bars when Scrolling</string>
<string name="ui_style">UI Mode</string>
<string name="ui_style_description">Choose the post style</string>
<string name="load_image">Load Image</string>
<string name="spamming_users">Spammers</string>