From: cskim Date: Tue, 11 Apr 2017 12:22:49 +0000 (+0900) Subject: Modify Font size calculation X-Git-Tag: submit/tizen/20170808.015446~116 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=126be77c2a451c140cecee24039b8af6d7948538;p=profile%2Ftv%2Fapps%2Fdotnet%2Fhome.git Modify Font size calculation Change-Id: Iab7677b7894409875036c8dca7342a0d9f4f86cb Signed-off-by: cskim --- diff --git a/LibTVRefCommonPortable/LibTVRefCommonPortable.csproj b/LibTVRefCommonPortable/LibTVRefCommonPortable.csproj index c8af293..ff74f8d 100755 --- a/LibTVRefCommonPortable/LibTVRefCommonPortable.csproj +++ b/LibTVRefCommonPortable/LibTVRefCommonPortable.csproj @@ -53,6 +53,7 @@ + diff --git a/LibTVRefCommonPortable/Models/AppShortcutController.cs b/LibTVRefCommonPortable/Models/AppShortcutController.cs index e0a38ff..b536002 100755 --- a/LibTVRefCommonPortable/Models/AppShortcutController.cs +++ b/LibTVRefCommonPortable/Models/AppShortcutController.cs @@ -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", } }; diff --git a/LibTVRefCommonPortable/Utils/AppShortcutStorage.cs b/LibTVRefCommonPortable/Utils/AppShortcutStorage.cs index 010f33d..94157ee 100644 --- a/LibTVRefCommonPortable/Utils/AppShortcutStorage.cs +++ b/LibTVRefCommonPortable/Utils/AppShortcutStorage.cs @@ -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 index 0000000..f2c26c1 --- /dev/null +++ b/LibTVRefCommonPortable/Utils/ISystemSettings.cs @@ -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); + } +} diff --git a/LibTVRefCommonPortable/Utils/SizeUtils.cs b/LibTVRefCommonPortable/Utils/SizeUtils.cs index 4084331..daa4d6d 100644 --- a/LibTVRefCommonPortable/Utils/SizeUtils.cs +++ b/LibTVRefCommonPortable/Utils/SizeUtils.cs @@ -66,11 +66,56 @@ namespace LibTVRefCommonPortable.Utils /// public static int ScreenWidth { set; get; } + /// + /// Device DPI + /// + public static double Dpi { set; get; } + /// /// Font Scale ratio /// public static double ScaleRatio { set; get; } + /// + /// Platform Model enumerations + /// + private enum PlatformModel + { + TV, + Emulator, + Other, + } + + /// + /// Platform Model Name + /// + private static PlatformModel ModelName = PlatformModel.TV; + + /// + /// Set model name of running device. + /// + /// a model name + 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; + } + } + /// /// A method provides a converted height size. /// @@ -98,7 +143,20 @@ namespace LibTVRefCommonPortable.Utils /// A date 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); + } } } } diff --git a/LibTVRefCommonTizen/LibTVRefCommonTizen.csproj b/LibTVRefCommonTizen/LibTVRefCommonTizen.csproj index cdd82fd..4e881cd 100755 --- a/LibTVRefCommonTizen/LibTVRefCommonTizen.csproj +++ b/LibTVRefCommonTizen/LibTVRefCommonTizen.csproj @@ -48,6 +48,7 @@ + diff --git a/LibTVRefCommonTizen/Ports/SystemSettingsPort.cs b/LibTVRefCommonTizen/Ports/SystemSettingsPort.cs new file mode 100644 index 0000000..9b16104 --- /dev/null +++ b/LibTVRefCommonTizen/Ports/SystemSettingsPort.cs @@ -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; + } + } +} diff --git a/TVApps/TVApps.TizenTV/TVApps.TizenTV.cs b/TVApps/TVApps.TizenTV/TVApps.TizenTV.cs index 1afc931..ad11034 100755 --- a/TVApps/TVApps.TizenTV/TVApps.TizenTV.cs +++ b/TVApps/TVApps.TizenTV/TVApps.TizenTV.cs @@ -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(); Xamarin.Forms.DependencyService.Register(); Xamarin.Forms.DependencyService.Register(); + Xamarin.Forms.DependencyService.Register(); Xamarin.Forms.Platform.Tizen.Forms.Init(instance); TizenFormsExtension.Init(); diff --git a/TVApps/TVApps/TVApps.cs b/TVApps/TVApps/TVApps.cs index a94cbe9..2df3aa7 100755 --- a/TVApps/TVApps/TVApps.cs +++ b/TVApps/TVApps/TVApps.cs @@ -62,13 +62,21 @@ namespace TVApps /// /// Screen Width /// Screen Height + /// Screen DPI /// Scale ratio - 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().GetSystemModelName(out modelName)) + { + SizeUtils.SetModelName(modelName); + } + MainPage = new MainPage(); } diff --git a/TVHome/TVHome.TizenTV/TVHome.TizenTV.cs b/TVHome/TVHome.TizenTV/TVHome.TizenTV.cs index af42553..d9fcd5c 100755 --- a/TVHome/TVHome.TizenTV/TVHome.TizenTV.cs +++ b/TVHome/TVHome.TizenTV/TVHome.TizenTV.cs @@ -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(); global::Xamarin.Forms.DependencyService.Register(); global::Xamarin.Forms.DependencyService.Register(); + global::Xamarin.Forms.DependencyService.Register(); TizenFormsExtension.Init(); global::Xamarin.Forms.Platform.Tizen.Forms.Init(app); app.Run(args); diff --git a/TVHome/TVHome/TVHome.cs b/TVHome/TVHome/TVHome.cs index 4c2fc53..f0ea4ec 100755 --- a/TVHome/TVHome/TVHome.cs +++ b/TVHome/TVHome/TVHome.cs @@ -80,13 +80,21 @@ namespace TVHome /// /// Screen Width /// Screen Height + /// Screen DPI /// Scale ratio - 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().GetSystemModelName(out modelName)) + { + SizeUtils.SetModelName(modelName); + } + MainPage = new MainPage(); }