Search in sources :

Example 1 with ActionBarContextView

use of com.android.internal.widget.ActionBarContextView in project android_frameworks_base by ParanoidAndroid.

the class PhoneWindow method installDecor.

private void installDecor() {
    if (mDecor == null) {
        mDecor = generateDecor();
        mDecor.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
        mDecor.setIsRootNamespace(true);
        if (!mInvalidatePanelMenuPosted && mInvalidatePanelMenuFeatures != 0) {
            mDecor.postOnAnimation(mInvalidatePanelMenuRunnable);
        }
    }
    if (mContentParent == null) {
        mContentParent = generateLayout(mDecor);
        // Set up decor part of UI to ignore fitsSystemWindows if appropriate.
        mDecor.makeOptionalFitsSystemWindows();
        mTitleView = (TextView) findViewById(com.android.internal.R.id.title);
        if (mTitleView != null) {
            mTitleView.setLayoutDirection(mDecor.getLayoutDirection());
            if ((getLocalFeatures() & (1 << FEATURE_NO_TITLE)) != 0) {
                View titleContainer = findViewById(com.android.internal.R.id.title_container);
                if (titleContainer != null) {
                    titleContainer.setVisibility(View.GONE);
                } else {
                    mTitleView.setVisibility(View.GONE);
                }
                if (mContentParent instanceof FrameLayout) {
                    ((FrameLayout) mContentParent).setForeground(null);
                }
            } else {
                mTitleView.setText(mTitle);
            }
        } else {
            mActionBar = (ActionBarView) findViewById(com.android.internal.R.id.action_bar);
            if (mActionBar != null) {
                mActionBar.setWindowCallback(getCallback());
                if (mActionBar.getTitle() == null) {
                    mActionBar.setWindowTitle(mTitle);
                }
                final int localFeatures = getLocalFeatures();
                if ((localFeatures & (1 << FEATURE_PROGRESS)) != 0) {
                    mActionBar.initProgress();
                }
                if ((localFeatures & (1 << FEATURE_INDETERMINATE_PROGRESS)) != 0) {
                    mActionBar.initIndeterminateProgress();
                }
                boolean splitActionBar = false;
                final boolean splitWhenNarrow = (mUiOptions & ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW) != 0;
                if (splitWhenNarrow) {
                    splitActionBar = getContext().getResources().getBoolean(com.android.internal.R.bool.split_action_bar_is_narrow);
                } else {
                    splitActionBar = getWindowStyle().getBoolean(com.android.internal.R.styleable.Window_windowSplitActionBar, false);
                }
                final ActionBarContainer splitView = (ActionBarContainer) findViewById(com.android.internal.R.id.split_action_bar);
                if (splitView != null) {
                    mActionBar.setSplitView(splitView);
                    mActionBar.setSplitActionBar(splitActionBar);
                    mActionBar.setSplitWhenNarrow(splitWhenNarrow);
                    final ActionBarContextView cab = (ActionBarContextView) findViewById(com.android.internal.R.id.action_context_bar);
                    cab.setSplitView(splitView);
                    cab.setSplitActionBar(splitActionBar);
                    cab.setSplitWhenNarrow(splitWhenNarrow);
                } else if (splitActionBar) {
                    Log.e(TAG, "Requested split action bar with " + "incompatible window decor! Ignoring request.");
                }
                // Post the panel invalidate for later; avoid application onCreateOptionsMenu
                // being called in the middle of onCreate or similar.
                mDecor.post(new Runnable() {

                    public void run() {
                        // Invalidate if the panel menu hasn't been created before this.
                        PanelFeatureState st = getPanelState(FEATURE_OPTIONS_PANEL, false);
                        if (!isDestroyed() && (st == null || st.menu == null)) {
                            invalidatePanelMenu(FEATURE_ACTION_BAR);
                        }
                    }
                });
            }
        }
    }
}
Also used : ActionBarContainer(com.android.internal.widget.ActionBarContainer) FrameLayout(android.widget.FrameLayout) ActionBarContextView(com.android.internal.widget.ActionBarContextView) MenuView(com.android.internal.view.menu.MenuView) ImageView(android.widget.ImageView) View(android.view.View) ActionBarView(com.android.internal.widget.ActionBarView) TextView(android.widget.TextView) ActionBarContextView(com.android.internal.widget.ActionBarContextView)

Example 2 with ActionBarContextView

use of com.android.internal.widget.ActionBarContextView in project android_frameworks_base by ResurrectionRemix.

the class DecorView method createStandaloneActionMode.

private ActionMode createStandaloneActionMode(ActionMode.Callback callback) {
    endOnGoingFadeAnimation();
    cleanupPrimaryActionMode();
    // cleanupPrimaryActionMode() invocation above.
    if (mPrimaryActionModeView == null || !mPrimaryActionModeView.isAttachedToWindow()) {
        if (mWindow.isFloating()) {
            // Use the action bar theme.
            final TypedValue outValue = new TypedValue();
            final Resources.Theme baseTheme = mContext.getTheme();
            baseTheme.resolveAttribute(R.attr.actionBarTheme, outValue, true);
            final Context actionBarContext;
            if (outValue.resourceId != 0) {
                final Resources.Theme actionBarTheme = mContext.getResources().newTheme();
                actionBarTheme.setTo(baseTheme);
                actionBarTheme.applyStyle(outValue.resourceId, true);
                actionBarContext = new ContextThemeWrapper(mContext, 0);
                actionBarContext.getTheme().setTo(actionBarTheme);
            } else {
                actionBarContext = mContext;
            }
            mPrimaryActionModeView = new ActionBarContextView(actionBarContext);
            mPrimaryActionModePopup = new PopupWindow(actionBarContext, null, R.attr.actionModePopupWindowStyle);
            mPrimaryActionModePopup.setWindowLayoutType(WindowManager.LayoutParams.TYPE_APPLICATION);
            mPrimaryActionModePopup.setContentView(mPrimaryActionModeView);
            mPrimaryActionModePopup.setWidth(MATCH_PARENT);
            actionBarContext.getTheme().resolveAttribute(R.attr.actionBarSize, outValue, true);
            final int height = TypedValue.complexToDimensionPixelSize(outValue.data, actionBarContext.getResources().getDisplayMetrics());
            mPrimaryActionModeView.setContentHeight(height);
            mPrimaryActionModePopup.setHeight(WRAP_CONTENT);
            mShowPrimaryActionModePopup = new Runnable() {

                public void run() {
                    mPrimaryActionModePopup.showAtLocation(mPrimaryActionModeView.getApplicationWindowToken(), Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0);
                    endOnGoingFadeAnimation();
                    if (shouldAnimatePrimaryActionModeView()) {
                        mFadeAnim = ObjectAnimator.ofFloat(mPrimaryActionModeView, View.ALPHA, 0f, 1f);
                        mFadeAnim.addListener(new AnimatorListenerAdapter() {

                            @Override
                            public void onAnimationStart(Animator animation) {
                                mPrimaryActionModeView.setVisibility(VISIBLE);
                            }

                            @Override
                            public void onAnimationEnd(Animator animation) {
                                mPrimaryActionModeView.setAlpha(1f);
                                mFadeAnim = null;
                            }
                        });
                        mFadeAnim.start();
                    } else {
                        mPrimaryActionModeView.setAlpha(1f);
                        mPrimaryActionModeView.setVisibility(VISIBLE);
                    }
                }
            };
        } else {
            ViewStub stub = (ViewStub) findViewById(R.id.action_mode_bar_stub);
            if (stub != null) {
                mPrimaryActionModeView = (ActionBarContextView) stub.inflate();
                mPrimaryActionModePopup = null;
            }
        }
    }
    if (mPrimaryActionModeView != null) {
        mPrimaryActionModeView.killMode();
        ActionMode mode = new StandaloneActionMode(mPrimaryActionModeView.getContext(), mPrimaryActionModeView, callback, mPrimaryActionModePopup == null);
        return mode;
    }
    return null;
}
Also used : Context(android.content.Context) PopupWindow(android.widget.PopupWindow) Paint(android.graphics.Paint) StandaloneActionMode(com.android.internal.view.StandaloneActionMode) ViewStub(android.view.ViewStub) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ContextThemeWrapper(android.view.ContextThemeWrapper) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ActionMode(android.view.ActionMode) StandaloneActionMode(com.android.internal.view.StandaloneActionMode) FloatingActionMode(com.android.internal.view.FloatingActionMode) ActionBarContextView(com.android.internal.widget.ActionBarContextView) Resources(android.content.res.Resources) TypedValue(android.util.TypedValue)

Example 3 with ActionBarContextView

use of com.android.internal.widget.ActionBarContextView in project android_frameworks_base by crdroidandroid.

the class DecorView method createStandaloneActionMode.

private ActionMode createStandaloneActionMode(ActionMode.Callback callback) {
    endOnGoingFadeAnimation();
    cleanupPrimaryActionMode();
    // cleanupPrimaryActionMode() invocation above.
    if (mPrimaryActionModeView == null || !mPrimaryActionModeView.isAttachedToWindow()) {
        if (mWindow.isFloating()) {
            // Use the action bar theme.
            final TypedValue outValue = new TypedValue();
            final Resources.Theme baseTheme = mContext.getTheme();
            baseTheme.resolveAttribute(R.attr.actionBarTheme, outValue, true);
            final Context actionBarContext;
            if (outValue.resourceId != 0) {
                final Resources.Theme actionBarTheme = mContext.getResources().newTheme();
                actionBarTheme.setTo(baseTheme);
                actionBarTheme.applyStyle(outValue.resourceId, true);
                actionBarContext = new ContextThemeWrapper(mContext, 0);
                actionBarContext.getTheme().setTo(actionBarTheme);
            } else {
                actionBarContext = mContext;
            }
            mPrimaryActionModeView = new ActionBarContextView(actionBarContext);
            mPrimaryActionModePopup = new PopupWindow(actionBarContext, null, R.attr.actionModePopupWindowStyle);
            mPrimaryActionModePopup.setWindowLayoutType(WindowManager.LayoutParams.TYPE_APPLICATION);
            mPrimaryActionModePopup.setContentView(mPrimaryActionModeView);
            mPrimaryActionModePopup.setWidth(MATCH_PARENT);
            actionBarContext.getTheme().resolveAttribute(R.attr.actionBarSize, outValue, true);
            final int height = TypedValue.complexToDimensionPixelSize(outValue.data, actionBarContext.getResources().getDisplayMetrics());
            mPrimaryActionModeView.setContentHeight(height);
            mPrimaryActionModePopup.setHeight(WRAP_CONTENT);
            mShowPrimaryActionModePopup = new Runnable() {

                public void run() {
                    mPrimaryActionModePopup.showAtLocation(mPrimaryActionModeView.getApplicationWindowToken(), Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0);
                    endOnGoingFadeAnimation();
                    if (shouldAnimatePrimaryActionModeView()) {
                        mFadeAnim = ObjectAnimator.ofFloat(mPrimaryActionModeView, View.ALPHA, 0f, 1f);
                        mFadeAnim.addListener(new AnimatorListenerAdapter() {

                            @Override
                            public void onAnimationStart(Animator animation) {
                                mPrimaryActionModeView.setVisibility(VISIBLE);
                            }

                            @Override
                            public void onAnimationEnd(Animator animation) {
                                mPrimaryActionModeView.setAlpha(1f);
                                mFadeAnim = null;
                            }
                        });
                        mFadeAnim.start();
                    } else {
                        mPrimaryActionModeView.setAlpha(1f);
                        mPrimaryActionModeView.setVisibility(VISIBLE);
                    }
                }
            };
        } else {
            ViewStub stub = (ViewStub) findViewById(R.id.action_mode_bar_stub);
            if (stub != null) {
                mPrimaryActionModeView = (ActionBarContextView) stub.inflate();
                mPrimaryActionModePopup = null;
            }
        }
    }
    if (mPrimaryActionModeView != null) {
        mPrimaryActionModeView.killMode();
        ActionMode mode = new StandaloneActionMode(mPrimaryActionModeView.getContext(), mPrimaryActionModeView, callback, mPrimaryActionModePopup == null);
        return mode;
    }
    return null;
}
Also used : Context(android.content.Context) PopupWindow(android.widget.PopupWindow) Paint(android.graphics.Paint) StandaloneActionMode(com.android.internal.view.StandaloneActionMode) ViewStub(android.view.ViewStub) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ContextThemeWrapper(android.view.ContextThemeWrapper) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ActionMode(android.view.ActionMode) StandaloneActionMode(com.android.internal.view.StandaloneActionMode) FloatingActionMode(com.android.internal.view.FloatingActionMode) ActionBarContextView(com.android.internal.widget.ActionBarContextView) Resources(android.content.res.Resources) TypedValue(android.util.TypedValue)

Example 4 with ActionBarContextView

use of com.android.internal.widget.ActionBarContextView in project platform_frameworks_base by android.

the class DecorView method createStandaloneActionMode.

private ActionMode createStandaloneActionMode(ActionMode.Callback callback) {
    endOnGoingFadeAnimation();
    cleanupPrimaryActionMode();
    // cleanupPrimaryActionMode() invocation above.
    if (mPrimaryActionModeView == null || !mPrimaryActionModeView.isAttachedToWindow()) {
        if (mWindow.isFloating()) {
            // Use the action bar theme.
            final TypedValue outValue = new TypedValue();
            final Resources.Theme baseTheme = mContext.getTheme();
            baseTheme.resolveAttribute(R.attr.actionBarTheme, outValue, true);
            final Context actionBarContext;
            if (outValue.resourceId != 0) {
                final Resources.Theme actionBarTheme = mContext.getResources().newTheme();
                actionBarTheme.setTo(baseTheme);
                actionBarTheme.applyStyle(outValue.resourceId, true);
                actionBarContext = new ContextThemeWrapper(mContext, 0);
                actionBarContext.getTheme().setTo(actionBarTheme);
            } else {
                actionBarContext = mContext;
            }
            mPrimaryActionModeView = new ActionBarContextView(actionBarContext);
            mPrimaryActionModePopup = new PopupWindow(actionBarContext, null, R.attr.actionModePopupWindowStyle);
            mPrimaryActionModePopup.setWindowLayoutType(WindowManager.LayoutParams.TYPE_APPLICATION);
            mPrimaryActionModePopup.setContentView(mPrimaryActionModeView);
            mPrimaryActionModePopup.setWidth(MATCH_PARENT);
            actionBarContext.getTheme().resolveAttribute(R.attr.actionBarSize, outValue, true);
            final int height = TypedValue.complexToDimensionPixelSize(outValue.data, actionBarContext.getResources().getDisplayMetrics());
            mPrimaryActionModeView.setContentHeight(height);
            mPrimaryActionModePopup.setHeight(WRAP_CONTENT);
            mShowPrimaryActionModePopup = new Runnable() {

                public void run() {
                    mPrimaryActionModePopup.showAtLocation(mPrimaryActionModeView.getApplicationWindowToken(), Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0);
                    endOnGoingFadeAnimation();
                    if (shouldAnimatePrimaryActionModeView()) {
                        mFadeAnim = ObjectAnimator.ofFloat(mPrimaryActionModeView, View.ALPHA, 0f, 1f);
                        mFadeAnim.addListener(new AnimatorListenerAdapter() {

                            @Override
                            public void onAnimationStart(Animator animation) {
                                mPrimaryActionModeView.setVisibility(VISIBLE);
                            }

                            @Override
                            public void onAnimationEnd(Animator animation) {
                                mPrimaryActionModeView.setAlpha(1f);
                                mFadeAnim = null;
                            }
                        });
                        mFadeAnim.start();
                    } else {
                        mPrimaryActionModeView.setAlpha(1f);
                        mPrimaryActionModeView.setVisibility(VISIBLE);
                    }
                }
            };
        } else {
            ViewStub stub = (ViewStub) findViewById(R.id.action_mode_bar_stub);
            if (stub != null) {
                mPrimaryActionModeView = (ActionBarContextView) stub.inflate();
                mPrimaryActionModePopup = null;
            }
        }
    }
    if (mPrimaryActionModeView != null) {
        mPrimaryActionModeView.killMode();
        ActionMode mode = new StandaloneActionMode(mPrimaryActionModeView.getContext(), mPrimaryActionModeView, callback, mPrimaryActionModePopup == null);
        return mode;
    }
    return null;
}
Also used : Context(android.content.Context) PopupWindow(android.widget.PopupWindow) Paint(android.graphics.Paint) StandaloneActionMode(com.android.internal.view.StandaloneActionMode) ViewStub(android.view.ViewStub) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ContextThemeWrapper(android.view.ContextThemeWrapper) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ActionMode(android.view.ActionMode) StandaloneActionMode(com.android.internal.view.StandaloneActionMode) FloatingActionMode(com.android.internal.view.FloatingActionMode) ActionBarContextView(com.android.internal.widget.ActionBarContextView) Resources(android.content.res.Resources) TypedValue(android.util.TypedValue)

Example 5 with ActionBarContextView

use of com.android.internal.widget.ActionBarContextView in project android_frameworks_base by AOSPA.

the class DecorView method createStandaloneActionMode.

private ActionMode createStandaloneActionMode(ActionMode.Callback callback) {
    endOnGoingFadeAnimation();
    cleanupPrimaryActionMode();
    // cleanupPrimaryActionMode() invocation above.
    if (mPrimaryActionModeView == null || !mPrimaryActionModeView.isAttachedToWindow()) {
        if (mWindow.isFloating()) {
            // Use the action bar theme.
            final TypedValue outValue = new TypedValue();
            final Resources.Theme baseTheme = mContext.getTheme();
            baseTheme.resolveAttribute(R.attr.actionBarTheme, outValue, true);
            final Context actionBarContext;
            if (outValue.resourceId != 0) {
                final Resources.Theme actionBarTheme = mContext.getResources().newTheme();
                actionBarTheme.setTo(baseTheme);
                actionBarTheme.applyStyle(outValue.resourceId, true);
                actionBarContext = new ContextThemeWrapper(mContext, 0);
                actionBarContext.getTheme().setTo(actionBarTheme);
            } else {
                actionBarContext = mContext;
            }
            mPrimaryActionModeView = new ActionBarContextView(actionBarContext);
            mPrimaryActionModePopup = new PopupWindow(actionBarContext, null, R.attr.actionModePopupWindowStyle);
            mPrimaryActionModePopup.setWindowLayoutType(WindowManager.LayoutParams.TYPE_APPLICATION);
            mPrimaryActionModePopup.setContentView(mPrimaryActionModeView);
            mPrimaryActionModePopup.setWidth(MATCH_PARENT);
            actionBarContext.getTheme().resolveAttribute(R.attr.actionBarSize, outValue, true);
            final int height = TypedValue.complexToDimensionPixelSize(outValue.data, actionBarContext.getResources().getDisplayMetrics());
            mPrimaryActionModeView.setContentHeight(height);
            mPrimaryActionModePopup.setHeight(WRAP_CONTENT);
            mShowPrimaryActionModePopup = new Runnable() {

                public void run() {
                    mPrimaryActionModePopup.showAtLocation(mPrimaryActionModeView.getApplicationWindowToken(), Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0);
                    endOnGoingFadeAnimation();
                    if (shouldAnimatePrimaryActionModeView()) {
                        mFadeAnim = ObjectAnimator.ofFloat(mPrimaryActionModeView, View.ALPHA, 0f, 1f);
                        mFadeAnim.addListener(new AnimatorListenerAdapter() {

                            @Override
                            public void onAnimationStart(Animator animation) {
                                mPrimaryActionModeView.setVisibility(VISIBLE);
                            }

                            @Override
                            public void onAnimationEnd(Animator animation) {
                                mPrimaryActionModeView.setAlpha(1f);
                                mFadeAnim = null;
                            }
                        });
                        mFadeAnim.start();
                    } else {
                        mPrimaryActionModeView.setAlpha(1f);
                        mPrimaryActionModeView.setVisibility(VISIBLE);
                    }
                }
            };
        } else {
            ViewStub stub = (ViewStub) findViewById(R.id.action_mode_bar_stub);
            if (stub != null) {
                mPrimaryActionModeView = (ActionBarContextView) stub.inflate();
                mPrimaryActionModePopup = null;
            }
        }
    }
    if (mPrimaryActionModeView != null) {
        mPrimaryActionModeView.killMode();
        ActionMode mode = new StandaloneActionMode(mPrimaryActionModeView.getContext(), mPrimaryActionModeView, callback, mPrimaryActionModePopup == null);
        return mode;
    }
    return null;
}
Also used : Context(android.content.Context) PopupWindow(android.widget.PopupWindow) Paint(android.graphics.Paint) StandaloneActionMode(com.android.internal.view.StandaloneActionMode) ViewStub(android.view.ViewStub) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ContextThemeWrapper(android.view.ContextThemeWrapper) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ActionMode(android.view.ActionMode) StandaloneActionMode(com.android.internal.view.StandaloneActionMode) FloatingActionMode(com.android.internal.view.FloatingActionMode) ActionBarContextView(com.android.internal.widget.ActionBarContextView) Resources(android.content.res.Resources) TypedValue(android.util.TypedValue)

Aggregations

ActionBarContextView (com.android.internal.widget.ActionBarContextView)6 Animator (android.animation.Animator)5 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)5 ObjectAnimator (android.animation.ObjectAnimator)5 Context (android.content.Context)5 Resources (android.content.res.Resources)5 Paint (android.graphics.Paint)5 TypedValue (android.util.TypedValue)5 ActionMode (android.view.ActionMode)5 ContextThemeWrapper (android.view.ContextThemeWrapper)5 ViewStub (android.view.ViewStub)5 PopupWindow (android.widget.PopupWindow)5 FloatingActionMode (com.android.internal.view.FloatingActionMode)5 StandaloneActionMode (com.android.internal.view.StandaloneActionMode)5 View (android.view.View)1 FrameLayout (android.widget.FrameLayout)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 MenuView (com.android.internal.view.menu.MenuView)1 ActionBarContainer (com.android.internal.widget.ActionBarContainer)1