fongmi
jhengazuki 1 month ago
parent 9c608396be
commit 4f67bf821e
  1. 2
      app/src/main/java/com/fongmi/android/tv/utils/Util.java
  2. 11
      app/src/mobile/java/com/fongmi/android/tv/ui/custom/CustomKeyDown.java

@ -78,7 +78,7 @@ public class Util {
try {
float value = activity.getWindow().getAttributes().screenBrightness;
if (WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL >= value && value >= WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF) return value;
return Settings.System.getFloat(activity.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS) / 128;
return Settings.System.getFloat(activity.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS) / 255;
} catch (Exception e) {
return 0.5f;
}

@ -66,8 +66,8 @@ public class CustomKeyDown extends GestureDetector.SimpleOnGestureListener imple
public void resetScale() {
if (scale == 1.0f) return;
videoView.animate().scaleX(1.0f).scaleY(1.0f).translationX(0f).translationY(0f).setDuration(250).withEndAction(() -> {
videoView.setPivotY(videoView.getHeight() / 2f);
videoView.setPivotX(videoView.getWidth() / 2f);
videoView.setPivotY(videoView.getHeight() / 2.0f);
videoView.setPivotX(videoView.getWidth() / 2.0f);
scale = 1.0f;
}).start();
}
@ -167,9 +167,8 @@ public class CustomKeyDown extends GestureDetector.SimpleOnGestureListener imple
}
private void setBright(float deltaY) {
if (bright == -1.0f) bright = 0.5f;
int height = videoView.getMeasuredHeight();
float brightness = deltaY * 2 / height + bright;
float brightness = deltaY * 2.0f / height + bright;
if (brightness < 0) brightness = 0f;
if (brightness > 1.0f) brightness = 1.0f;
WindowManager.LayoutParams attributes = activity.getWindow().getAttributes();
@ -181,12 +180,12 @@ public class CustomKeyDown extends GestureDetector.SimpleOnGestureListener imple
private void setVolume(float deltaY) {
int height = videoView.getMeasuredHeight();
int maxVolume = manager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
float deltaV = deltaY * 2 / height * maxVolume;
float deltaV = deltaY * 2.0f / height * maxVolume;
float index = volume + deltaV;
if (index > maxVolume) index = maxVolume;
if (index < 0) index = 0;
manager.setStreamVolume(AudioManager.STREAM_MUSIC, (int) index, 0);
listener.onVolume((int) (index / maxVolume * 100));
listener.onVolume((int) (index / maxVolume * 100.0f));
}
@Override

Loading…
Cancel
Save