Abodunrinwa Toki | 0e6b43e | 2017-09-19 23:18:40 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 android.view.textclassifier; |
| 18 | |
| 19 | import android.annotation.Nullable; |
Abodunrinwa Toki | 0e6b43e | 2017-09-19 23:18:40 +0100 | [diff] [blame] | 20 | |
Tony Mak | f93e9e5 | 2018-07-16 14:46:29 +0200 | [diff] [blame] | 21 | import com.android.internal.util.IndentingPrintWriter; |
| 22 | |
Jan Althaus | 0aacdb6 | 2018-02-19 11:44:37 +0100 | [diff] [blame] | 23 | import java.util.Arrays; |
| 24 | import java.util.Collections; |
| 25 | import java.util.List; |
| 26 | import java.util.StringJoiner; |
| 27 | |
Abodunrinwa Toki | 0e6b43e | 2017-09-19 23:18:40 +0100 | [diff] [blame] | 28 | /** |
| 29 | * TextClassifier specific settings. |
| 30 | * This is encoded as a key=value list, separated by commas. Ex: |
| 31 | * |
| 32 | * <pre> |
Tony Mak | fc37457 | 2019-03-05 14:46:24 +0000 | [diff] [blame] | 33 | * smart_linkify_enabled (boolean) |
| 34 | * system_textclassifier_enabled (boolean) |
| 35 | * model_dark_launch_enabled (boolean) |
| 36 | * smart_selection_enabled (boolean) |
| 37 | * smart_text_share_enabled (boolean) |
| 38 | * smart_linkify_enabled (boolean) |
| 39 | * smart_select_animation_enabled (boolean) |
| 40 | * suggest_selection_max_range_length (int) |
| 41 | * classify_text_max_range_length (int) |
| 42 | * generate_links_max_text_length (int) |
| 43 | * generate_links_log_sample_rate (int) |
| 44 | * entity_list_default (String[]) |
| 45 | * entity_list_not_editable (String[]) |
| 46 | * entity_list_editable (String[]) |
| 47 | * in_app_conversation_action_types_default (String[]) |
| 48 | * notification_conversation_action_types_default (String[]) |
| 49 | * lang_id_threshold_override (float) |
| 50 | * template_intent_factory_enabled (boolean) |
Abodunrinwa Toki | 0e6b43e | 2017-09-19 23:18:40 +0100 | [diff] [blame] | 51 | * </pre> |
| 52 | * |
| 53 | * <p> |
| 54 | * Type: string |
| 55 | * see also android.provider.Settings.Global.TEXT_CLASSIFIER_CONSTANTS |
| 56 | * |
| 57 | * Example of setting the values for testing. |
Jan Althaus | 0aacdb6 | 2018-02-19 11:44:37 +0100 | [diff] [blame] | 58 | * adb shell settings put global text_classifier_constants \ |
Abodunrinwa Toki | db8fc31 | 2018-02-26 21:37:51 +0000 | [diff] [blame] | 59 | * model_dark_launch_enabled=true,smart_selection_enabled=true,\ |
Jan Althaus | 0aacdb6 | 2018-02-19 11:44:37 +0100 | [diff] [blame] | 60 | * entity_list_default=phone:address |
Abodunrinwa Toki | 0e6b43e | 2017-09-19 23:18:40 +0100 | [diff] [blame] | 61 | * @hide |
| 62 | */ |
Abodunrinwa Toki | db8fc31 | 2018-02-26 21:37:51 +0000 | [diff] [blame] | 63 | public final class TextClassificationConstants { |
Abodunrinwa Toki | db8fc31 | 2018-02-26 21:37:51 +0000 | [diff] [blame] | 64 | private static final String LOG_TAG = "TextClassificationConstants"; |
Abodunrinwa Toki | 0e6b43e | 2017-09-19 23:18:40 +0100 | [diff] [blame] | 65 | |
Tony Mak | fc37457 | 2019-03-05 14:46:24 +0000 | [diff] [blame] | 66 | /** |
| 67 | * Whether the smart linkify feature is enabled. |
| 68 | */ |
| 69 | private static final String SMART_LINKIFY_ENABLED = "smart_linkify_enabled"; |
| 70 | /** |
| 71 | * Whether SystemTextClassifier is enabled. |
| 72 | */ |
| 73 | private static final String SYSTEM_TEXT_CLASSIFIER_ENABLED = "system_textclassifier_enabled"; |
| 74 | /** |
| 75 | * Whether TextClassifierImpl is enabled. |
| 76 | */ |
| 77 | private static final String LOCAL_TEXT_CLASSIFIER_ENABLED = "local_textclassifier_enabled"; |
| 78 | /** |
| 79 | * Enable smart selection without a visible UI changes. |
| 80 | */ |
| 81 | private static final String MODEL_DARK_LAUNCH_ENABLED = "model_dark_launch_enabled"; |
| 82 | |
| 83 | /** |
| 84 | * Whether the smart selection feature is enabled. |
| 85 | */ |
| 86 | private static final String SMART_SELECTION_ENABLED = "smart_selection_enabled"; |
| 87 | /** |
| 88 | * Whether the smart text share feature is enabled. |
| 89 | */ |
| 90 | private static final String SMART_TEXT_SHARE_ENABLED = "smart_text_share_enabled"; |
| 91 | /** |
| 92 | * Whether animation for smart selection is enabled. |
| 93 | */ |
Abodunrinwa Toki | db8fc31 | 2018-02-26 21:37:51 +0000 | [diff] [blame] | 94 | private static final String SMART_SELECT_ANIMATION_ENABLED = |
| 95 | "smart_select_animation_enabled"; |
Tony Mak | fc37457 | 2019-03-05 14:46:24 +0000 | [diff] [blame] | 96 | /** |
| 97 | * Max length of text that suggestSelection can accept. |
| 98 | */ |
Jan Althaus | 108aad3 | 2018-01-30 15:26:55 +0100 | [diff] [blame] | 99 | private static final String SUGGEST_SELECTION_MAX_RANGE_LENGTH = |
| 100 | "suggest_selection_max_range_length"; |
Tony Mak | fc37457 | 2019-03-05 14:46:24 +0000 | [diff] [blame] | 101 | /** |
| 102 | * Max length of text that classifyText can accept. |
| 103 | */ |
| 104 | private static final String CLASSIFY_TEXT_MAX_RANGE_LENGTH = "classify_text_max_range_length"; |
| 105 | /** |
| 106 | * Max length of text that generateLinks can accept. |
| 107 | */ |
| 108 | private static final String GENERATE_LINKS_MAX_TEXT_LENGTH = "generate_links_max_text_length"; |
| 109 | /** |
| 110 | * Sampling rate for generateLinks logging. |
| 111 | */ |
Jan Althaus | 31efdc3 | 2018-02-19 22:23:13 +0100 | [diff] [blame] | 112 | private static final String GENERATE_LINKS_LOG_SAMPLE_RATE = |
| 113 | "generate_links_log_sample_rate"; |
Tony Mak | fc37457 | 2019-03-05 14:46:24 +0000 | [diff] [blame] | 114 | /** |
| 115 | * A colon(:) separated string that specifies the default entities types for |
| 116 | * generateLinks when hint is not given. |
| 117 | */ |
| 118 | private static final String ENTITY_LIST_DEFAULT = "entity_list_default"; |
| 119 | /** |
| 120 | * A colon(:) separated string that specifies the default entities types for |
| 121 | * generateLinks when the text is in a not editable UI widget. |
| 122 | */ |
| 123 | private static final String ENTITY_LIST_NOT_EDITABLE = "entity_list_not_editable"; |
| 124 | /** |
| 125 | * A colon(:) separated string that specifies the default entities types for |
| 126 | * generateLinks when the text is in an editable UI widget. |
| 127 | */ |
| 128 | private static final String ENTITY_LIST_EDITABLE = "entity_list_editable"; |
| 129 | /** |
| 130 | * A colon(:) separated string that specifies the default action types for |
| 131 | * suggestConversationActions when the suggestions are used in an app. |
| 132 | */ |
Tony Mak | adbebcc | 2018-10-30 18:59:06 +0000 | [diff] [blame] | 133 | private static final String IN_APP_CONVERSATION_ACTION_TYPES_DEFAULT = |
| 134 | "in_app_conversation_action_types_default"; |
Tony Mak | fc37457 | 2019-03-05 14:46:24 +0000 | [diff] [blame] | 135 | /** |
| 136 | * A colon(:) separated string that specifies the default action types for |
| 137 | * suggestConversationActions when the suggestions are used in a notification. |
| 138 | */ |
Tony Mak | adbebcc | 2018-10-30 18:59:06 +0000 | [diff] [blame] | 139 | private static final String NOTIFICATION_CONVERSATION_ACTION_TYPES_DEFAULT = |
| 140 | "notification_conversation_action_types_default"; |
Tony Mak | fc37457 | 2019-03-05 14:46:24 +0000 | [diff] [blame] | 141 | /** |
| 142 | * Threshold in classifyText to consider a text is in a foreign language. |
| 143 | */ |
| 144 | private static final String LANG_ID_THRESHOLD_OVERRIDE = "lang_id_threshold_override"; |
| 145 | /** |
| 146 | * Whether to enable {@link android.view.textclassifier.TemplateIntentFactory}. |
| 147 | */ |
Tony Mak | fc039c3 | 2019-01-17 19:32:08 +0000 | [diff] [blame] | 148 | private static final String TEMPLATE_INTENT_FACTORY_ENABLED = "template_intent_factory_enabled"; |
Abodunrinwa Toki | 0e6b43e | 2017-09-19 23:18:40 +0100 | [diff] [blame] | 149 | |
Abodunrinwa Toki | c7073a4 | 2018-02-28 23:02:13 +0000 | [diff] [blame] | 150 | private static final boolean LOCAL_TEXT_CLASSIFIER_ENABLED_DEFAULT = true; |
| 151 | private static final boolean SYSTEM_TEXT_CLASSIFIER_ENABLED_DEFAULT = true; |
Abodunrinwa Toki | db8fc31 | 2018-02-26 21:37:51 +0000 | [diff] [blame] | 152 | private static final boolean MODEL_DARK_LAUNCH_ENABLED_DEFAULT = false; |
| 153 | private static final boolean SMART_SELECTION_ENABLED_DEFAULT = true; |
| 154 | private static final boolean SMART_TEXT_SHARE_ENABLED_DEFAULT = true; |
Richard Ledley | 9cfa606 | 2018-01-15 13:13:29 +0000 | [diff] [blame] | 155 | private static final boolean SMART_LINKIFY_ENABLED_DEFAULT = true; |
Abodunrinwa Toki | db8fc31 | 2018-02-26 21:37:51 +0000 | [diff] [blame] | 156 | private static final boolean SMART_SELECT_ANIMATION_ENABLED_DEFAULT = true; |
Jan Althaus | 108aad3 | 2018-01-30 15:26:55 +0100 | [diff] [blame] | 157 | private static final int SUGGEST_SELECTION_MAX_RANGE_LENGTH_DEFAULT = 10 * 1000; |
| 158 | private static final int CLASSIFY_TEXT_MAX_RANGE_LENGTH_DEFAULT = 10 * 1000; |
| 159 | private static final int GENERATE_LINKS_MAX_TEXT_LENGTH_DEFAULT = 100 * 1000; |
Jan Althaus | 31efdc3 | 2018-02-19 22:23:13 +0100 | [diff] [blame] | 160 | private static final int GENERATE_LINKS_LOG_SAMPLE_RATE_DEFAULT = 100; |
Abodunrinwa Toki | a77dba6 | 2019-01-25 19:27:11 +0000 | [diff] [blame] | 161 | private static final String STRING_LIST_DELIMITER = ":"; |
| 162 | private static final String ENTITY_LIST_DEFAULT_VALUE = new StringJoiner(STRING_LIST_DELIMITER) |
Jan Althaus | 0aacdb6 | 2018-02-19 11:44:37 +0100 | [diff] [blame] | 163 | .add(TextClassifier.TYPE_ADDRESS) |
| 164 | .add(TextClassifier.TYPE_EMAIL) |
| 165 | .add(TextClassifier.TYPE_PHONE) |
| 166 | .add(TextClassifier.TYPE_URL) |
| 167 | .add(TextClassifier.TYPE_DATE) |
| 168 | .add(TextClassifier.TYPE_DATE_TIME) |
| 169 | .add(TextClassifier.TYPE_FLIGHT_NUMBER).toString(); |
Tony Mak | adbebcc | 2018-10-30 18:59:06 +0000 | [diff] [blame] | 170 | private static final String CONVERSATION_ACTIONS_TYPES_DEFAULT_VALUES = |
Abodunrinwa Toki | a77dba6 | 2019-01-25 19:27:11 +0000 | [diff] [blame] | 171 | new StringJoiner(STRING_LIST_DELIMITER) |
Tony Mak | ae85aae | 2019-01-09 15:59:56 +0000 | [diff] [blame] | 172 | .add(ConversationAction.TYPE_TEXT_REPLY) |
| 173 | .add(ConversationAction.TYPE_CREATE_REMINDER) |
| 174 | .add(ConversationAction.TYPE_CALL_PHONE) |
| 175 | .add(ConversationAction.TYPE_OPEN_URL) |
| 176 | .add(ConversationAction.TYPE_SEND_EMAIL) |
| 177 | .add(ConversationAction.TYPE_SEND_SMS) |
| 178 | .add(ConversationAction.TYPE_TRACK_FLIGHT) |
| 179 | .add(ConversationAction.TYPE_VIEW_CALENDAR) |
| 180 | .add(ConversationAction.TYPE_VIEW_MAP) |
Tony Mak | a396be4 | 2019-02-07 14:37:22 +0000 | [diff] [blame] | 181 | .add(ConversationAction.TYPE_ADD_CONTACT) |
Tony Mak | adbebcc | 2018-10-30 18:59:06 +0000 | [diff] [blame] | 182 | .toString(); |
Abodunrinwa Toki | a77dba6 | 2019-01-25 19:27:11 +0000 | [diff] [blame] | 183 | /** |
| 184 | * < 0 : Not set. Use value from LangId model. |
| 185 | * 0 - 1: Override value in LangId model. |
| 186 | * > 1 : Effectively turns off the foreign language detection. Scores should never be > 1. |
| 187 | * @see EntityConfidence |
| 188 | */ |
| 189 | private static final float LANG_ID_THRESHOLD_OVERRIDE_DEFAULT = -1f; |
Tony Mak | fc039c3 | 2019-01-17 19:32:08 +0000 | [diff] [blame] | 190 | private static final boolean TEMPLATE_INTENT_FACTORY_ENABLED_DEFAULT = true; |
Abodunrinwa Toki | 0e6b43e | 2017-09-19 23:18:40 +0100 | [diff] [blame] | 191 | |
Abodunrinwa Toki | c7073a4 | 2018-02-28 23:02:13 +0000 | [diff] [blame] | 192 | private final boolean mSystemTextClassifierEnabled; |
| 193 | private final boolean mLocalTextClassifierEnabled; |
Abodunrinwa Toki | db8fc31 | 2018-02-26 21:37:51 +0000 | [diff] [blame] | 194 | private final boolean mModelDarkLaunchEnabled; |
| 195 | private final boolean mSmartSelectionEnabled; |
| 196 | private final boolean mSmartTextShareEnabled; |
Richard Ledley | 9cfa606 | 2018-01-15 13:13:29 +0000 | [diff] [blame] | 197 | private final boolean mSmartLinkifyEnabled; |
Abodunrinwa Toki | db8fc31 | 2018-02-26 21:37:51 +0000 | [diff] [blame] | 198 | private final boolean mSmartSelectionAnimationEnabled; |
Jan Althaus | 108aad3 | 2018-01-30 15:26:55 +0100 | [diff] [blame] | 199 | private final int mSuggestSelectionMaxRangeLength; |
| 200 | private final int mClassifyTextMaxRangeLength; |
| 201 | private final int mGenerateLinksMaxTextLength; |
Jan Althaus | 31efdc3 | 2018-02-19 22:23:13 +0100 | [diff] [blame] | 202 | private final int mGenerateLinksLogSampleRate; |
Jan Althaus | 0aacdb6 | 2018-02-19 11:44:37 +0100 | [diff] [blame] | 203 | private final List<String> mEntityListDefault; |
| 204 | private final List<String> mEntityListNotEditable; |
| 205 | private final List<String> mEntityListEditable; |
Tony Mak | adbebcc | 2018-10-30 18:59:06 +0000 | [diff] [blame] | 206 | private final List<String> mInAppConversationActionTypesDefault; |
| 207 | private final List<String> mNotificationConversationActionTypesDefault; |
Abodunrinwa Toki | a77dba6 | 2019-01-25 19:27:11 +0000 | [diff] [blame] | 208 | private final float mLangIdThresholdOverride; |
Tony Mak | fc039c3 | 2019-01-17 19:32:08 +0000 | [diff] [blame] | 209 | private final boolean mTemplateIntentFactoryEnabled; |
Abodunrinwa Toki | 0e6b43e | 2017-09-19 23:18:40 +0100 | [diff] [blame] | 210 | |
Abodunrinwa Toki | db8fc31 | 2018-02-26 21:37:51 +0000 | [diff] [blame] | 211 | private TextClassificationConstants(@Nullable String settings) { |
Tony Mak | fc37457 | 2019-03-05 14:46:24 +0000 | [diff] [blame] | 212 | ConfigParser configParser = new ConfigParser(settings); |
| 213 | mSystemTextClassifierEnabled = |
| 214 | configParser.getBoolean( |
| 215 | SYSTEM_TEXT_CLASSIFIER_ENABLED, |
| 216 | SYSTEM_TEXT_CLASSIFIER_ENABLED_DEFAULT); |
| 217 | mLocalTextClassifierEnabled = |
| 218 | configParser.getBoolean( |
| 219 | LOCAL_TEXT_CLASSIFIER_ENABLED, |
| 220 | LOCAL_TEXT_CLASSIFIER_ENABLED_DEFAULT); |
| 221 | mModelDarkLaunchEnabled = |
| 222 | configParser.getBoolean( |
| 223 | MODEL_DARK_LAUNCH_ENABLED, |
| 224 | MODEL_DARK_LAUNCH_ENABLED_DEFAULT); |
| 225 | mSmartSelectionEnabled = |
| 226 | configParser.getBoolean( |
| 227 | SMART_SELECTION_ENABLED, |
| 228 | SMART_SELECTION_ENABLED_DEFAULT); |
| 229 | mSmartTextShareEnabled = |
| 230 | configParser.getBoolean( |
| 231 | SMART_TEXT_SHARE_ENABLED, |
| 232 | SMART_TEXT_SHARE_ENABLED_DEFAULT); |
| 233 | mSmartLinkifyEnabled = |
| 234 | configParser.getBoolean( |
| 235 | SMART_LINKIFY_ENABLED, |
| 236 | SMART_LINKIFY_ENABLED_DEFAULT); |
| 237 | mSmartSelectionAnimationEnabled = |
| 238 | configParser.getBoolean( |
| 239 | SMART_SELECT_ANIMATION_ENABLED, |
| 240 | SMART_SELECT_ANIMATION_ENABLED_DEFAULT); |
| 241 | mSuggestSelectionMaxRangeLength = |
| 242 | configParser.getInt( |
| 243 | SUGGEST_SELECTION_MAX_RANGE_LENGTH, |
| 244 | SUGGEST_SELECTION_MAX_RANGE_LENGTH_DEFAULT); |
| 245 | mClassifyTextMaxRangeLength = |
| 246 | configParser.getInt( |
| 247 | CLASSIFY_TEXT_MAX_RANGE_LENGTH, |
| 248 | CLASSIFY_TEXT_MAX_RANGE_LENGTH_DEFAULT); |
| 249 | mGenerateLinksMaxTextLength = |
| 250 | configParser.getInt( |
| 251 | GENERATE_LINKS_MAX_TEXT_LENGTH, |
| 252 | GENERATE_LINKS_MAX_TEXT_LENGTH_DEFAULT); |
| 253 | mGenerateLinksLogSampleRate = |
| 254 | configParser.getInt( |
| 255 | GENERATE_LINKS_LOG_SAMPLE_RATE, |
| 256 | GENERATE_LINKS_LOG_SAMPLE_RATE_DEFAULT); |
| 257 | mEntityListDefault = parseStringList(configParser.getString( |
Jan Althaus | 0aacdb6 | 2018-02-19 11:44:37 +0100 | [diff] [blame] | 258 | ENTITY_LIST_DEFAULT, |
| 259 | ENTITY_LIST_DEFAULT_VALUE)); |
Tony Mak | fc37457 | 2019-03-05 14:46:24 +0000 | [diff] [blame] | 260 | mEntityListNotEditable = parseStringList( |
| 261 | configParser.getString( |
| 262 | ENTITY_LIST_NOT_EDITABLE, |
| 263 | ENTITY_LIST_DEFAULT_VALUE)); |
| 264 | mEntityListEditable = parseStringList( |
| 265 | configParser.getString( |
| 266 | ENTITY_LIST_EDITABLE, |
| 267 | ENTITY_LIST_DEFAULT_VALUE)); |
| 268 | mInAppConversationActionTypesDefault = parseStringList( |
| 269 | configParser.getString( |
| 270 | IN_APP_CONVERSATION_ACTION_TYPES_DEFAULT, |
| 271 | CONVERSATION_ACTIONS_TYPES_DEFAULT_VALUES)); |
| 272 | mNotificationConversationActionTypesDefault = parseStringList( |
| 273 | configParser.getString( |
| 274 | NOTIFICATION_CONVERSATION_ACTION_TYPES_DEFAULT, |
| 275 | CONVERSATION_ACTIONS_TYPES_DEFAULT_VALUES)); |
| 276 | mLangIdThresholdOverride = |
| 277 | configParser.getFloat( |
| 278 | LANG_ID_THRESHOLD_OVERRIDE, |
| 279 | LANG_ID_THRESHOLD_OVERRIDE_DEFAULT); |
| 280 | mTemplateIntentFactoryEnabled = configParser.getBoolean( |
| 281 | TEMPLATE_INTENT_FACTORY_ENABLED, |
| 282 | TEMPLATE_INTENT_FACTORY_ENABLED_DEFAULT); |
Abodunrinwa Toki | 0e6b43e | 2017-09-19 23:18:40 +0100 | [diff] [blame] | 283 | } |
| 284 | |
Jan Althaus | 0aacdb6 | 2018-02-19 11:44:37 +0100 | [diff] [blame] | 285 | /** Load from a settings string. */ |
Abodunrinwa Toki | db8fc31 | 2018-02-26 21:37:51 +0000 | [diff] [blame] | 286 | public static TextClassificationConstants loadFromString(String settings) { |
| 287 | return new TextClassificationConstants(settings); |
Abodunrinwa Toki | 0e6b43e | 2017-09-19 23:18:40 +0100 | [diff] [blame] | 288 | } |
| 289 | |
Abodunrinwa Toki | c7073a4 | 2018-02-28 23:02:13 +0000 | [diff] [blame] | 290 | public boolean isLocalTextClassifierEnabled() { |
| 291 | return mLocalTextClassifierEnabled; |
| 292 | } |
| 293 | |
| 294 | public boolean isSystemTextClassifierEnabled() { |
| 295 | return mSystemTextClassifierEnabled; |
| 296 | } |
| 297 | |
Abodunrinwa Toki | db8fc31 | 2018-02-26 21:37:51 +0000 | [diff] [blame] | 298 | public boolean isModelDarkLaunchEnabled() { |
| 299 | return mModelDarkLaunchEnabled; |
Abodunrinwa Toki | 0e6b43e | 2017-09-19 23:18:40 +0100 | [diff] [blame] | 300 | } |
| 301 | |
Abodunrinwa Toki | db8fc31 | 2018-02-26 21:37:51 +0000 | [diff] [blame] | 302 | public boolean isSmartSelectionEnabled() { |
| 303 | return mSmartSelectionEnabled; |
| 304 | } |
| 305 | |
| 306 | public boolean isSmartTextShareEnabled() { |
| 307 | return mSmartTextShareEnabled; |
Abodunrinwa Toki | 0e6b43e | 2017-09-19 23:18:40 +0100 | [diff] [blame] | 308 | } |
Richard Ledley | 9cfa606 | 2018-01-15 13:13:29 +0000 | [diff] [blame] | 309 | |
| 310 | public boolean isSmartLinkifyEnabled() { |
| 311 | return mSmartLinkifyEnabled; |
| 312 | } |
Jan Althaus | 108aad3 | 2018-01-30 15:26:55 +0100 | [diff] [blame] | 313 | |
Abodunrinwa Toki | db8fc31 | 2018-02-26 21:37:51 +0000 | [diff] [blame] | 314 | public boolean isSmartSelectionAnimationEnabled() { |
| 315 | return mSmartSelectionAnimationEnabled; |
| 316 | } |
| 317 | |
Jan Althaus | 108aad3 | 2018-01-30 15:26:55 +0100 | [diff] [blame] | 318 | public int getSuggestSelectionMaxRangeLength() { |
| 319 | return mSuggestSelectionMaxRangeLength; |
| 320 | } |
| 321 | |
| 322 | public int getClassifyTextMaxRangeLength() { |
| 323 | return mClassifyTextMaxRangeLength; |
| 324 | } |
| 325 | |
| 326 | public int getGenerateLinksMaxTextLength() { |
| 327 | return mGenerateLinksMaxTextLength; |
| 328 | } |
Jan Althaus | 31efdc3 | 2018-02-19 22:23:13 +0100 | [diff] [blame] | 329 | |
| 330 | public int getGenerateLinksLogSampleRate() { |
| 331 | return mGenerateLinksLogSampleRate; |
| 332 | } |
Jan Althaus | 0aacdb6 | 2018-02-19 11:44:37 +0100 | [diff] [blame] | 333 | |
| 334 | public List<String> getEntityListDefault() { |
| 335 | return mEntityListDefault; |
| 336 | } |
| 337 | |
| 338 | public List<String> getEntityListNotEditable() { |
| 339 | return mEntityListNotEditable; |
| 340 | } |
| 341 | |
| 342 | public List<String> getEntityListEditable() { |
| 343 | return mEntityListEditable; |
| 344 | } |
| 345 | |
Tony Mak | adbebcc | 2018-10-30 18:59:06 +0000 | [diff] [blame] | 346 | public List<String> getInAppConversationActionTypes() { |
| 347 | return mInAppConversationActionTypesDefault; |
| 348 | } |
| 349 | |
| 350 | public List<String> getNotificationConversationActionTypes() { |
| 351 | return mNotificationConversationActionTypesDefault; |
| 352 | } |
| 353 | |
Abodunrinwa Toki | a77dba6 | 2019-01-25 19:27:11 +0000 | [diff] [blame] | 354 | public float getLangIdThresholdOverride() { |
| 355 | return mLangIdThresholdOverride; |
| 356 | } |
| 357 | |
Tony Mak | fc039c3 | 2019-01-17 19:32:08 +0000 | [diff] [blame] | 358 | public boolean isTemplateIntentFactoryEnabled() { |
| 359 | return mTemplateIntentFactoryEnabled; |
| 360 | } |
| 361 | |
Abodunrinwa Toki | a77dba6 | 2019-01-25 19:27:11 +0000 | [diff] [blame] | 362 | private static List<String> parseStringList(String listStr) { |
| 363 | return Collections.unmodifiableList(Arrays.asList(listStr.split(STRING_LIST_DELIMITER))); |
Jan Althaus | 0aacdb6 | 2018-02-19 11:44:37 +0100 | [diff] [blame] | 364 | } |
Tony Mak | f93e9e5 | 2018-07-16 14:46:29 +0200 | [diff] [blame] | 365 | |
| 366 | void dump(IndentingPrintWriter pw) { |
| 367 | pw.println("TextClassificationConstants:"); |
| 368 | pw.increaseIndent(); |
| 369 | pw.printPair("isLocalTextClassifierEnabled", mLocalTextClassifierEnabled); |
| 370 | pw.printPair("isSystemTextClassifierEnabled", mSystemTextClassifierEnabled); |
| 371 | pw.printPair("isModelDarkLaunchEnabled", mModelDarkLaunchEnabled); |
| 372 | pw.printPair("isSmartSelectionEnabled", mSmartSelectionEnabled); |
| 373 | pw.printPair("isSmartTextShareEnabled", mSmartTextShareEnabled); |
| 374 | pw.printPair("isSmartLinkifyEnabled", mSmartLinkifyEnabled); |
| 375 | pw.printPair("isSmartSelectionAnimationEnabled", mSmartSelectionAnimationEnabled); |
| 376 | pw.printPair("getSuggestSelectionMaxRangeLength", mSuggestSelectionMaxRangeLength); |
| 377 | pw.printPair("getClassifyTextMaxRangeLength", mClassifyTextMaxRangeLength); |
| 378 | pw.printPair("getGenerateLinksMaxTextLength", mGenerateLinksMaxTextLength); |
| 379 | pw.printPair("getGenerateLinksLogSampleRate", mGenerateLinksLogSampleRate); |
| 380 | pw.printPair("getEntityListDefault", mEntityListDefault); |
| 381 | pw.printPair("getEntityListNotEditable", mEntityListNotEditable); |
| 382 | pw.printPair("getEntityListEditable", mEntityListEditable); |
Tony Mak | adbebcc | 2018-10-30 18:59:06 +0000 | [diff] [blame] | 383 | pw.printPair("getInAppConversationActionTypes", mInAppConversationActionTypesDefault); |
| 384 | pw.printPair("getNotificationConversationActionTypes", |
| 385 | mNotificationConversationActionTypesDefault); |
Abodunrinwa Toki | a77dba6 | 2019-01-25 19:27:11 +0000 | [diff] [blame] | 386 | pw.printPair("getLangIdThresholdOverride", mLangIdThresholdOverride); |
Tony Mak | fc039c3 | 2019-01-17 19:32:08 +0000 | [diff] [blame] | 387 | pw.printPair("isTemplateIntentFactoryEnabled", mTemplateIntentFactoryEnabled); |
Tony Mak | f93e9e5 | 2018-07-16 14:46:29 +0200 | [diff] [blame] | 388 | pw.decreaseIndent(); |
| 389 | pw.println(); |
| 390 | } |
Abodunrinwa Toki | 0e6b43e | 2017-09-19 23:18:40 +0100 | [diff] [blame] | 391 | } |