Java Code Examples for android.widget.EditText#getTextColors()

The following examples show how to use android.widget.EditText#getTextColors() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ColorPickerDialog.java    From LyricHere with Apache License 2.0 4 votes vote down vote up
private void setUp(int color) {

        LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        mLayout = inflater.inflate(R.layout.dialog_color_picker, null);
        mLayout.getViewTreeObserver().addOnGlobalLayoutListener(this);

        mOrientation = getContext().getResources().getConfiguration().orientation;
        setContentView(mLayout);

        setTitle(R.string.dialog_color_picker);

        mColorPicker = (ColorPickerView) mLayout.findViewById(R.id.color_picker_view);
        mOldColor = (ColorPickerPanelView) mLayout.findViewById(R.id.old_color_panel);
        mNewColor = (ColorPickerPanelView) mLayout.findViewById(R.id.new_color_panel);

        mHexVal = (EditText) mLayout.findViewById(R.id.hex_val);
        mHexVal.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
        mHexDefaultTextColor = mHexVal.getTextColors();

        mHexVal.setOnEditorActionListener(new TextView.OnEditorActionListener() {

            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_DONE) {
                    InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                    imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
                    String s = mHexVal.getText().toString();
                    if (s.length() > 5 || s.length() < 10) {
                        try {
                            int c = ColorPickerPreference.convertToColorInt(s.toString());
                            mColorPicker.setColor(c, true);
                            mHexVal.setTextColor(mHexDefaultTextColor);
                        } catch (IllegalArgumentException e) {
                            mHexVal.setTextColor(Color.RED);
                        }
                    } else {
                        mHexVal.setTextColor(Color.RED);
                    }
                    return true;
                }
                return false;
            }
        });

        ((LinearLayout) mOldColor.getParent()).setPadding(
                Math.round(mColorPicker.getDrawingOffset()),
                0,
                Math.round(mColorPicker.getDrawingOffset()),
                0
        );

        mOldColor.setOnClickListener(this);
        mNewColor.setOnClickListener(this);
        mColorPicker.setOnColorChangedListener(this);
        mOldColor.setColor(color);
        mColorPicker.setColor(color, true);

    }
 
Example 2
Source File: ColorPickerDialog.java    From WiFiKeyView with Apache License 2.0 4 votes vote down vote up
private void setUp(int color) {
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View layout = inflater.inflate(R.layout.dialog_color_picker, null);

    setContentView(layout);

    setTitle(R.string.dialog_color_picker);

    mColorPicker = (ColorPickerView) layout.findViewById(R.id.color_picker_view);
    mOldColor = (ColorPickerPanelView) layout.findViewById(R.id.old_color_panel);
    mNewColor = (ColorPickerPanelView) layout.findViewById(R.id.new_color_panel);

    mHexVal = (EditText) layout.findViewById(R.id.hex_val);
    mHexVal.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    mHexDefaultTextColor = mHexVal.getTextColors();

    mHexVal.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
                String s = mHexVal.getText().toString();
                if (s.length() > 5 || s.length() < 10) {
                    try {
                        int c = ColorPickerPreference.convertToColorInt(s.toString());
                        mColorPicker.setColor(c, true);
                        mHexVal.setTextColor(mHexDefaultTextColor);
                    } catch (IllegalArgumentException e) {
                        mHexVal.setTextColor(Color.RED);
                    }
                } else {
                    mHexVal.setTextColor(Color.RED);
                }
                return true;
            }
            return false;
        }
    });

    ((LinearLayout) mOldColor.getParent()).setPadding(
            Math.round(mColorPicker.getDrawingOffset()),
            0,
            Math.round(mColorPicker.getDrawingOffset()),
            0
    );

    mOldColor.setOnClickListener(this);
    mNewColor.setOnClickListener(this);
    mColorPicker.setOnColorChangedListener(this);
    mOldColor.setColor(color);
    mColorPicker.setColor(color, true);

}
 
Example 3
Source File: ColorPickerDialog.java    From Hangar with GNU General Public License v3.0 4 votes vote down vote up
@SuppressLint("InflateParams")
private void setUp(int color, int newColor) {
	
	LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	View layout = inflater.inflate(R.layout.dialog_color_picker, null);

	setContentView(layout);

	setTitle(R.string.dialog_color_picker);
	
	mColorPicker = (ColorPickerView) layout.findViewById(R.id.color_picker_view);
	mOldColor = (ColorPickerPanelView) layout.findViewById(R.id.old_color_panel);
	mNewColor = (ColorPickerPanelView) layout.findViewById(R.id.new_color_panel);
	
	mHexVal = (EditText) layout.findViewById(R.id.hex_val);
	mHexVal.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
	mHexDefaultTextColor = mHexVal.getTextColors();
	
	mHexVal.setOnEditorActionListener(new TextView.OnEditorActionListener() {

		@Override
		public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
			if (actionId == EditorInfo.IME_ACTION_DONE) {
				InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
				imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
				String s = mHexVal.getText().toString();
				if (s.length() > 5 || s.length() < 10) {
					try {
						int c = ColorPickerPreference.convertToColorInt(s.toString());
						mColorPicker.setColor(c, true);
						mHexVal.setTextColor(mHexDefaultTextColor);
					} catch (IllegalArgumentException e) {
						mHexVal.setTextColor(Color.RED);
					}
				} else {
					mHexVal.setTextColor(Color.RED);
				}
				return true;
			}
			return false;
		}
	});
	
	((LinearLayout) mOldColor.getParent()).setPadding(
		Math.round(mColorPicker.getDrawingOffset()), 
		0, 
		Math.round(mColorPicker.getDrawingOffset()), 
		0
	);	
	
	mOldColor.setOnClickListener(this);
	mNewColor.setOnClickListener(this);
	mColorPicker.setOnColorChangedListener(this);
       mOldColor.setColor(color);
       mColorPicker.setColor((newColor != color) ? newColor : color, true);

}