Implementation of Frontend and Backend Logic of SharePanel 26/320526/5
authorMd. Shahrukh Islam/NC eXperience Group /SRBD/Engineer/Samsung Electronics <shahrukh.i@samsung.com>
Mon, 18 Nov 2024 06:03:30 +0000 (12:03 +0600)
committerMd. Shahrukh Islam/NC eXperience Group /SRBD/Engineer/Samsung Electronics <shahrukh.i@samsung.com>
Mon, 18 Nov 2024 11:26:30 +0000 (17:26 +0600)
[Problem] N/A

[Cause & Measure]
 Cause : N/A
 Measure : Implemented frontend and backend of SharePanel

Change-Id: Ia1b62447a82d8b6c589b213e08832da4ed3d1179
Signed-off-by: Md. Shahrukh Islam/NC eXperience Group /SRBD/Engineer/Samsung Electronics <shahrukh.i@samsung.com>
SharePanel/SharePanel/Common/AppConstants.cs
SharePanel/SharePanel/Common/Logger.cs
SharePanel/SharePanel/Core/AppLauncher.cs [new file with mode: 0644]
SharePanel/SharePanel/Models/ItemModel.cs [new file with mode: 0644]
SharePanel/SharePanel/SharePanel.cs
SharePanel/SharePanel/ViewModels/SharePanelViewModel.cs
SharePanel/SharePanel/Views/ItemView.cs [new file with mode: 0644]
SharePanel/SharePanel/Views/MainView.cs
SharePanel/SharePanel/Views/SharePanelView.cs
SharePanel/SharePanel/tizen-manifest.xml

index 436ec154413244e739a08bdd16b5c5e0db21e238..9efa7b87be796c735032bc86749103a30b49b9c7 100644 (file)
@@ -8,17 +8,18 @@ namespace SharePanel.Common
         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);
@@ -27,7 +28,26 @@ namespace SharePanel.Common
         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
index 1bb1079e374ecc626bdd119266404e5432946d47..1a8f3a82da2ec9a4858ce61c8cc209078761fa7e 100644 (file)
@@ -1,6 +1,4 @@
-using Tizen.NUI;
-
-namespace SharePanel.Common
+namespace SharePanel.Common
 {
     static class Logger
     {
diff --git a/SharePanel/SharePanel/Core/AppLauncher.cs b/SharePanel/SharePanel/Core/AppLauncher.cs
new file mode 100644 (file)
index 0000000..aaa307b
--- /dev/null
@@ -0,0 +1,92 @@
+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);
+            }
+        }
+    }
+}
diff --git a/SharePanel/SharePanel/Models/ItemModel.cs b/SharePanel/SharePanel/Models/ItemModel.cs
new file mode 100644 (file)
index 0000000..aad4052
--- /dev/null
@@ -0,0 +1,56 @@
+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);
+        }
+    }
+}
index 9890b56cdb2baea30132a59bd6430a9ed1971129..2df0336d263edc8db2bd9ebabf79fc7d6f5988e1 100644 (file)
@@ -1,12 +1,15 @@
 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()
         {
@@ -37,6 +40,30 @@ namespace SharePanel
             }
         }
 
+        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();
index 70fc68d15b792937daf45726666fe14cddd27041..e35786afc474588412fc742c74e8cd82513de3b3 100644 (file)
@@ -1,4 +1,5 @@
 using SharePanel.Common;
+using SharePanel.Models;
 using System.Collections;
 using System.Collections.Generic;
 using System.Windows.Input;
@@ -7,7 +8,7 @@ using Tizen.NUI.Binding;
 
 namespace SharePanel.ViewModels
 {
-    internal class SharePanelViewModel: PropertyNotifier
+    internal class SharePanelViewModel : PropertyNotifier
     {
         private ICommand closeClicked;
         private IEnumerable itemModelList;
@@ -15,6 +16,7 @@ namespace SharePanel.ViewModels
         public SharePanelViewModel()
         {
             CloseClicked = new Command(onCloseClicked);
+            GetItemList();
         }
 
         public ICommand CloseClicked
@@ -34,5 +36,17 @@ namespace SharePanel.ViewModels
             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;
+        }
     }
 }
diff --git a/SharePanel/SharePanel/Views/ItemView.cs b/SharePanel/SharePanel/Views/ItemView.cs
new file mode 100644 (file)
index 0000000..5d108f7
--- /dev/null
@@ -0,0 +1,45 @@
+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);
+        }
+    }
+}
index 931090e6258f676f41042b942e29f2fd76a92591..78eab0ced5a170e903389a2b48371e5ce3e2027e 100644 (file)
@@ -15,7 +15,7 @@ namespace SharePanel.Views
 
         public MainView()
         {
-            Logger.Debug("MainView()");
+            Logger.Debug("MainView Created");
             Layout = new LinearLayout()
             {
                 LinearOrientation = LinearLayout.Orientation.Vertical
@@ -23,37 +23,32 @@ namespace SharePanel.Views
 
             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)
index d71cc76917935c51a44fad985820aee641f84b29..ceedcd10b201dbf762563c0926a63b91804b88cf 100644 (file)
@@ -1,8 +1,11 @@
-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
 {
@@ -12,12 +15,16 @@ 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
@@ -25,10 +32,41 @@ namespace SharePanel.Views
                 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
@@ -48,6 +86,19 @@ namespace SharePanel.Views
             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()
@@ -77,17 +128,46 @@ namespace SharePanel.Views
             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
index e54f82f6e8a9ab15386d8526d6d1ddfab644120b..9c08db53c068feb675e946555ba45cd2ef932625 100644 (file)
@@ -5,5 +5,12 @@
     <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>