Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed feedback link from reading preferences #21466

Draft
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,13 @@ class ReaderReadingPreferencesDialogFragment : BottomSheetDialogFragment() {
setContent {
AppThemeM3 {
val readerPreferences by viewModel.currentReadingPreferences.collectAsState()
val isFeedbackEnabled by viewModel.isFeedbackEnabled.collectAsState()
ReadingPreferencesScreen(
currentReadingPreferences = readerPreferences,
onCloseClick = viewModel::onExitActionClick,
onSendFeedbackClick = viewModel::onSendFeedbackClick,
onThemeClick = viewModel::onThemeClick,
onFontFamilyClick = viewModel::onFontFamilyClick,
onFontSizeClick = viewModel::onFontSizeClick,
onBackgroundColorUpdate = { dialog?.window?.setWindowStatusBarColor(it) },
isFeedbackEnabled = isFeedbackEnabled,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ class ReaderReadingPreferencesTracker @Inject constructor(
analyticsTrackerWrapper.track(AnalyticsTracker.Stat.READER_READING_PREFERENCES_CLOSED)
}

fun trackFeedbackTapped() {
analyticsTrackerWrapper.track(AnalyticsTracker.Stat.READER_READING_PREFERENCES_FEEDBACK_TAPPED)
}

fun trackItemTapped(theme: ReaderReadingPreferences.Theme) {
val props = mapOf(
PROP_TYPE_KEY to PROP_TYPE_THEME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import org.wordpress.android.ui.reader.models.ReaderReadingPreferences
import org.wordpress.android.ui.reader.tracker.ReaderReadingPreferencesTracker
import org.wordpress.android.ui.reader.usecases.ReaderGetReadingPreferencesSyncUseCase
import org.wordpress.android.ui.reader.usecases.ReaderSaveReadingPreferencesUseCase
import org.wordpress.android.util.config.ReaderReadingPreferencesFeedbackFeatureConfig
import org.wordpress.android.viewmodel.ScopedViewModel
import javax.inject.Inject
import javax.inject.Named
Expand All @@ -21,23 +20,18 @@ import javax.inject.Named
class ReaderReadingPreferencesViewModel @Inject constructor(
getReadingPreferences: ReaderGetReadingPreferencesSyncUseCase,
private val saveReadingPreferences: ReaderSaveReadingPreferencesUseCase,
private val readingPreferencesFeedbackFeatureConfig: ReaderReadingPreferencesFeedbackFeatureConfig,
private val readingPreferencesTracker: ReaderReadingPreferencesTracker,
@Named(BG_THREAD) private val bgDispatcher: CoroutineDispatcher,
) : ScopedViewModel(bgDispatcher) {
private val originalReadingPreferences = getReadingPreferences()
private val _currentReadingPreferences = MutableStateFlow(originalReadingPreferences)
val currentReadingPreferences: StateFlow<ReaderReadingPreferences> = _currentReadingPreferences

private val _isFeedbackEnabled = MutableStateFlow(false)
val isFeedbackEnabled: StateFlow<Boolean> = _isFeedbackEnabled

private val _actionEvents = MutableSharedFlow<ActionEvent>()
val actionEvents: SharedFlow<ActionEvent> = _actionEvents

fun init() {
launch {
_isFeedbackEnabled.emit(readingPreferencesFeedbackFeatureConfig.isEnabled())
_actionEvents.emit(ActionEvent.UpdateStatusBarColor(originalReadingPreferences.theme))
}
}
Expand Down Expand Up @@ -92,13 +86,6 @@ class ReaderReadingPreferencesViewModel @Inject constructor(
}
}

fun onSendFeedbackClick() {
launch {
readingPreferencesTracker.trackFeedbackTapped()
_actionEvents.emit(ActionEvent.OpenWebView(FEEDBACK_URL))
}
}

private suspend fun saveReadingPreferencesInternal() {
val currentPreferences = currentReadingPreferences.value
if (isDirty()) {
Expand All @@ -115,8 +102,4 @@ class ReaderReadingPreferencesViewModel @Inject constructor(
data class UpdateStatusBarColor(val theme: ReaderReadingPreferences.Theme) : ActionEvent
data class OpenWebView(val url: String) : ActionEvent
}

companion object {
private const val FEEDBACK_URL = "https://automattic.survey.fm/reader-customization-survey"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.ClickableText
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
Expand All @@ -35,14 +34,9 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.onClick
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.sp
import org.wordpress.android.R
Expand All @@ -63,19 +57,16 @@ private const val TEXT_LINE_HEIGHT_MULTIPLIER = 1.6f
fun ReadingPreferencesScreen(
currentReadingPreferences: ReaderReadingPreferences,
onCloseClick: () -> Unit,
onSendFeedbackClick: () -> Unit,
onThemeClick: (ReaderReadingPreferences.Theme) -> Unit,
onFontFamilyClick: (ReaderReadingPreferences.FontFamily) -> Unit,
onFontSizeClick: (ReaderReadingPreferences.FontSize) -> Unit,
onBackgroundColorUpdate: (Int) -> Unit,
isFeedbackEnabled: Boolean,
isHapticsFeedbackEnabled: Boolean = true,
) {
val themeValues = ReaderReadingPreferences.ThemeValues.from(LocalContext.current, currentReadingPreferences.theme)
val backgroundColor by animateColorAsState(Color(themeValues.intBackgroundColor), label = "backgroundColor")
val baseTextColor by animateColorAsState(Color(themeValues.intBaseTextColor), label = "baseTextColor")
val textColor by animateColorAsState(Color(themeValues.intTextColor), label = "textColor")
val linkColor by animateColorAsState(Color(themeValues.intLinkColor), label = "linkColor")

SideEffect {
// update background color based on value animation and notify the parent
Expand Down Expand Up @@ -145,14 +136,6 @@ fun ReadingPreferencesScreen(
style = contentStyle,
)

if (isFeedbackEnabled) {
ReadingPreferencesPreviewFeedback(
onSendFeedbackClick = onSendFeedbackClick,
textStyle = contentStyle,
linkColor = linkColor,
)
}

// Tags
FlowRow(
modifier = Modifier.fillMaxWidth(),
Expand Down Expand Up @@ -260,62 +243,6 @@ private fun ExperimentalBadge(
)
}

@Composable
private fun ReadingPreferencesPreviewFeedback(
onSendFeedbackClick: () -> Unit,
textStyle: TextStyle,
linkColor: Color,
) {
val linkString = stringResource(R.string.reader_preferences_screen_preview_text_feedback_link)
val feedbackString = stringResource(R.string.reader_preferences_screen_preview_text_feedback, linkString)
val annotatedString = buildAnnotatedString {
append(feedbackString)

val startIndex = feedbackString.indexOf(linkString)
val endIndex = startIndex + linkString.length

addStyle(
style = SpanStyle(
color = linkColor,
textDecoration = TextDecoration.Underline,
),
start = startIndex,
end = endIndex,
)

addStringAnnotation(
tag = "url",
annotation = "feedback",
start = startIndex,
end = endIndex,
)
}

val buttonLabel = stringResource(R.string.reader_preferences_screen_preview_text_feedback_label)
@Suppress("DEPRECATION")
ClickableText(
text = annotatedString,
style = textStyle,
onClick = { offset ->
annotatedString.getStringAnnotations(tag = "url", start = offset, end = offset)
.firstOrNull()
?.let { annotation ->
if (annotation.item == "feedback") {
onSendFeedbackClick()
}
}
},
modifier = Modifier.semantics {
onClick(
label = buttonLabel,
) {
onSendFeedbackClick()
true
}
},
)
}

private fun getTitleTextStyle(
fontFamily: FontFamily,
fontSizeMultiplier: Float,
Expand All @@ -341,11 +268,9 @@ private fun ReadingPreferencesScreenPreview() {
ReadingPreferencesScreen(
currentReadingPreferences = readingPreferences,
onCloseClick = {},
onSendFeedbackClick = {},
onThemeClick = { readingPreferences = readingPreferences.copy(theme = it) },
onFontFamilyClick = { readingPreferences = readingPreferences.copy(fontFamily = it) },
onFontSizeClick = { readingPreferences = readingPreferences.copy(fontSize = it) },
isFeedbackEnabled = true,
onBackgroundColorUpdate = {},
)
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ public enum Stat {
READER_FOLLOWING_FETCHED,
READER_READING_PREFERENCES_OPENED,
READER_READING_PREFERENCES_CLOSED,
READER_READING_PREFERENCES_FEEDBACK_TAPPED,
READER_READING_PREFERENCES_ITEM_TAPPED,
READER_READING_PREFERENCES_SAVED,
READER_ANNOUNCEMENT_CARD_DISMISSED,
Expand Down