Making blurred background of the queue work with law width drawables.

This commit is contained in:
Anonymus Raccoon
2019-07-01 18:27:57 +02:00
parent 0edf2eb491
commit 6dbe180b0b
2 changed files with 15 additions and 8 deletions

View File

@@ -43,7 +43,7 @@ using TransportType = Android.Net.TransportType;
namespace Opus
{
[Activity(Label = "Opus", MainLauncher = true, Icon = "@drawable/Icon", Theme = "@style/SplashScreen", ScreenOrientation = ScreenOrientation.Portrait, LaunchMode = LaunchMode.SingleTask)]
[Activity(Label = "Opus", MainLauncher = true, Icon = "@drawable/Icon", Theme = "@style/SplashScreen", ScreenOrientation = ScreenOrientation.Portrait, LaunchMode = LaunchMode.SingleTask, ResizeableActivity = true)]
[IntentFilter(new[] {Intent.ActionSend }, Categories = new[] { Intent.CategoryDefault }, DataHost = "www.youtube.com", DataMimeType = "text/*")]
[IntentFilter(new[] {Intent.ActionSend }, Categories = new[] { Intent.CategoryDefault }, DataHost = "m.youtube.com", DataMimeType = "text/plain")]
[IntentFilter(new[] { Intent.ActionView }, Categories = new[] { Intent.CategoryDefault }, DataMimeTypes = new[] { "audio/*", "application/ogg", "application/x-ogg", "application/itunes" })]
@@ -556,7 +556,7 @@ namespace Opus
{
FindViewById<NestedScrollView>(Resource.Id.playerSheet).Visibility = ViewStates.Visible;
FindViewById<NestedScrollView>(Resource.Id.playerSheet).TranslationY = 0;
FindViewById<BottomNavigationView>(Resource.Id.bottomView).TranslationY = (int)(56 * Resources.DisplayMetrics.Density + 0.5f);
FindViewById<BottomNavigationView>(Resource.Id.bottomView).TranslationY = DpToPx(56);
FindViewById(Resource.Id.playerContainer).Alpha = 1;
FindViewById(Resource.Id.smallPlayer).Alpha = 0;
SheetBehavior.State = BottomSheetBehavior.StateExpanded;

View File

@@ -196,13 +196,20 @@ namespace Opus
{
try
{
//The width of the view in pixel (we'll multiply this by 0.75f because the drawer has a width of 75%)
int width = (int)(albumArt.Width * (float)drawable.Height / albumArt.Height);
//k is the coeficient to convert ImageView's size to Bitmap's size
//We want to take the lower coeficient because if we take the higher, we will have a final bitmap larger than the initial one and we can't create pixels
float k = Math.Min((float)drawable.Height / albumArt.Height, (float)drawable.Width / albumArt.Width);
int width = (int)(albumArt.Width * k);
int height = (int)(albumArt.Height * k);
int dX = (int)((drawable.Width - width) * 0.5f);
int dY = (int)((drawable.Height - height) * 0.5f);
Console.WriteLine("&Drawable Info: Width: " + drawable.Width + " Height: " + drawable.Height);
Console.WriteLine("&AlbumArt Info: Width: " + albumArt.Width + " Height: " + albumArt.Height);
Console.WriteLine("&Blur Creation: Width: " + width + " dX: " + dX);
Bitmap blured = Bitmap.CreateBitmap(drawable, dX, 0, (int)(width * 0.75f), drawable.Height);
Console.WriteLine("&Blur Creation: Width: " + width + " Height: " + height + " dX: " + dX + " dY: " + dY);
//The width of the view in pixel (we'll multiply this by 0.75f because the drawer has a width of 75%)
Bitmap blured = Bitmap.CreateBitmap(drawable, dX, dY, (int)(width * 0.75f), height);
Console.WriteLine("&BLured bitmap created");
RenderScript rs = RenderScript.Create(MainActivity.instance);
@@ -225,8 +232,8 @@ namespace Opus
if (bar != null)
{
if(spBar == null)
spBar = Activity.FindViewById<ProgressBar>(Resource.Id.spProgress);
if (spBar == null)
spBar = MainActivity.instance.FindViewById<ProgressBar>(Resource.Id.spProgress);
if (current.IsLiveStream)
{