public static Extents BaseViewPadding = new Extents(0, 0, 20, 20);
public static Extents HeaderPadding = new Extents(16, 16, 8, 8);
public static Extents DetailContentMargin = new Extents(64, 64, 8, 8);
+
+ public static float windowHeightRatio = 540f / 1080;
+ public static float windowWidthRation = 960f / 1920;
}
}
-using Tizen.NUI;
-using Tizen.System;
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+using Tizen.NUI;
namespace Notifications.Common
{
private static int width;
private static int height;
private static Window.WindowOrientation orientation;
- private const string WidthKey = "tizen.org/feature/screen.width";
- private const string HeightKey = "tizen.org/feature/screen.height";
static DeviceInfo()
{
- bool isWidthAvailable = Information.TryGetValue(WidthKey, out width);
- bool isHeightAvailable = Information.TryGetValue(HeightKey, out height);
- if (isHeightAvailable == false || isWidthAvailable == false)
- {
- width = 1280;
- height = 720;
- Tizen.Log.Debug(AppConstants.LogTag, "Width and height are not available , setting default size as 1280 x 720");
- }
+ Size displaySize = NUIApplication.GetScreenSize();
+ width = (int)displaySize.Width;
+ height = (int)displaySize.Height;
+
orientation = Window.Instance.GetCurrentOrientation();
IsPortrait = orientation == Window.WindowOrientation.Portrait || orientation == Window.WindowOrientation.PortraitInverse;
}
using System.Globalization;
using Tizen.NUI;
using Notifications.Common;
+using Notifications.Core;
namespace Notifications
{
};
window.SetAvailableOrientations(list);
- UpdateWindowSize();
- UpdateWindowPosition();
+
+ WindowManager.UpdateWindowPositionSize();
+
window.BackgroundColor = Color.Transparent;
window.OrientationChanged += OnWindowOrientationChanged;
viewManager = new ViewManager();
}
- private void UpdateWindowSize()
- {
- int width, height;
- if (DeviceInfo.IsPortrait)
- {
- width = DeviceInfo.DisplayHeight / 2;
- height = DeviceInfo.DisplayWidth / 2;
- }
- else
- {
- width = DeviceInfo.DisplayWidth / 2;
- height = DeviceInfo.DisplayHeight / 2;
- }
- window.WindowSize = new Size2D(width, height - AppConstants.BorderHeight.SpToPx());
- Tizen.Log.Info(AppConstants.LogTag, "width is: " + window.WindowSize.Width);
- Tizen.Log.Info(AppConstants.LogTag, "height is: " + window.WindowSize.Height);
- }
-
- private void UpdateWindowPosition()
- {
- int positionX = (DeviceInfo.DisplayWidth - window.WindowSize.Width) / 2;
- int positionY = (DeviceInfo.DisplayHeight - window.WindowSize.Height) / 2;
- window.WindowPosition = new Position2D(positionX, positionY);
- Tizen.Log.Info(AppConstants.LogTag, "position X is: " + window.WindowPosition.X);
- Tizen.Log.Info(AppConstants.LogTag, "position Y is: " + window.WindowPosition.Y);
- }
-
private void OnWindowOrientationChanged(object sender, WindowOrientationChangedEventArgs e)
{
Tizen.Log.Debug(AppConstants.LogTag, "orientation changed" + e.WindowOrientation);
- DeviceInfo.UpdateDeviceInfo();
- UpdateWindowSize();
- UpdateWindowPosition();
+
+ WindowManager.UpdateWindowPositionSize();
}
private void SetupLanguage()
--- /dev/null
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+using Notifications.Common;
+using Tizen.NUI;
+
+namespace Notifications.Core
+{
+ public static class WindowManager
+ {
+ private static Window window;
+
+ static WindowManager()
+ {
+ window = Window.Instance;
+ }
+
+ public static void UpdateWindowPositionSize()
+ {
+ DeviceInfo.UpdateDeviceInfo();
+
+ int positionX, positionY;
+ int width, height;
+
+ width = (int)(DeviceInfo.DisplayWidth * AppConstants.windowWidthRation);
+ height = (int)(DeviceInfo.DisplayHeight * AppConstants.windowHeightRatio);
+
+ positionX = ((DeviceInfo.IsPortrait ? DeviceInfo.DisplayHeight : DeviceInfo.DisplayWidth) - width) / 2;
+ positionY = ((DeviceInfo.IsPortrait ? DeviceInfo.DisplayWidth : DeviceInfo.DisplayHeight) - height) / 2;
+
+ if (DeviceInfo.IsPortrait)
+ {
+ (width, height) = (height, width);
+ (positionX, positionY) = (positionY, positionX);
+ }
+
+ window.WindowPositionSize = new Rectangle(positionX, positionY, width, height);
+
+ Tizen.Log.Info(AppConstants.LogTag, "width is: " + window.WindowSize.Width);
+ Tizen.Log.Info(AppConstants.LogTag, "height is: " + window.WindowSize.Height);
+ Tizen.Log.Info(AppConstants.LogTag, "position X is: " + window.WindowPosition.X);
+ Tizen.Log.Info(AppConstants.LogTag, "position Y is: " + window.WindowPosition.Y);
+ }
+ }
+}