From: kiso.chang Date: Wed, 5 Oct 2022 04:36:33 +0000 (+0900) Subject: Update UIs when time and language changed X-Git-Tag: accepted/tizen/unified/20221005.144502^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2d28f48e53fa7e6cdb07254866e1dc21d090d0e6;p=profile%2Fiot%2Fapps%2Fdotnet%2Fsettings.git Update UIs when time and language changed Change-Id: Ieab48bdacfc915921001002d2161dc89e669e060 Signed-off-by: kiso.chang --- diff --git a/SettingMain/SettingContent_Base.cs b/SettingMain/SettingContent_Base.cs index a29699f..8ca73c4 100644 --- a/SettingMain/SettingContent_Base.cs +++ b/SettingMain/SettingContent_Base.cs @@ -268,11 +268,16 @@ namespace SettingMain { } + protected Window mWindow; + protected string mTitle; + protected ContentPage mPage; public SettingContent_Base() : base() { + mWindow = null; + mPage = null; } protected override void OnCreate(string contentInfo, Window window) @@ -281,14 +286,16 @@ namespace SettingMain window.BackgroundColor = Color.Transparent; + mWindow = window; - var page = new ContentPage() + mPage = new ContentPage() { Content = CreateContent(window), AppBar = CreateAppBar(mTitle), }; - window.Add(page); + window.Add(mPage); + } protected virtual AppBar CreateAppBar(string title) @@ -336,6 +343,7 @@ namespace SettingMain protected override void OnTerminate(string contentInfo, TerminationType type) { + base.OnTerminate(contentInfo, type); } diff --git a/SettingMain/SettingContent_DateTime.cs b/SettingMain/SettingContent_DateTime.cs index 6abb60b..3c5f766 100644 --- a/SettingMain/SettingContent_DateTime.cs +++ b/SettingMain/SettingContent_DateTime.cs @@ -13,6 +13,8 @@ namespace SettingMain { class SettingContent_DateTime : SettingContent_Base { + DefaultLinearItem mDateItem = null; + DefaultLinearItem mTimeItem = null; public SettingContent_DateTime() : base() { @@ -64,6 +66,7 @@ namespace SettingMain item = CreateItemWithCheck(Resources.IDS_ST_BODY_SET_DATE, DateTime.Now.ToShortDateString()); + mDateItem = item; if (item) { item.Clicked += (o, e) => @@ -81,13 +84,14 @@ namespace SettingMain }; content.Add(item); } - + item = CreateItemWithCheck(Resources.IDS_ST_BODY_SET_TIME, DateTime.Now.ToShortTimeString()); + mTimeItem = item; if (item) { item.Clicked += (o, e) => @@ -155,5 +159,28 @@ namespace SettingMain return content; } + + + private void SystemSettings_TimeChanged(object sender, Tizen.System.TimeChangedEventArgs e) + { + Tizen.Log.Debug("NUI", "SystemSettings_TimeChanged is called\n"); + + mDateItem.SubText = DateTime.Now.ToShortDateString(); + mTimeItem.SubText = DateTime.Now.ToShortTimeString(); + + } + + protected override void OnCreate(string contentInfo, Window window) + { + base.OnCreate(contentInfo, window); + Tizen.System.SystemSettings.TimeChanged += SystemSettings_TimeChanged; + } + protected override void OnTerminate(string contentInfo, TerminationType type) + { + Tizen.System.SystemSettings.TimeChanged -= SystemSettings_TimeChanged; + + base.OnTerminate(contentInfo, type); + } + } } diff --git a/SettingMain/SettingContent_LanguageInput.cs b/SettingMain/SettingContent_LanguageInput.cs index ae6f26f..07b2486 100644 --- a/SettingMain/SettingContent_LanguageInput.cs +++ b/SettingMain/SettingContent_LanguageInput.cs @@ -18,6 +18,29 @@ namespace SettingMain { mTitle = Resources.IDS_ST_HEADER_LANGUAGE_AND_INPUT; } + protected override void OnCreate(string contentInfo, Window window) + { + base.OnCreate(contentInfo, window); + + Tizen.System.SystemSettings.LocaleLanguageChanged += SystemSettings_LocaleLanguageChanged; + } + + protected override void OnTerminate(string contentInfo, TerminationType type) + { + Tizen.System.SystemSettings.LocaleLanguageChanged -= SystemSettings_LocaleLanguageChanged; + + base.OnTerminate(contentInfo, type); + } + + private void SystemSettings_LocaleLanguageChanged(object sender, Tizen.System.LocaleLanguageChangedEventArgs e) + { + if (mPage != null) + { + mPage.AppBar.Title = Resources.IDS_ST_HEADER_LANGUAGE_AND_INPUT; + mPage.Content = CreateContent(mWindow); + } + } + protected override View CreateContent(Window window) { diff --git a/SettingView/SettingView.cs b/SettingView/SettingView.cs index 2c3d3df..dfc8324 100644 --- a/SettingView/SettingView.cs +++ b/SettingView/SettingView.cs @@ -13,33 +13,69 @@ namespace SettingView private static readonly string resPath = Tizen.Applications.Application.Current.DirectoryInfo.Resource; protected const string SETTING_LIST_ICON_PATH_CFG = "/icons/list_icon/"; + private ContentPage mMainPage; + public Program(string styleSheet, Size2D windowSize, Position2D windowPosition, IBorderInterface borderInterface) : base(styleSheet, windowSize, windowPosition, borderInterface) { + mMainPage = null; } protected override void OnCreate() { base.OnCreate(); - Initialize(); - } - - void Initialize() - { Window window = GetDefaultWindow(); - window.KeyEvent += OnKeyEvent; window.TouchEvent += OnTouchEvent; - Bundle bundle = new Bundle(); - bundle.AddItem(" ", " "); - String encodedBundle = bundle.Encode(); + // Page with AppBar and Content. + var appBar = new AppBar() + { + Title = Resources.IDS_ST_OPT_SETTINGS, + }; + var appBarStyle = ThemeManager.GetStyle("Tizen.NUI.Components.AppBar"); + var navigationContent = new Button(((AppBarStyle)appBarStyle).BackButton); + navigationContent.Clicked += (o, e) => + { + Exit(); + }; + appBar.NavigationContent = navigationContent; + //appBarStyle.Dispose(); + + mMainPage = new ContentPage() + { + AppBar = appBar, + + Content = CreateMainMenuContent(), + }; + + + // Push the page to the default navigator. + window.GetDefaultNavigator().Push(mMainPage); + + + Tizen.System.SystemSettings.LocaleLanguageChanged += SystemSettings_LocaleLanguageChanged; + } + + protected override void OnTerminate() + { + Window window = GetDefaultWindow(); + + window.KeyEvent -= OnKeyEvent; + window.TouchEvent -= OnTouchEvent; - Tizen.Log.Error("SettingWidget", "REQUEST \n"); - CreateSettingsMainMenu(); + Tizen.System.SystemSettings.LocaleLanguageChanged -= SystemSettings_LocaleLanguageChanged; + base.OnTerminate(); + } + private void SystemSettings_LocaleLanguageChanged(object sender, Tizen.System.LocaleLanguageChangedEventArgs e) + { + if (mMainPage != null) { + mMainPage.AppBar.Title = Resources.IDS_ST_OPT_SETTINGS; + mMainPage.Content = CreateMainMenuContent(); + } } @@ -334,26 +370,26 @@ namespace SettingView return item; } - // Create a page with scrollable content - private void CreateSettingsMainMenu() - { - - // Content of the page which scrolls items vertically. - var content = new ScrollableBase() + // Create a page with scrollable content + private View CreateMainMenuContent() { - WidthSpecification = LayoutParamPolicies.MatchParent, - HeightSpecification = LayoutParamPolicies.MatchParent, - ScrollingDirection = ScrollableBase.Direction.Vertical, - HideScrollbar = false, - Layout = new LinearLayout() - { - LinearOrientation = LinearLayout.Orientation.Vertical, - }, - }; - // Create items and add them to the content of the page. - DefaultLinearItem item = null; - item = CreateItemWithIcon(Resources.IDS_ST_BODY_WI_FI, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_wifi.png"); + // Content of the page which scrolls items vertically. + var content = new ScrollableBase() + { + WidthSpecification = LayoutParamPolicies.MatchParent, + HeightSpecification = LayoutParamPolicies.MatchParent, + ScrollingDirection = ScrollableBase.Direction.Vertical, + HideScrollbar = false, + Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Vertical, + }, + }; + + // Create items and add them to the content of the page. + DefaultLinearItem item = null; + item = CreateItemWithIcon(Resources.IDS_ST_BODY_WI_FI, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_wifi.png"); if (item != null) { item.Clicked += (o, e) => @@ -367,7 +403,7 @@ namespace SettingView }; content.Add(item); } - item = CreateItemWithIcon(Resources.IDS_TPLATFORM_OPT_BLUETOOTH, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_bluetooth.png"); + item = CreateItemWithIcon(Resources.IDS_TPLATFORM_OPT_BLUETOOTH, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_bluetooth.png"); if (item != null) { item.Clicked += (o, e) => @@ -382,16 +418,16 @@ namespace SettingView content.Add(item); } - item = CreateItemWithIcon(Resources.IDS_ST_HEADER_SOUND, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_sound_and_notifications.png"); - if (item != null) - { - item.Clicked += (o, e) => + item = CreateItemWithIcon(Resources.IDS_ST_HEADER_SOUND, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_sound_and_notifications.png"); + if (item != null) { - Window window = GetDefaultWindow(); - LaunchWidget(window, "sound@org.tizen.cssettings"); - }; - content.Add(item); - } + item.Clicked += (o, e) => + { + Window window = GetDefaultWindow(); + LaunchWidget(window, "sound@org.tizen.cssettings"); + }; + content.Add(item); + } #if false item = CreateItemWithIcon(Resources.IDS_ST_BODY_NOTIFICATIONS, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_notifications.png"); @@ -402,27 +438,27 @@ namespace SettingView #endif - item = CreateItemWithIcon(Resources.IDS_ST_HEADER_DISPLAY, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_display.png"); - if (item != null) - { - item.Clicked += (o, e) => + item = CreateItemWithIcon(Resources.IDS_ST_HEADER_DISPLAY, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_display.png"); + if (item != null) { - Window window = GetDefaultWindow(); - LaunchWidget(window, "display@org.tizen.cssettings"); - }; - content.Add(item); - } + item.Clicked += (o, e) => + { + Window window = GetDefaultWindow(); + LaunchWidget(window, "display@org.tizen.cssettings"); + }; + content.Add(item); + } - item = CreateItemWithIcon(Resources.IDS_LCKSCN_BODY_WALLPAPERS, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_wallpapers.png"); - if (item != null) - { - item.Clicked += (o, e) => + item = CreateItemWithIcon(Resources.IDS_LCKSCN_BODY_WALLPAPERS, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_wallpapers.png"); + if (item != null) { - Window window = GetDefaultWindow(); - LaunchWidget(window, "wallpaper@org.tizen.cssetting-wallpaper"); - }; - content.Add(item); - } + item.Clicked += (o, e) => + { + Window window = GetDefaultWindow(); + LaunchWidget(window, "wallpaper@org.tizen.cssetting-wallpaper"); + }; + content.Add(item); + } #if false item = CreateItemWithIcon("Tray", resPath + SETTING_LIST_ICON_PATH_CFG + "settings_softkey.png"); @@ -431,119 +467,96 @@ namespace SettingView content.Add(item); #endif item = CreateItemWithIcon(Resources.IDS_ST_BODY_ACCOUNTS, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_account.png"); - if (item != null) - { - item.Clicked += (o, e) => + if (item != null) { - Window window = GetDefaultWindow(); - LaunchWidget(window, "account@org.tizen.cssetting-account"); - }; - content.Add(item); - } + item.Clicked += (o, e) => + { + Window window = GetDefaultWindow(); + LaunchWidget(window, "account@org.tizen.cssetting-account"); + }; + content.Add(item); + } - item = CreateItemWithIcon(Resources.IDS_ST_HEADER_PRIVACY, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_privacy_and_safety.png"); - if (item != null) - { - item.Clicked += (o, e) => + item = CreateItemWithIcon(Resources.IDS_ST_HEADER_PRIVACY, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_privacy_and_safety.png"); + if (item != null) { - Window window = GetDefaultWindow(); - LaunchWidget(window, "privacy@org.tizen.cssetting-privacy"); - }; - content.Add(item); - } + item.Clicked += (o, e) => + { + Window window = GetDefaultWindow(); + LaunchWidget(window, "privacy@org.tizen.cssetting-privacy"); + }; + content.Add(item); + } - item = CreateItemWithIcon(Resources.IDS_ST_BODY_APPLICATIONS, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_applications.png"); - if (item != null) - { - item.Clicked += (o, e) => + item = CreateItemWithIcon(Resources.IDS_ST_BODY_APPLICATIONS, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_applications.png"); + if (item != null) { - Window window = GetDefaultWindow(); - LaunchWidget(window, "apps@org.tizen.cssettings"); - }; - content.Add(item); - } + item.Clicked += (o, e) => + { + Window window = GetDefaultWindow(); + LaunchWidget(window, "apps@org.tizen.cssettings"); + }; + content.Add(item); + } - item = CreateItemWithIcon(Resources.IDS_ST_BODY_STORAGE, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_storage.png"); - if (item != null) - { - item.Clicked += (o, e) => + item = CreateItemWithIcon(Resources.IDS_ST_BODY_STORAGE, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_storage.png"); + if (item != null) { - Window window = GetDefaultWindow(); - LaunchWidget(window, "storage@org.tizen.cssettings"); - }; - content.Add(item); - } + item.Clicked += (o, e) => + { + Window window = GetDefaultWindow(); + LaunchWidget(window, "storage@org.tizen.cssettings"); + }; + content.Add(item); + } - item = CreateItemWithIcon(Resources.IDS_ST_HEADER_LANGUAGE_AND_INPUT, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_language_and_input.png"); - if (item != null) - { - item.Clicked += (o, e) => + item = CreateItemWithIcon(Resources.IDS_ST_HEADER_LANGUAGE_AND_INPUT, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_language_and_input.png"); + if (item != null) { - Window window = GetDefaultWindow(); - LaunchWidget(window, "languageinput@org.tizen.cssettings"); - }; - content.Add(item); - } + item.Clicked += (o, e) => + { + Window window = GetDefaultWindow(); + LaunchWidget(window, "languageinput@org.tizen.cssettings"); + }; + content.Add(item); + } - item = CreateItemWithIcon(Resources.IDS_ST_BODY_DATE_AND_TIME, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_date_and_time.png"); - if (item != null) - { - item.Clicked += (o, e) => + item = CreateItemWithIcon(Resources.IDS_ST_BODY_DATE_AND_TIME, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_date_and_time.png"); + if (item != null) { - Window window = GetDefaultWindow(); - LaunchWidget(window, "datetime@org.tizen.cssettings"); - }; - content.Add(item); - } + item.Clicked += (o, e) => + { + Window window = GetDefaultWindow(); + LaunchWidget(window, "datetime@org.tizen.cssettings"); + }; + content.Add(item); + } - item = CreateItemWithIcon(Resources.IDS_ST_BODY_ACCESSIBILITY, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_accessibility.png"); - if (item != null) - { - item.Clicked += (o, e) => + item = CreateItemWithIcon(Resources.IDS_ST_BODY_ACCESSIBILITY, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_accessibility.png"); + if (item != null) { - Window window = GetDefaultWindow(); - LaunchWidget(window, "accessibility@org.tizen.cssetting-accessibility"); - }; - content.Add(item); - } + item.Clicked += (o, e) => + { + Window window = GetDefaultWindow(); + LaunchWidget(window, "accessibility@org.tizen.cssetting-accessibility"); + }; + content.Add(item); + } - item = CreateItemWithIcon(Resources.IDS_ST_BODY_ABOUT_DEVICE, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_about_device.png"); - if (item != null) - { - item.Clicked += (o, e) => + item = CreateItemWithIcon(Resources.IDS_ST_BODY_ABOUT_DEVICE, resPath + SETTING_LIST_ICON_PATH_CFG + "settings_about_device.png"); + if (item != null) { - Window window = GetDefaultWindow(); - LaunchWidget(window, "aboutdevice@org.tizen.cssettings"); - }; - content.Add(item); - } - - - // Page with AppBar and Content. - var appBar = new AppBar() - { - Title = Resources.IDS_ST_OPT_SETTINGS, - }; - var appBarStyle = ThemeManager.GetStyle("Tizen.NUI.Components.AppBar"); - var navigationContent = new Button(((AppBarStyle)appBarStyle).BackButton); - navigationContent.Clicked += (o, e) => - { - Exit(); - }; - appBar.NavigationContent = navigationContent; - //appBarStyle.Dispose(); - - var contentPage = new ContentPage() - { - AppBar = appBar, - - Content = content, - }; + item.Clicked += (o, e) => + { + Window window = GetDefaultWindow(); + LaunchWidget(window, "aboutdevice@org.tizen.cssettings"); + }; + content.Add(item); + } - // Push the page to the default navigator. - NUIApplication.GetDefaultWindow().GetDefaultNavigator().Push(contentPage); + return content; - } + } void LaunchWidget(Window window, string widgetid) {