Java Code Examples for android.text.method.TextKeyListener

The following are top voted examples for showing how to use android.text.method.TextKeyListener. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: LaunchEnr   File: Launcher.java   Source Code and License 6 votes vote down vote up
@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();
        }
    }

    // Eat the long press event so the keyboard doesn't come up.
    if (keyCode == KeyEvent.KEYCODE_MENU && event.isLongPress()) {
        return true;
    }

    return handled;
}
 
Example 2
Project: LaunchEnr   File: AllAppsContainerView.java   Source Code and License 6 votes vote down vote up
@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();
            }
        }
    }

    return super.dispatchKeyEvent(event);
}
 
Example 3
Project: FlickLauncher   File: Launcher.java   Source Code and License 6 votes vote down vote up
@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();
        }
    }

    // Eat the long press event so the keyboard doesn't come up.
    if (keyCode == KeyEvent.KEYCODE_MENU && event.isLongPress()) {
        return true;
    }

    return handled;
}
 
Example 4
Project: FlickLauncher   File: AllAppsContainerView.java   Source Code and License 6 votes vote down vote up
@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();
            }
        }
    }

    return super.dispatchKeyEvent(event);
}
 
Example 5
Project: SimpleUILauncher   File: Launcher.java   Source Code and License 6 votes vote down vote up
@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();
        }
    }

    // Eat the long press event so the keyboard doesn't come up.
    if (keyCode == KeyEvent.KEYCODE_MENU && event.isLongPress()) {
        return true;
    }

    return handled;
}
 
Example 6
Project: SimpleUILauncher   File: AllAppsContainerView.java   Source Code and License 6 votes vote down vote up
@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();
            }
        }
    }

    return super.dispatchKeyEvent(event);
}
 
Example 7
Project: SimplOS   File: Launcher.java   Source Code and License 6 votes vote down vote up
@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();
        }
    }

    // Eat the long press event so the keyboard doesn't come up.
    if (keyCode == KeyEvent.KEYCODE_MENU && event.isLongPress()) {
        return true;
    }

    return handled;
}
 
Example 8
Project: SimplOS   File: AllAppsContainerView.java   Source Code and License 6 votes vote down vote up
@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();
            }
        }
    }

    return super.dispatchKeyEvent(event);
}
 
Example 9
Project: Trebuchet   File: Launcher.java   Source Code and License 6 votes vote down vote up
@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();
        }
    }

    // Eat the long press event so the keyboard doesn't come up.
    if (keyCode == KeyEvent.KEYCODE_MENU && event.isLongPress()) {
        return true;
    }

    return handled;
}
 
Example 10
Project: Trebuchet   File: AllAppsContainerView.java   Source Code and License 6 votes vote down vote up
@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 != null &&
            !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();
            }
        }
    }

    return super.dispatchKeyEvent(event);
}
 
Example 11
Project: EngineDriver   File: function_settings.java   Source Code and License 6 votes vote down vote up
void move_settings_to_view() {
    ViewGroup t = (ViewGroup) findViewById(R.id.label_func_table); //table
    //loop thru input rows, skipping first (headings)
    int ndx = 0;
    for (int i = 1; i < t.getChildCount(); i++) {
        ViewGroup r = (ViewGroup) t.getChildAt(i);
        //move to next non-blank array entry if it exists
        while (ndx < aFnc.size() && aLbl.get(ndx).length() == 0)
            ndx++;
        if (ndx < aFnc.size()) {
            ((EditText) r.getChildAt(0)).setText(aLbl.get(ndx));
            ((EditText) r.getChildAt(1)).setText(aFnc.get(ndx).toString());
            ndx++;
        } else {
            //          
            // work around for known EditText bug - see http://code.google.com/p/android/issues/detail?id=17508
            //          ((EditText)r.getChildAt(0)).setText("");
            //          ((EditText)r.getChildAt(1)).setText("");
            TextKeyListener.clear(((EditText) r.getChildAt(0)).getText());
            TextKeyListener.clear(((EditText) r.getChildAt(1)).getText());
        }
    }
}
 
Example 12
Project: TurboLauncher   File: Launcher.java   Source Code and License 6 votes vote down vote up
@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) {

			return onSearchRequested();
		}
	}

	if (keyCode == KeyEvent.KEYCODE_MENU && event.isLongPress()) {
		return true;
	}

	return handled;
}
 
Example 13
Project: FLauncher   File: Launcher.java   Source Code and License 6 votes vote down vote up
@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();
        }
    }

    // Eat the long press event so the keyboard doesn't come up.
    if (keyCode == KeyEvent.KEYCODE_MENU && event.isLongPress()) {
        return true;
    }

    return handled;
}
 
Example 14
Project: FLauncher   File: AllAppsContainerView.java   Source Code and License 6 votes vote down vote up
@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();
            }
        }
    }

    return super.dispatchKeyEvent(event);
}
 
Example 15
Project: LB-Launcher   File: Launcher.java   Source Code and License 6 votes vote down vote up
@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();
        }
    }

    // Eat the long press event so the keyboard doesn't come up.
    if (keyCode == KeyEvent.KEYCODE_MENU && event.isLongPress()) {
        return true;
    }

    return handled;
}
 
Example 16
Project: androidProject   File: Launcher.java   Source Code and License 6 votes vote down vote up
@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();
        }
    }

    // Eat the long press event so the keyboard doesn't come up.
    if (keyCode == KeyEvent.KEYCODE_MENU && event.isLongPress()) {
        return true;
    }

    return handled;
}
 
Example 17
Project: open-gel-plus   File: Launcher.java   Source Code and License 6 votes vote down vote up
@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();
        }
    }

    // Eat the long press event so the keyboard doesn't come up.
    if (keyCode == KeyEvent.KEYCODE_MENU && event.isLongPress()) {
        return true;
    }

    return handled;
}
 
Example 18
Project: BluetoothHidEmu   File: KeyboardKeyListener.java   Source Code and License 6 votes vote down vote up
@Override
public boolean onKeyDown(View view, Editable content, int keyCode, KeyEvent event) {
    switch (keyCode) {
    
    case KeyEvent.KEYCODE_ENTER:
        TextKeyListener.clear(content);
        mHidPayload.assemblePayload(HidKeyPair.ENTER);
        mSocketManager.sendPayload(mHidPayload);
        return true;
    case KeyEvent.KEYCODE_DEL:
    	mHidPayload.assemblePayload(HidKeyPair.DEL);
        mSocketManager.sendPayload(mHidPayload);
    case KeyEvent.KEYCODE_VOLUME_UP:
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        mHidPayload.assemblePayload(keyCode);
        mSocketManager.sendPayload(mHidPayload);
    default:
        return mTextKeyListener.onKeyDown(view, content, keyCode, event);
    }
}
 
Example 19
Project: LaunchEnr   File: Launcher.java   Source Code and License 5 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();

    mWorkspace.removeCallbacks(mBuildLayersRunnable);
    mWorkspace.removeFolderListeners();

    // 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(this).setLauncher(null);
    }

    if (mRotationPrefChangeHandler != null) {
        mSharedPrefs.unregisterOnSharedPreferenceChangeListener(mRotationPrefChangeHandler);
    }

    try {
        mAppWidgetHost.stopListening();
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    mAppWidgetHost = null;

    TextKeyListener.getInstance().release();

    ((AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE))
            .removeAccessibilityStateChangeListener(this);

    LauncherAnimUtils.onDestroyActivity();

    if (mLauncherCallbacks != null) {
        mLauncherCallbacks.onDestroy();
    }
}
 
Example 20
Project: JotaTextEditor   File: JotaTextKeyListener.java   Source Code and License 5 votes vote down vote up
public static TextKeyListener getInstance(boolean autotext, Capitalize cap) {
    int off = cap.ordinal() * 2 + (autotext ? 1 : 0);

    if (sInstance[off] == null) {
        sInstance[off] = new JotaTextKeyListener(cap, autotext);
    }

    return sInstance[off];
}
 
Example 21
Project: AbroadEasy   File: CustomSearchBar.java   Source Code and License 5 votes vote down vote up
public void cancelSearch() {
    hideInputPannel();
    post(new Runnable() {
        @Override
        public void run() {
            if (mListener != null) {
                mListener.cancelSearch();
            }
        }
    });
    TextKeyListener.clear(mSearchEdit.getText());
    mIsSearchMode = false;
}
 
Example 22
Project: androidProject   File: Launcher.java   Source Code and License 5 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();

    // Remove all pending runnables
    mHandler.removeMessages(ADVANCE_MSG);
    mHandler.removeMessages(0);
    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();


    unbindWorkspaceAndHotseatItems();

    getContentResolver().unregisterContentObserver(mWidgetObserver);
    unregisterReceiver(mCloseSystemDialogsReceiver);

    ((ViewGroup) mWorkspace.getParent()).removeAllViews();
    mWorkspace.removeAllViews();
    mWorkspace = null;
    mDragController = null;

    ValueAnimator.clearAllAnimations();
}
 
Example 23
Project: fruit.launcher   File: Launcher.java   Source Code and License 5 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {		        
	if (isWorkspaceLocked())
		return true;

	boolean handled = super.onKeyDown(keyCode, event);
	if (!handled && acceptFilter() && keyCode != KeyEvent.KEYCODE_ENTER) {
		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();
		}
	}

	// Eat the long press event so the keyboard doesn't come up.
	if (keyCode == KeyEvent.KEYCODE_MENU && event.isLongPress()) {
		return true;
	}

	if (keyCode == KeyEvent.KEYCODE_BACK && mThumbnailWorkspace.isVisible()) {
		int currPageIndex = ((CellLayout) mWorkspace.getChildAt(mWorkspace.getCurrentScreen())).getPageIndex();
           mThumbnailWorkspace.setmCurSelectedScreenIndex(currPageIndex);
		closeThumbnailWorkspace(true);
		return true;
	}
	return handled;
}
 
Example 24
Project: fruit.launcher   File: Launcher.java   Source Code and License 5 votes vote down vote up
@Override
	public void onDestroy() {
		super.onDestroy();

		Log.d(TAG,"launcherseq,onDestroy");
		
		try {
			mAppWidgetHost.stopListening();
		} catch (NullPointerException ex) {
			Log.w(TAG,
					"problem while stopping AppWidgetHost during Launcher destruction",
					ex);
		}

		TextKeyListener.getInstance().release();

		mThemeMgr.stopListener();
		mModel.stopLoader();

		mPhoneMonitor.removeAllCallback();
		mMssMonitor.removeAllCallback();

		unbindDesktopItems();

		getSharedPreferences(SettingUtils.LAUNCHER_SETTINGS_NAME, 0)
				.unregisterOnSharedPreferenceChangeListener(mSPChangeListener);

		getContentResolver().unregisterContentObserver(mWidgetObserver);

		unregisterReceiver(mCloseSystemDialogsReceiver);
		unregisterReceiver(mScreenConfigReceiver);
//		unregisterReceiver(mSCReceiver);
	}
 
Example 25
Project: sagesmobile-mCollect   File: StringWidget.java   Source Code and License 5 votes vote down vote up
protected StringWidget(Context context, FormEntryPrompt prompt, boolean derived) {
    super(context, prompt);
    mAnswer = new EditText(context);
    mAnswer.setId(QuestionWidget.newUniqueId());
    mReadOnly = prompt.isReadOnly();

    mAnswer.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);

    TableLayout.LayoutParams params = new TableLayout.LayoutParams();
    params.setMargins(7, 5, 7, 5);
    mAnswer.setLayoutParams(params);
    
    // capitalize the first letter of the sentence
    mAnswer.setKeyListener(new TextKeyListener(Capitalize.SENTENCES, false));

    // needed to make long read only text scroll
    mAnswer.setHorizontallyScrolling(false);
    mAnswer.setSingleLine(false);

    String s = prompt.getAnswerText();
    if (s != null) {
        mAnswer.setText(s);
    }

    if (mReadOnly) {
        mAnswer.setBackgroundDrawable(null);
        mAnswer.setFocusable(false);
        mAnswer.setClickable(false);
    }
    
    addView(mAnswer);
}
 
Example 26
Project: Fairphone   File: Launcher.java   Source Code and License 5 votes vote down vote up
@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();
		}
	}

	// Eat the long press event so the keyboard doesn't come up.
	if (keyCode == KeyEvent.KEYCODE_MENU && event.isLongPress()) {
		return true;
	}

	return handled;
}
 
Example 27
Project: Fairphone---DEPRECATED   File: Launcher.java   Source Code and License 5 votes vote down vote up
@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();
		}
	}

	// Eat the long press event so the keyboard doesn't come up.
	if (keyCode == KeyEvent.KEYCODE_MENU && event.isLongPress()) {
		return true;
	}

	return handled;
}
 
Example 28
Project: Onosendai   File: PostActivity.java   Source Code and License 5 votes vote down vote up
public void setupAutoComplete () {
	if (this.txtBody.getAdapter() != null) return;
	this.txtBody.setThreshold(1);
	this.txtBody.setTokenizer(new UsernameTokenizer());
	this.txtBody.setAdapter(new UsernameSearchAdapter(this));
	this.txtBody.addTextChangedListener(new PopupPositioniner(this.txtBody));
	this.txtBody.setKeyListener(TextKeyListener.getInstance(true, TextKeyListener.Capitalize.SENTENCES));
}
 
Example 29
Project: MyFlightbookAndroid   File: PropertyEdit.java   Source Code and License 4 votes vote down vote up
private void UpdateForProperty() {
    UpdateLabelTypefaceForProperty();
    CustomPropertyType.CFPPropertyType cptType = m_fp.getType();
    Boolean fIsBasicDecimal = cptType == CustomPropertyType.CFPPropertyType.cfpDecimal && (m_fp.CustomPropertyType().cptFlag & 0x00200000) != 0;

    m_tvLabel.setVisibility(VISIBLE);
    m_txtStringVal.setVisibility(GONE);
    m_txtNumericField.setVisibility(GONE);
    m_ck.setVisibility(GONE);
    m_tvDate.setVisibility(GONE);

    switch (cptType) {
        default:
            break;
        case cfpInteger:
            m_txtNumericField.setVisibility(VISIBLE);
            m_txtNumericField.setMode(DecimalEdit.EditMode.INTEGER);
            m_txtNumericField.setIntValue(m_fp.intValue);
            break;
        case cfpDecimal:
            m_txtNumericField.setVisibility(VISIBLE);
            m_txtNumericField.setMode(DecimalEdit.DefaultHHMM && !fIsBasicDecimal ? DecimalEdit.EditMode.HHMM : DecimalEdit.EditMode.DECIMAL);
            m_txtNumericField.setDoubleValue(m_fp.decValue);
            if (m_cfd != null)
                m_txtNumericField.setDelegate(m_cfd);
            break;
        case cfpCurrency:
            m_txtNumericField.setVisibility(VISIBLE);
            m_txtNumericField.setMode(DecimalEdit.EditMode.DECIMAL);
            m_txtNumericField.setDoubleValue(m_fp.decValue);
            break;
        case cfpString: {
            m_txtStringVal.setVisibility(VISIBLE);
            m_txtStringVal.setHint("");
            m_txtStringVal.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
                    | InputType.TYPE_CLASS_TEXT);
            m_txtStringVal.setKeyListener(TextKeyListener.getInstance());
            m_txtStringVal.setText(m_fp.toString());
            String[] rgPrevVals = m_fp.CustomPropertyType().PreviousValues;
            if (rgPrevVals != null && rgPrevVals.length > 0) {
                ArrayAdapter<String> adapter = new ArrayAdapter<>(
                        this.getContext(), android.R.layout.simple_list_item_1,
                        rgPrevVals);
                m_txtStringVal.setAdapter(adapter);
            }
            m_txtStringVal.setThreshold(1);
        }
            break;
        case cfpBoolean:
            m_ck.setVisibility(VISIBLE);
            m_tvLabel.setVisibility(GONE);
            break;
        case cfpDate:
            m_tvDate.setVisibility(VISIBLE);
            SetPropDate(m_fp.dateValue, false);
            break;
        case cfpDateTime:
            m_tvDate.setVisibility(VISIBLE);
            SetPropDate(m_fp.dateValue, true);
            break;
    }

    findViewById(R.id.imgFavorite).setVisibility(m_fIsPinned ? View.VISIBLE : View.INVISIBLE);
}
 
Example 30
Project: FlickLauncher   File: Launcher.java   Source Code and License 4 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();

    // Remove all pending runnables
    mHandler.removeMessages(ADVANCE_MSG);
    mHandler.removeMessages(0);
    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();
    }
}
 
Example 31
Project: SimpleUILauncher   File: Launcher.java   Source Code and License 4 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();

    // Remove all pending runnables
    mHandler.removeMessages(ADVANCE_MSG);
    mHandler.removeMessages(0);
    mWorkspace.removeCallbacks(mBuildLayersRunnable);
    mWorkspace.removeFolderListeners();

    // 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();
    }
}
 
Example 32
Project: SimplOS   File: Launcher.java   Source Code and License 4 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();

    // Remove all pending runnables
    mHandler.removeMessages(ADVANCE_MSG);
    mHandler.removeMessages(0);
    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();
    }
}
 
Example 33
Project: Trebuchet   File: Launcher.java   Source Code and License 4 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();

    // Remove all pending runnables
    mHandler.removeMessages(ADVANCE_MSG);
    mHandler.removeMessages(0);
    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);
    unregisterReceiver(mConnectionReceiver);
    unregisterReceiver(mDeviceUnlockedReceiver);

    mDragLayer.clearAllResizeFrames();
    ((ViewGroup) mWorkspace.getParent()).removeAllViews();
    mWorkspace.removeAllWorkspaceScreens();
    mWorkspace = null;
    mDragController = null;

    LauncherAnimUtils.onDestroyActivity();

    if (mLauncherCallbacks != null) {
        mLauncherCallbacks.onDestroy();
    }

    unregisterReceiver(protectedAppsChangedReceiver);
    unregisterReceiver(searchBarVisibilityChangedReceiver);
}
 
Example 34
Project: Tada   File: TextView.java   Source Code and License 4 votes vote down vote up
private void setInputType(int type, boolean direct) {
    final int cls = type & EditorInfo.TYPE_MASK_CLASS;
    KeyListener input;
    if (cls == EditorInfo.TYPE_CLASS_TEXT) {
        boolean autotext = (type & EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT) != 0;
        TextKeyListener.Capitalize cap;
        if ((type & EditorInfo.TYPE_TEXT_FLAG_CAP_CHARACTERS) != 0) {
            cap = TextKeyListener.Capitalize.CHARACTERS;
        } else if ((type & EditorInfo.TYPE_TEXT_FLAG_CAP_WORDS) != 0) {
            cap = TextKeyListener.Capitalize.WORDS;
        } else if ((type & EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES) != 0) {
            cap = TextKeyListener.Capitalize.SENTENCES;
        } else {
            cap = TextKeyListener.Capitalize.NONE;
        }
        input = TextKeyListener.getInstance(autotext, cap);
    } else if (cls == EditorInfo.TYPE_CLASS_NUMBER) {
        input = DigitsKeyListener.getInstance(
                (type & EditorInfo.TYPE_NUMBER_FLAG_SIGNED) != 0,
                (type & EditorInfo.TYPE_NUMBER_FLAG_DECIMAL) != 0);
    } else if (cls == EditorInfo.TYPE_CLASS_DATETIME) {
        switch (type & EditorInfo.TYPE_MASK_VARIATION) {
            case EditorInfo.TYPE_DATETIME_VARIATION_DATE:
                input = DateKeyListener.getInstance();
                break;
            case EditorInfo.TYPE_DATETIME_VARIATION_TIME:
                input = TimeKeyListener.getInstance();
                break;
            default:
                input = DateTimeKeyListener.getInstance();
                break;
        }
    } else if (cls == EditorInfo.TYPE_CLASS_PHONE) {
        input = DialerKeyListener.getInstance();
    } else {
        input = TextKeyListener.getInstance();
    }
    setRawInputType(type);
    if (direct) {
        createEditorIfNeeded();
        mEditor.mKeyListener = input;
    } else {
        setKeyListenerOnly(input);
    }
}
 
Example 35
Project: ODK-Liberia   File: StringWidget.java   Source Code and License 4 votes vote down vote up
protected StringWidget(Context context, FormEntryPrompt prompt, boolean readOnlyOverride, boolean derived) {
    super(context, prompt);
    mAnswer = new EditText(context);
    mAnswer.setId(QuestionWidget.newUniqueId());
    mReadOnly = prompt.isReadOnly() || readOnlyOverride;

    mAnswer.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);

    TableLayout.LayoutParams params = new TableLayout.LayoutParams();

    /**
     * If a 'rows' attribute is on the input tag, set the minimum number of lines
     * to display in the field to that value.
     *
     * I.e.,
     * <input ref="foo" rows="5">
     *   ...
     * </input>
     *
     * will set the height of the EditText box to 5 rows high.
     */
    String height = prompt.getQuestion().getAdditionalAttribute(null, ROWS);
    if ( height != null && height.length() != 0 ) {
    	try {
     	int rows = Integer.valueOf(height);
     	mAnswer.setMinLines(rows);
     	mAnswer.setGravity(Gravity.TOP); // to write test starting at the top of the edit area
    	} catch (Exception e) {
    		Log.e(this.getClass().getName(), "Unable to process the rows setting for the answer field: " + e.toString());
    	}
    }

    params.setMargins(7, 5, 7, 5);
    mAnswer.setLayoutParams(params);

    // capitalize the first letter of the sentence
    mAnswer.setKeyListener(new TextKeyListener(Capitalize.SENTENCES, false));

    // needed to make long read only text scroll
    mAnswer.setHorizontallyScrolling(false);
    mAnswer.setSingleLine(false);

    String s = prompt.getAnswerText();
    if (s != null) {
        mAnswer.setText(s);
    }

    if (mReadOnly) {
        mAnswer.setBackgroundDrawable(null);
        mAnswer.setFocusable(false);
        mAnswer.setClickable(false);
    }

    addView(mAnswer);
}
 
Example 36
Project: TurboLauncher   File: Launcher.java   Source Code and License 4 votes vote down vote up
@Override
public void onDestroy() {
	super.onDestroy();

	// Remove all pending runnables
	mHandler.removeMessages(ADVANCE_MSG);
	mHandler.removeMessages(0);
	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.removeAllWorkspaceScreens();
	mWorkspace = null;
	mDragController = null;

	LauncherAnimUtils.onDestroyActivity();

	unregisterReceiver(protectedAppsChangedReceiver);
}
 
Example 37
Project: FLauncher   File: Launcher.java   Source Code and License 4 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();

    // Remove all pending runnables
    mHandler.removeMessages(ADVANCE_MSG);
    mHandler.removeMessages(0);
    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();
    }
}
 
Example 38
Project: mc_backup   File: GeckoInputConnection.java   Source Code and License 4 votes vote down vote up
private boolean processKey(int keyCode, KeyEvent event, boolean down) {
    if (GamepadUtils.isSonyXperiaGamepadKeyEvent(event)) {
        event = GamepadUtils.translateSonyXperiaGamepadKeys(keyCode, event);
        keyCode = event.getKeyCode();
    }

    if (keyCode > KeyEvent.getMaxKeyCode() ||
        !shouldProcessKey(keyCode, event)) {
        return false;
    }
    final int action = down ? KeyEvent.ACTION_DOWN : KeyEvent.ACTION_UP;
    event = translateKey(keyCode, event);
    keyCode = event.getKeyCode();

    View view = getView();
    if (view == null) {
        InputThreadUtils.sInstance.sendEventFromUiThread(ThreadUtils.getUiHandler(),
            mEditableClient, GeckoEvent.createKeyEvent(event, action, 0));
        return true;
    }

    // KeyListener returns true if it handled the event for us. KeyListener is only
    // safe to use on the UI thread; therefore we need to pass a proxy Editable to it
    KeyListener keyListener = TextKeyListener.getInstance();
    Handler uiHandler = view.getRootView().getHandler();
    Editable uiEditable = InputThreadUtils.sInstance.
        getEditableForUiThread(uiHandler, mEditableClient);
    boolean skip = shouldSkipKeyListener(keyCode, event);
    if (down) {
        mEditableClient.setSuppressKeyUp(true);
    }
    if (skip ||
        (down && !keyListener.onKeyDown(view, uiEditable, keyCode, event)) ||
        (!down && !keyListener.onKeyUp(view, uiEditable, keyCode, event))) {
        InputThreadUtils.sInstance.sendEventFromUiThread(uiHandler, mEditableClient,
            GeckoEvent.createKeyEvent(event, action, TextKeyListener.getMetaState(uiEditable)));
        if (skip && down) {
            // Usually, the down key listener call above adjusts meta states for us.
            // However, if we skip that call above, we have to manually adjust meta
            // states so the meta states remain consistent
            TextKeyListener.adjustMetaAfterKeypress(uiEditable);
        }
    }
    if (down) {
        mEditableClient.setSuppressKeyUp(false);
    }
    return true;
}
 
Example 39
Project: JotaTextEditor   File: TextView.java   Source Code and License 4 votes vote down vote up
private void setInputType(int type, boolean direct) {
    final int cls = type & EditorInfo.TYPE_MASK_CLASS;
    KeyListener input;
    if (cls == EditorInfo.TYPE_CLASS_TEXT) {
        boolean autotext = (type & EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT) != 0;
        TextKeyListener.Capitalize cap;
        if ((type & EditorInfo.TYPE_TEXT_FLAG_CAP_CHARACTERS) != 0) {
            cap = TextKeyListener.Capitalize.CHARACTERS;
        } else if ((type & EditorInfo.TYPE_TEXT_FLAG_CAP_WORDS) != 0) {
            cap = TextKeyListener.Capitalize.WORDS;
        } else if ((type & EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES) != 0) {
            cap = TextKeyListener.Capitalize.SENTENCES;
        } else {
            cap = TextKeyListener.Capitalize.NONE;
        }
        input = JotaTextKeyListener.getInstance(autotext, cap);
    } else if (cls == EditorInfo.TYPE_CLASS_NUMBER) {
        input = DigitsKeyListener.getInstance(
                (type & EditorInfo.TYPE_NUMBER_FLAG_SIGNED) != 0,
                (type & EditorInfo.TYPE_NUMBER_FLAG_DECIMAL) != 0);
    } else if (cls == EditorInfo.TYPE_CLASS_DATETIME) {
        switch (type & EditorInfo.TYPE_MASK_VARIATION) {
            case EditorInfo.TYPE_DATETIME_VARIATION_DATE:
                input = DateKeyListener.getInstance();
                break;
            case EditorInfo.TYPE_DATETIME_VARIATION_TIME:
                input = TimeKeyListener.getInstance();
                break;
            default:
                input = DateTimeKeyListener.getInstance();
                break;
        }
    } else if (cls == EditorInfo.TYPE_CLASS_PHONE) {
        input = DialerKeyListener.getInstance();
    } else {
        input = JotaTextKeyListener.getInstance();
    }
    setRawInputType(type);
    if (direct) mInput = input;
    else {
        setKeyListenerOnly(input);
    }
}
 
Example 40
Project: JotaTextEditor   File: Layout.java   Source Code and License 4 votes vote down vote up
/**
 * Fills in the specified Path with a representation of a cursor
 * at the specified offset.  This will often be a vertical line
 * but can be multiple discontinous lines in text with multiple
 * directionalities.
 */
public void getCursorPath(int point, Path dest,
                          CharSequence editingBuffer) {
    dest.reset();

    int line = getLineForOffset(point);
    int top = getLineTop(line);
    int bottom = getLineTop(line+1);

    float h1 = getPrimaryHorizontal(point) - 0.5f;
    float h2 = getSecondaryHorizontal(point) - 0.5f;

    int caps = TextKeyListener.getMetaState(editingBuffer,
                                            KeyEvent.META_SHIFT_ON) |
               JotaTextKeyListener.getMetaStateSelecting(editingBuffer);
    int fn = TextKeyListener.getMetaState(editingBuffer,
                                          KeyEvent.META_ALT_ON);
    int dist = 0;

    if (caps != 0 || fn != 0) {
        dist = (bottom - top) >> 2;

        if (fn != 0)
            top += dist;
        if (caps != 0)
            bottom -= dist;
    }

    if (h1 < 0.5f)
        h1 = 0.5f;
    if (h2 < 0.5f)
        h2 = 0.5f;

    if (h1 == h2) {
        dest.moveTo(h1, top);
        dest.lineTo(h1, bottom);
    } else {
        dest.moveTo(h1, top);
        dest.lineTo(h1, (top + bottom) >> 1);

        dest.moveTo(h2, (top + bottom) >> 1);
        dest.lineTo(h2, bottom);
    }

    if (caps == 2) {
        dest.moveTo(h2, bottom);
        dest.lineTo(h2 - dist, bottom + dist);
        dest.lineTo(h2, bottom);
        dest.lineTo(h2 + dist, bottom + dist);
    } else if (caps == 1) {
        dest.moveTo(h2, bottom);
        dest.lineTo(h2 - dist, bottom + dist);

        dest.moveTo(h2 - dist, bottom + dist - 0.5f);
        dest.lineTo(h2 + dist, bottom + dist - 0.5f);

        dest.moveTo(h2 + dist, bottom + dist);
        dest.lineTo(h2, bottom);
    }

    if (fn == 2) {
        dest.moveTo(h1, top);
        dest.lineTo(h1 - dist, top - dist);
        dest.lineTo(h1, top);
        dest.lineTo(h1 + dist, top - dist);
    } else if (fn == 1) {
        dest.moveTo(h1, top);
        dest.lineTo(h1 - dist, top - dist);

        dest.moveTo(h1 - dist, top - dist + 0.5f);
        dest.lineTo(h1 + dist, top - dist + 0.5f);

        dest.moveTo(h1 + dist, top - dist);
        dest.lineTo(h1, top);
    }
}
 
Example 41
Project: AbroadEasy   File: CustomSearchBar.java   Source Code and License 4 votes vote down vote up
public void clearState(){
    TextKeyListener.clear(mSearchEdit.getText());
}
 
Example 42
Project: LB-Launcher   File: Launcher.java   Source Code and License 4 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();

    // Remove all pending runnables
    mHandler.removeMessages(ADVANCE_MSG);
    mHandler.removeMessages(0);
    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();
    }
}
 
Example 43
Project: LeanLauncher   File: Launcher.java   Source Code and License 4 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();

    // Remove all pending runnables
    mHandler.removeMessages(ADVANCE_MSG);
    mHandler.removeMessages(0);
    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();

}
 
Example 44
Project: commcare-android   File: StringWidget.java   Source Code and License 4 votes vote down vote up
public StringWidget(Context context, FormEntryPrompt prompt, boolean secret, boolean inCompactGroup) {
    super(context, prompt, inCompactGroup);
    mAnswer = (EditText)LayoutInflater.from(getContext()).inflate(getAnswerLayout(), this, false);
    mAnswer.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontSize);
    mAnswer.setOnClickListener(this);

    mAnswer.addTextChangedListener(this);

    //Let's see if we can figure out a constraint for this string
    try {
        addAnswerFilter(new InputFilter.LengthFilter(guessMaxStringLength(prompt)));
    } catch (UnpivotableExpressionException e) {
        //expected if there isn't a constraint that does this
    }

    this.secret = secret;

    if (!secret) {
        // capitalize the first letter of the sentence
        mAnswer.setKeyListener(new TextKeyListener(Capitalize.SENTENCES, false));
    }
    setTextInputType(mAnswer);

    if (!secret) {
        mAnswer.setSingleLine(false);
    }

    if (prompt != null) {
        mReadOnly = prompt.isReadOnly();
        IAnswerData value = prompt.getAnswerValue();
        if (value != null) {
            mAnswer.setText(value.getDisplayText());
        }

        if (mReadOnly) {
            if (value == null) {
                mAnswer.setText("---");
            }
            mAnswer.setBackgroundDrawable(null);
            mAnswer.setFocusable(false);
            mAnswer.setClickable(false);
        }
    }

    if (isInCompactMode()) {
        addToCompactLayout(mAnswer);
    } else {
        addView(mAnswer);
    }
}
 
Example 45
Project: sms_DualCard   File: ComposeMessageActivity.java   Source Code and License 4 votes vote down vote up
private void resetMessage() {
	if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
		log("");
	}

	// Make the attachment editor hide its view.
	mAttachmentEditor.hideView();
	mAttachmentEditorScrollView.setVisibility(View.GONE);

	// Hide the subject editor.
	showSubjectEditor(false);

	// Focus to the text editor.
	mTextEditor.requestFocus();

	// We have to remove the text change listener while the text editor gets
	// cleared and
	// we subsequently turn the message back into SMS. When the listener is
	// listening while
	// doing the clearing, it's fighting to update its counts and itself try
	// and turn
	// the message one way or the other.
	mTextEditor.removeTextChangedListener(mTextEditorWatcher);

	// Clear the text box.
	TextKeyListener.clear(mTextEditor.getText());

	mWorkingMessage.clearConversation(mConversation, false);
	mWorkingMessage = WorkingMessage.createEmpty(this);
	mWorkingMessage.setConversation(mConversation);

	hideRecipientEditor();
	drawBottomPanel();

	// "Or not", in this case.
	updateSendButtonState();

	// Our changes are done. Let the listener respond to text changes once
	// again.
	mTextEditor.addTextChangedListener(mTextEditorWatcher);
	// zaizhe
	mIsMmsMessage = false;
	// Close the soft on-screen keyboard if we're in landscape mode so the
	// user can see the
	// conversation.
	if (mIsLandscape) {
		hideKeyboard();
	}

	mLastRecipientCount = 0;
	mSendingMessage = false;
	invalidateOptionsMenu();
}
 
Example 46
Project: open-gel-plus   File: Launcher.java   Source Code and License 4 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();

    // Remove all pending runnables
    mHandler.removeMessages(ADVANCE_MSG);
    mHandler.removeMessages(0);
    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();
}
 
Example 47
Project: Fairphone   File: Launcher.java   Source Code and License 4 votes vote down vote up
@Override
public void onDestroy() {
	super.onDestroy();

	// Remove all pending runnables
	mHandler.removeMessages(ADVANCE_MSG);
	mHandler.removeMessages(0);
	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();
}
 
Example 48
Project: Fairphone---DEPRECATED   File: Launcher.java   Source Code and License 4 votes vote down vote up
@Override
public void onDestroy() {
	super.onDestroy();

	// Remove all pending runnables
	mHandler.removeMessages(ADVANCE_MSG);
	mHandler.removeMessages(0);
	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();
}
 
Example 49
Project: android-aosp-mms   File: ComposeMessageActivity.java   Source Code and License 4 votes vote down vote up
private void resetMessage() {
     if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
         log("resetMessage");
     }

     // Make the attachment editor hide its view.
     mAttachmentEditor.hideView();
     mAttachmentEditorScrollView.setVisibility(View.GONE);

     // Hide the subject editor.
     showSubjectEditor(false);

     // Focus to the text editor.
     mTextEditor.requestFocus();

     // We have to remove the text change listener while the text editor gets cleared and
     // we subsequently turn the message back into SMS. When the listener is listening while
     // doing the clearing, it's fighting to update its counts and itself try and turn
     // the message one way or the other.
     mTextEditor.removeTextChangedListener(mTextEditorWatcher);

     // Clear the text box.
     TextKeyListener.clear(mTextEditor.getText());

     mWorkingMessage.clearConversation(mConversation, false);
     mWorkingMessage = WorkingMessage.createEmpty(this);
     mWorkingMessage.setConversation(mConversation);

     hideRecipientEditor();
     drawBottomPanel();

     // "Or not", in this case.
     updateSendButtonState();

     // Our changes are done. Let the listener respond to text changes once again.
     mTextEditor.addTextChangedListener(mTextEditorWatcher);

     // Close the soft on-screen keyboard if we're in landscape mode so the user can see the
     // conversation.
     if (mIsLandscape) {
         hideKeyboard();
     }

     mLastRecipientCount = 0;
     mSendingMessage = false;
     invalidateOptionsMenu();
}
 
Example 50
Project: BluetoothHidEmu   File: KeyboardKeyListener.java   Source Code and License 3 votes vote down vote up
public KeyboardKeyListener(SocketManager socketManager) {
    super();
    
    mTextKeyListener = new TextKeyListener(Capitalize.NONE, false);
    mSocketManager = socketManager;
    
}