From c29863fa2f0f6d1a53b139b2660198edcecb9db6 Mon Sep 17 00:00:00 2001 From: Sergey Solovyev Date: Wed, 21 Nov 2012 17:28:29 +0400 Subject: [PATCH] Calculator Overlay --- .../android/calculator/overlay/CalculatorOverlayService.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/overlay/CalculatorOverlayService.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/overlay/CalculatorOverlayService.java index 7a611ca5..bf12d73d 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/overlay/CalculatorOverlayService.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/overlay/CalculatorOverlayService.java @@ -46,6 +46,7 @@ public class CalculatorOverlayService extends Service implements ExternalCalcula @Override public void onCreate() { super.onCreate(); + final WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE); final LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); @@ -72,8 +73,8 @@ public class CalculatorOverlayService extends Service implements ExternalCalcula final WindowManager.LayoutParams params = new WindowManager.LayoutParams( - 300, - 450, + Math.max(wm.getDefaultDisplay().getWidth() / 2, 300), + Math.max(wm.getDefaultDisplay().getHeight() / 2, 450), WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL|WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, PixelFormat.TRANSLUCENT);