diff --git a/Opus/Code/MainActivity.cs b/Opus/Code/MainActivity.cs index de5e8b0..26cc60b 100644 --- a/Opus/Code/MainActivity.cs +++ b/Opus/Code/MainActivity.cs @@ -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(Resource.Id.playerSheet).Visibility = ViewStates.Visible; FindViewById(Resource.Id.playerSheet).TranslationY = 0; - FindViewById(Resource.Id.bottomView).TranslationY = (int)(56 * Resources.DisplayMetrics.Density + 0.5f); + FindViewById(Resource.Id.bottomView).TranslationY = DpToPx(56); FindViewById(Resource.Id.playerContainer).Alpha = 1; FindViewById(Resource.Id.smallPlayer).Alpha = 0; SheetBehavior.State = BottomSheetBehavior.StateExpanded; diff --git a/Opus/Code/UI/Views/Player.cs b/Opus/Code/UI/Views/Player.cs index 5d91ad7..b13f41b 100644 --- a/Opus/Code/UI/Views/Player.cs +++ b/Opus/Code/UI/Views/Player.cs @@ -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(Resource.Id.spProgress); + if (spBar == null) + spBar = MainActivity.instance.FindViewById(Resource.Id.spProgress); if (current.IsLiveStream) {