Skip to content

Commit

Permalink
Adding support for importantForAccessibility attribute (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
podarsmarty authored Jul 21, 2020
1 parent e674604 commit de40237
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions paris/src/main/java/com/airbnb/paris/proxies/ViewProxy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ class ViewProxy(view: View) : BaseProxy<ViewProxy, View>(view) {
ignoreLayoutWidthAndHeight = ignore
}

@Attr(R2.styleable.Paris_View_android_importantForAccessibility)
fun setImportantForAccessibility(mode: Int) {
view.importantForAccessibility = mode
}

companion object {

const val PORTERDUFF_MODE_SRC_OVER = 3
Expand Down
1 change: 1 addition & 0 deletions paris/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<attr name="android:paddingVertical" />
<attr name="android:stateListAnimator" />
<attr name="android:visibility" />
<attr name="android:importantForAccessibility" />

<attr name="ignoreLayoutWidthAndHeight" format="boolean" />
</declare-styleable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,11 @@ class ViewProxyTest {
proxy.setLayoutWeight(weight)
assertEquals(weight, (view.layoutParams as LinearLayout.LayoutParams).weight)
}

@Test
fun setImportantForAccessibility() {
val mode = View.IMPORTANT_FOR_ACCESSIBILITY_NO
proxy.setImportantForAccessibility(mode)
assertEquals(mode, view.importantForAccessibility)
}
}

0 comments on commit de40237

Please sign in to comment.