private static int WindowHeight = NUIApplication.GetDefaultWindow().Size.Height;
private static int TaskBarHeight = (80 * WindowHeight) / 1080;
- private static int SharePanelHeight = (368 * WindowHeight) / 1080;
- private static int SharePanelWidth = WindowWidth;
+ public static int SharePanelHeight = (368 * WindowHeight) / 1080;
+ public static int SharePanelWidth = WindowWidth;
+ public static int SharePanelCornerRadius = (28 * WindowHeight) / 1080;
private static int OuterViewWidth = WindowWidth;
private static int OuterViewHeight = WindowHeight - TaskBarHeight - SharePanelHeight;
public static Size SharePanelSize = new Size2D(SharePanelWidth, SharePanelHeight);
public static int SharePanelPositionY = WindowHeight - SharePanelHeight - TaskBarHeight;
+
public static int TopViewWidth = WindowWidth;
public static int TopViewHeight = (int)((90 * WindowHeight) / 1080);
- public static int SharePanelCornerRadius = (28 * WindowHeight) / 1080;
public static int HeaderWidth = (WindowWidth * 9) / 10;
public static float TextPointSize = (14.5f * 1080) / WindowHeight;
public static Size OuterViewSize = new Size2D(OuterViewWidth, OuterViewHeight);
public static int CloseButtonHeight = (int)((80 * WindowHeight) / 1080);
public static Size CloseButtonSize = new Size2D(CloseButtonWidth, CloseButtonHeight);
+ private static int OptionsViewWidth = WindowWidth;
+ private static int OptionsViewHeight = SharePanelHeight - TopViewHeight;
+ public static Size OptionsViewSize = new Size2D(OptionsViewWidth, OptionsViewHeight);
+
+ private static int ItemHeight = (int)((116 * 368) / SharePanelHeight);
+ private static int ItemWidth = (int)((116 * 1920) / SharePanelWidth);
+ private static int ItemIconSideLength = ItemWidth;
+ private static int ItemLabelWidth = ItemWidth;
+ private static int ItemLabelHeight = (int)((20 * WindowHeight) / 1080);
+ public static Size ItemSize = new Size2D(ItemWidth, ItemHeight);
+ public static Size ItemIconSize = new Size2D(ItemIconSideLength, ItemIconSideLength);
+ public static Size ItemLabelSize = new Size2D(ItemLabelWidth, ItemLabelHeight);
+
+ public static int BluetoothIconLength = (116 * WindowHeight) / 1080;
+ public static Size BluetoothIconSize = new Size2D(BluetoothIconLength, BluetoothIconLength);
+
public static string KEY_BACK = "XF86Back";
public static string KEY_ESCAPE = "Escape";
+ public static string KEY_PATH = "http://tizen.org/appcontrol/data/path";
+ public static string SINGLE_SHARE = "http://tizen.org/appcontrol/operation/share";
+ public static string MULTI_SHARE = "http://tizen.org/appcontrol/operation/multi_share";
}
}
\ No newline at end of file
-using Tizen.NUI;
-
-namespace SharePanel.Common
+namespace SharePanel.Common
{
static class Logger
{
--- /dev/null
+using SharePanel.Common;
+using System;
+using System.Collections.Generic;
+using Tizen.Applications;
+using Tizen.Applications.Exceptions;
+
+namespace SharePanel.Core
+{
+ internal class AppLauncher
+ {
+ public static void LaunchApplication(string id)
+ {
+ List<string> files = Program.fileList;
+ const string key = "http://tizen.org/appcontrol/data/path";
+
+ foreach (string file in files)
+ {
+ Logger.Debug("Filename in bluetooth launcher is " + file);
+ }
+
+ AppControl appControl = new AppControl()
+ {
+ ApplicationId = id,
+ Operation = AppControlOperations.Default,
+ };
+
+ string shareOption;
+
+ if (files.Count > 1)
+ {
+ shareOption = AppConstants.MULTI_SHARE;
+ }
+ else
+ {
+ shareOption = AppConstants.SINGLE_SHARE;
+ }
+
+ appControl.Operation = shareOption;
+
+ if (files.Count == 1)
+ {
+ appControl.Uri = files[0];
+ }
+ else
+ {
+ appControl.ExtraData.Add(key, files);
+ }
+
+ SendLaunchRequest(appControl);
+ }
+
+ private static void SendLaunchRequest(AppControl appControl)
+ {
+ try
+ {
+ AppControl.SendLaunchRequest(appControl);
+ Logger.Info("App Launched Successfully");
+ }
+ catch (LaunchRejectedException e)
+ {
+ Logger.Error("Launch Exception" + e.Message);
+ }
+ catch (ArgumentException e)
+ {
+ Logger.Error("Argument is invalid" + e.Message);
+ }
+ catch (AppNotFoundException e)
+ {
+ Logger.Error("App not found" + e.Message);
+ }
+ catch (LaunchFailedException e)
+ {
+ Logger.Error("Launch failed" + e.Message);
+ }
+ catch (Tizen.Applications.Exceptions.OutOfMemoryException e)
+ {
+ Logger.Error("Out of memory" + e.Message);
+ }
+ catch (PermissionDeniedException e)
+ {
+ Logger.Error("Permission denied" + e.Message);
+ }
+ catch (TimeoutException e)
+ {
+ Logger.Error("App timeout" + e.Message);
+ }
+ catch (Exception e) {
+ Logger.Error("Unknown exception"+ e.Message);
+ }
+ }
+ }
+}
--- /dev/null
+using SharePanel.Common;
+using SharePanel.Core;
+using System;
+using System.Windows.Input;
+using Tizen.NUI.Binding;
+
+namespace SharePanel.Models
+{
+ internal class ItemModel : PropertyNotifier
+ {
+ public event Action CloseApplication;
+
+ private string iconURL;
+ public string IconURL
+ {
+ get => iconURL;
+ set => SetProperty(ref iconURL, value);
+ }
+
+ private string label;
+ public string Label
+ {
+ get => label;
+ set => SetProperty(ref label, value);
+ }
+
+ private string appID;
+ public string AppID
+ {
+ get { return appID; }
+ set { appID = value; }
+ }
+
+ private ICommand iconClicked;
+ public ICommand IconClicked
+ {
+ get => iconClicked;
+ set => SetProperty(ref iconClicked, value);
+ }
+
+ public ItemModel(string iconURL, string label, string appID)
+ {
+ IconURL = iconURL;
+ Label = label;
+ AppID = appID;
+ IconClicked = new Command(OnIconClicked);
+ }
+
+ public void OnIconClicked()
+ {
+ Logger.Info(label + " button clicked, Launching: " + appID);
+ CloseApplication?.Invoke();
+ AppLauncher.LaunchApplication(appID);
+ }
+ }
+}
using Tizen.NUI;
using SharePanel.Common;
using SharePanel.Views;
+using System.Collections.Generic;
+using Tizen.Applications;
namespace SharePanel
{
class Program : NUIApplication
{
private Window defaultWindow;
+ public static List<string> fileList;
protected override void OnCreate()
{
}
}
+ protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
+ {
+ ReceivedAppControl control = e.ReceivedAppControl;
+ string caller = control.ApplicationId;
+
+ fileList = new List<string>();
+ string key = AppConstants.KEY_PATH;
+
+ if (control.Uri != null)
+ {
+ string filename = control.Uri.ToString();
+ fileList.Add(filename);
+ Logger.Debug("Filename is " + filename);
+ }
+ else if (control.ExtraData != null)
+ {
+ fileList = (List<string>)control.ExtraData.Get(key);
+ for (int i = 0; i < fileList.Count; i++)
+ {
+ Logger.Debug("Filename is " + fileList[i]);
+ }
+ }
+ }
+
static void Main(string[] args)
{
var app = new Program();
using SharePanel.Common;
+using SharePanel.Models;
using System.Collections;
using System.Collections.Generic;
using System.Windows.Input;
namespace SharePanel.ViewModels
{
- internal class SharePanelViewModel: PropertyNotifier
+ internal class SharePanelViewModel : PropertyNotifier
{
private ICommand closeClicked;
private IEnumerable itemModelList;
public SharePanelViewModel()
{
CloseClicked = new Command(onCloseClicked);
+ GetItemList();
}
public ICommand CloseClicked
Logger.Info("Closing Share Panel");
Application.Current.Exit();
}
+
+ private void GetItemList()
+ {
+ List<ItemModel> items = new List<ItemModel>();
+
+ ApplicationInfo bluetoothAppInfo = new ApplicationInfo("ug-bluetooth-efl");
+ ItemModel item = new ItemModel(bluetoothAppInfo.IconPath, bluetoothAppInfo.Label, bluetoothAppInfo.ApplicationId);
+ item.CloseApplication += onCloseClicked;
+ items.Add(item);
+
+ ItemModelList = items;
+ }
}
}
--- /dev/null
+using SharePanel.Common;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+
+namespace SharePanel.Views
+{
+ internal class ItemView : View
+ {
+ public Button button;
+ public TextLabel label;
+ public ItemView()
+ {
+ Size = AppConstants.ItemSize;
+ Layout = new LinearLayout
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ CellPadding = new Size2D(0, 30)
+ };
+ AddButton();
+ AddLabel();
+ }
+
+ public void AddButton()
+ {
+ button = new Button()
+ {
+ Size = AppConstants.ItemSize,
+ BackgroundColor = Color.White
+ };
+ Add(button);
+ }
+
+ public void AddLabel()
+ {
+ label = new TextLabel()
+ {
+ PointSize = (6.6f * 368) / AppConstants.SharePanelHeight,
+ };
+ Logger.Debug("Pointsize of addlabel is " + label.PointSize);
+ Add(label);
+ }
+ }
+}
public MainView()
{
- Logger.Debug("MainView()");
+ Logger.Debug("MainView Created");
Layout = new LinearLayout()
{
LinearOrientation = LinearLayout.Orientation.Vertical
AddOuterView();
AddSharePanel();
+ Logger.Debug("Share Panel Launched Successfully");
}
private void AddOuterView()
{
- Logger.Debug("AddOuterView(): Outer View Created");
-
outerView = new View()
{
Size = AppConstants.OuterViewSize,
- Layout = new LinearLayout
- {
- LinearOrientation = LinearLayout.Orientation.Vertical,
- HorizontalAlignment = HorizontalAlignment.Center,
- }
+ AllowOnlyOwnTouch = true,
};
-
- outerView.BackgroundColor = Color.Transparent;
+ outerView.TouchEvent += OnOuterViewTouched;
Add(outerView);
+ Logger.Info("Outer View Created");
}
private void AddSharePanel()
{
- Logger.Debug("AddSharePanel(): Share Panel View Created");
-
viewModel = new SharePanelViewModel();
sharePanelView = new SharePanelView();
sharePanelView.BindingContext = viewModel;
sharePanelView.closeButton.SetBinding(Control.CommandProperty, "CloseClicked");
+ sharePanelView.SetBinding(SharePanelView.ItemModelListProperty, "ItemModelList");
Add(sharePanelView);
+ Logger.Info("Share Panel View Created");
}
private bool OnOuterViewTouched(object sender, TouchEventArgs e)
-using Tizen.NUI;
+using SharePanel.Common;
+using SharePanel.Models;
+using System.Collections;
+using System.Collections.Generic;
+using Tizen.NUI;
+using Tizen.NUI.Binding;
using Tizen.NUI.Components;
using Tizen.NUI.BaseComponents;
-using SharePanel.Common;
-using System.Reflection.PortableExecutable;
namespace SharePanel.Views
{
private View headerView;
public Button closeButton;
public TextLabel header;
+ private View optionView;
+
+ private List<ItemView> items;
+ private IEnumerable itemModelList;
public SharePanelView()
{
Size = AppConstants.SharePanelSize;
- BackgroundColor = Color.White;
PositionY = AppConstants.SharePanelPositionY;
+ BackgroundColor = Color.White;
CornerRadius = AppConstants.SharePanelCornerRadius;
Layout = new LinearLayout
LinearOrientation = LinearLayout.Orientation.Vertical,
HorizontalAlignment = HorizontalAlignment.Center,
};
-
+ items = new List<ItemView>();
AddTopBar();
+ AddOptionView();
}
+ public IEnumerable ItemModelList
+ {
+ get => GetValue(ItemModelListProperty) as IEnumerable;
+ set => SetValue(ItemModelListProperty, value);
+ }
+
+ public static readonly BindableProperty ItemModelListProperty = BindableProperty.Create(
+ nameof(ItemModelList),
+ typeof(IEnumerable),
+ typeof(SharePanelView),
+ null,
+ propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ SharePanelView instance = bindable as SharePanelView;
+ if (oldValue != newValue)
+ {
+ if (oldValue != null)
+ {
+ (oldValue as List<object>).Clear();
+ }
+ if (newValue != null)
+ {
+ instance.itemModelList = newValue as IEnumerable;
+ instance.UpdateOptions();
+ }
+ }
+ },
+ defaultValueCreator: (bindable) => (bindable as SharePanelView).itemModelList
+ );
+
public void AddTopBar()
{
topBar = new View
Add(topBar);
}
+ public void AddCloseButton()
+ {
+ closeButton = new Button()
+ {
+ IconURL = "*Resource*/Images/close.png",
+ Size = AppConstants.CloseButtonSize,
+ CornerRadius = AppConstants.SharePanelCornerRadius,
+ BackgroundColor = Color.White,
+ CellHorizontalAlignment = HorizontalAlignmentType.Right
+ };
+ topBar.Add(closeButton);
+ }
+
public void AddHeaderView()
{
headerView = new View()
topBar.Add(headerView);
}
- public void AddCloseButton()
+ public void AddOptionView()
{
- closeButton = new Button()
+ optionView = new View()
{
- IconURL = "*Resource*/Images/close.png",
- Size = AppConstants.CloseButtonSize,
- CornerRadius = AppConstants.SharePanelCornerRadius,
- BackgroundColor = Color.White,
- CellHorizontalAlignment = HorizontalAlignmentType.Right
+ Layout = new LinearLayout
+ {
+ LinearOrientation = LinearLayout.Orientation.Horizontal,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ CellPadding = new Size2D(0, 30)
+ },
+ Size = AppConstants.OptionsViewSize,
+ Margin = 30
};
- topBar.Add(closeButton);
+ Add(optionView);
+ }
+
+ public void UpdateOptions()
+ {
+ if (items == null)
+ {
+ return;
+ }
+ foreach (ItemView item in items)
+ {
+ item.BindingContext = null;
+ optionView.Remove(item);
+ item.Dispose();
+ }
+ items.Clear();
+
+ foreach (ItemModel model in ItemModelList)
+ {
+ ItemView itemView = new ItemView();
+ itemView.BindingContext = model;
+ itemView.button.Icon.SetBinding(ImageView.ResourceUrlProperty, "IconURL");
+ itemView.button.SetBinding(Control.CommandProperty, "IconClicked");
+ itemView.label.SetBinding(TextLabel.TextProperty, "Label");
+ items.Add(itemView);
+ optionView.Add(itemView);
+ }
}
}
}
\ No newline at end of file
<label>share-panel</label>
<icon>SharePanel.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/appmanager.launch</privilege>
+ </privileges>
+ <dependencies />
+ <provides-appdefined-privileges />
</manifest>