Merge pull request #4338 from Isira-Seneviratne/Use_DisplayCutoutCompat
Use DisplayCutoutCompat in VideoPlayerImpl.
This commit is contained in:
commit
dd55ad61f4
|
@ -32,8 +32,6 @@ import android.graphics.PixelFormat;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.view.DisplayCutout;
|
|
||||||
import androidx.preference.PreferenceManager;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -60,8 +58,12 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.content.res.AppCompatResources;
|
import androidx.appcompat.content.res.AppCompatResources;
|
||||||
|
import androidx.core.view.DisplayCutoutCompat;
|
||||||
|
import androidx.core.view.ViewCompat;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||||
import com.google.android.exoplayer2.Player;
|
import com.google.android.exoplayer2.Player;
|
||||||
import com.google.android.exoplayer2.SimpleExoPlayer;
|
import com.google.android.exoplayer2.SimpleExoPlayer;
|
||||||
|
@ -72,6 +74,7 @@ import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
||||||
import com.google.android.exoplayer2.ui.SubtitleView;
|
import com.google.android.exoplayer2.ui.SubtitleView;
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
import com.nostra13.universalimageloader.core.assist.FailReason;
|
import com.nostra13.universalimageloader.core.assist.FailReason;
|
||||||
|
|
||||||
import org.schabi.newpipe.MainActivity;
|
import org.schabi.newpipe.MainActivity;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
|
@ -92,9 +95,9 @@ import org.schabi.newpipe.player.playqueue.PlayQueueItemTouchCallback;
|
||||||
import org.schabi.newpipe.player.resolver.AudioPlaybackResolver;
|
import org.schabi.newpipe.player.resolver.AudioPlaybackResolver;
|
||||||
import org.schabi.newpipe.player.resolver.MediaSourceTag;
|
import org.schabi.newpipe.player.resolver.MediaSourceTag;
|
||||||
import org.schabi.newpipe.player.resolver.VideoPlaybackResolver;
|
import org.schabi.newpipe.player.resolver.VideoPlaybackResolver;
|
||||||
import org.schabi.newpipe.util.DeviceUtils;
|
|
||||||
import org.schabi.newpipe.util.AnimationUtils;
|
import org.schabi.newpipe.util.AnimationUtils;
|
||||||
import org.schabi.newpipe.util.Constants;
|
import org.schabi.newpipe.util.Constants;
|
||||||
|
import org.schabi.newpipe.util.DeviceUtils;
|
||||||
import org.schabi.newpipe.util.KoreUtil;
|
import org.schabi.newpipe.util.KoreUtil;
|
||||||
import org.schabi.newpipe.util.ListHelper;
|
import org.schabi.newpipe.util.ListHelper;
|
||||||
import org.schabi.newpipe.util.NavigationHelper;
|
import org.schabi.newpipe.util.NavigationHelper;
|
||||||
|
@ -475,16 +478,14 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
settingsContentObserver);
|
settingsContentObserver);
|
||||||
getRootView().addOnLayoutChangeListener(this);
|
getRootView().addOnLayoutChangeListener(this);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
ViewCompat.setOnApplyWindowInsetsListener(queueLayout, (view, windowInsets) -> {
|
||||||
queueLayout.setOnApplyWindowInsetsListener((view, windowInsets) -> {
|
final DisplayCutoutCompat cutout = windowInsets.getDisplayCutout();
|
||||||
final DisplayCutout cutout = windowInsets.getDisplayCutout();
|
if (cutout != null) {
|
||||||
if (cutout != null) {
|
view.setPadding(cutout.getSafeInsetLeft(), cutout.getSafeInsetTop(),
|
||||||
view.setPadding(cutout.getSafeInsetLeft(), cutout.getSafeInsetTop(),
|
cutout.getSafeInsetRight(), cutout.getSafeInsetBottom());
|
||||||
cutout.getSafeInsetRight(), cutout.getSafeInsetBottom());
|
}
|
||||||
}
|
return windowInsets;
|
||||||
return windowInsets;
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// PlaybackControlRoot already consumed window insets but we should pass them to
|
// PlaybackControlRoot already consumed window insets but we should pass them to
|
||||||
// player_overlays too. Without it they will be off-centered
|
// player_overlays too. Without it they will be off-centered
|
||||||
|
|
Loading…
Reference in New Issue