diff --git a/amity-uikit/build.gradle b/amity-uikit/build.gradle index 8d2a14d6..2d350e58 100644 --- a/amity-uikit/build.gradle +++ b/amity-uikit/build.gradle @@ -22,5 +22,5 @@ dependencies { api project(path: ':social') api project(path: ':chat') - api "co.amity.android:amity-sdk:$amityMessagingSdkVersion" + api "$amitySDKDependency:amity-sdk:$amityMessagingSdkVersion" } \ No newline at end of file diff --git a/buildsystem/activity.gradle b/buildsystem/activity.gradle index 5459ba46..47d93b91 100755 --- a/buildsystem/activity.gradle +++ b/buildsystem/activity.gradle @@ -42,7 +42,7 @@ dependencies { // Glide dependencide implementation 'com.github.bumptech.glide:glide:4.12.0' kapt 'com.github.bumptech.glide:compiler:4.12.0' - api "co.amity.android:amity-sdk:$amityMessagingSdkVersion" + api "$amitySDKDependency:amity-sdk:$amityMessagingSdkVersion" implementation 'com.github.chrisbanes:PhotoView:2.3.0' } diff --git a/buildsystem/dependencies.gradle b/buildsystem/dependencies.gradle index 8ec5e5d5..fbe1b829 100644 --- a/buildsystem/dependencies.gradle +++ b/buildsystem/dependencies.gradle @@ -10,7 +10,10 @@ buildscript { amityKotlinVersion = "1.6.20" amityLifecycleExtensionVersion = "2.0.0" amityMockkVersion = "1.10.0" - amityMessagingSdkVersion = '6.45.0' + amitySDKJitpackDependency = 'com.github.AmityCo.Amity-Social-Cloud-SDK-Android' + amitySDKMavenDependency = 'co.amity.android' + amityMessagingSdkVersion = '6.46.0' + amitySDKDependency = amitySDKMavenDependency amityRxLifeCycleVersion = '1.1.2-beta01' amityJacocoVersion = '0.8.5' amityExoplayerVersion = '2.18.5' diff --git a/common-compose/src/main/java/com/amity/socialcloud/uikit/common/eventbus/AmityUIKitSnackbar.kt b/common-compose/src/main/java/com/amity/socialcloud/uikit/common/eventbus/AmityUIKitSnackbar.kt new file mode 100644 index 00000000..1295ca48 --- /dev/null +++ b/common-compose/src/main/java/com/amity/socialcloud/uikit/common/eventbus/AmityUIKitSnackbar.kt @@ -0,0 +1,16 @@ +package com.amity.socialcloud.uikit.common.eventbus + +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.SharedFlow +import kotlinx.coroutines.flow.asSharedFlow + +object AmityUIKitSnackbar { + + private val _snackbarMessage = MutableSharedFlow(1) + val snackbarMessage: SharedFlow = _snackbarMessage.asSharedFlow() + + fun publishSnackbarMessage(message: String?) { + _snackbarMessage.tryEmit(message) + } + +} \ No newline at end of file diff --git a/common-compose/src/main/java/com/amity/socialcloud/uikit/common/ui/scope/AmityComposeScopeImpl.kt b/common-compose/src/main/java/com/amity/socialcloud/uikit/common/ui/scope/AmityComposeScopeImpl.kt index 9a7b28c5..14f2a884 100644 --- a/common-compose/src/main/java/com/amity/socialcloud/uikit/common/ui/scope/AmityComposeScopeImpl.kt +++ b/common-compose/src/main/java/com/amity/socialcloud/uikit/common/ui/scope/AmityComposeScopeImpl.kt @@ -4,9 +4,11 @@ import androidx.annotation.DrawableRes import androidx.compose.material3.SnackbarHostState import com.amity.socialcloud.uikit.common.config.AmityUIKitConfig import com.amity.socialcloud.uikit.common.config.AmityUIKitConfigController +import com.amity.socialcloud.uikit.common.eventbus.AmityUIKitSnackbar import com.amity.socialcloud.uikit.common.ui.elements.AmityProgressSnackbarVisuals import com.amity.socialcloud.uikit.common.ui.elements.AmitySnackbarVisuals import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch internal class AmityComposePageScopeImpl( @@ -15,6 +17,17 @@ internal class AmityComposePageScopeImpl( private val coroutineScope: CoroutineScope, ) : AmityComposePageScope { + init { + coroutineScope.launch { + AmityUIKitSnackbar.snackbarMessage.collectLatest { message -> + if (message != null) { + showSnackbar(message) + AmityUIKitSnackbar.publishSnackbarMessage(null) + } + } + } + } + override fun getId(): String { return pageId } diff --git a/common-compose/src/main/java/com/amity/socialcloud/uikit/common/utils/AmityComposeExt.kt b/common-compose/src/main/java/com/amity/socialcloud/uikit/common/utils/AmityComposeExt.kt index f88e66b0..3e6a4247 100644 --- a/common-compose/src/main/java/com/amity/socialcloud/uikit/common/utils/AmityComposeExt.kt +++ b/common-compose/src/main/java/com/amity/socialcloud/uikit/common/utils/AmityComposeExt.kt @@ -5,6 +5,7 @@ import android.content.ContextWrapper import android.content.Intent import android.widget.Toast import androidx.activity.ComponentActivity +import androidx.annotation.StringRes import androidx.compose.animation.core.LinearEasing import androidx.compose.animation.core.RepeatMode import androidx.compose.animation.core.animateFloat @@ -20,6 +21,7 @@ import androidx.compose.foundation.layout.ime import androidx.compose.foundation.lazy.LazyItemScope import androidx.compose.foundation.lazy.LazyListScope import androidx.compose.runtime.Composable +import androidx.compose.runtime.ReadOnlyComposable import androidx.compose.runtime.State import androidx.compose.runtime.rememberUpdatedState import androidx.compose.ui.Modifier @@ -37,6 +39,8 @@ import androidx.compose.ui.layout.onGloballyPositioned import androidx.compose.ui.layout.positionInRoot import androidx.compose.ui.platform.ClipboardManager import androidx.compose.ui.platform.LocalClipboardManager +import androidx.compose.ui.platform.LocalConfiguration +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.TextStyle @@ -48,6 +52,7 @@ import androidx.palette.graphics.Palette.Swatch import com.amity.socialcloud.uikit.common.common.toDp import com.amity.socialcloud.uikit.common.common.views.AmityColorPaletteUtil import com.amity.socialcloud.uikit.common.common.views.AmityColorShade +import com.amity.socialcloud.uikit.common.compose.R import com.amity.socialcloud.uikit.common.ui.theme.AmityTheme import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.emptyFlow @@ -226,4 +231,23 @@ fun measureTextWidth(text: String, style: TextStyle): Dp { val textMeasurer = rememberTextMeasurer() val widthInPixels = textMeasurer.measure(text, style).size.width return with(LocalDensity.current) { widthInPixels.toDp() } +} + +@Composable +@ReadOnlyComposable +fun amityStringResource( + configString: String = "", + @StringRes id: Int = R.string.empty_string, +): String { + LocalConfiguration.current + val resources = LocalContext.current.resources + return configString.ifEmpty { resources.getString(id) } +} + +fun Context.amityStringResource( + configString: String = "", + @StringRes id: Int = R.string.empty_string, +): String { + val resources = this.resources + return configString.ifEmpty { resources.getString(id) } } \ No newline at end of file diff --git a/common-compose/src/main/res/values/strings.xml b/common-compose/src/main/res/values/strings.xml new file mode 100644 index 00000000..a59b234d --- /dev/null +++ b/common-compose/src/main/res/values/strings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/sample/build.gradle b/sample/build.gradle index b077411a..4f915af6 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -87,7 +87,7 @@ dependencies { implementation 'com.afollestad.material-dialogs:core:3.3.0' implementation 'com.afollestad.material-dialogs:input:3.3.0' - implementation "co.amity.android:amity-push-fcm:$amityMessagingSdkVersion" + implementation "$amitySDKDependency:amity-push-fcm:$amityMessagingSdkVersion" implementation 'androidx.activity:activity-compose:1.7.0' diff --git a/social-compose/build.gradle b/social-compose/build.gradle index 5f3e1261..5bf8ba79 100644 --- a/social-compose/build.gradle +++ b/social-compose/build.gradle @@ -41,6 +41,6 @@ dependencies { implementation "androidx.camera:camera-view:1.2.2" implementation "androidx.camera:camera-extensions:1.2.2" - implementation("co.amity.android:amity-video-publisher:$amityMessagingSdkVersion") - implementation("co.amity.android:amity-video-player:$amityMessagingSdkVersion") + implementation("$amitySDKDependency:amity-video-publisher:$amityMessagingSdkVersion") + implementation("$amitySDKDependency:amity-video-player:$amityMessagingSdkVersion") } \ No newline at end of file diff --git a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/membership/element/AmityCommunityJoinButton.kt b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/membership/element/AmityCommunityJoinButton.kt index 170c6967..8e21536f 100644 --- a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/membership/element/AmityCommunityJoinButton.kt +++ b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/membership/element/AmityCommunityJoinButton.kt @@ -43,10 +43,10 @@ fun AmityCommunityJoinButton( modifier: Modifier = Modifier, community: AmityCommunity, ) { - var isJoined by remember { + var isJoined by remember(community.getCommunityId()) { mutableStateOf(community.isJoined()) } - var isInProgress by remember { + var isInProgress by remember(community.getCommunityId()) { mutableStateOf(false) } diff --git a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/profile/AmityCommunityProfilePage.kt b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/profile/AmityCommunityProfilePage.kt index 2eff3e65..fac4c0fd 100644 --- a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/profile/AmityCommunityProfilePage.kt +++ b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/profile/AmityCommunityProfilePage.kt @@ -35,6 +35,7 @@ import androidx.compose.ui.unit.dp import androidx.paging.LoadState import androidx.paging.compose.collectAsLazyPagingItems import com.amity.socialcloud.sdk.api.core.AmityCoreClient +import com.amity.socialcloud.sdk.api.social.AmitySocialClient import com.amity.socialcloud.sdk.helper.core.coroutines.asFlow import com.amity.socialcloud.sdk.model.core.permission.AmityPermission import com.amity.socialcloud.sdk.model.social.community.AmityCommunityPostSettings @@ -58,6 +59,7 @@ import com.amity.socialcloud.uikit.community.compose.paging.feed.community.amity import com.amity.socialcloud.uikit.community.compose.post.detail.AmityPostCategory import com.amity.socialcloud.uikit.community.compose.post.detail.components.AmityPostShimmer import kotlinx.coroutines.flow.catch +import kotlinx.coroutines.flow.map @OptIn(ExperimentalMaterialApi::class, ExperimentalFoundationApi::class) @SuppressLint("UnrememberedMutableState") @@ -106,6 +108,51 @@ fun AmityCommunityProfilePage( } .collectAsState(initial = false) + val hasManageStoryPermission by AmityCoreClient.hasPermission(AmityPermission.MANAGE_COMMUNITY_STORY) + .atCommunity(communityId) + .check() + .asFlow() + .catch { + emit(false) + } + .collectAsState(initial = false) + + val allowAllUserStoryCreation by AmitySocialClient.getSettings() + .asFlow() + .map { it.getStorySettings().isAllowAllUserToCreateStory() } + .catch { + emit(false) + } + .collectAsState(initial = false) + + val isOnlyAdminCanPost by remember(community?.getPostSettings()) { + derivedStateOf { + community?.getPostSettings() == AmityCommunityPostSettings.ADMIN_CAN_POST_ONLY + } + } + + val shouldShowPostCreationButton by remember( + isOnlyAdminCanPost, + hasCreatePrivilege, + community?.isJoined() + ) { + derivedStateOf { + (!isOnlyAdminCanPost || hasCreatePrivilege) + && (community?.isJoined() == true) + } + } + + val shouldShowStoryCreationButton by remember( + allowAllUserStoryCreation, + hasManageStoryPermission, + community?.isJoined() + ) { + derivedStateOf { + (allowAllUserStoryCreation || hasManageStoryPermission) + && (community?.isJoined() == true) + } + } + LaunchedEffect(state.isRefreshing) { if (state.isRefreshing) { announcementPosts.refresh() @@ -216,7 +263,7 @@ fun AmityCommunityProfilePage( } when (selectedTabIndex) { 0 -> { - if(communityPosts.loadState.refresh == LoadState.Loading) { + if (communityPosts.loadState.refresh == LoadState.Loading) { repeat(4) { item { AmityPostShimmer() @@ -279,7 +326,8 @@ fun AmityCommunityProfilePage( pageScope = getPageScope(), elementId = "community_create_post_button", ) { - if((community != null && community!!.isJoined() && community!!.getPostSettings() != AmityCommunityPostSettings.ADMIN_CAN_POST_ONLY) || hasCreatePrivilege) { + if (shouldShowPostCreationButton || shouldShowStoryCreationButton) { + FloatingActionButton( onClick = { expanded = true @@ -305,6 +353,8 @@ fun AmityCommunityProfilePage( modifier = Modifier, community = community!!, shouldShow = expanded, + shouldShowPostCreationButton = shouldShowPostCreationButton, + shouldShowStoryCreationButton = shouldShowStoryCreationButton, onDismiss = { expanded = false }, ) } diff --git a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/profile/element/AmityCommunityInfoView.kt b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/profile/element/AmityCommunityInfoView.kt index df688b31..d38c02ff 100644 --- a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/profile/element/AmityCommunityInfoView.kt +++ b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/profile/element/AmityCommunityInfoView.kt @@ -73,7 +73,9 @@ fun AmityCommunityInfoView( .height(20.dp) .background(color = AmityTheme.colors.baseShade4) ) {} - Row(modifier = Modifier.clickable { + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier.clickable { community?.let{ behavior.goToMemberListPage( AmityCommunityProfilePageBehavior.Context( diff --git a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/profile/element/AmityCommunityProfileActionsBottomSheet.kt b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/profile/element/AmityCommunityProfileActionsBottomSheet.kt index ffaea01e..afd8de9f 100644 --- a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/profile/element/AmityCommunityProfileActionsBottomSheet.kt +++ b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/profile/element/AmityCommunityProfileActionsBottomSheet.kt @@ -33,6 +33,8 @@ fun AmityCommunityProfileActionsBottomSheet( componentScope: AmityComposeComponentScope? = null, community: AmityCommunity, shouldShow: Boolean, + shouldShowPostCreationButton: Boolean, + shouldShowStoryCreationButton: Boolean, onDismiss: () -> Unit, ) { val sheetState = rememberModalBottomSheetState() @@ -53,6 +55,8 @@ fun AmityCommunityProfileActionsBottomSheet( modifier = modifier, componentScope = componentScope, community = community, + shouldShowPostCreationButton = shouldShowPostCreationButton, + shouldShowStoryCreationButton = shouldShowStoryCreationButton, ) { scope.launch { sheetState.hide() @@ -71,9 +75,12 @@ fun AmityCommunityProfileActionsContainer( modifier: Modifier = Modifier, componentScope: AmityComposeComponentScope? = null, community: AmityCommunity, + shouldShowPostCreationButton: Boolean, + shouldShowStoryCreationButton: Boolean, onDismiss: () -> Unit, ) { val context = LocalContext.current + AmityBaseElement( componentScope = componentScope, elementId = "community_profile_actions" @@ -83,9 +90,6 @@ fun AmityCommunityProfileActionsContainer( .background(AmityTheme.colors.background) .padding(start = 16.dp, end = 16.dp, bottom = 20.dp) ) { - val targetType = CommunityCreatePostTargetType.COMMUNITY - val context = LocalContext.current - val behavior by lazy { AmitySocialBehaviorHelper.communityProfilePageBehavior } @@ -94,51 +98,56 @@ fun AmityCommunityProfileActionsContainer( contract = ActivityResultContracts.StartActivityForResult() ) {} - AmityBottomSheetActionItem( - icon = R.drawable.amity_ic_post_create, - text = "Post", - modifier = modifier, - ) { - onDismiss() - behavior.goToPostComposerPage( - AmityCommunityProfilePageBehavior.Context( - pageContext = context, - activityLauncher = launcher, - community = community, + if (shouldShowPostCreationButton) { + AmityBottomSheetActionItem( + icon = R.drawable.amity_ic_post_create, + text = "Post", + modifier = modifier, + ) { + onDismiss() + behavior.goToPostComposerPage( + AmityCommunityProfilePageBehavior.Context( + pageContext = context, + activityLauncher = launcher, + community = community, + ) ) - ) + } } - AmityBottomSheetActionItem( - icon = R.drawable.amity_ic_create_story_social, - text = "Story", - modifier = modifier, - ) { - onDismiss() - behavior.goToCreateStoryPage( - AmityCommunityProfilePageBehavior.Context( - pageContext = context, - activityLauncher = launcher, - community = community, + if (shouldShowStoryCreationButton) { + AmityBottomSheetActionItem( + icon = R.drawable.amity_ic_create_story_social, + text = "Story", + modifier = modifier, + ) { + onDismiss() + behavior.goToCreateStoryPage( + AmityCommunityProfilePageBehavior.Context( + pageContext = context, + activityLauncher = launcher, + community = community, + ) ) - ) + } } - AmityBottomSheetActionItem( - icon = R.drawable.ic_amity_ic_poll_create, - text = "Poll", - modifier = modifier, - ) { - onDismiss() - behavior.goToCreatePollPage( - AmityCommunityProfilePageBehavior.Context( - pageContext = context, - activityLauncher = launcher, - community = community, + if (shouldShowPostCreationButton) { + AmityBottomSheetActionItem( + icon = R.drawable.ic_amity_ic_poll_create, + text = "Poll", + modifier = modifier, + ) { + onDismiss() + behavior.goToCreatePollPage( + AmityCommunityProfilePageBehavior.Context( + pageContext = context, + activityLauncher = launcher, + community = community, + ) ) - ) + } } - } } } diff --git a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/setting/notifications/comments/AmityCommunityCommentsNotificationSettingPage.kt b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/setting/notifications/comments/AmityCommunityCommentsNotificationSettingPage.kt index 822fe274..82f22975 100644 --- a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/setting/notifications/comments/AmityCommunityCommentsNotificationSettingPage.kt +++ b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/setting/notifications/comments/AmityCommunityCommentsNotificationSettingPage.kt @@ -27,6 +27,7 @@ import com.amity.socialcloud.uikit.common.ui.base.AmityBasePage import com.amity.socialcloud.uikit.common.ui.elements.AmityAlertDialog import com.amity.socialcloud.uikit.common.ui.elements.AmityToolBar import com.amity.socialcloud.uikit.common.ui.theme.AmityTheme +import com.amity.socialcloud.uikit.common.utils.amityStringResource import com.amity.socialcloud.uikit.common.utils.clickableWithoutRipple import com.amity.socialcloud.uikit.common.utils.closePage import com.amity.socialcloud.uikit.common.utils.getEnabledCommentNotificationSettings @@ -215,10 +216,10 @@ fun AmityCommunityCommentsNotificationSettingPage( if (showLeaveConfirmDialog) { if (shouldAllowToSave) { AmityAlertDialog( - dialogTitle = context.getString(R.string.amity_cc_leave_title), - dialogText = "Your changes that you made may not be saved.", - confirmText = context.getString(R.string.amity_leave), - dismissText = context.getString(R.string.amity_cancel), + dialogTitle = context.amityStringResource(id = R.string.amity_v4_community_dialog_leave_title), + dialogText = context.amityStringResource(id = R.string.amity_v4_community_dialog_leave_description), + confirmText = context.getString(R.string.amity_v4_dialog_leave_button), + dismissText = context.getString(R.string.amity_v4_dialog_cancel_button), confirmTextColor = AmityTheme.colors.alert, onConfirmation = { context.closePage() diff --git a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/setting/notifications/posts/AmityCommunityPostsNotificationSettingPage.kt b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/setting/notifications/posts/AmityCommunityPostsNotificationSettingPage.kt index 842aee5a..428a6f10 100644 --- a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/setting/notifications/posts/AmityCommunityPostsNotificationSettingPage.kt +++ b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/setting/notifications/posts/AmityCommunityPostsNotificationSettingPage.kt @@ -27,6 +27,7 @@ import com.amity.socialcloud.uikit.common.ui.base.AmityBasePage import com.amity.socialcloud.uikit.common.ui.elements.AmityAlertDialog import com.amity.socialcloud.uikit.common.ui.elements.AmityToolBar import com.amity.socialcloud.uikit.common.ui.theme.AmityTheme +import com.amity.socialcloud.uikit.common.utils.amityStringResource import com.amity.socialcloud.uikit.common.utils.clickableWithoutRipple import com.amity.socialcloud.uikit.common.utils.closePage import com.amity.socialcloud.uikit.common.utils.getEnabledPostNotificationSettings @@ -171,10 +172,10 @@ fun AmityCommunityPostsNotificationSettingPage( if (showLeaveConfirmDialog) { if (shouldAllowToSave) { AmityAlertDialog( - dialogTitle = context.getString(R.string.amity_cc_leave_title), - dialogText = "Your changes that you made may not be saved.", - confirmText = context.getString(R.string.amity_leave), - dismissText = context.getString(R.string.amity_cancel), + dialogTitle = context.amityStringResource(id = R.string.amity_v4_community_dialog_leave_title), + dialogText = context.amityStringResource(id = R.string.amity_v4_community_dialog_leave_description), + confirmText = context.getString(R.string.amity_v4_dialog_leave_button), + dismissText = context.getString(R.string.amity_v4_dialog_cancel_button), confirmTextColor = AmityTheme.colors.alert, onConfirmation = { context.closePage() diff --git a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/setting/notifications/stories/AmityCommunityStoriesNotificationSettingPage.kt b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/setting/notifications/stories/AmityCommunityStoriesNotificationSettingPage.kt index 2f11f99a..43d4a7c9 100644 --- a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/setting/notifications/stories/AmityCommunityStoriesNotificationSettingPage.kt +++ b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/setting/notifications/stories/AmityCommunityStoriesNotificationSettingPage.kt @@ -27,6 +27,7 @@ import com.amity.socialcloud.uikit.common.ui.base.AmityBasePage import com.amity.socialcloud.uikit.common.ui.elements.AmityAlertDialog import com.amity.socialcloud.uikit.common.ui.elements.AmityToolBar import com.amity.socialcloud.uikit.common.ui.theme.AmityTheme +import com.amity.socialcloud.uikit.common.utils.amityStringResource import com.amity.socialcloud.uikit.common.utils.clickableWithoutRipple import com.amity.socialcloud.uikit.common.utils.closePage import com.amity.socialcloud.uikit.common.utils.getEnabledStoryNotificationSettings @@ -208,10 +209,10 @@ fun AmityCommunityStoriesNotificationSettingPage( if (showLeaveConfirmDialog) { if (shouldAllowToSave) { AmityAlertDialog( - dialogTitle = context.getString(R.string.amity_cc_leave_title), - dialogText = "Your changes that you made may not be saved.", - confirmText = context.getString(R.string.amity_leave), - dismissText = context.getString(R.string.amity_cancel), + dialogTitle = context.amityStringResource(id = R.string.amity_v4_community_dialog_leave_title), + dialogText = context.amityStringResource(id = R.string.amity_v4_community_dialog_leave_description), + confirmText = context.getString(R.string.amity_v4_dialog_leave_button), + dismissText = context.getString(R.string.amity_v4_dialog_cancel_button), confirmTextColor = AmityTheme.colors.alert, onConfirmation = { context.closePage() diff --git a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/setting/post/AmityCommunityPostPermissionPage.kt b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/setting/post/AmityCommunityPostPermissionPage.kt index f0b5a7c4..e059261c 100644 --- a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/setting/post/AmityCommunityPostPermissionPage.kt +++ b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/setting/post/AmityCommunityPostPermissionPage.kt @@ -28,6 +28,7 @@ import com.amity.socialcloud.uikit.common.ui.base.AmityBasePage import com.amity.socialcloud.uikit.common.ui.elements.AmityAlertDialog import com.amity.socialcloud.uikit.common.ui.elements.AmityToolBar import com.amity.socialcloud.uikit.common.ui.theme.AmityTheme +import com.amity.socialcloud.uikit.common.utils.amityStringResource import com.amity.socialcloud.uikit.common.utils.clickableWithoutRipple import com.amity.socialcloud.uikit.common.utils.closePage import com.amity.socialcloud.uikit.common.utils.closePageWithResult @@ -155,10 +156,10 @@ fun AmityCommunityPostPermissionPage( if (showLeaveConfirmDialog) { if (shouldAllowToSave) { AmityAlertDialog( - dialogTitle = context.getString(R.string.amity_cc_leave_title), - dialogText = "Your changes that you made may not be saved.", - confirmText = context.getString(R.string.amity_leave), - dismissText = context.getString(R.string.amity_cancel), + dialogTitle = context.amityStringResource(id = R.string.amity_v4_community_dialog_leave_title), + dialogText = context.amityStringResource(id = R.string.amity_v4_community_dialog_leave_description), + confirmText = context.getString(R.string.amity_v4_dialog_leave_button), + dismissText = context.getString(R.string.amity_v4_dialog_cancel_button), confirmTextColor = AmityTheme.colors.alert, onConfirmation = { context.closePage() diff --git a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/setup/AmityCommunitySetupPage.kt b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/setup/AmityCommunitySetupPage.kt index b50742fb..85befc61 100644 --- a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/setup/AmityCommunitySetupPage.kt +++ b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/community/setup/AmityCommunitySetupPage.kt @@ -3,7 +3,6 @@ package com.amity.socialcloud.uikit.community.compose.community.setup import android.app.Activity import android.content.Context import android.net.Uri -import android.util.Log import androidx.activity.compose.BackHandler import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.PickVisualMediaRequest @@ -71,6 +70,7 @@ import com.amity.socialcloud.uikit.common.ui.elements.AmityTextField import com.amity.socialcloud.uikit.common.ui.scope.AmityComposePageScope import com.amity.socialcloud.uikit.common.ui.theme.AmityTheme import com.amity.socialcloud.uikit.common.utils.AmityCameraUtil +import com.amity.socialcloud.uikit.common.utils.amityStringResource import com.amity.socialcloud.uikit.common.utils.clickableWithoutRipple import com.amity.socialcloud.uikit.common.utils.closePage import com.amity.socialcloud.uikit.common.utils.closePageWithResult @@ -272,7 +272,11 @@ fun AmityCommunitySetupPage( elementId = if (isInEditMode) "community_edit_title" else "title" ) { Text( - text = getConfig().getText(), + text = amityStringResource( + configString = getConfig().getText(), + id = if (isInEditMode) R.string.amity_v4_community_setup_edit_title + else R.string.amity_v4_community_setup_create_title, + ), style = AmityTheme.typography.title, modifier = modifier .fillMaxWidth() @@ -331,7 +335,10 @@ fun AmityCommunitySetupPage( elementId = "community_name_title" ) { Text( - text = getConfig().getText(), + text = amityStringResource( + configString = getConfig().getText(), + id = R.string.amity_v4_community_setup_name_title + ), style = AmityTheme.typography.title, modifier = modifier.testTag(getAccessibilityId()) ) @@ -349,7 +356,7 @@ fun AmityCommunitySetupPage( AmityTextField( maxCharacters = 30, text = name, - hint = context.getString(R.string.amity_cc_hint), + hint = amityStringResource(id = R.string.amity_v4_community_setup_name_description), onValueChange = { name = it }, ) @@ -374,13 +381,18 @@ fun AmityCommunitySetupPage( elementId = "community_about_title" ) { Text( - text = getConfig().getText(), + text = amityStringResource( + configString = getConfig().getText(), + id = R.string.amity_v4_community_setup_about_title, + ), style = AmityTheme.typography.title, modifier = modifier.testTag(getAccessibilityId()) ) } Text( - text = " (Optional)", + text = " " + amityStringResource( + id = R.string.amity_v4_community_setup_about_optional_title, + ), style = AmityTheme.typography.body.copy( color = AmityTheme.colors.baseShade3, ) @@ -399,7 +411,7 @@ fun AmityCommunitySetupPage( AmityTextField( maxCharacters = 180, text = description, - hint = context.getString(R.string.amity_enter_description), + hint = amityStringResource(id = R.string.amity_v4_community_setup_about_description), onValueChange = { description = it }, ) @@ -414,7 +426,10 @@ fun AmityCommunitySetupPage( elementId = "community_category_title" ) { Text( - text = getConfig().getText(), + text = amityStringResource( + configString = getConfig().getText(), + id = R.string.amity_v4_community_setup_categories_title, + ), style = AmityTheme.typography.title, modifier = modifier .padding(horizontal = 16.dp) @@ -429,7 +444,7 @@ fun AmityCommunitySetupPage( ) { if (selectedCategories.isEmpty()) { Text( - text = context.getString(R.string.amity_select_category), + text = context.getString(R.string.amity_v4_community_setup_categories_description), style = AmityTheme.typography.body.copy( color = AmityTheme.colors.baseShade3, ), @@ -485,7 +500,10 @@ fun AmityCommunitySetupPage( elementId = "community_privacy_title" ) { Text( - text = getConfig().getText(), + text = amityStringResource( + configString = getConfig().getText(), + id = R.string.amity_v4_community_setup_privacy_title, + ), style = AmityTheme.typography.title, modifier = modifier .padding(horizontal = 16.dp) @@ -530,7 +548,10 @@ fun AmityCommunitySetupPage( elementId = "community_privacy_public_title" ) { Text( - text = context.getString(R.string.amity_public), + text = amityStringResource( + configString = getConfig().getText(), + id = R.string.amity_v4_community_setup_privacy_public_title, + ), style = AmityTheme.typography.body.copy( fontWeight = FontWeight.SemiBold ), @@ -543,7 +564,10 @@ fun AmityCommunitySetupPage( elementId = "community_privacy_public_description" ) { Text( - text = getConfig().getText(), + text = amityStringResource( + configString = getConfig().getText(), + id = R.string.amity_v4_community_setup_privacy_public_description, + ), style = AmityTheme.typography.caption.copy( color = AmityTheme.colors.baseShade1, fontWeight = FontWeight.Normal, @@ -601,7 +625,10 @@ fun AmityCommunitySetupPage( elementId = "community_privacy_private_title" ) { Text( - text = context.getString(R.string.amity_private), + text = amityStringResource( + configString = getConfig().getText(), + id = R.string.amity_v4_community_setup_privacy_private_title, + ), style = AmityTheme.typography.body.copy( fontWeight = FontWeight.SemiBold ), @@ -614,7 +641,10 @@ fun AmityCommunitySetupPage( elementId = "community_privacy_private_description" ) { Text( - text = context.getString(R.string.amity_private_description), + text = amityStringResource( + configString = getConfig().getText(), + id = R.string.amity_v4_community_setup_privacy_private_description, + ), style = AmityTheme.typography.caption.copy( color = AmityTheme.colors.baseShade1, fontWeight = FontWeight.Normal, @@ -648,7 +678,10 @@ fun AmityCommunitySetupPage( elementId = "community_add_member_title" ) { Text( - text = getConfig().getText(), + text = amityStringResource( + configString = getConfig().getText(), + id = R.string.amity_v4_community_setup_create_button, + ), style = AmityTheme.typography.title, modifier = modifier .padding(horizontal = 16.dp) @@ -721,7 +754,12 @@ fun AmityCommunitySetupPage( ) } } else { - getPageScope().showProgressSnackbar("Creating...") + getPageScope().showProgressSnackbar( + context.amityStringResource( + id = R.string.amity_v4_community_setup_toast_creating + ) + ) + viewModel.createCommunity( avatarUri = avatarUri, displayName = name, @@ -730,7 +768,11 @@ fun AmityCommunitySetupPage( categoryIds = selectedCategories.map { it.getCategoryId() }, userIds = selectedUsers.map { it.getUserId() }, onSuccess = { - context.showToast("Successfully created community!") + context.showToast( + context.amityStringResource( + id = R.string.amity_v4_community_setup_toast_create_success + ) + ) context.closePageWithResult(Activity.RESULT_OK) behavior.goToCommunityProfilePage( AmityCommunitySetupPageBehavior.Context( @@ -740,7 +782,11 @@ fun AmityCommunitySetupPage( ) }, onError = { - context.showToast("Failed to create community. Please try again.") + context.showToast( + context.amityStringResource( + id = R.string.amity_v4_community_setup_toast_create_failed + ) + ) } ) } @@ -760,7 +806,11 @@ fun AmityCommunitySetupPage( Spacer(modifier = modifier.width(8.dp)) } Text( - text = getConfig().getText(), + text = context.amityStringResource( + configString = getConfig().getText(), + id = if (isInEditMode) R.string.amity_v4_community_setup_edit_button + else R.string.amity_v4_community_setup_create_button + ), style = AmityTheme.typography.caption.copy( color = Color.White, ), @@ -777,10 +827,10 @@ fun AmityCommunitySetupPage( if (showPrivacyConfirmDialog) { AmityAlertDialog( - dialogTitle = "Change community privacy settings", - dialogText = "This community has globally featured posts. Changing the community from public to private will remove these posts from being featured globally", - confirmText = "Confirm", - dismissText = context.getString(R.string.amity_cancel), + dialogTitle = context.amityStringResource(id = R.string.amity_v4_community_setup_dialog_change_privacy_title), + dialogText = context.amityStringResource(id = R.string.amity_v4_community_setup_dialog_change_privacy_message), + confirmText = context.amityStringResource(id = R.string.amity_v4_dialog_confirm_button), + dismissText = context.amityStringResource(id = R.string.amity_v4_dialog_cancel_button), onConfirmation = { showPrivacyConfirmDialog = false updateCommunity( @@ -829,10 +879,10 @@ fun AmityCommunitySetupPage( if (shouldActionButtonEnable) { if (isInEditMode) { AmityAlertDialog( - dialogTitle = context.getString(R.string.amity_ec_leave_title), - dialogText = context.getString(R.string.amity_ec_leave_description), - confirmText = context.getString(R.string.amity_discard), - dismissText = context.getString(R.string.amity_cancel), + dialogTitle = context.amityStringResource(id = R.string.amity_v4_community_setup_dialog_leave_edit_title), + dialogText = context.amityStringResource(id = R.string.amity_v4_community_setup_dialog_leave_edit_description), + confirmText = context.amityStringResource(id = R.string.amity_v4_dialog_discard_button), + dismissText = context.amityStringResource(id = R.string.amity_v4_dialog_cancel_button), confirmTextColor = AmityTheme.colors.alert, onConfirmation = { context.closePage() @@ -843,10 +893,10 @@ fun AmityCommunitySetupPage( ) } else { AmityAlertDialog( - dialogTitle = context.getString(R.string.amity_cc_leave_title), - dialogText = context.getString(R.string.amity_cc_leave_description), - confirmText = context.getString(R.string.amity_leave), - dismissText = context.getString(R.string.amity_cancel), + dialogTitle = context.amityStringResource(id = R.string.amity_v4_community_setup_dialog_leave_title), + dialogText = context.amityStringResource(id = R.string.amity_v4_community_setup_dialog_leave_description), + confirmText = context.amityStringResource(id = R.string.amity_v4_dialog_leave_button), + dismissText = context.amityStringResource(id = R.string.amity_v4_dialog_cancel_button), confirmTextColor = AmityTheme.colors.alert, onConfirmation = { context.closePage() @@ -874,7 +924,7 @@ fun updateCommunity( pageScope: AmityComposePageScope, context: Context, ) { - pageScope.showProgressSnackbar("Updating...") + pageScope.showProgressSnackbar(context.amityStringResource(id = R.string.amity_v4_community_setup_toast_updating)) viewModel.editCommunity( communityId = communityId, avatarUri = avatarUri, @@ -883,11 +933,11 @@ fun updateCommunity( isPublic = isPublic, categoryIds = categoryIds, onSuccess = { - context.showToast("Successfully updated community profile!") + context.showToast(context.amityStringResource(id = R.string.amity_v4_community_setup_toast_update_success)) context.closePageWithResult(Activity.RESULT_OK) }, onError = { - context.showToast("Failed to save your community profile. Please try again.") + context.showToast(context.amityStringResource(id = R.string.amity_v4_community_setup_toast_update_failed)) context.closePageWithResult(Activity.RESULT_OK) } ) diff --git a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/socialhome/components/AmityCreatePostMenuComponent.kt b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/socialhome/components/AmityCreatePostMenuComponent.kt index 523e32e0..4f9f74ad 100644 --- a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/socialhome/components/AmityCreatePostMenuComponent.kt +++ b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/socialhome/components/AmityCreatePostMenuComponent.kt @@ -16,6 +16,8 @@ import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier @@ -27,6 +29,7 @@ import androidx.compose.ui.semantics.testTagsAsResourceId import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.DpOffset import androidx.compose.ui.unit.dp +import androidx.lifecycle.viewmodel.compose.viewModel import com.amity.socialcloud.sdk.model.social.post.AmityPost import com.amity.socialcloud.sdk.model.social.story.AmityStory import com.amity.socialcloud.uikit.common.common.isNotEmptyOrBlank @@ -74,6 +77,9 @@ fun AmityCreatePostMenuComponent( context.closePageWithResult(Activity.RESULT_OK) } + val viewModel = viewModel() + val showStoryAction by viewModel.showStoryAction.collectAsState() + AmityBaseComponent( pageScope = pageScope, componentId = "create_post_menu" @@ -138,49 +144,52 @@ fun AmityCreatePostMenuComponent( } }, ) - DropdownMenuItem( - text = { - AmityBaseElement( - pageScope = pageScope, - componentScope = getComponentScope(), - elementId = "create_story_button" - ) { - Row( - horizontalArrangement = Arrangement.spacedBy(8.dp), - verticalAlignment = Alignment.CenterVertically, - modifier = modifier - .padding(horizontal = 8.dp) - .testTag(getAccessibilityId()), + + if (showStoryAction) { + DropdownMenuItem( + text = { + AmityBaseElement( + pageScope = pageScope, + componentScope = getComponentScope(), + elementId = "create_story_button" ) { - Icon( - painter = painterResource(id = getConfig().getIcon()), - contentDescription = "Create Story", - tint = AmityTheme.colors.base, - modifier = modifier.size(20.dp) - ) - Text( - text = getConfig().getText(), - style = AmityTheme.typography.body.copy( - fontWeight = FontWeight.SemiBold + Row( + horizontalArrangement = Arrangement.spacedBy(8.dp), + verticalAlignment = Alignment.CenterVertically, + modifier = modifier + .padding(horizontal = 8.dp) + .testTag(getAccessibilityId()), + ) { + Icon( + painter = painterResource(id = getConfig().getIcon()), + contentDescription = "Create Story", + tint = AmityTheme.colors.base, + modifier = modifier.size(20.dp) + ) + Text( + text = getConfig().getText(), + style = AmityTheme.typography.body.copy( + fontWeight = FontWeight.SemiBold + ) ) + } + } + }, + onClick = { + onDismiss() + if (targetType == CreatePostTargetType.COMMUNITY && targetId?.isNotEmptyOrBlank() == true) { + targetStoryBehavior.goToStoryCreationPage( + context = context, + launcher = launcher, + targetId = targetId, + targetType = AmityStory.TargetType.COMMUNITY, ) + } else { + behavior.goToSelectStoryTargetPage(context) } } - }, - onClick = { - onDismiss() - if (targetType == CreatePostTargetType.COMMUNITY && targetId?.isNotEmptyOrBlank() == true) { - targetStoryBehavior.goToStoryCreationPage( - context = context, - launcher = launcher, - targetId = targetId, - targetType = AmityStory.TargetType.COMMUNITY, - ) - } else { - behavior.goToSelectStoryTargetPage(context) - } - } - ) + ) + } DropdownMenuItem( text = { diff --git a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/socialhome/components/AmityCreatePostMenuComponentViewModel.kt b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/socialhome/components/AmityCreatePostMenuComponentViewModel.kt new file mode 100644 index 00000000..15811552 --- /dev/null +++ b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/socialhome/components/AmityCreatePostMenuComponentViewModel.kt @@ -0,0 +1,56 @@ +package com.amity.socialcloud.uikit.community.compose.socialhome.components + +import com.amity.socialcloud.sdk.api.core.AmityCoreClient +import com.amity.socialcloud.sdk.api.social.AmitySocialClient +import com.amity.socialcloud.sdk.model.core.permission.AmityPermission +import com.amity.socialcloud.uikit.common.base.AmityBaseViewModel +import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers +import io.reactivex.rxjava3.core.Flowable +import io.reactivex.rxjava3.disposables.CompositeDisposable +import io.reactivex.rxjava3.schedulers.Schedulers +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.asStateFlow + +class AmityCreatePostMenuComponentViewModel : AmityBaseViewModel() { + + private val _showStoryAction = MutableStateFlow(false) + val showStoryAction = _showStoryAction.asStateFlow() + + private val disposables = CompositeDisposable() + + init { + checkStoryPermissions() + } + + private fun checkStoryPermissions() { + // Combine global setting and permission check + val globalSetting = AmitySocialClient.getSettings() + .map { it.getStorySettings().isAllowAllUserToCreateStory() } + .subscribeOn(Schedulers.io()) + + val globalPermission = AmityCoreClient.hasPermission(AmityPermission.MANAGE_COMMUNITY_STORY) + .atGlobal() + .check() + .subscribeOn(Schedulers.io()) + + disposables.add( + Flowable.combineLatest( + globalSetting, + globalPermission + ) { isGloballyAllowed, hasPermission -> + isGloballyAllowed || hasPermission + } + .observeOn(AndroidSchedulers.mainThread()) + .doOnNext { shouldShow -> + _showStoryAction.value = shouldShow + } + .doOnError { } + .subscribe() + ) + } + + override fun onCleared() { + super.onCleared() + disposables.clear() + } +} diff --git a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/story/draft/AmityDraftStoryPage.kt b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/story/draft/AmityDraftStoryPage.kt index 082e1419..97cd2f29 100644 --- a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/story/draft/AmityDraftStoryPage.kt +++ b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/story/draft/AmityDraftStoryPage.kt @@ -63,6 +63,7 @@ import com.amity.socialcloud.sdk.model.social.story.AmityStory import com.amity.socialcloud.sdk.model.social.story.AmityStoryImageDisplayMode import com.amity.socialcloud.sdk.model.social.story.AmityStoryTarget import com.amity.socialcloud.uikit.common.config.AmityUIKitConfigController +import com.amity.socialcloud.uikit.common.eventbus.AmityUIKitSnackbar import com.amity.socialcloud.uikit.common.ui.base.AmityBaseElement import com.amity.socialcloud.uikit.common.ui.base.AmityBasePage import com.amity.socialcloud.uikit.common.ui.elements.AmityAlertDialog @@ -367,10 +368,14 @@ fun AmityDraftStoryPage( hyperlinkUrlText = hyperlinkUrlText, hyperlinkCustomText = hyperlinkCustomText, onSuccess = { - context.showToast("Successfully shared story") + AmityUIKitSnackbar.publishSnackbarMessage( + "Successfully shared story" + ) }, onError = { message -> - context.showToast(message) + AmityUIKitSnackbar.publishSnackbarMessage( + message + ) } ) context.closePageWithResult(Activity.RESULT_OK) @@ -384,10 +389,14 @@ fun AmityDraftStoryPage( hyperlinkUrlText = hyperlinkUrlText, hyperlinkCustomText = hyperlinkCustomText, onSuccess = { - context.showToast("Successfully shared story") + AmityUIKitSnackbar.publishSnackbarMessage( + "Successfully shared story" + ) }, onError = { message -> - context.showToast(message) + AmityUIKitSnackbar.publishSnackbarMessage( + message + ) } ) context.closePageWithResult(Activity.RESULT_OK) diff --git a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/story/view/AmityViewCommunityStoryPage.kt b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/story/view/AmityViewCommunityStoryPage.kt index cf2d273b..5abd5df4 100644 --- a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/story/view/AmityViewCommunityStoryPage.kt +++ b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/story/view/AmityViewCommunityStoryPage.kt @@ -213,7 +213,11 @@ fun AmityViewCommunityStoryPage( LaunchedEffect(isTargetVisible, isShowingVideoStory, shouldPauseTimer) { if (!isTargetVisible) return@LaunchedEffect - val storyId = currentStory?.getStoryId() ?: return@LaunchedEffect + val storyId = currentStory?.getStoryId() + if(storyId == null) { + exoPlayer.pause() + return@LaunchedEffect + } if (isShowingVideoStory) { AmityStoryVideoPlayerHelper.playMediaItem(storyId = storyId) } else { diff --git a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/ui/shimmer/AmityCommunityTargetListShimmer.kt b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/ui/shimmer/AmityCommunityTargetListShimmer.kt index 30a21d24..9120dbfe 100644 --- a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/ui/shimmer/AmityCommunityTargetListShimmer.kt +++ b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/ui/shimmer/AmityCommunityTargetListShimmer.kt @@ -37,7 +37,7 @@ fun AmityCommunityTargetListShimmer( .size(40.dp) .aspectRatio(1f) .shimmerBackground( - color = AmityTheme.colors.baseShade3, + color = AmityTheme.colors.baseShade4, shape = CircleShape ) ) @@ -47,7 +47,7 @@ fun AmityCommunityTargetListShimmer( .height(8.dp) .width(140.dp) .shimmerBackground( - color = AmityTheme.colors.baseShade3, + color = AmityTheme.colors.baseShade4, shape = RoundedCornerShape(6.dp) ) ) diff --git a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/ui/shimmer/AmityUserListShimmer.kt b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/ui/shimmer/AmityUserListShimmer.kt index ca291ab6..de888426 100644 --- a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/ui/shimmer/AmityUserListShimmer.kt +++ b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/ui/shimmer/AmityUserListShimmer.kt @@ -37,7 +37,7 @@ fun AmityUserListShimmer( .size(40.dp) .aspectRatio(1f) .shimmerBackground( - color = AmityTheme.colors.baseShade3, + color = AmityTheme.colors.baseShade4, shape = CircleShape ) ) @@ -47,7 +47,7 @@ fun AmityUserListShimmer( .height(8.dp) .width(140.dp) .shimmerBackground( - color = AmityTheme.colors.baseShade3, + color = AmityTheme.colors.baseShade4, shape = RoundedCornerShape(6.dp) ) ) diff --git a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/user/edit/AmityEditUserProfilePage.kt b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/user/edit/AmityEditUserProfilePage.kt index 7cb93ec4..9f3d7eaa 100644 --- a/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/user/edit/AmityEditUserProfilePage.kt +++ b/social-compose/src/main/java/com/amity/socialcloud/uikit/community/compose/user/edit/AmityEditUserProfilePage.kt @@ -41,6 +41,8 @@ import androidx.compose.ui.text.withStyle import androidx.compose.ui.unit.coerceAtMost import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel +import com.amity.socialcloud.sdk.api.core.AmityCoreClient +import com.amity.socialcloud.sdk.helper.core.coroutines.asFlow import com.amity.socialcloud.uikit.common.ui.base.AmityBaseElement import com.amity.socialcloud.uikit.common.ui.base.AmityBasePage import com.amity.socialcloud.uikit.common.ui.elements.AmityAlertDialog @@ -54,6 +56,7 @@ import com.amity.socialcloud.uikit.common.utils.isKeyboardVisible import com.amity.socialcloud.uikit.common.utils.showToast import com.amity.socialcloud.uikit.community.compose.R import com.amity.socialcloud.uikit.community.compose.user.edit.elements.AmityEditUserAvatar +import kotlinx.coroutines.flow.catch @Composable fun AmityEditUserProfilePage( @@ -91,6 +94,17 @@ fun AmityEditUserProfilePage( val keyboardHeight by getKeyboardHeight() val systemBarPadding = WindowInsets.systemBars.asPaddingValues().calculateBottomPadding() + val shouldAllowDisplayNameEditing by remember { + AmityCoreClient.getCoreUserSettings() + .map { + it.isAllowUpdateDisplayName() + } + .asFlow() + .catch { + emit(false) + } + }.collectAsState(false) + val saveButtonBarBottomOffset by remember(systemBarPadding) { derivedStateOf { if (isKeyboardOpen) { @@ -175,7 +189,7 @@ fun AmityEditUserProfilePage( text = displayName, hint = getConfig().getText(), maxCharacters = UserDisplayNameLimit, - enabled = false, + enabled = shouldAllowDisplayNameEditing, maxLines = 3, onValueChange = { displayName = it diff --git a/social-compose/src/main/res/values/strings.xml b/social-compose/src/main/res/values/strings.xml index 6f57a77a..a917c737 100644 --- a/social-compose/src/main/res/values/strings.xml +++ b/social-compose/src/main/res/values/strings.xml @@ -53,34 +53,12 @@ Post to Story to - Discard Discard post? Do you want to discard your post? - - Create Community - Community name - Name your community - About - Enter description - Categories - Select category - Privacy - Public - Choose to allow Only Admins to create posts in this community. - Anyone can join, view, and search the posts in this community. - Private - Only members invited by the moderators can join, view, and search the posts in this community. Only admin can post Add members* Cancel request Select members - Leave without finishing - Your progress won\'t be saved and your community won\'t be created. - Leave - Close - Save - Unsaved changes - Are you sure you want to discard the changes? They will be lost when you leave this page. Close community Closing this community will remove the community page and all its content and comments. @@ -92,4 +70,51 @@ You won\’t no longer be able to post and interact in this community after leaving. Unable to leave community Unable to close community + + + Confirm + Cancel + Leave + Close + Save + Discard + + + Create community + Edit community + Community name + Name your community + About + (Optional) + Enter description + Categories + Select category + Privacy + Public + Anyone can join, view, and search the posts in this community. + Private + Only members invited by the moderators can join, view, and search the posts in this community. + Create community + Save + + + Creating… + Successfully created community! + Failed to create community. Please try again. + Updating… + Successfully updated community profile! + Failed to save your community profile. Please try again. + + + Change community privacy settings + This community has globally featured posts. Changing the community from public to private will remove these posts from being featured globally + Leave without finishing + Your progress won\'t be saved and your community won\'t be created. + Unsaved changes + Are you sure you want to discard the changes? They will be lost when you leave this page. + + + Leave without finishing + Your changes that you made may not be saved. + \ No newline at end of file diff --git a/social/build.gradle b/social/build.gradle index ae48f751..a12855a0 100644 --- a/social/build.gradle +++ b/social/build.gradle @@ -36,6 +36,6 @@ dependencies { api("com.linkedin.android.spyglass:spyglass:3.0.1") - api("co.amity.android:amity-video-publisher:$amityMessagingSdkVersion") - api("co.amity.android:amity-video-player:$amityMessagingSdkVersion") + api("$amitySDKDependency:amity-video-publisher:$amityMessagingSdkVersion") + api("$amitySDKDependency:amity-video-player:$amityMessagingSdkVersion") } diff --git a/social/src/main/res/values/strings.xml b/social/src/main/res/values/strings.xml index 927379b6..88e10607 100644 --- a/social/src/main/res/values/strings.xml +++ b/social/src/main/res/values/strings.xml @@ -308,4 +308,97 @@ Unable to turn off allow comment Unable to turn on allow comment + Take Photo + Start Capture + Stop Capture + + Like + Liked + Reply + + Join community to interact with all stories + + Comments + Comments are disabled for this story + Delete Comment + Comment deleted + Edit Comment + Report Comment + Comment reported + Report retracted + Undo Report + Edit Reply + Delete Reply + Report Reply + This reply has been deleted + This comment has been deleted + View more replies + Delete Comment + This comment will be permanently removed. + Delete reply + This reply will be permanently removed. + Unable to add reply + Unable to add comment + Your comment wasn’t created as it contained blocked words. Only you can see this + Unable to update comment + Your comment wasn’t updated as it contained blocked words. Only you can see this + + Cancel + Delete + + + %s like + %s likes + + + %s comment + %s comments + + + Delete this post? + This post will be permanently deleted. You’ll no longer to see and find this post + + Post to + Story to + + Discard + Discard post? + Do you want to discard your post? + + Create Community + Community name + Name your community + About + Enter description + Categories + Select category + Privacy + Public + Choose to allow Only Admins to create posts in this community. + Anyone can join, view, and search the posts in this community. + Private + Only members invited by the moderators can join, view, and search the posts in this community. + Only admin can post + Add members* + Cancel request + Select members + Leave without finishing + Your progress won\'t be saved and your community won\'t be created. + Leave + Close + Save + Unsaved changes + Are you sure you want to discard the changes? They will be lost when you leave this page. + + Close community + Closing this community will remove the community page and all its content and comments. + Leave community + Leaving community, you’ll give up your moderator status and won’t no longer be able to post and interact in this community. + You’re the only moderator in this group. To leave community, nominate other members to moderator role. + As you’re the last moderator and member, leaving will also close this community. All posts shared in community will be deleted. This cannot be undone. + All members will be removed from the community. All posts, messages, reactions, and media shared in community will be deleted. This cannot be undone. + You won\’t no longer be able to post and interact in this community after leaving. + Unable to leave community + Unable to close community +