1341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette/*
2341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette * Copyright (C) 2013 The Android Open Source Project
3341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette *
4341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette * Licensed under the Apache License, Version 2.0 (the "License");
5341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette * you may not use this file except in compliance with the License.
6341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette * You may obtain a copy of the License at
7341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette *
8341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette *      http://www.apache.org/licenses/LICENSE-2.0
9341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette *
10341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette * Unless required by applicable law or agreed to in writing, software
11341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette * distributed under the License is distributed on an "AS IS" BASIS,
12341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette * See the License for the specific language governing permissions and
14341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette * limitations under the License.
15341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette */
16341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette
17341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverettepackage com.android.settings.accessibility;
18341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette
19341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viveretteimport android.provider.Settings;
20341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette
215160536df91bb9daa6cac9a878ce406deda791c6Fabrice Di Meglioimport com.android.settings.widget.ToggleSwitch;
225160536df91bb9daa6cac9a878ce406deda791c6Fabrice Di Meglioimport com.android.settings.widget.ToggleSwitch.OnBeforeCheckedChangeListener;
23341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette
24341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverettepublic class ToggleScreenMagnificationPreferenceFragment
25341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette        extends ToggleFeaturePreferenceFragment {
26341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette    @Override
27341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette    protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
28341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette        Settings.Secure.putInt(getContentResolver(),
29341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette                Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, enabled ? 1 : 0);
30341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette    }
31341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette
32341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette    @Override
336220275d6dec8ffc6f1df2cbfbf42934d09d41f0Fabrice Di Meglio    protected void onInstallSwitchBarToggleSwitch() {
346220275d6dec8ffc6f1df2cbfbf42934d09d41f0Fabrice Di Meglio        super.onInstallSwitchBarToggleSwitch();
3500b5e6b24741257352da975966ebe6c143b2eff5Fabrice Di Meglio        mToggleSwitch.setOnBeforeCheckedChangeListener(new OnBeforeCheckedChangeListener() {
36341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette                @Override
37341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette            public boolean onBeforeCheckedChanged(ToggleSwitch toggleSwitch, boolean checked) {
38006b2cca1311e61472a8b66fb0c50854fc36d2e7Fabrice Di Meglio                mSwitchBar.setCheckedInternal(checked);
39341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette                getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED, checked);
40341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette                onPreferenceToggled(mPreferenceKey, checked);
41341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette                return false;
42341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette            }
43341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette        });
44341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette    }
45341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette}
46