Search in sources :

Example 66 with WindowManager

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;
}
Also used : Point(android.graphics.Point) InvocationTargetException(java.lang.reflect.InvocationTargetException) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 67 with WindowManager

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.");
}
Also used : Context(android.content.Context) LayoutParams(android.view.WindowManager.LayoutParams) Configuration(android.content.res.Configuration) ViewGroup(android.view.ViewGroup) ViewParent(android.view.ViewParent) LayoutParams(android.view.WindowManager.LayoutParams) WindowManager(android.view.WindowManager) IWindowManager(android.view.IWindowManager)

Example 68 with WindowManager

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);
    }
}
Also used : LayoutParams(android.view.WindowManager.LayoutParams) PointerLocationView(com.android.internal.widget.PointerLocationView) LayoutParams(android.view.WindowManager.LayoutParams) IWindowManager(android.view.IWindowManager) WindowManager(android.view.WindowManager)

Example 69 with WindowManager

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);
    }
}
Also used : IWindowManager(android.view.IWindowManager) WindowManager(android.view.WindowManager)

Example 70 with WindowManager

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;
}
Also used : DisplayMetrics(android.util.DisplayMetrics) WindowManager(android.view.WindowManager) Display(android.view.Display)

Aggregations

WindowManager (android.view.WindowManager)409 Display (android.view.Display)185 Point (android.graphics.Point)129 DisplayMetrics (android.util.DisplayMetrics)103 View (android.view.View)43 IWindowManager (android.view.IWindowManager)37 Context (android.content.Context)36 Resources (android.content.res.Resources)25 ImageView (android.widget.ImageView)24 Configuration (android.content.res.Configuration)20 SuppressLint (android.annotation.SuppressLint)19 Camera (android.hardware.Camera)17 Intent (android.content.Intent)16 Rect (android.graphics.Rect)16 RemoteException (android.os.RemoteException)15 LayoutParams (android.view.WindowManager.LayoutParams)15 TextView (android.widget.TextView)15 Dialog (android.app.Dialog)14 Method (java.lang.reflect.Method)12 PackageManager (android.content.pm.PackageManager)11