下面列出了android.content.res.Configuration#HARDKEYBOARDHIDDEN_YES 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void refreshImeWindowVisibilityLocked() {
final Configuration conf = mRes.getConfiguration();
final boolean haveHardKeyboard = conf.keyboard
!= Configuration.KEYBOARD_NOKEYS;
final boolean hardKeyShown = haveHardKeyboard
&& conf.hardKeyboardHidden
!= Configuration.HARDKEYBOARDHIDDEN_YES;
final boolean isScreenLocked = isKeyguardLocked();
final boolean inputActive = !isScreenLocked && (mInputShown || hardKeyShown);
// We assume the softkeyboard is shown when the input is active as long as the
// hard keyboard is not shown.
final boolean inputVisible = inputActive && !hardKeyShown;
mImeWindowVis = (inputActive ? InputMethodService.IME_ACTIVE : 0)
| (inputVisible ? InputMethodService.IME_VISIBLE : 0);
updateImeWindowStatusLocked();
}
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;
}
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
this.configuration = newConfig;
try {
if (this.prefs.getBoolean("forceKeyboard", false)
|| (this.configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES)
|| (this.configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_UNDEFINED)) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null)
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,
InputMethodManager.HIDE_NOT_ALWAYS);
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void onPause() {
super.onPause();
try {
if ((puz != null) && (baseFile != null)) {
if ((timer != null) && (puz.getPercentComplete() != 100)) {
this.timer.stop();
puz.setTime(timer.getElapsed());
this.timer = null;
}
IO.save(puz, baseFile);
}
} catch (IOException ioe) {
ioe.printStackTrace();
}
if (this.prefs.getBoolean("forceKeyboard", false)
|| (this.configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES)
|| (this.configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_UNDEFINED)) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(this.imageView.getWindowToken(), 0);
}
}
private void render() {
if (this.prefs.getBoolean("forceKeyboard", false)
|| (this.configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES)
|| (this.configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_UNDEFINED)) {
if (this.useNativeKeyboard) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,
InputMethodManager.HIDE_IMPLICIT_ONLY);
} else {
this.keyboardView.setVisibility(View.VISIBLE);
}
} else {
this.keyboardView.setVisibility(View.GONE);
}
this.imageView.setBitmap(renderer.drawWord());
}
@Override
protected void onPause() {
try {
if ((puz != null) && (baseFile != null)) {
if ((puz.getPercentComplete() != 100) && (this.timer != null)) {
this.timer.stop();
puz.setTime(timer.getElapsed());
this.timer = null;
}
IO.save(puz, baseFile);
}
} catch (IOException ioe) {
LOG.log(Level.SEVERE, null, ioe);
}
this.timer = null;
if ((this.configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES)
|| (this.configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_UNDEFINED)) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(clue.getWindowToken(), 0);
}
super.onPause();
}
/**
* 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;
}
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;
}
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;
}
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;
}
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;
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
this.configuration = newConfig;
if (this.prefs.getBoolean("forceKeyboard", false)
|| (this.configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES)
|| (this.configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_UNDEFINED)) {
if (this.useNativeKeyboard) {
keyboardView.setVisibility(View.GONE);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,
InputMethodManager.HIDE_NOT_ALWAYS);
} else {
this.keyboardView.setVisibility(View.VISIBLE);
}
} else {
this.keyboardView.setVisibility(View.GONE);
}
this.runTimer = prefs.getBoolean("runTimer", false);
if (runTimer) {
this.handler.post(this.updateTimeTask);
}
metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
this.screenWidthInInches = (metrics.widthPixels > metrics.heightPixels ? metrics.widthPixels : metrics.heightPixels) / Math.round(160 * metrics.density);
LOG.info("Configuration Changed "+this.screenWidthInInches+" ");
if(this.screenWidthInInches >= 7){
this.handler.post(this.fitToScreenTask);
}
}
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;
}