From 6c04339c5aadb5118b0e0a8178b3d569956bbad7 Mon Sep 17 00:00:00 2001 From: Seigo Nonaka Date: Mon, 7 Dec 2015 19:03:50 -0800 Subject: [PATCH] Change NavigationBar invisible if the input view is not shown. The opaque navigation bar guard view does not make much sense when the IME does not show software keyboard at all. LatinIME does not show any UI when the hardware keyboard is connected. With Iea77915ecc55eedaf19899e72c44f704ba9d852c, input method can change the navigation bar visibility. This CL changes navigation bar invisible when the hardware keyboard is connected. Bug:22564251 Change-Id: I14d9490e00caa852035a05830e76114cbe6af8f2 --- .../src/com/android/inputmethod/latin/LatinIME.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 25a5de250..f3cf6cde2 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -30,6 +30,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.res.Configuration; import android.content.res.Resources; +import android.graphics.Color; import android.inputmethodservice.InputMethodService; import android.media.AudioManager; import android.os.Debug; @@ -967,6 +968,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (TRACE) Debug.startMethodTracing("/data/trace/latinime"); } + @Override + public void onWindowShown() { + super.onWindowShown(); + setNavigationBarVisibility(isInputViewShown()); + } + @Override public void onWindowHidden() { super.onWindowHidden(); @@ -974,6 +981,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (mainKeyboardView != null) { mainKeyboardView.closing(); } + setNavigationBarVisibility(false); } void onFinishInputInternal() { @@ -1865,4 +1873,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } return mRichImm.shouldOfferSwitchingToNextInputMethod(token, fallbackValue); } + + private void setNavigationBarVisibility(final boolean visible) { + // Color.BLACK is ignored and default IME navigation bar color is used. + getWindow().getWindow().setNavigationBarColor(visible ? Color.BLACK : Color.TRANSPARENT); + } }