* MainActivity.cs:

* AndroidManifest.xml: Android: Bind to WIFI

* ControlPage.xaml.cs:
* QCueListCell.cs:
* OSCListItem.cs: Add sub-cues in cue listing

* qController.csproj: Update
This commit is contained in:
2019-08-04 15:57:25 -05:00
parent a2d96d2985
commit 5deb4fd084
6 changed files with 96 additions and 20 deletions
+18
View File
@@ -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);
}
}
}
}
}
}
+2
View File
@@ -2,5 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="26" android:versionName="1.0.9" package="com.jwetzell.qlabcontroller">
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application android:label="qController" android:icon="@drawable/icon"></application>
</manifest>
@@ -8,34 +8,37 @@ namespace qController
{
public ListView cueListView;
public Button closeButton;
public ObservableCollection<OSCListItem> items;
public QCueListCell(QCueList qCueList)
{
Margin = new Thickness(10);
Padding = new Thickness(10);
items = new ObservableCollection<OSCListItem>();
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
});
}
}
}
}
@@ -0,0 +1,11 @@
namespace qController
{
public class OSCListItem
{
public string Text { get; set; }
public string Icon { get; set; }
public string Command { get; set; }
}
}
@@ -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();
}
+1 -1
View File
@@ -55,7 +55,7 @@
<ItemGroup>
<PackageReference Include="Acr.UserDialogs" Version="7.0.4" />
<PackageReference Include="Zeroconf" Version="3.0.30" />
<PackageReference Include="Xamarin.Forms" Version="4.1.0.581479" />
<PackageReference Include="Xamarin.Forms" Version="4.1.0.618606" />
<PackageReference Include="Acr.Settings" Version="9.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="Xamarin.Essentials" Version="1.2.0" />