Search in sources :

Example 31 with WindowManager

use of android.view.WindowManager in project platform_frameworks_base by android.

the class ActivityThread method handleDestroyActivity.

private void handleDestroyActivity(IBinder token, boolean finishing, int configChanges, boolean getNonConfigInstance) {
    ActivityClientRecord r = performDestroyActivity(token, finishing, configChanges, getNonConfigInstance);
    if (r != null) {
        cleanUpPendingRemoveWindows(r, finishing);
        WindowManager wm = r.activity.getWindowManager();
        View v = r.activity.mDecor;
        if (v != null) {
            if (r.activity.mVisibleFromServer) {
                mNumVisibleActivities--;
            }
            IBinder wtoken = v.getWindowToken();
            if (r.activity.mWindowAdded) {
                if (r.mPreserveWindow) {
                    // Hold off on removing this until the new activity's
                    // window is being added.
                    r.mPendingRemoveWindow = r.window;
                    r.mPendingRemoveWindowManager = wm;
                    // We can only keep the part of the view hierarchy that we control,
                    // everything else must be removed, because it might not be able to
                    // behave properly when activity is relaunching.
                    r.window.clearContentView();
                } else {
                    wm.removeViewImmediate(v);
                }
            }
            if (wtoken != null && r.mPendingRemoveWindow == null) {
                WindowManagerGlobal.getInstance().closeAll(wtoken, r.activity.getClass().getName(), "Activity");
            } else if (r.mPendingRemoveWindow != null) {
                // We're preserving only one window, others should be closed so app views
                // will be detached before the final tear down. It should be done now because
                // some components (e.g. WebView) rely on detach callbacks to perform receiver
                // unregister and other cleanup.
                WindowManagerGlobal.getInstance().closeAllExceptView(token, v, r.activity.getClass().getName(), "Activity");
            }
            r.activity.mDecor = null;
        }
        if (r.mPendingRemoveWindow == null) {
            // If we are delaying the removal of the activity window, then
            // we can't clean up all windows here.  Note that we can't do
            // so later either, which means any windows that aren't closed
            // by the app will leak.  Well we try to warning them a lot
            // about leaking windows, because that is a bug, so if they are
            // using this recreate facility then they get to live with leaks.
            WindowManagerGlobal.getInstance().closeAll(token, r.activity.getClass().getName(), "Activity");
        }
        // Mocked out contexts won't be participating in the normal
        // process lifecycle, but if we're running with a proper
        // ApplicationContext we need to have it tear down things
        // cleanly.
        Context c = r.activity.getBaseContext();
        if (c instanceof ContextImpl) {
            ((ContextImpl) c).scheduleFinalCleanup(r.activity.getClass().getName(), "Activity");
        }
    }
    if (finishing) {
        try {
            ActivityManagerNative.getDefault().activityDestroyed(token);
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
    }
    mSomeActivitiesChanged = true;
}
Also used : Context(android.content.Context) IBinder(android.os.IBinder) RemoteException(android.os.RemoteException) View(android.view.View) WebView(android.webkit.WebView) WindowManager(android.view.WindowManager)

Example 32 with WindowManager

use of android.view.WindowManager in project platform_frameworks_base by android.

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 33 with WindowManager

use of android.view.WindowManager in project StaticLayoutView by ragnraok.

the class Util method getScreenWidth.

public static int getScreenWidth(Context context) {
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Point size = new Point();
    windowManager.getDefaultDisplay().getSize(size);
    return size.x;
}
Also used : Point(android.graphics.Point) WindowManager(android.view.WindowManager)

Example 34 with WindowManager

use of android.view.WindowManager in project robolectric by robolectric.

the class LoadWeirdClassesTest method shouldLoadDisplay.

@Test
@Config(sdk = KITKAT)
public void shouldLoadDisplay() throws Exception {
    WindowManager windowManager = (WindowManager) RuntimeEnvironment.application.getSystemService(Context.WINDOW_SERVICE);
    ReflectionHelpers.callInstanceMethod(Display.class, windowManager.getDefaultDisplay(), "getDisplayAdjustments");
}
Also used : WindowManager(android.view.WindowManager) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 35 with WindowManager

use of android.view.WindowManager in project android-app by eoecn.

the class CameraConfigurationManager method initFromCameraParameters.

/**
     * Reads, one time, values from the camera that are needed by the app.
     */
void initFromCameraParameters(Camera camera) {
    Camera.Parameters parameters = camera.getParameters();
    previewFormat = parameters.getPreviewFormat();
    previewFormatString = parameters.get("preview-format");
    Log.d(TAG, "Default preview format: " + previewFormat + '/' + previewFormatString);
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = manager.getDefaultDisplay();
    screenResolution = new Point(display.getWidth(), display.getHeight());
    Log.d(TAG, "Screen resolution: " + screenResolution);
    /** modify here **/
    Point screenResolutionForCamera = new Point();
    screenResolutionForCamera.x = screenResolution.x;
    screenResolutionForCamera.y = screenResolution.y;
    // preview size is always something like 480*320, other 320*480
    if (screenResolution.x < screenResolution.y) {
        screenResolutionForCamera.x = screenResolution.y;
        screenResolutionForCamera.y = screenResolution.x;
    }
    /** end **/
    cameraResolution = getCameraResolution(parameters, screenResolutionForCamera);
    Log.d(TAG, "Camera resolution: " + screenResolutionForCamera);
/*
         * cameraResolution = getCameraResolution(parameters, screenResolution);
         * Log.d(TAG, "Camera resolution: " + screenResolution);
         */
/** end **/
}
Also used : Camera(android.hardware.Camera) Point(android.graphics.Point) WindowManager(android.view.WindowManager) Display(android.view.Display)

Aggregations

WindowManager (android.view.WindowManager)411 Display (android.view.Display)186 Point (android.graphics.Point)129 DisplayMetrics (android.util.DisplayMetrics)104 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 SuppressLint (android.annotation.SuppressLint)20 Configuration (android.content.res.Configuration)20 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