From 56c72113182609e8408c0df01fc06421b5f115cb Mon Sep 17 00:00:00 2001 From: Ashita Agrawal Date: Thu, 24 Nov 2022 12:37:22 +0530 Subject: [PATCH] Merge pull request #609 from Automattic/task/410-remove-share-first-last-story End of Year: Hide share from first and last story --- .../com/shiftyjelly/pocketcasts/endofyear/StoriesPage.kt | 9 +++++++-- .../pocketcasts/endofyear/StoriesViewModel.kt | 5 +++++ .../shiftyjelly/pocketcasts/analytics/AnalyticsEvent.kt | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/features/endofyear/src/main/java/au/com/shiftyjelly/pocketcasts/endofyear/StoriesPage.kt b/modules/features/endofyear/src/main/java/au/com/shiftyjelly/pocketcasts/endofyear/StoriesPage.kt index bc67bdccd07..26d35acf498 100644 --- a/modules/features/endofyear/src/main/java/au/com/shiftyjelly/pocketcasts/endofyear/StoriesPage.kt +++ b/modules/features/endofyear/src/main/java/au/com/shiftyjelly/pocketcasts/endofyear/StoriesPage.kt @@ -37,6 +37,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.vector.rememberVectorPainter @@ -206,7 +207,8 @@ private fun StoriesView( } requireNotNull(onCaptureBitmap).let { ShareButton( - onClick = { onShareClicked.invoke(it) } + onClick = { if (state.showShare) { onShareClicked.invoke(it) } }, + modifier = modifier.alpha(if (state.showShare) 1f else 0f) ) } } @@ -259,6 +261,7 @@ private fun StorySharableContent( @Composable private fun ShareButton( onClick: () -> Unit, + modifier: Modifier, ) { RowOutlinedButton( text = stringResource(id = LR.string.share), @@ -271,7 +274,9 @@ private fun ShareButton( textIcon = rememberVectorPainter(Icons.Default.Share), onClick = { onClick.invoke() - } + }, + modifier = modifier + ) } diff --git a/modules/features/endofyear/src/main/java/au/com/shiftyjelly/pocketcasts/endofyear/StoriesViewModel.kt b/modules/features/endofyear/src/main/java/au/com/shiftyjelly/pocketcasts/endofyear/StoriesViewModel.kt index bebbba1cfb3..a3a39a8e327 100644 --- a/modules/features/endofyear/src/main/java/au/com/shiftyjelly/pocketcasts/endofyear/StoriesViewModel.kt +++ b/modules/features/endofyear/src/main/java/au/com/shiftyjelly/pocketcasts/endofyear/StoriesViewModel.kt @@ -11,6 +11,8 @@ import au.com.shiftyjelly.pocketcasts.endofyear.ShareableTextProvider.ShareTextD import au.com.shiftyjelly.pocketcasts.endofyear.StoriesViewModel.State.Loaded.SegmentsData import au.com.shiftyjelly.pocketcasts.repositories.endofyear.EndOfYearManager import au.com.shiftyjelly.pocketcasts.repositories.endofyear.stories.Story +import au.com.shiftyjelly.pocketcasts.repositories.endofyear.stories.StoryEpilogue +import au.com.shiftyjelly.pocketcasts.repositories.endofyear.stories.StoryIntro import au.com.shiftyjelly.pocketcasts.utils.FileUtilWrapper import au.com.shiftyjelly.pocketcasts.utils.SentryHelper import au.com.shiftyjelly.pocketcasts.utils.log.LogBuffer @@ -142,6 +144,7 @@ class StoriesViewModel @Inject constructor( fun onRetryClicked() { viewModelScope.launch { + analyticsTracker.track(AnalyticsEvent.END_OF_YEAR_STORY_RETRY_BUTTON_TAPPED) loadStories() } } @@ -204,6 +207,8 @@ class StoriesViewModel @Inject constructor( val segmentsData: SegmentsData, val preparingShareText: Boolean = false, ) : State() { + val showShare: Boolean + get() = currentStory !is StoryIntro && currentStory !is StoryEpilogue data class SegmentsData( val widths: List = emptyList(), val xStartOffsets: List = emptyList(), diff --git a/modules/services/analytics/src/main/java/au/com/shiftyjelly/pocketcasts/analytics/AnalyticsEvent.kt b/modules/services/analytics/src/main/java/au/com/shiftyjelly/pocketcasts/analytics/AnalyticsEvent.kt index 7ea5f9fd42b..86a19e2098e 100644 --- a/modules/services/analytics/src/main/java/au/com/shiftyjelly/pocketcasts/analytics/AnalyticsEvent.kt +++ b/modules/services/analytics/src/main/java/au/com/shiftyjelly/pocketcasts/analytics/AnalyticsEvent.kt @@ -316,4 +316,5 @@ enum class AnalyticsEvent(val key: String) { END_OF_YEAR_STORY_SHOWN("end_of_year_story_shown"), END_OF_YEAR_STORY_SHARE("end_of_year_story_share"), END_OF_YEAR_STORY_SHARED("end_of_year_story_shared"), + END_OF_YEAR_STORY_RETRY_BUTTON_TAPPED("end_of_year_story_retry_button_tapped"), }