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

Commit 15000fa4 authored by Kweku Adams's avatar Kweku Adams Committed by Android (Google) Code Review
Browse files

Merge "Adding new strings for battery saver sticky off notification."

parents 391c6c46 3c95ee10
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -5320,6 +5320,21 @@
    <string name="battery_saver_sticky_disabled_notification_title">Battery Saver won\u2019t reactivate until battery low again</string>
    <!-- Summary of notification letting users know why battery saver didn't turn back on automatically after the device was unplugged [CHAR_LIMIT=NONE] -->
    <string name="battery_saver_sticky_disabled_notification_summary">Battery has been charged to a sufficient level. Battery Saver won\u2019t reactivate until the battery is low again.</string>
    <!-- Title of notification letting users know the battery level at the time the notification was posted [CHAR_LIMIT=80] -->
    <string name="battery_saver_charged_notification_title" product="default">Phone <xliff:g id="charge level" example="90%">%1$s</xliff:g> charged</string>
    <!-- Title of notification letting users know the battery level at the time the notification was posted [CHAR_LIMIT=80] -->
    <string name="battery_saver_charged_notification_title" product="tablet">Tablet <xliff:g id="charge level" example="90%">%1$s</xliff:g> charged</string>
    <!-- Title of notification letting users know the battery level at the time the notification was posted [CHAR_LIMIT=80] -->
    <string name="battery_saver_charged_notification_title" product="device">Device <xliff:g id="charge level" example="90%">%1$s</xliff:g> charged</string>
    <!-- Summary of notification letting users know that battery saver is now off [CHAR_LIMIT=NONE] -->
    <string name="battery_saver_off_notification_summary">Battery Saver is off. Features no longer restricted.</string>
    <!-- Alternative summary of notification letting users know that battery saver has been turned off.
     If it's easy to translate the difference between "Battery Saver turned off. Features no longer restricted."
     and "Battery Saver is off. Features no longer restricted." into the target language,
     then translate "Battery Saver turned off. Features no longer restricted."
     If the translation doesn't make a difference or the difference is hard to capture in the target language,
     then translate "Battery Saver is off. Features no longer restricted." instead. [CHAR_LIMIT=NONE] -->
    <string name="battery_saver_off_alternative_notification_summary">Battery Saver turned off. Features no longer restricted.</string>

    <!-- Description of media type: folder or directory that contains additional files. [CHAR LIMIT=32] -->
    <string name="mime_type_folder">Folder</string>
+3 −0
Original line number Diff line number Diff line
@@ -3653,6 +3653,9 @@
  <java-symbol type="string" name="battery_saver_notification_channel_name" />
  <java-symbol type="string" name="battery_saver_sticky_disabled_notification_title" />
  <java-symbol type="string" name="battery_saver_sticky_disabled_notification_summary" />
  <java-symbol type="string" name="battery_saver_charged_notification_title" />
  <java-symbol type="string" name="battery_saver_off_notification_summary" />
  <java-symbol type="string" name="battery_saver_off_alternative_notification_summary" />
  <java-symbol type="string" name="dynamic_mode_notification_channel_name" />
  <java-symbol type="string" name="dynamic_mode_notification_title" />
  <java-symbol type="string" name="dynamic_mode_notification_summary" />
+10 −5
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import com.android.server.EventLogTags;
import com.android.server.power.BatterySaverStateMachineProto;

import java.io.PrintWriter;
import java.text.NumberFormat;

/**
 * Decides when to enable / disable battery saver.
@@ -791,7 +792,7 @@ public class BatterySaverStateMachine {

        manager.notify(DYNAMIC_MODE_NOTIFICATION_ID,
                buildNotification(DYNAMIC_MODE_NOTIF_CHANNEL_ID,
                        R.string.dynamic_mode_notification_title,
                        mContext.getResources().getString(R.string.dynamic_mode_notification_title),
                        R.string.dynamic_mode_notification_summary,
                        Intent.ACTION_POWER_USAGE_SUMMARY));
    }
@@ -801,10 +802,13 @@ public class BatterySaverStateMachine {
        ensureNotificationChannelExists(manager, BATTERY_SAVER_NOTIF_CHANNEL_ID,
                R.string.battery_saver_notification_channel_name);

        final String percentage = NumberFormat.getPercentInstance()
                .format((double) mBatteryLevel / 100.0);
        manager.notify(STICKY_AUTO_DISABLED_NOTIFICATION_ID,
                buildNotification(BATTERY_SAVER_NOTIF_CHANNEL_ID,
                        R.string.battery_saver_sticky_disabled_notification_title,
                        R.string.battery_saver_sticky_disabled_notification_summary,
                        mContext.getResources().getString(
                                R.string.battery_saver_charged_notification_title, percentage),
                        R.string.battery_saver_off_notification_summary,
                        Settings.ACTION_BATTERY_SAVER_SETTINGS));
    }

@@ -816,7 +820,7 @@ public class BatterySaverStateMachine {
        manager.createNotificationChannel(channel);
    }

    private Notification buildNotification(@NonNull String channelId, @StringRes int titleId,
    private Notification buildNotification(@NonNull String channelId, @NonNull String title,
            @StringRes int summaryId, @NonNull String intentAction) {
        Resources res = mContext.getResources();
        Intent intent = new Intent(intentAction);
@@ -827,11 +831,12 @@ public class BatterySaverStateMachine {

        return new Notification.Builder(mContext, channelId)
                .setSmallIcon(R.drawable.ic_battery)
                .setContentTitle(res.getString(titleId))
                .setContentTitle(title)
                .setContentText(summary)
                .setContentIntent(batterySaverIntent)
                .setStyle(new Notification.BigTextStyle().bigText(summary))
                .setOnlyAlertOnce(true)
                .setAutoCancel(true)
                .build();
    }