Search in sources :

Example 1 with MetricsFeatureProvider

use of com.android.settings.core.instrumentation.MetricsFeatureProvider in project android_packages_apps_Settings by LineageOS.

the class PowerUsageSummary method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    final SettingsActivity sa = (SettingsActivity) getActivity();
    final Context context = getContext();
    final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
    switch(item.getItemId()) {
        case MENU_STATS_TYPE:
            if (mStatsType == BatteryStats.STATS_SINCE_CHARGED) {
                mStatsType = BatteryStats.STATS_SINCE_UNPLUGGED;
            } else {
                mStatsType = BatteryStats.STATS_SINCE_CHARGED;
            }
            refreshUi();
            return true;
        case MENU_HIGH_POWER_APPS:
            Bundle args = new Bundle();
            args.putString(ManageApplications.EXTRA_CLASSNAME, HighPowerApplicationsActivity.class.getName());
            sa.startPreferencePanel(this, ManageApplications.class.getName(), args, R.string.high_power_apps, null, null, 0);
            metricsFeatureProvider.action(context, MetricsEvent.ACTION_SETTINGS_MENU_BATTERY_OPTIMIZATION);
            return true;
        case MENU_ADDITIONAL_BATTERY_INFO:
            startActivity(mPowerFeatureProvider.getAdditionalBatteryInfoIntent());
            metricsFeatureProvider.action(context, MetricsEvent.ACTION_SETTINGS_MENU_BATTERY_USAGE_ALERTS);
            return true;
        case MENU_TOGGLE_APPS:
            mShowAllApps = !mShowAllApps;
            item.setTitle(mShowAllApps ? R.string.hide_extra_apps : R.string.show_all_apps);
            metricsFeatureProvider.action(context, MetricsEvent.ACTION_SETTINGS_MENU_BATTERY_APPS_TOGGLE, mShowAllApps);
            restartBatteryStatsLoader(false);
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
Also used : Context(android.content.Context) MetricsFeatureProvider(com.android.settings.core.instrumentation.MetricsFeatureProvider) Bundle(android.os.Bundle) HighPowerApplicationsActivity(com.android.settings.Settings.HighPowerApplicationsActivity) ManageApplications(com.android.settings.applications.ManageApplications) SettingsActivity(com.android.settings.SettingsActivity)

Example 2 with MetricsFeatureProvider

use of com.android.settings.core.instrumentation.MetricsFeatureProvider in project android_packages_apps_Settings by LineageOS.

the class BluetoothDevicePreference method onClicked.

void onClicked() {
    Context context = getContext();
    int bondState = mCachedDevice.getBondState();
    final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
    if (mCachedDevice.isConnected()) {
        metricsFeatureProvider.action(context, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_DISCONNECT);
        askDisconnect();
    } else if (bondState == BluetoothDevice.BOND_BONDED) {
        metricsFeatureProvider.action(context, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_CONNECT);
        mCachedDevice.connect(true);
    } else if (bondState == BluetoothDevice.BOND_NONE) {
        metricsFeatureProvider.action(context, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR);
        if (!mCachedDevice.hasHumanReadableName()) {
            metricsFeatureProvider.action(context, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR_DEVICES_WITHOUT_NAMES);
        }
        pair();
    }
}
Also used : Context(android.content.Context) MetricsFeatureProvider(com.android.settings.core.instrumentation.MetricsFeatureProvider)

Example 3 with MetricsFeatureProvider

use of com.android.settings.core.instrumentation.MetricsFeatureProvider in project android_packages_apps_Settings by SudaMod.

the class PowerUsageSummary method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    final SettingsActivity sa = (SettingsActivity) getActivity();
    final Context context = getContext();
    final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
    switch(item.getItemId()) {
        case MENU_STATS_TYPE:
            if (mStatsType == BatteryStats.STATS_SINCE_CHARGED) {
                mStatsType = BatteryStats.STATS_SINCE_UNPLUGGED;
            } else {
                mStatsType = BatteryStats.STATS_SINCE_CHARGED;
            }
            refreshUi();
            return true;
        case MENU_HIGH_POWER_APPS:
            Bundle args = new Bundle();
            args.putString(ManageApplications.EXTRA_CLASSNAME, HighPowerApplicationsActivity.class.getName());
            sa.startPreferencePanel(this, ManageApplications.class.getName(), args, R.string.high_power_apps, null, null, 0);
            metricsFeatureProvider.action(context, MetricsEvent.ACTION_SETTINGS_MENU_BATTERY_OPTIMIZATION);
            return true;
        case MENU_ADDITIONAL_BATTERY_INFO:
            startActivity(mPowerFeatureProvider.getAdditionalBatteryInfoIntent());
            metricsFeatureProvider.action(context, MetricsEvent.ACTION_SETTINGS_MENU_BATTERY_USAGE_ALERTS);
            return true;
        case MENU_TOGGLE_APPS:
            mShowAllApps = !mShowAllApps;
            item.setTitle(mShowAllApps ? R.string.hide_extra_apps : R.string.show_all_apps);
            metricsFeatureProvider.action(context, MetricsEvent.ACTION_SETTINGS_MENU_BATTERY_APPS_TOGGLE, mShowAllApps);
            restartBatteryStatsLoader(false);
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
Also used : Context(android.content.Context) MetricsFeatureProvider(com.android.settings.core.instrumentation.MetricsFeatureProvider) Bundle(android.os.Bundle) HighPowerApplicationsActivity(com.android.settings.Settings.HighPowerApplicationsActivity) ManageApplications(com.android.settings.applications.ManageApplications) SettingsActivity(com.android.settings.SettingsActivity)

Example 4 with MetricsFeatureProvider

use of com.android.settings.core.instrumentation.MetricsFeatureProvider in project platform_packages_apps_Settings by BlissRoms.

the class BluetoothDevicePreference method onClicked.

void onClicked() {
    Context context = getContext();
    int bondState = mCachedDevice.getBondState();
    final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
    if (mCachedDevice.isConnected()) {
        metricsFeatureProvider.action(context, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_DISCONNECT);
        askDisconnect();
    } else if (bondState == BluetoothDevice.BOND_BONDED) {
        metricsFeatureProvider.action(context, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_CONNECT);
        mCachedDevice.connect(true);
    } else if (bondState == BluetoothDevice.BOND_NONE) {
        metricsFeatureProvider.action(context, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR);
        if (!mCachedDevice.hasHumanReadableName()) {
            metricsFeatureProvider.action(context, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR_DEVICES_WITHOUT_NAMES);
        }
        pair();
    }
}
Also used : Context(android.content.Context) MetricsFeatureProvider(com.android.settings.core.instrumentation.MetricsFeatureProvider)

Example 5 with MetricsFeatureProvider

use of com.android.settings.core.instrumentation.MetricsFeatureProvider in project android_packages_apps_Settings by omnirom.

the class PowerUsageSummary method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    final SettingsActivity sa = (SettingsActivity) getActivity();
    final Context context = getContext();
    final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
    switch(item.getItemId()) {
        case MENU_STATS_TYPE:
            if (mStatsType == BatteryStats.STATS_SINCE_CHARGED) {
                mStatsType = BatteryStats.STATS_SINCE_UNPLUGGED;
            } else {
                mStatsType = BatteryStats.STATS_SINCE_CHARGED;
            }
            refreshUi();
            return true;
        case MENU_HIGH_POWER_APPS:
            Bundle args = new Bundle();
            args.putString(ManageApplications.EXTRA_CLASSNAME, HighPowerApplicationsActivity.class.getName());
            sa.startPreferencePanel(this, ManageApplications.class.getName(), args, R.string.high_power_apps, null, null, 0);
            metricsFeatureProvider.action(context, MetricsEvent.ACTION_SETTINGS_MENU_BATTERY_OPTIMIZATION);
            return true;
        case MENU_ADDITIONAL_BATTERY_INFO:
            startActivity(mPowerFeatureProvider.getAdditionalBatteryInfoIntent());
            metricsFeatureProvider.action(context, MetricsEvent.ACTION_SETTINGS_MENU_BATTERY_USAGE_ALERTS);
            return true;
        case MENU_TOGGLE_APPS:
            mShowAllApps = !mShowAllApps;
            item.setTitle(mShowAllApps ? R.string.hide_extra_apps : R.string.show_all_apps);
            metricsFeatureProvider.action(context, MetricsEvent.ACTION_SETTINGS_MENU_BATTERY_APPS_TOGGLE, mShowAllApps);
            restartBatteryStatsLoader(false);
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
Also used : Context(android.content.Context) MetricsFeatureProvider(com.android.settings.core.instrumentation.MetricsFeatureProvider) Bundle(android.os.Bundle) HighPowerApplicationsActivity(com.android.settings.Settings.HighPowerApplicationsActivity) ManageApplications(com.android.settings.applications.ManageApplications) SettingsActivity(com.android.settings.SettingsActivity)

Aggregations

Context (android.content.Context)7 MetricsFeatureProvider (com.android.settings.core.instrumentation.MetricsFeatureProvider)7 Bundle (android.os.Bundle)5 HighPowerApplicationsActivity (com.android.settings.Settings.HighPowerApplicationsActivity)5 SettingsActivity (com.android.settings.SettingsActivity)5 ManageApplications (com.android.settings.applications.ManageApplications)5