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

Commit 1a97fa13 authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

Polish of the accessibility settings.

Change-Id: Ifb32ec6745e566cf7ffafe20019b68d95661b45d
parent bb33bdce
Loading
Loading
Loading
Loading
+23 −18
Original line number Diff line number Diff line
@@ -2681,9 +2681,8 @@ found in the list of installed applications.</string>
    <!-- Title for accessibility preference to enable touch exploration mode. [CHAR LIMIT=35] -->
    <string name="accessibility_touch_exploration_title">Explore by touch</string>
    <!-- Summary for accessibility of the touch exploration mode. [CHAR LIMIT=NONE] -->
    <string name="accessibility_touch_exploration_summary" >Allows exploring screen content and interacting with the device.\n\n
        Touch the screen to receive feedback of the content under your finger.\n\n Tap on the last explored location to activate.\n\n
        Use two fingers to drag. </string>
    <string name="accessibility_touch_exploration_summary" >When Explore by Touch is turned on,
    you can hear or see descriptions of what\'s under your finger.\n\n This feature is for low-vision users.</string>
    <!-- Title for accessibility preference to choose long-press delay i.e. timeout before it is detected. [CHAR LIMIT=35] -->
    <string name="accessibility_long_press_timeout_title">Touch &amp; hold delay</string>
    <!-- Title for accessibility preference to install accessibility scripts from Google. [CHAR LIMIT=35] -->
@@ -2710,31 +2709,37 @@ found in the list of installed applications.</string>
    <string name="accessibility_script_injection_button_disallow">Don\'t Allow</string>

    <!-- Warning message about security implications of enabling an accessibility service,
         displayed as a dialog message when the user selects to enable an accessibility service. [CHAR LIMIT=NONE] -->
    <string name="accessibility_service_security_warning">This accessibility service may be able to collect
        all the text you type, including personal data credit card numbers except passwords.
        It may also log your user interface interactions. It comes from the application
        <xliff:g id="accessibility_service_name">%1$s</xliff:g>. Use this accessibility service?</string>
    <!-- Warning about disabling accessibility displayed as a dialog message when the user
         displayed as a dialog message when the user selects to enable an accessibility service (tablet). [CHAR LIMIT=NONE] -->
    <string name="accessibility_service_security_warning">
            <xliff:g id="accessibility_service_name">%1$s</xliff:g> can
            collect all of the text you type, except passwords. This includes personal data such as credit card
            numbers. It can also collect data about your interactions with the device.</string>
    <!-- Title for a warning about disabling accessibility displayed as a dialog message when the user
         selects to disable accessibility. This avoids accidental disabling. [CHAR LIMIT=30] -->
    <string name="accessibility_disable_warning_title">Turn accessibility off?</string>
    <!-- Summary for a warning about disabling accessibility displayed as a dialog message when the user
         selects to disable accessibility. This avoids accidental disabling. [CHAR LIMIT=NONE] -->
    <string name="accessibility_service_disable_warning">Disable accessibility?</string>
    <string name="accessibility_disable_warning_summary">Touching OK will stop spoken
        descriptions and all other accessibility features you\'ve been using.</string>
    <!-- Title for the prompt that lets users know that they have no accessibility related apps
         installed and that they can install TalkBack from Market. [CHAR LIMIT=50] -->
    <string name="accessibility_service_no_apps_title">No accessibility related applications found
    <string name="accessibility_service_no_apps_title">No accessibility applications
        </string>
    <!-- Message for the prompt that lets users know that they have no accessibility related apps
         installed and that they can install TalkBack from Market. [CHAR LIMIT=NONE] -->
    <string name="accessibility_service_no_apps_message">You do not have any accessibility-related
        applications installed.\n\nYou can download a screen reader for your device from Android
        Market.\n\nClick "OK" to install the screen reader.</string>
    <string name="accessibility_service_no_apps_message">You don\'t have accessibility
        applications installed. Do you want to download a screen reader from the Android Market?</string>
    <!-- Warning message about security implications of downloading accessibility scripts,
         displayed as a dialog message when the user selects to enable script downloading. [CHAR LIMIT=NONE] -->
    <string name="accessibility_script_injection_security_warning">Some applications can ask Google
        to download scripts to your device that make their content more accessible. Are you sure you
        want to allow Google to install accessibility scripts on your device?</string>
    <string name="accessibility_script_injection_security_warning">Do you want applications to install
        scripts from Google that will make their content more accessible?</string>
    <!-- Warning message that the interaction model changes on enabling touch exploration. [CHAR LIMIT=NONE] -->
    <string name="accessibility_touch_exploration_warning">Enabling explore by touch
        changes the interation model. Enable explore by touch?</string>
        changes how the devices respons to touch. Enable explore by touch?</string>
    <!-- Default description for an accessiiblity serivice if the latter doesn't provide one. [CHAR LIMIT=NONE] -->
    <string name="accessibility_service_default_description">This accessibility service has no
        description.\n\nAccessibility services provide various types of feedback when you interact
        with the device. </string>

    <!-- App Fuel Gauge strings -->
    <skip />
+9 −4
Original line number Diff line number Diff line
@@ -30,12 +30,12 @@
        <CheckBoxPreference
                android:key="toggle_large_text_preference"
                android:title="@string/accessibility_toggle_large_text_title"
                android:persistent="false"/>
                android:persistent="true"/>

        <CheckBoxPreference
                android:key="toggle_power_button_ends_call_preference"
                android:title="@string/accessibility_power_button_ends_call_title"
                android:persistent="false">
                android:persistent="true">
        </CheckBoxPreference>

        <PreferenceScreen
@@ -55,10 +55,15 @@
                android:entryValues="@array/long_press_timeout_selector_values"
                android:persistent="true" />

        <Preference
        <com.android.settings.AccessibilityEnableScriptInjectionPreference
                android:key="toggle_script_injection_preference"
                android:title="@string/accessibility_script_injection_title"
                android:persistent="false" />
                android:dialogTitle="@android:string/dialog_alert_title"
                android:dialogIcon="@android:drawable/ic_dialog_alert"
                android:dialogMessage="@string/accessibility_script_injection_security_warning"
                android:positiveButtonText="@string/accessibility_script_injection_button_allow"
                android:negativeButtonText="@string/accessibility_script_injection_button_disallow"
                android:persistent="true" />

    </PreferenceCategory>

+175 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2011 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;

import android.content.Context;
import android.content.res.TypedArray;
import android.os.Parcel;
import android.os.Parcelable;
import android.preference.DialogPreference;
import android.provider.Settings;
import android.util.AttributeSet;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;

/**
 * Preference for enabling accessibility script injection. It displays a warning
 * dialog before enabling the preference.
 */
public class AccessibilityEnableScriptInjectionPreference extends DialogPreference {

    private boolean mInjectionAllowed;
    private boolean mSendClickAccessibilityEvent;

    public AccessibilityEnableScriptInjectionPreference(Context context, AttributeSet attrs) {
        super(context, attrs);
        updateSummary();
    }

    public void setInjectionAllowed(boolean injectionAllowed) {
        if (mInjectionAllowed != injectionAllowed) {
            mInjectionAllowed = injectionAllowed;
            persistBoolean(injectionAllowed);
            updateSummary();
        }
    }

    public boolean isInjectionAllowed() {
        return mInjectionAllowed;
    }

    @Override
    protected void onBindView(View view) {
        super.onBindView(view);
        View summaryView = view.findViewById(com.android.internal.R.id.summary);
        sendAccessibilityEvent(summaryView);
    }

    private void sendAccessibilityEvent(View view) {
        // Since the view is still not attached we create, populate,
        // and send the event directly since we do not know when it
        // will be attached and posting commands is not as clean.
        AccessibilityManager accessibilityManager = AccessibilityManager.getInstance(getContext());
        if (mSendClickAccessibilityEvent && accessibilityManager.isEnabled()) {
            AccessibilityEvent event = AccessibilityEvent.obtain();
            event.setEventType(AccessibilityEvent.TYPE_VIEW_CLICKED);
            view.onInitializeAccessibilityEvent(event);
            view.dispatchPopulateAccessibilityEvent(event);
            accessibilityManager.sendAccessibilityEvent(event);
        }
        mSendClickAccessibilityEvent = false;
    }

    @Override
    protected void onClick() {
        if (isInjectionAllowed()) {
            setInjectionAllowed(false);
            // Update the system setting only upon user action.
            setSystemSetting(false);
            mSendClickAccessibilityEvent = true;
        } else {
            super.onClick();
            mSendClickAccessibilityEvent = false;
        }
    }

    @Override
    protected Object onGetDefaultValue(TypedArray a, int index) {
        return a.getBoolean(index, false);
    }

    @Override
    protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
        setInjectionAllowed(restoreValue
                ? getPersistedBoolean(mInjectionAllowed)
                : (Boolean) defaultValue);
    }

    @Override
    protected void onDialogClosed(boolean result) {
        setInjectionAllowed(result);
        if (result) {
            // Update the system setting only upon user action.
            setSystemSetting(true);
        }
    }

    @Override
    protected Parcelable onSaveInstanceState() {
        Parcelable superState = super.onSaveInstanceState();
        if (isPersistent()) {
            return superState;
        }
        SavedState myState = new SavedState(superState);
        myState.mInjectionAllowed = mInjectionAllowed;
        return myState;
    }

    @Override
    protected void onRestoreInstanceState(Parcelable state) {
        if (state == null || !state.getClass().equals(SavedState.class)) {
            super.onRestoreInstanceState(state);
            return;
        }
        SavedState myState = (SavedState) state;
        super.onRestoreInstanceState(myState.getSuperState());
        setInjectionAllowed(myState.mInjectionAllowed);
    }

    private void updateSummary() {
        setSummary(mInjectionAllowed
                ? getContext().getString(R.string.accessibility_script_injection_allowed)
                : getContext().getString(R.string.accessibility_script_injection_disallowed));
    }

    private void setSystemSetting(boolean enabled) {
        Settings.Secure.putInt(getContext().getContentResolver(),
                Settings.Secure.ACCESSIBILITY_SCRIPT_INJECTION, enabled ? 1 : 0);
    }

    private static class SavedState extends BaseSavedState {
        private boolean mInjectionAllowed;

        public SavedState(Parcel source) {
            super(source);
            mInjectionAllowed = (source.readInt() == 1);
        }

        @Override
        public void writeToParcel(Parcel parcel, int flags) {
            super.writeToParcel(parcel, flags);
            parcel.writeInt(mInjectionAllowed ? 1 : 0);
        }

        public SavedState(Parcelable superState) {
            super(superState);
        }

        @SuppressWarnings("all")
        public static final Parcelable.Creator<SavedState> CREATOR =
                new Parcelable.Creator<SavedState>() {
            public SavedState createFromParcel(Parcel in) {
                return new SavedState(in);
            }

            public SavedState[] newArray(int size) {
                return new SavedState[size];
            }
        };
    }
}
+312 −164

File changed.

Preview size limit exceeded, changes collapsed.

+6 −0
Original line number Diff line number Diff line
@@ -47,6 +47,8 @@ import android.widget.ListView;
import android.widget.TextView;
import android.widget.ViewAnimator;

import com.android.settings.R;

import java.util.List;

/**
@@ -54,6 +56,10 @@ import java.util.List;
 * available in Touch Exploration.
 */
public class AccessibilityTutorialActivity extends Activity {

    /** Intent action for launching this activity. */
    public static final String ACTION = "android.settings.ACCESSIBILITY_TUTORIAL";

    /** Instance state saving constant for the active module. */
    private static final String KEY_ACTIVE_MODULE = "active_module";