@@ -34,15 +34,9 @@ import androidx.compose.ui.platform.LocalContext
34
34
import androidx.compose.ui.platform.LocalHapticFeedback
35
35
import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
36
36
import androidx.compose.ui.res.stringResource
37
- import androidx.compose.ui.semantics.onClick
38
- import androidx.compose.ui.semantics.semantics
39
- import androidx.compose.ui.text.LinkAnnotation
40
- import androidx.compose.ui.text.SpanStyle
41
37
import androidx.compose.ui.text.TextStyle
42
- import androidx.compose.ui.text.buildAnnotatedString
43
38
import androidx.compose.ui.text.font.FontFamily
44
39
import androidx.compose.ui.text.font.FontWeight
45
- import androidx.compose.ui.text.style.TextDecoration
46
40
import androidx.compose.ui.tooling.preview.Preview
47
41
import androidx.compose.ui.unit.sp
48
42
import org.wordpress.android.R
@@ -63,19 +57,15 @@ private const val TEXT_LINE_HEIGHT_MULTIPLIER = 1.6f
63
57
fun ReadingPreferencesScreen (
64
58
currentReadingPreferences : ReaderReadingPreferences ,
65
59
onCloseClick : () -> Unit ,
66
- onSendFeedbackClick : () -> Unit ,
67
60
onThemeClick : (ReaderReadingPreferences .Theme ) -> Unit ,
68
61
onFontFamilyClick : (ReaderReadingPreferences .FontFamily ) -> Unit ,
69
62
onFontSizeClick : (ReaderReadingPreferences .FontSize ) -> Unit ,
70
63
onBackgroundColorUpdate : (Int ) -> Unit ,
71
- isFeedbackEnabled : Boolean ,
72
- isHapticsFeedbackEnabled : Boolean = true,
73
64
) {
74
65
val themeValues = ReaderReadingPreferences .ThemeValues .from(LocalContext .current, currentReadingPreferences.theme)
75
66
val backgroundColor by animateColorAsState(Color (themeValues.intBackgroundColor), label = " backgroundColor" )
76
67
val baseTextColor by animateColorAsState(Color (themeValues.intBaseTextColor), label = " baseTextColor" )
77
68
val textColor by animateColorAsState(Color (themeValues.intTextColor), label = " textColor" )
78
- val linkColor by animateColorAsState(Color (themeValues.intLinkColor), label = " linkColor" )
79
69
80
70
SideEffect {
81
71
// update background color based on value animation and notify the parent
@@ -87,7 +77,7 @@ fun ReadingPreferencesScreen(
87
77
val fontSize = currentReadingPreferences.fontSize.toSp()
88
78
val fontSizeMultiplier = currentReadingPreferences.fontSize.multiplier
89
79
90
- val haptics = LocalHapticFeedback .current. takeIf { isHapticsFeedbackEnabled }
80
+ val haptics = LocalHapticFeedback .current
91
81
92
82
Column (
93
83
modifier = Modifier
@@ -145,14 +135,6 @@ fun ReadingPreferencesScreen(
145
135
style = contentStyle,
146
136
)
147
137
148
- if (isFeedbackEnabled) {
149
- ReadingPreferencesPreviewFeedback (
150
- onSendFeedbackClick = onSendFeedbackClick,
151
- textStyle = contentStyle,
152
- linkColor = linkColor,
153
- )
154
- }
155
-
156
138
// Tags
157
139
FlowRow (
158
140
modifier = Modifier .fillMaxWidth(),
@@ -195,7 +177,7 @@ fun ReadingPreferencesScreen(
195
177
theme = theme,
196
178
isSelected = theme == currentReadingPreferences.theme,
197
179
onClick = {
198
- haptics? .performHapticFeedback(HapticFeedbackType .LongPress )
180
+ haptics.performHapticFeedback(HapticFeedbackType .LongPress )
199
181
onThemeClick(theme)
200
182
},
201
183
)
@@ -218,7 +200,7 @@ fun ReadingPreferencesScreen(
218
200
fontFamily = fontFamily,
219
201
isSelected = fontFamily == currentReadingPreferences.fontFamily,
220
202
onClick = {
221
- haptics? .performHapticFeedback(HapticFeedbackType .LongPress )
203
+ haptics.performHapticFeedback(HapticFeedbackType .LongPress )
222
204
onFontFamilyClick(fontFamily)
223
205
},
224
206
)
@@ -235,7 +217,7 @@ fun ReadingPreferencesScreen(
235
217
previewFontFamily = fontFamily,
236
218
selectedFontSize = currentReadingPreferences.fontSize,
237
219
onFontSizeSelected = {
238
- haptics? .performHapticFeedback(HapticFeedbackType .LongPress )
220
+ haptics.performHapticFeedback(HapticFeedbackType .LongPress )
239
221
onFontSizeClick(it)
240
222
},
241
223
)
@@ -260,55 +242,6 @@ private fun ExperimentalBadge(
260
242
)
261
243
}
262
244
263
- @Composable
264
- private fun ReadingPreferencesPreviewFeedback (
265
- onSendFeedbackClick : () -> Unit ,
266
- textStyle : TextStyle ,
267
- linkColor : Color ,
268
- ) {
269
- val linkString = stringResource(R .string.reader_preferences_screen_preview_text_feedback_link)
270
- val feedbackString = stringResource(R .string.reader_preferences_screen_preview_text_feedback, linkString)
271
- val annotatedString = buildAnnotatedString {
272
- append(feedbackString)
273
-
274
- val startIndex = feedbackString.indexOf(linkString)
275
- val endIndex = startIndex + linkString.length
276
-
277
- addStyle(
278
- style = SpanStyle (
279
- color = linkColor,
280
- textDecoration = TextDecoration .Underline ,
281
- ),
282
- start = startIndex,
283
- end = endIndex,
284
- )
285
-
286
- addLink(
287
- clickable = LinkAnnotation .Clickable (
288
- tag = " url" ,
289
- linkInteractionListener = {
290
- onSendFeedbackClick()
291
- }
292
- ),
293
- start = startIndex,
294
- end = endIndex,
295
- )
296
- }
297
-
298
- val buttonLabel = stringResource(R .string.reader_preferences_screen_preview_text_feedback_label)
299
- Text (
300
- text = annotatedString,
301
- style = textStyle,
302
- modifier = Modifier .semantics {
303
- onClick(
304
- label = buttonLabel,
305
- ) {
306
- onSendFeedbackClick()
307
- true
308
- }
309
- },
310
- )
311
- }
312
245
313
246
private fun getTitleTextStyle (
314
247
fontFamily : FontFamily ,
@@ -335,11 +268,9 @@ private fun ReadingPreferencesScreenPreview() {
335
268
ReadingPreferencesScreen (
336
269
currentReadingPreferences = readingPreferences,
337
270
onCloseClick = {},
338
- onSendFeedbackClick = {},
339
271
onThemeClick = { readingPreferences = readingPreferences.copy(theme = it) },
340
272
onFontFamilyClick = { readingPreferences = readingPreferences.copy(fontFamily = it) },
341
273
onFontSizeClick = { readingPreferences = readingPreferences.copy(fontSize = it) },
342
- isFeedbackEnabled = true ,
343
274
onBackgroundColorUpdate = {},
344
275
)
345
276
}
0 commit comments