fix(target O): floating window cannot be shown

This commit is contained in:
hyb1996
2018-10-06 11:16:27 +08:00
parent 0ff7b1c208
commit 54cbb78d8e
6 changed files with 37 additions and 8 deletions

View File

@@ -80,7 +80,7 @@ public class ConsoleFloaty extends ResizableExpandableFloaty.AbstractResizableEx
}
private void initConsoleTitle(View view) {
mTitleView = (TextView) view.findViewById(R.id.title);
mTitleView = view.findViewById(R.id.title);
if (mTitle != null) {
mTitleView.setText(mTitle);
}
@@ -91,7 +91,7 @@ public class ConsoleFloaty extends ResizableExpandableFloaty.AbstractResizableEx
}
private void setUpConsole(View view, ResizableExpandableFloatyWindow window) {
ConsoleView consoleView = (ConsoleView) view.findViewById(R.id.console);
ConsoleView consoleView = view.findViewById(R.id.console);
consoleView.setConsole(mConsole);
consoleView.setWindow(window);
initConsoleTitle(view);

View File

@@ -66,10 +66,16 @@ public class RawWindow implements FloatyWindow {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
flags |= WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
}
int type;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
} else {
type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
}
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
type,
flags,
PixelFormat.TRANSLUCENT);
layoutParams.gravity = Gravity.TOP | Gravity.START;