Example usage for android.content.res Configuration TOUCHSCREEN_NOTOUCH

List of usage examples for android.content.res Configuration TOUCHSCREEN_NOTOUCH

Introduction

In this page you can find the example usage for android.content.res Configuration TOUCHSCREEN_NOTOUCH.

Prototype

int TOUCHSCREEN_NOTOUCH

To view the source code for android.content.res Configuration TOUCHSCREEN_NOTOUCH.

Click Source Link

Document

Constant for #touchscreen , value corresponding to the notouch resource qualifier.

Usage

From source file:com.android.screenspeak.eventprocessor.AccessibilityEventProcessor.java

/**
 * Returns whether the device should drop this event. Caches notifications
 * if necessary./*  w w  w .jav  a 2s  .c o  m*/
 *
 * @param event The current event.
 * @return {@code true} if the event should be dropped.
 */
private boolean shouldDropEvent(AccessibilityEvent event) {
    // Always drop null events.
    if (event == null) {
        return true;
    }

    // Always drop events if the service is suspended.
    if (!ScreenSpeakService.isServiceActive()) {
        return true;
    }

    // If touch exploration is enabled, drop automatically generated events
    // that are sent immediately after a window state change... unless we
    // decide to keep the event.
    if (AccessibilityManagerCompat.isTouchExplorationEnabled(mAccessibilityManager)
            && ((event.getEventType() & AUTOMATIC_AFTER_STATE_CHANGE) != 0)
            && ((event.getEventTime() - mLastWindowStateChanged) < DELAY_AUTO_AFTER_STATE)
            && !shouldKeepAutomaticEvent(event)) {
        if (LogUtils.LOG_LEVEL <= Log.VERBOSE) {
            Log.v(LOGTAG, "Drop event after window state change");
        }
        return true;
    }

    // Real notification events always have parcelable data.
    final boolean isNotification = (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED)
            && (event.getParcelableData() != null);

    final boolean isPhoneActive = (mCallStateMonitor != null)
            && (mCallStateMonitor.getCurrentCallState() != TelephonyManager.CALL_STATE_IDLE);
    final boolean shouldSpeakCallerId = (mSpeakCallerId && (mCallStateMonitor != null)
            && (mCallStateMonitor.getCurrentCallState() == TelephonyManager.CALL_STATE_RINGING));

    if (mRingerModeAndScreenMonitor != null && !mRingerModeAndScreenMonitor.isScreenOn()
            && !shouldSpeakCallerId) {
        if (!mSpeakWhenScreenOff) {
            // If the user doesn't allow speech when the screen is
            // off, drop the event immediately.
            if (LogUtils.LOG_LEVEL <= Log.VERBOSE) {
                Log.v(LOGTAG, "Drop event due to screen state and user pref");
            }
            return true;
        } else if (!isNotification) {
            // If the user allows speech when the screen is off, drop
            // all non-notification events.
            if (LogUtils.LOG_LEVEL <= Log.VERBOSE) {
                Log.v(LOGTAG, "Drop non-notification event due to screen state");
            }
            return true;
        }
    }

    final boolean canInterruptRadialMenu = AccessibilityEventUtils.eventMatchesAnyType(event,
            MASK_EVENT_TYPES_INTERRUPT_RADIAL_MENU);
    final boolean silencedByRadialMenu = (mService.getMenuManager().isMenuShowing() && !canInterruptRadialMenu);

    // Don't speak events that cannot interrupt the radial menu, if showing
    if (silencedByRadialMenu) {
        if (LogUtils.LOG_LEVEL <= Log.VERBOSE) {
            Log.v(LOGTAG, "Drop event due to radial menu state");
        }
        return true;
    }

    // Don't speak notification events if the user is touch exploring or a phone call is active.
    if (isNotification && (mIsUserTouchExploring || isPhoneActive)) {
        if (LogUtils.LOG_LEVEL <= Log.VERBOSE) {
            Log.v(LOGTAG, "Drop notification due to touch or phone state");
        }
        return true;
    }

    final int touchscreenState = mService.getResources().getConfiguration().touchscreen;
    final boolean isTouchInteractionStateChange = AccessibilityEventUtils.eventMatchesAnyType(event,
            MASK_EVENT_TYPES_TOUCH_STATE_CHANGES);

    // Drop all events related to touch interaction state on devices that don't support touch.
    return (touchscreenState == Configuration.TOUCHSCREEN_NOTOUCH) && isTouchInteractionStateChange;
}

From source file:com.android.talkback.eventprocessor.AccessibilityEventProcessor.java

/**
 * Returns whether the device should drop this event. Caches notifications
 * if necessary./*from  w ww.  ja va 2s  .  co  m*/
 *
 * @param event The current event.
 * @return {@code true} if the event should be dropped.
 */
private boolean shouldDropEvent(AccessibilityEvent event) {
    // Always drop null events.
    if (event == null) {
        return true;
    }

    // Always drop events if the service is suspended.
    if (!TalkBackService.isServiceActive()) {
        return true;
    }

    // If touch exploration is enabled, drop automatically generated events
    // that are sent immediately after a window state change... unless we
    // decide to keep the event.
    if (AccessibilityManagerCompat.isTouchExplorationEnabled(mAccessibilityManager)
            && ((event.getEventType() & AUTOMATIC_AFTER_STATE_CHANGE) != 0)
            && ((event.getEventTime() - mLastWindowStateChanged) < DELAY_AUTO_AFTER_STATE)
            && !shouldKeepAutomaticEvent(event)) {
        if (LogUtils.LOG_LEVEL <= Log.VERBOSE) {
            Log.v(LOGTAG, "Drop event after window state change");
        }
        return true;
    }

    // Some view-selected events are spurious if sent immediately after a focused event.
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SELECTED && !shouldKeepViewSelectedEvent(event)) {
        if (LogUtils.LOG_LEVEL <= Log.VERBOSE) {
            Log.v(LOGTAG, "Drop selected event after focused event");
        }
        return true;
    }

    // Real notification events always have parcelable data.
    final boolean isNotification = (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED)
            && (event.getParcelableData() != null);

    final boolean isPhoneActive = (mCallStateMonitor != null)
            && (mCallStateMonitor.getCurrentCallState() != TelephonyManager.CALL_STATE_IDLE);
    final boolean isPhoneRinging = (mCallStateMonitor != null)
            && (mCallStateMonitor.getCurrentCallState() == TelephonyManager.CALL_STATE_RINGING);

    // Sometimes the dialer's window-state-changed event gets sent right before the
    // TelephonyManager transitions to CALL_STATE_RINGING, so we need to check isDialerEvent().
    final boolean shouldSpeakCallerId = isPhoneRinging || isDialerEvent(event);

    if (mRingerModeAndScreenMonitor != null && !mRingerModeAndScreenMonitor.isScreenOn()
            && !shouldSpeakCallerId) {
        if (!mSpeakWhenScreenOff) {
            // If the user doesn't allow speech when the screen is
            // off, drop the event immediately.
            if (LogUtils.LOG_LEVEL <= Log.VERBOSE) {
                Log.v(LOGTAG, "Drop event due to screen state and user pref");
            }
            return true;
        } else if (!isNotification) {
            // If the user allows speech when the screen is off, drop
            // all non-notification events.
            if (LogUtils.LOG_LEVEL <= Log.VERBOSE) {
                Log.v(LOGTAG, "Drop non-notification event due to screen state");
            }
            return true;
        }
    }

    final boolean canInterruptRadialMenu = AccessibilityEventUtils.eventMatchesAnyType(event,
            MASK_EVENT_TYPES_INTERRUPT_RADIAL_MENU);
    final boolean silencedByRadialMenu = (mService.getMenuManager().isMenuShowing() && !canInterruptRadialMenu);

    // Don't speak events that cannot interrupt the radial menu, if showing
    if (silencedByRadialMenu) {
        if (LogUtils.LOG_LEVEL <= Log.VERBOSE) {
            Log.v(LOGTAG, "Drop event due to radial menu state");
        }
        return true;
    }

    // Don't speak notification events if the user is touch exploring or a phone call is active.
    if (isNotification && (mIsUserTouchExploring || isPhoneActive)) {
        if (LogUtils.LOG_LEVEL <= Log.VERBOSE) {
            Log.v(LOGTAG, "Drop notification due to touch or phone state");
        }
        return true;
    }

    final int touchscreenState = mService.getResources().getConfiguration().touchscreen;
    final boolean isTouchInteractionStateChange = AccessibilityEventUtils.eventMatchesAnyType(event,
            MASK_EVENT_TYPES_TOUCH_STATE_CHANGES);

    // Drop all events related to touch interaction state on devices that don't support touch.
    return (touchscreenState == Configuration.TOUCHSCREEN_NOTOUCH) && isTouchInteractionStateChange;
}

From source file:com.vuze.android.remote.AndroidUtils.java

public static boolean usesNavigationControl() {
    Configuration configuration = VuzeRemoteApp.getContext().getResources().getConfiguration();
    if (configuration.navigation == Configuration.NAVIGATION_NONAV) {
        return false;
    } else if (configuration.touchscreen == Configuration.TOUCHSCREEN_FINGER) {
        return false;
    } else if (configuration.navigation == Configuration.NAVIGATION_DPAD) {
        return true;
    } else if (configuration.touchscreen == Configuration.TOUCHSCREEN_NOTOUCH) {
        return true;
    } else if (configuration.touchscreen == Configuration.TOUCHSCREEN_UNDEFINED) {
        return true;
    } else if (configuration.navigationHidden == Configuration.NAVIGATIONHIDDEN_YES) {
        return true;
    } else if (configuration.uiMode == Configuration.UI_MODE_TYPE_TELEVISION) {
        return true;
    }/*w  w  w.j  a v  a2  s .co  m*/
    return false;
}

From source file:com.google.android.marvin.mytalkback.TalkBackService.java

/**
 * Returns whether the device should drop this event. Caches notifications
 * if necessary./* w ww.  j av  a  2 s.com*/
 *
 * @param event The current event.
 * @return {@code true} if the event should be dropped.
 */
private boolean shouldDropEvent(AccessibilityEvent event) {
    // Always drop null events.
    if (event == null) {
        return true;
    }

    // Always drop events if the service is suspended.
    if (!isServiceActive()) {
        return true;
    }

    // Always drop duplicate events (only applies to API < 14).
    if (AccessibilityEventUtils.eventEquals(mLastSpokenEvent, event)) {
        LogUtils.log(this, Log.VERBOSE, "Drop duplicate event");
        return true;
    }

    // If touch exploration is enabled, drop automatically generated events
    // that are sent immediately after a window state change... unless we
    // decide to keep the event.
    if (AccessibilityManagerCompat.isTouchExplorationEnabled(mAccessibilityManager)
            && ((event.getEventType() & AUTOMATIC_AFTER_STATE_CHANGE) != 0)
            && ((event.getEventTime() - mLastWindowStateChanged) < DELAY_AUTO_AFTER_STATE)
            && !shouldKeepAutomaticEvent(event)) {
        LogUtils.log(this, Log.VERBOSE, "Drop event after window state change");
        return true;
    }

    // Real notification events always have parcelable data.
    final boolean isNotification = (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED)
            && (event.getParcelableData() != null);

    final boolean isPhoneActive = (mCallStateMonitor != null)
            && (mCallStateMonitor.getCurrentCallState() != TelephonyManager.CALL_STATE_IDLE);
    final boolean shouldSpeakCallerId = (mSpeakCallerId && (mCallStateMonitor != null)
            && (mCallStateMonitor.getCurrentCallState() == TelephonyManager.CALL_STATE_RINGING));

    if (!mPowerManager.isScreenOn() && !shouldSpeakCallerId) {
        if (!mSpeakWhenScreenOff) {
            // If the user doesn't allow speech when the screen is
            // off, drop the event immediately.
            LogUtils.log(this, Log.VERBOSE, "Drop event due to screen state and user pref");
            return true;
        } else if (!isNotification) {
            // If the user allows speech when the screen is off, drop
            // all non-notification events.
            LogUtils.log(this, Log.VERBOSE, "Drop non-notification event due to screen state");
            return true;
        }
    }

    final boolean canInterruptRadialMenu = AccessibilityEventUtils.eventMatchesAnyType(event,
            MASK_EVENT_TYPES_INTERRUPT_RADIAL_MENU);
    final boolean silencedByRadialMenu = (mRadialMenuManager.isRadialMenuShowing() && !canInterruptRadialMenu);

    // Don't speak events that cannot interrupt the radial menu, if showing
    if (silencedByRadialMenu) {
        LogUtils.log(this, Log.VERBOSE, "Drop event due to radial menu state");
        return true;
    }

    // Don't speak notification events if the user is touch exploring or a phone call is active.
    if (isNotification && (mIsUserTouchExploring || isPhoneActive)) {
        LogUtils.log(this, Log.VERBOSE, "Drop notification due to touch or phone state");
        return true;
    }

    final int touchscreenState = getResources().getConfiguration().touchscreen;
    final boolean isTouchInteractionStateChange = AccessibilityEventUtils.eventMatchesAnyType(event,
            MASK_EVENT_TYPES_TOUCH_STATE_CHANGES);

    // Drop all events related to touch interaction state on devices that don't support touch.
    final int touchscreenConfig = getResources().getConfiguration().touchscreen;
    if ((touchscreenState == Configuration.TOUCHSCREEN_NOTOUCH) && isTouchInteractionStateChange) {
        return true;
    }

    return false;
}

From source file:com.google.android.marvin.screenspeak.ScreenSpeakService.java

/**
 * Launches the touch exploration tutorial if necessary.
 *///  ww  w .  j  a v  a 2s  . co m
public boolean showTutorial() {
    if (!mPrefs.getBoolean(PREF_FIRST_TIME_USER, true)) {
        return false;
    }

    final Editor editor = mPrefs.edit();
    editor.putBoolean(PREF_FIRST_TIME_USER, false);
    editor.apply();

    final int touchscreenState = getResources().getConfiguration().touchscreen;

    if (touchscreenState != Configuration.TOUCHSCREEN_NOTOUCH && mSupportsTouchScreen) {
        final Intent tutorial = new Intent(this, AccessibilityTutorialActivity.class);
        tutorial.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        tutorial.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(tutorial);
        return true;
    }

    return false;
}

From source file:com.google.android.marvin.mytalkback.TalkBackService.java

/**
 * Launches the touch exploration tutorial if necessary.
 *//*from   w w w. j a v  a  2  s. co m*/
private void onTouchExplorationEnabled() {
    if (!mPrefs.getBoolean(PREF_FIRST_TIME_USER, true)) {
        return;
    }

    final Editor editor = mPrefs.edit();
    editor.putBoolean(PREF_FIRST_TIME_USER, false);
    editor.commit();

    final int touchscreenState = getResources().getConfiguration().touchscreen;

    if (Build.VERSION.SDK_INT >= AccessibilityTutorialActivity.MIN_API_LEVEL
            && (touchscreenState != Configuration.TOUCHSCREEN_NOTOUCH)) {
        final Intent tutorial = new Intent(this, AccessibilityTutorialActivity.class);
        tutorial.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        tutorial.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(tutorial);
    }
}

From source file:com.android.gallery3d.app.PhotoPage.java

private boolean canShowBars() {
    // No bars if we are showing camera preview.
    if (mAppBridge != null && mCurrentIndex == 0 && !mPhotoView.getFilmMode())
        return false;

    // No bars if it's not allowed.
    if (!mActionBarAllowed)
        return false;

    Configuration config = mActivity.getResources().getConfiguration();
    if (config.touchscreen == Configuration.TOUCHSCREEN_NOTOUCH) {
        return false;
    }/*from ww  w  .  j a  va  2  s.c om*/

    return true;
}

From source file:com.miz.functions.MizLib.java

/**
 * Determines if the device uses navigation controls as the primary navigation from a number of factors.
 * @param context Application Context// ww w.ja  va2s.c om
 * @return True if the device uses navigation controls, false otherwise.
 */
public static boolean usesNavigationControl(Context context) {
    Configuration configuration = context.getResources().getConfiguration();
    if (configuration.navigation == Configuration.NAVIGATION_NONAV) {
        return false;
    } else if (configuration.touchscreen == Configuration.TOUCHSCREEN_FINGER) {
        return false;
    } else if (configuration.navigation == Configuration.NAVIGATION_DPAD) {
        return true;
    } else if (configuration.touchscreen == Configuration.TOUCHSCREEN_NOTOUCH) {
        return true;
    } else if (configuration.touchscreen == Configuration.TOUCHSCREEN_UNDEFINED) {
        return true;
    } else if (configuration.navigationHidden == Configuration.NAVIGATIONHIDDEN_YES) {
        return true;
    } else if (configuration.uiMode == Configuration.UI_MODE_TYPE_TELEVISION) {
        return true;
    }
    return false;
}