Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Unable to allocate picker on the screen using appium #334 #335

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | |
Expand Down
10 changes: 9 additions & 1 deletion android/src/main/java/com/beefe/picker/PickerViewModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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()];
Expand Down Expand Up @@ -402,7 +408,9 @@ public void onSelected(ArrayList<ReturnData> 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;
Expand Down
2 changes: 1 addition & 1 deletion android/src/main/java/com/beefe/picker/view/LoopView.java
Original file line number Diff line number Diff line change
Expand Up @@ -495,4 +495,4 @@ public boolean onTouchEvent(MotionEvent event) {
invalidate();
return true;
}
}
}
10 changes: 10 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}


Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down