For API 21 and lower, manually set the drawable tint based on the colors
set in the given navigation theme (light or dark).
505226
private void initializeBackground() {
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
      int navigationViewBannerBackgroundColor = ThemeSwitcher.retrieveThemeColor(getContext(),
        R.attr.navigationViewBannerBackground);
      int navigationViewListBackgroundColor = ThemeSwitcher.retrieveThemeColor(getContext(),
        R.attr.navigationViewListBackground);
      // Instruction Layout landscape - banner background
      if (isLandscape()) {
        View instructionLayoutManeuver = findViewById(R.id.instructionManeuverLayout);
        Drawable maneuverBackground = DrawableCompat.wrap(instructionLayoutManeuver.getBackground()).mutate();
        DrawableCompat.setTint(maneuverBackground, navigationViewBannerBackgroundColor);

        View subStepLayout = findViewById(R.id.subStepLayout);
        Drawable subStepBackground = DrawableCompat.wrap(subStepLayout.getBackground()).mutate();
        DrawableCompat.setTint(subStepBackground, navigationViewListBackgroundColor);

        View turnLaneLayout = findViewById(R.id.turnLaneLayout);
        Drawable turnLaneBackground = DrawableCompat.wrap(turnLaneLayout.getBackground()).mutate();
        DrawableCompat.setTint(turnLaneBackground, navigationViewListBackgroundColor);
      }
    }
  }
251923
def setColorSet( self, colorSet ):
        
        self._colorSet = colorSet
        
        if ( not colorSet ):
            return
        
        palette = self.palette()
        palette.setColor( palette.Base, colorSet.color('Background'))
        self.setPalette(palette)
        
        # set the global colors
        self.setCaretForegroundColor(
                                colorSet.color('CaretForeground'))
        self.setMarginsBackgroundColor(
                                colorSet.color('MarginsBackground'))
        self.setMarginsForegroundColor(
                                colorSet.color('MarginsForeground'))
        self.setPaper(          colorSet.color('Background'))
        self.setSelectionBackgroundColor(
                                colorSet.color('SelectionBackground'))
        self.setSelectionForegroundColor(
                                colorSet.color('SelectionForeground'))
        self.setFoldMarginColors(colorSet.color('FoldMarginsForeground'),
                                 colorSet.color('FoldMarginsBackground'))
        self.setCallTipsBackgroundColor(
                                colorSet.color('CallTipsBackground'))
        self.setCallTipsForegroundColor(
                                colorSet.color('CallTipsForeground'))
        self.setCallTipsHighlightColor(
                                colorSet.color('CallTipsHighlight'))
        self.setEdgeColor(      colorSet.color('Edge'))
        self.setMarkerBackgroundColor(
                                colorSet.color('MarkerBackground'))
        self.setMarkerForegroundColor(
                                colorSet.color('MarkerForeground'))
        self.setMatchedBraceBackgroundColor(
                                colorSet.color('MatchedBraceBackground'))
        self.setMatchedBraceForegroundColor(
                                colorSet.color('MatchedBraceForeground'))
        self.setUnmatchedBraceBackgroundColor(
                                colorSet.color('UnmatchedBraceBackground'))
        self.setUnmatchedBraceForegroundColor(
                                colorSet.color('UnmatchedBraceForeground'))
        self.setColor(          colorSet.color('Text'))
        
        self.setIndentationGuidesBackgroundColor(
                                    colorSet.color('IndentBackground'))
        self.setIndentationGuidesForegroundColor(
                                colorSet.color('IndentForeground'))
        
        # backwards support
        if ( hasattr(self, 'setCaretBackgroundColor') ):
            self.setCaretBackgroundColor(
                                    colorSet.color('CaretBackground'))
        elif ( hasattr(self, 'setCaretLineBackgroundColor') ):
            self.setCaretLineBackgroundColor(
                                    colorSet.color('CaretBackground'))
                                    
        
        # supported in newer QScintilla versions
        if ( hasattr(self, 'setIndicatorForegroundColor') ):
            self.setIndicatorForegroundColor(
                                    colorSet.color('IndicatorForeground'))
            self.setIndicatorOutlineColor(
                                    colorSet.color('IndicatorOutline'))
        
        # set the language and lexer colors
        lang  = self.language()
        lexer = self.lexer()
        
        if ( lang and lexer ):
            lang.setColorSet(lexer, colorSet)
1365775
public SuperActivityToast setProgressBarColor(@ColorInt int progressBarColor) {
        if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            Log.w(getClass().getName(), "SuperActivityToast.setProgressBarColor() requires API " +
                    "21 or newer.");
            return this;
        }
        this.mStyle.progressBarColor = progressBarColor;
        return this;
    }
1331226
function (ui, context) {
					var active = color.active;
					if (context != colorBar && active.val() == null) return;
					switch (settings.color.mode) {
					case 'h':
						active.val('h', {
							h: 360 - ui.val('y')
						}, context);
						break;
					case 's':
						active.val('s', {
							s: 100 - ui.val('y')
						}, context);
						break;
					case 'v':
						active.val('v', {
							v: 100 - ui.val('y')
						}, context);
						break;
					case 'r':
						active.val('r', {
							r: 255 - ui.val('y')
						}, context);
						break;
					case 'g':
						active.val('g', {
							g: 255 - ui.val('y')
						}, context);
						break;
					case 'b':
						active.val('b', {
							b: 255 - ui.val('y')
						}, context);
						break;
					case 'a':
						active.val('a', 255 - ui.val('y'), context);
						break;
					}
				}
1205408
static void setTheme(Context context, AttributeSet attrs) {
    boolean nightModeEnabled = isNightModeEnabled(context);

    if (shouldSetThemeFromPreferences(context)) {
      int prefLightTheme = retrieveThemeResIdFromPreferences(context, NavigationConstants.NAVIGATION_VIEW_LIGHT_THEME);
      int prefDarkTheme = retrieveThemeResIdFromPreferences(context, NavigationConstants.NAVIGATION_VIEW_DARK_THEME);
      prefLightTheme = prefLightTheme == 0 ? R.style.NavigationViewLight : prefLightTheme;
      prefDarkTheme = prefLightTheme == 0 ? R.style.NavigationViewDark : prefDarkTheme;
      context.setTheme(nightModeEnabled ? prefDarkTheme : prefLightTheme);
      return;
    }

    TypedArray styledAttributes = context.obtainStyledAttributes(attrs, R.styleable.NavigationView);
    int lightTheme = styledAttributes.getResourceId(R.styleable.NavigationView_navigationLightTheme,
      R.style.NavigationViewLight);
    int darkTheme = styledAttributes.getResourceId(R.styleable.NavigationView_navigationDarkTheme,
      R.style.NavigationViewDark);
    styledAttributes.recycle();

    context.setTheme(nightModeEnabled ? darkTheme : lightTheme);
  }
415825
public static void applyTheme(Drawable d, Resources.Theme t) {
        IMPL.applyTheme(d, t);
    }
569180
private void adaptBreadCrumbBackgroundColor() {
        if (breadCrumbToolbar != null) {
            GradientDrawable background = (GradientDrawable) ContextCompat
                    .getDrawable(this, R.drawable.breadcrumb_background);
            background.setColor(breadCrumbBackgroundColor);
            ViewUtil.setBackground(getBreadCrumbToolbar(), background);
        }
    }
683172
public void setBackgroundColor(ColorStateList colorStateList) {
        if (colorStateList != null && mBackgroundColor != colorStateList) {
            mBackgroundColor = colorStateList;
            setBackgroundColor(mBackgroundColor.getColorForState(getDrawableState(), mBackgroundColor.getDefaultColor()));
        }
    }
558200
public void setChromeColor(int color) {
    if (chromeColor != color) {
      viewBorderPaint.setColor(color);
      chromeColor = color;
      invalidate();
    }
  }
434830
def setDisabledAlternateColor(self, color):
        
        color = QColor(color)
        if self._palette is None:
            self._palette = XNodePalette(self._scenePalette)
        
        self._palette.setColor(self._palette.Disabled,
                               self._palette.NodeAlternateBackground,
                               color)
        self.setDirty()
1361132
public static void setDrawableTint(@NonNull Drawable drawable, @ColorInt int color) {
        DrawableCompat.setTint(DrawableCompat.wrap(drawable.mutate()), color);
    }
364442
public void setAmbientLight(int i, Color color, boolean enableColor, Vector3D v) {
	    float ambient[] = {
            (float)color.getRed(),
            (float)color.getGreen(),
            (float)color.getBlue(),
            (float)color.getAlpha()
        };
        float position[] = { (float)v.getX(), (float)v.getY(), (float)v.getZ(), 1.0f };
        gl.glEnable(GL2.GL_LIGHTING);
        gl.glEnable(GL2.GL_LIGHT0 + i);
        gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_POSITION, position, 0);
        if(enableColor)
            gl.glLightfv(GL2.GL_LIGHT0 + i, GL2.GL_AMBIENT, ambient, 0);
    }
217847
private void defineBaseColors(UIDefaults d) {
        d.put("control", new ColorUIResource(0xf8f8f8));

        // Copied from Nimbus

        //Color palette
        addColor(d, "text", 0, 0, 0, 255);
        addColor(d, "seaGlassBase", 51, 98, 140, 255);
        addColor(d, "seaGlassBlueGrey", "seaGlassBase", 0.032459438f, -0.52518797f, 0.19607842f, 0);
        addColor(d, "seaGlassOrange", 191, 98, 4, 255);
        addColor(d, "seaGlassGreen", 176, 179, 50, 255);
        addColor(d, "seaGlassRed", 169, 46, 34, 255);
        addColor(d, "seaGlassBorder", "seaGlassBlueGrey", 0.0f, -0.017358616f, -0.11372548f, 0);
        addColor(d, "seaGlassSelection", "seaGlassBase", -0.010750473f, -0.04875779f, -0.007843137f, 0);
        addColor(d, "seaGlassInfoBlue", 47, 92, 180, 255);
        addColor(d, "seaGlassAlertYellow", 255, 220, 35, 255);
        addColor(d, "seaGlassFocus", 115, 164, 209, 255);
        addColor(d, "seaGlassSelectedText", 255, 255, 255, 255);
        addColor(d, "seaGlassSelectionBackground", 57, 105, 138, 255);
        addColor(d, "seaGlassDisabledText", 142, 143, 145, 255);
        addColor(d, "seaGlassLightBackground", 255, 255, 255, 255);
        addColor(d, "infoText", "text", 0.0f, 0.0f, 0.0f, 0);
        addColor(d, "info", 242, 242, 189, 255);
        addColor(d, "menuText", "text", 0.0f, 0.0f, 0.0f, 0);
        addColor(d, "menu", "seaGlassBase", 0.021348298f, -0.6150531f, 0.39999998f, 0);
        addColor(d, "scrollbar", "seaGlassBlueGrey", -0.006944418f, -0.07296763f, 0.09019607f, 0);
        addColor(d, "controlText", "text", 0.0f, 0.0f, 0.0f, 0);
        addColor(d, "controlHighlight", "seaGlassBlueGrey", 0.0f, -0.07333623f, 0.20392156f, 0);
        addColor(d, "controlLHighlight", "seaGlassBlueGrey", 0.0f, -0.098526314f, 0.2352941f, 0);
        addColor(d, "controlShadow", "seaGlassBlueGrey", -0.0027777553f, -0.0212406f, 0.13333333f, 0);
        addColor(d, "controlDkShadow", "seaGlassBlueGrey", -0.0027777553f, -0.0018306673f, -0.02352941f, 0);
        addColor(d, "textHighlight", "seaGlassSelectionBackground", 0.0f, 0.0f, 0.0f, 0);
        addColor(d, "textHighlightText", "seaGlassSelectedText", 0.0f, 0.0f, 0.0f, 0);
        addColor(d, "textInactiveText", "seaGlassDisabledText", 0.0f, 0.0f, 0.0f, 0);
        addColor(d, "desktop", "seaGlassBase", -0.009207249f, -0.13984653f, -0.07450983f, 0);
        addColor(d, "activeCaption", "seaGlassBlueGrey", 0.0f, -0.049920253f, 0.031372547f, 0);
        addColor(d, "inactiveCaption", "seaGlassBlueGrey", -0.00505054f, -0.055526316f, 0.039215684f, 0);

        //The global style definition
        addColor(d, "textForeground", "text", 0.0f, 0.0f, 0.0f, 255);
        addColor(d, "[Disabled].textForeground", "textForeground", 0.0f, 0.0f, 0.0f, 80);
        addColor(d, "textBackground", "seaGlassSelectionBackground", 0.0f, 0.0f, 0.0f, 0);
        addColor(d, "background", "control", 0, 0, 0, 0);
        
        d.put("TitledBorder.position", "ABOVE_TOP");
        d.put("TitledBorder.titleColor", Color.BLACK);
        d.put("TitledBorder.font", new DerivedFont("defaultFont", 1.0f, false, false));
        d.put("FileView.fullRowSelection", Boolean.TRUE);
        
        // Seaglass starts here
        
        
        d.put("seaGlassSelection", new Color(0x6181a5));
        d.put("seaGlassFocus", new Color(0x73a4d1));
        d.put("seaGlassBorder", new Color(0x9297a1));
        d.put("seaGlassSelectedText", Color.WHITE);
        d.put("seaGlassSelectionBackground", new Color(0x6181a5));
        d.put("seaGlassDisabledText", new Color(0xc8c8c8));
        d.put("textHighlight", d.get("seaGlassSelectionBackground"));
        d.put("textHighlightText", Color.WHITE);
        d.put("textInactiveText", d.get("seaGlassDisabledText"));
        d.put("menuText", Color.WHITE);
        d.put("menu", Color.WHITE);

        d.put("seaGlassTransparent", new Color(0x0, true));
        d.put("seaGlassTextEmphasis", new Color(255, 255, 255, 110));
        d.put("seaGlassDropShadow", new Color(211, 211, 211));
        d.put("seaGlassInnerShadow", new Color(0x20000000, true));
        d.put("seaGlassStyleDefaultColor", new ColorUIResource(Color.BLACK));
        d.put("seaGlassFocusInsets", new Insets(2, 2, 2, 2));
        d.put("seaGlassTransparent", new Color(0, true));
        d.put("seaGlassFocus", new Color(0x73a4d1));
        d.put("seaGlassOuterFocus", getDerivedColor("seaGlassFocus", -0.0028f, 0.01f, 0f, -0x80, true));

        if (PlatformUtils.isMac()) {
            d.put("seaGlassToolBarFocus", d.get("seaGlassFocus"));
            d.put("seaGlassToolBarOuterFocus", d.get("seaGlassOuterFocus"));
            d.put("seaGlassToolBarDisabledText", new Color(0x80000000, true));
        } else {
            d.put("seaGlassToolBarFocus", new Color(0x5b7ea4)); // Rossi: new color for toolbar line
            d.put("seaGlassToolBarOuterFocus", getDerivedColor("seaGlassToolBarFocus", -0.0028f, 0.01f, 0f, -0x80, true));
            d.put("seaGlassToolBarDisabledText", new Color(0x80000000, true));
        }

        d.put("seaGlassTableSelectionActiveBottom", new Color(0x7daaea));
        d.put("seaGlassTableSelectionInactiveBottom", new Color(0xe0e0e0));

        d.put("seaGlassSearchPlaceholderText", new Color(0x808080));

        d.put("seaGlassSearchIcon", new Color(0x404040));
        d.put("seaGlassCancelIcon", new Color(0xb3b3b3));
        d.put("seaGlassCancelIconPressed", new Color(0x808080));

        d.put("seaGlassTextEnabledBorder", new Color(0x709ad0)); // Rossi: Blue borders for text fields
        d.put("seaGlassTextDisabledBorder", SeaGlassGraphicsUtils.disable( new Color(0x709ad0))); // new Color(0xdddddd)
        d.put("seaGlassTextEnabledToolbarBorder", new Color(0x888888));

        d.put("seaGlassMenuIcon", new Color(0x5b7ea4)); // Rossi: Menu "Icons" (Arrow, checkbox, radio) are now no longer black
    }
107127
@Override
    public void applyDesign(Design design, int themeColor) {

        if(mProgressStyle == HORIZONTAL) {

            LayerDrawable drawable = (LayerDrawable) mLayout.getResources().getDrawable(R.drawable.progress_material_horizontal);

            Drawable bg = drawable.getDrawable(0);
            int color = design.isLight() ? R.color.grey_700 : R.color.grey_500;
            bg.setColorFilter(mLayout.getResources().getColor(color), PorterDuff.Mode.SRC_ATOP);

            Drawable secProg = drawable.getDrawable(1);
            secProg.setColorFilter(lighten(themeColor), PorterDuff.Mode.SRC_ATOP);

            Drawable prg = drawable.getDrawable(2);
            prg.setColorFilter(themeColor, PorterDuff.Mode.SRC_ATOP);

            mProgress.setProgressDrawable(drawable);

            // Style the indeterminate drawable color
            Drawable animDrawable = mProgress.getIndeterminateDrawable();
            animDrawable.setColorFilter(themeColor, PorterDuff.Mode.SRC_ATOP);

        }

        if(design.isLight()){
            mProgressText.setTextColor(mLayout.getResources().getColor(R.color.tertiary_text_material_light));
            mProgressMax.setTextColor(mLayout.getResources().getColor(R.color.tertiary_text_material_light));
        }else{
            mProgressText.setTextColor(mLayout.getResources().getColor(R.color.tertiary_text_material_dark));
            mProgressMax.setTextColor(mLayout.getResources().getColor(R.color.tertiary_text_material_dark));
        }

        if(design.isMaterial()){
            FontLoader.applyTypeface(mProgressText, Types.ROBOTO_MEDIUM);
            FontLoader.applyTypeface(mProgressMax, Types.ROBOTO_MEDIUM);
        }

        // Style the progress message if available
        TextView progressMessage = (TextView) mLayout.findViewById(R.id.progress_mesage);
        if(progressMessage != null){

            if(design.isMaterial()){
                LinearLayout progressContainer = (LinearLayout) mLayout.findViewById(R.id.progress_container);
                progressContainer.removeView(progressMessage);

                LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) progressMessage.getLayoutParams();
                CharSequence text = progressMessage.getText();
                if(design.isLight()){
                    progressMessage = new TextView(mCtx, null, R.style.Widget_PostOffice_Material_Light_Dialog_Message);
                }else{
                    progressMessage = new TextView(mCtx, null, R.style.Widget_PostOffice_Material_Dark_Dialog_Message);
                }

                // Re Update
                progressMessage.setText(text);

                // Set the roboto font
                FontLoader.applyTypeface(progressMessage, Types.ROBOTO_REGULAR);

                // Add it back to the layout
                progressContainer.addView(progressMessage, params);

            }
        }

    }
1130821
public static void tint(View view, Tint tint) {
        final ColorStateList color = tint.getColor(view.getContext());

        if (view instanceof ImageView) {
            tint(((ImageView) view).getDrawable(), color);
        } else if (view instanceof TextView) {
            TextView text = (TextView) view;
            Drawable[] comp = text.getCompoundDrawables();
            for (int i = 0; i < comp.length; i++) {
                if (comp[i] != null) {
                    comp[i] = tint(comp[i], color);
                }
            }
            text.setCompoundDrawablesWithIntrinsicBounds(comp[0], comp[1], comp[2], comp[3]);
        } else {
            throw new IllegalArgumentException("Unsupported view type");
        }
    }
736373
public void setDialogWindowAttributes() {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
        lp.copyFrom(getWindow().getAttributes());
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
        lp.height = WindowManager.LayoutParams.MATCH_PARENT;
        lp.gravity = Gravity.BOTTOM;
        lp.dimAmount = 0.8f;
        getWindow().setAttributes(lp);
        getWindow().setWindowAnimations(android.R.anim.slide_in_left);
        setCanceledOnTouchOutside(true);
    }
765522
def setDisabledColor(self, color):
        
        color = QColor(color)
        if self._palette is None:
            self._palette = XNodePalette(self._scenePalette)
        
        self._palette.setColor(self._palette.Disabled,
                               self._palette.NodeBackground,
                               color)
        self._palette.setColor(self._palette.Disabled,
                               self._palette.NodeAlternateBackground,
                               color.darker(105))
        self.setDirty()