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 {
private static class ResourceItem {
private final int mIcon;
private final int mTitle;
private final int mExplanation;
private final @ContentSettingValues @Nullable Integer mDefaultEnabledValue;
private final @ContentSettingValues @Nullable Integer mDefaultDisabledValue;
private final int mEnabledSummary;
private final int mDisabledSummary;
ResourceItem(int icon, int title, int explanation,
ResourceItem(int icon, int title,
@ContentSettingValues @Nullable Integer defaultEnabledValue,
@ContentSettingValues @Nullable Integer defaultDisabledValue, int enabledSummary,
int disabledSummary) {
mIcon = icon;
mTitle = title;
mExplanation = explanation;
mDefaultEnabledValue = defaultEnabledValue;
mDefaultDisabledValue = defaultDisabledValue;
mEnabledSummary = enabledSummary;
......@@ -63,10 +61,6 @@ public class ContentSettingsResources {
return mTitle;
}
private int getExplanation() {
return mExplanation;
}
private @ContentSettingValues @Nullable Integer getDefaultEnabledValue() {
return mDefaultEnabledValue;
}
......@@ -99,107 +93,94 @@ public class ContentSettingsResources {
Map<Integer, ResourceItem> localMap = new HashMap<Integer, ResourceItem>();
localMap.put(ContentSettingsType.ADS,
new ResourceItem(R.drawable.web_asset, R.string.ads_permission_title,
R.string.ads_permission_title, ContentSettingValues.ALLOW,
ContentSettingValues.BLOCK, 0,
ContentSettingValues.ALLOW, ContentSettingValues.BLOCK, 0,
R.string.website_settings_category_ads_blocked));
localMap.put(ContentSettingsType.AR,
new ResourceItem(R.drawable.vr_headset, R.string.ar_permission_title,
R.string.ar_permission_title, ContentSettingValues.ASK,
ContentSettingValues.BLOCK, R.string.website_settings_category_ar_ask,
ContentSettingValues.ASK, ContentSettingValues.BLOCK,
R.string.website_settings_category_ar_ask,
R.string.website_settings_category_ar_blocked));
localMap.put(ContentSettingsType.AUTOMATIC_DOWNLOADS,
new ResourceItem(R.drawable.infobar_downloading,
R.string.automatic_downloads_permission_title,
R.string.automatic_downloads_permission_title, ContentSettingValues.ASK,
ContentSettingValues.BLOCK, R.string.website_settings_category_ask, 0));
localMap.put(ContentSettingsType.BACKGROUND_SYNC,
new ResourceItem(R.drawable.permission_background_sync,
R.string.background_sync_permission_title,
R.string.background_sync_permission_title, ContentSettingValues.ALLOW,
ContentSettingValues.BLOCK,
R.string.website_settings_category_allowed_recommended, 0));
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));
localMap.put(ContentSettingsType.BLUETOOTH_GUARD,
new ResourceItem(R.drawable.settings_bluetooth,
R.string.website_settings_bluetooth,
R.string.website_settings_bluetooth, ContentSettingValues.ASK,
ContentSettingValues.BLOCK,
R.string.website_settings_category_bluetooth_ask,
R.string.website_settings_category_bluetooth_blocked));
localMap.put(ContentSettingsType.BLUETOOTH_SCANNING,
new ResourceItem(R.drawable.ic_bluetooth_searching_black_24dp,
R.string.website_settings_bluetooth_scanning,
R.string.website_settings_bluetooth_scanning, ContentSettingValues.ASK,
ContentSettingValues.BLOCK,
R.string.website_settings_category_bluetooth_scanning_ask, 0));
localMap.put(ContentSettingsType.CLIPBOARD_READ_WRITE,
new ResourceItem(R.drawable.ic_content_paste_grey600_24dp,
R.string.clipboard_permission_title,
R.string.clipboard_permission_title, ContentSettingValues.ASK,
ContentSettingValues.BLOCK,
R.string.website_settings_category_clipboard_ask,
R.string.website_settings_category_clipboard_blocked));
localMap.put(ContentSettingsType.COOKIES,
new ResourceItem(R.drawable.permission_cookie, R.string.cookies_title,
R.string.cookies_title, ContentSettingValues.ALLOW,
ContentSettingValues.BLOCK,
ContentSettingValues.ALLOW, ContentSettingValues.BLOCK,
R.string.website_settings_category_cookie_allowed, 0));
localMap.put(ContentSettingsType.GEOLOCATION,
new ResourceItem(R.drawable.permission_location,
R.string.website_settings_device_location,
R.string.geolocation_permission_title, ContentSettingValues.ASK,
R.string.website_settings_device_location, ContentSettingValues.ASK,
ContentSettingValues.BLOCK,
R.string.website_settings_category_location_ask, 0));
localMap.put(ContentSettingsType.IDLE_DETECTION,
new ResourceItem(R.drawable.permission_idle_detection,
R.string.website_settings_idle_detection,
R.string.idle_detection_permission_title, ContentSettingValues.ASK,
R.string.website_settings_idle_detection, ContentSettingValues.ASK,
ContentSettingValues.BLOCK,
R.string.website_settings_category_idle_detection_ask,
R.string.website_settings_category_idle_detection_blocked));
localMap.put(ContentSettingsType.JAVASCRIPT,
new ResourceItem(R.drawable.permission_javascript,
R.string.javascript_permission_title,
R.string.javascript_permission_title, ContentSettingValues.ALLOW,
ContentSettingValues.BLOCK,
R.string.website_settings_category_javascript_allowed, 0));
localMap.put(ContentSettingsType.MEDIASTREAM_CAMERA,
new ResourceItem(R.drawable.ic_videocam_white_24dp,
R.string.website_settings_use_camera, R.string.camera_permission_title,
ContentSettingValues.ASK, ContentSettingValues.BLOCK,
R.string.website_settings_use_camera, ContentSettingValues.ASK,
ContentSettingValues.BLOCK,
R.string.website_settings_category_camera_ask, 0));
localMap.put(ContentSettingsType.MEDIASTREAM_MIC,
new ResourceItem(R.drawable.permission_mic, R.string.website_settings_use_mic,
R.string.mic_permission_title, ContentSettingValues.ASK,
ContentSettingValues.BLOCK, R.string.website_settings_category_mic_ask,
0));
ContentSettingValues.ASK, ContentSettingValues.BLOCK,
R.string.website_settings_category_mic_ask, 0));
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));
localMap.put(ContentSettingsType.NFC,
new ResourceItem(R.drawable.settings_nfc, R.string.nfc_permission_title,
R.string.nfc_permission_title, ContentSettingValues.ASK,
ContentSettingValues.BLOCK, R.string.website_settings_category_nfc_ask,
ContentSettingValues.ASK, ContentSettingValues.BLOCK,
R.string.website_settings_category_nfc_ask,
R.string.website_settings_category_nfc_blocked));
localMap.put(ContentSettingsType.NOTIFICATIONS,
new ResourceItem(R.drawable.permission_push_notification,
R.string.push_notifications_permission_title,
R.string.push_notifications_permission_title, ContentSettingValues.ASK,
ContentSettingValues.BLOCK,
R.string.website_settings_category_notifications_ask, 0));
localMap.put(ContentSettingsType.POPUPS,
new ResourceItem(R.drawable.permission_popups, R.string.popup_permission_title,
R.string.popup_permission_title, ContentSettingValues.ALLOW,
ContentSettingValues.BLOCK, 0,
ContentSettingValues.ALLOW, ContentSettingValues.BLOCK, 0,
R.string.website_settings_category_popups_redirects_blocked));
// 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.
localMap.put(ContentSettingsType.PROTECTED_MEDIA_IDENTIFIER,
new ResourceItem(R.drawable.permission_protected_media,
R.string.protected_content, R.string.protected_content,
ContentSettingValues.ASK, ContentSettingValues.BLOCK, 0, 0));
R.string.protected_content, ContentSettingValues.ASK,
ContentSettingValues.BLOCK, 0, 0));
int sensorsPermissionTitle = R.string.motion_sensors_permission_title;
int sensorsAllowedDescription =
R.string.website_settings_category_motion_sensors_allowed;
......@@ -218,27 +199,26 @@ public class ContentSettingsResources {
}
localMap.put(ContentSettingsType.SENSORS,
new ResourceItem(R.drawable.settings_sensors, sensorsPermissionTitle,
sensorsPermissionTitle, ContentSettingValues.ALLOW,
ContentSettingValues.BLOCK, sensorsAllowedDescription,
sensorsBlockedDescription));
ContentSettingValues.ALLOW, ContentSettingValues.BLOCK,
sensorsAllowedDescription, sensorsBlockedDescription));
localMap.put(ContentSettingsType.SOUND,
new ResourceItem(R.drawable.ic_volume_up_grey600_24dp,
R.string.sound_permission_title, R.string.sound_permission_title,
ContentSettingValues.ALLOW, ContentSettingValues.BLOCK,
R.string.sound_permission_title, ContentSettingValues.ALLOW,
ContentSettingValues.BLOCK,
R.string.website_settings_category_sound_allowed,
R.string.website_settings_category_sound_blocked));
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));
localMap.put(ContentSettingsType.USB_GUARD,
new ResourceItem(R.drawable.settings_usb, R.string.website_settings_usb,
R.string.website_settings_usb, ContentSettingValues.ASK,
ContentSettingValues.BLOCK, R.string.website_settings_category_usb_ask,
ContentSettingValues.ASK, ContentSettingValues.BLOCK,
R.string.website_settings_category_usb_ask,
R.string.website_settings_category_usb_blocked));
localMap.put(ContentSettingsType.VR,
new ResourceItem(R.drawable.vr_headset, R.string.vr_permission_title,
R.string.vr_permission_title, ContentSettingValues.ASK,
ContentSettingValues.BLOCK, R.string.website_settings_category_vr_ask,
ContentSettingValues.ASK, ContentSettingValues.BLOCK,
R.string.website_settings_category_vr_ask,
R.string.website_settings_category_vr_blocked));
sResourceInfo = localMap;
}
......@@ -279,13 +259,6 @@ public class ContentSettingsResources {
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.
......
......@@ -843,9 +843,9 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
*/
private void setUpPreferenceCommon(Preference preference) {
int contentType = getContentSettingsTypeFromPreferenceKey(preference.getKey());
int explanationResourceId = ContentSettingsResources.getExplanation(contentType);
if (explanationResourceId != 0) {
preference.setTitle(explanationResourceId);
int titleResourceId = ContentSettingsResources.getTitle(contentType);
if (titleResourceId != 0) {
preference.setTitle(titleResourceId);
}
if (!preference.isEnabled()) {
preference.setIcon(
......
......@@ -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.">
Ask first before allowing sites to use your camera (recommended)
</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.">
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>
......@@ -345,9 +342,6 @@
</message>
<!-- 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">
Ask when a site wants to know when you're present
</message>
......@@ -369,9 +363,6 @@
<!-- 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.">
Ask before allowing sites to know your location (recommended)
</message>
......@@ -390,9 +381,6 @@
<!-- 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.">
Ask first before allowing sites to use your microphone (recommended)
</message>
......
......@@ -29,7 +29,8 @@ import java.util.Locale;
/** Tests that translations work correctly for Java strings inside bundles. */
@RunWith(WebLayerJUnit4ClassRunner.class)
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";
@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