Search in sources :

Example 66 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class MagnificationPreferenceFragment method getConfigurationWarningStringForSecureSettingsKey.

static CharSequence getConfigurationWarningStringForSecureSettingsKey(String key, Context context) {
    if (!Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED.equals(key)) {
        return null;
    }
    if (Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, 0) == 0) {
        return null;
    }
    final AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    final String assignedId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ACCESSIBILITY_BUTTON_TARGET_COMPONENT);
    if (!TextUtils.isEmpty(assignedId) && !MAGNIFICATION_COMPONENT_ID.equals(assignedId)) {
        final ComponentName assignedComponentName = ComponentName.unflattenFromString(assignedId);
        final List<AccessibilityServiceInfo> activeServices = am.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
        final int serviceCount = activeServices.size();
        for (int i = 0; i < serviceCount; i++) {
            final AccessibilityServiceInfo info = activeServices.get(i);
            if (info.getComponentName().equals(assignedComponentName)) {
                final CharSequence assignedServiceName = info.getResolveInfo().loadLabel(context.getPackageManager());
                final int messageId = isGestureNavigateEnabled(context) ? R.string.accessibility_screen_magnification_gesture_navigation_warning : R.string.accessibility_screen_magnification_navbar_configuration_warning;
                return context.getString(messageId, assignedServiceName);
            }
        }
    }
    return null;
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) AccessibilityManager(android.view.accessibility.AccessibilityManager) ComponentName(android.content.ComponentName)

Example 67 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SystemNavigationGestureSettings method isAnyServiceSupportAccessibilityButton.

private boolean isAnyServiceSupportAccessibilityButton() {
    final AccessibilityManager ams = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    final List<AccessibilityServiceInfo> services = ams.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
    for (AccessibilityServiceInfo info : services) {
        if ((info.flags & AccessibilityServiceInfo.FLAG_REQUEST_ACCESSIBILITY_BUTTON) != 0) {
            return true;
        }
    }
    return false;
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) AccessibilityManager(android.view.accessibility.AccessibilityManager)

Example 68 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project Fairphone by Kwamecorp.

the class DragLayer method onInterceptHoverEvent.

@Override
public boolean onInterceptHoverEvent(MotionEvent ev) {
    if (mLauncher == null || mLauncher.getWorkspace() == null) {
        return false;
    }
    Folder currentFolder = mLauncher.getWorkspace().getOpenFolder();
    if (currentFolder == null) {
        return false;
    } else {
        AccessibilityManager accessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
        if (accessibilityManager.isTouchExplorationEnabled()) {
            final int action = ev.getAction();
            boolean isOverFolder;
            switch(action) {
                case MotionEvent.ACTION_HOVER_ENTER:
                    isOverFolder = isEventOverFolder(currentFolder, ev);
                    if (!isOverFolder) {
                        sendTapOutsideFolderAccessibilityEvent(currentFolder.isEditingName());
                        mHoverPointClosesFolder = true;
                        return true;
                    } else if (isOverFolder) {
                        mHoverPointClosesFolder = false;
                    } else {
                        return true;
                    }
                case MotionEvent.ACTION_HOVER_MOVE:
                    isOverFolder = isEventOverFolder(currentFolder, ev);
                    if (!isOverFolder && !mHoverPointClosesFolder) {
                        sendTapOutsideFolderAccessibilityEvent(currentFolder.isEditingName());
                        mHoverPointClosesFolder = true;
                        return true;
                    } else if (isOverFolder) {
                        mHoverPointClosesFolder = false;
                    } else {
                        return true;
                    }
            }
        }
    }
    return false;
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager)

Example 69 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project Fairphone by Kwamecorp.

the class DragLayer method sendTapOutsideFolderAccessibilityEvent.

private void sendTapOutsideFolderAccessibilityEvent(boolean isEditingName) {
    AccessibilityManager accessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (accessibilityManager.isEnabled()) {
        int stringId = isEditingName ? R.string.folder_tap_to_rename : R.string.folder_tap_to_close;
        AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_FOCUSED);
        onInitializeAccessibilityEvent(event);
        event.getText().add(getContext().getString(stringId));
        accessibilityManager.sendAccessibilityEvent(event);
    }
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 70 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project SunDay by iQuick.

the class Manager method announceForAccessibilityCompat.

/**
 * Generates and dispatches an SDK-specific spoken announcement.
 * <p>
 * For backwards compatibility, we're constructing an event from scratch
 * using the appropriate event type. If your application only targets SDK
 * 16+, you can just call View.announceForAccessibility(CharSequence).
 * </p>
 * <p/>
 * note: AccessibilityManager is only available from API lvl 4.
 * <p/>
 * Adapted from https://http://eyes-free.googlecode.com/files/
 * accessibility_codelab_demos_v2_src.zip via
 * https://github.com/coreform/android-formidable-validation
 *
 * @param context Used to get {@link android.view.accessibility.AccessibilityManager}
 * @param text The text to announce.
 */
public static void announceForAccessibilityCompat(Context context, CharSequence text) {
    if (Build.VERSION.SDK_INT >= 4) {
        AccessibilityManager accessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
        if (!accessibilityManager.isEnabled()) {
            return;
        }
        // Prior to SDK 16, announcements could only be made through FOCUSED
        // events. Jelly Bean (SDK 16) added support for speaking text
        // verbatim
        // using the ANNOUNCEMENT event type.
        final int eventType;
        if (Build.VERSION.SDK_INT < 16) {
            eventType = AccessibilityEvent.TYPE_VIEW_FOCUSED;
        } else {
            eventType = AccessibilityEventCompat.TYPE_ANNOUNCEMENT;
        }
        // Construct an accessibility event with the minimum recommended
        // attributes. An event without a class name or package may be
        // dropped.
        final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
        event.getText().add(text);
        event.setClassName(Manager.class.getName());
        event.setPackageName(context.getPackageName());
        // Sends the event directly through the accessibility manager. If
        // your
        // application only targets SDK 14+, you should just call
        // getParent().requestSendAccessibilityEvent(this, event);
        accessibilityManager.sendAccessibilityEvent(event);
    }
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) AccessibilityManager(android.view.accessibility.AccessibilityManager)

Aggregations

AccessibilityManager (android.view.accessibility.AccessibilityManager)170 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)54 AccessibilityEvent (android.view.accessibility.AccessibilityEvent)49 IAccessibilityManager (android.view.accessibility.IAccessibilityManager)43 ArrayList (java.util.ArrayList)26 ServiceInfo (android.content.pm.ServiceInfo)20 MediumTest (android.test.suitebuilder.annotation.MediumTest)20 ComponentName (android.content.ComponentName)16 Drawable (android.graphics.drawable.Drawable)10 Bundle (android.os.Bundle)9 EnforcedAdmin (com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)8 RestrictedPreference (com.android.settingslib.RestrictedPreference)8 SuppressLint (android.annotation.SuppressLint)7 Context (android.content.Context)7 SwitchPreference (android.support.v14.preference.SwitchPreference)7 ListPreference (android.support.v7.preference.ListPreference)7 Preference (android.support.v7.preference.Preference)7 AccessibilityNodeProvider (android.view.accessibility.AccessibilityNodeProvider)7 ITransientNotification (android.app.ITransientNotification)6 Notification (android.app.Notification)6