Commit 66a77596 authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Android: Improve and simplify strings for media streaming notifications

1. Split notification text into two lines, meaning the URL is
   actually readable without expanding notification.

2. String change: use "A site is using your camera" instead of
   "Accessing video input"

3. Unify incognito and normal strings.
   Incognito was "A site is accessing video input" whereas normal was
   "Accessing video input". Now they're both the same.

4. Use "tap" more consistently. Sometimes we were using "touch" and
   sometimes "tap".

5. Use grit placeholders instead of manually appending string elements
   (pre-N).

6. Move android only strings into android only strings file.

7. Make screen capture consistent with other types in terms of
   formatting (place url at end of second line of text instead of at
   start of first line of text).

See screenshots on bug.
UX: meggynwatkins@

Bug: 1067409
Change-Id: I58e531eae2f037bf6faabd5bbb49658c657c732b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2138776
Auto-Submit: Evan Stade <estade@chromium.org>
Commit-Queue: Evan Stade <estade@chromium.org>
Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759736}
parent 8bf07559
...@@ -201,9 +201,10 @@ public class MediaCaptureNotificationService extends Service { ...@@ -201,9 +201,10 @@ public class MediaCaptureNotificationService extends Service {
.setLocalOnly(true); .setLocalOnly(true);
Intent tabIntent = ChromeIntentUtil.createBringTabToFrontIntent(notificationId); Intent tabIntent = ChromeIntentUtil.createBringTabToFrontIntent(notificationId);
Context appContext = ContextUtils.getApplicationContext();
if (tabIntent != null) { if (tabIntent != null) {
PendingIntentProvider contentIntent = PendingIntentProvider.getActivity( PendingIntentProvider contentIntent =
ContextUtils.getApplicationContext(), notificationId, tabIntent, 0); PendingIntentProvider.getActivity(appContext, notificationId, tabIntent, 0);
builder.setContentIntent(contentIntent); builder.setContentIntent(contentIntent);
if (mediaType == MediaType.SCREEN_CAPTURE) { if (mediaType == MediaType.SCREEN_CAPTURE) {
// Add a "Stop" button to the screen capture notification and turn the notification // Add a "Stop" button to the screen capture notification and turn the notification
...@@ -211,47 +212,35 @@ public class MediaCaptureNotificationService extends Service { ...@@ -211,47 +212,35 @@ public class MediaCaptureNotificationService extends Service {
builder.setPriorityBeforeO(NotificationCompat.PRIORITY_HIGH); builder.setPriorityBeforeO(NotificationCompat.PRIORITY_HIGH);
builder.setVibrate(new long[0]); builder.setVibrate(new long[0]);
builder.addAction(R.drawable.ic_stop_white_36dp, builder.addAction(R.drawable.ic_stop_white_36dp,
ContextUtils.getApplicationContext().getResources().getString( appContext.getString(R.string.accessibility_stop),
R.string.accessibility_stop),
buildStopCapturePendingIntent(notificationId)); buildStopCapturePendingIntent(notificationId));
} }
} }
StringBuilder descriptionText = String titleText = getNotificationTitleText(mediaType);
new StringBuilder(getNotificationContentText(mediaType, url, isIncognito)) // App name is automatically added to the title from Android N, but needs to be added
.append('.'); // explicitly for prior versions.
if (isRunningAtLeastN()) {
builder.setContentTitle(titleText);
} else {
builder.setContentTitle(
appContext.getString(R.string.media_capture_notification_app_name_separator,
appContext.getString(R.string.app_name), titleText));
}
String contentText; String contentText = null;
if (isIncognito) { if (isIncognito) {
builder.setSubText(ContextUtils.getApplicationContext().getResources().getString( contentText = appContext.getString(
R.string.notification_incognito_tab)); R.string.media_capture_notification_content_text_incognito);
// App name is automatically added to the title from Android N, builder.setSubText(appContext.getString(R.string.notification_incognito_tab));
// but needs to be added explicitly for prior versions. } else if (tabIntent == null) {
String appNamePrefix = isRunningAtLeastN() contentText = url;
? ""
: (ContextUtils.getApplicationContext().getString(R.string.app_name) + " - ");
builder.setContentTitle(appNamePrefix + descriptionText.toString());
contentText = ContextUtils.getApplicationContext().getResources().getString(
R.string.media_notification_link_text_incognito);
} else { } else {
if (tabIntent == null) { contentText =
descriptionText.append(" ").append(url); appContext.getString(R.string.media_capture_notification_content_text, url);
} else if (mediaType != MediaType.SCREEN_CAPTURE) {
descriptionText.append(" ").append(
ContextUtils.getApplicationContext().getResources().getString(
R.string.media_notification_link_text, url));
}
// From Android N, notification by default has the app name and title should not be the
// same as app name.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
builder.setContentTitle(
ContextUtils.getApplicationContext().getString(R.string.app_name));
}
contentText = descriptionText.toString();
} }
builder.setContentText(contentText);
builder.setContentText(contentText);
ChromeNotification notification = builder.buildWithBigTextStyle(contentText); ChromeNotification notification = builder.buildWithBigTextStyle(contentText);
mNotificationManager.notify(notification); mNotificationManager.notify(notification);
mNotifications.put(notificationId, mediaType); mNotifications.put(notificationId, mediaType);
...@@ -262,37 +251,22 @@ public class MediaCaptureNotificationService extends Service { ...@@ -262,37 +251,22 @@ public class MediaCaptureNotificationService extends Service {
} }
/** /**
* Builds notification content text for the provided mediaType and url.
* @param mediaType Media type of the notification. * @param mediaType Media type of the notification.
* @param url Url of the current webrtc call. * @return user-facing text for the provided mediaType.
* @return A string builder initialized to the contents of the specified string.
*/ */
private String getNotificationContentText( private String getNotificationTitleText(@MediaType int mediaType) {
@MediaType int mediaType, String url, boolean hideUserData) {
if (mediaType == MediaType.SCREEN_CAPTURE) {
return ContextUtils.getApplicationContext().getResources().getString(hideUserData
? R.string.screen_capture_incognito_notification_text
: R.string.screen_capture_notification_text,
url);
}
int notificationContentTextId = 0; int notificationContentTextId = 0;
if (mediaType == MediaType.AUDIO_AND_VIDEO) { if (mediaType == MediaType.SCREEN_CAPTURE) {
notificationContentTextId = hideUserData notificationContentTextId = R.string.screen_capture_notification_title;
? R.string.video_audio_call_incognito_notification_text_2 } else if (mediaType == MediaType.AUDIO_AND_VIDEO) {
: R.string.video_audio_call_notification_text_2; notificationContentTextId = R.string.video_audio_capture_notification_title;
} else if (mediaType == MediaType.VIDEO_ONLY) { } else if (mediaType == MediaType.VIDEO_ONLY) {
notificationContentTextId = hideUserData notificationContentTextId = R.string.video_capture_notification_title;
? R.string.video_call_incognito_notification_text_2
: R.string.video_call_notification_text_2;
} else if (mediaType == MediaType.AUDIO_ONLY) { } else if (mediaType == MediaType.AUDIO_ONLY) {
notificationContentTextId = hideUserData notificationContentTextId = R.string.audio_capture_notification_title;
? R.string.audio_call_incognito_notification_text_2
: R.string.audio_call_notification_text_2;
} }
return ContextUtils.getApplicationContext().getResources().getString( return ContextUtils.getApplicationContext().getString(notificationContentTextId);
notificationContentTextId);
} }
/** /**
......
...@@ -9803,28 +9803,6 @@ Please help our engineers fix this problem. Tell us what happened right before y ...@@ -9803,28 +9803,6 @@ Please help our engineers fix this problem. Tell us what happened right before y
</message> </message>
</if> </if>
<!-- Media capture notification strings -->
<if expr="is_android or enable_vr">
<message name="IDS_VIDEO_CALL_NOTIFICATION_TEXT_2" desc="Text to be shown as a notification when a WebRTC video call is in progress." formatter_data="android_java">
Accessing video input
</message>
<message name="IDS_AUDIO_CALL_NOTIFICATION_TEXT_2" desc="Text to be shown as a notification when a WebRTC audio call is in progress" formatter_data="android_java">
Accessing audio input
</message>
<message name="IDS_VIDEO_AUDIO_CALL_NOTIFICATION_TEXT_2" desc="Text to be shown as a notification when a WebRTC video and audio call is in progress" formatter_data="android_java">
Accessing audio and video input
</message>
<message name="IDS_VIDEO_CALL_INCOGNITO_NOTIFICATION_TEXT_2" desc="Text to be shown as a notification when a WebRTC video call is in progress in incognito mode." formatter_data="android_java">
A site is accessing video input
</message>
<message name="IDS_AUDIO_CALL_INCOGNITO_NOTIFICATION_TEXT_2" desc="Text to be shown as a notification when a WebRTC audio call is in progress in incognito mode." formatter_data="android_java">
A site is accessing audio input
</message>
<message name="IDS_VIDEO_AUDIO_CALL_INCOGNITO_NOTIFICATION_TEXT_2" desc="Text to be shown as a notification when a WebRTC video and audio call is in progress in incognito mode." formatter_data="android_java">
A site is accessing audio and video input
</message>
</if>
<!-- Download open confirmation dialog --> <!-- Download open confirmation dialog -->
<if expr="not is_android"> <if expr="not is_android">
<message name="IDS_DOWNLOAD_OPEN_CONFIRMATION_DIALOG_TITLE" desc="Title of the dialog prompt shown to users when an extension is trying to open a downloaded file."> <message name="IDS_DOWNLOAD_OPEN_CONFIRMATION_DIALOG_TITLE" desc="Title of the dialog prompt shown to users when an extension is trying to open a downloaded file.">
......
...@@ -3155,23 +3155,36 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p ...@@ -3155,23 +3155,36 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
Tabs Tabs
</message> </message>
<message name="IDS_MEDIA_NOTIFICATION_LINK_TEXT" desc="Url of the current tab. The notification will display this text for the user to identify the tab to return to."> <message name="IDS_MEDIA_CAPTURE_NOTIFICATION_APP_NAME_SEPARATOR" desc="A separator between the app name and notification message.">
Touch to return to <ph name="URL_OF_THE_CURRENT_TAB">%1$s<ex>https://apprtc.appspot.com</ex></ph> <ph name="APP_NAME">%1$s<ex>Chrome</ex></ph> - <ph name="NOTIFICATION_MESSAGE">%2$s<ex>Accessing video input</ex></ph>
</message> </message>
<message name="IDS_MEDIA_NOTIFICATION_LINK_TEXT_INCOGNITO" desc="The notification will display this text for the user to return to the incognito tab which has created the notification.">
Tap to go to site <message name="IDS_MEDIA_CAPTURE_NOTIFICATION_CONTENT_TEXT" desc="Url of the current tab. The notification will display this text for the user to identify the tab to return to.">
Tap to return to <ph name="URL_OF_THE_CURRENT_TAB">%1$s<ex>https://apprtc.appspot.com</ex></ph>
</message> </message>
<message name="IDS_MEDIA_NOTIFICATION_INCOGNITO" desc="Text used as a placeholder for media notifications content, when notification is shown from incognito tab."> <message name="IDS_MEDIA_CAPTURE_NOTIFICATION_CONTENT_TEXT_INCOGNITO" desc="The notification will display this text for the user to return to the incognito tab which has created the notification.">
A site is playing media Tap to return to the site
</message> </message>
<message name="IDS_NOTIFICATION_INCOGNITO_TAB" desc="Text used as notifications source when the notification is from incognito tabs."> <message name="IDS_NOTIFICATION_INCOGNITO_TAB" desc="Text used as notifications source when the notification is from incognito tabs.">
Incognito tab Incognito tab
</message> </message>
<message name="IDS_SCREEN_CAPTURE_NOTIFICATION_TEXT" desc="Text to be shown as a notification when screen capture is in progress."> <message name="IDS_SCREEN_CAPTURE_NOTIFICATION_TITLE" desc="Text to be shown as a notification when screen capture is in progress.">
<ph name="URL_OF_THE_CURRENT_TAB">%1$s<ex>https://apprtc.appspot.com</ex></ph> is sharing your screen Sharing your screen
</message>
<message name="IDS_VIDEO_CAPTURE_NOTIFICATION_TITLE" desc="Text to be shown as a notification when a WebRTC video call is in progress.">
A site is using your camera
</message> </message>
<message name="IDS_SCREEN_CAPTURE_INCOGNITO_NOTIFICATION_TEXT" desc="Text to be shown as a notification when screen capture is in progress in incognito mode."> <message name="IDS_AUDIO_CAPTURE_NOTIFICATION_TITLE" desc="Text to be shown as a notification when a WebRTC audio call is in progress">
A site is sharing your screen A site is using your microphone
</message>
<message name="IDS_VIDEO_AUDIO_CAPTURE_NOTIFICATION_TITLE" desc="Text to be shown as a notification when a WebRTC video and audio call is in progress">
A site is using your camera and microphone
</message>
<message name="IDS_MEDIA_NOTIFICATION_INCOGNITO" desc="Text used as a placeholder for a media notification about playing media, when notification is shown from incognito tab.">
A site is playing media
</message> </message>
<!-- Contextual Search --> <!-- Contextual Search -->
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment