Search in sources :

Example 91 with WindowManager

use of android.view.WindowManager in project android_frameworks_base by ResurrectionRemix.

the class TaskManager method showTips.

/**
     * show tips before quick settings panel.
     */
private void showTips(int resid) {
    if (mTipsShowing) {
        Log.w(TAG, "The floating window is showing, stop showing another one.");
        return;
    }
    //Android toast is not able to be shown on top of notifications, so
    //implement a floating window to replace it.
    LayoutInflater inflate = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View floatView = inflate.inflate(com.android.internal.R.layout.transient_notification, null);
    final TextView textView = (TextView) floatView.findViewById(com.android.internal.R.id.message);
    textView.setText(mContext.getString(resid));
    final WindowManager windowManager = (WindowManager) mContext.getSystemService(mContext.WINDOW_SERVICE);
    WindowManager.LayoutParams params = new WindowManager.LayoutParams();
    params.type = WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL;
    params.format = PixelFormat.TRANSLUCENT;
    params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
    params.height = WindowManager.LayoutParams.WRAP_CONTENT;
    params.width = WindowManager.LayoutParams.WRAP_CONTENT;
    params.y = windowManager.getDefaultDisplay().getHeight() / 3;
    params.windowAnimations = com.android.internal.R.style.Animation_Toast;
    windowManager.addView(floatView, params);
    mTipsShowing = true;
    //close tips in two seconds
    new Timer().schedule(new TimerTask() {

        @Override
        public void run() {
            windowManager.removeView(floatView);
            mTipsShowing = false;
        }
    }, FLOAT_VIEW_DISPLAY_TIME);
}
Also used : LayoutParams(android.app.ActionBar.LayoutParams) Timer(java.util.Timer) TimerTask(java.util.TimerTask) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) WindowManager(android.view.WindowManager)

Example 92 with WindowManager

use of android.view.WindowManager in project android_frameworks_base by ResurrectionRemix.

the class DeviceUtils method getScreenType.

private static int getScreenType(Context con) {
    WindowManager wm = (WindowManager) con.getSystemService(Context.WINDOW_SERVICE);
    DisplayInfo outDisplayInfo = new DisplayInfo();
    wm.getDefaultDisplay().getDisplayInfo(outDisplayInfo);
    int shortSize = Math.min(outDisplayInfo.logicalHeight, outDisplayInfo.logicalWidth);
    int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / outDisplayInfo.logicalDensityDpi;
    if (shortSizeDp < 600) {
        return DEVICE_PHONE;
    } else if (shortSizeDp < 720) {
        return DEVICE_HYBRID;
    } else {
        return DEVICE_TABLET;
    }
}
Also used : DisplayInfo(android.view.DisplayInfo) WindowManager(android.view.WindowManager)

Example 93 with WindowManager

use of android.view.WindowManager in project android_frameworks_base by ResurrectionRemix.

the class PhoneWindow method openPanel.

private void openPanel(final 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().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.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);
    st.isOpen = true;
// Log.v(TAG, "Adding main menu to window manager.");
}
Also used : Context(android.content.Context) LayoutParams(android.view.WindowManager.LayoutParams) ViewConfiguration(android.view.ViewConfiguration) 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 94 with WindowManager

use of android.view.WindowManager in project android_frameworks_base by ResurrectionRemix.

the class MenuPopupHelper method createPopup.

/**
     * Creates the popup and assigns cached properties.
     *
     * @return an initialized popup
     */
@NonNull
private MenuPopup createPopup() {
    final WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    final Display display = windowManager.getDefaultDisplay();
    final Point displaySize = new Point();
    display.getRealSize(displaySize);
    final int smallestWidth = Math.min(displaySize.x, displaySize.y);
    final int minSmallestWidthCascading = mContext.getResources().getDimensionPixelSize(com.android.internal.R.dimen.cascading_menus_min_smallest_width);
    final boolean enableCascadingSubmenus = smallestWidth >= minSmallestWidthCascading;
    final MenuPopup popup;
    if (enableCascadingSubmenus) {
        popup = new CascadingMenuPopup(mContext, mAnchorView, mPopupStyleAttr, mPopupStyleRes, mOverflowOnly);
    } else {
        popup = new StandardMenuPopup(mContext, mMenu, mAnchorView, mPopupStyleAttr, mPopupStyleRes, mOverflowOnly);
    }
    // Assign immutable properties.
    popup.addMenu(mMenu);
    popup.setOnDismissListener(mInternalOnDismissListener);
    // Assign mutable properties. These may be reassigned later.
    popup.setAnchorView(mAnchorView);
    popup.setCallback(mPresenterCallback);
    popup.setForceShowIcon(mForceShowIcon);
    popup.setGravity(mDropDownGravity);
    return popup;
}
Also used : Point(android.graphics.Point) Point(android.graphics.Point) WindowManager(android.view.WindowManager) Display(android.view.Display) NonNull(android.annotation.NonNull)

Example 95 with WindowManager

use of android.view.WindowManager in project LshUtils by SenhLinsh.

the class LshScreenUtils method getScreenHeight.

public static int getScreenHeight() {
    WindowManager wm = (WindowManager) LshApplicationUtils.getContext().getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics outMetrics = new DisplayMetrics();
    wm.getDefaultDisplay().getMetrics(outMetrics);
    return outMetrics.heightPixels;
}
Also used : DisplayMetrics(android.util.DisplayMetrics) WindowManager(android.view.WindowManager)

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