Search in sources :

Example 71 with ActionMode

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

the class PhoneWindowActionModeTest method testCreatedPrimaryModeLifecycleIsHandled.

@UiThreadTest
public void testCreatedPrimaryModeLifecycleIsHandled() {
    mWindowCallback.mShouldReturnOwnActionMode = false;
    ActionMode mode = mPhoneWindow.getDecorView().startActionMode(mActionModeCallback, ActionMode.TYPE_PRIMARY);
    assertNotNull(mode);
    assertEquals(ActionMode.TYPE_PRIMARY, mode.getType());
    assertTrue(mActionModeCallback.mIsCreateActionModeCalled);
    assertTrue(mWindowCallback.mIsActionModeStarted);
}
Also used : ActionMode(android.view.ActionMode) UiThreadTest(android.test.UiThreadTest)

Example 72 with ActionMode

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

the class PhoneWindowActionModeTest method testStartActionModeWithCallback.

public void testStartActionModeWithCallback() {
    mWindowCallback.mShouldReturnOwnActionMode = true;
    ActionMode mode = mPhoneWindow.getDecorView().startActionMode(mActionModeCallback, ActionMode.TYPE_FLOATING);
    assertEquals(mWindowCallback.mLastCreatedActionMode, mode);
}
Also used : ActionMode(android.view.ActionMode)

Example 73 with ActionMode

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

the class DecorView method startActionMode.

private ActionMode startActionMode(View originatingView, ActionMode.Callback callback, int type) {
    ActionMode.Callback2 wrappedCallback = new ActionModeCallback2Wrapper(callback);
    ActionMode mode = null;
    if (mWindow.getCallback() != null && !mWindow.isDestroyed()) {
        try {
            mode = mWindow.getCallback().onWindowStartingActionMode(wrappedCallback, type);
        } catch (AbstractMethodError ame) {
            // Older apps might not implement the typed version of this method.
            if (type == ActionMode.TYPE_PRIMARY) {
                try {
                    mode = mWindow.getCallback().onWindowStartingActionMode(wrappedCallback);
                } catch (AbstractMethodError ame2) {
                // Older apps might not implement this callback method at all.
                }
            }
        }
    }
    if (mode != null) {
        if (mode.getType() == ActionMode.TYPE_PRIMARY) {
            cleanupPrimaryActionMode();
            mPrimaryActionMode = mode;
        } else if (mode.getType() == ActionMode.TYPE_FLOATING) {
            if (mFloatingActionMode != null) {
                mFloatingActionMode.finish();
            }
            mFloatingActionMode = mode;
        }
    } else {
        mode = createActionMode(type, wrappedCallback, originatingView);
        if (mode != null && wrappedCallback.onCreateActionMode(mode, mode.getMenu())) {
            setHandledActionMode(mode);
        } else {
            mode = null;
        }
    }
    if (mode != null && mWindow.getCallback() != null && !mWindow.isDestroyed()) {
        try {
            mWindow.getCallback().onActionModeStarted(mode);
        } catch (AbstractMethodError ame) {
        // Older apps might not implement this callback method.
        }
    }
    return mode;
}
Also used : ActionMode(android.view.ActionMode) StandaloneActionMode(com.android.internal.view.StandaloneActionMode) FloatingActionMode(com.android.internal.view.FloatingActionMode)

Example 74 with ActionMode

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

the class WindowDecorActionBarTest method testStartActionMode.

@UiThreadTest
public void testStartActionMode() {
    ActionMode mode = mWindowDecorActionBar.startActionMode(mCallback);
    assertNotNull(mode);
    assertTrue(mCallback.mIsCreateActionModeCalled);
}
Also used : ActionMode(android.view.ActionMode) UiThreadTest(android.test.UiThreadTest)

Example 75 with ActionMode

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

the class WindowDecorActionBarTest method testStartActionModeFinishesPreviousMode.

@UiThreadTest
public void testStartActionModeFinishesPreviousMode() {
    ActionMode mode1 = mWindowDecorActionBar.startActionMode(mCallback);
    ActionMode mode2 = mWindowDecorActionBar.startActionMode(new MockActionModeCallback());
    assertNotNull(mode1);
    assertNotNull(mode2);
    assertTrue(mCallback.mIsDestroyActionModeCalled);
}
Also used : ActionMode(android.view.ActionMode) UiThreadTest(android.test.UiThreadTest)

Aggregations

ActionMode (android.view.ActionMode)99 UiThreadTest (android.test.UiThreadTest)30 FloatingActionMode (com.android.internal.view.FloatingActionMode)15 StandaloneActionMode (com.android.internal.view.StandaloneActionMode)10 Menu (android.view.Menu)9 MenuItem (android.view.MenuItem)9 Animator (android.animation.Animator)6 Context (android.content.Context)6 Paint (android.graphics.Paint)6 View (android.view.View)6 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)5 ObjectAnimator (android.animation.ObjectAnimator)5 Resources (android.content.res.Resources)5 TypedValue (android.util.TypedValue)5 ContextThemeWrapper (android.view.ContextThemeWrapper)5 ViewStub (android.view.ViewStub)5 PopupWindow (android.widget.PopupWindow)5 ActionBarContextView (com.android.internal.widget.ActionBarContextView)5 MenuInflater (android.view.MenuInflater)4 AdapterView (android.widget.AdapterView)3