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

Commit 5602189a authored by Adrian Roos's avatar Adrian Roos
Browse files

AOD: Show charging status on AOD1

- Change PowerManager to not turn on display when on AOD
- Add charging icon to AOD1
- Add transient charging indication when plugged in

Bug: 30876804
Bug: 35850304
Test: runtest systemui; enable AOD, plug in phone, verify charging indicator shows, verify charging text shows and goes away after a few seconds
Change-Id: Icb80843a12c56c7e2abeca78115a366b4d508d4f
parent 22a905ee
Loading
Loading
Loading
Loading
+24 −6
Original line number Diff line number Diff line
@@ -28,25 +28,42 @@
    androidprv:layout_maxWidth="@dimen/keyguard_security_width"
    androidprv:layout_maxHeight="@dimen/keyguard_security_height"
    android:gravity="center_horizontal|top">
    <LinearLayout
    <RelativeLayout
        android:id="@+id/keyguard_clock_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal|top"
        android:orientation="vertical" >
        android:layout_gravity="center_horizontal|top">
        <TextClock
            android:id="@+id/clock_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_centerHorizontal="true"
            android:layout_alignParentTop="true"
            android:textColor="@color/clock_white"
            android:singleLine="true"
            style="@style/widget_big_thin"
            android:format12Hour="@string/keyguard_widget_12_hours_format"
            android:format24Hour="@string/keyguard_widget_24_hours_format"
            android:layout_marginBottom="@dimen/bottom_text_spacing_digital" />
        <com.android.systemui.ChargingView
            android:id="@+id/battery_doze"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignTop="@id/clock_view"
            android:layout_alignBottom="@id/clock_view"
            android:layout_toEndOf="@id/clock_view"
            android:visibility="invisible"
            android:src="@drawable/ic_aod_charging_24dp"
            android:contentDescription="@string/accessibility_ambient_display_charging"
        />

        <include layout="@layout/keyguard_status_area"
            android:id="@+id/keyguard_status_area"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/clock_view" />

        <include layout="@layout/keyguard_status_area" />
        <TextView
            android:id="@+id/owner_info"
            android:layout_marginLeft="16dp"
@@ -54,12 +71,13 @@
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/date_owner_info_margin"
            android:layout_gravity="center_horizontal"
            android:layout_centerHorizontal="true"
            android:layout_below="@id/keyguard_status_area"
            android:textColor="@color/clock_gray"
            android:textSize="@dimen/widget_label_font_size"
            android:letterSpacing="0.05"
            android:ellipsize="marquee"
            android:singleLine="true" />

    </LinearLayout>
    </RelativeLayout>
</com.android.keyguard.KeyguardStatusView>
+24 −0
Original line number Diff line number Diff line
<!--
Copyright (C) 2014 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24.0dp"
        android:height="24.0dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:pathData="M11.0,22.98l0.0,-8.98 -4.0,0.0 6.0,-13.0 0.0,9.0 4.0,0.0z"
        android:fillColor="#ffffff"/>
</vector>
+3 −0
Original line number Diff line number Diff line
@@ -565,6 +565,9 @@
    <!-- Content description of the display brightness slider (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_brightness">Display brightness</string>

    <!-- Content description of the charging indicator on Ambient Display (lower-power version of the lock screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_ambient_display_charging">Charging</string>

    <!-- Title of dialog shown when 2G-3G data usage has exceeded limit and has been disabled. [CHAR LIMIT=48] -->
    <string name="data_usage_disabled_dialog_3g_title">2G-3G data is paused</string>
    <!-- Title of dialog shown when 4G data usage has exceeded limit and has been disabled. [CHAR LIMIT=48] -->
+5 −1
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.widget.TextClock;
import android.widget.TextView;

import com.android.internal.widget.LockPatternUtils;
import com.android.systemui.ChargingView;

import java.util.Locale;

@@ -50,6 +51,7 @@ public class KeyguardStatusView extends GridLayout {
    private TextClock mClockView;
    private TextView mOwnerInfo;
    private ViewGroup mClockContainer;
    private ChargingView mBatteryDoze;

    private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {

@@ -114,6 +116,7 @@ public class KeyguardStatusView extends GridLayout {
        mDateView.setShowCurrentUserTime(true);
        mClockView.setShowCurrentUserTime(true);
        mOwnerInfo = (TextView) findViewById(R.id.owner_info);
        mBatteryDoze = (ChargingView) findViewById(R.id.battery_doze);

        boolean shouldMarquee = KeyguardUpdateMonitor.getInstance(mContext).isDeviceInteractive();
        setEnableMarquee(shouldMarquee);
@@ -273,10 +276,11 @@ public class KeyguardStatusView extends GridLayout {
        final int N = mClockContainer.getChildCount();
        for (int i = 0; i < N; i++) {
            View child = mClockContainer.getChildAt(i);
            if (child == mClockView) {
            if (child == mClockView || child == mBatteryDoze) {
                continue;
            }
            child.setAlpha(dark ? 0 : 1);
        }
        mBatteryDoze.setDark(dark);
    }
}
+91 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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.systemui;

import android.annotation.Nullable;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.ImageView;

import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.ConfigurationController;

/**
 * A view that only shows its drawable while the phone is charging.
 *
 * Also reloads its drawable upon density changes.
 */
public class ChargingView extends ImageView implements
        BatteryController.BatteryStateChangeCallback,
        ConfigurationController.ConfigurationListener {

    private BatteryController mBatteryController;
    private int mImageResource;
    private boolean mCharging;
    private boolean mDark;

    public ChargingView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);

        TypedArray a = context.obtainStyledAttributes(attrs, new int[]{android.R.attr.src});
        int srcResId = a.getResourceId(0, 0);

        if (srcResId != 0) {
            mImageResource = srcResId;
        }

        a.recycle();

        updateVisibility();
    }

    @Override
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        mBatteryController = Dependency.get(BatteryController.class);
        mBatteryController.addCallback(this);
        Dependency.get(ConfigurationController.class).addCallback(this);
    }

    @Override
    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        mBatteryController.removeCallback(this);
        Dependency.get(ConfigurationController.class).removeCallback(this);
    }

    @Override
    public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) {
        mCharging = charging;
        updateVisibility();
    }

    @Override
    public void onDensityOrFontScaleChanged() {
        setImageResource(mImageResource);
    }

    public void setDark(boolean dark) {
        mDark = dark;
        updateVisibility();
    }

    private void updateVisibility() {
        setVisibility(mCharging && mDark ? VISIBLE : INVISIBLE);
    }
}
Loading