use of android.view.WindowManager in project LuaViewSDK by alibaba.
the class AndroidUtil method getRealScreenSize.
public static Point getRealScreenSize(Context context) {
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = windowManager.getDefaultDisplay();
Point size = new Point();
if (Build.VERSION.SDK_INT >= 17) {
display.getRealSize(size);
} else if (Build.VERSION.SDK_INT >= 14) {
try {
size.x = (Integer) Display.class.getMethod("getRawWidth").invoke(display);
size.y = (Integer) Display.class.getMethod("getRawHeight").invoke(display);
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
} catch (NoSuchMethodException e) {
}
}
return size;
}
use of android.view.WindowManager in project android_frameworks_base by ParanoidAndroid.
the class PhoneWindow method openPanel.
private void openPanel(PanelFeatureState st, KeyEvent event) {
// Already open, return
if (st.isOpen || isDestroyed()) {
return;
}
// (The app should be using an action bar for menu items.)
if (st.featureId == FEATURE_OPTIONS_PANEL) {
Context context = getContext();
Configuration config = context.getResources().getConfiguration();
boolean isXLarge = (config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE;
boolean isHoneycombApp = context.getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES.HONEYCOMB;
if (isXLarge && isHoneycombApp) {
return;
}
}
Callback cb = getCallback();
if ((cb != null) && (!cb.onMenuOpened(st.featureId, st.menu))) {
// Callback doesn't want the menu to open, reset any state
closePanel(st, true);
return;
}
final WindowManager wm = getWindowManager();
if (wm == null) {
return;
}
// Prepare panel (should have been done before, but just in case)
if (!preparePanel(st, event)) {
return;
}
int width = WRAP_CONTENT;
if (st.decorView == null || st.refreshDecorView) {
if (st.decorView == null) {
// Initialize the panel decor, this will populate st.decorView
if (!initializePanelDecor(st) || (st.decorView == null))
return;
} else if (st.refreshDecorView && (st.decorView.getChildCount() > 0)) {
// Decor needs refreshing, so remove its views
st.decorView.removeAllViews();
}
// This will populate st.shownPanelView
if (!initializePanelContent(st) || !st.hasPanelItems()) {
return;
}
ViewGroup.LayoutParams lp = st.shownPanelView.getLayoutParams();
if (lp == null) {
lp = new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
}
int backgroundResId;
if (lp.width == ViewGroup.LayoutParams.MATCH_PARENT) {
// If the contents is fill parent for the width, set the
// corresponding background
backgroundResId = st.fullBackground;
width = MATCH_PARENT;
} else {
// Otherwise, set the normal panel background
backgroundResId = st.background;
}
st.decorView.setWindowBackground(getContext().getResources().getDrawable(backgroundResId));
ViewParent shownPanelParent = st.shownPanelView.getParent();
if (shownPanelParent != null && shownPanelParent instanceof ViewGroup) {
((ViewGroup) shownPanelParent).removeView(st.shownPanelView);
}
st.decorView.addView(st.shownPanelView, lp);
/*
* Give focus to the view, if it or one of its children does not
* already have it.
*/
if (!st.shownPanelView.hasFocus()) {
st.shownPanelView.requestFocus();
}
} else if (!st.isInListMode()) {
width = MATCH_PARENT;
} else if (st.createdPanelView != null) {
// If we already had a panel view, carry width=MATCH_PARENT through
// as we did above when it was created.
ViewGroup.LayoutParams lp = st.createdPanelView.getLayoutParams();
if (lp != null && lp.width == ViewGroup.LayoutParams.MATCH_PARENT) {
width = MATCH_PARENT;
}
}
st.isOpen = true;
st.isHandled = false;
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(width, WRAP_CONTENT, st.x, st.y, WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG, WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, st.decorView.mDefaultOpacity);
if (st.isCompact) {
lp.gravity = getOptionsPanelGravity();
sRotationWatcher.addWindow(this);
} else {
lp.gravity = st.gravity;
}
lp.windowAnimations = st.windowAnimations;
wm.addView(st.decorView, lp);
// Log.v(TAG, "Adding main menu to window manager.");
}
use of android.view.WindowManager in project android_frameworks_base by ParanoidAndroid.
the class PhoneWindowManager method enablePointerLocation.
private void enablePointerLocation() {
if (mPointerLocationView == null) {
mPointerLocationView = new PointerLocationView(mContext);
mPointerLocationView.setPrintCoords(false);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
lp.type = WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY;
lp.flags = WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
if (ActivityManager.isHighEndGfx()) {
lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED;
}
lp.format = PixelFormat.TRANSLUCENT;
lp.setTitle("PointerLocation");
WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
lp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL;
wm.addView(mPointerLocationView, lp);
mPointerLocationInputChannel = mWindowManagerFuncs.monitorInput("PointerLocationView");
mPointerLocationInputEventReceiver = new PointerLocationInputEventReceiver(mPointerLocationInputChannel, Looper.myLooper(), mPointerLocationView);
}
}
use of android.view.WindowManager in project android_frameworks_base by ParanoidAndroid.
the class PhoneWindowManager method removeStartingWindow.
/** {@inheritDoc} */
public void removeStartingWindow(IBinder appToken, View window) {
if (DEBUG_STARTING_WINDOW) {
RuntimeException e = new RuntimeException("here");
e.fillInStackTrace();
Log.v(TAG, "Removing starting window for " + appToken + ": " + window, e);
}
if (window != null) {
WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
wm.removeView(window);
}
}
use of android.view.WindowManager in project android_frameworks_base by ParanoidAndroid.
the class KeyguardTargets method isScreenLarge.
public boolean isScreenLarge() {
DisplayMetrics dm = new DisplayMetrics();
WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
display.getMetrics(dm);
int shortSize = Math.min(dm.heightPixels, dm.widthPixels);
int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / DisplayMetrics.DENSITY_DEVICE;
if (shortSizeDp >= 600) {
return true;
}
return false;
}
Aggregations