1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 16:40:32 +00:00

Merge pull request #2967 from moneytoo/cutout

Support display cutout
This commit is contained in:
Tobias Groza 2020-02-26 20:05:57 +01:00 committed by GitHub
commit ab4e1819c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 1 deletions

View File

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

View File

@ -45,9 +45,11 @@ import androidx.recyclerview.widget.ItemTouchHelper;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.DisplayCutout;
import android.view.GestureDetector; import android.view.GestureDetector;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.WindowInsets;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageButton; import android.widget.ImageButton;
@ -550,6 +552,19 @@ public final class MainVideoPlayer extends AppCompatActivity
setInitialGestureValues(); 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() { 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"> <style name="NavViewTextStyle">
<item name="android:ellipsize">end</item> <item name="android:ellipsize">end</item>
</style> </style>
<style name="VideoPlayerTheme" />
</resources> </resources>