Chromium Code Reviews| 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..fe0f06883b3c322ee86923acb0158f5c0adb699b 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,8 @@ public class Desktop |
| private DesktopView mRemoteHostDesktop; |
| + private boolean mHasPhysicalKeyboard; |
|
joedow
2016/10/05 22:50:59
Can you add a comment on how you detect a physical
Yuwei
2016/10/06 00:26:50
Done.
|
| + |
| /** Called when the activity is first created. */ |
| @Override |
| public void onCreate(Bundle savedInstanceState) { |
| @@ -222,9 +226,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 options menu is created since it needs to alter the |
| + // visibility of the keyboard button. |
|
joedow
2016/10/05 22:50:59
Shorten this to one line if possible:
"Keyboard st
Yuwei
2016/10/06 00:26:50
Done.
|
| + setKeyboardState(getResources().getConfiguration().keyboard); |
| + |
| return super.onCreateOptionsMenu(menu); |
| } |
| + @Override |
| + public void onConfigurationChanged(Configuration config) { |
| + super.onConfigurationChanged(config); |
| + setKeyboardState(config.keyboard); |
| + } |
| + |
| + private void setKeyboardState(int keyboardState) { |
| + mHasPhysicalKeyboard = (keyboardState & Configuration.KEYBOARD_NOKEYS) == 0; |
|
Yuwei
2016/10/06 00:26:50
Oops. Looks like keyboardState is just an integer
|
| + mToolbar.getMenu().findItem(R.id.actionbar_keyboard).setVisible(!mHasPhysicalKeyboard); |
| + } |
| + |
| public Event<SystemUiVisibilityChangedEventParameter> onSystemUiVisibilityChanged() { |
| return mOnSystemUiVisibilityChanged; |
| } |
| @@ -384,6 +403,16 @@ public class Desktop |
| return flags; |
| } |
| + /** |
| + * Shows the soft keyboard on the remote desktop view. Do nothing if a physical keyboard is |
| + * present. |
|
joedow
2016/10/05 22:50:59
nit: Shorten to one line if possible...
Yuwei
2016/10/06 00:26:50
Done.
|
| + */ |
| + 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 |