Modify Font size calculation
authorcskim <charles0.kim@samsung.com>
Tue, 11 Apr 2017 12:22:49 +0000 (21:22 +0900)
committerChulSeung Kim <charles0.kim@samsung.com>
Thu, 8 Jun 2017 09:34:52 +0000 (18:34 +0900)
Change-Id: Iab7677b7894409875036c8dca7342a0d9f4f86cb
Signed-off-by: cskim <charles0.kim@samsung.com>
LibTVRefCommonPortable/LibTVRefCommonPortable.csproj
LibTVRefCommonPortable/Models/AppShortcutController.cs
LibTVRefCommonPortable/Utils/AppShortcutStorage.cs
LibTVRefCommonPortable/Utils/ISystemSettings.cs [new file with mode: 0644]
LibTVRefCommonPortable/Utils/SizeUtils.cs
LibTVRefCommonTizen/LibTVRefCommonTizen.csproj
LibTVRefCommonTizen/Ports/SystemSettingsPort.cs [new file with mode: 0644]
TVApps/TVApps.TizenTV/TVApps.TizenTV.cs
TVApps/TVApps/TVApps.cs
TVHome/TVHome.TizenTV/TVHome.TizenTV.cs
TVHome/TVHome/TVHome.cs

index c8af293a871c9ca70fff88d9513ccbf0579ee66e..ff74f8d60c7a8e87d968abaed04c81663cfd5da8 100755 (executable)
@@ -53,6 +53,7 @@
     <Compile Include="Utils\AppControlUtils.cs" />
     <Compile Include="Utils\ApplicationManagerUtils.cs" />
     <Compile Include="Utils\AppShortcutStorage.cs" />
+    <Compile Include="Utils\ISystemSettings.cs" />
     <Compile Include="Utils\SizeUtils.cs" />
     <Compile Include="Utils\DateUtils.cs" />
     <Compile Include="Utils\DebuggingUtils.cs" />
index e0a38fffcc2efaa80babe54e9a0e62476696666e..b5360029dc0be9f094075fa72ef5182e90679658 100755 (executable)
@@ -110,7 +110,7 @@ namespace LibTVRefCommonPortable.Models
                 IconPath = "ic_tizen_home_list_mediahub_normal.png",
                 Action = new AppControlAction
                 {
-                    AppID = "org.tizen.mediahub",
+                    AppID = "org.tizen.xamediahub",
                 }
             };
 
index 010f33d6648d8fc5a249f0de977fc3b220949bf1..94157ee389cef834f5ba636027338c0e7c491b0c 100644 (file)
@@ -77,16 +77,6 @@ namespace LibTVRefCommonPortable.Utils
                 AppID = "org.tizen.settings",
             });
 
-            pinnedAppsInfo.Add(new AppShortcutInfo()
-            {
-                AppID = "org.tizen.dpm-toolkit",
-            });
-
-            pinnedAppsInfo.Add(new AppShortcutInfo()
-            {
-                AppID = "org.tizen.mediahub",
-            });
-
             pinnedAppsInfo.Add(new AppShortcutInfo()
             {
                 AppID = "org.tizen.apps",
diff --git a/LibTVRefCommonPortable/Utils/ISystemSettings.cs b/LibTVRefCommonPortable/Utils/ISystemSettings.cs
new file mode 100644 (file)
index 0000000..f2c26c1
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * 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.
+ */
+
+namespace LibTVRefCommonPortable.Utils
+{
+    public interface ISystemSettings
+    {
+        bool GetSystemModelName(out string modelName);
+    }
+}
index 408433192078ba73449a35800d9eccc21644e937..daa4d6da418638fd4729cdbe0cfb0b25afe8d281 100644 (file)
@@ -66,11 +66,56 @@ namespace LibTVRefCommonPortable.Utils
         /// </summary>
         public static int ScreenWidth { set; get; }
 
+        /// <summary>
+        /// Device DPI
+        /// </summary>
+        public static double Dpi { set; get; }
+
         /// <summary>
         /// Font Scale ratio
         /// </summary>
         public static double ScaleRatio { set; get; }
 
+        /// <summary>
+        /// Platform Model enumerations
+        /// </summary>
+        private enum PlatformModel
+        {
+            TV,
+            Emulator,
+            Other,
+        }
+
+        /// <summary>
+        /// Platform Model Name
+        /// </summary>
+        private static PlatformModel ModelName = PlatformModel.TV;
+
+        /// <summary>
+        /// Set model name of running device.
+        /// </summary>
+        /// <param name="modelName">a model name</param>
+        public static void SetModelName(string modelName)
+        {
+            if (modelName == null)
+            {
+                return;
+            }
+
+            DebuggingUtils.Dbg("ModelName is " + modelName);
+            switch (modelName.ToLower()[0])
+            {
+                case 'e':
+                    ModelName = PlatformModel.Emulator;
+                    break;
+
+                default:
+                case 'x':
+                    ModelName = PlatformModel.Other;
+                    break;
+            }
+        }
+
         /// <summary>
         /// A method provides a converted height size.
         /// </summary>
@@ -98,7 +143,20 @@ namespace LibTVRefCommonPortable.Utils
         /// <returns>A date</returns>
         public static int GetFontSize(int fontBaseSize)
         {
-            return Convert.ToInt32(((double)((double)fontBaseSize / (double)BaseScreenHeight) * (double)(ScreenHeight)) * ScaleRatio);
+            switch (ModelName)
+            {
+                case PlatformModel.Emulator:
+                    DebuggingUtils.Dbg("Emulator, Font size = " + fontBaseSize + " => " + ((double)((double)fontBaseSize / (double)BaseScreenHeight) * (double)ScreenHeight) * ScaleRatio);
+                    return Convert.ToInt32(((double)((double)fontBaseSize / (double)BaseScreenHeight) * (double)ScreenHeight) * ScaleRatio);
+
+                default:
+                case PlatformModel.Other:
+                case PlatformModel.TV:
+                    // TODO : Remove this if the TV/Other device's dpi is correctly changed.
+                    double tempAdjustmentRatio = 0.3D;
+                    DebuggingUtils.Dbg("TV/Other, Font size = " + fontBaseSize + " => " + ((double)((double)fontBaseSize / (double)BaseScreenHeight) * (double)ScreenHeight) * ScaleRatio * tempAdjustmentRatio);
+                    return Convert.ToInt32(((double)((double)fontBaseSize / (double)BaseScreenHeight) * (double)ScreenHeight) * ScaleRatio * tempAdjustmentRatio);
+            }
         }
     }
 }
index cdd82fddea0753a567e9c369873ee932f97a4a72..4e881cd970548a1698744a415d6bf5637d07f0a0 100755 (executable)
@@ -48,6 +48,7 @@
     <Compile Include="Ports\AppControlPort.cs" />
     <Compile Include="Ports\ApplicationManagerPort.cs" />
     <Compile Include="Ports\DbgPort.cs" />
+    <Compile Include="Ports\SystemSettingsPort.cs" />
     <Compile Include="Ports\WindowPort.cs" />
     <Compile Include="Ports\FileSystemPort.cs" />
     <Compile Include="Ports\FileSystemWatcherPort.cs" />
diff --git a/LibTVRefCommonTizen/Ports/SystemSettingsPort.cs b/LibTVRefCommonTizen/Ports/SystemSettingsPort.cs
new file mode 100644 (file)
index 0000000..9b16104
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * 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 System;
+using System.Runtime.InteropServices;
+using LibTVRefCommonPortable.Utils;
+using Xamarin.Forms.Platform.Tizen.Native;
+
+
+namespace LibTVRefCommonTizen.Ports
+{
+    public class SystemSettingsPort : ISystemSettings
+    {
+        public static readonly int ErrorNone = 0;
+        public static readonly string KeyModelName = "http://tizen.org/system/model_name";
+
+        internal class SystemInfo
+        {
+            [DllImport("libcapi-system-info.so.0", EntryPoint = "system_info_get_platform_string", CallingConvention = CallingConvention.Cdecl)]
+            internal static extern int SystemInfoGetPlatformString(string key, out string value);
+        }
+
+
+        public bool GetSystemModelName(out string modelName)
+        {
+            if (SystemInfo.SystemInfoGetPlatformString(KeyModelName, out modelName) != ErrorNone)
+            {
+                modelName = "";
+                return false;
+            }
+
+            return true;
+        }
+    }
+}
index 1afc93107c78b5408bb43c2fc365cb97fa41d76f..ad110347d49b5e4778abc2445b5aed1a9c336c53 100755 (executable)
@@ -60,7 +60,7 @@ namespace TVApps.TizenTV
         protected override void OnCreate()
         {
             base.OnCreate();
-            var app = new App(MainWindow.ScreenSize.Width, MainWindow.ScreenSize.Height, ElmSharp.Elementary.GetScale());
+            var app = new App(MainWindow.ScreenSize.Width, MainWindow.ScreenSize.Height, MainWindow.ScreenDpi.X, ElmSharp.Elementary.GetScale());
             notification = app;
 
             AppResourcePath = DirectoryInfo.Resource;
@@ -138,6 +138,7 @@ namespace TVApps.TizenTV
             Xamarin.Forms.DependencyService.Register<FileSystemWatcherPort>();
             Xamarin.Forms.DependencyService.Register<ApplicationManagerPort>();
             Xamarin.Forms.DependencyService.Register<FileSystemPort>();
+            Xamarin.Forms.DependencyService.Register<SystemSettingsPort>();
 
             Xamarin.Forms.Platform.Tizen.Forms.Init(instance);
             TizenFormsExtension.Init();
index a94cbe91674d7ee46819fe47113cc935c48eca30..2df3aa7839a6b859c5dbf1eece0d9e82fe365d28 100755 (executable)
@@ -62,13 +62,21 @@ namespace TVApps
         /// <see cref="MainPage"/>
         /// <param name="screenWidth">Screen Width</param>
         /// <param name="screenHeight">Screen Height</param>
+        /// <param name="dpi">Screen DPI</param>
         /// <param name="scaleRatio">Scale ratio</param>
-        public App(int screenWidth, int screenHeight, double scaleRatio)
+        public App(int screenWidth, int screenHeight, int dpi, double scaleRatio)
         {
             SizeUtils.ScreenWidth = screenWidth;
             SizeUtils.ScreenHeight = screenHeight;
+            SizeUtils.Dpi = dpi;
             SizeUtils.ScaleRatio = scaleRatio;
 
+            string modelName;
+            if (DependencyService.Get<ISystemSettings>().GetSystemModelName(out modelName))
+            {
+                SizeUtils.SetModelName(modelName);
+            }
+
             MainPage = new MainPage();
         }
 
index af42553c3d4c137572dc0df3fb2d24ee56c6e523..d9fcd5c9be9fa5217f1048a05f82666b6e4f8b34 100755 (executable)
@@ -59,7 +59,7 @@ namespace TVHome.TizenTV
         protected override void OnCreate()
         {
             base.OnCreate();
-            var app = new App(MainWindow.ScreenSize.Width, MainWindow.ScreenSize.Height, ElmSharp.Elementary.GetScale());
+            var app = new App(MainWindow.ScreenSize.Width, MainWindow.ScreenSize.Height, MainWindow.ScreenDpi.X, ElmSharp.Elementary.GetScale());
             notification = app;
 
             AppResourcePath = DirectoryInfo.Resource;
@@ -159,6 +159,7 @@ namespace TVHome.TizenTV
             global::Xamarin.Forms.DependencyService.Register<ApplicationManagerPort>();
             global::Xamarin.Forms.DependencyService.Register<FileSystemPort>();
             global::Xamarin.Forms.DependencyService.Register<WindowPort>();
+            global::Xamarin.Forms.DependencyService.Register<SystemSettingsPort>();
             TizenFormsExtension.Init();
             global::Xamarin.Forms.Platform.Tizen.Forms.Init(app);
             app.Run(args);
index 4c2fc5326719b2b2062297ddfea1f774ef5389a7..f0ea4ec91ab1495f61cf9be810d424320fc3d90a 100755 (executable)
@@ -80,13 +80,21 @@ namespace TVHome
         /// </summary>
         /// <param name="screenWidth">Screen Width</param>
         /// <param name="screenHeight">Screen Height</param>
+        /// <param name="dpi">Screen DPI</param>
         /// <param name="scaleRatio">Scale ratio</param>
-        public App(int screenWidth, int screenHeight, double scaleRatio)
+        public App(int screenWidth, int screenHeight, int dpi, double scaleRatio)
         {
             SizeUtils.ScreenWidth = screenWidth;
             SizeUtils.ScreenHeight = screenHeight;
+            SizeUtils.Dpi = dpi;
             SizeUtils.ScaleRatio = scaleRatio;
 
+            string modelName;
+            if (DependencyService.Get<ISystemSettings>().GetSystemModelName(out modelName))
+            {
+                SizeUtils.SetModelName(modelName);
+            }
+
             MainPage = new MainPage();
         }