You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
PopupWindow: implement more stuff, mainly offset
This commit is contained in:
@@ -10,6 +10,8 @@ import android.view.View;
|
||||
|
||||
public class PopupWindow {
|
||||
|
||||
int input_method_mode = 0;
|
||||
|
||||
public PopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
popover = native_constructor();
|
||||
}
|
||||
@@ -41,23 +43,25 @@ public class PopupWindow {
|
||||
public void onDismiss();
|
||||
}
|
||||
|
||||
protected native long native_constructor();
|
||||
protected native void native_setContentView(long widget, long contentView);
|
||||
protected native void native_showAsDropDown(long widget, long anchor, int xoff, int yoff, int gravity);
|
||||
protected native boolean native_isShowing(long widget);
|
||||
protected native void native_dismiss(long widget);
|
||||
protected native void native_update(long widget, long anchor, int xoff, int yoff, int width, int height);
|
||||
public void setBackgroundDrawable(Drawable background) {
|
||||
/* FIXME: use a decorview? */
|
||||
if(contentView != null) {
|
||||
contentView.setBackgroundDrawable(background);
|
||||
}
|
||||
}
|
||||
|
||||
public void setBackgroundDrawable(Drawable background) {}
|
||||
public void setInputMethodMode(int mode) {
|
||||
input_method_mode = mode;
|
||||
}
|
||||
|
||||
public void setInputMethodMode(int mode) {}
|
||||
public int getInputMethodMode() {
|
||||
return input_method_mode;
|
||||
}
|
||||
|
||||
public boolean isShowing() {
|
||||
return native_isShowing(popover);
|
||||
}
|
||||
|
||||
public native void setOnDismissListener(OnDismissListener listener);
|
||||
|
||||
public void setFocusable(boolean focusable) {}
|
||||
|
||||
public Drawable getBackground() {return null;}
|
||||
@@ -70,17 +74,16 @@ public class PopupWindow {
|
||||
native_setContentView(popover, view == null ? 0 : view.widget);
|
||||
}
|
||||
|
||||
public int getInputMethodMode() {return 0;}
|
||||
|
||||
public int getMaxAvailableHeight(View anchor, int yOffset) {return 500;}
|
||||
|
||||
public int getMaxAvailableHeight(View anchor, int yOffset, boolean ignoreKeyboard) {return 500;}
|
||||
|
||||
public native void setWidth(int width);
|
||||
|
||||
public native void setHeight(int height);
|
||||
|
||||
public void setOutsideTouchable(boolean touchable) {}
|
||||
public void setOutsideTouchable(boolean touchable) {
|
||||
/* FIXME: the semantics are different, this seems to specifically exist for cases
|
||||
* where the popup is *not* modal, so that in addition to the window behind getting
|
||||
* the real event, the popup gets a special MotionEvent.ACTION_OUTSIDE event */
|
||||
native_setTouchModal(popover, touchable);
|
||||
}
|
||||
|
||||
public void setTouchInterceptor(View.OnTouchListener listener) {}
|
||||
|
||||
@@ -88,9 +91,13 @@ public class PopupWindow {
|
||||
native_showAsDropDown(popover, anchor.widget, xoff, yoff, gravity);
|
||||
}
|
||||
|
||||
public View getContentView() {return contentView;}
|
||||
public View getContentView() {
|
||||
return contentView;
|
||||
}
|
||||
|
||||
public void setTouchable(boolean touchable) {}
|
||||
public void setTouchable(boolean touchable) {
|
||||
native_setTouchable(popover, touchable);
|
||||
}
|
||||
|
||||
public void showAsDropDown(View anchor, int xoff, int yoff) {
|
||||
if (!anchor.isAttachedToWindow()) {
|
||||
@@ -110,7 +117,9 @@ public class PopupWindow {
|
||||
|
||||
public void setAnimationStyle(int animationStyle) {}
|
||||
|
||||
public void setTouchModal(boolean touchModal) {}
|
||||
public void setTouchModal(boolean touchModal) {
|
||||
native_setTouchModal(popover, touchModal);
|
||||
}
|
||||
|
||||
public void setElevation(float elevation) {}
|
||||
|
||||
@@ -123,4 +132,53 @@ public class PopupWindow {
|
||||
public void setIsClippedToScreen(boolean isClippedToScreen) {}
|
||||
|
||||
public void setEpicenterBounds(Rect bounds) {}
|
||||
|
||||
public void setClippingEnabled(boolean enabled) {}
|
||||
|
||||
/* TODO: handle LayoutParams.WRAP_CONTENT and LayoutParams.MATCH_PARENT */
|
||||
public void setWidth(int width) {
|
||||
if(width < 0)
|
||||
return;
|
||||
|
||||
native_setWidth(popover, width);
|
||||
}
|
||||
|
||||
public void setHeight(int height) {
|
||||
if(height < 0)
|
||||
return;
|
||||
|
||||
native_setHeight(popover, height);
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return native_getWidth(popover);
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return native_getHeight(popover);
|
||||
}
|
||||
|
||||
public void update(int x, int y, int width, int height) {}
|
||||
|
||||
public void setWindowLayoutMode(int widthSpec, int heightSpec) {}
|
||||
|
||||
|
||||
public boolean isTouchable() {
|
||||
return native_isTouchable(popover);
|
||||
}
|
||||
|
||||
protected native long native_constructor();
|
||||
protected native void native_setContentView(long widget, long contentView);
|
||||
protected native void native_showAsDropDown(long widget, long anchor, int xoff, int yoff, int gravity);
|
||||
protected native boolean native_isShowing(long widget);
|
||||
protected native void native_setTouchable(long widget, boolean touchable);
|
||||
protected native void native_setTouchModal(long widget, boolean touchable);
|
||||
protected native void native_dismiss(long widget);
|
||||
protected native void native_update(long widget, long anchor, int xoff, int yoff, int width, int height);
|
||||
public native void setOnDismissListener(OnDismissListener listener);
|
||||
public native void native_setWidth(long widget, int width);
|
||||
public native void native_setHeight(long widget, int height);
|
||||
public native int native_getWidth(long widget);
|
||||
public native int native_getHeight(long widget);
|
||||
public native boolean native_isTouchable(long widget);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user