Moved device-specific code into DeviceUtils
This commit is contained in:
parent
e833d415e3
commit
b8a35e9e4a
|
@ -1538,8 +1538,9 @@ public class VideoPlayerImpl extends VideoPlayer
|
|||
&& navBarAtTheBottom ? size.y : ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
controlsRoot.requestLayout();
|
||||
|
||||
final DisplayMetrics metrics = getRootView().getResources().getDisplayMetrics();
|
||||
int topPadding = isFullscreen && !isInMultiWindow() ? getStatusBarHeight() : 0;
|
||||
topPadding = !isLandscape && hasCutout(topPadding) ? 0 : topPadding;
|
||||
topPadding = !isLandscape && DeviceUtils.hasCutout(topPadding, metrics) ? 0 : topPadding;
|
||||
getRootView().findViewById(R.id.playbackWindowRoot).setTranslationY(topPadding);
|
||||
getBottomControlsRoot().setTranslationY(-topPadding);
|
||||
}
|
||||
|
@ -1569,20 +1570,6 @@ public class VideoPlayerImpl extends VideoPlayer
|
|||
return statusBarHeight;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compares current status bar height with default status bar height in Android and decides,
|
||||
* does the device has cutout or not
|
||||
* */
|
||||
private boolean hasCutout(final float statusBarHeight) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
final DisplayMetrics metrics = getRootView().getResources().getDisplayMetrics();
|
||||
final float defaultStatusBarHeight = TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_DIP, 25, metrics);
|
||||
return statusBarHeight > defaultStatusBarHeight;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void setMuteButton(final ImageButton button, final boolean isMuted) {
|
||||
button.setImageDrawable(AppCompatResources.getDrawable(service, isMuted
|
||||
? R.drawable.ic_volume_off_white_24dp : R.drawable.ic_volume_up_white_24dp));
|
||||
|
|
|
@ -6,6 +6,8 @@ import android.content.pm.PackageManager;
|
|||
import android.content.res.Configuration;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -72,4 +74,17 @@ public final class DeviceUtils {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Compares current status bar height with default status bar height in Android and decides,
|
||||
* does the device has cutout or not
|
||||
* */
|
||||
public static boolean hasCutout(final float statusBarHeight, final DisplayMetrics metrics) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
final float defaultStatusBarHeight = TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_DIP, 25, metrics);
|
||||
return statusBarHeight > defaultStatusBarHeight;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue