@onekeyfe/react-native-native-list 6.8.0-3 → 6.8.0-31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +3 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +18 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +12 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +166 -36
- package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +3 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +8 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +6 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +21 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +24 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListRowUpdates.kt +34 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +11 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListTitleSegmentLayout.kt +71 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListTitleSegmentsView.kt +126 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +84 -9
- package/android/src/main/res/values/native_scroll_coordinator_ids.xml +1 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentitySubtitleBindingTest.kt +177 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +2 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListTitleSegmentLayoutTest.kt +130 -0
- package/docs/ROW_TEMPLATES.md +8 -1
- package/docs/SPEC.md +312 -5
- package/docs/STYLE_SPEC.md +7 -1
- package/ios/NativeListAccessoryStack.swift +22 -0
- package/ios/NativeListActivityDetailsView.swift +45 -1
- package/ios/NativeListDataRowRenderer.swift +12 -5
- package/ios/NativeListIdentityRenderer.swift +145 -66
- package/ios/NativeListLeadingVisual.swift +8 -0
- package/ios/NativeListMarketRenderer.swift +6 -2
- package/ios/NativeListModels.swift +7 -0
- package/ios/NativeListResolvedText.swift +9 -7
- package/ios/NativeListSectionHeaderRenderer.swift +9 -43
- package/ios/NativeListTextStyles.swift +72 -12
- package/ios/NativeListTitleSegmentLayout.swift +72 -0
- package/ios/NativeListTitleSegmentsLabel.swift +92 -0
- package/ios/RNCNativeListView.swift +203 -45
- package/ios/tests/NativeListActivityPresentationTests.swift +137 -0
- package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +155 -0
- package/ios/tests/NativeListLifecycleTests.swift +298 -24
- package/ios/tests/NativeListMediaVisibilityTests.swift +2 -1
- package/lib/module/models.js +2 -0
- package/lib/module/validation.js +96 -13
- package/lib/module/web/NativeListWebEngine.js +427 -100
- package/lib/module/web/templates/ActivityRowRenderer.js +1 -1
- package/lib/module/web/templates/IdentityRowRenderer.js +134 -3
- package/lib/module/web/templates/MarketRowRenderer.js +2 -0
- package/lib/module/web/templates/MediaTileRowRenderer.js +1 -0
- package/lib/module/web/templates/RowElements.js +2 -2
- package/lib/module/web/templates/RowText.js +2 -0
- package/lib/typescript/src/models.d.ts +35 -1
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +17 -2
- package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +6 -2
- package/lib/typescript/src/web/templates/RowVisual.d.ts +1 -1
- package/package.json +1 -1
- package/src/models.ts +38 -0
- package/src/validation.ts +196 -6
- package/src/web/NativeListWebEngine.ts +671 -112
- package/src/web/templates/ActivityRowRenderer.ts +1 -1
- package/src/web/templates/IdentityRowRenderer.ts +208 -3
- package/src/web/templates/MarketRowRenderer.ts +2 -0
- package/src/web/templates/MediaTileRowRenderer.ts +1 -0
- package/src/web/templates/RowElements.ts +3 -2
- package/src/web/templates/RowText.ts +6 -0
- package/src/web/templates/RowVisual.ts +2 -1
package/android/build.gradle
CHANGED
|
@@ -75,6 +75,8 @@ android {
|
|
|
75
75
|
disable "GradleCompatible"
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
testOptions { unitTests.includeAndroidResources = true }
|
|
79
|
+
|
|
78
80
|
compileOptions {
|
|
79
81
|
sourceCompatibility JavaVersion.VERSION_1_8
|
|
80
82
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
@@ -110,4 +112,5 @@ dependencies {
|
|
|
110
112
|
implementation project(":onekeyfe_react-native-native-logger")
|
|
111
113
|
implementation project(":onekeyfe_react-native-image")
|
|
112
114
|
testImplementation "junit:junit:4.13.2"
|
|
115
|
+
testImplementation "org.robolectric:robolectric:4.17"
|
|
113
116
|
}
|
|
@@ -255,10 +255,12 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
|
|
|
255
255
|
v.ellipsize = null
|
|
256
256
|
v.setLineSpacing(0f, 1f)
|
|
257
257
|
v.letterSpacing = 0f
|
|
258
|
+
v.fontFeatureSettings = null
|
|
258
259
|
}
|
|
259
260
|
trailingIcons.forEach {
|
|
260
261
|
it.visibility = GONE
|
|
261
262
|
it.setOnClickListener(null)
|
|
263
|
+
it.setTag(R.id.onekey_native_list_reorder_handle, null)
|
|
262
264
|
it.background = null
|
|
263
265
|
it.useSourceScale = selectorUsesSourceScale
|
|
264
266
|
it.glyphSizeDp = null
|
|
@@ -441,13 +443,20 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
|
|
|
441
443
|
theme,
|
|
442
444
|
)
|
|
443
445
|
"menu" -> showTrailingMenu(textIndex++, accessory.optString("actionKey"))
|
|
444
|
-
"drag" ->
|
|
446
|
+
"drag" -> {
|
|
447
|
+
val handleIndex = textIndex++
|
|
445
448
|
showTrailingIcon(
|
|
446
|
-
|
|
449
|
+
handleIndex,
|
|
447
450
|
item,
|
|
448
|
-
|
|
451
|
+
// ListItem draws the handle as a medium tertiary IconButton.
|
|
452
|
+
JSONObject(accessory.toString()).apply {
|
|
453
|
+
put("name", "DragOutline")
|
|
454
|
+
put("buttonStyle", "tertiary")
|
|
455
|
+
},
|
|
449
456
|
theme,
|
|
450
457
|
)
|
|
458
|
+
trailingIcons.getOrNull(handleIndex)?.setTag(R.id.onekey_native_list_reorder_handle, true)
|
|
459
|
+
}
|
|
451
460
|
"icon" -> showTrailingIcon(textIndex++, item, accessory, theme)
|
|
452
461
|
"spinner" -> spinner.visibility = VISIBLE
|
|
453
462
|
"progress" ->
|
|
@@ -719,9 +728,13 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
|
|
|
719
728
|
icon.contentDescription = data.optString("accessibilityLabel").takeIf { it.isNotEmpty() }
|
|
720
729
|
if (data.optString("buttonStyle") == "tertiary") {
|
|
721
730
|
icon.glyphSizeDp = 24
|
|
731
|
+
// A rename + drag pair sits in ListItem's <XStack gap="$6">: 24dp between
|
|
732
|
+
// the buttons' 24dp layout slots, after the second frame's m=-7.
|
|
733
|
+
val pairGap =
|
|
734
|
+
orientation == HORIZONTAL && index > 0 && data.optString("name") == "DragOutline"
|
|
722
735
|
icon.layoutParams = LayoutParams(dp(38), dp(38)).apply {
|
|
723
736
|
gravity = Gravity.CENTER_VERTICAL
|
|
724
|
-
marginStart = -dp(7)
|
|
737
|
+
marginStart = if (pairGap) dp(24) - dp(7) else -dp(7)
|
|
725
738
|
marginEnd = -dp(7)
|
|
726
739
|
}
|
|
727
740
|
icon.background = StateListDrawable().apply {
|
|
@@ -895,6 +908,7 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
|
|
|
895
908
|
if (style.has("offsetY"))
|
|
896
909
|
(view as? NativeListTextView)?.opticalOffsetY =
|
|
897
910
|
(style.optDouble("offsetY") * resources.displayMetrics.density).toFloat()
|
|
911
|
+
applyNativeListTextSpacing(view, style, view.fontFeatureSettings)
|
|
898
912
|
style.optString("alignment").takeIf(String::isNotEmpty)?.let {
|
|
899
913
|
view.gravity =
|
|
900
914
|
(view.gravity and Gravity.VERTICAL_GRAVITY_MASK) or
|
|
@@ -22,7 +22,10 @@ internal class NativeListActivityDetailsView(private val reactContext: ThemedRea
|
|
|
22
22
|
var leadingOverhangs = false
|
|
23
23
|
private set
|
|
24
24
|
private val identity = LinearLayout(context).apply { orientation = VERTICAL }
|
|
25
|
-
|
|
25
|
+
// Packs the title at its intrinsic width so badges follow the text (OK-67497).
|
|
26
|
+
private val titleLine = PackedTitleLineLayout(context).apply {
|
|
27
|
+
orientation = HORIZONTAL; gravity = Gravity.CENTER_VERTICAL; packsChildrenAtStart = true
|
|
28
|
+
}
|
|
26
29
|
private val title = NativeListTextView(context)
|
|
27
30
|
private val description = NativeListTextView(context)
|
|
28
31
|
private val status = NativeListTextView(context)
|
|
@@ -125,6 +128,14 @@ internal class NativeListActivityDetailsView(private val reactContext: ThemedRea
|
|
|
125
128
|
titleLine.addView(label, LayoutParams(-2, -2).apply { marginStart = if (style.has("titleBadgeGap")) px(style.optDouble("titleBadgeGap")) else dp(4) })
|
|
126
129
|
badges.add(label)
|
|
127
130
|
}
|
|
131
|
+
// PackedTitleLineLayout rewrites the title's params and cap only while badges follow it.
|
|
132
|
+
// Without badges, restore the fresh-row state so the title keeps the whole line and its
|
|
133
|
+
// `alignment` (center/end) behaves the same on a recycled row as on a new one.
|
|
134
|
+
if (badges.isEmpty()) {
|
|
135
|
+
(title.layoutParams as LayoutParams).apply { width = 0; weight = 1f }
|
|
136
|
+
title.maxWidth = Int.MAX_VALUE
|
|
137
|
+
title.requestLayout()
|
|
138
|
+
}
|
|
128
139
|
val amountData = data.optJSONArray("amounts")
|
|
129
140
|
val count = amountData?.length() ?: 0
|
|
130
141
|
while (amountViews.size > count) { val child = amountViews.removeAt(amountViews.lastIndex); child.recycle(); amounts.removeView(child) }
|
|
@@ -31,6 +31,8 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
31
31
|
private val titleLine = PackedTitleLineLayout(context)
|
|
32
32
|
private val title = NativeListTextView(context)
|
|
33
33
|
private val titleIcon = OneKeyIconView(context)
|
|
34
|
+
private val titleLeadingIcon = OneKeyIconView(context)
|
|
35
|
+
private val titleSegments = NativeListTitleSegmentsView(context)
|
|
34
36
|
private var titleImage: NativeListImageSlot? = null
|
|
35
37
|
private val subtitle = NativeListTextView(context)
|
|
36
38
|
private val tertiary = NativeListTextView(context)
|
|
@@ -109,8 +111,13 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
109
111
|
mainColumn.gravity = Gravity.CENTER_VERTICAL
|
|
110
112
|
titleLine.orientation = HORIZONTAL
|
|
111
113
|
titleLine.gravity = Gravity.CENTER_VERTICAL
|
|
114
|
+
titleLine.addView(titleLeadingIcon, LayoutParams(dp(16), dp(16)).apply { marginEnd = dp(6) })
|
|
112
115
|
titleLine.addView(title, LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f))
|
|
116
|
+
titleLine.addView(titleSegments, LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f))
|
|
113
117
|
titleLine.addView(titleIcon, LayoutParams(dp(20), dp(20)).apply { marginStart = dp(4) })
|
|
118
|
+
titleLine.titleChild = title
|
|
119
|
+
titleLeadingIcon.visibility = GONE
|
|
120
|
+
titleSegments.visibility = GONE
|
|
114
121
|
titleLine.addView(badgeLine)
|
|
115
122
|
trailingColumn.onAction = { key, view, slot, target ->
|
|
116
123
|
emitAction(key, view, "trailingAccessory", slot, target, trailingColumn.anchorInset(view))
|
|
@@ -157,6 +164,26 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
157
164
|
private fun JSONArray?.hasAccessory(kind: String) =
|
|
158
165
|
this != null && (0 until length()).any { optJSONObject(it)?.optString("kind") == kind }
|
|
159
166
|
|
|
167
|
+
override fun bindContentUpdate(
|
|
168
|
+
previous: NativeListItem,
|
|
169
|
+
item: NativeListItem,
|
|
170
|
+
theme: JSONObject?,
|
|
171
|
+
): Boolean {
|
|
172
|
+
val segments = item.json.optJSONArray("subtitleSegments") ?: return false
|
|
173
|
+
if (semanticSubtitleLabels.isEmpty() || semanticSubtitleLabels.size != segments.length() ||
|
|
174
|
+
!canUpdateIdentitySubtitle(previous, item)
|
|
175
|
+
) return false
|
|
176
|
+
|
|
177
|
+
val style = item.json.optJSONObject("style")?.optJSONObject("subtitle")
|
|
178
|
+
semanticSubtitleLabels.forEachIndexed { index, label ->
|
|
179
|
+
bindIdentitySubtitleLabel(label, segments.getJSONObject(index), theme)
|
|
180
|
+
style?.let { applyStyledText(label, it) }
|
|
181
|
+
applySelectorTextTypography(label, style)
|
|
182
|
+
label.requestLayout()
|
|
183
|
+
}
|
|
184
|
+
return true
|
|
185
|
+
}
|
|
186
|
+
|
|
160
187
|
override fun bindContent(
|
|
161
188
|
item: NativeListItem,
|
|
162
189
|
theme: JSONObject?,
|
|
@@ -172,8 +199,9 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
172
199
|
setOnLongClickListener(
|
|
173
200
|
if (longPressActionKey.isNotEmpty())
|
|
174
201
|
OnLongClickListener {
|
|
202
|
+
val actionItem = currentItem ?: return@OnLongClickListener false
|
|
175
203
|
val point = longPressPoint
|
|
176
|
-
if (!isEnabled || !
|
|
204
|
+
if (!isEnabled || !actionItem.isRowPressEnabled || actionItem.key != item.key ||
|
|
177
205
|
bindingEpoch != boundEpoch ||
|
|
178
206
|
(longPressPointEpoch == boundEpoch && point == null)) false
|
|
179
207
|
else {
|
|
@@ -182,7 +210,7 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
182
210
|
getLocationInWindow(location)
|
|
183
211
|
PointF(location[0] + it.x, location[1] + it.y)
|
|
184
212
|
}
|
|
185
|
-
onAction?.invoke(
|
|
213
|
+
onAction?.invoke(actionItem, longPressActionKey, null,
|
|
186
214
|
NativeListActionOrigin(this, this, bindingEpoch, "row",
|
|
187
215
|
windowPointPixels = windowPoint))
|
|
188
216
|
longPressPoint = null
|
|
@@ -223,6 +251,12 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
223
251
|
titleIcon.visibility = GONE
|
|
224
252
|
titleIcon.contentDescription = null
|
|
225
253
|
titleIcon.setOnClickListener(null)
|
|
254
|
+
titleLeadingIcon.visibility = GONE
|
|
255
|
+
titleLeadingIcon.contentDescription = null
|
|
256
|
+
titleSegments.visibility = GONE
|
|
257
|
+
titleSegments.clearRuns()
|
|
258
|
+
titleSegments.layoutParams = LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f)
|
|
259
|
+
titleLine.titleChild = title
|
|
226
260
|
for (view in listOf(title, subtitle, tertiary, badgeLine)) {
|
|
227
261
|
view.text = ""
|
|
228
262
|
view.visibility = GONE
|
|
@@ -343,6 +377,52 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
343
377
|
}
|
|
344
378
|
// Legacy: overhanging selector icons/checkboxes must not be clipped by row padding.
|
|
345
379
|
if (trailingColumn.parent === this && trailingColumn.requestsUnclippedHost) clipToPadding = false
|
|
380
|
+
if (titleSegments.visibility == VISIBLE)
|
|
381
|
+
bindTitleRuns(item, theme, style.optJSONObject("title"))
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// Runs take the title's final text appearance and color unless they set
|
|
385
|
+
// their own tone or weight.
|
|
386
|
+
private fun bindTitleRuns(item: NativeListItem, theme: JSONObject?, titleStyle: JSONObject?) {
|
|
387
|
+
titleSegments.typeface = title.typeface
|
|
388
|
+
titleSegments.setTextSize(android.util.TypedValue.COMPLEX_UNIT_PX, title.textSize)
|
|
389
|
+
titleSegments.includeFontPadding = title.includeFontPadding
|
|
390
|
+
titleSegments.letterSpacing = title.letterSpacing
|
|
391
|
+
titleSegments.opticalOffsetY = title.opticalOffsetY
|
|
392
|
+
titleSegments.maxLines = 1
|
|
393
|
+
titleSegments.ellipsize = TextUtils.TruncateAt.END
|
|
394
|
+
TextViewCompat.setLineHeight(titleSegments, title.lineHeight)
|
|
395
|
+
// An explicit line height is a span on the title's text, which
|
|
396
|
+
// `title.lineHeight` does not report.
|
|
397
|
+
titleSegments.explicitLineHeight =
|
|
398
|
+
titleStyle?.takeIf { it.has("lineHeight") }?.let { stylePx(it.optDouble("lineHeight")) }
|
|
399
|
+
if (titleSegments.explicitLineHeight != null) titleSegments.setLineSpacing(0f, 1f)
|
|
400
|
+
val baseColor = title.currentTextColor
|
|
401
|
+
titleSegments.setTextColor(baseColor)
|
|
402
|
+
val segments = item.json.optJSONArray("titleSegments") ?: return
|
|
403
|
+
val runs =
|
|
404
|
+
(0 until segments.length()).mapNotNull { index ->
|
|
405
|
+
val segment = segments.optJSONObject(index) ?: return@mapNotNull null
|
|
406
|
+
NativeListTitleSegmentsView.Run(
|
|
407
|
+
text = nativeListTitleRunText(segment.optString("text")),
|
|
408
|
+
typeface =
|
|
409
|
+
when (segment.optString("fontWeight")) {
|
|
410
|
+
"medium" -> fonts.medium(context)
|
|
411
|
+
"regular" -> fonts.regular(context)
|
|
412
|
+
else -> null
|
|
413
|
+
},
|
|
414
|
+
color =
|
|
415
|
+
when (segment.optString("tone")) {
|
|
416
|
+
"secondary" -> color(theme, "secondaryText", "#0000009B")
|
|
417
|
+
"primary" -> color(theme, "primaryText", "#000000DF")
|
|
418
|
+
else -> baseColor
|
|
419
|
+
},
|
|
420
|
+
shrink = segment.optBoolean("shrink", false),
|
|
421
|
+
maxWidthRatio =
|
|
422
|
+
if (segment.has("maxWidthRatio")) segment.optDouble("maxWidthRatio").toFloat() else null,
|
|
423
|
+
)
|
|
424
|
+
}
|
|
425
|
+
titleSegments.setRuns(runs, item.json.optString("title"))
|
|
346
426
|
}
|
|
347
427
|
|
|
348
428
|
private fun styleGap(column: LinearLayout, gap: Int) {
|
|
@@ -365,19 +445,21 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
365
445
|
)
|
|
366
446
|
return
|
|
367
447
|
fun visit(view: View) {
|
|
368
|
-
if (view is TextView)
|
|
369
|
-
view.fontFeatureSettings = "tnum"
|
|
370
|
-
if (sourceScale) {
|
|
371
|
-
paintDefaults.putIfAbsent(view, view.paintFlags)
|
|
372
|
-
// Explicit style fontSize/lineHeight are kept as the caller set them.
|
|
373
|
-
applyNativeListSourceTypography(view, explicitStyle(view))
|
|
374
|
-
}
|
|
375
|
-
}
|
|
448
|
+
if (view is TextView) applySelectorTextTypography(view, explicitStyle(view))
|
|
376
449
|
if (view is ViewGroup) for (i in 0 until view.childCount) visit(view.getChildAt(i))
|
|
377
450
|
}
|
|
378
451
|
visit(this)
|
|
379
452
|
}
|
|
380
453
|
|
|
454
|
+
private fun applySelectorTextTypography(view: TextView, style: JSONObject?) {
|
|
455
|
+
if (sourceScale) {
|
|
456
|
+
paintDefaults.putIfAbsent(view, view.paintFlags)
|
|
457
|
+
applyNativeListSourceTypography(view, style)
|
|
458
|
+
} else {
|
|
459
|
+
applyNativeListTextSpacing(view, style)
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
381
463
|
private fun addLeading(visual: JSONObject?, sizeDp: Int, spacingDp: Int = 12) {
|
|
382
464
|
// Legacy: a missing visual still reserves an empty, transparent leading slot.
|
|
383
465
|
val descriptor = visual ?: JSONObject().put("backgroundColor", "#00000000")
|
|
@@ -393,7 +475,13 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
393
475
|
}
|
|
394
476
|
leadingFrame.bitmapBorderWidth =
|
|
395
477
|
if (descriptor.optString("borderColor").isNotEmpty() &&
|
|
396
|
-
descriptor.optString("borderStyle") != "dashed")
|
|
478
|
+
descriptor.optString("borderStyle") != "dashed") {
|
|
479
|
+
// Optional borderWidth (logical units); a hairline still draws one physical pixel.
|
|
480
|
+
descriptor.optDouble("borderWidth", Double.NaN)
|
|
481
|
+
.takeIf { it.isFinite() && it > 0 && it <= 4 }
|
|
482
|
+
?.let { (it * resources.displayMetrics.density).roundToInt().coerceAtLeast(1) }
|
|
483
|
+
?: dp(1)
|
|
484
|
+
} else 0
|
|
397
485
|
if (visual == null) leadingFrame.recycle()
|
|
398
486
|
val item = currentItem!!
|
|
399
487
|
val style = item.json.optJSONObject("style")?.optJSONObject("image") ?: JSONObject()
|
|
@@ -476,7 +564,8 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
476
564
|
val imageWidth = titleImage?.view?.takeIf { it.visibility == VISIBLE }?.let {
|
|
477
565
|
it.layoutParams.width + dp(4)
|
|
478
566
|
} ?: 0
|
|
479
|
-
val icon = (if (titleIcon.visibility == VISIBLE) dp(24) else 0) + imageWidth
|
|
567
|
+
val icon = (if (titleIcon.visibility == VISIBLE) dp(24) else 0) + imageWidth +
|
|
568
|
+
(if (titleLeadingIcon.visibility == VISIBLE) dp(22) else 0)
|
|
480
569
|
(inner * ratio).roundToInt()
|
|
481
570
|
.minus(leading.width + leading.marginEnd + icon)
|
|
482
571
|
.coerceAtLeast(0)
|
|
@@ -487,9 +576,10 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
487
576
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
|
488
577
|
if (titleSuffixLabels.isNotEmpty()) {
|
|
489
578
|
val fixedWidth =
|
|
490
|
-
(
|
|
579
|
+
(0 until titleLine.childCount).sumOf { index ->
|
|
491
580
|
val view = titleLine.getChildAt(index)
|
|
492
|
-
if (view.visibility == GONE ||
|
|
581
|
+
if (view.visibility == GONE || view === titleLine.titleChild ||
|
|
582
|
+
titleSuffixLabels.any { it === view }) 0
|
|
493
583
|
else {
|
|
494
584
|
val margins = view.layoutParams as MarginLayoutParams
|
|
495
585
|
view.measuredWidth + margins.leftMargin + margins.rightMargin
|
|
@@ -722,11 +812,11 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
722
812
|
leadingActionIcon.setOnClickListener {
|
|
723
813
|
emitAction(item, action.optString("actionKey"), null, leadingActionIcon, "leadingAction")
|
|
724
814
|
}
|
|
725
|
-
// ListItem.IconButton is
|
|
726
|
-
//
|
|
727
|
-
//
|
|
728
|
-
setPadding(dp(
|
|
729
|
-
addView(leadingActionIcon, LayoutParams(dp(36), dp(36)).apply { marginEnd = dp(
|
|
815
|
+
// ListItem.IconButton is 38dp (6dp padding plus a 1dp border) with m=-7,
|
|
816
|
+
// so its glyph sits on a 24dp slot at the 12dp padding. This 36dp frame
|
|
817
|
+
// centers the same glyph with a 6dp inset and a 6dp following gap.
|
|
818
|
+
setPadding(dp(6), paddingTop, paddingRight, paddingBottom)
|
|
819
|
+
addView(leadingActionIcon, LayoutParams(dp(36), dp(36)).apply { marginEnd = dp(6) })
|
|
730
820
|
}
|
|
731
821
|
addLeading(
|
|
732
822
|
leading,
|
|
@@ -753,6 +843,38 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
753
843
|
titleLine.packsChildrenAtStart = true
|
|
754
844
|
title.ellipsize = TextUtils.TruncateAt.END
|
|
755
845
|
showText(title, item.json.optString("title"), item.json.optInt("titleLines", 1))
|
|
846
|
+
// Runs replace the drawn title except where `title` itself is highlighted;
|
|
847
|
+
// their content is bound once the title style is final.
|
|
848
|
+
if (nativeListShowsTitleRuns(
|
|
849
|
+
item.json.optString("presentation"),
|
|
850
|
+
item.json.optJSONArray("titleSegments")?.length() ?: 0,
|
|
851
|
+
item.json.optJSONArray("titleMatch")?.length() ?: 0,
|
|
852
|
+
)
|
|
853
|
+
) {
|
|
854
|
+
title.visibility = GONE
|
|
855
|
+
titleSegments.visibility = VISIBLE
|
|
856
|
+
titleLine.titleChild = titleSegments
|
|
857
|
+
}
|
|
858
|
+
val leadingIcon = item.json.optJSONObject("titleLeadingIcon")
|
|
859
|
+
?.takeIf { nativeListAllowsTitleDecorations(item.json.optString("presentation")) }
|
|
860
|
+
leadingIcon?.let { icon ->
|
|
861
|
+
titleLeadingIcon.iconName = icon.optString("name")
|
|
862
|
+
titleLeadingIcon.glyphSizeDp = 16
|
|
863
|
+
titleLeadingIcon.useSourceScale = sourceScale
|
|
864
|
+
// The slot was created before this row's scale was known; it follows the
|
|
865
|
+
// scale the glyph is drawn with.
|
|
866
|
+
titleLeadingIcon.layoutParams = LayoutParams(dp(16), dp(16)).apply { marginEnd = dp(6) }
|
|
867
|
+
titleLeadingIcon.tintColor = safeColor(
|
|
868
|
+
icon.optString("tintColor").takeIf(String::isNotEmpty),
|
|
869
|
+
color(theme, "iconSubdued", "#00000072"),
|
|
870
|
+
)
|
|
871
|
+
titleLeadingIcon.contentDescription =
|
|
872
|
+
icon.optString("accessibilityLabel").takeIf(String::isNotEmpty)
|
|
873
|
+
titleLeadingIcon.importantForAccessibility =
|
|
874
|
+
if (titleLeadingIcon.contentDescription == null) View.IMPORTANT_FOR_ACCESSIBILITY_NO
|
|
875
|
+
else View.IMPORTANT_FOR_ACCESSIBILITY_YES
|
|
876
|
+
titleLeadingIcon.visibility = VISIBLE
|
|
877
|
+
}
|
|
756
878
|
item.json.optJSONArray("titleSuffixes")?.let { suffixes ->
|
|
757
879
|
for (index in 0 until suffixes.length()) {
|
|
758
880
|
val suffix = suffixes.optJSONObject(index) ?: continue
|
|
@@ -827,27 +949,11 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
827
949
|
}
|
|
828
950
|
val label =
|
|
829
951
|
NativeListTextView(context).apply {
|
|
830
|
-
text = segment.optString("text")
|
|
831
|
-
typeface = fonts.regular(context)
|
|
832
|
-
textSize = sp(14f)
|
|
833
952
|
includeFontPadding = false
|
|
834
953
|
maxLines = 1
|
|
835
954
|
ellipsize = TextUtils.TruncateAt.END
|
|
836
|
-
val toneKey =
|
|
837
|
-
when (segment.optString("tone")) {
|
|
838
|
-
"primary" -> "primaryText"
|
|
839
|
-
"disabled" -> "disabledText"
|
|
840
|
-
"caution" -> "caution"
|
|
841
|
-
"positive" -> "positive"
|
|
842
|
-
"negative" -> "negative"
|
|
843
|
-
else -> "secondaryText"
|
|
844
|
-
}
|
|
845
|
-
setTextColor(
|
|
846
|
-
color(theme, toneKey, if (toneKey == "caution") "#AB6400" else "#0000009B")
|
|
847
|
-
)
|
|
848
955
|
}
|
|
849
|
-
|
|
850
|
-
applyValueSegments(label, segment.optJSONArray("textSegments"), 14, 20, false)
|
|
956
|
+
bindIdentitySubtitleLabel(label, segment, theme)
|
|
851
957
|
semanticSubtitleLabels.add(label)
|
|
852
958
|
line.addView(label, LayoutParams(LayoutParams.WRAP_CONTENT, dp(20)))
|
|
853
959
|
}
|
|
@@ -921,6 +1027,29 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
921
1027
|
),
|
|
922
1028
|
)
|
|
923
1029
|
trailingColumn.endInset?.let { setPadding(paddingLeft, paddingTop, it, paddingBottom) }
|
|
1030
|
+
// ListItem keeps 12dp between the text and a tertiary button's 24dp slot; the
|
|
1031
|
+
// button's m=-7 would otherwise pull its slot over the text column.
|
|
1032
|
+
val first = accessories.optJSONObject(0)
|
|
1033
|
+
if (first?.optString("kind") == "drag" || first?.optString("buttonStyle") == "tertiary") {
|
|
1034
|
+
(mainColumn.layoutParams as LayoutParams).marginEnd = dp(12)
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
private fun bindIdentitySubtitleLabel(label: TextView, segment: JSONObject, theme: JSONObject?) {
|
|
1039
|
+
label.text = segment.optString("text")
|
|
1040
|
+
label.typeface = fonts.regular(context)
|
|
1041
|
+
label.textSize = sp(14f)
|
|
1042
|
+
TextViewCompat.setLineHeight(label, dp(20))
|
|
1043
|
+
val toneKey = when (segment.optString("tone")) {
|
|
1044
|
+
"primary" -> "primaryText"
|
|
1045
|
+
"disabled" -> "disabledText"
|
|
1046
|
+
"caution" -> "caution"
|
|
1047
|
+
"positive" -> "positive"
|
|
1048
|
+
"negative" -> "negative"
|
|
1049
|
+
else -> "secondaryText"
|
|
1050
|
+
}
|
|
1051
|
+
label.setTextColor(color(theme, toneKey, if (toneKey == "caution") "#AB6400" else "#0000009B"))
|
|
1052
|
+
applyValueSegments(label, segment.optJSONArray("textSegments"), 14, 20, false)
|
|
924
1053
|
}
|
|
925
1054
|
|
|
926
1055
|
private fun applyValueSegments(
|
|
@@ -1021,6 +1150,7 @@ internal class NativeListIdentityRowView(context: ThemedReactContext, fonts: Nat
|
|
|
1021
1150
|
if (style.has("offsetY"))
|
|
1022
1151
|
(view as? NativeListTextView)?.opticalOffsetY =
|
|
1023
1152
|
(style.optDouble("offsetY") * resources.displayMetrics.density).toFloat()
|
|
1153
|
+
applyNativeListTextSpacing(view, style)
|
|
1024
1154
|
style.optString("alignment").takeIf(String::isNotEmpty)?.let {
|
|
1025
1155
|
view.gravity =
|
|
1026
1156
|
(view.gravity and Gravity.VERTICAL_GRAVITY_MASK) or
|
|
@@ -401,10 +401,10 @@ internal class NativeListMarketRowView(context: ThemedReactContext, fonts: Nativ
|
|
|
401
401
|
defaultAlignment: String,
|
|
402
402
|
) {
|
|
403
403
|
view.includeFontPadding = false
|
|
404
|
-
view.fontFeatureSettings = "tnum"
|
|
405
404
|
view.textSize =
|
|
406
405
|
sp(style?.optDouble("fontSize", defaultSize.toDouble())?.toFloat() ?: defaultSize)
|
|
407
406
|
view.typeface = marketTypeface(style?.optString("fontWeight").orEmpty(), defaultWeight)
|
|
407
|
+
applyNativeListTextSpacing(view, style)
|
|
408
408
|
view.setTextColor(safeColor(style?.optString("color"), defaultColor))
|
|
409
409
|
val alignment = style?.optString("alignment", defaultAlignment) ?: defaultAlignment
|
|
410
410
|
view.gravity =
|
|
@@ -437,6 +437,7 @@ internal class NativeListMarketRowView(context: ThemedReactContext, fonts: Nativ
|
|
|
437
437
|
kotlin.math.ceil(sourceSize.toDouble()).toFloat(),
|
|
438
438
|
)
|
|
439
439
|
}
|
|
440
|
+
applyNativeListTextSpacing(view, style)
|
|
440
441
|
// Legacy parity: keep marketText's subscript AbsoluteSizeSpan (ceil(0.6 x fontSize)).
|
|
441
442
|
val text = SpannableStringBuilder(view.text)
|
|
442
443
|
text.getSpans(0, text.length, NativeListLineHeightSpan::class.java).forEach(text::removeSpan)
|
|
@@ -703,8 +704,8 @@ internal class NativeListMarketRowView(context: ThemedReactContext, fonts: Nativ
|
|
|
703
704
|
}
|
|
704
705
|
badgeLabel.text = text
|
|
705
706
|
// OneKey patch: match SizableText's tabular numerals only for explicit Market metrics.
|
|
706
|
-
badgeLabel.fontFeatureSettings = if (badgeStyle != null) "tnum" else null
|
|
707
707
|
badgeLabel.textSize = sp(badgeStyle?.optDouble("fontSize", 11.0)?.toFloat() ?: 11f)
|
|
708
|
+
applyNativeListTextSpacing(badgeLabel, badgeStyle, if (badgeStyle != null) "tnum" else null)
|
|
708
709
|
badgeLabel.typeface =
|
|
709
710
|
marketTypeface(badgeStyle?.optString("fontWeight").orEmpty(), "medium")
|
|
710
711
|
if (badgeStyle?.has("lineHeight") == true) {
|
|
@@ -197,7 +197,8 @@ internal fun nativeListIdentityTrailingIsHorizontal(
|
|
|
197
197
|
first.actionKey.isEmpty()) ||
|
|
198
198
|
(kinds == listOf("icon", "icon") &&
|
|
199
199
|
first.name == "PencilOutline" &&
|
|
200
|
-
second.name == "DragOutline")
|
|
200
|
+
second.name == "DragOutline") ||
|
|
201
|
+
(kinds == listOf("icon", "drag") && first.name == "PencilOutline")
|
|
201
202
|
}
|
|
202
203
|
|
|
203
204
|
internal fun resolveNativeListSelectorBackgroundColor(
|
|
@@ -330,6 +331,8 @@ internal data class NativeListConfig(
|
|
|
330
331
|
val rowPressToggles: Boolean,
|
|
331
332
|
val selectedKeys: LinkedHashSet<String>,
|
|
332
333
|
val reorderable: Boolean,
|
|
334
|
+
/** `handle` starts a reorder only from a long press on a trailing `drag` accessory. */
|
|
335
|
+
val reorderFromHandleOnly: Boolean = false,
|
|
333
336
|
val pullToRefresh: Boolean,
|
|
334
337
|
val refreshTriggerDistance: Double? = null,
|
|
335
338
|
val refreshing: Boolean,
|
|
@@ -377,6 +380,9 @@ internal data class NativeListConfig(
|
|
|
377
380
|
val layout = root.getJSONObject("layout")
|
|
378
381
|
val selection = root.optJSONObject("selection")
|
|
379
382
|
val capabilities = root.optJSONObject("capabilities")
|
|
383
|
+
val reorderActivation = capabilities?.opt("reorderActivation")
|
|
384
|
+
require(reorderActivation == null || reorderActivation == "row" ||
|
|
385
|
+
reorderActivation == "handle") { "Invalid reorderActivation" }
|
|
380
386
|
val sectionIndex = capabilities?.optJSONObject("sectionIndex")
|
|
381
387
|
val rowArray = root.getJSONArray("rows")
|
|
382
388
|
val items = ArrayList<NativeListItem>(rowArray.length())
|
|
@@ -410,6 +416,7 @@ internal data class NativeListConfig(
|
|
|
410
416
|
rowPressToggles = selection?.optBoolean("rowPressToggles", false) ?: false,
|
|
411
417
|
selectedKeys = selectedKeys,
|
|
412
418
|
reorderable = capabilities?.optBoolean("reorderable", false) ?: false,
|
|
419
|
+
reorderFromHandleOnly = reorderActivation == "handle",
|
|
413
420
|
pullToRefresh = capabilities?.optBoolean("pullToRefresh", false) ?: false,
|
|
414
421
|
refreshTriggerDistance = capabilities?.optDouble("refreshTriggerDistance")?.takeIf { it.isFinite() && it > 0 },
|
|
415
422
|
refreshing = capabilities?.optBoolean("refreshing", false) ?: false,
|
|
@@ -109,6 +109,9 @@ internal class PackedTitleLineLayout(context: android.content.Context) : LinearL
|
|
|
109
109
|
var packsChildrenAtStart = false
|
|
110
110
|
// OneKey patch: optional cap for the Market subtitle's localized name.
|
|
111
111
|
var leadingTextMaxWidth = Int.MAX_VALUE
|
|
112
|
+
// The text view that takes what the other children leave; the first child
|
|
113
|
+
// when unset, so a glyph may precede the title once this names it.
|
|
114
|
+
var titleChild: TextView? = null
|
|
112
115
|
|
|
113
116
|
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
|
114
117
|
if (!packsChildrenAtStart || childCount < 2) {
|
|
@@ -116,13 +119,13 @@ internal class PackedTitleLineLayout(context: android.content.Context) : LinearL
|
|
|
116
119
|
return
|
|
117
120
|
}
|
|
118
121
|
|
|
119
|
-
val title = getChildAt(0)
|
|
122
|
+
val title = titleChild?.takeIf { it.parent === this } ?: getChildAt(0)
|
|
120
123
|
val widthMode = MeasureSpec.getMode(widthMeasureSpec)
|
|
121
124
|
val widthSize = MeasureSpec.getSize(widthMeasureSpec)
|
|
122
125
|
var accessoryWidth = 0
|
|
123
|
-
for (index in
|
|
126
|
+
for (index in 0 until childCount) {
|
|
124
127
|
val child = getChildAt(index)
|
|
125
|
-
if (child.visibility == GONE) continue
|
|
128
|
+
if (child === title || child.visibility == GONE) continue
|
|
126
129
|
measureChildWithMargins(
|
|
127
130
|
child,
|
|
128
131
|
widthMeasureSpec,
|
|
@@ -28,6 +28,12 @@ internal abstract class NativeListRendererRowView(protected val reactContext: Th
|
|
|
28
28
|
checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String,
|
|
29
29
|
)
|
|
30
30
|
|
|
31
|
+
protected open fun bindContentUpdate(
|
|
32
|
+
previous: NativeListItem,
|
|
33
|
+
item: NativeListItem,
|
|
34
|
+
theme: JSONObject?,
|
|
35
|
+
): Boolean = false
|
|
36
|
+
|
|
31
37
|
protected open fun bindSelectionContent(
|
|
32
38
|
item: NativeListItem,
|
|
33
39
|
checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String,
|
|
@@ -50,7 +56,8 @@ internal abstract class NativeListRendererRowView(protected val reactContext: Th
|
|
|
50
56
|
}
|
|
51
57
|
|
|
52
58
|
protected fun retainBoundItem(item: NativeListItem): Boolean {
|
|
53
|
-
if (
|
|
59
|
+
if (renderedItem?.key != item.key) return false
|
|
60
|
+
renderedItem = item
|
|
54
61
|
current = item
|
|
55
62
|
tag = item
|
|
56
63
|
return true
|
|
@@ -106,6 +113,8 @@ internal abstract class NativeListRendererRowView(protected val reactContext: Th
|
|
|
106
113
|
protected open val pressedColorName = "rowPressedBackground"
|
|
107
114
|
protected open val pressedColorFallback = "#00000017"
|
|
108
115
|
private var current: NativeListItem? = null
|
|
116
|
+
// Selection can advance current before RecyclerView binds the new content.
|
|
117
|
+
private var renderedItem: NativeListItem? = null
|
|
109
118
|
protected val boundItem: NativeListItem?
|
|
110
119
|
get() = current
|
|
111
120
|
private var theme: JSONObject? = null
|
|
@@ -189,7 +198,8 @@ internal abstract class NativeListRendererRowView(protected val reactContext: Th
|
|
|
189
198
|
val iconUpdate = NativeListIconUpdate(this)
|
|
190
199
|
try {
|
|
191
200
|
|
|
192
|
-
val
|
|
201
|
+
val previous = renderedItem
|
|
202
|
+
val update = update(previous, item)
|
|
193
203
|
val signature =
|
|
194
204
|
nativeListCanonical(
|
|
195
205
|
JSONObject()
|
|
@@ -201,8 +211,13 @@ internal abstract class NativeListRendererRowView(protected val reactContext: Th
|
|
|
201
211
|
.put("listStyle", listStyle)
|
|
202
212
|
)
|
|
203
213
|
sourceScale = usesSourceScale(item, useSourceScale)
|
|
204
|
-
|
|
205
|
-
|
|
214
|
+
val signatureChanged = signature != inputSignature
|
|
215
|
+
val updatedContentInPlace = update == NativeListRendererUpdate.CONTENT &&
|
|
216
|
+
!signatureChanged && previous != null && bindContentUpdate(previous, item, theme)
|
|
217
|
+
if (!updatedContentInPlace &&
|
|
218
|
+
(update != NativeListRendererUpdate.UNCHANGED || signatureChanged)
|
|
219
|
+
) {
|
|
220
|
+
if (previous != null) onBindingInvalidated?.invoke(this, bindingEpoch)
|
|
206
221
|
bindingEpoch++
|
|
207
222
|
if (update == NativeListRendererUpdate.REPLACE) {
|
|
208
223
|
recycleContent()
|
|
@@ -211,6 +226,7 @@ internal abstract class NativeListRendererRowView(protected val reactContext: Th
|
|
|
211
226
|
bindContent(item, theme, layout, checkboxState)
|
|
212
227
|
inputSignature = signature
|
|
213
228
|
}
|
|
229
|
+
renderedItem = item
|
|
214
230
|
current = item
|
|
215
231
|
tag = item
|
|
216
232
|
this.theme = theme
|
|
@@ -409,6 +425,7 @@ internal abstract class NativeListRendererRowView(protected val reactContext: Th
|
|
|
409
425
|
if (current != null) onBindingInvalidated?.invoke(this, bindingEpoch)
|
|
410
426
|
bindingEpoch++
|
|
411
427
|
current = null
|
|
428
|
+
renderedItem = null
|
|
412
429
|
tag = null
|
|
413
430
|
inputSignature = ""
|
|
414
431
|
touchPressed = false
|
|
@@ -42,6 +42,7 @@ internal data class NativeListResolvedText(
|
|
|
42
42
|
val clip: Boolean,
|
|
43
43
|
val gravity: Int,
|
|
44
44
|
val offset: Float,
|
|
45
|
+
private val style: JSONObject?,
|
|
45
46
|
) {
|
|
46
47
|
/** Offset into [text] for a UTF-16 offset into the [source] it was resolved from. */
|
|
47
48
|
fun displayOffset(sourceOffset: Long, source: String): Int =
|
|
@@ -49,11 +50,10 @@ internal data class NativeListResolvedText(
|
|
|
49
50
|
|
|
50
51
|
fun bind(view: NativeListTextView) {
|
|
51
52
|
view.includeFontPadding = false
|
|
52
|
-
view.fontFeatureSettings = "tnum"
|
|
53
53
|
view.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
|
54
54
|
view.typeface = typeface
|
|
55
55
|
view.setTextColor(color)
|
|
56
|
-
view
|
|
56
|
+
applyNativeListTextSpacing(view, style)
|
|
57
57
|
view.gravity = gravity
|
|
58
58
|
view.opticalOffsetY = offset
|
|
59
59
|
view.maxLines = if (lines == 0) Int.MAX_VALUE else lines
|
|
@@ -137,11 +137,32 @@ internal data class NativeListResolvedText(
|
|
|
137
137
|
style?.optString("truncate") == "clip",
|
|
138
138
|
horizontal or vertical,
|
|
139
139
|
((style?.optDouble("offsetY", 0.0) ?: 0.0) * density).toFloat(),
|
|
140
|
+
style,
|
|
140
141
|
)
|
|
141
142
|
}
|
|
142
143
|
}
|
|
143
144
|
}
|
|
144
145
|
|
|
146
|
+
/** Apply tracking after the final font size, then rebuild font features for this binding. */
|
|
147
|
+
internal fun applyNativeListTextSpacing(
|
|
148
|
+
view: TextView,
|
|
149
|
+
style: JSONObject?,
|
|
150
|
+
defaultFeatures: String? = "tnum",
|
|
151
|
+
defaultLetterSpacing: Float = 0f,
|
|
152
|
+
) {
|
|
153
|
+
val tracking = style?.optDouble("letterSpacing")?.takeIf { it.isFinite() }
|
|
154
|
+
val digitFeatures = when {
|
|
155
|
+
style?.has("tabularNumbers") != true -> defaultFeatures
|
|
156
|
+
style.optBoolean("tabularNumbers") -> "tnum"
|
|
157
|
+
else -> "'tnum' 0, 'pnum' 1"
|
|
158
|
+
}
|
|
159
|
+
view.fontFeatureSettings = if (tracking == null) digitFeatures else
|
|
160
|
+
listOfNotNull(digitFeatures, "'kern' 0").joinToString(", ")
|
|
161
|
+
view.letterSpacing = if (tracking != null && view.textSize > 0f)
|
|
162
|
+
(tracking * view.resources.displayMetrics.density / view.textSize).toFloat()
|
|
163
|
+
else defaultLetterSpacing
|
|
164
|
+
}
|
|
165
|
+
|
|
145
166
|
/**
|
|
146
167
|
* Legacy selector source-scale typography (accountSelector / networkSelector /
|
|
147
168
|
* walletSidebar with source scaling): whole-pixel unscaled font size, unhinted
|
|
@@ -158,7 +179,7 @@ internal fun applyNativeListSourceTypography(view: TextView, style: JSONObject?)
|
|
|
158
179
|
TypedValue.COMPLEX_UNIT_PX,
|
|
159
180
|
kotlin.math.ceil((view.textSize * metrics.density / metrics.scaledDensity).toDouble()).toFloat(),
|
|
160
181
|
)
|
|
161
|
-
view
|
|
182
|
+
applyNativeListTextSpacing(view, style)
|
|
162
183
|
if (style?.has("lineHeight") != true && view.text.isNotEmpty()) {
|
|
163
184
|
val text = SpannableStringBuilder(view.text)
|
|
164
185
|
text.getSpans(0, text.length, NativeListLineHeightSpan::class.java).forEach(text::removeSpan)
|