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
21341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viveretteimport com.android.settings.accessibility.ToggleSwitch.OnBeforeCheckedChangeListener;
22341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette
23341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverettepublic class ToggleScreenMagnificationPreferenceFragment
24341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette        extends ToggleFeaturePreferenceFragment {
25341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette    @Override
26341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette    protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
27341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette        Settings.Secure.putInt(getContentResolver(),
28341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette                Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, enabled ? 1 : 0);
29341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette    }
30341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette
31341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette    @Override
32341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette    protected void onInstallActionBarToggleSwitch() {
33341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette        super.onInstallActionBarToggleSwitch();
34341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette        mToggleSwitch.setOnBeforeCheckedChangeListener(new OnBeforeCheckedChangeListener() {
35341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette                @Override
36341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette            public boolean onBeforeCheckedChanged(ToggleSwitch toggleSwitch, boolean checked) {
37341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette                toggleSwitch.setCheckedInternal(checked);
38341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette                getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED, checked);
39341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette                onPreferenceToggled(mPreferenceKey, checked);
40341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette                return false;
41341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette            }
42341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette        });
43341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette    }
44341ff66e0374a46f89c51bca2ef55da368b7e40fAlan Viverette}
45