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

Commit 767eb0fa authored by Beverly Tai's avatar Beverly Tai Committed by Android (Google) Code Review
Browse files

Merge "Update PowerNotificationWarnings"

parents 984c4102 07f0054d
Loading
Loading
Loading
Loading
+15 −6
Original line number Original line Diff line number Diff line
@@ -2422,17 +2422,26 @@


    <!-- Title for notification & dialog that the user's phone last shut down because it got too hot. [CHAR LIMIT=40] -->
    <!-- Title for notification & dialog that the user's phone last shut down because it got too hot. [CHAR LIMIT=40] -->
    <string name="thermal_shutdown_title">Phone turned off due to heat</string>
    <string name="thermal_shutdown_title">Phone turned off due to heat</string>
    <!-- Message body for notification that user's phone last shut down because it got too hot. [CHAR LIMIT=100] -->
    <!-- Message body for notification that user's phone last shut down because it got too hot. [CHAR LIMIT=120] -->
    <string name="thermal_shutdown_message">Your phone is now running normally</string>
    <string name="thermal_shutdown_message">Your phone is now running normally.\nTap for more info</string>
    <!-- Text body for dialog alerting user that their phone last shut down because it got too hot. [CHAR LIMIT=450] -->
    <!-- Text body for dialog alerting user that their phone last shut down because it got too hot. [CHAR LIMIT=500] -->
    <string name="thermal_shutdown_dialog_message">Your phone was too hot, so it turned off to cool down. Your phone is now running normally.\n\nYour phone may get too hot if you:\n\t&#8226; Use resource-intensive apps (such as gaming, video, or navigation apps)\n\t&#8226; Download or upload large files\n\t&#8226; Use your phone in high temperatures</string>
    <string name="thermal_shutdown_dialog_message">Your phone was too hot, so it turned off to cool down. Your phone is now running normally.\n\nYour phone may get too hot if you:\n\t&#8226; Use resource-intensive apps (such as gaming, video, or navigation apps)\n\t&#8226; Download or upload large files\n\t&#8226; Use your phone in high temperatures</string>
    <!-- Text help link for care instructions for overheating devices [CHAR LIMIT=40] -->
    <string name="thermal_shutdown_dialog_help_text">See care steps</string>
    <!-- URL for care instructions for overheating devices -->
    <string name="thermal_shutdown_dialog_help_url" translatable="false"></string>


    <!-- Title for notification (and dialog) that user's phone has reached a certain temperature and may start to slow down in order to cool down. [CHAR LIMIT=30] -->
    <!-- Title for notification (and dialog) that user's phone has reached a certain temperature and may start to slow down in order to cool down. [CHAR LIMIT=30] -->
    <string name="high_temp_title">Phone is getting warm</string>
    <string name="high_temp_title">Phone is getting warm</string>
    <!-- Message body for notification that user's phone has reached a certain temperature and may start to slow down in order to cool down. [CHAR LIMIT=100] -->
    <!-- Message body for notification that user's phone has reached a certain temperature and may start to slow down in order to cool down. [CHAR LIMIT=120] -->
    <string name="high_temp_notif_message">Some features limited while phone cools down</string>
    <string name="high_temp_notif_message">Some features limited while phone cools down.\nTap for more info</string>
    <!-- Text body for dialog alerting user that their phone has reached a certain temperature and may start to slow down in order to cool down. [CHAR LIMIT=300] -->
    <!-- Text body for dialog alerting user that their phone has reached a certain temperature and may start to slow down in order to cool down. [CHAR LIMIT=350] -->
    <string name="high_temp_dialog_message">Your phone will automatically try to cool down. You can still use your phone, but it may run slower.\n\nOnce your phone has cooled down, it will run normally.</string>
    <string name="high_temp_dialog_message">Your phone will automatically try to cool down. You can still use your phone, but it may run slower.\n\nOnce your phone has cooled down, it will run normally.</string>
    <!-- Text help link for care instructions for overheating devices [CHAR LIMIT=40] -->
    <string name="high_temp_dialog_help_text">See care steps</string>
    <!-- URL for care instructions for overheating devices -->
    <string name="high_temp_dialog_help_url" translatable="false"></string>

    <!-- Title for alarm dialog alerting user the usb adapter has reached a certain temperature that should disconnect charging cable immediately. [CHAR LIMIT=30] -->
    <!-- Title for alarm dialog alerting user the usb adapter has reached a certain temperature that should disconnect charging cable immediately. [CHAR LIMIT=30] -->
    <string name="high_temp_alarm_title">Unplug charger</string>
    <string name="high_temp_alarm_title">Unplug charger</string>
    <!-- Text body for dialog alerting user the usb adapter has reached a certain temperature that should disconnect charging cable immediately. [CHAR LIMIT=300] -->
    <!-- Text body for dialog alerting user the usb adapter has reached a certain temperature that should disconnect charging cable immediately. [CHAR LIMIT=300] -->
+41 −2
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentFilter;
import android.media.AudioAttributes;
import android.media.AudioAttributes;
@@ -376,13 +377,15 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
            return;
            return;
        }
        }
        mHighTempWarning = true;
        mHighTempWarning = true;
        final String message = mContext.getString(R.string.high_temp_notif_message);
        final Notification.Builder nb =
        final Notification.Builder nb =
                new Notification.Builder(mContext, NotificationChannels.ALERTS)
                new Notification.Builder(mContext, NotificationChannels.ALERTS)
                        .setSmallIcon(R.drawable.ic_device_thermostat_24)
                        .setSmallIcon(R.drawable.ic_device_thermostat_24)
                        .setWhen(0)
                        .setWhen(0)
                        .setShowWhen(false)
                        .setShowWhen(false)
                        .setContentTitle(mContext.getString(R.string.high_temp_title))
                        .setContentTitle(mContext.getString(R.string.high_temp_title))
                        .setContentText(mContext.getString(R.string.high_temp_notif_message))
                        .setContentText(message)
                        .setStyle(new Notification.BigTextStyle().bigText(message))
                        .setVisibility(Notification.VISIBILITY_PUBLIC)
                        .setVisibility(Notification.VISIBILITY_PUBLIC)
                        .setContentIntent(pendingBroadcast(ACTION_CLICKED_TEMP_WARNING))
                        .setContentIntent(pendingBroadcast(ACTION_CLICKED_TEMP_WARNING))
                        .setDeleteIntent(pendingBroadcast(ACTION_DISMISSED_TEMP_WARNING))
                        .setDeleteIntent(pendingBroadcast(ACTION_DISMISSED_TEMP_WARNING))
@@ -402,6 +405,23 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
        d.setPositiveButton(com.android.internal.R.string.ok, null);
        d.setPositiveButton(com.android.internal.R.string.ok, null);
        d.setShowForAllUsers(true);
        d.setShowForAllUsers(true);
        d.setOnDismissListener(dialog -> mHighTempDialog = null);
        d.setOnDismissListener(dialog -> mHighTempDialog = null);
        final String url = mContext.getString(R.string.high_temp_dialog_help_url);
        if (!url.isEmpty()) {
            d.setNeutralButton(R.string.high_temp_dialog_help_text,
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            final Intent helpIntent =
                                    new Intent(Intent.ACTION_VIEW)
                                            .setData(Uri.parse(url))
                                            .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            Dependency.get(ActivityStarter.class).startActivity(helpIntent,
                                    true /* dismissShade */, resultCode -> {
                                        mHighTempDialog = null;
                                    });
                        }
                    });
        }
        d.show();
        d.show();
        mHighTempDialog = d;
        mHighTempDialog = d;
    }
    }
@@ -420,19 +440,38 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
        d.setPositiveButton(com.android.internal.R.string.ok, null);
        d.setPositiveButton(com.android.internal.R.string.ok, null);
        d.setShowForAllUsers(true);
        d.setShowForAllUsers(true);
        d.setOnDismissListener(dialog -> mThermalShutdownDialog = null);
        d.setOnDismissListener(dialog -> mThermalShutdownDialog = null);
        final String url = mContext.getString(R.string.thermal_shutdown_dialog_help_url);
        if (!url.isEmpty()) {
            d.setNeutralButton(R.string.thermal_shutdown_dialog_help_text,
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            final Intent helpIntent =
                                    new Intent(Intent.ACTION_VIEW)
                                            .setData(Uri.parse(url))
                                            .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            Dependency.get(ActivityStarter.class).startActivity(helpIntent,
                                    true /* dismissShade */, resultCode -> {
                                        mThermalShutdownDialog = null;
                                    });
                        }
                    });
        }
        d.show();
        d.show();
        mThermalShutdownDialog = d;
        mThermalShutdownDialog = d;
    }
    }


    @Override
    @Override
    public void showThermalShutdownWarning() {
    public void showThermalShutdownWarning() {
        final String message = mContext.getString(R.string.thermal_shutdown_message);
        final Notification.Builder nb =
        final Notification.Builder nb =
                new Notification.Builder(mContext, NotificationChannels.ALERTS)
                new Notification.Builder(mContext, NotificationChannels.ALERTS)
                        .setSmallIcon(R.drawable.ic_device_thermostat_24)
                        .setSmallIcon(R.drawable.ic_device_thermostat_24)
                        .setWhen(0)
                        .setWhen(0)
                        .setShowWhen(false)
                        .setShowWhen(false)
                        .setContentTitle(mContext.getString(R.string.thermal_shutdown_title))
                        .setContentTitle(mContext.getString(R.string.thermal_shutdown_title))
                        .setContentText(mContext.getString(R.string.thermal_shutdown_message))
                        .setContentText(message)
                        .setStyle(new Notification.BigTextStyle().bigText(message))
                        .setVisibility(Notification.VISIBILITY_PUBLIC)
                        .setVisibility(Notification.VISIBILITY_PUBLIC)
                        .setContentIntent(pendingBroadcast(ACTION_CLICKED_THERMAL_SHUTDOWN_WARNING))
                        .setContentIntent(pendingBroadcast(ACTION_CLICKED_THERMAL_SHUTDOWN_WARNING))
                        .setDeleteIntent(
                        .setDeleteIntent(