am f0fc320b: Merge "Simplify StatsUtils"

* commit 'f0fc320b4e70f8541b4d9d72b4bc426aad1955d9':
  Simplify StatsUtils
main
Yohei Yukawa 2014-05-15 06:38:49 +00:00 committed by Android Git Automerger
commit e4324df154
4 changed files with 13 additions and 27 deletions

View File

@ -481,6 +481,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
KeyboardSwitcher.init(this); KeyboardSwitcher.init(this);
AudioAndHapticFeedbackManager.init(this); AudioAndHapticFeedbackManager.init(this);
AccessibilityUtils.init(this); AccessibilityUtils.init(this);
StatsUtils.init(this);
super.onCreate(); super.onCreate();
@ -520,7 +521,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
DictionaryDecayBroadcastReciever.setUpIntervalAlarmForDictionaryDecaying(this); DictionaryDecayBroadcastReciever.setUpIntervalAlarmForDictionaryDecaying(this);
StatsUtils.onCreateCompleted(this); StatsUtils.onCreate(mSettings.getCurrent());
} }
// Has to be package-visible for unit tests // Has to be package-visible for unit tests
@ -539,6 +540,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
resetSuggestForLocale(locale); resetSuggestForLocale(locale);
} }
refreshPersonalizationDictionarySession(); refreshPersonalizationDictionarySession();
StatsUtils.onLoadSettings(currentSettingsValues);
} }
private void refreshPersonalizationDictionarySession() { private void refreshPersonalizationDictionarySession() {

View File

@ -87,6 +87,8 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_DEBUG_SETTINGS = "debug_settings"; public static final String PREF_DEBUG_SETTINGS = "debug_settings";
public static final String PREF_KEY_IS_INTERNAL = "pref_key_is_internal"; public static final String PREF_KEY_IS_INTERNAL = "pref_key_is_internal";
public static final String PREF_ENABLE_METRICS_LOGGING = "pref_enable_metrics_logging";
// This preference key is deprecated. Use {@link #PREF_SHOW_LANGUAGE_SWITCH_KEY} instead. // This preference key is deprecated. Use {@link #PREF_SHOW_LANGUAGE_SWITCH_KEY} instead.
// This is being used only for the backward compatibility. // This is being used only for the backward compatibility.
private static final String PREF_SUPPRESS_LANGUAGE_SWITCH_KEY = private static final String PREF_SUPPRESS_LANGUAGE_SWITCH_KEY =

View File

@ -73,6 +73,7 @@ public final class SettingsValues {
public final boolean mPhraseGestureEnabled; public final boolean mPhraseGestureEnabled;
public final int mKeyLongpressTimeout; public final int mKeyLongpressTimeout;
public final Locale mLocale; public final Locale mLocale;
public final boolean mEnableMetricsLogging;
// From the input box // From the input box
public final InputAttributes mInputAttributes; public final InputAttributes mInputAttributes;
@ -134,7 +135,7 @@ public final class SettingsValues {
mAutoCorrectEnabled = Settings.readAutoCorrectEnabled(autoCorrectionThresholdRawValue, res); mAutoCorrectEnabled = Settings.readAutoCorrectEnabled(autoCorrectionThresholdRawValue, res);
mBigramPredictionEnabled = readBigramPredictionEnabled(prefs, res); mBigramPredictionEnabled = readBigramPredictionEnabled(prefs, res);
mDoubleSpacePeriodTimeout = res.getInteger(R.integer.config_double_space_period_timeout); mDoubleSpacePeriodTimeout = res.getInteger(R.integer.config_double_space_period_timeout);
mEnableMetricsLogging = prefs.getBoolean(Settings.PREF_ENABLE_METRICS_LOGGING, true);
// Compute other readable settings // Compute other readable settings
mKeyLongpressTimeout = Settings.readKeyLongpressTimeout(prefs, res); mKeyLongpressTimeout = Settings.readKeyLongpressTimeout(prefs, res);
mKeypressVibrationDuration = Settings.readKeypressVibrationDuration(prefs, res); mKeypressVibrationDuration = Settings.readKeypressVibrationDuration(prefs, res);

View File

@ -17,37 +17,18 @@
package com.android.inputmethod.latin.utils; package com.android.inputmethod.latin.utils;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import com.android.inputmethod.latin.settings.SettingsValues;
import android.preference.PreferenceManager;
import android.util.Log;
import com.android.inputmethod.latin.settings.Settings;
public final class StatsUtils { public final class StatsUtils {
private static final String TAG = StatsUtils.class.getSimpleName(); public static void init(final Context context) {
private static final StatsUtils sInstance = new StatsUtils();
public static void onCreateCompleted(final Context context) {
sInstance.onCreateCompletedInternal(context);
} }
private void onCreateCompletedInternal(final Context context) { public static void onCreate(final SettingsValues settingsValues) {
mContext = context; }
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
final Boolean usePersonalizedDict = public static void onLoadSettings(final SettingsValues settingsValues) {
prefs.getBoolean(Settings.PREF_KEY_USE_PERSONALIZED_DICTS, true);
Log.d(TAG, "onCreateCompleted. context: " + context.toString() + "usePersonalizedDict: "
+ usePersonalizedDict);
} }
public static void onDestroy() { public static void onDestroy() {
sInstance.onDestroyInternal();
} }
private void onDestroyInternal() {
Log.d(TAG, "onDestroy. context: " + mContext.toString());
mContext = null;
}
private Context mContext;
} }