Search in sources :

Example 11 with ViewManager

use of android.view.ViewManager in project android_frameworks_base by AOSPA.

the class ActivityThread method handleResumeActivity.

final void handleResumeActivity(IBinder token, boolean clearHide, boolean isForward, boolean reallyResume, int seq, String reason) {
    ActivityClientRecord r = mActivities.get(token);
    if (!checkAndUpdateLifecycleSeq(seq, r, "resumeActivity")) {
        return;
    }
    // If we are getting ready to gc after going to the background, well
    // we are back active so skip it.
    unscheduleGcIdler();
    mSomeActivitiesChanged = true;
    // TODO Push resumeArgs into the activity for consideration
    r = performResumeActivity(token, clearHide, reason);
    if (r != null) {
        final Activity a = r.activity;
        if (localLOGV)
            Slog.v(TAG, "Resume " + r + " started activity: " + a.mStartedActivity + ", hideForNow: " + r.hideForNow + ", finished: " + a.mFinished);
        final int forwardBit = isForward ? WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION : 0;
        // If the window hasn't yet been added to the window manager,
        // and this guy didn't finish itself or start another activity,
        // then go ahead and add the window.
        boolean willBeVisible = !a.mStartedActivity;
        if (!willBeVisible) {
            try {
                willBeVisible = ActivityManagerNative.getDefault().willActivityBeVisible(a.getActivityToken());
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
        if (r.window == null && !a.mFinished && willBeVisible) {
            r.window = r.activity.getWindow();
            View decor = r.window.getDecorView();
            decor.setVisibility(View.INVISIBLE);
            ViewManager wm = a.getWindowManager();
            WindowManager.LayoutParams l = r.window.getAttributes();
            a.mDecor = decor;
            l.type = WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
            l.softInputMode |= forwardBit;
            if (r.mPreserveWindow) {
                // workflow.
                if (DecorView.isAddedToWindow(decor))
                    a.mWindowAdded = true;
                r.mPreserveWindow = false;
                // Normally the ViewRoot sets up callbacks with the Activity
                // in addView->ViewRootImpl#setView. If we are instead reusing
                // the decor view we have to notify the view root that the
                // callbacks may have changed.
                ViewRootImpl impl = decor.getViewRootImpl();
                if (impl != null) {
                    impl.notifyChildRebuilt();
                }
            }
            if (a.mVisibleFromClient && !a.mWindowAdded) {
                a.mWindowAdded = true;
                wm.addView(decor, l);
                DecorView.setAddedToWindow(a.mDecor);
            }
        // If the window has already been added, but during resume
        // we started another activity, then don't yet make the
        // window visible.
        } else if (!willBeVisible) {
            if (localLOGV)
                Slog.v(TAG, "Launch " + r + " mStartedActivity set");
            r.hideForNow = true;
        }
        // Get rid of anything left hanging around.
        cleanUpPendingRemoveWindows(r, false);
        // simply finishing, and we are not starting another activity.
        if (!r.activity.mFinished && willBeVisible && r.activity.mDecor != null && !r.hideForNow) {
            if (r.newConfig != null) {
                performConfigurationChangedForActivity(r, r.newConfig, REPORT_TO_ACTIVITY);
                if (DEBUG_CONFIGURATION)
                    Slog.v(TAG, "Resuming activity " + r.activityInfo.name + " with newConfig " + r.activity.mCurrentConfig);
                r.newConfig = null;
            }
            if (localLOGV)
                Slog.v(TAG, "Resuming " + r + " with isForward=" + isForward);
            WindowManager.LayoutParams l = r.window.getAttributes();
            if ((l.softInputMode & WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION) != forwardBit) {
                l.softInputMode = (l.softInputMode & (~WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION)) | forwardBit;
                if (r.activity.mVisibleFromClient) {
                    ViewManager wm = a.getWindowManager();
                    View decor = r.window.getDecorView();
                    wm.updateViewLayout(decor, l);
                }
            }
            r.activity.mVisibleFromServer = true;
            mNumVisibleActivities++;
            if (r.activity.mVisibleFromClient) {
                r.activity.makeVisible();
            }
        }
        if (!r.onlyLocalRequest) {
            r.nextIdle = mNewActivities;
            mNewActivities = r;
            if (localLOGV)
                Slog.v(TAG, "Scheduling idle handler for " + r);
            Looper.myQueue().addIdleHandler(new Idler());
        }
        r.onlyLocalRequest = false;
        // Tell the activity manager we have resumed.
        if (reallyResume) {
            try {
                ActivityManagerNative.getDefault().activityResumed(token);
            } catch (RemoteException ex) {
                throw ex.rethrowFromSystemServer();
            }
        }
    } else {
        // just end this activity.
        try {
            ActivityManagerNative.getDefault().finishActivity(token, Activity.RESULT_CANCELED, null, Activity.DONT_FINISH_TASK_WITH_ACTIVITY);
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
    }
}
Also used : ViewRootImpl(android.view.ViewRootImpl) ViewManager(android.view.ViewManager) RemoteException(android.os.RemoteException) DecorView(com.android.internal.policy.DecorView) View(android.view.View) WebView(android.webkit.WebView) WindowManager(android.view.WindowManager)

Example 12 with ViewManager

use of android.view.ViewManager in project android_frameworks_base by crdroidandroid.

the class ActivityThread method handleResumeActivity.

final void handleResumeActivity(IBinder token, boolean clearHide, boolean isForward, boolean reallyResume, int seq, String reason) {
    ActivityClientRecord r = mActivities.get(token);
    if (!checkAndUpdateLifecycleSeq(seq, r, "resumeActivity")) {
        return;
    }
    // If we are getting ready to gc after going to the background, well
    // we are back active so skip it.
    unscheduleGcIdler();
    mSomeActivitiesChanged = true;
    // TODO Push resumeArgs into the activity for consideration
    r = performResumeActivity(token, clearHide, reason);
    if (r != null) {
        final Activity a = r.activity;
        if (localLOGV)
            Slog.v(TAG, "Resume " + r + " started activity: " + a.mStartedActivity + ", hideForNow: " + r.hideForNow + ", finished: " + a.mFinished);
        final int forwardBit = isForward ? WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION : 0;
        // If the window hasn't yet been added to the window manager,
        // and this guy didn't finish itself or start another activity,
        // then go ahead and add the window.
        boolean willBeVisible = !a.mStartedActivity;
        if (!willBeVisible) {
            try {
                willBeVisible = ActivityManagerNative.getDefault().willActivityBeVisible(a.getActivityToken());
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
        if (r.window == null && !a.mFinished && willBeVisible) {
            r.window = r.activity.getWindow();
            View decor = r.window.getDecorView();
            decor.setVisibility(View.INVISIBLE);
            ViewManager wm = a.getWindowManager();
            WindowManager.LayoutParams l = r.window.getAttributes();
            a.mDecor = decor;
            l.type = WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
            l.softInputMode |= forwardBit;
            if (r.mPreserveWindow) {
                // workflow.
                if (DecorView.isAddedToWindow(decor))
                    a.mWindowAdded = true;
                r.mPreserveWindow = false;
                // Normally the ViewRoot sets up callbacks with the Activity
                // in addView->ViewRootImpl#setView. If we are instead reusing
                // the decor view we have to notify the view root that the
                // callbacks may have changed.
                ViewRootImpl impl = decor.getViewRootImpl();
                if (impl != null) {
                    impl.notifyChildRebuilt();
                }
            }
            if (a.mVisibleFromClient && !a.mWindowAdded) {
                a.mWindowAdded = true;
                wm.addView(decor, l);
                DecorView.setAddedToWindow(a.mDecor);
            }
        // If the window has already been added, but during resume
        // we started another activity, then don't yet make the
        // window visible.
        } else if (!willBeVisible) {
            if (localLOGV)
                Slog.v(TAG, "Launch " + r + " mStartedActivity set");
            r.hideForNow = true;
        }
        // Get rid of anything left hanging around.
        cleanUpPendingRemoveWindows(r, false);
        // simply finishing, and we are not starting another activity.
        if (!r.activity.mFinished && willBeVisible && r.activity.mDecor != null && !r.hideForNow) {
            if (r.newConfig != null) {
                performConfigurationChangedForActivity(r, r.newConfig, REPORT_TO_ACTIVITY);
                if (DEBUG_CONFIGURATION)
                    Slog.v(TAG, "Resuming activity " + r.activityInfo.name + " with newConfig " + r.activity.mCurrentConfig);
                r.newConfig = null;
            }
            if (localLOGV)
                Slog.v(TAG, "Resuming " + r + " with isForward=" + isForward);
            WindowManager.LayoutParams l = r.window.getAttributes();
            if ((l.softInputMode & WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION) != forwardBit) {
                l.softInputMode = (l.softInputMode & (~WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION)) | forwardBit;
                if (r.activity.mVisibleFromClient) {
                    ViewManager wm = a.getWindowManager();
                    View decor = r.window.getDecorView();
                    wm.updateViewLayout(decor, l);
                }
            }
            r.activity.mVisibleFromServer = true;
            mNumVisibleActivities++;
            if (r.activity.mVisibleFromClient) {
                r.activity.makeVisible();
            }
        }
        if (!r.onlyLocalRequest) {
            r.nextIdle = mNewActivities;
            mNewActivities = r;
            if (localLOGV)
                Slog.v(TAG, "Scheduling idle handler for " + r);
            Looper.myQueue().addIdleHandler(new Idler());
        }
        r.onlyLocalRequest = false;
        // Tell the activity manager we have resumed.
        if (reallyResume) {
            try {
                ActivityManagerNative.getDefault().activityResumed(token);
            } catch (RemoteException ex) {
                throw ex.rethrowFromSystemServer();
            }
        }
    } else {
        // just end this activity.
        try {
            ActivityManagerNative.getDefault().finishActivity(token, Activity.RESULT_CANCELED, null, Activity.DONT_FINISH_TASK_WITH_ACTIVITY);
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
    }
}
Also used : ViewRootImpl(android.view.ViewRootImpl) ViewManager(android.view.ViewManager) RemoteException(android.os.RemoteException) DecorView(com.android.internal.policy.DecorView) View(android.view.View) WebView(android.webkit.WebView) WindowManager(android.view.WindowManager)

Example 13 with ViewManager

use of android.view.ViewManager in project android_frameworks_base by crdroidandroid.

the class PhoneWindow method onOptionsPanelRotationChanged.

void onOptionsPanelRotationChanged() {
    final PanelFeatureState st = getPanelState(FEATURE_OPTIONS_PANEL, false);
    if (st == null)
        return;
    final WindowManager.LayoutParams lp = st.decorView != null ? (WindowManager.LayoutParams) st.decorView.getLayoutParams() : null;
    if (lp != null) {
        lp.gravity = getOptionsPanelGravity();
        final ViewManager wm = getWindowManager();
        if (wm != null) {
            wm.updateViewLayout(st.decorView, lp);
        }
    }
}
Also used : ViewManager(android.view.ViewManager) LayoutParams(android.view.WindowManager.LayoutParams) WindowManager(android.view.WindowManager) IWindowManager(android.view.IWindowManager)

Example 14 with ViewManager

use of android.view.ViewManager in project android_frameworks_base by crdroidandroid.

the class PhoneWindow method closePanel.

/**
     * Closes the given panel.
     *
     * @param st The panel to be closed.
     * @param doCallback Whether to notify the callback that the panel was
     *            closed. If the panel is in the process of re-opening or
     *            opening another panel (e.g., menu opening a sub menu), the
     *            callback should not happen and this variable should be false.
     *            In addition, this method internally will only perform the
     *            callback if the panel is open.
     */
public final void closePanel(PanelFeatureState st, boolean doCallback) {
    // System.out.println("Close panel: isOpen=" + st.isOpen);
    if (doCallback && st.featureId == FEATURE_OPTIONS_PANEL && mDecorContentParent != null && mDecorContentParent.isOverflowMenuShowing()) {
        checkCloseActionMenu(st.menu);
        return;
    }
    final ViewManager wm = getWindowManager();
    if ((wm != null) && st.isOpen) {
        if (st.decorView != null) {
            wm.removeView(st.decorView);
            // Log.v(TAG, "Removing main menu from window manager.");
            if (st.isCompact) {
                sRotationWatcher.removeWindow(this);
            }
        }
        if (doCallback) {
            callOnPanelClosed(st.featureId, st, null);
        }
    }
    st.isPrepared = false;
    st.isHandled = false;
    st.isOpen = false;
    // This view is no longer shown, so null it out
    st.shownPanelView = null;
    if (st.isInExpandedMode) {
        // Next time the menu opens, it should not be in expanded mode, so
        // force a refresh of the decor
        st.refreshDecorView = true;
        st.isInExpandedMode = false;
    }
    if (mPreparedPanel == st) {
        mPreparedPanel = null;
        mPanelChordingKey = 0;
    }
}
Also used : ViewManager(android.view.ViewManager)

Example 15 with ViewManager

use of android.view.ViewManager in project android_frameworks_base by AOSPA.

the class PhoneWindow method closePanel.

/**
     * Closes the given panel.
     *
     * @param st The panel to be closed.
     * @param doCallback Whether to notify the callback that the panel was
     *            closed. If the panel is in the process of re-opening or
     *            opening another panel (e.g., menu opening a sub menu), the
     *            callback should not happen and this variable should be false.
     *            In addition, this method internally will only perform the
     *            callback if the panel is open.
     */
public final void closePanel(PanelFeatureState st, boolean doCallback) {
    // System.out.println("Close panel: isOpen=" + st.isOpen);
    if (doCallback && st.featureId == FEATURE_OPTIONS_PANEL && mDecorContentParent != null && mDecorContentParent.isOverflowMenuShowing()) {
        checkCloseActionMenu(st.menu);
        return;
    }
    final ViewManager wm = getWindowManager();
    if ((wm != null) && st.isOpen) {
        if (st.decorView != null) {
            wm.removeView(st.decorView);
            // Log.v(TAG, "Removing main menu from window manager.");
            if (st.isCompact) {
                sRotationWatcher.removeWindow(this);
            }
        }
        if (doCallback) {
            callOnPanelClosed(st.featureId, st, null);
        }
    }
    st.isPrepared = false;
    st.isHandled = false;
    st.isOpen = false;
    // This view is no longer shown, so null it out
    st.shownPanelView = null;
    if (st.isInExpandedMode) {
        // Next time the menu opens, it should not be in expanded mode, so
        // force a refresh of the decor
        st.refreshDecorView = true;
        st.isInExpandedMode = false;
    }
    if (mPreparedPanel == st) {
        mPreparedPanel = null;
        mPanelChordingKey = 0;
    }
}
Also used : ViewManager(android.view.ViewManager)

Aggregations

ViewManager (android.view.ViewManager)32 WindowManager (android.view.WindowManager)13 RemoteException (android.os.RemoteException)7 View (android.view.View)7 IWindowManager (android.view.IWindowManager)6 LayoutParams (android.view.WindowManager.LayoutParams)6 ViewRootImpl (android.view.ViewRootImpl)5 WebView (android.webkit.WebView)5 DecorView (com.android.internal.policy.DecorView)4