Example usage for android.text InputType TYPE_TEXT_FLAG_NO_SUGGESTIONS

List of usage examples for android.text InputType TYPE_TEXT_FLAG_NO_SUGGESTIONS

Introduction

In this page you can find the example usage for android.text InputType TYPE_TEXT_FLAG_NO_SUGGESTIONS.

Prototype

int TYPE_TEXT_FLAG_NO_SUGGESTIONS

To view the source code for android.text InputType TYPE_TEXT_FLAG_NO_SUGGESTIONS.

Click Source Link

Document

Flag for #TYPE_CLASS_TEXT : the input method does not need to display any dictionary-based candidates.

Usage

From source file:com.phonemetra.turbo.launcher.Folder.java

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    mScrollView = (ScrollView) findViewById(R.id.scroll_view);
    mContent = (CellLayout) findViewById(R.id.folder_content);
    int measureSpec = MeasureSpec.UNSPECIFIED;

    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();

    mContent.setCellDimensions(grid.folderCellWidthPx, grid.folderCellHeightPx);
    mContent.setGridSize(0, 0);/*from   ww  w . ja  v a 2  s.c o m*/
    mContent.getShortcutsAndWidgets().setMotionEventSplittingEnabled(false);
    mContent.setInvertIfRtl(true);
    mFolderName = (FolderEditText) findViewById(R.id.folder_name);
    mFolderName.setFolder(this);
    mFolderName.setOnFocusChangeListener(this);

    // We find out how tall the text view wants to be (it is set to wrap_content), so that
    // we can allocate the appropriate amount of space for it.
    mFolderName.measure(measureSpec, measureSpec);
    mFolderNameHeight = mFolderName.getMeasuredHeight();

    // We disable action mode for now since it messes up the view on phones
    mFolderName.setCustomSelectionActionModeCallback(mActionModeCallback);
    mFolderName.setOnEditorActionListener(this);
    mFolderName.setSelectAllOnFocus(true);
    mFolderName.setInputType(mFolderName.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
            | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
    mAutoScrollHelper = new FolderAutoScrollHelper(mScrollView);

    if (SettingsProvider.getBoolean(mLauncher, SettingsProvider.SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS,
            R.bool.preferences_interface_homescreen_hide_icon_labels_default)) {
        mFolderName.setVisibility(View.GONE);
        mFolderNameHeight = getPaddingBottom();
    }

    mFolderLock = (ImageView) findViewById(R.id.folder_lock);
    mFolderTitleSection = (RelativeLayout) findViewById(R.id.folder_title_section);
    mFolderLock.measure(measureSpec, measureSpec);
    mFolderLock.setOnClickListener(this);
    mFolderTitleSection.measure(measureSpec, measureSpec);
}

From source file:com.aidy.launcher3.ui.folder.Folder.java

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    mScrollView = (ScrollView) findViewById(R.id.scroll_view);
    mContent = (CellLayout) findViewById(R.id.folder_content);

    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();

    mContent.setCellDimensions(grid.folderCellWidthPx, grid.folderCellHeightPx);
    mContent.setGridSize(0, 0);//from  www  .  j  av a2 s.  com
    mContent.getShortcutsAndWidgets().setMotionEventSplittingEnabled(false);
    mContent.setInvertIfRtl(true);
    mFolderName = (FolderEditText) findViewById(R.id.folder_name);
    mFolderName.setFolder(this);
    mFolderName.setOnFocusChangeListener(this);

    // We find out how tall the text view wants to be (it is set to
    // wrap_content), so that
    // we can allocate the appropriate amount of space for it.
    int measureSpec = MeasureSpec.UNSPECIFIED;
    mFolderName.measure(measureSpec, measureSpec);
    mFolderNameHeight = mFolderName.getMeasuredHeight();

    // We disable action mode for now since it messes up the view on phones
    mFolderName.setCustomSelectionActionModeCallback(mActionModeCallback);
    mFolderName.setOnEditorActionListener(this);
    mFolderName.setSelectAllOnFocus(true);
    mFolderName.setInputType(mFolderName.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
            | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
    mAutoScrollHelper = new FolderAutoScrollHelper(mScrollView);
}

From source file:de.qspool.clementineremote.ui.ConnectActivity.java

private void initializeUi() {
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));

    // Get the Layoutelements
    mBtnConnect = (Button) findViewById(R.id.btnConnect);
    mBtnConnect.setOnClickListener(oclConnect);
    mBtnConnect.requestFocus();// w w  w.  ja  v  a2 s  . co  m

    mBtnClementine = (ImageButton) findViewById(R.id.btnClementineIcon);
    mBtnClementine.setOnClickListener(oclClementine);

    // Setup the animation for the Clementine icon
    mAlphaDown = new AlphaAnimation(1.0f, 0.3f);
    mAlphaUp = new AlphaAnimation(0.3f, 1.0f);
    mAlphaDown.setDuration(ANIMATION_DURATION);
    mAlphaUp.setDuration(ANIMATION_DURATION);
    mAlphaDown.setFillAfter(true);
    mAlphaUp.setFillAfter(true);
    mAlphaUp.setAnimationListener(mAnimationListener);
    mAlphaDown.setAnimationListener(mAnimationListener);
    mAnimationCancel = false;

    // Ip and Autoconnect
    mEtIp = (AutoCompleteTextView) findViewById(R.id.etIp);
    mEtIp.setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    mEtIp.setThreshold(3);

    // Get old ip and auto-connect from shared prefences
    mEtIp.setText(mSharedPref.getString(SharedPreferencesKeys.SP_KEY_IP, ""));
    mEtIp.setSelection(mEtIp.length());

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.select_dialog_item,
            mKnownIps.toArray(new String[0]));
    mEtIp.setAdapter(adapter);

    // Get the last auth code
    mAuthCode = mSharedPref.getInt(SharedPreferencesKeys.SP_LAST_AUTH_CODE, 0);
}

From source file:org.cocos2dx.lib.Cocos2dxEditBoxDialog.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    getWindow().setBackgroundDrawable(new ColorDrawable(0x80000000));

    LinearLayout layout = new LinearLayout(mParentActivity);
    layout.setOrientation(LinearLayout.VERTICAL);

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT);

    mTextViewTitle = new TextView(mParentActivity);
    LinearLayout.LayoutParams textviewParams = new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    textviewParams.leftMargin = textviewParams.rightMargin = convertDipsToPixels(10);
    mTextViewTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    layout.addView(mTextViewTitle, textviewParams);

    mInputEditText = new EditText(mParentActivity);
    LinearLayout.LayoutParams editTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    editTextParams.leftMargin = editTextParams.rightMargin = convertDipsToPixels(10);

    layout.addView(mInputEditText, editTextParams);

    setContentView(layout, layoutParams);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

    mInputMode = mMsg.inputMode;//from www  .  j a va2  s  .  co  m
    mInputFlag = mMsg.inputFlag;
    mReturnType = mMsg.returnType;
    mMaxLength = mMsg.maxLength;

    mTextViewTitle.setText(mMsg.title);
    mInputEditText.setText(mMsg.content);

    int oldImeOptions = mInputEditText.getImeOptions();
    mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    oldImeOptions = mInputEditText.getImeOptions();

    switch (mInputMode) {
    case kEditBoxInputModeAny:
        mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE;
        break;
    case kEditBoxInputModeEmailAddr:
        mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
        break;
    case kEditBoxInputModeNumeric:
        mInputModeContraints = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED;
        break;
    case kEditBoxInputModePhoneNumber:
        mInputModeContraints = InputType.TYPE_CLASS_PHONE;
        break;
    case kEditBoxInputModeUrl:
        mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
        break;
    case kEditBoxInputModeDecimal:
        mInputModeContraints = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL
                | InputType.TYPE_NUMBER_FLAG_SIGNED;
        break;
    case kEditBoxInputModeSingleLine:
        mInputModeContraints = InputType.TYPE_CLASS_TEXT;
        break;
    default:

        break;
    }

    if (mIsMultiline) {
        mInputModeContraints |= InputType.TYPE_TEXT_FLAG_MULTI_LINE;
    }

    mInputEditText.setInputType(mInputModeContraints | mInputFlagConstraints);

    switch (mInputFlag) {
    case kEditBoxInputFlagPassword:
        mInputFlagConstraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
        break;
    case kEditBoxInputFlagSensitive:
        mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
        break;
    case kEditBoxInputFlagInitialCapsWord:
        mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_WORDS;
        break;
    case kEditBoxInputFlagInitialCapsSentence:
        mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
        break;
    case kEditBoxInputFlagInitialCapsAllCharacters:
        mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS;
        break;
    default:
        break;
    }
    mInputEditText.setInputType(mInputFlagConstraints | mInputModeContraints);

    switch (mReturnType) {
    case kKeyboardReturnTypeDefault:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_NONE);
        break;
    case kKeyboardReturnTypeDone:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_DONE);
        break;
    case kKeyboardReturnTypeSend:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_SEND);
        break;
    case kKeyboardReturnTypeSearch:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_SEARCH);
        break;
    case kKeyboardReturnTypeGo:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_GO);
        break;
    default:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_NONE);
        break;
    }

    if (mMaxLength > 0) {
        mInputEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(mMaxLength) });
    }

    Handler initHandler = new Handler();
    initHandler.postDelayed(new Runnable() {
        public void run() {
            mInputEditText.requestFocus();
            mInputEditText.setSelection(mInputEditText.length());
            openKeyboard();
        }
    }, 200);

    mInputEditText.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            // if user didn't set keyboard type,
            // this callback will be invoked twice with 'KeyEvent.ACTION_DOWN' and 'KeyEvent.ACTION_UP'
            if (actionId != EditorInfo.IME_NULL || (actionId == EditorInfo.IME_NULL && event != null
                    && event.getAction() == KeyEvent.ACTION_DOWN)) {
                //Log.d("EditBox", "actionId: "+actionId +",event: "+event);
                mParentActivity.setEditBoxResult(mInputEditText.getText().toString());
                closeKeyboard();
                dismiss();
                return true;
            }
            return false;
        }
    });
}

From source file:com.android.launcher3.Folder.java

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    mScrollView = (ScrollView) findViewById(R.id.scroll_view);
    mContent = (CellLayout) findViewById(R.id.folder_content);

    mFocusIndicatorHandler = new FocusIndicatorView(getContext());
    mContent.addView(mFocusIndicatorHandler, 0);
    mFocusIndicatorHandler.getLayoutParams().height = FocusIndicatorView.DEFAULT_LAYOUT_SIZE;
    mFocusIndicatorHandler.getLayoutParams().width = FocusIndicatorView.DEFAULT_LAYOUT_SIZE;

    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();

    mContent.setCellDimensions(grid.folderCellWidthPx, grid.folderCellHeightPx);
    mContent.setGridSize(0, 0);/*  w w  w.  j a  va 2  s. c  o m*/
    mContent.getShortcutsAndWidgets().setMotionEventSplittingEnabled(false);
    mContent.setInvertIfRtl(true);
    mFolderName = (FolderEditText) findViewById(R.id.folder_name);
    mFolderName.setFolder(this);
    mFolderName.setOnFocusChangeListener(this);

    /* SPRD: bug399384 2015-02-02 Feature limit folder title max length. @{ */
    int maxLen = getResources().getInteger(R.integer.config_folder_title_max_length);
    mFolderName.promptIfLargerThanLength(maxLen, R.string.input_too_long);
    /* SPRD: bug399384 2015-02-02 Feature limit folder title max length. @} */

    // We find out how tall the text view wants to be (it is set to wrap_content), so that
    // we can allocate the appropriate amount of space for it.
    int measureSpec = MeasureSpec.UNSPECIFIED;
    mFolderName.measure(measureSpec, measureSpec);
    mFolderNameHeight = mFolderName.getMeasuredHeight();

    // We disable action mode for now since it messes up the view on phones
    mFolderName.setCustomSelectionActionModeCallback(mActionModeCallback);
    mFolderName.setOnEditorActionListener(this);
    mFolderName.setSelectAllOnFocus(true);
    mFolderName.setInputType(mFolderName.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
            | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
    mAutoScrollHelper = new FolderAutoScrollHelper(mScrollView);
}

From source file:com.wb.launcher3.Folder.java

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    mScrollView = (ScrollView) findViewById(R.id.scroll_view);
    //*/added by xuchao for folder fullscreen 20140514
    topLine = (ImageView) findViewById(R.id.topline);
    bottomLine = (ImageView) findViewById(R.id.bottomline);
    //        leftLine = (ImageView) findViewById(R.id.leftline);
    //        rightLine = (ImageView) findViewById(R.id.rightline);
    //*//* w w w  .  j a  v  a  2  s.co  m*/
    mContent = (CellLayout) findViewById(R.id.folder_content);

    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();

    CellLayout cell = (CellLayout) mLauncher.getWorkspace().getChildAt(0);
    //*/modified by xuchao for icon's gap 20140529
    Log.d("xuchao", "onFinishInflate-------cell.getWidthGap()===" + cell.getWidthGap());
    Log.d("xuchao", "onFinishInflate-------cell.getHeightGap()===" + cell.getHeightGap());
    Log.d("xuchao", "onFinishInflate-------cell.getCellWidth()===" + cell.getCellWidth());
    Log.d("xuchao", "onFinishInflate-------cell.getCellHeight()===" + cell.getCellHeight());
    if (cell != null) {
        mContent.setCellDimensions(grid.isLandscape ? grid.folderCellWidthLandPx : grid.folderCellWidthPx,
                grid.folderCellHeightPx, cell.getWidthGap(), cell.getHeightGap());
        //final int padding = grid.edgeMarginPx * 2;
        //mContent.setPadding(padding, padding, padding, padding);
    } else {

        mContent.setCellDimensions(grid.isLandscape ? grid.folderCellWidthLandPx : grid.folderCellWidthPx,
                grid.folderCellHeightPx);
    }
    //*/
    mContent.setGridSize(mMaxCountX, mMaxCountY);
    mContent.setBackgroundResource(0);//zhangwuba add 2014-5-16

    mContent.getShortcutsAndWidgets().setMotionEventSplittingEnabled(false);
    mContent.setInvertIfRtl(true);
    mFolderName = (FolderEditText) findViewById(R.id.folder_name);
    mFolderName.setFolder(this);
    mFolderName.setOnFocusChangeListener(this);

    // We find out how tall the text view wants to be (it is set to wrap_content), so that
    // we can allocate the appropriate amount of space for it.
    int measureSpec = MeasureSpec.UNSPECIFIED;
    mFolderName.measure(measureSpec, measureSpec);
    mFolderNameHeight = mFolderName.getMeasuredHeight();

    // We disable action mode for now since it messes up the view on phones
    mFolderName.setCustomSelectionActionModeCallback(mActionModeCallback);
    mFolderName.setOnEditorActionListener(this);
    mFolderName.setSelectAllOnFocus(true);
    mFolderName.setInputType(mFolderName.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
            | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
    mAutoScrollHelper = new FolderAutoScrollHelper(mScrollView);
}

From source file:com.android.ex.chips.RecipientEditTextView.java

public RecipientEditTextView(final Context context, final AttributeSet attrs) {
    super(context, attrs);
    mAddTextWatcher = new Runnable() {
        @Override// www.  j  av a 2s  . c o  m
        public void run() {
            if (mTextWatcher == null) {
                mTextWatcher = new RecipientTextWatcher();
                addTextChangedListener(mTextWatcher);
            }
        }
    };
    mDelayedShrink = new Runnable() {
        @Override
        public void run() {
            shrink();
        }
    };
    mHandlePendingChips = new Runnable() {
        @Override
        public void run() {
            handlePendingChips();
        }
    };
    setChipDimensions(context, attrs);
    if (sSelectedTextColor == -1)
        sSelectedTextColor = ContextCompat.getColor(context, android.R.color.white);
    /*mAlternatesPopup=new ListPopupWindow(context);
    mAddressPopup=new ListPopupWindow(context);*/
    mCopyDialog = new Dialog(context);
    mAlternatesListener = new OnItemClickListener() {
        @Override
        public void onItemClick(final AdapterView<?> adapterView, final View view, final int position,
                final long rowId) {
            //mAlternatesPopup.setOnItemClickListener(null);
            replaceChip(mSelectedChip,
                    ((RecipientAlternatesAdapter) adapterView.getAdapter()).getRecipientEntry(position));
            final Message delayed = Message.obtain(mHandler, DISMISS);
            //delayed.obj=mAlternatesPopup;
            mHandler.sendMessageDelayed(delayed, DISMISS_DELAY);
            clearComposingText();
        }
    };
    setInputType(getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    setOnItemClickListener(null);
    setCustomSelectionActionModeCallback(this);
    mHandler = new Handler() {
        @Override
        public void handleMessage(final Message msg) {
            if (msg.what == DISMISS) {
                //((ListPopupWindow)msg.obj).dismiss();
                return;
            }
            super.handleMessage(msg);
        }
    };
    mTextWatcher = new RecipientTextWatcher();
    addTextChangedListener(mTextWatcher);
    mGestureDetector = new GestureDetector(context, this);
    setOnEditorActionListener(this);
}

From source file:com.ruesga.rview.widget.TagEditTextView.java

private void init(Context ctx, AttributeSet attrs, int defStyleAttr) {
    mHandler = new Handler(mTagMessenger);
    mTriggerTagCreationThreshold = CREATE_CHIP_DEFAULT_DELAYED_TIMEOUT;

    Resources.Theme theme = ctx.getTheme();
    TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.TagEditTextView, defStyleAttr, 0);

    mReadOnly = a.getBoolean(R.styleable.TagEditTextView_readonly, false);
    mDefaultTagMode = TAG_MODE.HASH;//from   w  w  w .ja v a 2  s. c om

    // Create the internal EditText that holds the tag logic
    mTagEdit = mReadOnly ? new TagEditText(ctx, attrs, defStyleAttr) : new TagEditText(ctx, attrs);
    mTagEdit.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 0));
    mTagEdit.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    mTagEdit.addTextChangedListener(mEditListener);
    mTagEdit.setTextIsSelectable(false);
    mTagEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    mTagEdit.setOnFocusChangeListener((v, hasFocus) -> {
        // Remove any pending message
        mHandler.removeMessages(MESSAGE_CREATE_CHIP);
    });
    mTagEdit.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
        @Override
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        @Override
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        @Override
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            return false;
        }

        @Override
        public void onDestroyActionMode(ActionMode mode) {

        }
    });
    addView(mTagEdit);

    // Configure the window mode for landscape orientation, to disallow hide the
    // EditText control, and show characters instead of chips
    int orientation = ctx.getResources().getConfiguration().orientation;
    if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
        if (ctx instanceof Activity) {
            Window window = ((Activity) ctx).getWindow();
            if (window != null) {
                window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
                mTagEdit.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
            }
        }
    }

    // Save the keyListener for later restore
    mEditModeKeyListener = mTagEdit.getKeyListener();

    // Initialize resources for chips
    mChipBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

    mChipFgPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    mChipFgPaint.setTextSize(mTagEdit.getTextSize() * (mReadOnly ? 1 : 0.8f));
    if (CHIP_TYPEFACE != null) {
        mChipFgPaint.setTypeface(CHIP_TYPEFACE);
    }
    mChipFgPaint.setTextAlign(Paint.Align.LEFT);

    // Calculate the width area used to remove the tag in the chip
    mChipRemoveAreaWidth = (int) (mChipFgPaint.measureText(CHIP_REMOVE_TEXT) + 0.5f);

    if (ONE_PIXEL <= 0) {
        Resources res = getResources();
        ONE_PIXEL = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, res.getDisplayMetrics());
    }

    int n = a.getIndexCount();
    for (int i = 0; i < n; i++) {
        int attr = a.getIndex(i);
        switch (attr) {
        case R.styleable.TagEditTextView_supportUserTags:
            setSupportsUserTags(a.getBoolean(attr, false));
            break;

        case R.styleable.TagEditTextView_chipBackgroundColor:
            mChipBackgroundColor = a.getColor(attr, mChipBackgroundColor);
            break;

        case R.styleable.TagEditTextView_chipTextColor:
            mChipFgPaint.setColor(a.getColor(attr, Color.WHITE));
            break;
        }
    }
    a.recycle();
}

From source file:com.android.launcher3.folder.Folder.java

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    mContent = (FolderPagedView) findViewById(R.id.folder_content);
    mContent.setFolder(this);

    mPageIndicator = (PageIndicatorDots) findViewById(R.id.folder_page_indicator);
    mFolderName = (ExtendedEditText) findViewById(R.id.folder_name);
    mFolderName.setOnBackKeyListener(new ExtendedEditText.OnBackKeyListener() {
        @Override/*w w w.j  a va 2s  .com*/
        public boolean onBackKey() {
            // Close the activity on back key press
            doneEditingFolderName(true);
            return false;
        }
    });
    mFolderName.setOnFocusChangeListener(this);

    if (!Utilities.ATLEAST_MARSHMALLOW) {
        // We disable action mode in older OSes where floating selection menu is not yet
        // available.
        mFolderName.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
            public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                return false;
            }

            public boolean onCreateActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            public void onDestroyActionMode(ActionMode mode) {
            }

            public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                return false;
            }
        });
    }
    mFolderName.setOnEditorActionListener(this);
    mFolderName.setSelectAllOnFocus(true);
    mFolderName.setInputType(mFolderName.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
            | InputType.TYPE_TEXT_FLAG_CAP_WORDS);

    mFooter = findViewById(R.id.folder_footer);

    // We find out how tall footer wants to be (it is set to wrap_content), so that
    // we can allocate the appropriate amount of space for it.
    int measureSpec = MeasureSpec.UNSPECIFIED;
    mFooter.measure(measureSpec, measureSpec);
    mFooterHeight = mFooter.getMeasuredHeight();
    //Folder background color
    if (Utilities.getFolderBackgroundPrefEnabled(getContext()) != -1) {
        mFooter.setBackgroundColor(Utilities
                .getFolderBackgroundPrefEnabled(Launcher.getLauncherActivity().getApplicationContext()));
        mContent.setBackgroundColor(Utilities
                .getFolderBackgroundPrefEnabled(Launcher.getLauncherActivity().getApplicationContext()));
    }
}

From source file:org.site_monitor.activity.MainActivity.java

public void floatingAddSite(final View v) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(R.string.add_monitor);
    final EditText input = new EditText(context);
    input.setHint(R.string.hint_site_url);
    input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
            | InputType.TYPE_TEXT_VARIATION_URI);
    builder.setView(input);/* w ww  .jav a  2  s  .  c om*/
    builder.setPositiveButton(R.string.action_add, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String host = input.getText().toString().trim();
            if (host.isEmpty()) {
                return;
            }
            try {
                DBSiteSettings dbSiteSettings = dbHelper.getDBSiteSettings();
                if (dbSiteSettings.findForHost(host) != null) {
                    Snackbar.make(v, host + getString(R.string.already_exists), Snackbar.LENGTH_SHORT).show();
                    return;
                }
                SiteSettings siteSettings = new SiteSettings(host);
                dbSiteSettings.create(siteSettings);
                alarmUtil.startAlarmIfNeeded(context);
                new CallSiteTask(context, taskFragment).execute(siteSettings);
                SiteSettingsActivity.start(context, siteSettings.getHost());
            } catch (SQLException e) {
                Log.e(TAG, "create", e);
            }
        }
    });
    builder.setNegativeButton(R.string.action_cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    });
    builder.show();
}