• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.tv.settings.system;
18 
19 import com.android.tv.settings.ActionBehavior;
20 import com.android.tv.settings.ActionKey;
21 import com.android.tv.settings.R;
22 import com.android.tv.settings.dialog.old.Action;
23 
24 import android.content.res.Resources;
25 
26 enum ActionType {
27     /*
28      * General
29      */
30     AGREE(R.string.agree),
31     DISAGREE(R.string.disagree),
32     EMAIL_ADDRESS(R.string.system_email_address),
33     OK(R.string.title_ok),
34     CANCEL(R.string.title_cancel),
35     ON(R.string.on),
36     OFF(R.string.off),
37     /*
38      * Date & Time
39      */
40     DATE_TIME_OVERVIEW(R.string.system_date_time),
41     DATE(R.string.system_date),
42     TIME(R.string.system_time),
43     DATE_SET_DATE(R.string.system_set_date),
44     DATE_CHOOSE_FORMAT(R.string.system_choose_date_format),
45     TIME_SET_TIME(R.string.system_set_time),
46     TIME_SET_TIME_ZONE(R.string.system_set_time_zone),
47     TIME_CHOOSE_FORMAT(R.string.system_set_time_format),
48     AUTO_DATE_TIME(R.string.system_auto_date_time, R.string.desc_auto_date_time),
49     /*
50      * Location
51      */
52     LOCATION_OVERVIEW(R.string.system_location),
53     NETWORK_LOCATION_CONFIRM(R.string.system_network_location_confirm),
54     LOCATION_STATUS(R.string.location_status),
55     LOCATION_MODE(R.string.location_mode_title),
56     LOCATION_MODE_WIFI(R.string.location_mode_wifi_description),
57     LOCATION_RECENT_REQUESTS(R.string.location_category_recent_location_requests),
58     LOCATION_NO_RECENT_REQUESTS(R.string.location_no_recent_apps),
59     LOCATION_SERVICES(R.string.location_services),
60     LOCATION_SERVICES_GOOGLE(R.string.google_location_services_title),
61     LOCATION_SERVICES_GOOGLE_SETTINGS(R.string.google_location_services_title),
62     LOCATION_SERVICES_GOOGLE_REPORTING(R.string.location_reporting,
63             R.string.location_reporting_desc),
64     LOCATION_SERVICES_GOOGLE_HISTORY(R.string.location_history, R.string.location_history_desc),
65     LOCATION_SERVICES_THIRD_PARTY(R.string.third_party_location_services_title),
66     LOCATION_HISTORY_DELETE(R.string.delete_location_history_title,
67             R.string.delete_location_history_desc),
68     /*
69      * Developer Options
70      */
71     DEVELOPER_OVERVIEW(R.string.system_developer_options),
72     DEVELOPER_GENERAL(R.string.system_general),
73     DEVELOPER_DEBUGGING(R.string.system_debugging),
74     DEVELOPER_INPUT(R.string.system_input),
75     DEVELOPER_DRAWING(R.string.system_drawing),
76     DEVELOPER_MONITORING(R.string.system_monitoring),
77     DEVELOPER_APPS(R.string.system_apps),
78     DEVELOPER_GENERAL_STAY_AWAKE(R.string.system_stay_awake,
79             R.string.system_desc_stay_awake),
80     DEVELOPER_GENERAL_HDCP_CHECKING(R.string.system_hdcp_checking,
81             R.string.system_desc_hdcp_checking),
82     DEVELOPER_GENERAL_HDMI_OPTIMIZATION(R.string.system_hdmi_optimization,
83             R.string.system_desc_hdmi_optimization),
84     DEVELOPER_GENERAL_BT_HCI_LOG(R.string.system_bt_hci_log,
85             R.string.system_desc_bt_hci_log),
86     DEVELOPER_GENERAL_REBOOT(R.string.system_reboot_confirm,
87             R.string.system_desc_reboot_confirm),
88     DEVELOPER_HDCP_NEVER_CHECK(R.string.system_never_check),
89     DEVELOPER_HDCP_CHECK_FOR_DRM_CONTENT_ONLY(R.string.system_check_for_drm_content_only),
90     DEVELOPER_HDCP_ALWAYS_CHECK(R.string.system_always_check),
91     DEVELOPER_DEBUGGING_USB_DEBUGGING(R.string.system_usb_debugging,
92             R.string.system_desc_usb_debugging),
93     DEVELOPER_DEBUGGING_ALLOW_MOCK_LOCATIONS(R.string.system_allow_mock_locations),
94     DEVELOPER_DEBUGGING_SELECT_DEBUG_APP(R.string.system_select_debug_app),
95     DEVELOPER_DEBUGGING_WAIT_FOR_DEBUGGER(R.string.system_wait_for_debugger,
96             R.string.system_desc_wait_for_debugger),
97     DEVELOPER_DEBUGGING_VERIFY_APPS_OVER_USB(R.string.system_verify_apps_over_usb,
98             R.string.system_desc_verify_apps_over_usb),
99     DEVELOPER_DEBUGGING_WIFI_VERBOSE_LOGGING(R.string.system_wifi_verbose_logging,
100             R.string.system_desc_wifi_verbose_logging),
101     DEVELOPER_INPUT_SHOW_TOUCHES(R.string.system_show_touches),
102     DEVELOPER_INPUT_POINTER_LOCATION(R.string.system_pointer_location),
103     DEVELOPER_DRAWING_SHOW_LAYOUT_BOUNDS(R.string.system_show_layout_bounds,
104             R.string.system_desc_show_layout_bounds),
105     DEVELOPER_DRAWING_SHOW_GPU_VIEW_UPDATES(R.string.system_show_gpu_view_updates,
106             R.string.system_desc_show_gpu_view_updates),
107     DEVELOPER_DRAWING_SHOW_GPU_OVERDRAW(R.string.system_show_gpu_overdraw,
108                     R.string.system_desc_show_gpu_overdraw),
109     DEVELOPER_DRAWING_SHOW_HARDWARE_LAYER(R.string.system_show_hardware_layer,
110             R.string.system_desc_show_hardware_layer),
111     DEVELOPER_DRAWING_SHOW_SURFACE_UPDATES(R.string.system_show_surface_updates,
112             R.string.system_desc_show_surface_updates),
113     DEVELOPER_DRAWING_WINDOW_ANIMATION_SCALE(R.string.system_window_animation_scale),
114     DEVELOPER_DRAWING_TRANSITION_ANIMATION_SCALE(R.string.system_transition_animation_scale),
115     DEVELOPER_DRAWING_ANIMATOR_DURATION_SCALE(R.string.system_animator_duration_scale),
116     DEVELOPER_MONITORING_STRICT_MODE_ENABLED(R.string.system_strict_mode_enabled,
117             R.string.system_desc_strict_mode_enabled),
118     DEVELOPER_MONITORING_SHOW_CPU_USAGE(R.string.system_show_cpu_usage,
119             R.string.system_desc_show_cpu_usage),
120     DEVELOPER_MONITORING_PROFILE_GPU_RENDERING(R.string.system_profile_gpu_rendering,
121             R.string.system_desc_profile_gpu_rendering),
122     DEVELOPER_MONITORING_ENABLE_TRACES(R.string.system_enable_traces),
123     DEVELOPER_APPS_DONT_KEEP_ACTIVITIES(R.string.system_dont_keep_activities),
124     DEVELOPER_APPS_BACKGROUND_PROCESS_LIMIT(R.string.system_background_process_limit),
125     DEVELOPER_APPS_SHOW_ALL_ANRS(R.string.system_show_all_anrs),
126     /*
127      * Keyboard
128      */
129     KEYBOARD_OVERVIEW(R.string.system_keyboard),
130     KEYBOARD_OVERVIEW_CURRENT_KEYBOARD(R.string.title_current_keyboard),
131     KEYBOARD_OVERVIEW_CONFIGURE(R.string.title_configure, R.string.desc_configure_keyboard),
132 
133     /*
134      * Security
135      */
136     SECURITY_OVERVIEW(R.string.system_security),
137     SECURITY_UNKNOWN_SOURCES(R.string.security_unknown_sources_title,
138             R.string.security_unknown_sources_desc),
139     SECURITY_UNKNOWN_SOURCES_CONFIRM(R.string.security_unknown_sources_title,
140                     R.string.security_unknown_sources_confirm_desc),
141     SECURITY_VERIFY_APPS(R.string.security_verify_apps_title,
142              R.string.security_verify_apps_desc),
143 
144     /*
145      * StorageReset
146      */
147     STORAGERESET_OVERVIEW(R.string.device_storage_reset),
148     STORAGERESET_FACTORY_RESET(R.string.device_reset),
149     STORAGERESET_STORAGE(R.string.device_storage),
150 
151     /*
152      * Accessibility
153      */
154     ACCESSIBILITY_OVERVIEW(R.string.system_accessibility),
155     ACCESSIBILITY_SERVICES(R.string.system_services),
156     ACCESSIBILITY_SERVICES_SETTINGS(R.string.accessibility_service_settings),
157     ACCESSIBILITY_SERVICES_STATUS(R.string.system_accessibility_status),
158     ACCESSIBILITY_SERVICES_CONFIRM_ON(R.string.system_accessibility_status),
159     ACCESSIBILITY_SERVICES_CONFIRM_OFF(R.string.system_accessibility_status),
160     ACCESSIBILITY_SERVICE_CONFIG(R.string.system_accessibility_config),
161     ACCESSIBILITY_CAPTIONS(R.string.accessibility_captions),
162     ACCESSIBILITY_SPEAK_PASSWORDS(R.string.system_speak_passwords),
163     ACCESSIBILITY_TTS_OUTPUT(R.string.system_accessibility_tts_output),
164     ACCESSIBILITY_PREFERRED_ENGINE(R.string.system_preferred_engine),
165     ACCESSIBILITY_LANGUAGE(R.string.system_language),
166     ACCESSIBILITY_SPEECH_RATE(R.string.system_speech_rate),
167     ACCESSIBILITY_PLAY_SAMPLE(R.string.system_play_sample),
168     ACCESSIBILITY_INSTALL_VOICE_DATA(R.string.system_install_voice_data),
169 
170     CAPTIONS_OVERVIEW(R.string.accessibility_captions,
171                       R.string.accessibility_captions_description),
172     CAPTIONS_DISPLAY(R.string.captions_display),
173     CAPTIONS_CONFIGURE(R.string.captions_configure),
174     CAPTIONS_LANGUAGE(R.string.captions_lanaguage),
175     CAPTIONS_TEXTSIZE(R.string.captions_textsize),
176     CAPTIONS_CAPTIONSTYLE(R.string.captions_captionstyle),
177     CAPTIONS_CUSTOMOPTIONS(R.string.captions_customoptions),
178     CAPTIONS_FONTFAMILY(R.string.captions_fontfamily),
179     CAPTIONS_TEXTCOLOR(R.string.captions_textcolor),
180     CAPTIONS_TEXTOPACITY(R.string.captions_textopacity),
181     CAPTIONS_EDGETYPE(R.string.captions_edgetype),
182     CAPTIONS_EDGECOLOR(R.string.captions_edgecolor),
183     CAPTIONS_BACKGROUNDCOLOR(R.string.captions_backgroundcolor),
184     CAPTIONS_BACKGROUNDOPACITY(R.string.captions_backgroundopacity),
185     CAPTIONS_WINDOWCOLOR(R.string.captions_windowcolor),
186     CAPTIONS_WINDOWOPACITY(R.string.captions_windowopacity);
187 
188     private final int mTitleResource;
189     private final int mDescResource;
190 
ActionType(int titleResource)191     private ActionType(int titleResource) {
192         mTitleResource = titleResource;
193         mDescResource = 0;
194     }
195 
ActionType(int titleResource, int descResource)196     private ActionType(int titleResource, int descResource) {
197         mTitleResource = titleResource;
198         mDescResource = descResource;
199     }
getTitle(Resources resources)200     String getTitle(Resources resources) {
201         return resources.getString(mTitleResource);
202     }
203 
getDescription(Resources resources)204     String getDescription(Resources resources) {
205         if (mDescResource != 0) {
206             return resources.getString(mDescResource);
207         }
208         return null;
209     }
210 
toAction(Resources resources)211     Action toAction(Resources resources) {
212         return toAction(resources, true/*enabled*/);
213     }
214 
toAction(Resources resources, boolean enabled)215     Action toAction(Resources resources, boolean enabled) {
216         return toAction(resources, getDescription(resources), enabled, false/* not checked */);
217     }
218 
toAction(Resources resources, String description)219     Action toAction(Resources resources, String description) {
220         return toAction(resources, description, true/*enabled*/, false /* not checked */);
221     }
222 
toAction(Resources resources, String description, boolean enabled)223     Action toAction(Resources resources, String description, boolean enabled) {
224         return toAction(resources, description, enabled, false /* not checked */);
225     }
226 
toAction(Resources resources, String description, boolean enabled, boolean checked)227     Action toAction(Resources resources, String description, boolean enabled, boolean checked) {
228         return new Action.Builder()
229                 .key(getKey(this, ActionBehavior.INIT))
230                 .title(getTitle(resources))
231                 .description(description)
232                 .enabled(enabled)
233                 .checked(checked)
234                 .build();
235     }
236 
getKey(ActionType t, ActionBehavior b)237     private String getKey(ActionType t, ActionBehavior b) {
238         return new ActionKey<ActionType, ActionBehavior>(t, b).getKey();
239     }
240 }
241