Java Code Examples for android.content.res.Configuration#KEYBOARD_NOKEYS

The following examples show how to use android.content.res.Configuration#KEYBOARD_NOKEYS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InputMethodService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * The system has decided that it may be time to show your input method.
 * This is called due to a corresponding call to your
 * {@link InputMethod#showSoftInput InputMethod.showSoftInput()}
 * method.  The default implementation uses
 * {@link #onEvaluateInputViewShown()}, {@link #onEvaluateFullscreenMode()},
 * and the current configuration to decide whether the input view should
 * be shown at this point.
 * 
 * @param flags Provides additional information about the show request,
 * as per {@link InputMethod#showSoftInput InputMethod.showSoftInput()}.
 * @param configChange This is true if we are re-showing due to a
 * configuration change.
 * @return Returns true to indicate that the window should be shown.
 */
public boolean onShowInputRequested(int flags, boolean configChange) {
    if (!onEvaluateInputViewShown()) {
        return false;
    }
    if ((flags&InputMethod.SHOW_EXPLICIT) == 0) {
        if (!configChange && onEvaluateFullscreenMode()) {
            // Don't show if this is not explicitly requested by the user and
            // the input method is fullscreen.  That would be too disruptive.
            // However, we skip this change for a config change, since if
            // the IME is already shown we do want to go into fullscreen
            // mode at this point.
            return false;
        }
        if (!mSettingsObserver.shouldShowImeWithHardKeyboard() &&
                getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS) {
            // And if the device has a hard keyboard, even if it is
            // currently hidden, don't show the input method implicitly.
            // These kinds of devices don't need it that much.
            return false;
        }
    }
    return true;
}
 
Example 2
Source File: EventFilter.java    From talkback with Apache License 2.0 6 votes vote down vote up
private boolean shouldEchoKeyboard(int changeType) {
  // Always echo text removal events.
  if (changeType == Compositor.EVENT_TYPE_INPUT_TEXT_REMOVE) {
    return true;
  }

  final Resources res = context.getResources();

  switch (keyboardEcho) {
    case PREF_ECHO_ALWAYS:
      return true;
    case PREF_ECHO_SOFTKEYS:
      final Configuration config = res.getConfiguration();
      return (config.keyboard == Configuration.KEYBOARD_NOKEYS)
          || (config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES);
    case PREF_ECHO_NEVER:
      return false;
    default:
      LogUtils.e(TAG, "Invalid keyboard echo preference value: %d", keyboardEcho);
      return false;
  }
}
 
Example 3
Source File: AndroidUtilities.java    From KrGallery with GNU General Public License v2.0 6 votes vote down vote up
public static void checkDisplaySize() {
    try {
        Configuration configuration = applicationContext.getResources()
                .getConfiguration();
        usingHardwareInput = configuration.keyboard != Configuration.KEYBOARD_NOKEYS
                && configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO;
        WindowManager manager = (WindowManager) applicationContext
                .getSystemService(Context.WINDOW_SERVICE);
        if (manager != null) {
            Display display = manager.getDefaultDisplay();
            if (display != null) {
                display.getMetrics(displayMetrics);
                display.getSize(displaySize);
                Log.d("tmessages", "display size = " + displaySize.x + " " + displaySize.y + " "
                        + displayMetrics.xdpi + "x" + displayMetrics.ydpi);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 4
Source File: ContentViewCore.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * @see View#onConfigurationChanged(Configuration)
 */
@SuppressWarnings("javadoc")
public void onConfigurationChanged(Configuration newConfig) {
    TraceEvent.begin();

    if (newConfig.keyboard != Configuration.KEYBOARD_NOKEYS) {
        mImeAdapter.attach(nativeGetNativeImeAdapter(mNativeContentViewCore),
                ImeAdapter.getTextInputTypeNone(),
                AdapterInputConnection.INVALID_SELECTION,
                AdapterInputConnection.INVALID_SELECTION);
        InputMethodManager manager = (InputMethodManager)
                getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        manager.restartInput(mContainerView);
    }
    mContainerViewInternals.super_onConfigurationChanged(newConfig);
    // Make sure the size is up to date in JavaScript's window.onorientationchanged.
    mContainerView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                int oldLeft, int oldTop, int oldRight, int oldBottom) {
            mContainerView.removeOnLayoutChangeListener(this);
            sendOrientationChangeEvent();
        }
    });
    // To request layout has side effect, but it seems OK as it only happen in
    // onConfigurationChange and layout has to be changed in most case.
    mContainerView.requestLayout();
    TraceEvent.end();
}
 
Example 5
Source File: InputMethodService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Override this to control when the soft input area should be shown to the user.  The default
 * implementation returns {@code false} when there is no hard keyboard or the keyboard is hidden
 * unless the user shows an intention to use software keyboard.  If you change what this
 * returns, you will need to call {@link #updateInputViewShown()} yourself whenever the returned
 * value may have changed to have it re-evaluated and applied.
 *
 * <p>When you override this method, it is recommended to call
 * {@code super.onEvaluateInputViewShown()} and return {@code true} when {@code true} is
 * returned.</p>
 */
@CallSuper
public boolean onEvaluateInputViewShown() {
    if (mSettingsObserver == null) {
        Log.w(TAG, "onEvaluateInputViewShown: mSettingsObserver must not be null here.");
        return false;
    }
    if (mSettingsObserver.shouldShowImeWithHardKeyboard()) {
        return true;
    }
    Configuration config = getResources().getConfiguration();
    return config.keyboard == Configuration.KEYBOARD_NOKEYS
            || config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES;
}
 
Example 6
Source File: ImeAdapter.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Show soft keyboard only if it is the current keyboard configuration.
 */
private void showSoftKeyboard() {
    if (DEBUG_LOGS) Log.i(TAG, "showSoftKeyboard");
    mInputMethodManagerWrapper.showSoftInput(mContainerView, 0, getNewShowKeyboardReceiver());
    if (mContainerView.getResources().getConfiguration().keyboard
            != Configuration.KEYBOARD_NOKEYS) {
        mWebContents.scrollFocusedEditableNodeIntoView();
    }
}
 
Example 7
Source File: UmaSessionStats.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Starts a new session for logging.
 * @param tabModelSelector A TabModelSelector instance for recording tab counts on page loads.
 * If null, UmaSessionStats does not record page loads and tab counts.
 */
public void startNewSession(TabModelSelector tabModelSelector) {
    ensureNativeInitialized();

    mTabModelSelector = tabModelSelector;
    if (mTabModelSelector != null) {
        mComponentCallbacks = new ComponentCallbacks() {
            @Override
            public void onLowMemory() {
                // Not required
            }

            @Override
            public void onConfigurationChanged(Configuration newConfig) {
                mKeyboardConnected = newConfig.keyboard != Configuration.KEYBOARD_NOKEYS;
            }
        };
        mContext.registerComponentCallbacks(mComponentCallbacks);
        mKeyboardConnected = mContext.getResources().getConfiguration()
                .keyboard != Configuration.KEYBOARD_NOKEYS;
        mTabModelSelectorTabObserver = new TabModelSelectorTabObserver(mTabModelSelector) {
            @Override
            public void onPageLoadFinished(Tab tab) {
                recordPageLoadStats(tab);
            }
        };
    }

    nativeUmaResumeSession(sNativeUmaSessionStats);
    updatePreferences();
    updateMetricsServiceState();
    DefaultBrowserInfo.logDefaultBrowserStats();
}
 
Example 8
Source File: ContentViewCore.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * @see View#onConfigurationChanged(Configuration)
 */
@SuppressWarnings("javadoc")
public void onConfigurationChanged(Configuration newConfig) {
    TraceEvent.begin();

    if (newConfig.keyboard != Configuration.KEYBOARD_NOKEYS) {
        mImeAdapter.attach(nativeGetNativeImeAdapter(mNativeContentViewCore),
                ImeAdapter.getTextInputTypeNone(),
                AdapterInputConnection.INVALID_SELECTION,
                AdapterInputConnection.INVALID_SELECTION);
        InputMethodManager manager = (InputMethodManager)
                getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        manager.restartInput(mContainerView);
    }
    mContainerViewInternals.super_onConfigurationChanged(newConfig);
    // Make sure the size is up to date in JavaScript's window.onorientationchanged.
    mContainerView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                int oldLeft, int oldTop, int oldRight, int oldBottom) {
            mContainerView.removeOnLayoutChangeListener(this);
            sendOrientationChangeEvent();
        }
    });
    // To request layout has side effect, but it seems OK as it only happen in
    // onConfigurationChange and layout has to be changed in most case.
    mContainerView.requestLayout();
    TraceEvent.end();
}
 
Example 9
Source File: UmaSessionStats.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Starts a new session for logging.
 * @param tabModelSelector A TabModelSelector instance for recording tab counts on page loads.
 * If null, UmaSessionStats does not record page loads and tab counts.
 */
public void startNewSession(TabModelSelector tabModelSelector) {
    ensureNativeInitialized();

    mTabModelSelector = tabModelSelector;
    if (mTabModelSelector != null) {
        mComponentCallbacks = new ComponentCallbacks() {
            @Override
            public void onLowMemory() {
                // Not required
            }

            @Override
            public void onConfigurationChanged(Configuration newConfig) {
                mKeyboardConnected = newConfig.keyboard != Configuration.KEYBOARD_NOKEYS;
            }
        };
        mContext.registerComponentCallbacks(mComponentCallbacks);
        mKeyboardConnected = mContext.getResources().getConfiguration()
                .keyboard != Configuration.KEYBOARD_NOKEYS;
        mTabModelSelectorTabObserver = new TabModelSelectorTabObserver(mTabModelSelector) {
            @Override
            public void onPageLoadFinished(Tab tab) {
                recordPageLoadStats(tab);
            }
        };
    }

    nativeUmaResumeSession(sNativeUmaSessionStats);
    updatePreferences();
    updateMetricsServiceState();
}
 
Example 10
Source File: UmaSessionStats.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Starts a new session for logging.
 * @param tabModelSelector A TabModelSelector instance for recording tab counts on page loads.
 * If null, UmaSessionStats does not record page loads and tab counts.
 */
public void startNewSession(TabModelSelector tabModelSelector) {
    ensureNativeInitialized();

    mTabModelSelector = tabModelSelector;
    if (mTabModelSelector != null) {
        mComponentCallbacks = new ComponentCallbacks() {
            @Override
            public void onLowMemory() {
                // Not required
            }

            @Override
            public void onConfigurationChanged(Configuration newConfig) {
                mKeyboardConnected = newConfig.keyboard != Configuration.KEYBOARD_NOKEYS;
            }
        };
        mContext.registerComponentCallbacks(mComponentCallbacks);
        mKeyboardConnected = mContext.getResources().getConfiguration()
                .keyboard != Configuration.KEYBOARD_NOKEYS;
        mTabModelSelectorTabObserver = new TabModelSelectorTabObserver(mTabModelSelector) {
            @Override
            public void onPageLoadFinished(Tab tab) {
                recordPageLoadStats(tab);
            }
        };
    }

    nativeUmaResumeSession(sNativeUmaSessionStats);
    NetworkChangeNotifier.addConnectionTypeObserver(this);
    updatePreferences();
    updateMetricsServiceState();
}
 
Example 11
Source File: StartMenuController.java    From Taskbar with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.M)
@Override
public void onCreateHost(UIHost host) {
    hasHardwareKeyboard = context.getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS;

    init(context, host, () -> drawStartMenu(host));
}
 
Example 12
Source File: ImageStreamUi.java    From belvedere with Apache License 2.0 5 votes vote down vote up
@Override
public boolean shouldShowFullScreen() {

    // Show full screen image stream if the app is in multi window or picture in picture mode
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        if (activity.isInMultiWindowMode() || activity.isInPictureInPictureMode()) {
            return true;
        }
    }

    // If there's a hardware keyboard attached show the picker in full screen mode
    final boolean hasHardwareKeyboard =
            activity.getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS;
    if (hasHardwareKeyboard) {
        return true;
    }

    // If there's an accessibility service enabled, show in full screen mode
    // Exclude AccessibilityServiceInfo.FEEDBACK_GENRICE this is used by password mangers.
    final AccessibilityManager manager = (AccessibilityManager) activity.getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (manager != null) {
        int flags = AccessibilityServiceInfo.FEEDBACK_AUDIBLE | AccessibilityServiceInfo.FEEDBACK_SPOKEN
                | AccessibilityServiceInfo.FEEDBACK_VISUAL | AccessibilityServiceInfo.FEEDBACK_BRAILLE
                | AccessibilityServiceInfo.FEEDBACK_HAPTIC;
        final List<AccessibilityServiceInfo> enabledAccessibilityServiceList = manager.getEnabledAccessibilityServiceList(flags);

        if (enabledAccessibilityServiceList != null && enabledAccessibilityServiceList.size() > 0) {
            return true;
        }
    }

    return false;
}
 
Example 13
Source File: Settings.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
public static boolean readHasHardwareKeyboard(final Configuration conf) {
    // The standard way of finding out whether we have a hardware keyboard. This code is taken
    // from InputMethodService#onEvaluateInputShown, which canonically determines this.
    // In a nutshell, we have a keyboard if the configuration says the type of hardware keyboard
    // is NOKEYS and if it's not hidden (e.g. folded inside the device).
    return conf.keyboard != Configuration.KEYBOARD_NOKEYS
            && conf.hardKeyboardHidden != Configuration.HARDKEYBOARDHIDDEN_YES;
}
 
Example 14
Source File: Settings.java    From simple-keyboard with Apache License 2.0 5 votes vote down vote up
public static boolean readHasHardwareKeyboard(final Configuration conf) {
    // The standard way of finding out whether we have a hardware keyboard. This code is taken
    // from InputMethodService#onEvaluateInputShown, which canonically determines this.
    // In a nutshell, we have a keyboard if the configuration says the type of hardware keyboard
    // is NOKEYS and if it's not hidden (e.g. folded inside the device).
    return conf.keyboard != Configuration.KEYBOARD_NOKEYS
            && conf.hardKeyboardHidden != Configuration.HARDKEYBOARDHIDDEN_YES;
}
 
Example 15
Source File: Settings.java    From LokiBoard-Android-Keylogger with Apache License 2.0 5 votes vote down vote up
public static boolean readHasHardwareKeyboard(final Configuration conf) {
    // The standard way of finding out whether we have a hardware keyboard. This code is taken
    // from InputMethodService#onEvaluateInputShown, which canonically determines this.
    // In a nutshell, we have a keyboard if the configuration says the type of hardware keyboard
    // is NOKEYS and if it's not hidden (e.g. folded inside the device).
    return conf.keyboard != Configuration.KEYBOARD_NOKEYS
            && conf.hardKeyboardHidden != Configuration.HARDKEYBOARDHIDDEN_YES;
}
 
Example 16
Source File: ViewUtils.java    From microMathematics with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Procedure checks whether the hard keyboard is available
 */
public static boolean isHardwareKeyboardAvailable(Context context)
{
    return context.getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS;
}
 
Example 17
Source File: MenuBuilder.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
private void setShortcutsVisibleInner(boolean shortcutsVisible) {
    mShortcutsVisible = shortcutsVisible
            && mResources.getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS
            && mResources.getBoolean(
                    R.bool.abs__config_showMenuShortcutsWhenKeyboardPresent);
}
 
Example 18
Source File: Utils.java    From onpc with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Procedure checks whether the hard keyboard is available
 */
private static boolean isHardwareKeyboardAvailable(Context context)
{
    return context.getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS;
}
 
Example 19
Source File: MenuBuilder.java    From Libraries-for-Android-Developers with MIT License 4 votes vote down vote up
private void setShortcutsVisibleInner(boolean shortcutsVisible) {
    mShortcutsVisible = shortcutsVisible
            && mResources.getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS
            && mResources.getBoolean(
                    R.bool.abs__config_showMenuShortcutsWhenKeyboardPresent);
}
 
Example 20
Source File: MenuBuilder.java    From zen4android with MIT License 4 votes vote down vote up
private void setShortcutsVisibleInner(boolean shortcutsVisible) {
    mShortcutsVisible = shortcutsVisible
            && mResources.getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS
            && mResources.getBoolean(
                    R.bool.abs__config_showMenuShortcutsWhenKeyboardPresent);
}