List of usage examples for android.text.method TextKeyListener getInstance
public static TextKeyListener getInstance()
From source file:com.android.launcher3.allapps.FullMergeAlgorithm.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { // Determine if the key event was actual text, if so, focus the search bar and then dispatch // the key normally so that it can process this key event if (!mSearchBarController.isSearchFieldFocused() && event.getAction() == KeyEvent.ACTION_DOWN) { final int unicodeChar = event.getUnicodeChar(); final boolean isKeyNotWhitespace = unicodeChar > 0 && !Character.isWhitespace(unicodeChar) && !Character.isSpaceChar(unicodeChar); if (isKeyNotWhitespace) { boolean gotKey = TextKeyListener.getInstance().onKeyDown(this, mSearchQueryBuilder, event.getKeyCode(), event); if (gotKey && mSearchQueryBuilder.length() > 0) { mSearchBarController.focusSearchField(); }/*from w ww .j ava2 s. com*/ } } return super.dispatchKeyEvent(event); }
From source file:com.android.launcher2.Launcher.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { final int uniChar = event.getUnicodeChar(); final boolean handled = super.onKeyDown(keyCode, event); final boolean isKeyNotWhitespace = uniChar > 0 && !Character.isWhitespace(uniChar); if (!handled && acceptFilter() && isKeyNotWhitespace) { boolean gotKey = TextKeyListener.getInstance().onKeyDown(mWorkspace, mDefaultKeySsb, keyCode, event); if (gotKey && mDefaultKeySsb != null && mDefaultKeySsb.length() > 0) { // something usable has been typed - start a search // the typed text will be retrieved and cleared by // showSearchDialog() // If there are multiple keystrokes before the search dialog takes focus, // onSearchRequested() will be called for every keystroke, // but it is idempotent, so it's fine. return onSearchRequested(); }/*from w w w . ja v a 2s. c o m*/ } // Eat the long press event so the keyboard doesn't come up. if (keyCode == KeyEvent.KEYCODE_MENU && event.isLongPress()) { return true; } return handled; }
From source file:com.android.leanlauncher.LauncherTransitionable.java
@Override public void onDestroy() { super.onDestroy(); // Remove all pending runnables mHandler.removeMessages(ADVANCE_MSG); mHandler.removeMessages(0);//from www.j av a2 s .co m mWorkspace.removeCallbacks(mBuildLayersRunnable); // Stop callbacks from LauncherModel LauncherAppState app = (LauncherAppState.getInstance()); // It's possible to receive onDestroy after a new Launcher activity has // been created. In this case, don't interfere with the new Launcher. if (mModel.isCurrentCallbacks(this)) { mModel.stopLoader(); app.setLauncher(null); } try { mAppWidgetHost.stopListening(); } catch (NullPointerException ex) { Log.w(TAG, "problem while stopping AppWidgetHost during Launcher destruction", ex); } mAppWidgetHost = null; mWidgetsToAdvance.clear(); TextKeyListener.getInstance().release(); // Disconnect any of the callbacks and drawables associated with ItemInfos on the workspace // to prevent leaking Launcher activities on orientation change. if (mModel != null) { mModel.unbindItemInfosAndClearQueuedBindRunnables(); } getContentResolver().unregisterContentObserver(mWidgetObserver); unregisterReceiver(mCloseSystemDialogsReceiver); mDragLayer.clearAllResizeFrames(); ((ViewGroup) mWorkspace.getParent()).removeAllViews(); mWorkspace.removeAllWorkspace(); mWorkspace = null; mDragController = null; LauncherAnimUtils.onDestroyActivity(); }
From source file:com.android.launcher2.Launcher.java
@Override public void onDestroy() { super.onDestroy(); // Remove all pending runnables mHandler.removeMessages(ADVANCE_MSG); mHandler.removeMessages(0);//w w w. j ava 2 s . c o m mWorkspace.removeCallbacks(mBuildLayersRunnable); // Stop callbacks from LauncherModel LauncherApplication app = ((LauncherApplication) getApplication()); mModel.stopLoader(); app.setLauncher(null); try { mAppWidgetHost.stopListening(); } catch (NullPointerException ex) { Log.w(TAG, "problem while stopping AppWidgetHost during Launcher destruction", ex); } mAppWidgetHost = null; mWidgetsToAdvance.clear(); TextKeyListener.getInstance().release(); // Disconnect any of the callbacks and drawables associated with ItemInfos on the workspace // to prevent leaking Launcher activities on orientation change. if (mModel != null) { mModel.unbindItemInfosAndClearQueuedBindRunnables(); } getContentResolver().unregisterContentObserver(mWidgetObserver); unregisterReceiver(mCloseSystemDialogsReceiver); mDragLayer.clearAllResizeFrames(); ((ViewGroup) mWorkspace.getParent()).removeAllViews(); mWorkspace.removeAllViews(); mWorkspace = null; mDragController = null; LauncherAnimUtils.onDestroyActivity(); }
From source file:com.cognizant.trumobi.PersonaLauncher.java
@Override public void onDestroy() { mDestroyed = true;//from w w w. ja va 2 s . co m // setPersistent(false); // ADW: unregister the sharedpref listener getSharedPreferences("launcher.preferences.almostnexus", Context.MODE_PRIVATE) .unregisterOnSharedPreferenceChangeListener(this); super.onDestroy(); try { mAppWidgetHost.stopListening(); } catch (NullPointerException ex) { PersonaLog.w(LOG_TAG, "problem while stopping AppWidgetHost during PersonaLauncher destruction", ex); } TextKeyListener.getInstance().release(); mAllAppsGrid.clearTextFilter(); mAllAppsGrid.setAdapter(null); sModel.unbind(); sModel.abortLoaders(); mWorkspace.unbindWidgetScrollableViews(); getContentResolver().unregisterContentObserver(mObserver); getContentResolver().unregisterContentObserver(mWidgetObserver); //Badge getContentResolver().unregisterContentObserver(mDialerBadgeObserver); getContentResolver().unregisterContentObserver(mMessengerBadgeObserver); unregisterReceiver(mApplicationsReceiver); unregisterReceiver(mCloseSystemDialogsReceiver); if (mCounterReceiver != null) unregisterReceiver(mCounterReceiver); mWorkspace.unregisterProvider(); }
From source file:com.android.soma.Launcher.java
@Override public void onDestroy() { super.onDestroy(); // Remove all pending runnables mHandler.removeMessages(ADVANCE_MSG); mHandler.removeMessages(0);// w w w . jav a 2s . com mWorkspace.removeCallbacks(mBuildLayersRunnable); // Stop callbacks from LauncherModel LauncherAppState app = (LauncherAppState.getInstance()); mModel.stopLoader(); app.setLauncher(null); try { mAppWidgetHost.stopListening(); } catch (NullPointerException ex) { Log.w(TAG, "problem while stopping AppWidgetHost during Launcher destruction", ex); } mAppWidgetHost = null; mWidgetsToAdvance.clear(); TextKeyListener.getInstance().release(); // Disconnect any of the callbacks and drawables associated with ItemInfos on the workspace // to prevent leaking Launcher activities on orientation change. if (mModel != null) { mModel.unbindItemInfosAndClearQueuedBindRunnables(); } getContentResolver().unregisterContentObserver(mWidgetObserver); unregisterReceiver(mCloseSystemDialogsReceiver); mDragLayer.clearAllResizeFrames(); ((ViewGroup) mWorkspace.getParent()).removeAllViews(); mWorkspace.removeAllViews(); mWorkspace = null; mDragController = null; LauncherAnimUtils.onDestroyActivity(); }
From source file:com.klinker.android.launcher.launcher3.Launcher.java
@Override public void onDestroy() { super.onDestroy(); // Remove all pending runnables mHandler.removeMessages(ADVANCE_MSG); mHandler.removeMessages(0);//from w w w . j a v a 2s . c o m mWorkspace.removeCallbacks(mBuildLayersRunnable); // Stop callbacks from LauncherModel LauncherAppState app = (LauncherAppState.getInstance()); // It's possible to receive onDestroy after a new Launcher activity has // been created. In this case, don't interfere with the new Launcher. if (mModel.isCurrentCallbacks(this)) { mModel.stopLoader(); app.setLauncher(null); } try { mAppWidgetHost.stopListening(); } catch (NullPointerException ex) { Log.w(TAG, "problem while stopping AppWidgetHost during Launcher destruction", ex); } mAppWidgetHost = null; mWidgetsToAdvance.clear(); TextKeyListener.getInstance().release(); unregisterReceiver(mCloseSystemDialogsReceiver); mDragLayer.clearAllResizeFrames(); ((ViewGroup) mWorkspace.getParent()).removeAllViews(); mWorkspace.removeAllWorkspaceScreens(); mWorkspace = null; mDragController = null; LauncherAnimUtils.onDestroyActivity(); if (mLauncherCallbacks != null) { mLauncherCallbacks.onDestroy(); } }
From source file:com.android.launcher3.Launcher.java
@Override public void onDestroy() { super.onDestroy(); // Remove all pending runnables mHandler.removeMessages(ADVANCE_MSG); mHandler.removeMessages(0);/*from ww w . jav a2 s . c o m*/ mWorkspace.removeCallbacks(mBuildLayersRunnable); mWorkspace.removeFolderListeners(); if (mHomeWatcher != null) { mHomeWatcher.stopWatch(); } // Stop callbacks from LauncherModel // It's possible to receive onDestroy after a new Launcher activity has // been created. In this case, don't interfere with the new Launcher. if (mModel.isCurrentCallbacks(this)) { mModel.stopLoader(); LauncherAppState.getInstance().setLauncher(null); } if (mRotationPrefChangeHandler != null) { mSharedPrefs.unregisterOnSharedPreferenceChangeListener(mRotationPrefChangeHandler); } try { mAppWidgetHost.stopListening(); } catch (NullPointerException ex) { Log.w(TAG, "problem while stopping AppWidgetHost during Launcher destruction", ex); } mAppWidgetHost = null; mWidgetsToAdvance.clear(); TextKeyListener.getInstance().release(); ((AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE)) .removeAccessibilityStateChangeListener(this); unregisterReceiver(mUiBroadcastReceiver); LauncherAnimUtils.onDestroyActivity(); if (mLauncherCallbacks != null) { mLauncherCallbacks.onDestroy(); } }
From source file:g7.bluesky.launcher3.Launcher.java
@Override public void onDestroy() { super.onDestroy(); // Remove all pending runnables mHandler.removeMessages(ADVANCE_MSG); mHandler.removeMessages(0);/*from w w w . j a v a 2s .c om*/ mWorkspace.removeCallbacks(mBuildLayersRunnable); // Stop callbacks from LauncherModel LauncherAppState app = (LauncherAppState.getInstance()); // It's possible to receive onDestroy after a new Launcher activity has // been created. In this case, don't interfere with the new Launcher. if (mModel.isCurrentCallbacks(this)) { mModel.stopLoader(); app.setLauncher(null); } try { mAppWidgetHost.stopListening(); } catch (NullPointerException ex) { Log.w(TAG, "problem while stopping AppWidgetHost during Launcher destruction", ex); } mAppWidgetHost = null; mWidgetsToAdvance.clear(); TextKeyListener.getInstance().release(); // Disconnect any of the callbacks and drawables associated with ItemInfos on the workspace // to prevent leaking Launcher activities on orientation change. if (mModel != null) { mModel.unbindItemInfosAndClearQueuedBindRunnables(); } getContentResolver().unregisterContentObserver(mWidgetObserver); unregisterReceiver(mCloseSystemDialogsReceiver); mDragLayer.clearAllResizeFrames(); ((ViewGroup) mWorkspace.getParent()).removeAllViews(); mWorkspace.removeAllWorkspaceScreens(); mWorkspace = null; mDragController = null; LauncherAnimUtils.onDestroyActivity(); if (mLauncherCallbacks != null) { mLauncherCallbacks.onDestroy(); } }
From source file:android.app.Activity.java
/** * Called when a key was pressed down and not handled by any of the views * inside of the activity. So, for example, key presses while the cursor * is inside a TextView will not trigger the event (unless it is a navigation * to another object) because TextView handles its own key presses. * //from w w w .j a va2s .c om * <p>If the focused view didn't want this event, this method is called. * * <p>The default implementation takes care of {@link KeyEvent#KEYCODE_BACK} * by calling {@link #onBackPressed()}, though the behavior varies based * on the application compatibility mode: for * {@link android.os.Build.VERSION_CODES#ECLAIR} or later applications, * it will set up the dispatch to call {@link #onKeyUp} where the action * will be performed; for earlier applications, it will perform the * action immediately in on-down, as those versions of the platform * behaved. * * <p>Other additional default key handling may be performed * if configured with {@link #setDefaultKeyMode}. * * @return Return <code>true</code> to prevent this event from being propagated * further, or <code>false</code> to indicate that you have not handled * this event and it should continue to be propagated. * @see #onKeyUp * @see android.view.KeyEvent */ public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if (getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.ECLAIR) { event.startTracking(); } else { onBackPressed(); } return true; } if (mDefaultKeyMode == DEFAULT_KEYS_DISABLE) { return false; } else if (mDefaultKeyMode == DEFAULT_KEYS_SHORTCUT) { if (getWindow().performPanelShortcut(Window.FEATURE_OPTIONS_PANEL, keyCode, event, Menu.FLAG_ALWAYS_PERFORM_CLOSE)) { return true; } return false; } else { // Common code for DEFAULT_KEYS_DIALER & DEFAULT_KEYS_SEARCH_* boolean clearSpannable = false; boolean handled; if ((event.getRepeatCount() != 0) || event.isSystem()) { clearSpannable = true; handled = false; } else { handled = TextKeyListener.getInstance().onKeyDown(null, mDefaultKeySsb, keyCode, event); if (handled && mDefaultKeySsb.length() > 0) { // something useable has been typed - dispatch it now. final String str = mDefaultKeySsb.toString(); clearSpannable = true; switch (mDefaultKeyMode) { case DEFAULT_KEYS_DIALER: Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + str)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); break; case DEFAULT_KEYS_SEARCH_LOCAL: startSearch(str, false, null, false); break; case DEFAULT_KEYS_SEARCH_GLOBAL: startSearch(str, false, null, true); break; } } } if (clearSpannable) { mDefaultKeySsb.clear(); mDefaultKeySsb.clearSpans(); Selection.setSelection(mDefaultKeySsb, 0); } return handled; } }