Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(630)

Unified Diff: remoting/android/java/src/org/chromium/chromoting/Desktop.java

Issue 2391993004: [Remoting Android] Hide soft keyboard button when physical keyboard is connected (Closed)
Patch Set: Only hide the button for QWERTY keyboard Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | remoting/android/java/src/org/chromium/chromoting/DesktopView.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/android/java/src/org/chromium/chromoting/Desktop.java
diff --git a/remoting/android/java/src/org/chromium/chromoting/Desktop.java b/remoting/android/java/src/org/chromium/chromoting/Desktop.java
index c115749677ffb9dab8db7ecd28567fc8e5b79200..e2070d62c9112b7788efe197a2595de81adcc082 100644
--- a/remoting/android/java/src/org/chromium/chromoting/Desktop.java
+++ b/remoting/android/java/src/org/chromium/chromoting/Desktop.java
@@ -5,6 +5,7 @@
package org.chromium.chromoting;
import android.annotation.SuppressLint;
+import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
@@ -23,6 +24,7 @@ import android.view.inputmethod.InputMethodManager;
import org.chromium.chromoting.help.HelpContext;
import org.chromium.chromoting.help.HelpSingleton;
import org.chromium.chromoting.jni.Client;
+import org.chromium.ui.UiUtils;
import java.util.List;
@@ -78,6 +80,14 @@ public class Desktop
private DesktopView mRemoteHostDesktop;
+ /**
+ * Indicates whether the device is connected to a non-hidden physical qwerty keyboard. This is
+ * set by {@link Desktop#setKeyboardState(Configuration)}. DO NOT request a soft keyboard when a
+ * physical keyboard exists, otherwise the activity will enter an undefined state where the soft
+ * keyboard never shows up meanwhile request to hide status bar always fails.
+ */
+ private boolean mHasPhysicalKeyboard;
+
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -222,9 +232,24 @@ public class Desktop
// Wait to set the input mode until after the default tinting has been applied.
setInputMode(mInputMode);
+ // Keyboard state must be set after the keyboard icon has been added to the menu.
+ setKeyboardState(getResources().getConfiguration());
+
return super.onCreateOptionsMenu(menu);
}
+ @Override
+ public void onConfigurationChanged(Configuration config) {
+ super.onConfigurationChanged(config);
+ setKeyboardState(config);
+ }
+
+ private void setKeyboardState(Configuration configuration) {
+ mHasPhysicalKeyboard = (configuration.keyboard == Configuration.KEYBOARD_QWERTY)
+ && (configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO);
+ mToolbar.getMenu().findItem(R.id.actionbar_keyboard).setVisible(!mHasPhysicalKeyboard);
+ }
+
public Event<SystemUiVisibilityChangedEventParameter> onSystemUiVisibilityChanged() {
return mOnSystemUiVisibilityChanged;
}
@@ -384,6 +409,15 @@ public class Desktop
return flags;
}
+ /**
+ * Shows the soft keyboard if no physical keyboard is attached.
+ */
+ public void showKeyboard() {
+ if (!mHasPhysicalKeyboard) {
+ UiUtils.showKeyboard(mRemoteHostDesktop);
+ }
+ }
+
public void showSystemUi() {
// Request exit from any fullscreen mode. The action-bar controls will be shown in response
// to the SystemUiVisibility notification. The visibility of the action-bar should be tied
« no previous file with comments | « no previous file | remoting/android/java/src/org/chromium/chromoting/DesktopView.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698