mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-03-17 21:31:57 +01:00
Merge branch 'main' of https://github.com/vitorpamplona/amethyst
# Conflicts: # amethyst/src/main/res/values-uz-rUZ/strings.xml
This commit is contained in:
commit
9f465d3296
@ -1863,6 +1863,21 @@ object LocalCache {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Will return true if supplied note is one of events to be excluded from
|
||||
* search results.
|
||||
*/
|
||||
private fun excludeNoteEventFromSearchResults(note: Note): Boolean =
|
||||
(
|
||||
note.event is GenericRepostEvent ||
|
||||
note.event is RepostEvent ||
|
||||
note.event is CommunityPostApprovalEvent ||
|
||||
note.event is ReactionEvent ||
|
||||
note.event is LnZapEvent ||
|
||||
note.event is LnZapRequestEvent ||
|
||||
note.event is FileHeaderEvent
|
||||
)
|
||||
|
||||
fun findNotesStartingWith(
|
||||
text: String,
|
||||
forAccount: Account,
|
||||
@ -1873,19 +1888,13 @@ object LocalCache {
|
||||
|
||||
if (key != null) {
|
||||
val note = getNoteIfExists(key)
|
||||
if (note != null) {
|
||||
if ((note != null) && !excludeNoteEventFromSearchResults(note)) {
|
||||
return listOfNotNull(note)
|
||||
}
|
||||
}
|
||||
|
||||
return notes.filter { _, note ->
|
||||
if (note.event is GenericRepostEvent ||
|
||||
note.event is RepostEvent ||
|
||||
note.event is CommunityPostApprovalEvent ||
|
||||
note.event is ReactionEvent ||
|
||||
note.event is LnZapEvent ||
|
||||
note.event is LnZapRequestEvent
|
||||
) {
|
||||
if (excludeNoteEventFromSearchResults(note)) {
|
||||
return@filter false
|
||||
}
|
||||
|
||||
@ -1910,13 +1919,7 @@ object LocalCache {
|
||||
return@filter false
|
||||
} +
|
||||
addressables.filter { _, addressable ->
|
||||
if (addressable.event is GenericRepostEvent ||
|
||||
addressable.event is RepostEvent ||
|
||||
addressable.event is CommunityPostApprovalEvent ||
|
||||
addressable.event is ReactionEvent ||
|
||||
addressable.event is LnZapEvent ||
|
||||
addressable.event is LnZapRequestEvent
|
||||
) {
|
||||
if (excludeNoteEventFromSearchResults(addressable)) {
|
||||
return@filter false
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@ data class Settings(
|
||||
val dontShowPushNotificationSelector: Boolean = false,
|
||||
val dontAskForNotificationPermissions: Boolean = false,
|
||||
val featureSet: FeatureSetType = FeatureSetType.SIMPLIFIED,
|
||||
val gallerySet: ProfileGalleryType = ProfileGalleryType.CLASSIC,
|
||||
)
|
||||
|
||||
enum class ThemeType(
|
||||
@ -75,6 +76,14 @@ enum class FeatureSetType(
|
||||
PERFORMANCE(2, R.string.ui_feature_set_type_performance),
|
||||
}
|
||||
|
||||
enum class ProfileGalleryType(
|
||||
val screenCode: Int,
|
||||
val resourceId: Int,
|
||||
) {
|
||||
CLASSIC(0, R.string.gallery_type_classic),
|
||||
MODERN(1, R.string.gallery_type_modern),
|
||||
}
|
||||
|
||||
fun parseConnectivityType(code: Boolean?): ConnectivityType =
|
||||
when (code) {
|
||||
ConnectivityType.ALWAYS.prefCode -> ConnectivityType.ALWAYS
|
||||
@ -105,6 +114,15 @@ fun parseFeatureSetType(screenCode: Int): FeatureSetType =
|
||||
}
|
||||
}
|
||||
|
||||
fun parseGalleryType(screenCode: Int): ProfileGalleryType =
|
||||
when (screenCode) {
|
||||
ProfileGalleryType.CLASSIC.screenCode -> ProfileGalleryType.CLASSIC
|
||||
ProfileGalleryType.MODERN.screenCode -> ProfileGalleryType.MODERN
|
||||
else -> {
|
||||
ProfileGalleryType.CLASSIC
|
||||
}
|
||||
}
|
||||
|
||||
enum class BooleanType(
|
||||
val prefCode: Boolean?,
|
||||
val screenCode: Int,
|
||||
|
@ -38,6 +38,7 @@ 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.ProfileGalleryType
|
||||
import com.vitorpamplona.amethyst.model.Settings
|
||||
import com.vitorpamplona.amethyst.model.ThemeType
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@ -56,6 +57,7 @@ class SettingsState {
|
||||
var dontShowPushNotificationSelector by mutableStateOf<Boolean>(false)
|
||||
var dontAskForNotificationPermissions by mutableStateOf<Boolean>(false)
|
||||
var featureSet by mutableStateOf(FeatureSetType.SIMPLIFIED)
|
||||
var gallerySet by mutableStateOf(ProfileGalleryType.CLASSIC)
|
||||
|
||||
var isOnMobileData: State<Boolean> = mutableStateOf(false)
|
||||
|
||||
@ -71,6 +73,14 @@ class SettingsState {
|
||||
}
|
||||
}
|
||||
|
||||
val modernGalleryStyle =
|
||||
derivedStateOf {
|
||||
when (gallerySet) {
|
||||
ProfileGalleryType.CLASSIC -> false
|
||||
ProfileGalleryType.MODERN -> true
|
||||
}
|
||||
}
|
||||
|
||||
val showUrlPreview =
|
||||
derivedStateOf {
|
||||
when (automaticallyShowUrlPreview) {
|
||||
@ -117,6 +127,7 @@ class SharedPreferencesViewModel : ViewModel() {
|
||||
sharedPrefs.automaticallyShowProfilePictures = savedSettings.automaticallyShowProfilePictures
|
||||
sharedPrefs.dontShowPushNotificationSelector = savedSettings.dontShowPushNotificationSelector
|
||||
sharedPrefs.dontAskForNotificationPermissions = savedSettings.dontAskForNotificationPermissions
|
||||
sharedPrefs.gallerySet = savedSettings.gallerySet
|
||||
sharedPrefs.featureSet = savedSettings.featureSet
|
||||
|
||||
updateLanguageInTheUI()
|
||||
@ -191,6 +202,13 @@ class SharedPreferencesViewModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
fun updateGallerySetType(newgalleryType: ProfileGalleryType) {
|
||||
if (sharedPrefs.gallerySet != newgalleryType) {
|
||||
sharedPrefs.gallerySet = newgalleryType
|
||||
saveSharedSettings()
|
||||
}
|
||||
}
|
||||
|
||||
fun dontShowPushNotificationSelector() {
|
||||
if (sharedPrefs.dontShowPushNotificationSelector == false) {
|
||||
sharedPrefs.dontShowPushNotificationSelector = true
|
||||
@ -237,6 +255,7 @@ class SharedPreferencesViewModel : ViewModel() {
|
||||
sharedPrefs.dontShowPushNotificationSelector,
|
||||
sharedPrefs.dontAskForNotificationPermissions,
|
||||
sharedPrefs.featureSet,
|
||||
sharedPrefs.gallerySet,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ fun GalleryCardCompose(
|
||||
modifier: Modifier = Modifier,
|
||||
accountViewModel: AccountViewModel,
|
||||
nav: INav,
|
||||
ratio: Float = 1.0f,
|
||||
) {
|
||||
WatchNoteEvent(baseNote = baseNote, accountViewModel = accountViewModel, shortPreview = true) {
|
||||
CheckHiddenFeedWatchBlockAndReport(
|
||||
@ -74,6 +75,7 @@ fun GalleryCardCompose(
|
||||
modifier = modifier,
|
||||
accountViewModel = accountViewModel,
|
||||
nav = nav,
|
||||
ratio = ratio,
|
||||
)
|
||||
} else {
|
||||
RedirectableGalleryCard(
|
||||
@ -82,6 +84,7 @@ fun GalleryCardCompose(
|
||||
modifier = modifier,
|
||||
accountViewModel = accountViewModel,
|
||||
nav = nav,
|
||||
ratio = ratio,
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -92,6 +95,7 @@ fun GalleryCardCompose(
|
||||
modifier = modifier,
|
||||
accountViewModel = accountViewModel,
|
||||
nav = nav,
|
||||
ratio = ratio,
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -105,6 +109,7 @@ fun RedirectableGalleryCard(
|
||||
modifier: Modifier = Modifier,
|
||||
accountViewModel: AccountViewModel,
|
||||
nav: INav,
|
||||
ratio: Float = 1.0f,
|
||||
) {
|
||||
QuickActionGallery(baseNote = galleryNote, accountViewModel = accountViewModel) { showPopup ->
|
||||
ClickableNote(
|
||||
@ -123,7 +128,7 @@ fun RedirectableGalleryCard(
|
||||
note = galleryNote,
|
||||
accountViewModel = accountViewModel,
|
||||
) {
|
||||
GalleryThumbnail(galleryNote, accountViewModel, nav)
|
||||
GalleryThumbnail(galleryNote, accountViewModel, nav, ratio = ratio)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ fun GalleryThumbnail(
|
||||
baseNote: Note,
|
||||
accountViewModel: AccountViewModel,
|
||||
nav: INav,
|
||||
ratio: Float = 1.0f,
|
||||
) {
|
||||
val noteState by baseNote.live().metadata.observeAsState()
|
||||
val noteEvent = noteState?.note?.event ?: return
|
||||
@ -134,7 +135,7 @@ fun GalleryThumbnail(
|
||||
emptyList()
|
||||
}
|
||||
|
||||
InnerRenderGalleryThumb(content, baseNote, accountViewModel)
|
||||
InnerRenderGalleryThumb(content, baseNote, accountViewModel, ratio)
|
||||
}
|
||||
|
||||
@Composable
|
||||
@ -142,9 +143,10 @@ fun InnerRenderGalleryThumb(
|
||||
content: List<MediaUrlContent>,
|
||||
note: Note,
|
||||
accountViewModel: AccountViewModel,
|
||||
ratio: Float = 1.0f,
|
||||
) {
|
||||
if (content.isNotEmpty()) {
|
||||
GalleryContentView(content, accountViewModel)
|
||||
GalleryContentView(content, accountViewModel, ratio = ratio)
|
||||
} else {
|
||||
DisplayGalleryAuthorBanner(note)
|
||||
}
|
||||
@ -162,16 +164,17 @@ fun DisplayGalleryAuthorBanner(note: Note) {
|
||||
fun GalleryContentView(
|
||||
contentList: List<MediaUrlContent>,
|
||||
accountViewModel: AccountViewModel,
|
||||
ratio: Float = 1.0f,
|
||||
) {
|
||||
AutoNonlazyGrid(contentList.size) { contentIndex ->
|
||||
when (val content = contentList[contentIndex]) {
|
||||
is MediaUrlImage ->
|
||||
SensitivityWarning(content.contentWarning != null, accountViewModel) {
|
||||
UrlImageView(content, accountViewModel)
|
||||
UrlImageView(content, accountViewModel, ratio = ratio)
|
||||
}
|
||||
is MediaUrlVideo ->
|
||||
SensitivityWarning(content.contentWarning != null, accountViewModel) {
|
||||
UrlVideoView(content, accountViewModel)
|
||||
UrlVideoView(content, accountViewModel, ratio = ratio)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -182,8 +185,9 @@ fun UrlImageView(
|
||||
content: MediaUrlImage,
|
||||
accountViewModel: AccountViewModel,
|
||||
alwayShowImage: Boolean = false,
|
||||
ratio: Float = 1.0f,
|
||||
) {
|
||||
val defaultModifier = Modifier.fillMaxSize().aspectRatio(1f)
|
||||
val defaultModifier = Modifier.fillMaxSize().aspectRatio(ratio)
|
||||
|
||||
val showImage =
|
||||
remember {
|
||||
@ -250,8 +254,9 @@ fun UrlImageView(
|
||||
fun UrlVideoView(
|
||||
content: MediaUrlVideo,
|
||||
accountViewModel: AccountViewModel,
|
||||
ratio: Float = 1.0f,
|
||||
) {
|
||||
val defaultModifier = Modifier.fillMaxSize().aspectRatio(1f)
|
||||
val defaultModifier = Modifier.fillMaxSize().aspectRatio(ratio)
|
||||
|
||||
val automaticallyStartPlayback =
|
||||
remember(content) {
|
||||
|
@ -33,6 +33,7 @@ import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.vitorpamplona.amethyst.ui.actions.CrossfadeIfEnabled
|
||||
import com.vitorpamplona.amethyst.ui.feeds.FeedEmpty
|
||||
import com.vitorpamplona.amethyst.ui.feeds.FeedError
|
||||
@ -40,6 +41,7 @@ import com.vitorpamplona.amethyst.ui.feeds.FeedState
|
||||
import com.vitorpamplona.amethyst.ui.feeds.LoadingFeed
|
||||
import com.vitorpamplona.amethyst.ui.navigation.INav
|
||||
import com.vitorpamplona.amethyst.ui.screen.FeedViewModel
|
||||
import com.vitorpamplona.amethyst.ui.screen.SharedPreferencesViewModel
|
||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||
import com.vitorpamplona.amethyst.ui.theme.FeedPadding
|
||||
|
||||
@ -87,6 +89,14 @@ private fun GalleryFeedLoaded(
|
||||
nav: INav,
|
||||
) {
|
||||
val items by loaded.feed.collectAsStateWithLifecycle()
|
||||
val sharedPreferencesViewModel: SharedPreferencesViewModel = viewModel()
|
||||
|
||||
sharedPreferencesViewModel.init()
|
||||
|
||||
var ratio = 1.0f
|
||||
if (sharedPreferencesViewModel.sharedPrefs.modernGalleryStyle.value) {
|
||||
ratio = 0.8f
|
||||
}
|
||||
|
||||
LazyVerticalGrid(
|
||||
columns = GridCells.Fixed(3),
|
||||
@ -100,11 +110,12 @@ private fun GalleryFeedLoaded(
|
||||
baseNote = item,
|
||||
modifier =
|
||||
Modifier
|
||||
.aspectRatio(1f)
|
||||
.aspectRatio(ratio)
|
||||
.fillMaxSize()
|
||||
.animateItem(),
|
||||
accountViewModel = accountViewModel,
|
||||
nav = nav,
|
||||
ratio = ratio,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -48,10 +48,12 @@ 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.ProfileGalleryType
|
||||
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.parseGalleryType
|
||||
import com.vitorpamplona.amethyst.model.parseThemeType
|
||||
import com.vitorpamplona.amethyst.ui.components.PushNotificationSettingsRow
|
||||
import com.vitorpamplona.amethyst.ui.navigation.INav
|
||||
@ -187,6 +189,12 @@ fun SettingsScreen(sharedPreferencesViewModel: SharedPreferencesViewModel) {
|
||||
TitleExplainer(stringRes(FeatureSetType.PERFORMANCE.resourceId)),
|
||||
)
|
||||
|
||||
val galleryItems =
|
||||
persistentListOf(
|
||||
TitleExplainer(stringRes(ProfileGalleryType.CLASSIC.resourceId)),
|
||||
TitleExplainer(stringRes(ProfileGalleryType.MODERN.resourceId)),
|
||||
)
|
||||
|
||||
val showImagesIndex = sharedPreferencesViewModel.sharedPrefs.automaticallyShowImages.screenCode
|
||||
val videoIndex = sharedPreferencesViewModel.sharedPrefs.automaticallyStartPlayback.screenCode
|
||||
val linkIndex = sharedPreferencesViewModel.sharedPrefs.automaticallyShowUrlPreview.screenCode
|
||||
@ -204,6 +212,8 @@ fun SettingsScreen(sharedPreferencesViewModel: SharedPreferencesViewModel) {
|
||||
|
||||
val featureSetIndex =
|
||||
sharedPreferencesViewModel.sharedPrefs.featureSet.screenCode
|
||||
val galleryIndex =
|
||||
sharedPreferencesViewModel.sharedPrefs.gallerySet.screenCode
|
||||
|
||||
Column(
|
||||
Modifier
|
||||
@ -295,9 +305,19 @@ fun SettingsScreen(sharedPreferencesViewModel: SharedPreferencesViewModel) {
|
||||
) {
|
||||
sharedPreferencesViewModel.updateFeatureSetType(parseFeatureSetType(it))
|
||||
}
|
||||
Spacer(modifier = HalfVertSpacer)
|
||||
|
||||
Spacer(modifier = HalfVertSpacer)
|
||||
|
||||
SettingsRow(
|
||||
R.string.gallery_style,
|
||||
R.string.gallery_style_description,
|
||||
galleryItems,
|
||||
galleryIndex,
|
||||
) {
|
||||
sharedPreferencesViewModel.updateGallerySetType(parseGalleryType(it))
|
||||
}
|
||||
|
||||
PushNotificationSettingsRow(sharedPreferencesViewModel)
|
||||
}
|
||||
}
|
||||
|
@ -104,6 +104,7 @@
|
||||
<string name="website_url">ওয়েবসাইটের URL</string>
|
||||
<string name="ln_address">বিজলি-ঠিকানা</string>
|
||||
<string name="ln_url_outdated">বিজলি URL (অপ্রচলিত)</string>
|
||||
<string name="save_to_gallery">গ্যালারিতে সংরক্ষণ করুন</string>
|
||||
<string name="image_saved_to_the_gallery">ছবিটি গ্যালারিতে সংরক্ষণ করা হয়েছে</string>
|
||||
<string name="failed_to_save_the_image">ছবিটি সফলভাবে সংরক্ষণ করা যায় নি</string>
|
||||
<string name="upload_image">ছবিটি আপলোড করুন</string>
|
||||
|
@ -10,7 +10,7 @@
|
||||
<string name="post_was_flagged_as_inappropriate_by">A hozzászólás el lett némítva vagy be lett jelentve általa:</string>
|
||||
<string name="post_not_found">Az esemény épp betöltődik vagy nem található az átjátszólistában</string>
|
||||
<string name="post_not_found_short">👀</string>
|
||||
<string name="channel_image">Csatornakép</string>
|
||||
<string name="channel_image">Csatorna profilképe</string>
|
||||
<string name="referenced_event_not_found">A hivatkozott esemény nem található</string>
|
||||
<string name="could_not_decrypt_the_message">Nem sikerült visszafejteni az üzenetet</string>
|
||||
<string name="group_picture">Csoport profilképe</string>
|
||||
@ -53,7 +53,7 @@
|
||||
<string name="zaps">Zap</string>
|
||||
<string name="view_count">Megtekintések száma</string>
|
||||
<string name="boost">Megtolás</string>
|
||||
<string name="boosted">Megtolva</string>
|
||||
<string name="boosted">megtolta</string>
|
||||
<string name="edited">szerkesztve</string>
|
||||
<string name="edited_number">#%1$s szerkesztése</string>
|
||||
<string name="original">eredeti</string>
|
||||
|
@ -1,2 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources></resources>
|
||||
<resources>
|
||||
<string name="point_to_the_qr_code">Kamerani QR kodga yo\'naltiring</string>
|
||||
<string name="show_qr">QR kodni ko‘rsatish</string>
|
||||
<string name="profile_image">Profil rasmini</string>
|
||||
<string name="your_profile_image">Sizning profil rasmingiz</string>
|
||||
<string name="scan_qr">QR kodni skanerlang</string>
|
||||
<string name="show_anyway">Baribir postni ko‘rsat</string>
|
||||
<string name="post_was_hidden">Ushbu post yashirilgan, chunki u siz yashirgan foydalanuvchilar yoki so\'zlarni eslatadi</string>
|
||||
<string name="post_was_flagged_as_inappropriate_by">Post ________ tomonidan bloklangan yoki xabar qilingan</string>
|
||||
<string name="post_not_found">Post yuklanmoqda yoki estafetalar ro‘yxatingizda topilmadi</string>
|
||||
<string name="post_not_found_short">👀</string>
|
||||
<string name="channel_image">Kanal rasmi</string>
|
||||
<string name="referenced_event_not_found">Havola qilingan post topilmadi</string>
|
||||
<string name="could_not_decrypt_the_message">Xabarni shifrdan chiqarib bo\'lmadi</string>
|
||||
<string name="group_picture">Guruh rasmi</string>
|
||||
<string name="explicit_content"></string>
|
||||
</resources>
|
||||
|
@ -634,6 +634,9 @@
|
||||
<string name="ui_feature_set_type_simplified">Simplified</string>
|
||||
<string name="ui_feature_set_type_performance">Performance</string>
|
||||
|
||||
<string name="gallery_type_classic">Classic</string>
|
||||
<string name="gallery_type_modern">Modern</string>
|
||||
|
||||
<string name="system">System</string>
|
||||
<string name="light">Light</string>
|
||||
<string name="dark">Dark</string>
|
||||
@ -650,6 +653,9 @@
|
||||
<string name="ui_style">UI Mode</string>
|
||||
<string name="ui_style_description">Choose the post style</string>
|
||||
|
||||
<string name="gallery_style">Profile Gallery Style</string>
|
||||
<string name="gallery_style_description">Choose the gallery style</string>
|
||||
|
||||
<string name="load_image">Load Image</string>
|
||||
|
||||
<string name="spamming_users">Spammers</string>
|
||||
|
@ -1,7 +1,7 @@
|
||||
[versions]
|
||||
accompanistAdaptive = "0.37.0"
|
||||
activityCompose = "1.9.3"
|
||||
agp = "8.7.3"
|
||||
agp = "8.8.0"
|
||||
android-compileSdk = "35"
|
||||
android-minSdk = "26"
|
||||
android-targetSdk = "35"
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
||||
#Wed Jan 04 09:23:50 EST 2023
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
Loading…
x
Reference in New Issue
Block a user