From 5eadecf65a8791db8b06912a4383b13e4316e8eb Mon Sep 17 00:00:00 2001 From: zeburek Date: Wed, 8 Aug 2018 19:38:44 +0300 Subject: [PATCH 1/3] Removed FLAG_NOT_FOCUSABLE --- android/src/main/java/com/beefe/picker/PickerViewModule.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/beefe/picker/PickerViewModule.java b/android/src/main/java/com/beefe/picker/PickerViewModule.java index 813a0bddf..c846221f3 100644 --- a/android/src/main/java/com/beefe/picker/PickerViewModule.java +++ b/android/src/main/java/com/beefe/picker/PickerViewModule.java @@ -394,7 +394,7 @@ public void onSelected(ArrayList selectedList) { Window window = dialog.getWindow(); if (window != null) { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - window.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); + window.setType(WindowManager.LayoutParams.TYPE_APPLICATION); }else{ if (MIUIUtils.isMIUI()) { layoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION; @@ -402,7 +402,7 @@ public void onSelected(ArrayList selectedList) { //layoutParams.type = WindowManager.LayoutParams.TYPE_TOAST; } } - layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; +// layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; layoutParams.format = PixelFormat.TRANSPARENT; layoutParams.windowAnimations = R.style.PickerAnim; layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; From e09952068a0f3bca24c2cff97a904fdeafefb1d7 Mon Sep 17 00:00:00 2001 From: zeburek Date: Wed, 8 Aug 2018 20:15:42 +0300 Subject: [PATCH 2/3] Replaced LAYER_TYPE_SOFTWARE with LAYER_TYPE_NONE --- android/src/main/java/com/beefe/picker/view/LoopView.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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..ade13709e 100644 --- a/android/src/main/java/com/beefe/picker/view/LoopView.java +++ b/android/src/main/java/com/beefe/picker/view/LoopView.java @@ -137,7 +137,7 @@ private void initPaints() { paintIndicator.setAntiAlias(true); if (android.os.Build.VERSION.SDK_INT >= 11) { - setLayerType(LAYER_TYPE_SOFTWARE, null); + setLayerType(LAYER_TYPE_NONE, null); } } @@ -495,4 +495,4 @@ public boolean onTouchEvent(MotionEvent event) { invalidate(); return true; } -} \ No newline at end of file +} From a6b768dafd060c75a1035f115f0cf71330b89e1d Mon Sep 17 00:00:00 2001 From: Parviz Khavari Date: Thu, 9 Aug 2018 19:44:31 +0300 Subject: [PATCH 3/3] Added isFocusable parameter to set whether picker is focusable or not --- README.md | 1 + .../main/java/com/beefe/picker/PickerViewModule.java | 12 ++++++++++-- .../main/java/com/beefe/picker/view/LoopView.java | 2 +- index.d.ts | 10 ++++++++++ index.js | 1 + 5 files changed, 23 insertions(+), 3 deletions(-) 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 c846221f3..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()]; @@ -394,7 +400,7 @@ public void onSelected(ArrayList selectedList) { Window window = dialog.getWindow(); if (window != null) { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - window.setType(WindowManager.LayoutParams.TYPE_APPLICATION); + window.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); }else{ if (MIUIUtils.isMIUI()) { layoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION; @@ -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 ade13709e..128dbe03c 100644 --- a/android/src/main/java/com/beefe/picker/view/LoopView.java +++ b/android/src/main/java/com/beefe/picker/view/LoopView.java @@ -137,7 +137,7 @@ private void initPaints() { paintIndicator.setAntiAlias(true); if (android.os.Build.VERSION.SDK_INT >= 11) { - setLayerType(LAYER_TYPE_NONE, null); + setLayerType(LAYER_TYPE_SOFTWARE, null); } } 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',