Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mobile][NUI] AppHistory sample appliction #365

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Mobile/NUI/AppHistory/.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

arg_file_template = ""
buildconfig = "//build/BUILDCONFIG.gn"
root = "//build:"
script_executable = ""
secondary_source = "//build"
27 changes: 27 additions & 0 deletions Mobile/NUI/AppHistory/AppHistory.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31005.135
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppHistory", "AppHistory\AppHistory.csproj", "{5e07eb0b-d8d8-4a68-a9f8-60eed77e6f3f}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{d18319e3-b056-4369-9933-afae8a659515}"
ProjectSection(SolutionItems) = preProject
tizen_workspace.yaml = tizen_workspace.yaml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5e07eb0b-d8d8-4a68-a9f8-60eed77e6f3f}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5e07eb0b-d8d8-4a68-a9f8-60eed77e6f3f}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5e07eb0b-d8d8-4a68-a9f8-60eed77e6f3f}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5e07eb0b-d8d8-4a68-a9f8-60eed77e6f3f}.Release|Any CPU.Build.0 = Release|Any CPU

EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
50 changes: 50 additions & 0 deletions Mobile/NUI/AppHistory/AppHistory/AppHistory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.NUI;
using Tizen.NUI.Components;

namespace AppHistory
{
public class Program : NUIApplication
{
protected override void OnCreate()
{
base.OnCreate();
Window window = Window.Instance;
window.BackgroundColor = Color.Blue;
window.KeyEvent += OnKeyEvent;

Navigator navigator = window.GetDefaultNavigator();

MainPage page = new MainPage();
navigator.Push(page);
}

public void OnKeyEvent(object sender, Window.KeyEventArgs e)
{
if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape"))
{
Exit();
}
}

static void Main(string[] args)
{
var app = new Program();
app.Run(args);
}
}
}
39 changes: 39 additions & 0 deletions Mobile/NUI/AppHistory/AppHistory/AppHistory.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<Project Sdk="Tizen.NET.Sdk/1.1.9">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>tizen10.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>portable</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>None</DebugType>
</PropertyGroup>
<ItemGroup>
<None Remove="res\layout\AppInfoPage.xaml" />
</ItemGroup>

<ItemGroup>
<Folder Include="lib\" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="res\layout\MainPage.xaml">
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
<EmbeddedResource Include="res\layout\AppInfoPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Tizen.NUI.XamlBuild" Version="1.0.34" />
</ItemGroup>

<PropertyGroup>
<NeedInjection>True</NeedInjection>
</PropertyGroup>

</Project>
92 changes: 92 additions & 0 deletions Mobile/NUI/AppHistory/AppHistory/AppInfoPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.NUI;
using Tizen.NUI.Components;
using Tizen.NUI.BaseComponents;
using Tizen.NUI.Binding;
using AppHistory.ViewModel;

namespace AppHistory
{
public partial class AppInfoPage : ContentPage
{
public AppInfoPage(ListType listType)
{
InitializeComponent();

BindingContext = new AppInfoPageViewModel(listType);

ColView.ItemTemplate = new Tizen.NUI.Binding.DataTemplate(() =>
{
var item = new RecyclerViewItem()
{
WidthSpecification = LayoutParamPolicies.MatchParent,
Layout = new FlexLayout
{
Direction = FlexLayout.FlexDirection.Column,
Justification = FlexLayout.FlexJustification.SpaceBetween,
}
};

var firstLabel = new TextLabel()
{
WidthSpecification = LayoutParamPolicies.MatchParent,
TextColor = Color.Black
};
firstLabel.SetBinding(TextLabel.TextProperty, "Name");
item.Add(firstLabel);

var secondLabel = new TextLabel()
{
WidthSpecification = LayoutParamPolicies.MatchParent,
TextColor = Color.Gray
};
secondLabel.SetBinding(TextLabel.TextProperty, "Information");
item.Add(secondLabel);
return item;
});
}

/// <summary>
/// User needs to implement this, if required
/// </summary>
/// <param name="type">dispose type</param>
protected override void Dispose(DisposeTypes type)
{
if (Disposed)
{
return;
}

ExitXaml();

if (type == DisposeTypes.Explicit)
{
//Todo: Called by User
//Release your own managed resources here.
//You should release all of your own disposable objects here.

}

//Todo: Release your own unmanaged resources here.
//You should not access any managed member here except static instance.
//because the execution order of Finalizes is non-deterministic.


base.Dispose(type);
}
}
}
21 changes: 21 additions & 0 deletions Mobile/NUI/AppHistory/AppHistory/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!--
***********************************************************************************************
<Build.Directory.targets>
WARNING: DO NOT MODIFY this file. Incorrect changes to this file will make it
impossible to load or build your projects from the IDE.

***********************************************************************************************
-->

<Project>
<Target Name="BuildDotnet" AfterTargets="TizenPackage" >
<Message Text="Tizen Build starts here ------------" Importance="high"/>
<Message Text="$(MSBuildProjectDirectory)" Importance="high"/>
<PropertyGroup>
<WorkspaceFolder>$([System.IO.Path]::GetDirectoryName($(MSBuildProjectDirectory)))</WorkspaceFolder>
</PropertyGroup>
<Message Text="Workspace: '$(WorkspaceFolder)'" Importance="high" />

<Exec Command="C:\tizen-studio\tools\tizen-core\tz.exe pack -S $(ProjectDir) $(WorkspaceFolder)"> </Exec>
</Target>
</Project>
128 changes: 128 additions & 0 deletions Mobile/NUI/AppHistory/AppHistory/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
* Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.NUI;
using Tizen.NUI.Components;
using Tizen.NUI.BaseComponents;
using Tizen.Security;
using Tizen.NUI.Binding;
using AppHistory.ViewModel;
using System.Linq;

namespace AppHistory
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
CheckPermission();

BindingContext = new MainPageViewModel();

ColView.ItemTemplate = new Tizen.NUI.Binding.DataTemplate(() =>
{
var item = new RecyclerViewItem()
{
WidthSpecification = LayoutParamPolicies.MatchParent,
Layout = new FlexLayout
{
Direction = FlexLayout.FlexDirection.Column,
Justification = FlexLayout.FlexJustification.SpaceBetween,
}
};

item.Clicked += OnClicked;

var firstLabel = new TextLabel()
{
WidthSpecification = LayoutParamPolicies.MatchParent,
TextColor = Color.Black
};
firstLabel.SetBinding(TextLabel.TextProperty, "FirstLine");
item.Add(firstLabel);

var secondLabel = new TextLabel()
{
WidthSpecification = LayoutParamPolicies.MatchParent,
TextColor = Color.Gray
};
secondLabel.SetBinding(TextLabel.TextProperty, "SecondLine");
item.Add(secondLabel);
return item;
});
}

private void OnClicked(object sender, ClickedEventArgs e)
{
ListType listType = ListType.Battery;
switch (((sender as RecyclerViewItem).Children.First() as TextLabel).Text)
{
case "Top 10 frequently used applications":
listType = ListType.Frequently;
break;
case "Top 5 recently used applications":
listType = ListType.Recently;
break;
}
Navigator?.PushWithTransition(new AppInfoPage(listType));
}

private void CheckPermission()
{
CheckResult result = PrivacyPrivilegeManager.CheckPermission("http://tizen.org/privilege/apphistory.read");

switch (result)
{
case CheckResult.Allow:
break;
case CheckResult.Deny:
break;
case CheckResult.Ask:
PrivacyPrivilegeManager.RequestPermission("http://tizen.org/privilege/apphistory.read");
break;
}
}

/// <summary>
/// User needs to implement this, if required
/// </summary>
/// <param name="type">dispose type</param>
protected override void Dispose(DisposeTypes type)
{
if (Disposed)
{
return;
}

ExitXaml();

if (type == DisposeTypes.Explicit)
{
//Todo: Called by User
//Release your own managed resources here.
//You should release all of your own disposable objects here.

}

//Todo: Release your own unmanaged resources here.
//You should not access any managed member here except static instance.
//because the execution order of Finalizes is non-deterministic.


base.Dispose(type);
}
}
}
Loading