Search in sources :

Example 1 with BatteryTipAction

use of com.android.settings.fuelgauge.batterytip.actions.BatteryTipAction in project android_packages_apps_Settings by omnirom.

the class BatteryTipPreferenceController method handlePreferenceTreeClick.

@Override
public boolean handlePreferenceTreeClick(Preference preference) {
    final BatteryTip batteryTip = mBatteryTipMap.get(preference.getKey());
    if (batteryTip != null) {
        if (batteryTip.shouldShowDialog()) {
            BatteryTipDialogFragment dialogFragment = BatteryTipDialogFragment.newInstance(batteryTip, mFragment.getMetricsCategory());
            dialogFragment.setTargetFragment(mFragment, REQUEST_ANOMALY_ACTION);
            dialogFragment.show(mFragment.getFragmentManager(), TAG);
        } else {
            final BatteryTipAction action = BatteryTipUtils.getActionForBatteryTip(batteryTip, mSettingsActivity, mFragment);
            if (action != null) {
                action.handlePositiveAction(mFragment.getMetricsCategory());
            }
            if (mBatteryTipListener != null) {
                mBatteryTipListener.onBatteryTipHandled(batteryTip);
            }
        }
        return true;
    }
    return super.handlePreferenceTreeClick(preference);
}
Also used : BatteryTipAction(com.android.settings.fuelgauge.batterytip.actions.BatteryTipAction) BatteryTip(com.android.settings.fuelgauge.batterytip.tips.BatteryTip)

Example 2 with BatteryTipAction

use of com.android.settings.fuelgauge.batterytip.actions.BatteryTipAction in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BatteryTipDialogFragment method onClick.

@Override
public void onClick(DialogInterface dialog, int which) {
    final BatteryTipListener lsn = (BatteryTipListener) getTargetFragment();
    if (lsn == null) {
        return;
    }
    final BatteryTipAction action = BatteryTipUtils.getActionForBatteryTip(mBatteryTip, (SettingsActivity) getActivity(), (InstrumentedPreferenceFragment) getTargetFragment());
    if (action != null) {
        action.handlePositiveAction(mMetricsKey);
    }
    lsn.onBatteryTipHandled(mBatteryTip);
}
Also used : BatteryTipListener(com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController.BatteryTipListener) BatteryTipAction(com.android.settings.fuelgauge.batterytip.actions.BatteryTipAction)

Example 3 with BatteryTipAction

use of com.android.settings.fuelgauge.batterytip.actions.BatteryTipAction in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BatteryTipPreferenceController method handlePreferenceTreeClick.

@Override
public boolean handlePreferenceTreeClick(Preference preference) {
    final BatteryTip batteryTip = mBatteryTipMap.get(preference.getKey());
    if (batteryTip != null) {
        if (batteryTip.shouldShowDialog()) {
            BatteryTipDialogFragment dialogFragment = BatteryTipDialogFragment.newInstance(batteryTip, mFragment.getMetricsCategory());
            dialogFragment.setTargetFragment(mFragment, REQUEST_ANOMALY_ACTION);
            dialogFragment.show(mFragment.getFragmentManager(), TAG);
        } else {
            final BatteryTipAction action = BatteryTipUtils.getActionForBatteryTip(batteryTip, mSettingsActivity, mFragment);
            if (action != null) {
                action.handlePositiveAction(mFragment.getMetricsCategory());
            }
            if (mBatteryTipListener != null) {
                mBatteryTipListener.onBatteryTipHandled(batteryTip);
            }
        }
        return true;
    }
    return super.handlePreferenceTreeClick(preference);
}
Also used : BatteryTipAction(com.android.settings.fuelgauge.batterytip.actions.BatteryTipAction) BatteryTip(com.android.settings.fuelgauge.batterytip.tips.BatteryTip)

Example 4 with BatteryTipAction

use of com.android.settings.fuelgauge.batterytip.actions.BatteryTipAction in project android_packages_apps_Settings by omnirom.

the class BatteryTipDialogFragment method onClick.

@Override
public void onClick(DialogInterface dialog, int which) {
    final BatteryTipListener lsn = (BatteryTipListener) getTargetFragment();
    if (lsn == null) {
        return;
    }
    final BatteryTipAction action = BatteryTipUtils.getActionForBatteryTip(mBatteryTip, (SettingsActivity) getActivity(), (InstrumentedPreferenceFragment) getTargetFragment());
    if (action != null) {
        action.handlePositiveAction(mMetricsKey);
    }
    lsn.onBatteryTipHandled(mBatteryTip);
}
Also used : BatteryTipListener(com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController.BatteryTipListener) BatteryTipAction(com.android.settings.fuelgauge.batterytip.actions.BatteryTipAction)

Aggregations

BatteryTipAction (com.android.settings.fuelgauge.batterytip.actions.BatteryTipAction)4 BatteryTipListener (com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController.BatteryTipListener)2 BatteryTip (com.android.settings.fuelgauge.batterytip.tips.BatteryTip)2