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
main
Seigo Nonaka 2015-12-07 19:03:50 -08:00
parent 5765a98b59
commit 6c04339c5a
1 changed files with 13 additions and 0 deletions

View File

@ -30,6 +30,7 @@ import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Color;
import android.inputmethodservice.InputMethodService; import android.inputmethodservice.InputMethodService;
import android.media.AudioManager; import android.media.AudioManager;
import android.os.Debug; import android.os.Debug;
@ -967,6 +968,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (TRACE) Debug.startMethodTracing("/data/trace/latinime"); if (TRACE) Debug.startMethodTracing("/data/trace/latinime");
} }
@Override
public void onWindowShown() {
super.onWindowShown();
setNavigationBarVisibility(isInputViewShown());
}
@Override @Override
public void onWindowHidden() { public void onWindowHidden() {
super.onWindowHidden(); super.onWindowHidden();
@ -974,6 +981,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (mainKeyboardView != null) { if (mainKeyboardView != null) {
mainKeyboardView.closing(); mainKeyboardView.closing();
} }
setNavigationBarVisibility(false);
} }
void onFinishInputInternal() { void onFinishInputInternal() {
@ -1865,4 +1873,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
} }
return mRichImm.shouldOfferSwitchingToNextInputMethod(token, fallbackValue); 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);
}
} }