Support display cutout

Fixes #2682
This commit is contained in:
Marcel Dopita 2020-01-18 14:37:42 +01:00 committed by TobiGr
parent ec684434dc
commit 91aa65e717
4 changed files with 27 additions and 1 deletions

View file

@ -61,7 +61,8 @@
android:name=".player.MainVideoPlayer"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTask"/>
android:launchMode="singleTask"
android:theme="@style/VideoPlayerTheme"/>
<activity
android:name=".settings.SettingsActivity"

View file

@ -45,9 +45,11 @@ import androidx.recyclerview.widget.ItemTouchHelper;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.DisplayCutout;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageButton;
@ -550,6 +552,19 @@ public final class MainVideoPlayer extends AppCompatActivity
setInitialGestureValues();
}
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
queueLayout.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@Override
public WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) {
final DisplayCutout cutout = windowInsets.getDisplayCutout();
if (cutout != null)
view.setPadding(cutout.getSafeInsetLeft(), cutout.getSafeInsetTop(),
cutout.getSafeInsetRight(), cutout.getSafeInsetBottom());
return windowInsets;
}
});
}
}
public void minimize() {

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="VideoPlayerTheme">
<item name="android:windowLayoutInDisplayCutoutMode">
shortEdges
</item>
</style>
</resources>

View file

@ -247,4 +247,6 @@
<style name="NavViewTextStyle">
<item name="android:ellipsize">end</item>
</style>
<style name="VideoPlayerTheme" />
</resources>