From 28c7b262aa5d81675e1d28a37d9e54f93c67fb0d Mon Sep 17 00:00:00 2001 From: Yohei Yukawa <yukawa@google.com> Date: Tue, 3 Jun 2014 17:40:24 +0900 Subject: [PATCH] Add a preference item for metrics logging BUG: 14324207 Change-Id: Idc8582655bc73cb24e416e8ba78470209b2ff702 --- java/res/values/strings-production.xml | 24 +++++++++++++++++++ java/res/values/strings.xml | 3 +++ java/res/xml/prefs.xml | 6 +++++ .../latin/settings/SettingsFragment.java | 15 ++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 java/res/values/strings-production.xml diff --git a/java/res/values/strings-production.xml b/java/res/values/strings-production.xml new file mode 100644 index 0000000000..8064b99498 --- /dev/null +++ b/java/res/values/strings-production.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2014, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<resources> + <!-- Description for option to enable sending usage statistics --> + <string name="enable_metrics_logging_summary" translatable="false"></string> +</resources> diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index 2ad7ce5925..3f5980dfdf 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -87,6 +87,9 @@ <!-- Option name for enabling the use by the keyboards of sent/received messages, e-mail and typing history to improve suggestion accuracy [CHAR LIMIT=25] --> <string name="use_personalized_dicts">Personalized suggestions</string> + <!-- Option to enable sending usage statistics --> + <string name="enable_metrics_logging">"Improve <xliff:g id="APPLICATION_NAME" example="Android Keyboard">%s</xliff:g>"</string> + <!-- Option name for enabling or disabling the double-space period feature that lets double tap on spacebar insert a period followed by a space [CHAR LIMIT=30] --> <string name="use_double_space_period">Double-space period</string> <!-- Description for option enabling or disabling the double-space period feature that lets double tap on spacebar insert a period followed by a space [CHAR LIMIT=65] --> diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml index a629862280..0e9c16190d 100644 --- a/java/res/xml/prefs.xml +++ b/java/res/xml/prefs.xml @@ -95,6 +95,12 @@ android:summary="@string/use_personalized_dicts_summary" android:persistent="true" android:defaultValue="true" /> + <!-- title will be set programmatically to embed application name --> + <CheckBoxPreference + android:key="pref_enable_metrics_logging" + android:summary="@string/enable_metrics_logging_summary" + android:persistent="true" + android:defaultValue="true" /> </PreferenceCategory> <PreferenceCategory android:title="@string/gesture_typing_category" diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java index af46aad96f..5eb0377c79 100644 --- a/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java @@ -41,6 +41,7 @@ import com.android.inputmethod.keyboard.KeyboardTheme; import com.android.inputmethod.latin.AudioAndHapticFeedbackManager; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.SubtypeSwitcher; +import com.android.inputmethod.latin.define.ProductionFlag; import com.android.inputmethod.latin.setup.LauncherIconVisibilityManager; import com.android.inputmethod.latin.userdictionary.UserDictionaryList; import com.android.inputmethod.latin.userdictionary.UserDictionarySettings; @@ -212,6 +213,20 @@ public final class SettingsFragment extends InputMethodSettingsFragment textCorrectionGroup.removePreference(dictionaryLink); } + if (ProductionFlag.IS_METRICS_LOGGING_SUPPORTED) { + final Preference enableMetricsLogging = + findPreference(Settings.PREF_ENABLE_METRICS_LOGGING); + if (enableMetricsLogging != null) { + final int applicationLabelRes = context.getApplicationInfo().labelRes; + final String applicationName = res.getString(applicationLabelRes); + final String enableMetricsLoggingTitle = res.getString( + R.string.enable_metrics_logging, applicationName); + enableMetricsLogging.setTitle(enableMetricsLoggingTitle); + } + } else { + removePreference(Settings.PREF_ENABLE_METRICS_LOGGING, textCorrectionGroup); + } + final Preference editPersonalDictionary = findPreference(Settings.PREF_EDIT_PERSONAL_DICTIONARY); final Intent editPersonalDictionaryIntent = editPersonalDictionary.getIntent(); -- GitLab