Bug 1222390 - (Part 4) Restricted profiles: Add descriptions to restrictions. r=margaret

This commit is contained in:
Sebastian Kaspari 2015-11-27 14:04:43 +01:00
parent a0915875a0
commit 0e011fcba3
4 changed files with 58 additions and 19 deletions

View File

@ -717,10 +717,15 @@ just addresses the organization to follow, e.g. "This site is run by " -->
<!-- Localization note: These are features the device owner (e.g. parent) can enable or disable for
a restricted profile (e.g. child). Used inside the Android settings UI. -->
<!ENTITY restrictable_feature_addons_installation "Add-ons">
<!ENTITY restrictable_feature_addons_installation_description "Add features or functionality to Firefox. Note: Add-ons can disable certain restrictions.">
<!ENTITY restrictable_feature_private_browsing "Private Browsing">
<!ENTITY restrictable_feature_private_browsing_description "Allows family members to browse without saving information about the sites and pages they\'ve visited.">
<!ENTITY restrictable_feature_clear_history "Clear History">
<!ENTITY restrictable_feature_clear_history_description "Allows family members to delete information about the sites and pages they\'ve visited.">
<!ENTITY restrictable_feature_advanced_settings "Advanced Settings">
<!ENTITY restrictable_feature_advanced_settings_description "This includes importing bookmarks, restoring tabs and automated updates. Turn off for simplified settings suitable for any family member.">
<!ENTITY restrictable_feature_camera_microphone "Camera &amp; Microphone">
<!ENTITY restrictable_feature_camera_microphone_description "Allows family members to engage in real time communication on websites.">
<!-- Default Bookmarks titles-->
<!-- LOCALIZATION NOTE (bookmarks_about_browser): link title for about:fennec -->

View File

@ -16,43 +16,55 @@ import android.support.annotation.StringRes;
* These constants should be in sync with the ones from toolkit/components/parentalcontrols/nsIParentalControlsService.idl
*/
public enum Restrictable {
DOWNLOAD(1, "downloads", 0),
DOWNLOAD(1, "downloads", 0, 0),
INSTALL_EXTENSION(2, "no_install_extensions", R.string.restrictable_feature_addons_installation),
INSTALL_EXTENSION(
2, "no_install_extensions",
R.string.restrictable_feature_addons_installation,
R.string.restrictable_feature_addons_installation_description),
// UserManager.DISALLOW_INSTALL_APPS
INSTALL_APPS(3, "no_install_apps", 0),
INSTALL_APPS(3, "no_install_apps", 0 , 0),
BROWSE(4, "browse", 0),
BROWSE(4, "browse", 0, 0),
SHARE(5, "share", 0),
SHARE(5, "share", 0, 0),
BOOKMARK(6, "bookmark", 0),
BOOKMARK(6, "bookmark", 0, 0),
ADD_CONTACT(7, "add_contact", 0),
ADD_CONTACT(7, "add_contact", 0, 0),
SET_IMAGE(8, "set_image", 0),
SET_IMAGE(8, "set_image", 0, 0),
// UserManager.DISALLOW_MODIFY_ACCOUNTS
MODIFY_ACCOUNTS(9, "no_modify_accounts", 0),
MODIFY_ACCOUNTS(9, "no_modify_accounts", 0, 0),
REMOTE_DEBUGGING(10, "remote_debugging", 0),
REMOTE_DEBUGGING(10, "remote_debugging", 0, 0),
IMPORT_SETTINGS(11, "import_settings", 0),
IMPORT_SETTINGS(11, "import_settings", 0, 0),
PRIVATE_BROWSING(12, "private_browsing", R.string.restrictable_feature_private_browsing),
PRIVATE_BROWSING(
12, "private_browsing",
R.string.restrictable_feature_private_browsing,
R.string.restrictable_feature_private_browsing_description),
LOCATION_SERVICE(13, "location_service", 0),
LOCATION_SERVICE(13, "location_service", 0, 0),
CLEAR_HISTORY(14, "clear_history", R.string.restrictable_feature_clear_history),
CLEAR_HISTORY(14, "clear_history",
R.string.restrictable_feature_clear_history,
R.string.restrictable_feature_clear_history_description),
MASTER_PASSWORD(15, "master_password", 0),
MASTER_PASSWORD(15, "master_password", 0, 0),
GUEST_BROWSING(16, "guest_browsing", 0),
GUEST_BROWSING(16, "guest_browsing", 0, 0),
ADVANCED_SETTINGS(17, "advanced_settings", R.string.restrictable_feature_advanced_settings),
ADVANCED_SETTINGS(17, "advanced_settings",
R.string.restrictable_feature_advanced_settings,
R.string.restrictable_feature_advanced_settings_description),
CAMERA_MICROPHONE(18, "camera_microphone", R.string.restrictable_feature_camera_microphone);
CAMERA_MICROPHONE(18, "camera_microphone",
R.string.restrictable_feature_camera_microphone,
R.string.restrictable_feature_camera_microphone_description);
public final int id;
public final String name;
@ -60,10 +72,14 @@ public enum Restrictable {
@StringRes
public final int title;
Restrictable(final int id, final String name, @StringRes int title) {
@StringRes
public final int description;
Restrictable(final int id, final String name, @StringRes int title, @StringRes int description) {
this.id = id;
this.name = name;
this.title = title;
this.description = description;
}
public String getTitle(Context context) {
@ -72,4 +88,11 @@ public enum Restrictable {
}
return context.getResources().getString(title);
}
public String getDescription(Context context) {
if (description == 0) {
return null;
}
return context.getResources().getString(description);
}
}

View File

@ -15,6 +15,7 @@ import android.content.Intent;
import android.content.RestrictionEntry;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import java.util.ArrayList;
@ -74,6 +75,11 @@ public class RestrictionProvider extends BroadcastReceiver {
entry.setTitle(restrictable.getTitle(context));
final String description = restrictable.getDescription(context);
if (!TextUtils.isEmpty(description)) {
entry.setDescription(description);
}
return entry;
}
}

View File

@ -566,10 +566,15 @@
<!-- Restrictable features -->
<string name="restrictable_feature_addons_installation">&restrictable_feature_addons_installation;</string>
<string name="restrictable_feature_addons_installation_description">&restrictable_feature_addons_installation_description;</string>
<string name="restrictable_feature_private_browsing">&restrictable_feature_private_browsing;</string>
<string name="restrictable_feature_private_browsing_description">&restrictable_feature_private_browsing_description;</string>
<string name="restrictable_feature_clear_history">&restrictable_feature_clear_history;</string>
<string name="restrictable_feature_clear_history_description">&restrictable_feature_clear_history_description;</string>
<string name="restrictable_feature_advanced_settings">&restrictable_feature_advanced_settings;</string>
<string name="restrictable_feature_advanced_settings_description">&restrictable_feature_advanced_settings_description;</string>
<string name="restrictable_feature_camera_microphone">&restrictable_feature_camera_microphone;</string>
<string name="restrictable_feature_camera_microphone_description">&restrictable_feature_camera_microphone_description;</string>
<!-- Miscellaneous -->
<string name="ellipsis">&ellipsis;</string>