public void clearFlag() { tvService.setTextColor(tvService.getResources().getColor(R.color.color_gray5)); tvNoPay.setTextColor(tvNoPay.getResources().getColor(R.color.color_gray5)); tvPay.setTextColor(tvService.getResources().getColor(R.color.color_gray5)); tvAll.setTextColor(tvService.getResources().getColor(R.color.color_gray5)); tvServiceFlag.setVisibility(View.GONE); tvNoPayFlag.setVisibility(View.GONE); tvPayFlag.setVisibility(View.GONE); tvAllFlag.setVisibility(View.GONE); }
private static void setTextViewEnabled(TextView textView, boolean enabled, boolean isSecondary) { if (textView != null && textView.getResources() != null) { int colorResId; if (enabled) { if (isSecondary) { colorResId = R.color.secondary_textcolor; } else { colorResId = R.color.primary_textcolor; } } else { colorResId = R.color.disabled; } textView.setTextColor(textView.getResources().getColor(colorResId)); } }
public void setData(int position, AccountsModel mAccountsModel) { this.position = position; this.mAccountsModel = mAccountsModel; if (mAccountsModel.getAccountAlias() != null) { name_tv.setText(mAccountsModel.getAccountAlias()); } else { name_tv.setText(""); } if (mAccountsModel.getCardHolder() != null) { iban.setText(mAccountsModel.getCardHolder()); } else { iban.setText(""); } String cardNumber = mAccountsModel.getCardNumber(); if (cardNumber == null) { cardNumber = ""; } avilable_banlence_tv.setText(cardNumber); if (mAccountsModel.getIsPreferred()) { isPreferredStar.setVisibility(View.VISIBLE); } else { isPreferredStar.setVisibility(View.GONE); } if (disAblePosition == position) { onEnable(false); } else { rbtn.setChecked(selectedPosition == position); name_tv.setTextColor(name_tv.getResources().getColor(R.color.black)); itemView.setEnabled(true); rbtn.setEnabled(true); } }
private void fillImageHeaderData() { int completedCount = getCompletedImageDataCount(); mImageDescr.setText( mImageDescr .getResources() .getString( R.string.bundle_creator_image_descr, completedCount, mSelectedBitmaps.size())); }
/** * Concatenates with the specified text (two spaces and appendix) to the TextView with RTL * support. * * @param text the String that is concatenated to the TextView */ @SuppressLint("SetTextI18n") public static void concatWithTwoSpacesForRtlSupport(TextView textView, CharSequence text) { if (ResourceUtil.isRTL(textView.getResources())) { textView.setText(text + StringUtil.TWO_SPACES + textView.getText()); } else { textView.append(StringUtil.TWO_SPACES + text); } }
public void onEnable(boolean enable) { Holder mHolder = (Holder) beneficiary_rg.getChildAt(disAblePosition).getTag(); if (enable) { name_tv.setTextColor(mHolder.name_tv.getResources().getColor(R.color.black)); iban.setTextColor(iban.getResources().getColor(R.color.gray)); avilable_banlence_tv.setTextColor(mHolder.name_tv.getResources().getColor(R.color.black)); } else { name_tv.setTextColor(mHolder.name_tv.getResources().getColor(R.color.light_gray)); avilable_banlence_tv.setTextColor( mHolder.name_tv.getResources().getColor(R.color.light_gray)); iban.setTextColor(iban.getResources().getColor(R.color.light_gray)); rbtn.setChecked(false); if (selectedPosition == position) { selectedPosition = -1; } } mHolder.itemView.setEnabled(enable); mHolder.rbtn.setEnabled(enable); }
/** * Concatenates with the specified text (two spaces and appendix) to the TextView with RTL * support. * * @param text the String that is concatenated to the TextView * @param textColor the <code>text</code> color */ @SuppressLint("SetTextI18n") public static void concatWithTwoSpacesForRtlSupport( TextView textView, CharSequence text, @ColorInt int textColor) { if (ResourceUtil.isRTL(textView.getResources())) { textView.setText(text + StringUtil.TWO_SPACES + textView.getText()); ViewUtil.setForegroundColor(textView, textColor, 0, text.length()); } else { int start = textView.length(); textView.append(StringUtil.TWO_SPACES + text); ViewUtil.setForegroundColor(textView, textColor, start, textView.length()); } }
public static void setSessionTitleColor( long blockStart, long blockEnd, TextView title, TextView subtitle) { long currentTimeMillis = System.currentTimeMillis(); int colorId = R.color.body_text_1; int subColorId = R.color.body_text_2; if (currentTimeMillis > blockEnd && currentTimeMillis < CONFERENCE_END_MILLIS) { colorId = subColorId = R.color.body_text_disabled; } final Resources res = title.getResources(); title.setTextColor(res.getColor(colorId)); subtitle.setTextColor(res.getColor(subColorId)); }
private static TextView createField( @NonNull LayoutInflater inflater, @NonNull ViewGroup parent, @NonNull final FormField field, @NonNull final String value, boolean readOnly, @NonNull View.OnClickListener onClickListener) { final TextView textView = (TextView) inflater.inflate(R.layout.edit_user_profile_field, parent, false); final SpannableString formattedValue = new SpannableString(value); formattedValue.setSpan( new ForegroundColorSpan(parent.getResources().getColor(R.color.edx_grayscale_neutral_dark)), 0, formattedValue.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText( ResourceUtil.getFormattedString( parent.getResources(), R.string.edit_user_profile_field, new HashMap<String, CharSequence>() { { put("label", field.getLabel()); put("value", formattedValue); } })); Context context = parent.getContext(); TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds( textView, null, null, new IconDrawable(context, FontAwesomeIcons.fa_angle_right) .colorRes(context, R.color.edx_grayscale_neutral_light) .sizeDp(context, 24), null); if (readOnly) { textView.setEnabled(false); textView.setBackgroundColor( textView.getResources().getColor(R.color.edx_grayscale_neutral_x_light)); } else { textView.setOnClickListener(onClickListener); } parent.addView(textView); return textView; }
/** * Fills selected bitmaps data, showing amount of loaded bitmaps and setting image data container * visibility accordingly. Updates image data header. */ private void fillSelectedBitmapsData() { int count = mSelectedBitmaps.size(); int sizeMB = getEstimatedSizeMB(); if (count > 0) { fillImageData(); if (mImageInformationContainer.getVisibility() != View.VISIBLE) { mImageInformationContainer.setVisibility(View.VISIBLE); } // would be strange to have 0MB even though there are images selected sizeMB = Math.max(1, sizeMB); } else { mImageInformationContainer.setVisibility(View.GONE); } mBitmapsDescr.setText( mBitmapsDescr .getResources() .getString(R.string.bundle_creator_bitmaps_descr, count, sizeMB)); mBitmapsSelect.setEnabled(true); fillImageHeaderData(); }
/** * Checks and updates all status indicators, updates current image's status indicators. If all * checks are passed, the bundle is allowed to save. */ private void updateStatus() { String userOrigin = User.getInstance().getOriginName(); boolean originOk = userOrigin != null && userOrigin.equals(mOriginName.getText().toString().trim()); applyStatus(mOriginStatus, originOk); boolean bundleNameOk = mBundleNameText != null && mBundleNameText.equals(mBundleName.getText().toString().trim()); applyStatus(mBundleNameStatus, bundleNameOk); boolean bitmapsOk = mSelectedBitmaps.size() > 0 && mBitmapsSelectCount == 0; applyStatus(mBitmapsStatus, bitmapsOk); boolean imageInformationOk = getCompletedImageDataCount() == mSelectedBitmaps.size() && mSelectedBitmaps.size() > 0; applyStatus(mImageStatus, imageInformationOk); boolean allOk = originOk && bundleNameOk && bitmapsOk && imageInformationOk; mSave.setEnabled(allOk); if (allOk) { if (mSaveResult == ImageXmlWriter.RESULT_SUCCESS) { mProgressText.setText(R.string.bundle_creator_progress_saved); } else if (mSaveResult == ImageXmlWriter.RESULT_NONE) { mProgressText.setText(R.string.bundle_creator_progress_ready_to_save); } else { mProgressText.setText( mProgressText .getResources() .getString(R.string.bundle_creator_progress_error_result, mSaveResult)); } mSave.setCompoundDrawablesWithIntrinsicBounds(0, 0, ACCEPT_RESOURCE, 0); } else { mSaving = false; mSave.setCompoundDrawablesWithIntrinsicBounds(0, 0, REFUSE_RESOURCE, 0); mProgressText.setText(R.string.bundle_creator_progress_info_missing); } updateCurrentImageStatus(); fillImageHeaderData(); }
public static void updateFontSize(TextView v, int dimensId) { if (v != null) { v.setTextSize(TypedValue.COMPLEX_UNIT_PX, v.getResources().getDimensionPixelSize(dimensId)); } }
public void testGoNStepsBackBrick() { ScriptActivity activity = (ScriptActivity) solo.getCurrentActivity(); ScriptFragment fragment = (ScriptFragment) activity.getFragment(ScriptActivity.FRAGMENT_SCRIPTS); BrickAdapter adapter = fragment.getAdapter(); int childrenCount = adapter.getChildCountFromLastGroup(); int groupCount = adapter.getScriptCount(); assertEquals( "Incorrect number of bricks.", 2, solo.getCurrentViews(ListView.class).get(0).getChildCount()); assertEquals("Incorrect number of bricks.", 1, childrenCount); ArrayList<Brick> projectBrickList = project.getSpriteList().get(0).getScript(0).getBrickList(); assertEquals("Incorrect number of bricks.", 1, projectBrickList.size()); assertEquals( "Wrong Brick instance.", projectBrickList.get(0), adapter.getChild(groupCount - 1, 0)); assertNotNull("TextView does not exist.", solo.getText(solo.getString(R.string.brick_move))); UiTestUtils.testBrickWithFormulaEditor( solo, ProjectManager.getInstance().getCurrentSprite(), R.id.brick_move_n_steps_edit_text, STEPS_TO_MOVE, Brick.BrickField.STEPS, moveNStepsBrick); UiTestUtils.insertValueViaFormulaEditor(solo, R.id.brick_move_n_steps_edit_text, STEPS_TO_MOVE); try { assertEquals( "Wrong text in field.", STEPS_TO_MOVE, (moveNStepsBrick.getFormulaWithBrickField(Brick.BrickField.STEPS)).interpretDouble(null)); } catch (InterpretationException interpretationException) { fail("Wrong text in field."); } assertEquals( "Value in Brick is not updated.", STEPS_TO_MOVE, Double.valueOf( ((TextView) solo.getView(R.id.brick_move_n_steps_edit_text)) .getText() .toString() .replace(',', '.'))); UiTestUtils.insertValueViaFormulaEditor(solo, R.id.brick_move_n_steps_edit_text, 1); TextView stepTextView = (TextView) solo.getView(R.id.brick_move_n_steps_step_text_view); assertTrue( "Specifier hasn't changed from plural to singular", stepTextView .getText() .equals( stepTextView .getResources() .getQuantityString(R.plurals.brick_move_n_step_plural, 1))); UiTestUtils.insertValueViaFormulaEditor(solo, R.id.brick_move_n_steps_edit_text, 1.4); stepTextView = (TextView) solo.getView(R.id.brick_move_n_steps_step_text_view); assertTrue( "Specifier hasn't changed from singular to plural", stepTextView .getText() .equals( stepTextView .getResources() .getQuantityString( R.plurals.brick_move_n_step_plural, Utils.convertDoubleToPluralInteger(1.4)))); }
public void setSel(TextView textView, TextView selTextViewFlag) { textView.setTextColor(textView.getResources().getColor(R.color.color_them)); selTextViewFlag.setVisibility(View.VISIBLE); }
/** * Will set text color of a TextView. * * @param viewId The view id. * @param textColorRes The text color resource id. * @return The BaseAdapterHelper for chaining. */ public BaseRcvAdapterHelper setTextColorRes(int viewId, int textColorRes) { TextView view = retrieveView(viewId); view.setTextColor(view.getResources().getColor(textColorRes)); return this; }