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

Commit 0e315588 authored by Ian Roy's avatar Ian Roy Committed by Steve Kondik
Browse files

Forward port battery icon options [1/2]

Bring forward the various battery icon options.
Portrait, Landscape, Circle, Text.

Still retains new options for where to display battery percentage text.

Change-Id: Icfc14d989eebde9014538291c24aa76d328df234
parent b37fe88e
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -3119,6 +3119,18 @@ public final class Settings {
         */
        public static final String EGG_MODE = "egg_mode";

        /**
         * Display style of the status bar battery information
         * 0: Display the battery an icon in portrait mode
         * 2: Display the battery as a circle
         * 4: Hide the battery status information
         * 5: Display the battery an icon in landscape mode
         * 6: Display the battery as plain text
         * default: 0
         * @hide
         */
        public static final String STATUS_BAR_BATTERY_STYLE = "status_bar_battery_style";

        /**
         * Status bar battery %
         * 0: Hide the battery percentage
@@ -3235,6 +3247,7 @@ public final class Settings {
            PHONE_BLACKLIST_PRIVATE_NUMBER_MODE,
            PHONE_BLACKLIST_UNKNOWN_NUMBER_MODE,
            PHONE_BLACKLIST_REGEX_ENABLED,
            STATUS_BAR_BATTERY_STYLE,
            STATUS_BAR_SHOW_BATTERY_PERCENT,
            INCREASING_RING,
            INCREASING_RING_START_VOLUME,
+1 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@
            >
            <include layout="@layout/system_icons" />
        </FrameLayout>
        <TextView android:id="@+id/battery_level"
        <com.android.systemui.BatteryLevelTextView android:id="@+id/battery_level_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
+28 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2012-2014 The CyanogenMod 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 xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">

    <array name="batterymeter_inverted_bolt_points" translatable="false">
        <item>743</item><item>73</item>
        <item>743</item><item>292</item>
        <item>442</item><item>201</item>
        <item>442</item><item>400</item>
        <item>0</item><item>20</item>
        <item>369</item><item>157</item>
        <item>369</item><item>0</item>
    </array>
</resources>
+55 −3
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui;

import android.app.ActivityManager;
import android.content.ContentResolver;
import android.content.Context;
import android.database.ContentObserver;
import android.net.Uri;
@@ -28,6 +30,10 @@ import com.android.systemui.statusbar.policy.BatteryController;

public class BatteryLevelTextView extends TextView implements
        BatteryController.BatteryStateChangeCallback{

    private static final String STATUS_BAR_BATTERY_STYLE = "status_bar_battery_style";
    private static final String STATUS_BAR_SHOW_BATTERY_PERCENT = "status_bar_show_battery_percent";

    private BatteryController mBatteryController;
    private boolean mShow;

@@ -45,8 +51,52 @@ public class BatteryLevelTextView extends TextView implements
    }

    private void loadShowBatteryTextSetting() {
        mShow = 2 == Settings.System.getInt(getContext().getContentResolver(),
                Settings.System.STATUS_BAR_SHOW_BATTERY_PERCENT, 0);
        //mShow = 2 == Settings.System.getInt(getContext().getContentResolver(),
        //        Settings.System.STATUS_BAR_SHOW_BATTERY_PERCENT, 0);

        ContentResolver resolver = getContext().getContentResolver();
        int currentUserId = ActivityManager.getCurrentUser();

        boolean showInsidePercent = Settings.System.getIntForUser(resolver,
                Settings.System.STATUS_BAR_SHOW_BATTERY_PERCENT, 0, currentUserId) == 1;

        boolean showNextPercent = Settings.System.getIntForUser(resolver,
                Settings.System.STATUS_BAR_SHOW_BATTERY_PERCENT, 0, currentUserId) == 2;

        int batteryStyle = Settings.System.getIntForUser(resolver,
                Settings.System.STATUS_BAR_BATTERY_STYLE, 0, currentUserId);
        switch (batteryStyle) {
            case 2:
                //meterMode = BatteryMeterMode.BATTERY_METER_CIRCLE;
                showNextPercent = showNextPercent;
                break;

            case 4:
                //meterMode = BatteryMeterMode.BATTERY_METER_GONE;
                showNextPercent = false;
                break;

            case 5:
                //meterMode = BatteryMeterMode.BATTERY_METER_ICON_LANDSCAPE;
                showNextPercent = showNextPercent;
                break;

            case 6:
                //meterMode = BatteryMeterMode.BATTERY_METER_TEXT;
                showNextPercent = true;
                break;

            default:
                break;
        }

        setShowPercent(showNextPercent);

    }

    public void setShowPercent(boolean show) {
        mShow = show;
        setVisibility(mShow ? View.VISIBLE : View.GONE);
    }

    @Override
@@ -68,7 +118,9 @@ public class BatteryLevelTextView extends TextView implements
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        getContext().getContentResolver().registerContentObserver(Settings.System.getUriFor(
                "status_bar_show_battery_percent"), false, mObserver);
                STATUS_BAR_BATTERY_STYLE), false, mObserver);
        getContext().getContentResolver().registerContentObserver(Settings.System.getUriFor(
                STATUS_BAR_SHOW_BATTERY_PERCENT), false, mObserver);
    }

    @Override
+728 −216

File changed.

Preview size limit exceeded, changes collapsed.

Loading