Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e1549f0a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "MagnificationPreferenceFragment use DashboardFragment" into pi-dev

parents 519009d3 807506b1
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -14,14 +14,17 @@
     limitations under the License.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
                  xmlns:settings="http://schemas.android.com/apk/res-auto"
                  android:key="magnification_preference_screen_title"
                  android:title="@string/accessibility_screen_magnification_title">
    <Preference
        android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment"
        android:key="screen_magnification_gestures_preference_screen"
        android:title="@string/accessibility_screen_magnification_gestures_title"/>
        android:title="@string/accessibility_screen_magnification_gestures_title"
        settings:controller="com.android.settings.accessibility.MagnificationGesturesPreferenceController"/>
    <Preference
        android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment"
        android:key="screen_magnification_navbar_preference_screen"
        android:title="@string/accessibility_screen_magnification_navbar_title"/>
        android:title="@string/accessibility_screen_magnification_navbar_title"
        settings:controller="com.android.settings.accessibility.MagnificationNavbarPreferenceController"/>
</PreferenceScreen>
+2 −2
Original line number Diff line number Diff line
@@ -813,8 +813,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
        if (!MagnificationPreferenceFragment.isApplicable(context.getResources())) {
            preference.setFragment(ToggleScreenMagnificationPreferenceFragment.class.getName());
            final Bundle extras = preference.getExtras();
            MagnificationPreferenceFragment.populateMagnificationGesturesPreferenceExtras(extras,
                    context);
            MagnificationGesturesPreferenceController
                    .populateMagnificationGesturesPreferenceExtras(extras, context);
        }
    }

+2 −2
Original line number Diff line number Diff line
@@ -156,8 +156,8 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
            preference.setFragment(
                    ToggleScreenMagnificationPreferenceFragmentForSetupWizard.class.getName());
            final Bundle extras = preference.getExtras();
            MagnificationPreferenceFragment.populateMagnificationGesturesPreferenceExtras(extras,
                    context);
            MagnificationGesturesPreferenceController
                    .populateMagnificationGesturesPreferenceExtras(extras, context);
        }
    }
}
+80 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the
 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
package com.android.settings.accessibility;

import android.content.Context;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v7.preference.Preference;

import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;

public class MagnificationGesturesPreferenceController extends BasePreferenceController {

    private boolean mIsFromSUW = false;

    public MagnificationGesturesPreferenceController(Context context, String key) {
        super(context, key);
    }

    public void setIsFromSUW(boolean fromSUW) {
        mIsFromSUW = fromSUW;
    }

    @Override
    public boolean handlePreferenceTreeClick(Preference preference) {
        if (getPreferenceKey().equals(preference.getKey())) {
            Bundle extras = preference.getExtras();
            populateMagnificationGesturesPreferenceExtras(extras, mContext);
            extras.putBoolean(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW, mIsFromSUW);
        }
        return false;
    }

    @Override
    public int getAvailabilityStatus() {
        return AVAILABLE;
    }

    @Override
    public CharSequence getSummary() {
        int resId = 0;
        if (mIsFromSUW) {
            resId = R.string.accessibility_screen_magnification_short_summary;
        } else {
            final boolean enabled = Settings.Secure.getInt(mContext.getContentResolver(),
                    Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, 0) == 1;
            resId = (enabled ? R.string.accessibility_feature_state_on :
                    R.string.accessibility_feature_state_off);
        }
        return mContext.getString(resId);
    }

    static void populateMagnificationGesturesPreferenceExtras(Bundle extras, Context context) {
        extras.putString(AccessibilitySettings.EXTRA_PREFERENCE_KEY,
                Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED);
        extras.putString(AccessibilitySettings.EXTRA_TITLE, context.getString(
                R.string.accessibility_screen_magnification_gestures_title));
        extras.putInt(AccessibilitySettings.EXTRA_TITLE_RES,
                R.string.accessibility_screen_magnification_gestures_title);
        extras.putCharSequence(AccessibilitySettings.EXTRA_SUMMARY, context.getResources().getText(
                R.string.accessibility_screen_magnification_summary));
        extras.putBoolean(AccessibilitySettings.EXTRA_CHECKED,
                Settings.Secure.getInt(context.getContentResolver(),
                        Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, 0) == 1);
        extras.putInt(AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID,
                R.raw.accessibility_screen_magnification);
    }
}
+78 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the
 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
package com.android.settings.accessibility;

import android.content.Context;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v7.preference.Preference;

import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;

public class MagnificationNavbarPreferenceController extends BasePreferenceController {

    private boolean mIsFromSUW = false;

    public MagnificationNavbarPreferenceController(Context context, String key) {
        super(context, key);
    }

    public void setIsFromSUW(boolean fromSUW) {
        mIsFromSUW = fromSUW;
    }

    @Override
    public boolean handlePreferenceTreeClick(Preference preference) {
        if (getPreferenceKey().equals(preference.getKey())) {
            Bundle extras = preference.getExtras();
            extras.putString(AccessibilitySettings.EXTRA_PREFERENCE_KEY,
                    Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED);
            extras.putString(AccessibilitySettings.EXTRA_TITLE, mContext.getString(
                    R.string.accessibility_screen_magnification_navbar_title));
            extras.putInt(AccessibilitySettings.EXTRA_TITLE_RES,
                    R.string.accessibility_screen_magnification_navbar_title);
            extras.putCharSequence(AccessibilitySettings.EXTRA_SUMMARY,
                    mContext.getResources().getText(
                            R.string.accessibility_screen_magnification_navbar_summary));
            extras.putBoolean(AccessibilitySettings.EXTRA_CHECKED,
                    Settings.Secure.getInt(mContext.getContentResolver(),
                            Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, 0)
                            == 1);
            extras.putBoolean(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW, mIsFromSUW);
        }
        return false;
    }

    @Override
    public int getAvailabilityStatus() {
        return MagnificationPreferenceFragment.isApplicable(mContext.getResources())
                ? AVAILABLE
                : DISABLED_UNSUPPORTED;
    }

    @Override
    public CharSequence getSummary() {
        int resId = 0;
        if (mIsFromSUW) {
            resId = R.string.accessibility_screen_magnification_navbar_short_summary;
        } else {
            final boolean enabled = Settings.Secure.getInt(mContext.getContentResolver(),
                    Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, 0) == 1;
            resId = (enabled ? R.string.accessibility_feature_state_on :
                    R.string.accessibility_feature_state_off);
        }
        return mContext.getText(resId);
    }
}
Loading