Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cef1628d authored by Dirk Rettschlag's avatar Dirk Rettschlag Committed by Michael Bestas
Browse files

make LinearColorBar themeable



Move colors to resources and use them instead.

Change-Id: I923e5daa219f302dc24e62faab666483109e6620
Signed-off-by: default avatarDirk Rettschlag <dirk.rettschlag@gmail.com>
parent 46af8086
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
 * Copyright 2013, The Android Open Kang Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-->
<resources>
    <color name="linear_color_bar_left_color">#ff0099cc</color>
    <color name="linear_color_bar_middle_color">#ff0099cc</color>
    <color name="linear_color_bar_right_color">#ff888888</color>
    <color name="linear_color_bar_gray_color">#ff555555</color>
    <color name="linear_color_bar_white_color">#ffffffff</color>
</resources>
+17 −13
Original line number Diff line number Diff line
@@ -15,20 +15,18 @@ import android.util.DisplayMetrics;
import android.view.MotionEvent;
import android.widget.LinearLayout;

public class LinearColorBar extends LinearLayout {
    static final int LEFT_COLOR = 0xff0099cc;
    static final int MIDDLE_COLOR = 0xff0099cc;
    static final int RIGHT_COLOR = 0xff888888;
    static final int GRAY_COLOR = 0xff555555;
    static final int WHITE_COLOR = 0xffffffff;
import com.android.settings.R;

public class LinearColorBar extends LinearLayout {
    private float mRedRatio;
    private float mYellowRatio;
    private float mGreenRatio;

    private int mLeftColor = LEFT_COLOR;
    private int mMiddleColor = MIDDLE_COLOR;
    private int mRightColor = RIGHT_COLOR;
    private int mLeftColor;
    private int mMiddleColor;
    private int mRightColor;
    private int mGrayColor;
    private int mWhiteColor;

    private boolean mShowIndicator = true;
    private boolean mShowingGreen;
@@ -61,6 +59,13 @@ public class LinearColorBar extends LinearLayout {

    public LinearColorBar(Context context, AttributeSet attrs) {
        super(context, attrs);

        mLeftColor = getResources().getColor(R.color.linear_color_bar_left_color);
        mMiddleColor = getResources().getColor(R.color.linear_color_bar_middle_color);
        mRightColor = getResources().getColor(R.color.linear_color_bar_right_color);
        mGrayColor = getResources().getColor(R.color.linear_color_bar_gray_color);
        mWhiteColor = getResources().getColor(R.color.linear_color_bar_white_color);

        setWillNotDraw(false);
        mPaint.setStyle(Paint.Style.FILL);
        mColorGradientPaint.setStyle(Paint.Style.FILL);
@@ -70,7 +75,6 @@ public class LinearColorBar extends LinearLayout {
                ? 2 : 1;
        mEdgeGradientPaint.setStrokeWidth(mLineWidth);
        mEdgeGradientPaint.setAntiAlias(true);
        
    }

    public void setOnRegionTappedListener(OnRegionTappedListener listener) {
@@ -175,10 +179,10 @@ public class LinearColorBar extends LinearLayout {

    private int pickColor(int color, int region) {
        if (isPressed() && (mLastRegion&region) != 0) {
            return WHITE_COLOR;
            return mWhiteColor;
        }
        if ((mColoredRegions&region) == 0) {
            return GRAY_COLOR;
            return mGrayColor;
        }
        return color;
    }