@Override public View getViewWithAlpha(int alphaValue) { if (view != null) { View layout = view.findViewById(R.id.brick_change_variable_layout); Drawable background = layout.getBackground(); background.setAlpha(alphaValue); TextView textSetVariable = (TextView) view.findViewById(R.id.brick_change_variable_label); TextView textTo = (TextView) view.findViewById(R.id.brick_change_variable_by); TextView editVariable = (TextView) view.findViewById(R.id.brick_change_variable_edit_text); Spinner variablebrickSpinner = (Spinner) view.findViewById(R.id.change_variable_spinner); ColorStateList color = textSetVariable.getTextColors().withAlpha(alphaValue); variablebrickSpinner.getBackground().setAlpha(alphaValue); if (adapterView != null) { ((TextView) adapterView.getChildAt(0)).setTextColor(color); } textSetVariable.setTextColor(textSetVariable.getTextColors().withAlpha(alphaValue)); textTo.setTextColor(textTo.getTextColors().withAlpha(alphaValue)); editVariable.setTextColor(editVariable.getTextColors().withAlpha(alphaValue)); editVariable.getBackground().setAlpha(alphaValue); this.alphaValue = (alphaValue); } return view; }
private static void findNotificationTextColors(ViewGroup group, String title, String content) { for (int i = 0; i < group.getChildCount(); i++) { if (group.getChildAt(i) instanceof TextView) { TextView textView = (TextView) group.getChildAt(i); String text = textView.getText().toString(); if (title.equals(text)) { NOTIFICATION_TEXT_COLORS.setFirst(textView.getTextColors().getDefaultColor()); } else if (content.equals(text)) { NOTIFICATION_TEXT_COLORS.setSecond(textView.getTextColors().getDefaultColor()); } } else if (group.getChildAt(i) instanceof ViewGroup) findNotificationTextColors((ViewGroup) group.getChildAt(i), title, content); } }
private Map<int[], Integer> getExistingColorStates(TextView view) { Map<int[], Integer> map = new LinkedHashMap<int[], Integer>(); ColorStateList textColors = view.getTextColors(); if (textColors != null) { try { Field specsField = textColors.getClass().getDeclaredField("mStateSpecs"); specsField.setAccessible(true); int[][] stateSpecs = (int[][]) specsField.get(textColors); Field colorsField = textColors.getClass().getDeclaredField("mColors"); colorsField.setAccessible(true); int[] colors = (int[]) colorsField.get(textColors); // These all should match if (stateSpecs != null && colors != null && stateSpecs.length == colors.length) { // load the map with the existing states for (int i = 0; i < stateSpecs.length; i++) { map.put(stateSpecs[i], colors[i]); } } } catch (Exception e) { PXLog.e(PXViewStyleAdapter.class.getSimpleName(), e, "Error getting the state set"); } finally { } } return map; }
/** * setSelection, if user is touching on the AWView, the function is invalid. * * @param index */ public void setSelection(int index) { if (index >= 0 && index < mAlphabetList.size()) { TextView textV = (TextView) getChildAt(index); TextView curTextV = (TextView) getChildAt(mCurrentSelection); ColorStateList oldColor = null; if (textV != null) { oldColor = textV.getTextColors(); } if (curTextV != null && oldColor != null) { curTextV.setTextColor(oldColor); // restore } mCurrentSelection = index; if (textV != null && oldColor != null) { if (isPoped) { textV.setTextColor(oldColor); } else { textV.setTextColor(Color.WHITE); } } if (!isPoped) { isShowSelected = true; invalidate(); } if (mShowingPreview) { setState(STATE_CHANGE_TEXT); setState(STATE_NONE); } } }
protected boolean selectAlphabet() { final int itemPosition = getItemPosition(); // get the item (we can do it since we know item index) if (itemPosition < mAlphabetList.size() && mCurrentSelection != itemPosition) { mPreSelection = mCurrentSelection; String firstAlphabet = mAlphabetList.get(itemPosition).firstAlphabet; TextView textV = (TextView) getChildAt(itemPosition); // current TextView curTextV = (TextView) getChildAt(mCurrentSelection); // pre if (curTextV != null && textV != null) { curTextV.setTextColor(textV.getTextColors()); // restore } mCurrentSelection = itemPosition; if (textV != null) { textV.setTextColor(Color.WHITE); } if (mShowingPreview) { setState(STATE_CHANGE_TEXT); } else { setState(STATE_VISIBLE); } // notify alphabet changed. if (mAlphabetListener != null) { mAlphabetListener.onAlphabetChanged(itemPosition, firstAlphabet); } return true; } return false; }
public void setupViewOptions() { setTextSize(adapter.getTextSize()); mediaPreview.setStyle(adapter.getMediaPreviewStyle()); // profileImageView.setStyle(adapter.getProfileImageStyle()); final boolean nameFirst = adapter.isNameFirst(); nameView.setNameFirst(nameFirst); quotedNameView.setNameFirst(nameFirst); final int favIcon, favStyle, favColor; final Context context = adapter.getContext(); if (adapter.shouldUseStarsForLikes()) { favIcon = R.drawable.ic_action_star; favStyle = LikeAnimationDrawable.Style.FAVORITE; favColor = ContextCompat.getColor(context, R.color.highlight_favorite); } else { favIcon = R.drawable.ic_action_heart; favStyle = LikeAnimationDrawable.Style.LIKE; favColor = ContextCompat.getColor(context, R.color.highlight_like); } final Drawable icon = ContextCompat.getDrawable(context, favIcon); final LikeAnimationDrawable drawable = new LikeAnimationDrawable( icon, favoriteCountView.getTextColors().getDefaultColor(), favColor, favStyle); drawable.mutate(); favoriteIconView.setImageDrawable(drawable); timeView.setShowAbsoluteTime(adapter.isShowAbsoluteTime()); favoriteIconView.setActivatedColor(favColor); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View v = inflater.inflate(R.layout.fragment_status, null, false); // inicializar mButtonTweet = (Button) v.findViewById(R.id.status_button_tweet); mTextStatus = (EditText) v.findViewById(R.id.status_text); mTextCount = (TextView) v.findViewById(R.id.status_text_count); mTextCount.setText(Integer.toString(140)); mDefaultColor = mTextCount.getTextColors().getDefaultColor(); mButtonTweet.setEnabled(false); mButtonTweet.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // Toast.makeText(getActivity(), "pulsaste publicar", Toast.LENGTH_SHORT).show(); String status = mTextStatus.getText().toString(); PostTask postTask = new PostTask(); postTask.execute(status); Log.d(TAG, "onClicked"); try { InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), 0); } catch (Exception e) { e.printStackTrace(); } } }); mTextStatus.addTextChangedListener( new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { numCaracteres = 140 - s.length(); cambiaContador(numCaracteres); } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { numCaracteres = 140 - s.length(); cambiaContador(numCaracteres); } @Override public void afterTextChanged(Editable s) { numCaracteres = 140 - s.length(); cambiaContador(numCaracteres); } }); return v; }
@Override public View getViewWithAlpha(int alphaValue) { if (view != null) { View layout = view.findViewById(R.id.brick_glide_to_layout); Drawable background = layout.getBackground(); background.setAlpha(alphaValue); TextView glideToLabel = (TextView) view.findViewById(R.id.brick_glide_to_label); TextView glideToSeconds = (TextView) view.findViewById(R.id.brick_glide_to_seconds_text_view); TextView glideToXTextView = (TextView) view.findViewById(R.id.brick_glide_to_x); TextView glideToYTextView = (TextView) view.findViewById(R.id.brick_glide_to_y); TextView editDuration = (TextView) view.findViewById(R.id.brick_glide_to_edit_text_duration); TextView editX = (TextView) view.findViewById(R.id.brick_glide_to_edit_text_x); TextView editY = (TextView) view.findViewById(R.id.brick_glide_to_edit_text_y); glideToLabel.setTextColor(glideToLabel.getTextColors().withAlpha(alphaValue)); glideToSeconds.setTextColor(glideToSeconds.getTextColors().withAlpha(alphaValue)); glideToXTextView.setTextColor(glideToXTextView.getTextColors().withAlpha(alphaValue)); glideToYTextView.setTextColor(glideToYTextView.getTextColors().withAlpha(alphaValue)); editDuration.setTextColor(editDuration.getTextColors().withAlpha(alphaValue)); editDuration.getBackground().setAlpha(alphaValue); editX.setTextColor(editX.getTextColors().withAlpha(alphaValue)); editX.getBackground().setAlpha(alphaValue); editY.setTextColor(editY.getTextColors().withAlpha(alphaValue)); editY.getBackground().setAlpha(alphaValue); this.alphaValue = alphaValue; } return view; }
@Override public View getViewWithAlpha(int alphaValue) { if (view != null) { LinearLayout layout = (LinearLayout) view.findViewById(R.id.brick_nxt_motor_action_layout); Drawable background = layout.getBackground(); background.setAlpha(alphaValue); TextView textLegoMotorActionLabel = (TextView) view.findViewById(R.id.lego_motor_action_label); TextView textLegoMotorActionSpeed = (TextView) view.findViewById(R.id.lego_motor_action_speed); TextView textLegoMotorActionPercent = (TextView) view.findViewById(R.id.lego_motor_action_percent); TextView textLegoMotorActionLabelSpeedView = (TextView) view.findViewById(R.id.motor_action_speed_text_view); EditText editSpeed = (EditText) view.findViewById(R.id.motor_action_speed_edit_text); textLegoMotorActionLabel.setTextColor( textLegoMotorActionLabel.getTextColors().withAlpha(alphaValue)); textLegoMotorActionSpeed.setTextColor( textLegoMotorActionSpeed.getTextColors().withAlpha(alphaValue)); textLegoMotorActionPercent.setTextColor( textLegoMotorActionPercent.getTextColors().withAlpha(alphaValue)); textLegoMotorActionLabelSpeedView.setTextColor( textLegoMotorActionLabelSpeedView.getTextColors().withAlpha(alphaValue)); Spinner motorSpinner = (Spinner) view.findViewById(R.id.lego_motor_action_spinner); ColorStateList color = textLegoMotorActionLabelSpeedView.getTextColors().withAlpha(alphaValue); motorSpinner.getBackground().setAlpha(alphaValue); if (adapterView != null) { ((TextView) adapterView.getChildAt(0)).setTextColor(color); } editSpeed.setTextColor(editSpeed.getTextColors().withAlpha(alphaValue)); editSpeed.getBackground().setAlpha(alphaValue); this.alphaValue = (alphaValue); } return view; }
@Override public View getViewWithAlpha(int alphaValue) { if (view != null) { View layout = view.findViewById(R.id.brick_set_y_layout); Drawable background = layout.getBackground(); background.setAlpha(alphaValue); TextView textY = (TextView) view.findViewById(R.id.brick_set_y_textview); TextView editY = (TextView) view.findViewById(R.id.brick_set_y_edit_text); textY.setTextColor(textY.getTextColors().withAlpha(alphaValue)); editY.setTextColor(editY.getTextColors().withAlpha(alphaValue)); editY.getBackground().setAlpha(alphaValue); this.alphaValue = (alphaValue); } return view; }
@Override public View getViewWithAlpha(int alphaValue) { if (view != null) { View layout = view.findViewById(R.id.brick_point_to_layout); layout.getBackground().setAlpha(alphaValue); TextView textPointToLabel = (TextView) view.findViewById(R.id.brick_point_to_label); textPointToLabel.setTextColor(textPointToLabel.getTextColors().withAlpha(alphaValue)); Spinner pointToSpinner = (Spinner) view.findViewById(R.id.brick_point_to_spinner); ColorStateList color = textPointToLabel.getTextColors().withAlpha(alphaValue); pointToSpinner.getBackground().setAlpha(alphaValue); if (adapterView != null) { ((TextView) adapterView.getChildAt(0)).setTextColor(color); } this.alphaValue = alphaValue; } return view; }
@Override public View getViewWithAlpha(int alphaValue) { if (view != null) { Log.d("TAG", "VIEW != NULL"); View layout = view.findViewById(R.id.brick_hide_layout); Drawable background = layout.getBackground(); background.setAlpha(alphaValue); this.alphaValue = alphaValue; TextView hideLabel = (TextView) view.findViewById(R.id.brick_hide_label); hideLabel.setTextColor(hideLabel.getTextColors().withAlpha(alphaValue)); } return view; }
@Override public View getViewWithAlpha(int alphaValue) { if (view != null) { View layout = view.findViewById(R.id.brick_phiro_motor_stop_layout); Drawable background = layout.getBackground(); background.setAlpha(alphaValue); TextView textPhiroProMotorStopLabel = (TextView) view.findViewById(R.id.ValueTextView); textPhiroProMotorStopLabel.setTextColor( textPhiroProMotorStopLabel.getTextColors().withAlpha(alphaValue)); Spinner motorSpinner = (Spinner) view.findViewById(R.id.brick_phiro_stop_motor_spinner); ColorStateList color = textPhiroProMotorStopLabel.getTextColors().withAlpha(alphaValue); motorSpinner.getBackground().setAlpha(alphaValue); if (adapterView != null) { ((TextView) adapterView.getChildAt(0)).setTextColor(color); } this.alphaValue = (alphaValue); } return view; }
@Override public View getViewWithAlpha(int alphaValue) { if (view != null) { View layout = view.findViewById(R.id.brick_nxt_play_tone_layout); Drawable background = layout.getBackground(); background.setAlpha(alphaValue); TextView textLegoPlayToneLabel = (TextView) view.findViewById(R.id.brick_nxt_play_tone_label); TextView textLegoPlayToneDuration = (TextView) view.findViewById(R.id.brick_nxt_play_tone_duration); TextView textLegoPlayToneDurationTextView = (TextView) view.findViewById(R.id.nxt_tone_duration_text_view); TextView textLegoPlayToneSeconds = (TextView) view.findViewById(R.id.brick_nxt_play_tone_seconds); TextView textLegoPlayToneFrequency = (TextView) view.findViewById(R.id.brick_nxt_play_tone_frequency); TextView textLegoPlayToneOz = (TextView) view.findViewById(R.id.brick_nxt_play_tone_hundred_hz); TextView editLegoDuration = (TextView) view.findViewById(R.id.nxt_tone_duration_edit_text); TextView editLegoFrequency = (TextView) view.findViewById(R.id.nxt_tone_freq_edit_text); textLegoPlayToneLabel.setTextColor( textLegoPlayToneLabel.getTextColors().withAlpha(alphaValue)); textLegoPlayToneDuration.setTextColor( textLegoPlayToneDuration.getTextColors().withAlpha(alphaValue)); textLegoPlayToneDurationTextView.setTextColor( textLegoPlayToneDurationTextView.getTextColors().withAlpha(alphaValue)); textLegoPlayToneSeconds.setTextColor( textLegoPlayToneSeconds.getTextColors().withAlpha(alphaValue)); textLegoPlayToneFrequency.setTextColor( textLegoPlayToneFrequency.getTextColors().withAlpha(alphaValue)); textLegoPlayToneOz.setTextColor(textLegoPlayToneOz.getTextColors().withAlpha(alphaValue)); editLegoFrequency.setTextColor(editLegoFrequency.getTextColors().withAlpha(alphaValue)); editLegoFrequency.getBackground().setAlpha(alphaValue); editLegoDuration.setTextColor(editLegoDuration.getTextColors().withAlpha(alphaValue)); editLegoDuration.getBackground().setAlpha(alphaValue); this.alphaValue = (alphaValue); } return view; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Setting up spinner spinner = (ProgressBar) findViewById(R.id.progressBar1); spinner.setVisibility(View.GONE); // Set up UI Components title_box = (TextView) findViewById(R.id.title); status_box = (TextView) findViewById(R.id.status); downloadsize_box = (TextView) findViewById(R.id.downloadsize); mp3_butt = (Button) findViewById(R.id.downmp3); oldColors = status_box.getTextColors(); // Save default color Typeface font_title = Typeface.createFromAsset(c.getAssets(), "fonts/JosefinSlab-Bold.ttf"); title_box.setTypeface(font_title); status_box.setTypeface(font_title); downloadsize_box.setTypeface(font_title); // Set up ProgressDialog mProgressDialog = new CustomProgressDialog(MainActivity.this); mProgressDialog.setIndeterminate(true); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); mProgressDialog.setCancelable(true); mProgressDialog.setProgressDrawable( getResources().getDrawable(R.drawable.apptheme_progress_horizontal_holo_dark)); mProgressDialog.setIndeterminateDrawable( getResources() .getDrawable(R.drawable.apptheme_progress_indeterminate_horizontal_holo_dark)); syncpref(); /* Check First Time Launch */ if (sharedPrefs.getBoolean( "firststart", true)) { // Check if it's the first time you run the application // Show a disclaimer. showdialog( 0, getResources().getString(R.string.disclaimer_title), getResources().getString(R.string.disclaimer_text)); } else { checkandstart(); } }
public PagerTitleStrip(Context context, AttributeSet attrs) { super(context, attrs); addView(mPrevText = new TextView(context)); addView(mCurrText = new TextView(context)); addView(mNextText = new TextView(context)); final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); final int textAppearance = a.getResourceId(0, 0); if (textAppearance != 0) { mPrevText.setTextAppearance(context, textAppearance); mCurrText.setTextAppearance(context, textAppearance); mNextText.setTextAppearance(context, textAppearance); } if (a.hasValue(1)) { final int textColor = a.getColor(1, 0); mPrevText.setTextColor(textColor); mCurrText.setTextColor(textColor); mNextText.setTextColor(textColor); } final int textSize = a.getDimensionPixelSize(2, 0); if (textSize != 0) { mPrevText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); mCurrText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); mNextText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); } a.recycle(); final int defaultColor = mPrevText.getTextColors().getDefaultColor(); final int transparentColor = (SIDE_ALPHA << 24) | (defaultColor & 0xFFFFFF); mPrevText.setTextColor(transparentColor); mNextText.setTextColor(transparentColor); mPrevText.setEllipsize(TruncateAt.END); mCurrText.setEllipsize(TruncateAt.END); mNextText.setEllipsize(TruncateAt.END); mPrevText.setSingleLine(); mCurrText.setSingleLine(); mNextText.setSingleLine(); final float density = context.getResources().getDisplayMetrics().density; mScaledTextSpacing = (int) (TEXT_SPACING * density); }
void setupLicenseText(AlertDialog.Builder builder) { View view = getLayoutInflater().inflate(R.layout.license, null); final TextView textView = (TextView) view.findViewById(R.id.license_text); textView.setTextColor( textView.getTextColors().getDefaultColor()); // disables color change on selection textView.setText( new StringBuilder(getString(R.string.license_intro)) .append(Strings.THREENEWLINES) .append(getString(R.string.license))); final TextView contributorsTextView = (TextView) view.findViewById(R.id.contributors_togglebutton); contributorsTextView.setOnClickListener( new OnClickListener() { boolean showingLicense = true; @Override public void onClick(View view) { if (showingLicense) { textView.setText(R.string.contributors_list); contributorsTextView.setText(R.string.license_word); } else { textView.setText( new StringBuilder(getString(R.string.license_intro)) .append(Strings.THREENEWLINES) .append(getString(R.string.license))); contributorsTextView.setText(R.string.contributors); } showingLicense = !showingLicense; } }); builder.setView(view); }
@Override public View getViewWithAlpha(int alphaValue) { if (view != null) { View layout = view.findViewById(R.id.brick_phiro_rgb_led_layout); Drawable background = layout.getBackground(); background.setAlpha(alphaValue); TextView textPhiroProLabel = (TextView) view.findViewById(R.id.brick_phiro_rgb_led_action_label); TextView textPhiroProEyeRed = (TextView) view.findViewById(R.id.brick_phiro_rgb_led_red_text_view); TextView editRed = (TextView) view.findViewById(R.id.brick_phiro_rgb_led_action_red_edit_text); // red TextView textPhiroProEyeRedView = (TextView) view.findViewById(R.id.brick_phiro_rgb_led_red_text_view); textPhiroProLabel.setTextColor(textPhiroProLabel.getTextColors().withAlpha(alphaValue)); textPhiroProEyeRed.setTextColor(textPhiroProEyeRed.getTextColors().withAlpha(alphaValue)); Spinner eyeSpinner = (Spinner) view.findViewById(R.id.brick_phiro_rgb_light_spinner); ColorStateList color = textPhiroProEyeRedView.getTextColors().withAlpha(alphaValue); eyeSpinner.getBackground().setAlpha(alphaValue); if (adapterView != null) { ((TextView) adapterView.getChildAt(0)).setTextColor(color); } editRed.setTextColor(editRed.getTextColors().withAlpha(alphaValue)); editRed.getBackground().setAlpha(alphaValue); // green TextView textPhiroProEyeGreen = (TextView) view.findViewById(R.id.brick_phiro_rgb_led_green_text_view); TextView editGreen = (TextView) view.findViewById(R.id.brick_phiro_rgb_led_action_green_edit_text); TextView textPhiroProEyeGreenView = (TextView) view.findViewById(R.id.brick_phiro_rgb_led_green_text_view); editGreen.setTextColor(editGreen.getTextColors().withAlpha(alphaValue)); editGreen.getBackground().setAlpha(alphaValue); ColorStateList color2 = textPhiroProEyeGreenView.getTextColors().withAlpha(alphaValue); if (adapterView != null) { ((TextView) adapterView.getChildAt(0)).setTextColor(color2); } textPhiroProEyeGreen.setTextColor(textPhiroProEyeGreen.getTextColors().withAlpha(alphaValue)); // blue TextView textPhiroProEyeBlue = (TextView) view.findViewById(R.id.brick_phiro_rgb_led_blue_text_view); TextView editBlue = (TextView) view.findViewById(R.id.brick_phiro_rgb_led_action_blue_edit_text); TextView textPhiroProEyeBlueView = (TextView) view.findViewById(R.id.brick_phiro_rgb_led_action_blue_edit_text); editBlue.setTextColor(editGreen.getTextColors().withAlpha(alphaValue)); editBlue.getBackground().setAlpha(alphaValue); ColorStateList color3 = textPhiroProEyeBlueView.getTextColors().withAlpha(alphaValue); if (adapterView != null) { ((TextView) adapterView.getChildAt(0)).setTextColor(color3); } textPhiroProEyeBlue.setTextColor(textPhiroProEyeBlue.getTextColors().withAlpha(alphaValue)); this.alphaValue = alphaValue; } return view; }