-
Notifications
You must be signed in to change notification settings - Fork 224
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
Sample App IMEManager #362
Open
AbedalrahmanRasem
wants to merge
1
commit into
Samsung:master
Choose a base branch
from
AbedalrahmanRasem:sampleapps_IMEManager
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+582
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net6.0-tizen</TargetFramework> | ||
<OutputType>Exe</OutputType> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Folder Include="res\images\" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 17 | ||
VisualStudioVersion = 17.4.33122.133 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IMEManager", "IMEManager.csproj", "{DF8F0922-5A9F-4E9A-9328-8550F210E178}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{DF8F0922-5A9F-4E9A-9328-8550F210E178}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{DF8F0922-5A9F-4E9A-9328-8550F210E178}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{DF8F0922-5A9F-4E9A-9328-8550F210E178}.Debug|Any CPU.Deploy.0 = Debug|Any CPU | ||
{DF8F0922-5A9F-4E9A-9328-8550F210E178}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{DF8F0922-5A9F-4E9A-9328-8550F210E178}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{DF8F0922-5A9F-4E9A-9328-8550F210E178}.Release|Any CPU.Deploy.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {2C0EFC83-798D-4A7F-9B2B-BAFB078CA32B} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,311 @@ | ||
using System.Collections.Generic; | ||
using Tizen.NUI; | ||
using Tizen.NUI.BaseComponents; | ||
using Tizen.NUI.Components; | ||
using Tizen.NUI.Binding; | ||
using System; | ||
using Tizen.Uix.InputMethodManager; | ||
|
||
namespace IMEManager | ||
{ | ||
public class Operations | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you may add more comments to pass the self-verification process. |
||
{ | ||
public Operations(string name) | ||
{ | ||
Name = name; | ||
} | ||
|
||
public string Name { get; set; } | ||
|
||
public string ViewLabel | ||
{ | ||
get | ||
{ | ||
return Name; | ||
} | ||
} | ||
|
||
public bool Selected { get; set; } | ||
} | ||
internal class Program : NUIApplication | ||
{ | ||
private Window window; | ||
private Navigator navigator; | ||
private AppBar mainAppBar, customAppBar; | ||
private ContentPage mainPage, customPage; | ||
private View mainView, customView; | ||
private CollectionView mainCollectionView; | ||
private List<Operations> operations = new List<Operations> { new Operations(" ShowIMEList"), new Operations(" ShowIMESelector"), new Operations(" IsIMEEnabled"), new Operations(" GetActiveIME"), new Operations(" GetEnabledIMECount") }; | ||
TextLabel IMEStatusLabel; | ||
LinearLayout customPageLayout; | ||
|
||
protected override void OnCreate() | ||
{ | ||
base.OnCreate(); | ||
Initialize(); | ||
SetMainPage(); | ||
} | ||
|
||
public void OnKeyEvent(object sender, Window.KeyEventArgs e) | ||
{ | ||
if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape")) | ||
{ | ||
Exit(); | ||
} | ||
} | ||
|
||
void Initialize() | ||
{ | ||
//Initialize the defined variables | ||
window = GetDefaultWindow(); | ||
window.Title = "IMEManager"; | ||
window.KeyEvent += OnKeyEvent; | ||
navigator = window.GetDefaultNavigator(); | ||
var statusLabelTextStyle = new PropertyMap(); | ||
statusLabelTextStyle.Add("slant", new PropertyValue(FontSlantType.Normal.ToString())); | ||
statusLabelTextStyle.Add("width", new PropertyValue(FontWidthType.Expanded.ToString())); | ||
statusLabelTextStyle.Add("weight", new PropertyValue(FontWeightType.Light.ToString())); | ||
IMEStatusLabel = new TextLabel() | ||
{ | ||
HeightSpecification = LayoutParamPolicies.MatchParent, | ||
WidthSpecification = LayoutParamPolicies.MatchParent, | ||
VerticalAlignment = VerticalAlignment.Center, | ||
HorizontalAlignment = HorizontalAlignment.Center, | ||
TextColor = Color.Black, | ||
PointSize = 10f, | ||
FontStyle = statusLabelTextStyle, | ||
}; | ||
customPageLayout = new LinearLayout() | ||
{ | ||
LinearOrientation = LinearLayout.Orientation.Vertical, | ||
HorizontalAlignment = HorizontalAlignment.Center, | ||
VerticalAlignment = VerticalAlignment.Center, | ||
}; | ||
} | ||
|
||
//This function will be called when the event clicked or select. | ||
public void OnSelectionChanged(object sender, SelectionChangedEventArgs ev) | ||
{ | ||
Console.WriteLine($"@@@ OnSelectionChanged() {ev.CurrentSelection}"); | ||
|
||
customView.Layout = customPageLayout; | ||
|
||
foreach (object item in ev.CurrentSelection) | ||
{ | ||
if (item == null) | ||
{ | ||
break; | ||
} | ||
|
||
var selItem = item as Operations; | ||
|
||
if (selItem.Name == " ShowIMEList") | ||
{ | ||
try | ||
{ | ||
customView.ClearBackground(); | ||
IMEStatusLabel.Text = "ShowIMEList"; | ||
customView.Add(IMEStatusLabel); | ||
Manager.ShowIMEList(); | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine(e.Message); | ||
Exit(); | ||
} | ||
|
||
} | ||
else if (selItem.Name == " ShowIMESelector") | ||
{ | ||
try | ||
{ | ||
customView.ClearBackground(); | ||
IMEStatusLabel.Text = "ShowIMESelection"; | ||
customView.Add(IMEStatusLabel); | ||
Manager.ShowIMESelector(); | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine(e.Message); | ||
Exit(); | ||
} | ||
} | ||
else if (selItem.Name == " IsIMEEnabled") | ||
{ | ||
try | ||
{ | ||
customView.ClearBackground(); | ||
bool IMEEnabled = Manager.IsIMEEnabled(this.ApplicationInfo.ApplicationId); | ||
string status = IMEEnabled ? " ON" : "Off"; | ||
IMEStatusLabel.Text = "IME State : " + status; | ||
customView.Add(IMEStatusLabel); | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine(e.Message); | ||
Exit(); | ||
} | ||
} | ||
else if (selItem.Name == " GetActiveIME") | ||
{ | ||
try | ||
{ | ||
customView.ClearBackground(); | ||
IMEStatusLabel.Text = "IME Active : " + Manager.GetActiveIME(); | ||
customView.Add(IMEStatusLabel); | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine(e.Message); | ||
Exit(); | ||
} | ||
} | ||
else if (selItem.Name == " GetEnabledIMECount") | ||
{ | ||
try | ||
{ | ||
customView.ClearBackground(); | ||
IMEStatusLabel.Text = "IME Count : " + Manager.GetEnabledIMECount(); | ||
customView.Add(IMEStatusLabel); | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine(e.Message); | ||
Exit(); | ||
} | ||
} | ||
} | ||
navigator.Push(customPage); | ||
} | ||
|
||
private void SetMainPage() | ||
{ | ||
//Setting the AppBar variable. | ||
var mainAppBarTextStyle = new PropertyMap(); | ||
mainAppBarTextStyle.Add("slant", new PropertyValue(FontSlantType.Normal.ToString())); | ||
mainAppBarTextStyle.Add("width", new PropertyValue(FontWidthType.Expanded.ToString())); | ||
mainAppBarTextStyle.Add("weight", new PropertyValue(FontWeightType.Medium.ToString())); | ||
mainAppBar = new() | ||
{ | ||
TitleContent = new TextLabel() | ||
{ | ||
HeightSpecification = LayoutParamPolicies.MatchParent, | ||
WidthSpecification = LayoutParamPolicies.MatchParent, | ||
VerticalAlignment = VerticalAlignment.Center, | ||
HorizontalAlignment = HorizontalAlignment.Center, | ||
TextColor = Color.White, | ||
PointSize = 12, | ||
Text = "IMEManager", | ||
FontStyle = mainAppBarTextStyle, | ||
}, | ||
AutoNavigationContent = false, | ||
SizeWidth = window.Size.Width, | ||
SizeHeight = window.Size.Height / 12, | ||
BackgroundColor = Color.Transparent, | ||
WidthSpecification = LayoutParamPolicies.MatchParent, | ||
ActionContent = new View(), | ||
NavigationContent = new View(), | ||
}; | ||
|
||
//Creating the mainView to display for the user. | ||
mainView = new() | ||
{ | ||
Layout = new LinearLayout() | ||
{ | ||
LinearOrientation = LinearLayout.Orientation.Vertical, | ||
}, | ||
|
||
//Without adding specification items will now show in the collection | ||
WidthSpecification = LayoutParamPolicies.MatchParent, | ||
HeightSpecification = LayoutParamPolicies.MatchParent, | ||
BackgroundColor = Color.White, | ||
}; | ||
|
||
//Putting all galleries in collection as list to display it . | ||
mainCollectionView = new() | ||
{ | ||
ItemsSource = operations, | ||
ItemsLayouter = new LinearLayouter(), | ||
ItemTemplate = new DataTemplate(() => | ||
{ | ||
DefaultLinearItem item = new DefaultLinearItem() | ||
{ | ||
WidthSpecification = LayoutParamPolicies.MatchParent, | ||
}; | ||
item.Label.SetBinding(TextLabel.TextProperty, "ViewLabel"); | ||
item.Label.HorizontalAlignment = HorizontalAlignment.Begin; | ||
item.SizeHeight = window.Size.Height / 8; | ||
//BaseComponents' Focusable is false as a default value, true should be set to navigate key focus. | ||
return item; | ||
|
||
}), | ||
ScrollingDirection = ScrollableBase.Direction.Vertical, | ||
HideScrollbar = true, | ||
WidthSpecification = LayoutParamPolicies.MatchParent, | ||
HeightSpecification = LayoutParamPolicies.MatchParent, | ||
SelectionMode = ItemSelectionMode.Single,//For selecting only one item from list. | ||
}; | ||
|
||
//When the event SelectionChanged ocures will cal the function OnSelectionChanged. | ||
mainCollectionView.SelectionChanged += OnSelectionChanged; | ||
|
||
//The custom appbar will have a back button this is the reason its created to get the user back to the main page. | ||
customAppBar = new()//every page needs a new App bar ** do not use the same app bar for more than one page | ||
{ | ||
TitleContent = new TextLabel() | ||
{ | ||
HeightSpecification = LayoutParamPolicies.MatchParent, | ||
WidthSpecification = LayoutParamPolicies.MatchParent, | ||
VerticalAlignment = VerticalAlignment.Center, | ||
HorizontalAlignment = HorizontalAlignment.Center, | ||
TextColor = Color.White, | ||
PointSize = 12, | ||
Text = "IMEManager", | ||
FontStyle = mainAppBarTextStyle, | ||
}, | ||
AutoNavigationContent = false, | ||
SizeWidth = window.Size.Width, | ||
SizeHeight = window.Size.Height / 12, | ||
BackgroundColor = Color.Transparent, | ||
WidthSpecification = LayoutParamPolicies.MatchParent, | ||
ActionContent = new View(), | ||
}; | ||
|
||
//Creating custom view for the new page which will be opened after the selection . | ||
customView = new() | ||
{ | ||
Layout = new LinearLayout() | ||
{ | ||
LinearOrientation = LinearLayout.Orientation.Vertical, | ||
}, | ||
WidthSpecification = LayoutParamPolicies.MatchParent, | ||
HeightSpecification = LayoutParamPolicies.MatchParent, | ||
}; | ||
|
||
//Custome page is the page that will be opened after the selection. | ||
//Seting the appbar and contenet for the pages. | ||
customPage = new ContentPage() | ||
{ | ||
AppBar = customAppBar, | ||
Content = customView, | ||
BackgroundImage = DirectoryInfo.Resource + "images/bg.png", | ||
}; | ||
|
||
mainView.Add(mainCollectionView); | ||
mainPage = new ContentPage() | ||
{ | ||
AppBar = mainAppBar, | ||
Content = mainView, | ||
BackgroundImage = DirectoryInfo.Resource + "images/bg.png", | ||
}; | ||
|
||
//Pushing the main page for the user. | ||
navigator.Push(mainPage); | ||
} | ||
static void Main(string[] args) | ||
{ | ||
var app = new Program(); | ||
app.Run(args); | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="org.tizen.IMEManager" version="1.0.0" api-version="7.0" xmlns="http://tizen.org/ns/packages"> | ||
<profile name="common" /> | ||
<ui-application appid="org.tizen.IMEManager" exec="IMEManager.dll" multiple="false" nodisplay="false" taskmanage="true" type="dotnet" launch_mode="single"> | ||
<label>IMEManager</label> | ||
<icon>IMEManager.png</icon> | ||
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" /> | ||
<splash-screens /> | ||
</ui-application> | ||
<shortcut-list /> | ||
<privileges> | ||
<privilege>http://tizen.org/privilege/imemanager</privilege> | ||
</privileges> | ||
<dependencies /> | ||
<provides-appdefined-privileges /> | ||
</manifest> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add copy right comments.
(ex: https://github.com/Samsung/TizenFX/blob/master/src/Tizen.NUI/src/public/Accessibility/Accessibility.cs#L1)