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());
LoadApplication(app);
}
<Compile Include="TVMediaHub.cs" />
<Compile Include="TVMediaHub.Tizen.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Utils\DbgPort.cs" />
<Compile Include="Utils\NinePatch.xaml.cs">
<DependentUpon>NinePatch.xaml</DependentUpon>
</Compile>
<Compile Include="Utils\NinePatchImageRenderer.cs" />
<Compile Include="Utils\SizeUtils.cs" />
+ <Compile Include="Utils\SystemSettingsPort.cs" />
<Compile Include="ViewModels\ImageTabViewModel.cs" />
<Compile Include="ViewModels\MediaHubMainPageViewModel.cs" />
<Compile Include="ViewModels\MusicTabViewModel.cs" />
/// <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 (SystemSettingsPort.GetSystemModelName(out modelName))
+ {
+ SizeUtils.SetModelName(modelName);
+ }
+
MainPage = new NavigationPage(new Tizen.Views.MediaHubMainPage());
}
--- /dev/null
+/*
+ * 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 Tizen;
+using System.Runtime.CompilerServices;
+
+namespace TVMediaHub.Tizen.Utils
+{
+ /// <summary>
+ /// Platform dependent implementation for the Logging.
+ /// </summary>
+ public class DbgPort
+ {
+ /// <summary>
+ /// A Logging Tag
+ /// </summary>
+ public static string TAG = "mediahub";
+
+ /// <summary>
+ /// Displays a log message which developer want to check
+ /// </summary>
+ /// <param name="message"> A debugging message </param>
+ /// <param name="file"> A file name that debugging message is exist </param>
+ /// <param name="func"> A function name that debugging message is exist </param>
+ /// <param name="line"> A line number that debugging message is exist </param>
+ public static void D(string message, [CallerFilePath] System.String file = "", [CallerMemberName] System.String func = "", [CallerLineNumber] System.Int32 line = 0)
+ {
+ Log.Debug(TAG, message, file, func, line);
+
+ }
+
+ /// <summary>
+ /// Displays a error log message
+ /// </summary>
+ /// <param name="message"> A debugging message </param>
+ /// <param name="file"> A file name that debugging message is exist </param>
+ /// <param name="func"> A function name that debugging message is exist </param>
+ /// <param name="line"> A line number that debugging message is exist </param>
+ public static void E(string message, [CallerFilePath] System.String file = "", [CallerMemberName] System.String func = "", [CallerLineNumber] System.Int32 line = 0)
+ {
+ Log.Error(TAG, message, file, func, line);
+ }
+ }
+}
\ No newline at end of file
*/
using System;
+using Tizen;
namespace TVMediaHub.Tizen.Utils
{
-
/// <summary>
/// A class provides Size metric related functions
/// </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;
+ }
+
+ DbgPort.D("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>
/// <param name="heightBaseSize">A height value in BaseScreen ratio</param>
/// <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:
+ DbgPort.D("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;
+ DbgPort.D("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);
+ }
}
}
}
--- /dev/null
+/*
+ * 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.Runtime.InteropServices;
+
+
+namespace TVMediaHub.Tizen.Utils
+{
+ public class SystemSettingsPort
+ {
+ 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 static bool GetSystemModelName(out string modelName)
+ {
+ if (SystemInfo.SystemInfoGetPlatformString(KeyModelName, out modelName) != ErrorNone)
+ {
+ modelName = "";
+ return false;
+ }
+
+ return true;
+ }
+ }
+}