Commit ba834b78 authored by Ehimare Okoyomon's avatar Ehimare Okoyomon Committed by Commit Bot

[Android] Fix Website Settings strings

Screenshot: https://crbug.com/1136533#c1
Bug: 1136533
Change-Id: I6140f9e49a723afd0dd4ae22b059784b2cf73d2f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2461308
Commit-Queue: Ehimare Okoyomon <eokoyomon@chromium.org>
Reviewed-by: default avatarClark DuVall <cduvall@chromium.org>
Reviewed-by: default avatarChristian Dullweber <dullweber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816123}
parent 108d547b
...@@ -36,19 +36,17 @@ public class ContentSettingsResources { ...@@ -36,19 +36,17 @@ public class ContentSettingsResources {
private static class ResourceItem { private static class ResourceItem {
private final int mIcon; private final int mIcon;
private final int mTitle; private final int mTitle;
private final int mExplanation;
private final @ContentSettingValues @Nullable Integer mDefaultEnabledValue; private final @ContentSettingValues @Nullable Integer mDefaultEnabledValue;
private final @ContentSettingValues @Nullable Integer mDefaultDisabledValue; private final @ContentSettingValues @Nullable Integer mDefaultDisabledValue;
private final int mEnabledSummary; private final int mEnabledSummary;
private final int mDisabledSummary; private final int mDisabledSummary;
ResourceItem(int icon, int title, int explanation, ResourceItem(int icon, int title,
@ContentSettingValues @Nullable Integer defaultEnabledValue, @ContentSettingValues @Nullable Integer defaultEnabledValue,
@ContentSettingValues @Nullable Integer defaultDisabledValue, int enabledSummary, @ContentSettingValues @Nullable Integer defaultDisabledValue, int enabledSummary,
int disabledSummary) { int disabledSummary) {
mIcon = icon; mIcon = icon;
mTitle = title; mTitle = title;
mExplanation = explanation;
mDefaultEnabledValue = defaultEnabledValue; mDefaultEnabledValue = defaultEnabledValue;
mDefaultDisabledValue = defaultDisabledValue; mDefaultDisabledValue = defaultDisabledValue;
mEnabledSummary = enabledSummary; mEnabledSummary = enabledSummary;
...@@ -63,10 +61,6 @@ public class ContentSettingsResources { ...@@ -63,10 +61,6 @@ public class ContentSettingsResources {
return mTitle; return mTitle;
} }
private int getExplanation() {
return mExplanation;
}
private @ContentSettingValues @Nullable Integer getDefaultEnabledValue() { private @ContentSettingValues @Nullable Integer getDefaultEnabledValue() {
return mDefaultEnabledValue; return mDefaultEnabledValue;
} }
...@@ -99,107 +93,94 @@ public class ContentSettingsResources { ...@@ -99,107 +93,94 @@ public class ContentSettingsResources {
Map<Integer, ResourceItem> localMap = new HashMap<Integer, ResourceItem>(); Map<Integer, ResourceItem> localMap = new HashMap<Integer, ResourceItem>();
localMap.put(ContentSettingsType.ADS, localMap.put(ContentSettingsType.ADS,
new ResourceItem(R.drawable.web_asset, R.string.ads_permission_title, new ResourceItem(R.drawable.web_asset, R.string.ads_permission_title,
R.string.ads_permission_title, ContentSettingValues.ALLOW, ContentSettingValues.ALLOW, ContentSettingValues.BLOCK, 0,
ContentSettingValues.BLOCK, 0,
R.string.website_settings_category_ads_blocked)); R.string.website_settings_category_ads_blocked));
localMap.put(ContentSettingsType.AR, localMap.put(ContentSettingsType.AR,
new ResourceItem(R.drawable.vr_headset, R.string.ar_permission_title, new ResourceItem(R.drawable.vr_headset, R.string.ar_permission_title,
R.string.ar_permission_title, ContentSettingValues.ASK, ContentSettingValues.ASK, ContentSettingValues.BLOCK,
ContentSettingValues.BLOCK, R.string.website_settings_category_ar_ask, R.string.website_settings_category_ar_ask,
R.string.website_settings_category_ar_blocked)); R.string.website_settings_category_ar_blocked));
localMap.put(ContentSettingsType.AUTOMATIC_DOWNLOADS, localMap.put(ContentSettingsType.AUTOMATIC_DOWNLOADS,
new ResourceItem(R.drawable.infobar_downloading, new ResourceItem(R.drawable.infobar_downloading,
R.string.automatic_downloads_permission_title,
R.string.automatic_downloads_permission_title, ContentSettingValues.ASK, R.string.automatic_downloads_permission_title, ContentSettingValues.ASK,
ContentSettingValues.BLOCK, R.string.website_settings_category_ask, 0)); ContentSettingValues.BLOCK, R.string.website_settings_category_ask, 0));
localMap.put(ContentSettingsType.BACKGROUND_SYNC, localMap.put(ContentSettingsType.BACKGROUND_SYNC,
new ResourceItem(R.drawable.permission_background_sync, new ResourceItem(R.drawable.permission_background_sync,
R.string.background_sync_permission_title,
R.string.background_sync_permission_title, ContentSettingValues.ALLOW, R.string.background_sync_permission_title, ContentSettingValues.ALLOW,
ContentSettingValues.BLOCK, ContentSettingValues.BLOCK,
R.string.website_settings_category_allowed_recommended, 0)); R.string.website_settings_category_allowed_recommended, 0));
localMap.put(ContentSettingsType.BLUETOOTH_CHOOSER_DATA, localMap.put(ContentSettingsType.BLUETOOTH_CHOOSER_DATA,
new ResourceItem(R.drawable.settings_bluetooth, 0, 0, ContentSettingValues.ASK, new ResourceItem(R.drawable.settings_bluetooth, 0, ContentSettingValues.ASK,
ContentSettingValues.BLOCK, 0, 0)); ContentSettingValues.BLOCK, 0, 0));
localMap.put(ContentSettingsType.BLUETOOTH_GUARD, localMap.put(ContentSettingsType.BLUETOOTH_GUARD,
new ResourceItem(R.drawable.settings_bluetooth, new ResourceItem(R.drawable.settings_bluetooth,
R.string.website_settings_bluetooth,
R.string.website_settings_bluetooth, ContentSettingValues.ASK, R.string.website_settings_bluetooth, ContentSettingValues.ASK,
ContentSettingValues.BLOCK, ContentSettingValues.BLOCK,
R.string.website_settings_category_bluetooth_ask, R.string.website_settings_category_bluetooth_ask,
R.string.website_settings_category_bluetooth_blocked)); R.string.website_settings_category_bluetooth_blocked));
localMap.put(ContentSettingsType.BLUETOOTH_SCANNING, localMap.put(ContentSettingsType.BLUETOOTH_SCANNING,
new ResourceItem(R.drawable.ic_bluetooth_searching_black_24dp, new ResourceItem(R.drawable.ic_bluetooth_searching_black_24dp,
R.string.website_settings_bluetooth_scanning,
R.string.website_settings_bluetooth_scanning, ContentSettingValues.ASK, R.string.website_settings_bluetooth_scanning, ContentSettingValues.ASK,
ContentSettingValues.BLOCK, ContentSettingValues.BLOCK,
R.string.website_settings_category_bluetooth_scanning_ask, 0)); R.string.website_settings_category_bluetooth_scanning_ask, 0));
localMap.put(ContentSettingsType.CLIPBOARD_READ_WRITE, localMap.put(ContentSettingsType.CLIPBOARD_READ_WRITE,
new ResourceItem(R.drawable.ic_content_paste_grey600_24dp, new ResourceItem(R.drawable.ic_content_paste_grey600_24dp,
R.string.clipboard_permission_title,
R.string.clipboard_permission_title, ContentSettingValues.ASK, R.string.clipboard_permission_title, ContentSettingValues.ASK,
ContentSettingValues.BLOCK, ContentSettingValues.BLOCK,
R.string.website_settings_category_clipboard_ask, R.string.website_settings_category_clipboard_ask,
R.string.website_settings_category_clipboard_blocked)); R.string.website_settings_category_clipboard_blocked));
localMap.put(ContentSettingsType.COOKIES, localMap.put(ContentSettingsType.COOKIES,
new ResourceItem(R.drawable.permission_cookie, R.string.cookies_title, new ResourceItem(R.drawable.permission_cookie, R.string.cookies_title,
R.string.cookies_title, ContentSettingValues.ALLOW, ContentSettingValues.ALLOW, ContentSettingValues.BLOCK,
ContentSettingValues.BLOCK,
R.string.website_settings_category_cookie_allowed, 0)); R.string.website_settings_category_cookie_allowed, 0));
localMap.put(ContentSettingsType.GEOLOCATION, localMap.put(ContentSettingsType.GEOLOCATION,
new ResourceItem(R.drawable.permission_location, new ResourceItem(R.drawable.permission_location,
R.string.website_settings_device_location, R.string.website_settings_device_location, ContentSettingValues.ASK,
R.string.geolocation_permission_title, ContentSettingValues.ASK,
ContentSettingValues.BLOCK, ContentSettingValues.BLOCK,
R.string.website_settings_category_location_ask, 0)); R.string.website_settings_category_location_ask, 0));
localMap.put(ContentSettingsType.IDLE_DETECTION, localMap.put(ContentSettingsType.IDLE_DETECTION,
new ResourceItem(R.drawable.permission_idle_detection, new ResourceItem(R.drawable.permission_idle_detection,
R.string.website_settings_idle_detection, R.string.website_settings_idle_detection, ContentSettingValues.ASK,
R.string.idle_detection_permission_title, ContentSettingValues.ASK,
ContentSettingValues.BLOCK, ContentSettingValues.BLOCK,
R.string.website_settings_category_idle_detection_ask, R.string.website_settings_category_idle_detection_ask,
R.string.website_settings_category_idle_detection_blocked)); R.string.website_settings_category_idle_detection_blocked));
localMap.put(ContentSettingsType.JAVASCRIPT, localMap.put(ContentSettingsType.JAVASCRIPT,
new ResourceItem(R.drawable.permission_javascript, new ResourceItem(R.drawable.permission_javascript,
R.string.javascript_permission_title,
R.string.javascript_permission_title, ContentSettingValues.ALLOW, R.string.javascript_permission_title, ContentSettingValues.ALLOW,
ContentSettingValues.BLOCK, ContentSettingValues.BLOCK,
R.string.website_settings_category_javascript_allowed, 0)); R.string.website_settings_category_javascript_allowed, 0));
localMap.put(ContentSettingsType.MEDIASTREAM_CAMERA, localMap.put(ContentSettingsType.MEDIASTREAM_CAMERA,
new ResourceItem(R.drawable.ic_videocam_white_24dp, new ResourceItem(R.drawable.ic_videocam_white_24dp,
R.string.website_settings_use_camera, R.string.camera_permission_title, R.string.website_settings_use_camera, ContentSettingValues.ASK,
ContentSettingValues.ASK, ContentSettingValues.BLOCK, ContentSettingValues.BLOCK,
R.string.website_settings_category_camera_ask, 0)); R.string.website_settings_category_camera_ask, 0));
localMap.put(ContentSettingsType.MEDIASTREAM_MIC, localMap.put(ContentSettingsType.MEDIASTREAM_MIC,
new ResourceItem(R.drawable.permission_mic, R.string.website_settings_use_mic, new ResourceItem(R.drawable.permission_mic, R.string.website_settings_use_mic,
R.string.mic_permission_title, ContentSettingValues.ASK, ContentSettingValues.ASK, ContentSettingValues.BLOCK,
ContentSettingValues.BLOCK, R.string.website_settings_category_mic_ask, R.string.website_settings_category_mic_ask, 0));
0));
localMap.put(ContentSettingsType.MIDI_SYSEX, localMap.put(ContentSettingsType.MIDI_SYSEX,
new ResourceItem(R.drawable.permission_midi, 0, new ResourceItem(R.drawable.permission_midi,
R.string.midi_sysex_permission_title, null, null, 0, 0)); R.string.midi_sysex_permission_title, null, null, 0, 0));
localMap.put(ContentSettingsType.NFC, localMap.put(ContentSettingsType.NFC,
new ResourceItem(R.drawable.settings_nfc, R.string.nfc_permission_title, new ResourceItem(R.drawable.settings_nfc, R.string.nfc_permission_title,
R.string.nfc_permission_title, ContentSettingValues.ASK, ContentSettingValues.ASK, ContentSettingValues.BLOCK,
ContentSettingValues.BLOCK, R.string.website_settings_category_nfc_ask, R.string.website_settings_category_nfc_ask,
R.string.website_settings_category_nfc_blocked)); R.string.website_settings_category_nfc_blocked));
localMap.put(ContentSettingsType.NOTIFICATIONS, localMap.put(ContentSettingsType.NOTIFICATIONS,
new ResourceItem(R.drawable.permission_push_notification, new ResourceItem(R.drawable.permission_push_notification,
R.string.push_notifications_permission_title,
R.string.push_notifications_permission_title, ContentSettingValues.ASK, R.string.push_notifications_permission_title, ContentSettingValues.ASK,
ContentSettingValues.BLOCK, ContentSettingValues.BLOCK,
R.string.website_settings_category_notifications_ask, 0)); R.string.website_settings_category_notifications_ask, 0));
localMap.put(ContentSettingsType.POPUPS, localMap.put(ContentSettingsType.POPUPS,
new ResourceItem(R.drawable.permission_popups, R.string.popup_permission_title, new ResourceItem(R.drawable.permission_popups, R.string.popup_permission_title,
R.string.popup_permission_title, ContentSettingValues.ALLOW, ContentSettingValues.ALLOW, ContentSettingValues.BLOCK, 0,
ContentSettingValues.BLOCK, 0,
R.string.website_settings_category_popups_redirects_blocked)); R.string.website_settings_category_popups_redirects_blocked));
// PROTECTED_MEDIA_IDENTIFIER uses 3-state preference so some values are not used. // PROTECTED_MEDIA_IDENTIFIER uses 3-state preference so some values are not used.
// If 3-state becomes more common we should update localMaps to support it better. // If 3-state becomes more common we should update localMaps to support it better.
localMap.put(ContentSettingsType.PROTECTED_MEDIA_IDENTIFIER, localMap.put(ContentSettingsType.PROTECTED_MEDIA_IDENTIFIER,
new ResourceItem(R.drawable.permission_protected_media, new ResourceItem(R.drawable.permission_protected_media,
R.string.protected_content, R.string.protected_content, R.string.protected_content, ContentSettingValues.ASK,
ContentSettingValues.ASK, ContentSettingValues.BLOCK, 0, 0)); ContentSettingValues.BLOCK, 0, 0));
int sensorsPermissionTitle = R.string.motion_sensors_permission_title; int sensorsPermissionTitle = R.string.motion_sensors_permission_title;
int sensorsAllowedDescription = int sensorsAllowedDescription =
R.string.website_settings_category_motion_sensors_allowed; R.string.website_settings_category_motion_sensors_allowed;
...@@ -218,27 +199,26 @@ public class ContentSettingsResources { ...@@ -218,27 +199,26 @@ public class ContentSettingsResources {
} }
localMap.put(ContentSettingsType.SENSORS, localMap.put(ContentSettingsType.SENSORS,
new ResourceItem(R.drawable.settings_sensors, sensorsPermissionTitle, new ResourceItem(R.drawable.settings_sensors, sensorsPermissionTitle,
sensorsPermissionTitle, ContentSettingValues.ALLOW, ContentSettingValues.ALLOW, ContentSettingValues.BLOCK,
ContentSettingValues.BLOCK, sensorsAllowedDescription, sensorsAllowedDescription, sensorsBlockedDescription));
sensorsBlockedDescription));
localMap.put(ContentSettingsType.SOUND, localMap.put(ContentSettingsType.SOUND,
new ResourceItem(R.drawable.ic_volume_up_grey600_24dp, new ResourceItem(R.drawable.ic_volume_up_grey600_24dp,
R.string.sound_permission_title, R.string.sound_permission_title, R.string.sound_permission_title, ContentSettingValues.ALLOW,
ContentSettingValues.ALLOW, ContentSettingValues.BLOCK, ContentSettingValues.BLOCK,
R.string.website_settings_category_sound_allowed, R.string.website_settings_category_sound_allowed,
R.string.website_settings_category_sound_blocked)); R.string.website_settings_category_sound_blocked));
localMap.put(ContentSettingsType.USB_CHOOSER_DATA, localMap.put(ContentSettingsType.USB_CHOOSER_DATA,
new ResourceItem(R.drawable.settings_usb, 0, 0, ContentSettingValues.ASK, new ResourceItem(R.drawable.settings_usb, 0, ContentSettingValues.ASK,
ContentSettingValues.BLOCK, 0, 0)); ContentSettingValues.BLOCK, 0, 0));
localMap.put(ContentSettingsType.USB_GUARD, localMap.put(ContentSettingsType.USB_GUARD,
new ResourceItem(R.drawable.settings_usb, R.string.website_settings_usb, new ResourceItem(R.drawable.settings_usb, R.string.website_settings_usb,
R.string.website_settings_usb, ContentSettingValues.ASK, ContentSettingValues.ASK, ContentSettingValues.BLOCK,
ContentSettingValues.BLOCK, R.string.website_settings_category_usb_ask, R.string.website_settings_category_usb_ask,
R.string.website_settings_category_usb_blocked)); R.string.website_settings_category_usb_blocked));
localMap.put(ContentSettingsType.VR, localMap.put(ContentSettingsType.VR,
new ResourceItem(R.drawable.vr_headset, R.string.vr_permission_title, new ResourceItem(R.drawable.vr_headset, R.string.vr_permission_title,
R.string.vr_permission_title, ContentSettingValues.ASK, ContentSettingValues.ASK, ContentSettingValues.BLOCK,
ContentSettingValues.BLOCK, R.string.website_settings_category_vr_ask, R.string.website_settings_category_vr_ask,
R.string.website_settings_category_vr_blocked)); R.string.website_settings_category_vr_blocked));
sResourceInfo = localMap; sResourceInfo = localMap;
} }
...@@ -279,13 +259,6 @@ public class ContentSettingsResources { ...@@ -279,13 +259,6 @@ public class ContentSettingsResources {
return getResourceItem(contentType).getTitle(); return getResourceItem(contentType).getTitle();
} }
/**
* Returns the resource id of the title explanation, shown on the Website Details page for
* a content type.
*/
public static int getExplanation(int contentType) {
return getResourceItem(contentType).getExplanation();
}
/** /**
* Returns which ContentSetting the global default is set to, when enabled. * Returns which ContentSetting the global default is set to, when enabled.
......
...@@ -843,9 +843,9 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment ...@@ -843,9 +843,9 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
*/ */
private void setUpPreferenceCommon(Preference preference) { private void setUpPreferenceCommon(Preference preference) {
int contentType = getContentSettingsTypeFromPreferenceKey(preference.getKey()); int contentType = getContentSettingsTypeFromPreferenceKey(preference.getKey());
int explanationResourceId = ContentSettingsResources.getExplanation(contentType); int titleResourceId = ContentSettingsResources.getTitle(contentType);
if (explanationResourceId != 0) { if (titleResourceId != 0) {
preference.setTitle(explanationResourceId); preference.setTitle(titleResourceId);
} }
if (!preference.isEnabled()) { if (!preference.isEnabled()) {
preference.setIcon( preference.setIcon(
......
...@@ -289,9 +289,6 @@ ...@@ -289,9 +289,6 @@
<message name="IDS_WEBSITE_SETTINGS_CATEGORY_CAMERA_ASK" desc="Summary text explaining that sites need to ask for permission before accessing the camera and that it is the recommended setting."> <message name="IDS_WEBSITE_SETTINGS_CATEGORY_CAMERA_ASK" desc="Summary text explaining that sites need to ask for permission before accessing the camera and that it is the recommended setting.">
Ask first before allowing sites to use your camera (recommended) Ask first before allowing sites to use your camera (recommended)
</message> </message>
<message name="IDS_CAMERA_PERMISSION_TITLE" desc="Title text to be shown when the user has allowed/denied video access for the website [CHAR-LIMIT=32]">
Access your camera
</message>
<message name="IDS_ANDROID_CAMERA_PERMISSION_OFF" desc="The message to show when the camera permission needs to be turned on not just in Chrome, but also in Android settings."> <message name="IDS_ANDROID_CAMERA_PERMISSION_OFF" desc="The message to show when the camera permission needs to be turned on not just in Chrome, but also in Android settings.">
To let <ph name="APP_NAME">%1$s<ex>Chrome</ex></ph> access your camera, also turn on camera in <ph name="BEGIN_LINK">&lt;link&gt;</ph>Android Settings<ph name="END_LINK">&lt;/link&gt;</ph>. To let <ph name="APP_NAME">%1$s<ex>Chrome</ex></ph> access your camera, also turn on camera in <ph name="BEGIN_LINK">&lt;link&gt;</ph>Android Settings<ph name="END_LINK">&lt;/link&gt;</ph>.
</message> </message>
...@@ -345,9 +342,6 @@ ...@@ -345,9 +342,6 @@
</message> </message>
<!-- Idle Detection --> <!-- Idle Detection -->
<message name="IDS_IDLE_DETECTION_PERMISSION_TITLE" desc="Title for the permission of detecting user activity [CHAR-LIMIT=32]">
User presence
</message>
<message name="IDS_WEBSITE_SETTINGS_CATEGORY_IDLE_DETECTION_ASK" desc="The description for the option to allow sites to ask for permission to access your activity state"> <message name="IDS_WEBSITE_SETTINGS_CATEGORY_IDLE_DETECTION_ASK" desc="The description for the option to allow sites to ask for permission to access your activity state">
Ask when a site wants to know when you're present Ask when a site wants to know when you're present
</message> </message>
...@@ -369,9 +363,6 @@ ...@@ -369,9 +363,6 @@
<!-- Location --> <!-- Location -->
<message name="IDS_GEOLOCATION_PERMISSION_TITLE" desc="Title for the permission of accessing the current location of a device [CHAR-LIMIT=32]">
Location access
</message>
<message name="IDS_WEBSITE_SETTINGS_CATEGORY_LOCATION_ASK" desc="Summary text explaining that sites need to ask for permission before knowing location and that it is the recommended setting."> <message name="IDS_WEBSITE_SETTINGS_CATEGORY_LOCATION_ASK" desc="Summary text explaining that sites need to ask for permission before knowing location and that it is the recommended setting.">
Ask before allowing sites to know your location (recommended) Ask before allowing sites to know your location (recommended)
</message> </message>
...@@ -390,9 +381,6 @@ ...@@ -390,9 +381,6 @@
<!-- Microphone --> <!-- Microphone -->
<message name="IDS_MIC_PERMISSION_TITLE" desc="Title text to be shown when the user has allowed/denied voice access for the website [CHAR-LIMIT=32]">
Access your microphone
</message>
<message name="IDS_WEBSITE_SETTINGS_CATEGORY_MIC_ASK" desc="Summary text explaining that sites need to ask for permission before accessing the microphone and that it is the recommended setting."> <message name="IDS_WEBSITE_SETTINGS_CATEGORY_MIC_ASK" desc="Summary text explaining that sites need to ask for permission before accessing the microphone and that it is the recommended setting.">
Ask first before allowing sites to use your microphone (recommended) Ask first before allowing sites to use your microphone (recommended)
</message> </message>
......
...@@ -29,7 +29,8 @@ import java.util.Locale; ...@@ -29,7 +29,8 @@ import java.util.Locale;
/** Tests that translations work correctly for Java strings inside bundles. */ /** Tests that translations work correctly for Java strings inside bundles. */
@RunWith(WebLayerJUnit4ClassRunner.class) @RunWith(WebLayerJUnit4ClassRunner.class)
public class BundleLanguageTest { public class BundleLanguageTest {
private static final String WEBLAYER_SPECIFIC_STRING = "string/geolocation_permission_title"; private static final String WEBLAYER_SPECIFIC_STRING =
"string/infobar_missing_location_permission_text";
private static final String SHARED_STRING = "string/color_picker_dialog_title"; private static final String SHARED_STRING = "string/color_picker_dialog_title";
@Rule @Rule
......
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