forked from joejulian/gio
app: use tabs consistently in GioView.java
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+80
-80
@@ -143,92 +143,92 @@ public final class GioView extends SurfaceView {
|
|||||||
setPointerIcon(pointerIcon);
|
setPointerIcon(pointerIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setOrientation(int id, int fallback) {
|
private void setOrientation(int id, int fallback) {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||||
id = fallback;
|
id = fallback;
|
||||||
}
|
}
|
||||||
((Activity) this.getContext()).setRequestedOrientation(id);
|
((Activity) this.getContext()).setRequestedOrientation(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFullscreen(boolean enabled) {
|
private void setFullscreen(boolean enabled) {
|
||||||
int flags = this.getSystemUiVisibility();
|
int flags = this.getSystemUiVisibility();
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
flags |= SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
flags |= SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
||||||
flags |= SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
flags |= SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
||||||
flags |= SYSTEM_UI_FLAG_FULLSCREEN;
|
flags |= SYSTEM_UI_FLAG_FULLSCREEN;
|
||||||
flags |= SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
|
flags |= SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
|
||||||
} else {
|
} else {
|
||||||
flags &= ~SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
flags &= ~SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
||||||
flags &= ~SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
flags &= ~SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
||||||
flags &= ~SYSTEM_UI_FLAG_FULLSCREEN;
|
flags &= ~SYSTEM_UI_FLAG_FULLSCREEN;
|
||||||
flags &= ~SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
|
flags &= ~SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
|
||||||
}
|
}
|
||||||
this.setSystemUiVisibility(flags);
|
this.setSystemUiVisibility(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum Bar {
|
private enum Bar {
|
||||||
NAVIGATION,
|
NAVIGATION,
|
||||||
STATUS,
|
STATUS,
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBarColor(Bar t, int color, int luminance) {
|
private void setBarColor(Bar t, int color, int luminance) {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Window window = ((Activity) this.getContext()).getWindow();
|
Window window = ((Activity) this.getContext()).getWindow();
|
||||||
|
|
||||||
int insetsMask;
|
int insetsMask;
|
||||||
int viewMask;
|
int viewMask;
|
||||||
|
|
||||||
switch (t) {
|
switch (t) {
|
||||||
case STATUS:
|
case STATUS:
|
||||||
insetsMask = WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
|
insetsMask = WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
|
||||||
viewMask = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
|
viewMask = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
|
||||||
window.setStatusBarColor(color);
|
window.setStatusBarColor(color);
|
||||||
break;
|
break;
|
||||||
case NAVIGATION:
|
case NAVIGATION:
|
||||||
insetsMask = WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;
|
insetsMask = WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;
|
||||||
viewMask = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
|
viewMask = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
|
||||||
window.setNavigationBarColor(color);
|
window.setNavigationBarColor(color);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("invalid bar type");
|
throw new RuntimeException("invalid bar type");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
|
||||||
int flags = this.getSystemUiVisibility();
|
int flags = this.getSystemUiVisibility();
|
||||||
if (luminance > 128) {
|
if (luminance > 128) {
|
||||||
flags |= viewMask;
|
flags |= viewMask;
|
||||||
} else {
|
} else {
|
||||||
flags &= ~viewMask;
|
flags &= ~viewMask;
|
||||||
}
|
}
|
||||||
this.setSystemUiVisibility(flags);
|
this.setSystemUiVisibility(flags);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowInsetsController insetsController = window.getInsetsController();
|
WindowInsetsController insetsController = window.getInsetsController();
|
||||||
if (insetsController == null) {
|
if (insetsController == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (luminance > 128) {
|
if (luminance > 128) {
|
||||||
insetsController.setSystemBarsAppearance(insetsMask, insetsMask);
|
insetsController.setSystemBarsAppearance(insetsMask, insetsMask);
|
||||||
} else {
|
} else {
|
||||||
insetsController.setSystemBarsAppearance(0, insetsMask);
|
insetsController.setSystemBarsAppearance(0, insetsMask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setStatusColor(int color, int luminance) {
|
private void setStatusColor(int color, int luminance) {
|
||||||
this.setBarColor(Bar.STATUS, color, luminance);
|
this.setBarColor(Bar.STATUS, color, luminance);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setNavigationColor(int color, int luminance) {
|
private void setNavigationColor(int color, int luminance) {
|
||||||
this.setBarColor(Bar.NAVIGATION, color, luminance);
|
this.setBarColor(Bar.NAVIGATION, color, luminance);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dispatchMotionEvent(MotionEvent event) {
|
private void dispatchMotionEvent(MotionEvent event) {
|
||||||
if (nhandle == 0) {
|
if (nhandle == 0) {
|
||||||
@@ -277,11 +277,11 @@ public final class GioView extends SurfaceView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setInputHint(int hint) {
|
void setInputHint(int hint) {
|
||||||
if (hint == this.keyboardHint) {
|
if (hint == this.keyboardHint) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.keyboardHint = hint;
|
this.keyboardHint = hint;
|
||||||
imm.restartInput(this);
|
imm.restartInput(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showTextInput() {
|
void showTextInput() {
|
||||||
|
|||||||
Reference in New Issue
Block a user