string appLabel;
string appIconPath;
- appInfo.TryGetValue("Label", out appLabel);
+ if (appInfo.TryGetValue("Label", out appLabel) == false)
+ {
+ appLabel = "No Name";
+ }
+
appInfo.TryGetValue("IconPath", out appIconPath);
- DebuggingUtils.Dbg("AppID: " + appShortcutInfo.AppID + ", Label : " + appLabel);
var defaultStateDescription = new StateDescription()
{
Label = appLabel,
return false;
}
- public async Task<IEnumerable<RecentShortcutInfo>> GetList()
+ public IEnumerable<RecentShortcutInfo> GetList()
{
IApplicationManagerAPIs applicationManagerPort = DependencyService.Get<IApplicationManagerAPIs>();
List<RecentShortcutInfo> recentShortcutInfoList = new List<RecentShortcutInfo>();
- var applicationList = await applicationManagerPort.GetRecentApplications();
- foreach (KeyValuePair<string, string[]> item in applicationList)
+ var recentApps = applicationManagerPort.GetRecentApplications();
+ foreach (var item in recentApps)
{
var defaultStateDescription = new StateDescription()
{
- Label = item.Value[0],
- IconPath = item.Value[2],
+ Label = item.instanceLabel,
+ IconPath = item.iconPath,
Action = new AppControlAction()
{
- AppID = item.Key
+ AppID = item.appID,
}
};
var recentShortcutInfo = new RecentShortcutInfo();
public SettingShortcutController()
{
+ // TODO : read from file!!!
ShortcutInfo settings = SettingShortcutFactory.Get(SettingID.SETTINGS);
settingShortcutList.Add(settings);
public IEnumerable<ShortcutInfo> GetList()
{
- return settingShortcutList ?? null;
+ return new List<ShortcutInfo>(settingShortcutList);
}
}
AppID = "org.tizen.settings",
});
- pinnedAppsInfo.Add(new AppShortcutInfo()
- {
- AppID = "org.tizen.chromium-efl.ubrowser",
- });
-
pinnedAppsInfo.Add(new AppShortcutInfo()
{
AppID = "org.tizen.dpm-toolkit",
});
- pinnedAppsInfo.Add(new AppShortcutInfo()
- {
- AppID = "org.tizen.infosquare",
- });
-
pinnedAppsInfo.Add(new AppShortcutInfo()
{
AppID = "org.tizen.mediahub",
});
- pinnedAppsInfo.Add(new AppShortcutInfo()
- {
- AppID = "org.tizen.heremaps-uc",
- });
-
- pinnedAppsInfo.Add(new AppShortcutInfo()
- {
- AppID = "org.tizen.ode",
- });
-
pinnedAppsInfo.Add(new AppShortcutInfo()
{
AppID = "org.tizen.apps",
namespace LibTVRefCommonPortable.Utils
{
+ public class RecentApp
+ {
+ public String instanceID;
+ public String instanceLabel;
+ public String appID;
+ public String applabel;
+ public String iconPath;
+ public DateTime launchedTime;
+ public String uri;
+ }
+
public interface IApplicationManagerAPIs
{
Task<Dictionary<string, string[]>> GetAllInstalledApplication();
- Task<Dictionary<string, string[]>> GetRecentApplications();
+ IEnumerable<RecentApp> GetRecentApplications();
Dictionary<string, string> GetInstalledApplication(string applicationId);
}
}
DebuggingUtils.Dbg(launchedEventArgs.ApplicationRunningContext.ApplicationId + " launched");
}
- public async Task<Dictionary<string, string[]>> GetRecentApplications()
+ public IEnumerable<RecentApp> GetRecentApplications()
{
- // RUA가 지원되지 않으므로 일단 설치된 app들을 가져와 본다
- // TODO: RUA로 대체한다
- Dictionary<string, string[]> resultList = new Dictionary<string, string[]>();
- var applicationList = await ApplicationManager.GetInstalledApplicationsAsync();
- string[] result;
+ List<RecentApp> resultList = new List<RecentApp>();
+ IEnumerable<RecentApplicationInfo> recentApps = ApplicationManager.GetRecentApplications();
- foreach (ApplicationInfo appInfo in applicationList)
+ foreach (var app in recentApps)
{
- if (appInfo.Label == null ||
- appInfo.ApplicationId == null)
+ if (app.IsNoDisplay ||
+ app.ApplicationId == null ||
+ app.ApplicationId.Length < 1)
{
continue;
}
- result = new string[3];
- result[0] = appInfo.Label;
- result[1] = appInfo.ApplicationId;
- result[2] = (System.IO.File.Exists(appInfo.IconPath)) ? appInfo.IconPath : DefaultAppIcon;
- resultList.Add(appInfo.ApplicationId, result);
+ resultList.Add(new RecentApp()
+ {
+ instanceID = app.InstanceId,
+ instanceLabel = app.InstanceName,
+ appID = app.ApplicationId,
+ applabel = (app.Label == null || app.Label.Length < 1) ? "No Name" : app.Label,
+ iconPath = app.IconPath,
+ launchedTime = app.LaunchTime,
+ uri = app.Uri,
+ });
}
return resultList;
{
UpdateBorder();
}
+
base.OnElementPropertyChanged(sender, e);
}
get { return (AppsStatus)GetValue(CurrentStatusProperty); }
set { SetValue(CurrentStatusProperty, value); }
}
+
/*
private async void PlayHideAnimation()
{
// TODO : Apps Out Animation.
}
*/
+
private async void PlayShowAnimation()
{
await AppList.TranslateTo(0, 12, 0);
private async Task<bool> OnBackKeyPressedAtMain()
{
- DebuggingUtils.Dbg("OnBackKeyPressedAtMain - first item focused? " + AppList.IsFirstItemFocused);
-
if (CurrentStatus != AppsStatus.Default)
{
MessagingCenter.Send<MainPage, string>(this, "ChangeCurrentStatus", AppsStatus.Default.ToString());
if (!AppList.IsFirstItemFocused)
{
- DebuggingUtils.Dbg("OnBackKeyPressedAtMain - focus move");
AppList.InitializeFocus();
return true;
}
var answer = await DisplayAlert("QUIT", "Do you want to quit?", "YES", "NO");
if (answer)
{
- DebuggingUtils.Dbg("OnBackKeyPressedAtMain - Yes");
AppControlUtils.SelfTerminate();
return true;
}
protected override bool OnBackButtonPressed()
{
- DebuggingUtils.Dbg("OnBackButtonPressed");
SynchronizationContext.Current.Post(async (o) =>
{
await OnBackKeyPressedAtMain();
AppResourcePath = DirectoryInfo.Resource;
AppDataPath = DirectoryInfo.Data;
+ DbgPort.D("-----------------------------------");
DbgPort.D("Home application is being loaded...");
+ DbgPort.D("-----------------------------------");
LoadApplication(app);
PackageManagerPort.RegisterCallbacks(notification);
protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
{
- DbgPort.D("OnAppControlReceived, " + e.ReceivedAppControl.Operation);
- DbgPort.D("ApplicationId = " + e.ReceivedAppControl.ApplicationId);
- DbgPort.D("CallerApplicationId = " + e.ReceivedAppControl.CallerApplicationId);
-
if (AppControlPort.AppAddedNotifyOperation.CompareTo(e.ReceivedAppControl.Operation) == 0)
{
DbgPort.D("App Added Notification");
public string arg;
}
+ public enum TVHomeStatus
+ {
+ OnStart,
+ OnSleep,
+ OnResume,
+ }
+
public class App : Application, IPlatformNotification
{
+ public static readonly string AppStatus = "appstatus";
+
private static EventHandler<TVHomeEventArgs> HomeKeyListener;
private static EventHandler<TVHomeEventArgs> MenuKeyListener;
private static EventHandler<TVHomeEventArgs> AppInstalledListener;
protected override void OnStart()
{
-
+ MessagingCenter.Send<App, TVHomeStatus>(this, "appstatus", TVHomeStatus.OnStart);
}
protected override void OnSleep()
{
-
+ MessagingCenter.Send<App, TVHomeStatus>(this, "appstatus", TVHomeStatus.OnSleep);
}
protected override void OnResume()
{
-
+ MessagingCenter.Send<App, TVHomeStatus>(this, "appstatus", TVHomeStatus.OnResume);
}
public static void SetHomeKeyListener(EventHandler<TVHomeEventArgs> listener)
interface IHomeViewModel
{
void OnPropertyChanged(string name);
- void ChangeCurrentStatus(HomeStatus newStatus);
+ void ChangeCurrentStatus(HomeStatus newStatus, bool isForceUpdate);
}
}
*/
using System;
-using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
-using System.Windows.Input;
-using System.Threading.Tasks;
using System.Linq;
using LibTVRefCommonPortable.DataModels;
using LibTVRefCommonPortable.Utils;
public MainPageViewModel()
{
- Init();
- InitCommands();
+ // Init sequence
+ // MainPage ( MainPageViewModel -> MainPanel -> SubPanel )
MakeMainMenuItems();
- MakeRecentButtons();
+ InitStatus();
+ InitCommands();
+ SetDefaultAppList();
+ MakeSettingsButtons();
- DebuggingUtils.Dbg("Reading Apps list");
- TVHomeImpl.GetInstance.AppShortcutControllerInstance.GetDefaultShortcuts();
- OnPropertyChanged("AppList");
UpdateAppList(null, null);
- //SettingsList = TVHomeImpl.GetInstance.AppShortcutControllerInstnace.ReadFromFile();
- SettingsList = TVHomeImpl.GetInstance.SettingShortcutControllerInstance.GetList();
- OnPropertyChanged("SettingsList");
-
TVHomeImpl.GetInstance.AppShortcutControllerInstance.AddFileSystemChangedListener(UpdateAppList);
App.SetAppPinnedNotificationListener((s, e) =>
{
// TODO : Make this for Move a pinned app/Show pinned apps(scroll to last)
+ ChangeCurrentStatus(HomeStatus.SubPanelFocused);
+ ChangeSelectedPanelName(HomeMenuItem.Apps);
if (e.arg.Length > 0)
{
DebuggingUtils.Dbg("Move, AppID : " + e.arg);
DebuggingUtils.Dbg("Show, Pinned Apps");
}
});
+
+ MessagingCenter.Subscribe<App, TVHomeStatus>(this, App.AppStatus, (sender, arg) =>
+ {
+ switch (arg)
+ {
+ case TVHomeStatus.OnResume:
+ MakeRecentButtons();
+ break;
+ case TVHomeStatus.OnSleep:
+ ChangeCurrentStatus(HomeStatus.Default, true);
+ break;
+ }
+ });
}
- private void Init()
+ private void InitStatus()
{
- CurrentStatus = HomeStatus.Default;
- SelectedMenuName = HomeMenuItem.NotSelected;
+ ChangeCurrentStatus(HomeStatus.Default, true);
}
private void InitCommands()
string[] AppUnselectIconPath = { "ic_tizen_home_menu_recent_unselect.png", "ic_tizen_home_menu_apps_unselect.png", "ic_tizen_home_menu_settings_unselect.png" };
List<ShortcutInfo> TempList = new List<ShortcutInfo>();
- for (int i = 0; i < 3; i++)
+ for (int i = 0; i < AppName.Length; i++)
{
ShortcutInfo shortcutInfo = new HomeMenuAppShortcutInfo()
{
OnPropertyChanged("MainList");
}
+ private void SetDefaultAppList()
+ {
+ AppList = TVHomeImpl.GetInstance.AppShortcutControllerInstance.GetDefaultShortcuts();
+ OnPropertyChanged("AppList");
+ }
+
private async void UpdateAppList(object sender, EventArgs e)
{
AppList = await TVHomeImpl.GetInstance.AppShortcutControllerInstance.GetPinnedAppsWithDefaultShortcuts();
OnPropertyChanged("AppList");
}
- private async void MakeRecentButtons()
+ private void MakeSettingsButtons()
+ {
+ SettingsList = TVHomeImpl.GetInstance.SettingShortcutControllerInstance.GetList();
+ OnPropertyChanged("SettingsList");
+ }
+
+ private void MakeRecentButtons()
{
- RecentList = await TVHomeImpl.GetInstance.RecentShortcutControllerInstance.GetList();
+ RecentList = TVHomeImpl.GetInstance.RecentShortcutControllerInstance.GetList();
if (RecentList.Count<ShortcutInfo>() > 0)
{
IsShowNoRecentContents = false;
}
}
- public void ChangeCurrentStatus(HomeStatus newStatus)
+ public void ChangeCurrentStatus(HomeStatus newStatus, bool isForceUpdate = false)
{
- if (CurrentStatus.CompareTo(newStatus) != 0)
+ if (isForceUpdate ||
+ CurrentStatus.CompareTo(newStatus) != 0)
{
CurrentStatus = newStatus;
- if (CurrentStatus.CompareTo(HomeStatus.MainPanelFocused) == 0)
+ if (CurrentStatus.CompareTo(HomeStatus.Default) == 0)
+ {
+ foreach (HomeMenuAppShortcutInfo item in MainList)
+ {
+ if (item.CurrentStateDescription.Label.CompareTo("Apps") == 0)
+ {
+ DebuggingUtils.Dbg(item.CurrentStateDescription.Label + " To Focused");
+ item.ChangeStatus("focused");
+ }
+ else
+ {
+ DebuggingUtils.Dbg(item.CurrentStateDescription.Label + " To Default");
+ item.ChangeStatus("default");
+ }
+ }
+
+ ChangeSelectedPanelName(HomeMenuItem.Apps, isForceUpdate);
+ }
+ else if (CurrentStatus.CompareTo(HomeStatus.MainPanelFocused) == 0)
{
HomeMenuItem index = HomeMenuItem.Recent;
foreach (HomeMenuAppShortcutInfo item in MainList)
{
- DebuggingUtils.Dbg(index.ToString());
if (index == SelectedMenuName)
{
- DebuggingUtils.Dbg("To Focused");
+ DebuggingUtils.Dbg(index.ToString() + " To Focused");
item.ChangeStatus("focused");
}
else
{
- DebuggingUtils.Dbg("To Default");
+ DebuggingUtils.Dbg(index.ToString() + " To Default");
item.ChangeStatus("default");
}
HomeMenuItem index = HomeMenuItem.Recent;
foreach (HomeMenuAppShortcutInfo item in MainList)
{
- DebuggingUtils.Dbg(index.ToString());
if (index == SelectedMenuName)
{
- DebuggingUtils.Dbg("To be selected");
+ DebuggingUtils.Dbg(index.ToString() + " To be selected");
item.ChangeStatus("selected");
}
else
{
- DebuggingUtils.Dbg("To be unselect");
+ DebuggingUtils.Dbg(index.ToString() + " To be unselect");
item.ChangeStatus("unselect");
}
}
}
- public void ChangeSelectedPanelName(HomeMenuItem panelName)
+ public void ChangeSelectedPanelName(HomeMenuItem panelName, bool isForceUpdate = false)
{
- if (SelectedMenuName.CompareTo(panelName) != 0)
+ if (isForceUpdate ||
+ SelectedMenuName.CompareTo(panelName) != 0)
{
SelectedMenuName = panelName;
HomeMenuItem index = HomeMenuItem.Recent;
foreach (HomeMenuAppShortcutInfo item in MainList)
{
- DebuggingUtils.Dbg(index.ToString());
if (index == panelName)
{
- DebuggingUtils.Dbg("To Focused");
+ DebuggingUtils.Dbg(index.ToString() + " To Focused");
item.ChangeStatus("focused");
}
else
{
- DebuggingUtils.Dbg("To Default");
+ DebuggingUtils.Dbg(index.ToString() + " To Default");
item.ChangeStatus("default");
}
xmlns:Views="clr-namespace:TVHome.Views"
xmlns:ViewModels="clr-namespace:TVHome.ViewModels"
xmlns:Controls="clr-namespace:TVHome.Controls"
- Appearing="OnAppearing"
CurrentStatus="{Binding CurrentStatus}"
SelectedMenuName="{Binding SelectedMenuName}">
<ContentPage.BindingContext>
SubPanelDictionary.Add(HomeMenuItem.Recent, RecentSubPanel);
SubPanelDictionary.Add(HomeMenuItem.Apps, AppsSubPanel);
SubPanelDictionary.Add(HomeMenuItem.Settings, SettingsSubPanel);
+
+ RecentSubPanel.HidePanel();
+ AppsSubPanel.ShowPanel();
+ SettingsSubPanel.HidePanel();
+
PropertyChanged += MainPage_PropertyChanged;
App.SetHomeKeyListener((e, arg) =>
{
//UnpinAppShortcutInfo(appId);
});
+
+ MessagingCenter.Subscribe<App, TVHomeStatus>(this, App.AppStatus, (sender, arg) =>
+ {
+ if (arg == TVHomeStatus.OnSleep)
+ {
+ PageMainPanel.InitialFocusing();
+ }
+ });
}
private void MainPage_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
- DebuggingUtils.Dbg(e.PropertyName);
if (e.PropertyName.CompareTo("CurrentStatus") == 0)
{
SetCurrentStatus(CurrentStatus);
private void SelectMenu(HomeMenuItem panelName)
{
- if (panelName == HomeMenuItem.NotSelected)
+ foreach (var panelItem in SubPanelDictionary)
{
- return;
+ panelItem.Value.HidePanel();
}
- IEnumerable<Panel> panels = from pair in SubPanelDictionary
- where pair.Key != panelName
- select pair.Value;
-
- foreach (Panel panel in panels)
+ if (panelName == HomeMenuItem.NotSelected)
{
- panel.HidePanel();
+ return;
}
SubPanelDictionary[panelName].ShowPanel();
}
- private void OnAppearing(object sender, EventArgs e)
- {
- PageMainPanel.InitialFocusing();
- }
-
private void UnpinAppShortcutInfo(string appId)
{
RemovePinnedApp(appId);
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=BackgroundBox ,Property=Width, Factor=0.28858}"
Text="No Content to display"
HorizontalTextAlignment="Center"
- FontSize="56"
+ FontSize="40"
TextColor="White" />
</RelativeLayout>
</RelativeLayout>