Java Code Examples for androidx.core.content.res.ResourcesCompat#getColor()

The following examples show how to use androidx.core.content.res.ResourcesCompat#getColor() . 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: NavigationViewTest.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@Test
public void testTextColor() {
  // Open our drawer
  onView(withId(R.id.drawer_layout)).perform(openDrawer(GravityCompat.START));

  final Resources res = activityTestRule.getActivity().getResources();
  final @ColorInt int defaultTextColor =
      ResourcesCompat.getColor(res, R.color.emerald_text, null);

  // Check the default text color of the menu items in our NavigationView
  for (int i = 0; i < MENU_CONTENT_ITEM_IDS.length; i++) {
    onView(
            allOf(
                withText(menuStringContent.get(MENU_CONTENT_ITEM_IDS[i])),
                isDescendantOfA(withId(R.id.start_drawer))))
        .check(matches(withTextColor(defaultTextColor)));
  }

  // Set a new text color on our NavigationView
  onView(withId(R.id.start_drawer))
      .perform(
          setItemTextColor(
              ResourcesCompat.getColorStateList(res, R.color.color_state_list_lilac, null)));

  // And check that all the menu items have the new color
  final @ColorInt int newTextColor = ResourcesCompat.getColor(res, R.color.lilac_default, null);
  for (int i = 0; i < MENU_CONTENT_ITEM_IDS.length; i++) {
    onView(
            allOf(
                withText(menuStringContent.get(MENU_CONTENT_ITEM_IDS[i])),
                isDescendantOfA(withId(R.id.start_drawer))))
        .check(matches(withTextColor(newTextColor)));
  }
}
 
Example 2
Source File: ThreadListAdapter.java    From mimi-reader with Apache License 2.0 5 votes vote down vote up
public ThreadListAdapter(@NonNull final ChanThread thread) {
    this.items.addAll(thread.getPosts());
    this.boardName = thread.getBoardName();
    this.threadId = thread.getThreadId();
    final Context context = MimiApplication.getInstance().getApplicationContext();

    this.flagUrl = MimiUtil.https() + context.getString(R.string.flag_int_link);
    this.trollUrl = MimiUtil.https() + context.getString(R.string.flag_pol_link);

    if (MimiUtil.getInstance().getTheme() == MimiUtil.THEME_LIGHT) {
        defaultPostBackground = R.color.row_item_background_light;
        highlightPostBackground = R.color.post_highlight_light;
        highlightTextBackground = ResourcesCompat.getColor(context.getResources(), R.color.text_highlight_background_light, context.getTheme());
        selectedTextBackground = ResourcesCompat.getColor(context.getResources(), R.color.text_select_background_light, context.getTheme());
    } else if (MimiUtil.getInstance().getTheme() == MimiUtil.THEME_DARK) {
        defaultPostBackground = R.color.row_item_background_dark;
        highlightPostBackground = R.color.post_highlight_dark;
        highlightTextBackground = ResourcesCompat.getColor(context.getResources(), R.color.text_highlight_background_dark, context.getTheme());
        selectedTextBackground = ResourcesCompat.getColor(context.getResources(), R.color.text_select_background_dark, context.getTheme());
    } else {
        defaultPostBackground = R.color.row_item_background_black;
        highlightPostBackground = R.color.post_highlight_black;
        highlightTextBackground = ResourcesCompat.getColor(context.getResources(), R.color.text_highlight_background_black, context.getTheme());
        selectedTextBackground = ResourcesCompat.getColor(context.getResources(), R.color.text_select_background_black, context.getTheme());
    }

    Pair<VectorDrawableCompat, VectorDrawableCompat> metadataDrawables = initMetadataDrawables();
    pinDrawable = metadataDrawables.first;
    lockDrawable = metadataDrawables.second;

    Context appContext = MimiApplication.getInstance().getApplicationContext();
    imageSpoilersEnabled = MimiPrefs.imageSpoilersEnabled(appContext);
    spoilerUrl = MimiUtil.https() + appContext.getString(R.string.spoiler_link) + appContext.getString(R.string.spoiler_path);
    customSpoilerUrl = MimiUtil.https() + appContext.getString(R.string.spoiler_link) + appContext.getString(R.string.custom_spoiler_path);

    setupThread();

}
 
Example 3
Source File: ColorUtil.java    From BLE-Indoor-Positioning with Apache License 2.0 5 votes vote down vote up
private static int[] getColors(@NonNull Context context, int[] colorResourceIds) {
    Resources resources = context.getResources();
    int[] colors = new int[colorResourceIds.length];
    for (int colorIndex = 0; colorIndex < colorResourceIds.length; colorIndex++) {
        colors[colorIndex] = ResourcesCompat.getColor(resources, colorResourceIds[colorIndex], null);
    }
    return colors;
}
 
Example 4
Source File: BadgeDrawableTest.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@Test
public void testSavedState() {
  int testBackgroundColor =
      ResourcesCompat.getColor(
          context.getResources(), android.R.color.holo_purple, context.getTheme());
  int testBadgeTextColor =
      ResourcesCompat.getColor(context.getResources(), android.R.color.white, context.getTheme());
  BadgeDrawable badgeDrawable = BadgeDrawable.create(context);
  SavedState drawableState = badgeDrawable.getSavedState();
  badgeDrawable.setNumber(TEST_BADGE_NUMBER);
  badgeDrawable.setBadgeGravity(BadgeDrawable.TOP_START);

  badgeDrawable.setHorizontalOffset(TEST_BADGE_HORIZONTAL_OFFSET);
  badgeDrawable.setVerticalOffset(TEST_BADGE_VERTICAL_OFFSET);

  badgeDrawable.setBackgroundColor(testBackgroundColor);
  badgeDrawable.setBadgeTextColor(testBadgeTextColor);

  Parcel parcel = Parcel.obtain();
  drawableState.writeToParcel(parcel, drawableState.describeContents());
  parcel.setDataPosition(0);

  SavedState createdFromParcel = SavedState.CREATOR.createFromParcel(parcel);
  BadgeDrawable restoredBadgeDrawable =
      BadgeDrawable.createFromSavedState(context, createdFromParcel);
  assertThat(restoredBadgeDrawable.getNumber()).isEqualTo(TEST_BADGE_NUMBER);
  assertThat(restoredBadgeDrawable.getBackgroundColor()).isEqualTo(testBackgroundColor);
  assertThat(restoredBadgeDrawable.getBadgeTextColor()).isEqualTo(testBadgeTextColor);
  // Values based on the default badge style.
  assertThat(restoredBadgeDrawable.getAlpha()).isEqualTo(255);
  assertThat(restoredBadgeDrawable.getMaxCharacterCount()).isEqualTo(4);
  assertThat(restoredBadgeDrawable.getBadgeGravity()).isEqualTo(BadgeDrawable.TOP_START);
  // badge offsets
  assertThat(restoredBadgeDrawable.getHorizontalOffset()).isEqualTo(TEST_BADGE_HORIZONTAL_OFFSET);
  assertThat(restoredBadgeDrawable.getVerticalOffset()).isEqualTo(TEST_BADGE_VERTICAL_OFFSET);
}
 
Example 5
Source File: Clock.java    From Clock-view with Apache License 2.0 5 votes vote down vote up
public void setStopwatchTheme(StopwatchTheme stopwatchTheme) {

        this.clockType = stopwatchTheme.getClockType();

        this.clockBackground = ResourcesCompat.getDrawable(getContext().getResources(), stopwatchTheme.getClockBackground(), null);

        this.valuesFont = ResourcesCompat.getFont(getContext(), stopwatchTheme.getValuesFont());
        this.valuesColor = ResourcesCompat.getColor(getContext().getResources(), stopwatchTheme.getValuesColor(), null);

        this.showBorder = stopwatchTheme.isShowBorder();
        this.borderColor = stopwatchTheme.getBorderColor();
        this.borderRadiusRx = stopwatchTheme.getBorderRadiusRx();
        this.borderRadiusRy = stopwatchTheme.getBorderRadiusRy();
    }
 
Example 6
Source File: DebugPageContentView.java    From under-the-hood with Apache License 2.0 4 votes vote down vote up
public DebugPageContentView(@NonNull Context context) {
    this(context, null, ResourcesCompat.getColor(context.getResources(), R.color.hoodlib_zebra_color, context.getTheme()));
}
 
Example 7
Source File: Clock.java    From Clock-view with Apache License 2.0 4 votes vote down vote up
public void setCenterInnerColor(int centerInnerColor) {
    this.centerInnerColor = ResourcesCompat.getColor(getContext().getResources(), centerInnerColor, null);
}
 
Example 8
Source File: NavigationViewTest.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
@Test
public void testIconTinting() {
  // Open our drawer
  onView(withId(R.id.drawer_layout)).perform(openDrawer(GravityCompat.START));

  final Resources res = activityTestRule.getActivity().getResources();
  final @ColorInt int redFill = ResourcesCompat.getColor(res, R.color.test_red, null);
  final @ColorInt int greenFill = ResourcesCompat.getColor(res, R.color.test_green, null);
  final @ColorInt int blueFill = ResourcesCompat.getColor(res, R.color.test_blue, null);
  final int iconSize = res.getDimensionPixelSize(R.dimen.drawable_small_size);
  onView(withId(R.id.start_drawer))
      .perform(
          setIconForMenuItem(
              R.id.destination_home, new TestDrawable(redFill, iconSize, iconSize)));
  onView(withId(R.id.start_drawer))
      .perform(
          setIconForMenuItem(
              R.id.destination_profile, new TestDrawable(greenFill, iconSize, iconSize)));
  onView(withId(R.id.start_drawer))
      .perform(
          setIconForMenuItem(
              R.id.destination_people, new TestDrawable(blueFill, iconSize, iconSize)));

  final @ColorInt int defaultTintColor =
      ResourcesCompat.getColor(res, R.color.emerald_translucent, null);

  // We're allowing a margin of error in checking the color of the items' icons.
  // This is due to the translucent color being used in the icon tinting
  // and off-by-one discrepancies of SRC_IN when it's compositing
  // translucent color. Note that all the checks below are written for the current
  // logic on NavigationView that uses the default SRC_IN tint mode - effectively
  // replacing all non-transparent pixels in the destination (original icon) with
  // our translucent tint color.
  final int allowedComponentVariance = 1;

  // Note that here we're tying ourselves to the implementation details of the
  // internal structure of the NavigationView. Specifically, we're checking the
  // start drawable of the text view with the specific text. If the internal
  // implementation of NavigationView changes, the second Matcher in the lookups
  // below will need to be tweaked.
  onView(
          allOf(
              withText(menuStringContent.get(R.id.destination_home)),
              isDescendantOfA(withId(R.id.start_drawer))))
      .check(matches(withStartDrawableFilledWith(defaultTintColor, allowedComponentVariance)));
  onView(
          allOf(
              withText(menuStringContent.get(R.id.destination_profile)),
              isDescendantOfA(withId(R.id.start_drawer))))
      .check(matches(withStartDrawableFilledWith(defaultTintColor, allowedComponentVariance)));
  onView(
          allOf(
              withText(menuStringContent.get(R.id.destination_people)),
              isDescendantOfA(withId(R.id.start_drawer))))
      .check(matches(withStartDrawableFilledWith(defaultTintColor, allowedComponentVariance)));

  final @ColorInt int newTintColor = ResourcesCompat.getColor(res, R.color.red_translucent, null);

  onView(withId(R.id.start_drawer))
      .perform(
          setItemIconTintList(
              ResourcesCompat.getColorStateList(
                  res, R.color.color_state_list_red_translucent, null)));
  // Check that all menu items with icons now have icons tinted with the newly set color
  onView(
          allOf(
              withText(menuStringContent.get(R.id.destination_home)),
              isDescendantOfA(withId(R.id.start_drawer))))
      .check(matches(withStartDrawableFilledWith(newTintColor, allowedComponentVariance)));
  onView(
          allOf(
              withText(menuStringContent.get(R.id.destination_profile)),
              isDescendantOfA(withId(R.id.start_drawer))))
      .check(matches(withStartDrawableFilledWith(newTintColor, allowedComponentVariance)));
  onView(
          allOf(
              withText(menuStringContent.get(R.id.destination_people)),
              isDescendantOfA(withId(R.id.start_drawer))))
      .check(matches(withStartDrawableFilledWith(newTintColor, allowedComponentVariance)));

  // And now remove all icon tinting
  onView(withId(R.id.start_drawer)).perform(setItemIconTintList(null));
  // And verify that all menu items with icons now have the original colors for their icons.
  // Note that since there is no tinting at this point, we don't allow any color variance
  // in these checks.
  onView(
          allOf(
              withText(menuStringContent.get(R.id.destination_home)),
              isDescendantOfA(withId(R.id.start_drawer))))
      .check(matches(withStartDrawableFilledWith(redFill, 0)));
  onView(
          allOf(
              withText(menuStringContent.get(R.id.destination_profile)),
              isDescendantOfA(withId(R.id.start_drawer))))
      .check(matches(withStartDrawableFilledWith(greenFill, 0)));
  onView(
          allOf(
              withText(menuStringContent.get(R.id.destination_people)),
              isDescendantOfA(withId(R.id.start_drawer))))
      .check(matches(withStartDrawableFilledWith(blueFill, 0)));
}
 
Example 9
Source File: BottomDialog.java    From ImageSaveandShare with Apache License 2.0 4 votes vote down vote up
public Builder setPositiveTextColorResource(@ColorRes int textColorRes) {
    this.btn_colorPositive = ResourcesCompat.getColor(context.getResources(), textColorRes, null);
    return this;
}
 
Example 10
Source File: NavigationViewTest.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
@Test
public void testCheckedAppearance() {
  // Open our drawer
  onView(withId(R.id.drawer_layout)).perform(openDrawer(GravityCompat.START));

  // Reconfigure our navigation view to use foreground (text) and background visuals
  // with explicitly different colors for the checked state
  final Resources res = activityTestRule.getActivity().getResources();
  onView(withId(R.id.start_drawer))
      .perform(
          setItemTextColor(
              ResourcesCompat.getColorStateList(res, R.color.color_state_list_sand, null)));
  onView(withId(R.id.start_drawer))
      .perform(setItemBackgroundResource(R.drawable.test_drawable_state_list));

  final @ColorInt int uncheckedItemForeground =
      ResourcesCompat.getColor(res, R.color.sand_default, null);
  final @ColorInt int checkedItemForeground =
      ResourcesCompat.getColor(res, R.color.sand_checked, null);
  final @ColorInt int uncheckedItemBackground =
      ResourcesCompat.getColor(res, R.color.test_green, null);
  final @ColorInt int checkedItemBackground =
      ResourcesCompat.getColor(res, R.color.test_blue, null);

  // Verify that all items are rendered with unchecked visuals
  verifyCheckedAppearance(
      0,
      uncheckedItemForeground,
      checkedItemForeground,
      uncheckedItemBackground,
      checkedItemBackground);

  // Mark one of the items as checked
  onView(withId(R.id.start_drawer)).perform(setCheckedItem(R.id.destination_profile));
  // And verify that it's now rendered with checked visuals
  verifyCheckedAppearance(
      R.id.destination_profile,
      uncheckedItemForeground,
      checkedItemForeground,
      uncheckedItemBackground,
      checkedItemBackground);

  // Register a navigation listener that "marks" the selected item
  navigationView.setNavigationItemSelectedListener(item -> true);

  // Click one of our items
  onView(
          allOf(
              withText(menuStringContent.get(R.id.destination_people)),
              isDescendantOfA(withId(R.id.start_drawer))))
      .perform(click());
  // and verify that it's now checked
  verifyCheckedAppearance(
      R.id.destination_people,
      uncheckedItemForeground,
      checkedItemForeground,
      uncheckedItemBackground,
      checkedItemBackground);

  // Register a navigation listener that doesn't "mark" the selected item
  navigationView.setNavigationItemSelectedListener(item -> false);

  // Click another items
  onView(
          allOf(
              withText(menuStringContent.get(R.id.destination_settings)),
              isDescendantOfA(withId(R.id.start_drawer))))
      .perform(click());
  // and verify that the checked state remains on the previously clicked item
  // since the current navigation listener returns false from its callback
  // implementation
  verifyCheckedAppearance(
      R.id.destination_people,
      uncheckedItemForeground,
      checkedItemForeground,
      uncheckedItemBackground,
      checkedItemBackground);
}
 
Example 11
Source File: Clock.java    From Clock-view with Apache License 2.0 4 votes vote down vote up
public void setNumericTheme(NumericTheme numericTheme) {

        this.clockType = numericTheme.getClockType();

        this.clockBackground = ResourcesCompat.getDrawable(getContext().getResources(), numericTheme.getClockBackground(), null);

        this.valuesFont = ResourcesCompat.getFont(getContext(), numericTheme.getValuesFont());
        this.valuesColor = ResourcesCompat.getColor(getContext().getResources(), numericTheme.getValuesColor(), null);

        this.showBorder = numericTheme.isShowBorder();
        this.borderColor = numericTheme.getBorderColor();
        this.borderRadiusRx = numericTheme.getBorderRadiusRx();
        this.borderRadiusRy = numericTheme.getBorderRadiusRy();

        this.numericFormat = numericTheme.getNumericFormat();
    }
 
Example 12
Source File: Clock.java    From Clock-view with Apache License 2.0 4 votes vote down vote up
public void setAnalogicalTheme(AnalogicalTheme analogicalTheme) {

        this.clockType = analogicalTheme.getClockType();

        this.clockBackground = ResourcesCompat.getDrawable(getContext().getResources(), analogicalTheme.getClockBackground(), null);

        this.showCenter = analogicalTheme.isShowCenter();
        this.centerInnerColor = analogicalTheme.getCenterInnerColor();
        this.centerOuterColor = analogicalTheme.getCenterOuterColor();

        this.showBorder = analogicalTheme.isShowBorder();
        this.borderColor = analogicalTheme.getBorderColor();

        this.showSecondsNeedle = analogicalTheme.isShowSecondsNeedle();
        this.needleHoursColor = analogicalTheme.getNeedleHoursColor();
        this.needleMinutesColor = analogicalTheme.getNeedleMinutesColor();
        this.needleSecondsColor = analogicalTheme.getNeedleSecondsColor();

        this.showProgress = analogicalTheme.isShowProgress();
        this.progressColor = analogicalTheme.getProgressColor();
        this.showMinutesProgress = analogicalTheme.isShowMinutesProgress();
        this.minutesProgressColor = analogicalTheme.getMinutesProgressColor();
        this.minutesProgressFactor = analogicalTheme.getMinutesProgressFactor();
        this.showSecondsProgress = analogicalTheme.isShowSecondsProgress();
        this.secondsProgressColor = analogicalTheme.getSecondsProgressColor();
        this.secondsProgressFactor = analogicalTheme.getSecondsProgressFactor();

        this.showDegrees = analogicalTheme.isShowDegrees();
        this.degreesColor = ResourcesCompat.getColor(getContext().getResources(), analogicalTheme.getDegreesColor(), null);
        this.degreesType = analogicalTheme.getDegreesType();
        this.degreesStep = analogicalTheme.getDegreesStep();

        this.valuesFont = ResourcesCompat.getFont(getContext(), analogicalTheme.getValuesFont());
        this.valuesColor = ResourcesCompat.getColor(getContext().getResources(), analogicalTheme.getValuesColor(), null);
        this.showHoursValues = analogicalTheme.isShowHoursValues();
        this.showMinutesValues = analogicalTheme.isShowMinutesValues();
        this.minutesValuesFactor = analogicalTheme.getMinutesValuesFactor();
        this.valueStep = analogicalTheme.getValueStep();
        this.valueType = analogicalTheme.getValueType();
        this.valueDisposition = analogicalTheme.getValueDisposition();
    }
 
Example 13
Source File: BottomSheetBuilder.java    From SimplicityBrowser with MIT License 4 votes vote down vote up
public BottomSheetBuilder setTitleTextColorResource(@ColorRes int color) {
    mTitleTextColor = ResourcesCompat.getColor(mContext.getResources(), color,
            mContext.getTheme());
    return this;
}
 
Example 14
Source File: Clock.java    From Clock-view with Apache License 2.0 4 votes vote down vote up
public void setSecondsNeedleColor(int needleSecondsColor) {
    this.needleSecondsColor = ResourcesCompat.getColor(getContext().getResources(), needleSecondsColor, null);
}
 
Example 15
Source File: Clock.java    From Clock-view with Apache License 2.0 4 votes vote down vote up
public void setMinutesNeedleColor(int needleMinutesColor) {
    this.needleMinutesColor = ResourcesCompat.getColor(getContext().getResources(), needleMinutesColor, null);
}
 
Example 16
Source File: Clock.java    From Clock-view with Apache License 2.0 4 votes vote down vote up
public void setHoursNeedleColor(int needleHoursColor) {
    this.needleHoursColor = ResourcesCompat.getColor(getContext().getResources(), needleHoursColor, null);
}
 
Example 17
Source File: Clock.java    From Clock-view with Apache License 2.0 4 votes vote down vote up
public void setBorderColor(int borderColor) {
    this.borderColor = ResourcesCompat.getColor(getContext().getResources(), borderColor, null);
}
 
Example 18
Source File: BottomNavigationViewTest.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
@Test
@SmallTest
public void testIconTinting() {
  final Resources res = activityTestRule.getActivity().getResources();
  @ColorInt final int redFill = ResourcesCompat.getColor(res, R.color.test_red, null);
  @ColorInt final int greenFill = ResourcesCompat.getColor(res, R.color.test_green, null);
  @ColorInt final int blueFill = ResourcesCompat.getColor(res, R.color.test_blue, null);
  final int iconSize = res.getDimensionPixelSize(R.dimen.drawable_small_size);
  onView(withId(R.id.bottom_navigation))
      .perform(
          setIconForMenuItem(
              R.id.destination_home, new TestDrawable(redFill, iconSize, iconSize)));
  onView(withId(R.id.bottom_navigation))
      .perform(
          setIconForMenuItem(
              R.id.destination_profile, new TestDrawable(greenFill, iconSize, iconSize)));
  onView(withId(R.id.bottom_navigation))
      .perform(
          setIconForMenuItem(
              R.id.destination_people, new TestDrawable(blueFill, iconSize, iconSize)));

  @ColorInt
  final int defaultTintColor = ResourcesCompat.getColor(res, R.color.emerald_translucent, null);

  // We're allowing a margin of error in checking the color of the items' icons.
  // This is due to the translucent color being used in the icon tinting
  // and off-by-one discrepancies of SRC_IN when it's compositing
  // translucent color. Note that all the checks below are written for the current
  // logic on BottomNavigationView that uses the default SRC_IN tint mode - effectively
  // replacing all non-transparent pixels in the destination (original icon) with
  // our translucent tint color.
  final int allowedComponentVariance = 1;

  // Note that here we're tying ourselves to the implementation details of the internal
  // structure of the BottomNavigationView. Specifically, we're checking the drawable the
  // ImageView with id R.id.icon. If the internal implementation of BottomNavigationView
  // changes, the second Matcher in the lookups below will need to be tweaked.
  onView(allOf(withId(R.id.icon), isDescendantOfA(withId(R.id.destination_home))))
      .check(matches(TestUtilsMatchers.drawable(defaultTintColor, allowedComponentVariance)));
  onView(allOf(withId(R.id.icon), isDescendantOfA(withId(R.id.destination_profile))))
      .check(matches(TestUtilsMatchers.drawable(defaultTintColor, allowedComponentVariance)));
  onView(allOf(withId(R.id.icon), isDescendantOfA(withId(R.id.destination_people))))
      .check(matches(TestUtilsMatchers.drawable(defaultTintColor, allowedComponentVariance)));

  @ColorInt final int newTintColor = ResourcesCompat.getColor(res, R.color.red_translucent, null);
  onView(withId(R.id.bottom_navigation))
      .perform(
          setItemIconTintList(
              ResourcesCompat.getColorStateList(
                  res, R.color.color_state_list_red_translucent, null)));
  // Check that all menu items with icons now have icons tinted with the newly set color
  onView(allOf(withId(R.id.icon), isDescendantOfA(withId(R.id.destination_home))))
      .check(matches(TestUtilsMatchers.drawable(newTintColor, allowedComponentVariance)));
  onView(allOf(withId(R.id.icon), isDescendantOfA(withId(R.id.destination_profile))))
      .check(matches(TestUtilsMatchers.drawable(newTintColor, allowedComponentVariance)));
  onView(allOf(withId(R.id.icon), isDescendantOfA(withId(R.id.destination_people))))
      .check(matches(TestUtilsMatchers.drawable(newTintColor, allowedComponentVariance)));

  // And now remove all icon tinting
  onView(withId(R.id.bottom_navigation)).perform(setItemIconTintList(null));
  // And verify that all menu items with icons now have the original colors for their icons.
  // Note that since there is no tinting at this point, we don't allow any color variance
  // in these checks.
  onView(allOf(withId(R.id.icon), isDescendantOfA(withId(R.id.destination_home))))
      .check(matches(TestUtilsMatchers.drawable(redFill, allowedComponentVariance)));
  onView(allOf(withId(R.id.icon), isDescendantOfA(withId(R.id.destination_profile))))
      .check(matches(TestUtilsMatchers.drawable(greenFill, allowedComponentVariance)));
  onView(allOf(withId(R.id.icon), isDescendantOfA(withId(R.id.destination_people))))
      .check(matches(TestUtilsMatchers.drawable(blueFill, allowedComponentVariance)));
}
 
Example 19
Source File: Clock.java    From Clock-view with Apache License 2.0 3 votes vote down vote up
public void setTimeCounterTheme(TimeCounterTheme timeCounterTheme) {

        this.clockType = timeCounterTheme.getClockType();

        this.clockBackground = ResourcesCompat.getDrawable(getContext().getResources(), timeCounterTheme.getClockBackground(), null);

        this.valuesFont = ResourcesCompat.getFont(getContext(), timeCounterTheme.getValuesFont());
        this.valuesColor = ResourcesCompat.getColor(getContext().getResources(), timeCounterTheme.getValuesColor(), null);

        this.showProgress = timeCounterTheme.isShowProgress();
        this.progressColor = timeCounterTheme.getProgressColor();
        this.borderColor = timeCounterTheme.getBorderColor();
    }
 
Example 20
Source File: SkyTubeApp.java    From SkyTube with GNU General Public License v3.0 2 votes vote down vote up
/**
 * @param colorId   Color resource ID (e.g. R.color.green).
 *
 * @return The color for the given color resource id.
 */
public static int getColorEx(int colorId) {
	return ResourcesCompat.getColor(skyTubeApp.getResources(), colorId, null);
}