Example usage for android.app Activity DEFAULT_KEYS_SHORTCUT

List of usage examples for android.app Activity DEFAULT_KEYS_SHORTCUT

Introduction

In this page you can find the example usage for android.app Activity DEFAULT_KEYS_SHORTCUT.

Prototype

int DEFAULT_KEYS_SHORTCUT

To view the source code for android.app Activity DEFAULT_KEYS_SHORTCUT.

Click Source Link

Document

Use with #setDefaultKeyMode to execute a menu shortcut in default key handling.

Usage

From source file:com.chen.mail.ui.AbstractActivityController.java

/**
 * The application can be started from the following entry points:
 * <ul>//ww w .j av  a 2  s.c  om
 *     <li>Launcher: you tap on the Gmail icon in the launcher. This is what most users think of
 *         as Starting the app?.</li>
 *     <li>Shortcut: Users can make a shortcut to take them directly to a label.</li>
 *     <li>Widget: Shows the contents of a synced label, and allows:
 *     <ul>
 *         <li>Viewing the list (tapping on the title)</li>
 *         <li>Composing a new message (tapping on the new message icon in the title. This
 *         launches the {@link ComposeActivity}.
 *         </li>
 *         <li>Viewing a single message (tapping on a list element)</li>
 *     </ul>
 *
 *     </li>
 *     <li>Tapping on a notification:
 *     <ul>
 *         <li>Shows message list if more than one message</li>
 *         <li>Shows the conversation if the notification is for a single message</li>
 *     </ul>
 *     </li>
 *     <li>...and most importantly, the activity life cycle can tear down the application and
 *     restart it:
 *     <ul>
 *         <li>Rotate the application: it is destroyed and recreated.</li>
 *         <li>Navigate away, and return from recent applications.</li>
 *     </ul>
 *     </li>
 *     <li>Add a new account: fires off an intent to add an account,
 *     and returns in {@link #onActivityResult(int, int, android.content.Intent)} .</li>
 *     <li>Re-authenticate your account: again returns in onActivityResult().</li>
 *     <li>Composing can happen from many entry points: third party applications fire off an
 *     intent to compose email, and launch directly into the {@link ComposeActivity}
 *     .</li>
 * </ul>
 * {@inheritDoc}
 */
@Override
public boolean onCreate(Bundle savedState) {
    initializeActionBar();
    initializeDevLoggingService();
    // Allow shortcut keys to function for the ActionBar and menus.
    mActivity.setDefaultKeyMode(Activity.DEFAULT_KEYS_SHORTCUT);
    mResolver = mActivity.getContentResolver();
    mNewEmailReceiver = new SuppressNotificationReceiver();
    mRecentFolderList.initialize(mActivity);
    mVeiledMatcher.initialize(this);

    // the "open drawer description" argument is for when the drawer is open
    // so tell the user that interacting will cause the drawer to close
    // and vice versa for the "close drawer description" argument
    mDrawerToggle = new ActionBarDrawerToggle((Activity) mActivity, mDrawerContainer, R.drawable.ic_drawer,
            R.string.drawer_close, R.string.drawer_open);
    mDrawerListener = new MailDrawerListener();
    mDrawerContainer.setDrawerListener(mDrawerListener);
    mDrawerContainer.setDrawerShadow(mContext.getResources().getDrawable(R.drawable.drawer_shadow),
            Gravity.START);

    mDrawerToggle.setDrawerIndicatorEnabled(isDrawerEnabled());

    // All the individual UI components listen for ViewMode changes. This
    // simplifies the amount of logic in the AbstractActivityController, but increases the
    // possibility of timing-related bugs.
    mViewMode.addListener(this);
    mPagerController = new ConversationPagerController(mActivity, this);
    mToastBar = (ActionableToastBar) mActivity.findViewById(R.id.toast_bar);
    attachActionBar();
    FolderSelectionDialog.setDialogDismissed();

    mDrawIdler.setRootView(mActivity.getWindow().getDecorView());

    final Intent intent = mActivity.getIntent();

    // Immediately handle a clean launch with intent, and any state restoration
    // that does not rely on restored fragments or loader data
    // any state restoration that relies on those can be done later in
    // onRestoreInstanceState, once fragments are up and loader data is re-delivered
    if (savedState != null) {
        if (savedState.containsKey(SAVED_ACCOUNT)) {
            setAccount((Account) savedState.getParcelable(SAVED_ACCOUNT));
        }
        if (savedState.containsKey(SAVED_FOLDER)) {
            final Folder folder = savedState.getParcelable(SAVED_FOLDER);
            final String query = savedState.getString(SAVED_QUERY, null);
            setListContext(folder, query);
        }
        if (savedState.containsKey(SAVED_ACTION)) {
            mDialogAction = savedState.getInt(SAVED_ACTION);
        }
        mDialogFromSelectedSet = savedState.getBoolean(SAVED_ACTION_FROM_SELECTED, false);
        mViewMode.handleRestore(savedState);
    } else if (intent != null) {
        handleIntent(intent);
    }
    // Create the accounts loader; this loads the account switch spinner.
    mActivity.getLoaderManager().initLoader(LOADER_ACCOUNT_CURSOR, Bundle.EMPTY, mAccountCallbacks);
    return true;
}

From source file:com.android.mail.ui.AbstractActivityController.java

/**
 * The application can be started from the following entry points:
 * <ul>/*from   w  w  w  . j a va  2s .  c o m*/
 *     <li>Launcher: you tap on the Gmail icon in the launcher. This is what most users think of
 *         as Starting the app?.</li>
 *     <li>Shortcut: Users can make a shortcut to take them directly to a label.</li>
 *     <li>Widget: Shows the contents of a synced label, and allows:
 *     <ul>
 *         <li>Viewing the list (tapping on the title)</li>
 *         <li>Composing a new message (tapping on the new message icon in the title. This
 *         launches the {@link ComposeActivity}.
 *         </li>
 *         <li>Viewing a single message (tapping on a list element)</li>
 *     </ul>
 *
 *     </li>
 *     <li>Tapping on a notification:
 *     <ul>
 *         <li>Shows message list if more than one message</li>
 *         <li>Shows the conversation if the notification is for a single message</li>
 *     </ul>
 *     </li>
 *     <li>...and most importantly, the activity life cycle can tear down the application and
 *     restart it:
 *     <ul>
 *         <li>Rotate the application: it is destroyed and recreated.</li>
 *         <li>Navigate away, and return from recent applications.</li>
 *     </ul>
 *     </li>
 *     <li>Add a new account: fires off an intent to add an account,
 *     and returns in {@link #onActivityResult(int, int, android.content.Intent)} .</li>
 *     <li>Re-authenticate your account: again returns in onActivityResult().</li>
 *     <li>Composing can happen from many entry points: third party applications fire off an
 *     intent to compose email, and launch directly into the {@link ComposeActivity}
 *     .</li>
 * </ul>
 * {@inheritDoc}
 */
@Override
public void onCreate(Bundle savedState) {
    initializeActionBar();
    initializeDevLoggingService();
    // Allow shortcut keys to function for the ActionBar and menus.
    mActivity.setDefaultKeyMode(Activity.DEFAULT_KEYS_SHORTCUT);
    mResolver = mActivity.getContentResolver();
    mNewEmailReceiver = new SuppressNotificationReceiver();
    mRecentFolderList.initialize(mActivity);
    mVeiledMatcher.initialize(this);

    mFloatingComposeButton = mActivity.findViewById(R.id.compose_button);
    mFloatingComposeButton.setOnClickListener(this);

    if (isDrawerEnabled()) {
        mDrawerToggle = new ActionBarDrawerToggle(mActivity, mDrawerContainer, R.string.drawer_open,
                R.string.drawer_close);
        mDrawerContainer.setDrawerListener(mDrawerListener);
        mDrawerContainer.setDrawerShadow(mContext.getResources().getDrawable(R.drawable.drawer_shadow),
                Gravity.START);

        // Disable default drawer indicator as we are setting the drawer indicator icons.
        // TODO(shahrk): Once we can disable/enable drawer animation, go back to using
        // drawer indicators.
        mDrawerToggle.setDrawerIndicatorEnabled(false);
        mDrawerToggle.setHomeAsUpIndicator(R.drawable.ic_menu_wht_24dp);
    } else {
        final ActionBar ab = mActivity.getSupportActionBar();
        ab.setHomeAsUpIndicator(R.drawable.ic_menu_wht_24dp);
        ab.setHomeActionContentDescription(R.string.drawer_open);
        ab.setDisplayHomeAsUpEnabled(true);
    }

    // All the individual UI components listen for ViewMode changes. This
    // simplifies the amount of logic in the AbstractActivityController, but increases the
    // possibility of timing-related bugs.
    mViewMode.addListener(this);
    mPagerController = new ConversationPagerController(mActivity, this);
    mToastBar = findActionableToastBar(mActivity);
    attachActionBar();

    mDrawIdler.setRootView(mActivity.getWindow().getDecorView());

    final Intent intent = mActivity.getIntent();

    mSearchViewController = new MaterialSearchViewController(mActivity, this, intent, savedState);
    addConversationListLayoutListener(mSearchViewController);

    // Immediately handle a clean launch with intent, and any state restoration
    // that does not rely on restored fragments or loader data
    // any state restoration that relies on those can be done later in
    // onRestoreInstanceState, once fragments are up and loader data is re-delivered
    if (savedState != null) {
        if (savedState.containsKey(SAVED_ACCOUNT)) {
            setAccount((Account) savedState.getParcelable(SAVED_ACCOUNT));
        }
        if (savedState.containsKey(SAVED_FOLDER)) {
            final Folder folder = savedState.getParcelable(SAVED_FOLDER);
            final String query = savedState.getString(SAVED_QUERY, null);
            setListContext(folder, query);
        }
        if (savedState.containsKey(SAVED_ACTION)) {
            mDialogAction = savedState.getInt(SAVED_ACTION);
        }
        mDialogFromSelectedSet = savedState.getBoolean(SAVED_ACTION_FROM_SELECTED, false);
        mViewMode.handleRestore(savedState);
    } else if (intent != null) {
        handleIntent(intent);
    }
    // Create the accounts loader; this loads the account switch spinner.
    mActivity.getLoaderManager().initLoader(LOADER_ACCOUNT_CURSOR, Bundle.EMPTY, mAccountCallbacks);
}

From source file:com.tct.mail.ui.AbstractActivityController.java

/**
 * The application can be started from the following entry points:
 * <ul>//from  w ww. ja  v  a 2 s. c o  m
 *     <li>Launcher: you tap on the Gmail icon in the launcher. This is what most users think of
 *         as Starting the app?.</li>
 *     <li>Shortcut: Users can make a shortcut to take them directly to a label.</li>
 *     <li>Widget: Shows the contents of a synced label, and allows:
 *     <ul>
 *         <li>Viewing the list (tapping on the title)</li>
 *         <li>Composing a new message (tapping on the new message icon in the title. This
 *         launches the {@link ComposeActivity}.
 *         </li>
 *         <li>Viewing a single message (tapping on a list element)</li>
 *     </ul>
 *
 *     </li>
 *     <li>Tapping on a notification:
 *     <ul>
 *         <li>Shows message list if more than one message</li>
 *         <li>Shows the conversation if the notification is for a single message</li>
 *     </ul>
 *     </li>
 *     <li>...and most importantly, the activity life cycle can tear down the application and
 *     restart it:
 *     <ul>
 *         <li>Rotate the application: it is destroyed and recreated.</li>
 *         <li>Navigate away, and return from recent applications.</li>
 *     </ul>
 *     </li>
 *     <li>Add a new account: fires off an intent to add an account,
 *     and returns in {@link #onActivityResult(int, int, android.content.Intent)} .</li>
 *     <li>Re-authenticate your account: again returns in onActivityResult().</li>
 *     <li>Composing can happen from many entry points: third party applications fire off an
 *     intent to compose email, and launch directly into the {@link ComposeActivity}
 *     .</li>
 * </ul>
 * {@inheritDoc}
 */
@SuppressLint("NewApi")
@Override
public boolean onCreate(Bundle savedState) {
    initializeActionBar();
    initializeDevLoggingService();
    // Allow shortcut keys to function for the ActionBar and menus.
    mActivity.setDefaultKeyMode(Activity.DEFAULT_KEYS_SHORTCUT);
    mResolver = mActivity.getContentResolver();
    mNewEmailReceiver = new SuppressNotificationReceiver();
    mRecentFolderList.initialize(mActivity);
    mVeiledMatcher.initialize(this);

    mFloatingComposeButton = mActivity.findViewById(R.id.compose_button);

    //TS: ke.ma 2015-03-12 EMAIL BUGFIX-947440 ADD_S
    mFloatingComposeButton.setElevation(8);
    mFloatingComposeButton.setOutlineProvider(new ViewOutlineProvider() {

        @Override
        public void getOutline(View view, Outline outline) {
            // TODO Auto-generated method stub
            outline.setOval(0, 0, view.getWidth(), view.getWidth());
        }
    });
    //TS: ke.ma 2015-03-12 EMAIL BUGFIX-947440 ADD_E
    mFloatingComposeButton.setOnClickListener(this);

    if (isDrawerEnabled()) {
        mDrawerToggle = new ActionBarDrawerToggle(mActivity, mDrawerContainer,
                //                    false,
                //                    R.drawable.ic_drawer,
                R.string.drawer_open, R.string.drawer_close);
        mDrawerContainer.setDrawerListener(mDrawerListener);
        mDrawerContainer.setDrawerShadow(mContext.getResources().getDrawable(R.drawable.drawer_shadow),
                Gravity.START);

        mDrawerToggle.setDrawerIndicatorEnabled(isDrawerEnabled());
    } else {
        final ActionBar ab = mActivity.getSupportActionBar();
        ab.setHomeAsUpIndicator(R.drawable.ic_drawer);
        ab.setHomeActionContentDescription(R.string.drawer_open);
        ab.setDisplayHomeAsUpEnabled(true);
    }

    // All the individual UI components listen for ViewMode changes. This
    // simplifies the amount of logic in the AbstractActivityController, but increases the
    // possibility of timing-related bugs.
    mViewMode.addListener(this);
    mPagerController = new ConversationPagerController(mActivity, this);
    mToastBar = findActionableToastBar(mActivity);
    attachActionBar();

    mDrawIdler.setRootView(mActivity.getWindow().getDecorView());

    final Intent intent = mActivity.getIntent();

    // Immediately handle a clean launch with intent, and any state restoration
    // that does not rely on restored fragments or loader data
    // any state restoration that relies on those can be done later in
    // onRestoreInstanceState, once fragments are up and loader data is re-delivered
    if (savedState != null) {
        //TS: junwei-xu 2015-09-02 EMAIL BUGFIX-546917 ADD-S
        // restore check status for star toggle
        mCheckStatus = savedState.getBoolean(BUNDLE_CHECK_STATUS_KEY, false);
        //TS: junwei-xu 2015-09-02 EMAIL BUGFIX-546917 ADD-E
        /// TCT: restore global search tag.
        if (savedState.containsKey(SAVED_GLOBAL_SEARCH)) {
            mGlobalSearch = savedState.getBoolean(SAVED_GLOBAL_SEARCH);
            LogUtils.logFeature(LogTag.SEARCH_TAG, "onCreate restore mGlobalSearch [%s] ", mGlobalSearch);
        }
        if (savedState.containsKey(SAVED_ACCOUNT)) {
            setAccount((Account) savedState.getParcelable(SAVED_ACCOUNT));
        }
        if (savedState.containsKey(SAVED_FOLDER)) {
            final Folder folder = savedState.getParcelable(SAVED_FOLDER);
            /**
             * TCT: Restore the local search or global search instance:
             * 1. Restore the ConversationListContext from Bundle.
             * 2. Restore query if in global search mode.
             * 3. Update Local Search UI (ActionBarView)
             * @{
             */
            final Bundle bundle = savedState.getParcelable(SAVED_LOCAL_SEARCH);
            if (bundle != null) {
                final ConversationListContext convListContext = ConversationListContext.forBundle(bundle);
                mConvListContext = convListContext;
                LogUtils.logFeature(LogTag.SEARCH_TAG,
                        "onCreate restore ConverationListContext from saved instance [%s] ", mConvListContext);
            }
            String query = mConvListContext != null ? mConvListContext.getSearchQuery() : null;
            if (TextUtils.isEmpty(query) && mGlobalSearch) {
                query = intent.getStringExtra(SearchManager.QUERY);
                mConvListContext.setLocalSearch(true);
                mConvListContext.setSearchQueryText(query);
                LogUtils.logFeature(LogTag.SEARCH_TAG, "onCreate restore global search query [%s]",
                        mConvListContext);
            }
            setListContext(folder, query);
            if (mConvListContext.isLocalSearch()) {
                LogUtils.logFeature(LogTag.SEARCH_TAG, "[Local Search] Enter and execute local search [%s]",
                        query);
                mActionBarController.expandSearch(query, mConvListContext.getSearchField());
            }
            /** @} */
        }
        if (savedState.containsKey(SAVED_ACTION)) {
            mDialogAction = savedState.getInt(SAVED_ACTION);
        }
        mDialogFromSelectedSet = savedState.getBoolean(SAVED_ACTION_FROM_SELECTED, false);
        mViewMode.handleRestore(savedState);
    } else if (intent != null) {
        handleIntent(intent);
    }
    // Create the accounts loader; this loads the account switch spinner.
    mActivity.getLoaderManager().initLoader(LOADER_ACCOUNT_CURSOR, Bundle.EMPTY, mAccountCallbacks);
    return true;
}