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);
AudioAndHapticFeedbackManager.init(this);
AccessibilityUtils.init(this);
StatsUtils.init(this);
super.onCreate();
@ -520,7 +521,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
DictionaryDecayBroadcastReciever.setUpIntervalAlarmForDictionaryDecaying(this);
StatsUtils.onCreateCompleted(this);
StatsUtils.onCreate(mSettings.getCurrent());
}
// Has to be package-visible for unit tests
@ -539,6 +540,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
resetSuggestForLocale(locale);
}
refreshPersonalizationDictionarySession();
StatsUtils.onLoadSettings(currentSettingsValues);
}
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_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 is being used only for the backward compatibility.
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 int mKeyLongpressTimeout;
public final Locale mLocale;
public final boolean mEnableMetricsLogging;
// From the input box
public final InputAttributes mInputAttributes;
@ -134,7 +135,7 @@ public final class SettingsValues {
mAutoCorrectEnabled = Settings.readAutoCorrectEnabled(autoCorrectionThresholdRawValue, res);
mBigramPredictionEnabled = readBigramPredictionEnabled(prefs, res);
mDoubleSpacePeriodTimeout = res.getInteger(R.integer.config_double_space_period_timeout);
mEnableMetricsLogging = prefs.getBoolean(Settings.PREF_ENABLE_METRICS_LOGGING, true);
// Compute other readable settings
mKeyLongpressTimeout = Settings.readKeyLongpressTimeout(prefs, res);
mKeypressVibrationDuration = Settings.readKeypressVibrationDuration(prefs, res);

View File

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