diff --git a/README.md b/README.md index 82ac41e28..d24871526 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ |Key | Type | Default| Support | Description | | --- | --- | ---- | ------ | ----------- | |isLoop | Boolean | false | Android | | +|isFocusable | Boolean | false | Android | | |pickerTextEllipsisLen | number | 6 | Android | | |pickerConfirmBtnText | string | confirm | iOS/Android | | |pickerCancelBtnText | string | cancel | iOS/Android | | diff --git a/android/src/main/java/com/beefe/picker/PickerViewModule.java b/android/src/main/java/com/beefe/picker/PickerViewModule.java index 813a0bddf..d210e7471 100644 --- a/android/src/main/java/com/beefe/picker/PickerViewModule.java +++ b/android/src/main/java/com/beefe/picker/PickerViewModule.java @@ -88,6 +88,7 @@ public class PickerViewModule extends ReactContextBaseJavaModule implements Life private static final String SELECTED_VALUE = "selectedValue"; private static final String IS_LOOP = "isLoop"; + private static final String IS_FOCUSABLE = "isFocusable"; private static final String WEIGHTS = "wheelFlex"; @@ -122,6 +123,7 @@ public class PickerViewModule extends ReactContextBaseJavaModule implements Life private Dialog dialog = null; private boolean isLoop = true; + private boolean isFocusable = false; private String confirmText; private String cancelText; @@ -258,6 +260,10 @@ public void onClick(View v) { isLoop = options.getBoolean(IS_LOOP); } + if (options.hasKey(IS_FOCUSABLE)) { + isFocusable = options.getBoolean(IS_FOCUSABLE); + } + if (options.hasKey(WEIGHTS)) { ReadableArray array = options.getArray(WEIGHTS); weights = new double[array.size()]; @@ -402,7 +408,9 @@ public void onSelected(ArrayList selectedList) { //layoutParams.type = WindowManager.LayoutParams.TYPE_TOAST; } } - layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; + if (!isFocusable){ + layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; + } layoutParams.format = PixelFormat.TRANSPARENT; layoutParams.windowAnimations = R.style.PickerAnim; layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; diff --git a/android/src/main/java/com/beefe/picker/view/LoopView.java b/android/src/main/java/com/beefe/picker/view/LoopView.java index a30ce35c7..128dbe03c 100644 --- a/android/src/main/java/com/beefe/picker/view/LoopView.java +++ b/android/src/main/java/com/beefe/picker/view/LoopView.java @@ -495,4 +495,4 @@ public boolean onTouchEvent(MotionEvent event) { invalidate(); return true; } -} \ No newline at end of file +} diff --git a/index.d.ts b/index.d.ts index 7c7093856..e396c8ab9 100644 --- a/index.d.ts +++ b/index.d.ts @@ -204,6 +204,16 @@ interface PickerOptions { * @memberof PickerOptions */ onPickerSelect?(item: any[]): void + + /** + * Sets whether picker is focusable for automation or not + * + * Default is false + * + * @type {boolean} + * @memberof PickerOptions + */ + isFocusable?: boolean } diff --git a/index.js b/index.js index bb5d1360e..a8f560fdf 100644 --- a/index.js +++ b/index.js @@ -9,6 +9,7 @@ const android = Platform.OS === 'android'; const Picker = NativeModules.BEEPickerManager; const options = { isLoop: false, + isFocusable: false, pickerConfirmBtnText: 'confirm', pickerCancelBtnText: 'cancel', pickerTitleText: 'pls select',