Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aabb3512 authored by Jatin Matani's avatar Jatin Matani
Browse files

Refactor StatsUtils into two components:StatsUtils & StatsUtilsManager

Bug:16522256
Change-Id: I9cb8129c552159cf17ea5c2656e0988bf0f999f5
parent 98e56c69
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -16,22 +16,12 @@

package com.android.inputmethod.latin.utils;

import android.content.Context;

import com.android.inputmethod.latin.RichInputMethodManager;
import com.android.inputmethod.latin.settings.SettingsValues;

public final class StatsUtils {
    public static void init(final Context context) {
    }

    public static void onCreate(final SettingsValues settingsValues,
            RichInputMethodManager richImm) {
    }

    public static void onLoadSettings(final SettingsValues settingsValues) {
    }

    public static void onDestroy() {
    }
}
+43 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 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.
 */


package com.android.inputmethod.latin.utils;

import android.content.Context;

import com.android.inputmethod.latin.settings.SettingsValues;

public class StatsUtilsManager {

    private static final StatsUtilsManager sInstance = new StatsUtilsManager();

    /**
     * @return the singleton instance of {@link StatsUtilsManager}.
     */
    public static StatsUtilsManager getInstance() {
        return sInstance;
    }

    public void onCreate(final Context context) {
    }

    public void onLoadSettings(final SettingsValues settingsValues) {
    }

    public void onDestroy() {
    }
}
+6 −5
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ import com.android.inputmethod.latin.utils.IntentUtils;
import com.android.inputmethod.latin.utils.JniUtils;
import com.android.inputmethod.latin.utils.LeakGuardHandlerWrapper;
import com.android.inputmethod.latin.utils.StatsUtils;
import com.android.inputmethod.latin.utils.StatsUtilsManager;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
import com.android.inputmethod.latin.utils.ViewLayoutUtils;

@@ -158,6 +159,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
    private final SubtypeSwitcher mSubtypeSwitcher;
    private final SubtypeState mSubtypeState = new SubtypeState();
    private final SpecialKeyDetector mSpecialKeyDetector;
    private StatsUtilsManager mStatsUtilsManager;

    // Object for reacting to adding/removing a dictionary pack.
    private final BroadcastReceiver mDictionaryPackInstallReceiver =
@@ -538,6 +540,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
        mSubtypeSwitcher = SubtypeSwitcher.getInstance();
        mKeyboardSwitcher = KeyboardSwitcher.getInstance();
        mSpecialKeyDetector = new SpecialKeyDetector(this);
        mStatsUtilsManager = StatsUtilsManager.getInstance();
        mIsHardwareAcceleratedDrawingEnabled =
                InputMethodServiceCompatUtils.enableHardwareAcceleration(this);
        Log.i(TAG, "Hardware accelerated drawing: " + mIsHardwareAcceleratedDrawingEnabled);
@@ -553,8 +556,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
        KeyboardSwitcher.init(this);
        AudioAndHapticFeedbackManager.init(this);
        AccessibilityUtils.init(this);
        StatsUtils.init(this);

        super.onCreate();

        mHandler.onCreate();
@@ -586,7 +587,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
        registerReceiver(mDictionaryDumpBroadcastReceiver, dictDumpFilter);

        DictionaryDecayBroadcastReciever.setUpIntervalAlarmForDictionaryDecaying(this);

        mStatsUtilsManager.onCreate(this /* context */);
        StatsUtils.onCreate(mSettings.getCurrent(), mRichImm);
    }

@@ -609,7 +610,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
        mDictionaryFacilitator.updateEnabledSubtypes(mRichImm.getMyEnabledInputMethodSubtypeList(
                true /* allowsImplicitlySelectedSubtypes */));
        refreshPersonalizationDictionarySession(currentSettingsValues);
        StatsUtils.onLoadSettings(currentSettingsValues);
        mStatsUtilsManager.onLoadSettings(currentSettingsValues);
    }

    private void refreshPersonalizationDictionarySession(
@@ -699,7 +700,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
        unregisterReceiver(mConnectivityAndRingerModeChangeReceiver);
        unregisterReceiver(mDictionaryPackInstallReceiver);
        unregisterReceiver(mDictionaryDumpBroadcastReceiver);
        StatsUtils.onDestroy();
        mStatsUtilsManager.onDestroy();
        super.onDestroy();
    }