Exemplo n.º 1
0
 @Override
 public void setOpened(boolean opened) {
   title.setTextColor(
       opened
           ? ColorStateList.valueOf(SettingsPreferences.getInstance().getPrimaryColor())
           : ColorStateList.valueOf(resources.getColor(R.color.primary_text_dark)));
 }
 private int getCurrentTitleTextColor() {
   if (mAttributes.getTitleTextColor() == null) {
     ColorStateList colors = getHintTextColors();
     if (colors == null) return getCurrentHintTextColor();
     else return colors.getColorForState(getDrawableState(), 0);
   } else return mAttributes.getTitleTextColor().getColorForState(getDrawableState(), 0);
 }
  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;
  }
Exemplo n.º 4
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   AppController.getController().getBus().register(this);
   manager = new GridLayoutManager(this, getResources().getInteger(R.integer.num_row));
   recycler.setItemAnimator(new DefaultItemAnimator());
   recycler.setHasFixedSize(true);
   recycler.setLayoutManager(manager);
   mDrawerLayout.setStatusBarBackgroundColor(
       AppHelper.getPrimaryDarkColor(AppHelper.getPrimaryColor(this)));
   navigationView.setItemIconTintList(ColorStateList.valueOf(AppHelper.getAccentColor(this)));
   if (AppHelper.isDarkTheme(this)) {
     navigationView.setItemTextColor(ColorStateList.valueOf(AppHelper.getAccentColor(this)));
   }
   adapter = new AppsAdapter(this, new ArrayList<AppsModel>());
   recycler.setAdapter(adapter);
   mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
   if (navigationView != null) {
     setupDrawerContent(navigationView);
   }
   getLoaderManager().restartLoader(0, null, this);
   productsList.addAll(Arrays.asList(getResources().getStringArray(R.array.in_app_billing)));
   mHelper = new IabHelper(this, getString(R.string.base64));
   mHelper.startSetup(mPurchaseFinishedListener);
   showWhatsNew();
   countBackup();
 }
  public ChartGridView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setWillNotDraw(false);

    final TypedArray a =
        context.obtainStyledAttributes(attrs, R.styleable.ChartGridView, defStyle, 0);

    mPrimary = a.getDrawable(R.styleable.ChartGridView_primaryDrawable);
    mSecondary = a.getDrawable(R.styleable.ChartGridView_secondaryDrawable);
    mBorder = a.getDrawable(R.styleable.ChartGridView_borderDrawable);

    final int taId = a.getResourceId(R.styleable.ChartGridView_android_textAppearance, -1);
    final TypedArray ta =
        context.obtainStyledAttributes(taId, com.android.internal.R.styleable.TextAppearance);
    mLabelSize =
        ta.getDimensionPixelSize(com.android.internal.R.styleable.TextAppearance_textSize, 0);
    ta.recycle();

    final ColorStateList labelColor =
        a.getColorStateList(R.styleable.ChartGridView_android_textColor);
    mLabelColor = labelColor.getDefaultColor();

    a.recycle();
  }
Exemplo n.º 6
0
 private void updateTint() {
   if (tint == null) tint = new TintPrimaryColorStateList(getContext());
   int color = tint.getColorForState(getDrawableState(), tint.getDefaultColor());
   if (leftGlow != null) leftGlow.setColor(color);
   if (rightGlow != null) rightGlow.setColor(color);
   postInvalidate();
 }
 /**
  * Sets the color of the seek thumb, as well as the color of the popup indicator.
  *
  * @param thumbColorStateList The ColorStateList the seek thumb will be changed to
  * @param indicatorColor The color the popup indicator will be changed to The indicator will
  *     animate from thumbColorStateList(pressed state) to indicatorColor when opening
  */
 public void setThumbColor(@NonNull ColorStateList thumbColorStateList, int indicatorColor) {
   mThumb.setColorStateList(thumbColorStateList);
   // we use the "pressed" color to morph the indicator from it to its own color
   int thumbColor =
       thumbColorStateList.getColorForState(
           new int[] {PRESSED_STATE}, thumbColorStateList.getDefaultColor());
   mIndicator.setColors(indicatorColor, thumbColor);
 }
 public MarkerDrawable(@NonNull ColorStateList tintList, int closedSize) {
   super(tintList);
   mInterpolator = new AccelerateDecelerateInterpolator();
   mClosedStateSize = closedSize;
   mStartColor =
       tintList.getColorForState(
           new int[] {android.R.attr.state_pressed}, tintList.getDefaultColor());
   mEndColor = tintList.getDefaultColor();
 }
Exemplo n.º 9
0
 private static ColorStateList createNavigationItemTintList(
     int baseColorAttrRes, int primaryColor, Context context) {
   ColorStateList baseColor = ViewUtils.getColorStateListFromAttrRes(baseColorAttrRes, context);
   int defaultColor = baseColor.getDefaultColor();
   return new ColorStateList(
       new int[][] {DISABLED_STATE_SET, CHECKED_STATE_SET, EMPTY_STATE_SET},
       new int[] {
         baseColor.getColorForState(DISABLED_STATE_SET, defaultColor), primaryColor, defaultColor
       });
 }
 public AlmostRippleDrawable(@NonNull ColorStateList tintStateList) {
   super(tintStateList);
   mInterpolator = new AccelerateDecelerateInterpolator();
   mFocusedColor =
       tintStateList.getColorForState(new int[] {android.R.attr.state_focused}, 0xFFFF0000);
   mPressedColor =
       tintStateList.getColorForState(new int[] {android.R.attr.state_pressed}, 0xFFFF0000);
   mDisabledColor =
       tintStateList.getColorForState(new int[] {-android.R.attr.state_enabled}, 0xFFFF0000);
 }
 @Override
 public void setColorStateList(ColorStateList tintStateList) {
   super.setColorStateList(tintStateList);
   mFocusedColor =
       tintStateList.getColorForState(new int[] {android.R.attr.state_focused}, 0xFFFF0000);
   mPressedColor =
       tintStateList.getColorForState(new int[] {android.R.attr.state_pressed}, 0xFFFF0000);
   mDisabledColor =
       tintStateList.getColorForState(new int[] {-android.R.attr.state_enabled}, 0xFFFF0000);
 }
  public void setBorderColor(ColorStateList colors) {
    if (borderColor.equals(colors)) {
      return;
    }

    borderColor =
        (colors != null) ? colors : ColorStateList.valueOf(RoundedDrawable.DEFAULT_BORDER_COLOR);
    updateDrawableAttrs();
    updateBackgroundDrawableAttrs(false);
    if (borderWidth > 0) {
      invalidate();
    }
  }
 private void applyIconTint() {
   for (int i = 0; i < mStatusIcons.getChildCount(); i++) {
     StatusBarIconView v = (StatusBarIconView) mStatusIcons.getChildAt(i);
     v.setImageTintList(ColorStateList.valueOf(mIconTint));
   }
   mSignalCluster.setIconTint(mIconTint, mDarkIntensity);
   mMoreIcon.setImageTintList(ColorStateList.valueOf(mIconTint));
   mBatteryMeterView.setDarkIntensity(mDarkIntensity);
   mClockController.setTextColor(mIconTint);
   mCarrier.setTextColor(mIconTint);
   mNetworkTraffic.setDarkIntensity(mDarkIntensity);
   applyNotificationIconsTint();
 }
 @Override
 protected boolean onStateChange(int[] stateSet) {
   final int newColor = mBackground.getColorForState(stateSet, mBackground.getDefaultColor());
   final boolean colorChanged = newColor != mPaint.getColor();
   if (colorChanged) {
     mPaint.setColor(newColor);
   }
   if (mTint != null && mTintMode != null) {
     mTintFilter = createTintFilter(mTint, mTintMode);
     return true;
   }
   return colorChanged;
 }
Exemplo n.º 15
0
 public static ColorStateList getTextColor(Context context, int type) {
   // Colors and font weight
   switch (type) {
     case FontManager.TEXT_TYPE_PRIMARY:
       boolean isNight =
           ThemeManager.getTheme() == ThemeManager.Theme.GREY
               || ThemeManager.getTheme() == ThemeManager.Theme.BLACK;
       int id = isNight ? R.color.text_primary_dark : R.color.text_primary_light;
       return context.getResources().getColorStateList(id);
     case FontManager.TEXT_TYPE_SECONDARY:
       return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundSecondary());
     case FontManager.TEXT_TYPE_TERTIARY:
       return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundSecondary());
     case FontManager.TEXT_TYPE_CATEGORY:
       return ColorStateList.valueOf(ThemeManager.getColor());
     case FontManager.TEXT_TYPE_DIALOG_TITLE:
       return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundPrimary());
     case FontManager.TEXT_TYPE_DIALOG_MESSAGE:
       return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundSecondary());
     case FontManager.TEXT_TYPE_DIALOG_BUTTON:
       return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundPrimary());
     case FontManager.TEXT_TYPE_TOOLBAR:
       return ColorStateList.valueOf(ThemeManager.getTextOnColorPrimary());
   }
   return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundPrimary());
 }
Exemplo n.º 16
0
 /** This method is idempotent so it only has effect the first time it's called */
 private void init(Context context) {
   if (mInitialised) {
     return;
   }
   mInitialised = true;
   mDraweeHolder = DraweeHolder.create(null, context);
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
     ColorStateList imageTintList = getImageTintList();
     if (imageTintList == null) {
       return;
     }
     setColorFilter(imageTintList.getDefaultColor());
   }
 }
 private boolean updateTint(int ai[]) {
   if (mTintList != null && mTintMode != null) {
     int i = mTintList.getColorForState(ai, mTintList.getDefaultColor());
     ai = mTintMode;
     if (!mColorFilterSet || i != mCurrentColor || ai != mCurrentMode) {
       setColorFilter(i, ai);
       mCurrentColor = i;
       mCurrentMode = ai;
       mColorFilterSet = true;
       return true;
     }
   }
   return false;
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_map_maker);

    ButterKnife.bind(this);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    board.setEditMode(true);

    radioEmpty.setChecked(true);

    radioEmpty.setButtonTintList(ColorStateList.valueOf(Config.COLOR_BACKGROUND));
    radioWall.setButtonTintList(ColorStateList.valueOf(Config.COLOR_WALL));
    radioStart.setButtonTintList(ColorStateList.valueOf(Config.COLOR_START));
    radioGoal.setButtonTintList(ColorStateList.valueOf(Config.COLOR_GOAL));

    // See if we are to edit an existing level
    if (getIntent().hasExtra("level")) {
      String levelName = getIntent().getStringExtra("level");
      level = QvikPuzzleApplication.getInstance().getLevelUtil().loadLevelFromDisk(levelName);
    } else { // or are we creating a new level.
      // use the original/default
      level = QvikPuzzleApplication.getInstance().getLevelUtil().getDefaultLevel();
      if (level == null) {
        level = new Level();
      }
      // Generate name with timestamp
      level.setName("Level_" + new Date().getTime());
    }

    if (level != null) {
      board.setLevel(level);
      int[] start = level.getStart();
      board.setPlayerStart(start[1], start[0], level.getStartOrientation());
    } else {
      Toast.makeText(MapMakerActivity.this, "Level load failed", Toast.LENGTH_SHORT).show();
      finish();
      return;
    }

    fill_empty.setOnClickListener(this);
    save.setOnClickListener(this);
    fill_wall.setOnClickListener(this);
    playerOrientation.setOnClickListener(this);
  }
Exemplo n.º 19
0
  /** Reset the ordering buttons to their default state */
  private void resetOrderingButtons() {
    Button hourlyButton = (Button) findViewById(R.id.hourly_button);
    Button ratingButton = (Button) findViewById(R.id.rating_button);

    Drawable noArrow = ContextCompat.getDrawable(this, R.drawable.ic_remove_black_24dp);

    hourlyButton.setCompoundDrawablesWithIntrinsicBounds(null, null, noArrow, null);
    ratingButton.setCompoundDrawablesWithIntrinsicBounds(null, null, noArrow, null);

    setButtonTint(
        hourlyButton,
        ColorStateList.valueOf(ContextCompat.getColor(this, R.color.button_material_light)));
    setButtonTint(
        ratingButton,
        ColorStateList.valueOf(ContextCompat.getColor(this, R.color.button_material_light)));
  }
 void setDaySelectorColor(ColorStateList dayBackgroundColor) {
   final int activatedColor =
       dayBackgroundColor.getColorForState(
           StateSet.get(StateSet.VIEW_STATE_ENABLED | StateSet.VIEW_STATE_ACTIVATED), 0);
   mDaySelectorPaint.setColor(activatedColor);
   invalidate();
 }
Exemplo n.º 21
0
  public static RippleDrawable createRipple(
      Palette palette,
      @FloatRange(from = 0f, to = 1f) float darkAlpha,
      @FloatRange(from = 0f, to = 1f) float lightAlpha,
      @ColorInt int fallbackColor,
      boolean bounded) {
    int rippleColor = fallbackColor;
    // try the named swatches in preference order
    if (palette != null) {
      if (palette.getVibrantSwatch() != null) {
        rippleColor = ColorUtils.modifyAlpha(palette.getVibrantSwatch().getRgb(), darkAlpha);
      } else if (palette.getLightVibrantSwatch() != null) {
        rippleColor = ColorUtils.modifyAlpha(palette.getLightVibrantSwatch().getRgb(), lightAlpha);
      } else if (palette.getDarkVibrantSwatch() != null) {
        rippleColor = ColorUtils.modifyAlpha(palette.getDarkVibrantSwatch().getRgb(), darkAlpha);
      } else if (palette.getMutedSwatch() != null) {
        rippleColor = ColorUtils.modifyAlpha(palette.getMutedSwatch().getRgb(), darkAlpha);
      } else if (palette.getLightMutedSwatch() != null) {
        rippleColor = ColorUtils.modifyAlpha(palette.getLightMutedSwatch().getRgb(), lightAlpha);
      } else if (palette.getDarkMutedSwatch() != null) {
        rippleColor = ColorUtils.modifyAlpha(palette.getDarkMutedSwatch().getRgb(), darkAlpha);
      }
    }

    return new RippleDrawable(
        ColorStateList.valueOf(rippleColor), null, bounded ? new ColorDrawable(Color.WHITE) : null);
  }
 /** Ensures the tint filter is consistent with the current tint color and mode. */
 private PorterDuffColorFilter createTintFilter(ColorStateList tint, PorterDuff.Mode tintMode) {
   if (tint == null || tintMode == null) {
     return null;
   }
   final int color = tint.getColorForState(getState(), Color.TRANSPARENT);
   return new PorterDuffColorFilter(color, tintMode);
 }
 void setDayHighlightColor(ColorStateList dayHighlightColor) {
   final int pressedColor =
       dayHighlightColor.getColorForState(
           StateSet.get(StateSet.VIEW_STATE_ENABLED | StateSet.VIEW_STATE_PRESSED), 0);
   mDayHighlightPaint.setColor(pressedColor);
   invalidate();
 }
Exemplo n.º 24
0
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    // Draw the switch
    int switchLeft = mSwitchLeft;
    int switchTop = mSwitchTop;
    int switchRight = mSwitchRight;
    int switchBottom = mSwitchBottom;

    mTrackDrawable.setBounds(switchLeft, switchTop, switchRight, switchBottom);
    mTrackDrawable.draw(canvas);

    canvas.save();

    mTrackDrawable.getPadding(mTempRect);
    int switchInnerLeft = switchLeft + mTempRect.left;
    int switchInnerTop = switchTop + mTempRect.top;
    int switchInnerRight = switchRight - mTempRect.right;
    int switchInnerBottom = switchBottom - mTempRect.bottom;
    canvas.clipRect(switchInnerLeft, switchTop, switchInnerRight, switchBottom);

    mThumbDrawable.getPadding(mTempRect);
    final int thumbPos = (int) (mThumbPosition + 0.5f);
    int thumbLeft = switchInnerLeft - mTempRect.left + thumbPos;
    int thumbRight = switchInnerLeft + thumbPos + mThumbWidth + mTempRect.right;

    mThumbDrawable.setBounds(thumbLeft, switchTop, thumbRight, switchBottom);
    mThumbDrawable.draw(canvas);

    // mTextColors should not be null, but just in case
    if (mTextColors != null) {
      mTextPaint.setColor(
          mTextColors.getColorForState(getDrawableState(), mTextColors.getDefaultColor()));
    }
    mTextPaint.drawableState = getDrawableState();

    Layout switchText = getTargetCheckedState() ? mOnLayout : mOffLayout;
    if (switchText != null) {
      canvas.translate(
          (thumbLeft + thumbRight) / 2 - switchText.getWidth() / 2,
          (switchInnerTop + switchInnerBottom) / 2 - switchText.getHeight() / 2);
      switchText.draw(canvas);
    }

    canvas.restore();
  }
Exemplo n.º 25
0
 protected void resetHoverColor() {
   if (Utilities.ATLEAST_LOLLIPOP) {
     animateTextColor(mOriginalTextColor.getDefaultColor());
   } else {
     mDrawable.setColorFilter(null);
     setTextColor(mOriginalTextColor);
   }
 }
Exemplo n.º 26
0
 @TargetApi(VERSION_CODES.LOLLIPOP)
 private void setRippleColor(Recipients recipients) {
   if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
     ((RippleDrawable) (getBackground()).mutate())
         .setColor(
             ColorStateList.valueOf(recipients.getColor().toConversationColor(getContext())));
   }
 }
Exemplo n.º 27
0
  public void setBorderColors(ColorStateList colors) {
    if (mBorderColor.equals(colors)) {
      return;
    }

    mBorderColor =
        colors != null ? colors : ColorStateList.valueOf(RoundedDrawable.DEFAULT_BORDER_COLOR);
    if (mDrawable instanceof RoundedDrawable) {
      ((RoundedDrawable) mDrawable).setBorderColors(colors);
    }
    if (mRoundBackground && mBackgroundDrawable instanceof RoundedDrawable) {
      ((RoundedDrawable) mBackgroundDrawable).setBorderColors(colors);
    }
    if (mBorderWidth > 0) {
      invalidate();
    }
  }
  @Override
  protected void drawableStateChanged() {
    super.drawableStateChanged();

    if (mColorStateList != null && mColorStateList.isStateful()) {
      updateTintColor();
    }
  }
Exemplo n.º 29
0
 @Override
 public void setTint(int color) {
   if (color == 0) {
     setTint(new DefaultColorStateList(getContext()));
   } else {
     setTint(ColorStateList.valueOf(color));
   }
 }
 private static PorterDuffColorFilter createTintFilter(
     ColorStateList paramColorStateList, PorterDuff.Mode paramMode, int[] paramArrayOfInt) {
   if ((paramColorStateList == null) || (paramMode == null)) {
     return null;
   }
   return getPorterDuffColorFilter(
       paramColorStateList.getColorForState(paramArrayOfInt, 0), paramMode);
 }