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

Commit 92aa8583 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes Ie4c98617,I6a7248d9

* changes:
  Add BatteryTipDialogFragment.
  Add high usage battery tip
parents 9c76ab23 fde637ff
Loading
Loading
Loading
Loading
+48 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2018 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.
-->

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="4dp"
    android:paddingStart="?android:dialogPreferredPadding"
    android:paddingEnd="?android:dialogPreferredPadding"
    android:orientation="horizontal">
    <ImageView
        android:id="@+id/app_icon"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_gravity="center_vertical"/>
    <TextView
        android:id="@+id/app_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginStart="24dp"
        android:textColor="?android:textColorPrimary"
        android:paddingEnd="7dp"/>
    <TextView
        android:id="@+id/app_screen_time"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_gravity="center_vertical"
        android:paddingEnd="16dp"
        android:textAlignment="viewEnd"
        android:textColor="?android:textColorPrimary"/>
</LinearLayout>
+23 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2018 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.
  -->
<android.support.v7.widget.RecyclerView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/recycler_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="8dp"
    android:scrollbars="vertical"/>
+15 −0
Original line number Diff line number Diff line
@@ -4773,6 +4773,21 @@
    <string name="battery_tip_low_battery_title">Low battery capacity</string>
    <!-- Summary for the low battery tip [CHAR LIMIT=NONE] -->
    <string name="battery_tip_low_battery_summary">Battery can\'t provide good battery life</string>
    <!-- Title for the battery high usage tip [CHAR LIMIT=NONE] -->
    <string name="battery_tip_high_usage_title" product="default">Phone used heavily</string>
    <!-- Title for the battery high usage tip [CHAR LIMIT=NONE] -->
    <string name="battery_tip_high_usage_title" product="tablet">Tablet used heavily</string>
    <!-- Title for the battery high usage tip [CHAR LIMIT=NONE] -->
    <string name="battery_tip_high_usage_title" product="device">Device used heavily</string>
    <!-- Summary for the battery high usage tip, which presents how many hours the device been used since last full charge [CHAR LIMIT=NONE] -->
    <string name="battery_tip_high_usage_summary">About <xliff:g id="hour">%1$s</xliff:g> used since last full charge</string>
    <!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
    <string name="battery_tip_dialog_message" product="default">Your phone was used heavily and this consumed a lot of battery. Your battery is behaving normally.\n\n Your phone was used for about <xliff:g id="hour">%1$s</xliff:g> since last full charge.\n\n Total usage:</string>
    <!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
    <string name="battery_tip_dialog_message" product="tablet">Your tablet was used heavily and this consumed a lot of battery. Your battery is behaving normally.\n\n Your tablet was used for about <xliff:g id="hour">%1$s</xliff:g> since last full charge.\n\n Total usage:</string>
    <!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
    <string name="battery_tip_dialog_message" product="device">Your device was used heavily and this consumed a lot of battery. Your battery is behaving normally.\n\n Your device was used for about <xliff:g id="hour">%1$s</xliff:g> since last full charge.\n\n Total usage:</string>
    <!-- Title for the smart battery manager preference [CHAR LIMIT=NONE] -->
    <string name="smart_battery_manager_title">Smart battery manager</string>
    <!-- Title for the smart battery toggle [CHAR LIMIT=NONE] -->
+15 −0
Original line number Diff line number Diff line
@@ -94,6 +94,7 @@ import android.text.TextUtils;
import android.text.format.DateUtils;
import android.text.style.TtsSpan;
import android.util.ArraySet;
import android.util.IconDrawableFactory;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
@@ -1382,4 +1383,18 @@ public final class Utils extends com.android.settingslib.Utils {
        }
        return new BitmapDrawable(null, bitmap);
    }

    /**
     * Get the {@link Drawable} that represents the app icon
     */
    public static Drawable getBadgedIcon(IconDrawableFactory iconDrawableFactory,
            PackageManager packageManager, String packageName, int userId) {
        try {
            final ApplicationInfo appInfo = packageManager.getApplicationInfo(packageName,
                    PackageManager.GET_META_DATA);
            return iconDrawableFactory.getBadgedIcon(appInfo, userId);
        } catch (PackageManager.NameNotFoundException e) {
            return packageManager.getDefaultActivityIcon();
        }
    }
}
+25 −0
Original line number Diff line number Diff line
@@ -345,6 +345,17 @@ public class BatteryUtils {

    }

    /**
     * Calculate the screen usage time since last full charge.
     * @param batteryStatsHelper utility class that contains the screen usage data
     * @return time in millis
     */
    public long calculateScreenUsageTime(BatteryStatsHelper batteryStatsHelper) {
        final BatterySipper sipper = findBatterySipperByType(
                batteryStatsHelper.getUsageList(), BatterySipper.DrainType.SCREEN);
        return sipper != null ? sipper.usageTimeMs : 0;
    }

    public static void logRuntime(String tag, String message, long startTime) {
        Log.d(tag, message + ": " + (System.currentTimeMillis() - startTime) + "ms");
    }
@@ -432,6 +443,20 @@ public class BatteryUtils {
        return batteryInfo;
    }

    /**
     * Find the {@link BatterySipper} with the corresponding {@link BatterySipper.DrainType}
     */
    public BatterySipper findBatterySipperByType(List<BatterySipper> usageList,
            BatterySipper.DrainType type) {
        for (int i = 0, size = usageList.size(); i < size; i++) {
            final BatterySipper sipper = usageList.get(i);
            if (sipper.drainType == type) {
                return sipper;
            }
        }
        return null;
    }

    private boolean isDataCorrupted() {
        return mPackageManager == null || mAppOpsManager == null;
    }
Loading