mirror of
https://github.com/TeamNewPipe/NewPipe.git
synced 2024-11-22 02:53:09 +01:00
Crop the notification thumbnail in 1:1 mode instead of stretching it (#8533)
Change square bitmap transformation strategy: change the bitmap transformation strategy when a 1:1 aspect ratio is enabled to not stretch the bitmap but rather crop it. On Android 11/12, the way the whole thumbnail was used for the notification icon was not ideal, however the setting to toggle a 1:1 (as it states in settings) resulted in distortions. Fix this by simply cropping the bitmap. Also update the 1:1 mode strings to remove mentions of scaling or distortions, as those no longer apply.
This commit is contained in:
parent
93b913e14d
commit
6f7298b9db
@ -6,7 +6,6 @@ import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Matrix;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
@ -366,16 +365,13 @@ public final class NotificationUtil {
|
||||
}
|
||||
|
||||
private Bitmap getBitmapWithSquareAspectRatio(final Bitmap bitmap) {
|
||||
return getResizedBitmap(bitmap, bitmap.getWidth(), bitmap.getWidth());
|
||||
}
|
||||
|
||||
private Bitmap getResizedBitmap(final Bitmap bitmap, final int newWidth, final int newHeight) {
|
||||
final int width = bitmap.getWidth();
|
||||
final int height = bitmap.getHeight();
|
||||
final float scaleWidth = ((float) newWidth) / width;
|
||||
final float scaleHeight = ((float) newHeight) / height;
|
||||
final Matrix matrix = new Matrix();
|
||||
matrix.postScale(scaleWidth, scaleHeight);
|
||||
return Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, false);
|
||||
// Find the smaller dimension and then take a center portion of the image that
|
||||
// has that size.
|
||||
final int w = bitmap.getWidth();
|
||||
final int h = bitmap.getHeight();
|
||||
final int dstSize = Math.min(w, h);
|
||||
final int x = (w - dstSize) / 2;
|
||||
final int y = (h - dstSize) / 2;
|
||||
return Bitmap.createBitmap(bitmap, x, y, dstSize, dstSize);
|
||||
}
|
||||
}
|
||||
|
@ -50,8 +50,8 @@
|
||||
<string name="show_play_with_kodi_title">Show \"Play with Kodi\" option</string>
|
||||
<string name="show_play_with_kodi_summary">Display an option to play a video via Kodi media center</string>
|
||||
<string name="crash_the_player">Crash the player</string>
|
||||
<string name="notification_scale_to_square_image_title">Scale thumbnail to 1:1 aspect ratio</string>
|
||||
<string name="notification_scale_to_square_image_summary">Scale the video thumbnail shown in the notification from 16:9 to 1:1 aspect ratio (may introduce distortions)</string>
|
||||
<string name="notification_scale_to_square_image_title">Crop thumbnail to 1:1 aspect ratio</string>
|
||||
<string name="notification_scale_to_square_image_summary">Crop the video thumbnail shown in the notification from 16:9 to 1:1 aspect ratio</string>
|
||||
<string name="notification_action_0_title">First action button</string>
|
||||
<string name="notification_action_1_title">Second action button</string>
|
||||
<string name="notification_action_2_title">Third action button</string>
|
||||
|
Loading…
Reference in New Issue
Block a user