From 5deb4fd084ef7252fb28afb0ec06be8173ec6a69 Mon Sep 17 00:00:00 2001 From: Joel Wetzell Date: Sun, 4 Aug 2019 15:57:25 -0500 Subject: [PATCH] * MainActivity.cs: * AndroidManifest.xml: Android: Bind to WIFI * ControlPage.xaml.cs: * QCueListCell.cs: * OSCListItem.cs: Add sub-cues in cue listing * qController.csproj: Update --- Droid/MainActivity.cs | 18 +++++ Droid/Properties/AndroidManifest.xml | 2 + .../Classes/Cell/QCueListCell.cs | 79 +++++++++++++++---- .../Classes/Settings/OSCListItem.cs | 11 +++ .../Pages/ControlPage.xaml.cs | 4 +- qController.Standard/qController.csproj | 2 +- 6 files changed, 96 insertions(+), 20 deletions(-) create mode 100644 qController.Standard/Classes/Settings/OSCListItem.cs diff --git a/Droid/MainActivity.cs b/Droid/MainActivity.cs index 5f930ad..cb73f0f 100644 --- a/Droid/MainActivity.cs +++ b/Droid/MainActivity.cs @@ -7,6 +7,7 @@ using Android.Runtime; using Android.Views; using Android.Widget; using Android.OS; +using Android.Net; namespace qController.Droid { @@ -25,6 +26,23 @@ namespace qController.Droid LoadApplication(new App()); Acr.UserDialogs.UserDialogs.Init(this); + if (Build.VERSION.SdkInt >= BuildVersionCodes.M) + { + ConnectivityManager connMgr = (ConnectivityManager)Application.Context.GetSystemService(Context.ConnectivityService); + connMgr.BindProcessToNetwork(null); + Console.WriteLine(connMgr.GetAllNetworks().Length); + Network[] networks = connMgr.GetAllNetworks(); + for (int i = 0; i < networks.Length; i++) + { + Network network = networks[i]; + NetworkInfo networkInfo = connMgr.GetNetworkInfo(network); + if (networkInfo.Type == ConnectivityType.Wifi && networkInfo.IsAvailable && networkInfo.IsConnected) + { + Console.WriteLine("FIRST WIFI NETWORK FOUND......BINDING"); + connMgr.BindProcessToNetwork(network); + } + } + } } } } diff --git a/Droid/Properties/AndroidManifest.xml b/Droid/Properties/AndroidManifest.xml index 198bb19..c30637c 100644 --- a/Droid/Properties/AndroidManifest.xml +++ b/Droid/Properties/AndroidManifest.xml @@ -2,5 +2,7 @@ + + \ No newline at end of file diff --git a/qController.Standard/Classes/Cell/QCueListCell.cs b/qController.Standard/Classes/Cell/QCueListCell.cs index ea58e56..c49fa93 100644 --- a/qController.Standard/Classes/Cell/QCueListCell.cs +++ b/qController.Standard/Classes/Cell/QCueListCell.cs @@ -8,34 +8,37 @@ namespace qController { public ListView cueListView; public Button closeButton; + public ObservableCollection items; public QCueListCell(QCueList qCueList) { Margin = new Thickness(10); Padding = new Thickness(10); - + items = new ObservableCollection(); cueListView = new ListView { - ItemsSource = qCueList.cues, + ItemsSource = items, RowHeight = (int)(App.HeightUnit * 6), ItemTemplate = new DataTemplate(() => { var grid = new Grid { Padding = new Thickness(5, 10) }; grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(30) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); - grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(30) }); var icon = new Label(); + icon.FontFamily = App.QFont; - icon.SetBinding(Label.TextProperty, "IconText"); + icon.SetBinding(Label.TextProperty, "Icon"); icon.HorizontalTextAlignment = TextAlignment.Center; icon.VerticalTextAlignment = TextAlignment.Center; icon.FontSize = App.HeightUnit * 3; - var label = new Label { VerticalOptions = LayoutOptions.FillAndExpand }; - label.SetBinding(Label.TextProperty, "listName"); - + label.SetBinding(Label.TextProperty, "Text"); + if (label.Text == "Disconnect") + { + label.TextColor = Color.DarkRed; + } switch (Device.RuntimePlatform) { case Device.iOS: @@ -45,17 +48,8 @@ namespace qController label.FontSize = App.HeightUnit * 2.2; break; } - var selectedLabel = new Label { - VerticalOptions = LayoutOptions.FillAndExpand, - FontFamily = App.QFont, - Text = QIcon.LEFT_DIR, - TextColor = Color.Green, - FontSize = App.HeightUnit * 3 - }; - - grid.Children.Add(icon, 0, 0); + grid.Children.Add(icon); grid.Children.Add(label, 1, 0); - //grid.Children.Add(selectedLabel, 2, 0); return new ViewCell { View = grid }; }) @@ -72,6 +66,57 @@ namespace qController layout.Children.Add(cueListView); Content = layout; + for(int j=0; j < qCueList.cues.Count; j++) + { + var cue = qCueList.cues[j]; + AddSubCues(cue, 0); + } + } + + public void AddSubCues(QCue cue, int level) + { + var cueIcon = cue.getIconString(); + var cueTitle = ""; + for (int i = 0; i < level; i++) + { + cueTitle += " "; + } + if (cue.number != "") + { + cueTitle += cue.number + " - " + cue.listName; + } + else + { + cueTitle += cue.listName; + } + + if (cue.cues != null) + { + items.Add(new OSCListItem + { + Text = cueTitle, + Icon = cueIcon, + Command = "/select_id/" + cue.uniqueID + }); + + //uncomment to load nested group cues + for (int i = 0; i < cue.cues.Count; i++) + { + var sub_cue = cue.cues[i]; + AddSubCues(sub_cue, level + 1); + } + } + else + { + items.Add(new OSCListItem + { + Text = cueTitle, + Icon = cueIcon, + Command = "/select_id/" + cue.uniqueID + }); + } + } + } } diff --git a/qController.Standard/Classes/Settings/OSCListItem.cs b/qController.Standard/Classes/Settings/OSCListItem.cs new file mode 100644 index 0000000..ccb79f4 --- /dev/null +++ b/qController.Standard/Classes/Settings/OSCListItem.cs @@ -0,0 +1,11 @@ + +namespace qController +{ + public class OSCListItem + { + public string Text { get; set; } + public string Icon { get; set; } + public string Command { get; set; } + } +} + diff --git a/qController.Standard/Pages/ControlPage.xaml.cs b/qController.Standard/Pages/ControlPage.xaml.cs index 81b3221..f12e4fd 100644 --- a/qController.Standard/Pages/ControlPage.xaml.cs +++ b/qController.Standard/Pages/ControlPage.xaml.cs @@ -385,8 +385,8 @@ namespace qController private void OnCueListItemSelected(object sender, SelectedItemChangedEventArgs e) { - QCue cue = (QCue)e.SelectedItem; - string selectCueOSC = "/workspace/" + qController.qWorkspace.workspace_id + "/select_id/" + cue.uniqueID; + OSCListItem cue = (OSCListItem)e.SelectedItem; + string selectCueOSC = "/workspace/" + qController.qWorkspace.workspace_id + cue.Command; qController.qClient.sendStringUDP(selectCueOSC); CloseCueList(); } diff --git a/qController.Standard/qController.csproj b/qController.Standard/qController.csproj index 739fa10..68f7133 100644 --- a/qController.Standard/qController.csproj +++ b/qController.Standard/qController.csproj @@ -55,7 +55,7 @@ - +