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

Commit 3c7fdfd9 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android Git Automerger
Browse files

am a582a051: Proc stats UI improvements.

* commit 'a582a051':
  Proc stats UI improvements.
parents 0aee1b15 a582a051
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source 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.
-->

<com.android.settings.applications.LinearColorBar
        xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?android:attr/listPreferredItemHeight"
    android:gravity="center_vertical"
    android:id="@+android:id/linear_color_bar"
    android:paddingEnd="?android:attr/scrollbarSize"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:shadowRadius="4"
    android:shadowColor="?android:attr/colorBackground"
    android:shadowDx="2"
    android:shadowDy="2">
</com.android.settings.applications.LinearColorBar>
+12 −0
Original line number Diff line number Diff line
@@ -1149,4 +1149,16 @@
        <item>Always allow</item>
    </string-array>

    <!-- [CHAR LIMIT=30] Labels for memory states -->
    <string-array name="ram_states">
        <!-- Normal desired memory state. -->
        <item>normal</item>
        <!-- Moderate memory state, not as good as normal. -->
        <item>moderate</item>
        <!-- Memory is running low. -->
        <item>low</item>
        <!-- Memory is critical. -->
        <item>critical</item>
    </string-array>

</resources>
+4 −1
Original line number Diff line number Diff line
@@ -3557,7 +3557,10 @@
    <!-- [CHAR LIMIT=NONE] Label for amount of memory use -->
    <string name="app_memory_use">Memory use</string>
    <!-- [CHAR LIMIT=NONE] Label for process stats, duration of time the stats are over -->
    <string name="process_stats_total_duration">Over <xliff:g id="time">%1$s</xliff:g></string>
    <string name="process_stats_total_duration">Stats over <xliff:g id="time">%1$s</xliff:g></string>
    <!-- [CHAR LIMIT=NONE] Label for process stats, duration of time the stats are over -->
    <string name="process_stats_memory_status">Device memory is currently
        <xliff:g id="memstate">%1$s</xliff:g></string>

    <!-- Voice input/output settings --><skip />
    <!-- Title of setting on main settings screen. This item will take the user to the screen to tweak settings related to speech functionality -->
+28 −6
Original line number Diff line number Diff line
@@ -23,6 +23,11 @@ public class LinearColorBar extends LinearLayout {
    private float mYellowRatio;
    private float mGreenRatio;

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

    private boolean mShowIndicator = true;
    private boolean mShowingGreen;

    final Rect mRect = new Rect();
@@ -57,6 +62,20 @@ public class LinearColorBar extends LinearLayout {
        invalidate();
    }

    public void setColors(int red, int yellow, int green) {
        mLeftColor = red;
        mMiddleColor = yellow;
        mRightColor = green;
        updateIndicator();
        invalidate();
    }

    public void setShowIndicator(boolean showIndicator) {
        mShowIndicator = showIndicator;
        updateIndicator();
        invalidate();
    }

    public void setShowingGreen(boolean showingGreen) {
        if (mShowingGreen != showingGreen) {
            mShowingGreen = showingGreen;
@@ -70,12 +89,15 @@ public class LinearColorBar extends LinearLayout {
        if (off < 0) off = 0;
        mRect.top = off;
        mRect.bottom = getHeight();
        if (!mShowIndicator) {
            return;
        }
        if (mShowingGreen) {
            mColorGradientPaint.setShader(new LinearGradient(
                    0, 0, 0, off-2, RIGHT_COLOR&0xffffff, RIGHT_COLOR, Shader.TileMode.CLAMP));
                    0, 0, 0, off-2, mRightColor &0xffffff, mRightColor, Shader.TileMode.CLAMP));
        } else {
            mColorGradientPaint.setShader(new LinearGradient(
                    0, 0, 0, off-2, MIDDLE_COLOR&0xffffff, MIDDLE_COLOR, Shader.TileMode.CLAMP));
                    0, 0, 0, off-2, mMiddleColor&0xffffff, mMiddleColor, Shader.TileMode.CLAMP));
        }
        mEdgeGradientPaint.setShader(new LinearGradient(
                0, 0, 0, off/2, 0x00a0a0a0, 0xffa0a0a0, Shader.TileMode.CLAMP));
@@ -111,7 +133,7 @@ public class LinearColorBar extends LinearLayout {
        if (mLastInterestingLeft != indicatorLeft || mLastInterestingRight != indicatorRight) {
            mColorPath.reset();
            mEdgePath.reset();
            if (indicatorLeft < indicatorRight) {
            if (mShowIndicator && indicatorLeft < indicatorRight) {
                final int midTopY = mRect.top;
                final int midBottomY = 0;
                final int xoff = 2;
@@ -146,7 +168,7 @@ public class LinearColorBar extends LinearLayout {
        if (left < right) {
            mRect.left = left;
            mRect.right = right;
            mPaint.setColor(LEFT_COLOR);
            mPaint.setColor(mLeftColor);
            canvas.drawRect(mRect, mPaint);
            width -= (right-left);
            left = right;
@@ -157,7 +179,7 @@ public class LinearColorBar extends LinearLayout {
        if (left < right) {
            mRect.left = left;
            mRect.right = right;
            mPaint.setColor(MIDDLE_COLOR);
            mPaint.setColor(mMiddleColor);
            canvas.drawRect(mRect, mPaint);
            width -= (right-left);
            left = right;
@@ -168,7 +190,7 @@ public class LinearColorBar extends LinearLayout {
        if (left < right) {
            mRect.left = left;
            mRect.right = right;
            mPaint.setColor(RIGHT_COLOR);
            mPaint.setColor(mRightColor);
            canvas.drawRect(mRect, mPaint);
        }
    }
+51 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013 The Android Open Source 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.
 */

package com.android.settings.applications;

import android.content.Context;
import android.preference.Preference;
import android.view.View;
import com.android.settings.R;

public class LinearColorPreference extends Preference {
    float mRedRatio;
    float mYellowRatio;
    float mGreenRatio;

    public LinearColorPreference(Context context) {
        super(context);
        setLayoutResource(R.layout.preference_linearcolor);
    }

    public void setRatios(float red, float yellow, float green) {
        mRedRatio = red;
        mYellowRatio = yellow;
        mGreenRatio = green;
        notifyChanged();
    }

    @Override
    protected void onBindView(View view) {
        super.onBindView(view);

        LinearColorBar colors = (LinearColorBar)view.findViewById(
                R.id.linear_color_bar);
        colors.setShowIndicator(false);
        colors.setColors(0xffcc3000, 0xffcccc00, 0xff00cc30);
        colors.setRatios(mRedRatio, mYellowRatio, mGreenRatio);
    }
}
Loading