@craft-native/android 0.0.146 → 0.0.147

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@craft-native/android",
3
- "version": "0.0.146",
3
+ "version": "0.0.147",
4
4
  "homepage": "https://github.com/craft-native/craft/tree/main/packages/android#readme",
5
5
  "repository": {
6
6
  "type": "git",
@@ -2094,6 +2094,21 @@ class MainActivity : AppCompatActivity() {
2094
2094
  maxLines = if (multiline) props.optInt("numberOfLines", Int.MAX_VALUE).coerceAtLeast(1) else 1
2095
2095
  isEnabled = props.optBoolean("editable", true)
2096
2096
  configureTextStyle(this, style)
2097
+ // The style's padding is where the text starts, as on iOS and
2098
+ // the web; without one the field keeps its own.
2099
+ if (listOf("padding", "paddingHorizontal", "paddingVertical", "paddingLeft", "paddingRight", "paddingTop", "paddingBottom").any { style.has(it) }) {
2100
+ val density = resources.displayMetrics.density
2101
+ val all = style.optDouble("padding", 0.0)
2102
+ val horizontal = style.optDouble("paddingHorizontal", all)
2103
+ val vertical = style.optDouble("paddingVertical", all)
2104
+ setPadding(
2105
+ (style.optDouble("paddingLeft", horizontal) * density).toInt(),
2106
+ (style.optDouble("paddingTop", vertical) * density).toInt(),
2107
+ (style.optDouble("paddingRight", horizontal) * density).toInt(),
2108
+ (style.optDouble("paddingBottom", vertical) * density).toInt(),
2109
+ )
2110
+ }
2111
+ autofillHintFor(props)?.let { setAutofillHints(it) }
2097
2112
  val controlledValue = props.opt("value")?.takeUnless { it == JSONObject.NULL }?.toString()
2098
2113
  if (controlledValue != null && text.toString() != controlledValue) {
2099
2114
  screen.suppressedTextChanges.add(this)
@@ -2991,6 +3006,24 @@ class MainActivity : AppCompatActivity() {
2991
3006
  return (if (keyboard == 0) base else keyboard) or capitalization or correction or secure
2992
3007
  }
2993
3008
 
3009
+ /// The autofill hint for `textContentType` (iOS's names) or `autoComplete`
3010
+ /// (HTML's), so a password manager fills the field.
3011
+ private fun autofillHintFor(props: JSONObject): String? {
3012
+ val raw = props.optString("textContentType").ifBlank { props.optString("autoComplete") }
3013
+ return when (raw.replace("-", "").replace("_", "").lowercase()) {
3014
+ "username" -> View.AUTOFILL_HINT_USERNAME
3015
+ "password", "currentpassword" -> View.AUTOFILL_HINT_PASSWORD
3016
+ "newpassword" -> "newPassword"
3017
+ "onetimecode" -> "smsOTPCode"
3018
+ "emailaddress", "email" -> View.AUTOFILL_HINT_EMAIL_ADDRESS
3019
+ "telephonenumber", "tel", "phone" -> View.AUTOFILL_HINT_PHONE
3020
+ "name" -> View.AUTOFILL_HINT_NAME
3021
+ "postalcode" -> View.AUTOFILL_HINT_POSTAL_CODE
3022
+ "fullstreetaddress", "streetaddress" -> View.AUTOFILL_HINT_POSTAL_ADDRESS
3023
+ else -> null
3024
+ }
3025
+ }
3026
+
2994
3027
  private fun imeOptionsFor(props: JSONObject): Int = when (props.optString("returnKeyType")) {
2995
3028
  "done" -> EditorInfo.IME_ACTION_DONE
2996
3029
  "go" -> EditorInfo.IME_ACTION_GO