Search in sources :

Example 1 with ToggleSwitch

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);
                }
            }
        }
    });
}
Also used : ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) SearchView(android.widget.SearchView) SendIntentException(android.content.IntentSender.SendIntentException) ColorDrawable(android.graphics.drawable.ColorDrawable) ToggleSwitch(com.android.settings.widget.ToggleSwitch) AdapterView(android.widget.AdapterView) PrinterInfo(android.print.PrinterInfo) SettingsActivity(com.android.settings.SettingsActivity)

Example 2 with ToggleSwitch

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;
        }
    });
}
Also used : ToggleSwitch(com.android.settings.widget.ToggleSwitch) OnBeforeCheckedChangeListener(com.android.settings.widget.ToggleSwitch.OnBeforeCheckedChangeListener)

Example 3 with ToggleSwitch

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;
        }
    });
}
Also used : ToggleSwitch(com.android.settings.widget.ToggleSwitch) OnBeforeCheckedChangeListener(com.android.settings.widget.ToggleSwitch.OnBeforeCheckedChangeListener)

Example 4 with ToggleSwitch

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;
        }
    });
}
Also used : ToggleSwitch(com.android.settings.widget.ToggleSwitch) OnBeforeCheckedChangeListener(com.android.settings.widget.ToggleSwitch.OnBeforeCheckedChangeListener)

Aggregations

ToggleSwitch (com.android.settings.widget.ToggleSwitch)4 OnBeforeCheckedChangeListener (com.android.settings.widget.ToggleSwitch.OnBeforeCheckedChangeListener)3 SendIntentException (android.content.IntentSender.SendIntentException)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 PrinterInfo (android.print.PrinterInfo)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 SearchView (android.widget.SearchView)1 TextView (android.widget.TextView)1 SettingsActivity (com.android.settings.SettingsActivity)1