1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.settings.accessibility; 18 19 import static com.android.settings.accessibility.AccessibilityUtil.State.OFF; 20 import static com.android.settings.accessibility.AccessibilityUtil.State.ON; 21 22 import android.content.Context; 23 import android.provider.Settings; 24 25 import com.android.settings.R; 26 27 /** 28 * Controller that accesses and switches the preference status of the magnification joystick feature 29 */ 30 public class MagnificationJoystickPreferenceController extends 31 MagnificationTogglePreferenceController { 32 33 private static final String TAG = 34 MagnificationJoystickPreferenceController.class.getSimpleName(); 35 static final String PREF_KEY = Settings.Secure.ACCESSIBILITY_MAGNIFICATION_JOYSTICK_ENABLED; 36 MagnificationJoystickPreferenceController(Context context, String preferenceKey)37 public MagnificationJoystickPreferenceController(Context context, String preferenceKey) { 38 super(context, preferenceKey); 39 } 40 41 @Override getAvailabilityStatus()42 public int getAvailabilityStatus() { 43 return isInSetupWizard() ? CONDITIONALLY_UNAVAILABLE : AVAILABLE; 44 } 45 46 @Override isChecked()47 public boolean isChecked() { 48 return Settings.Secure.getInt(mContext.getContentResolver(), 49 Settings.Secure.ACCESSIBILITY_MAGNIFICATION_JOYSTICK_ENABLED, OFF) == ON; 50 } 51 52 @Override setChecked(boolean isChecked)53 public boolean setChecked(boolean isChecked) { 54 return Settings.Secure.putInt(mContext.getContentResolver(), 55 Settings.Secure.ACCESSIBILITY_MAGNIFICATION_JOYSTICK_ENABLED, 56 (isChecked ? ON : OFF)); 57 } 58 59 @Override getSliceHighlightMenuRes()60 public int getSliceHighlightMenuRes() { 61 return R.string.menu_key_accessibility; 62 } 63 } 64