use of com.android.settings.widget.ToggleSwitch in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PrintServiceSettingsFragment method initComponents.
private void initComponents() {
mPrintersAdapter = new PrintersAdapter();
mPrintersAdapter.registerDataSetObserver(mDataObserver);
final SettingsActivity activity = (SettingsActivity) getActivity();
mSwitchBar = activity.getSwitchBar();
mSwitchBar.addOnSwitchChangeListener(this);
mSwitchBar.show();
mToggleSwitch = mSwitchBar.getSwitch();
mToggleSwitch.setOnBeforeCheckedChangeListener(new ToggleSwitch.OnBeforeCheckedChangeListener() {
@Override
public boolean onBeforeCheckedChanged(ToggleSwitch toggleSwitch, boolean checked) {
onPreferenceToggled(mPreferenceKey, checked);
return false;
}
});
getBackupListView().setSelector(new ColorDrawable(Color.TRANSPARENT));
getBackupListView().setAdapter(mPrintersAdapter);
getBackupListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
PrinterInfo printer = (PrinterInfo) mPrintersAdapter.getItem(position);
if (printer.getInfoIntent() != null) {
try {
getActivity().startIntentSender(printer.getInfoIntent().getIntentSender(), null, 0, 0, 0);
} catch (SendIntentException e) {
Log.e(LOG_TAG, "Could not execute info intent: %s", e);
}
}
}
});
}
use of com.android.settings.widget.ToggleSwitch in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ToggleAccessibilityServicePreferenceFragment method onInstallSwitchBarToggleSwitch.
@Override
protected void onInstallSwitchBarToggleSwitch() {
super.onInstallSwitchBarToggleSwitch();
mToggleSwitch.setOnBeforeCheckedChangeListener(new OnBeforeCheckedChangeListener() {
@Override
public boolean onBeforeCheckedChanged(ToggleSwitch toggleSwitch, boolean checked) {
if (checked) {
mSwitchBar.setCheckedInternal(false);
getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED, false);
showDialog(DIALOG_ID_ENABLE_WARNING);
} else {
mSwitchBar.setCheckedInternal(true);
getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED, true);
showDialog(DIALOG_ID_DISABLE_WARNING);
}
return true;
}
});
}
use of com.android.settings.widget.ToggleSwitch in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ToggleGlobalGesturePreferenceFragment method onInstallSwitchBarToggleSwitch.
@Override
protected void onInstallSwitchBarToggleSwitch() {
super.onInstallSwitchBarToggleSwitch();
mToggleSwitch.setOnBeforeCheckedChangeListener(new OnBeforeCheckedChangeListener() {
@Override
public boolean onBeforeCheckedChanged(ToggleSwitch toggleSwitch, boolean checked) {
mSwitchBar.setCheckedInternal(checked);
getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED, checked);
onPreferenceToggled(mPreferenceKey, checked);
return false;
}
});
}
use of com.android.settings.widget.ToggleSwitch in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ToggleScreenMagnificationPreferenceFragment method onInstallSwitchBarToggleSwitch.
@Override
protected void onInstallSwitchBarToggleSwitch() {
super.onInstallSwitchBarToggleSwitch();
mToggleSwitch.setOnBeforeCheckedChangeListener(new OnBeforeCheckedChangeListener() {
@Override
public boolean onBeforeCheckedChanged(ToggleSwitch toggleSwitch, boolean checked) {
mSwitchBar.setCheckedInternal(checked);
getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED, checked);
onPreferenceToggled(mPreferenceKey, checked);
return false;
}
});
}
Aggregations