Skip to content
Snippets Groups Projects
Commit 82c9b141 authored by Paul-Winpenny's avatar Paul-Winpenny
Browse files

Phone app looking alright!

parent b628ce0c
No related branches found
No related tags found
No related merge requests found
Showing
with 267 additions and 35 deletions
using Microsoft.Extensions.Logging;
using Plugin.BLE;
using Plugin.BLE.Abstractions.Contracts;
using RobobinApp.Networking; // Make sure to include the namespace for WifiManager
using RobobinApp.Networking;
namespace RobobinApp
{
......
......@@ -3,6 +3,4 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:RobobinApp.Views"
x:Class="RobobinApp.AppShell">
<ShellContent ContentTemplate="{DataTemplate views:MainPage}" />
</Shell>
\ No newline at end of file
</Shell>
namespace RobobinApp;
using Microsoft.Maui.Controls;
using RobobinApp.Views;
public partial class AppShell : Shell
namespace RobobinApp
{
public AppShell()
{
InitializeComponent();
}
public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
// Conditionally add ShellContent based on the platform
#if WINDOWS
Items.Add(new ShellContent
{
ContentTemplate = new DataTemplate(typeof(MainPage))
});
#elif ANDROID
Items.Add(new ShellContent
{
ContentTemplate = new DataTemplate(typeof(MainPage_Android))
});
#else
// Fallback if you need it for other platforms
Items.Add(new ShellContent
{
ContentTemplate = new DataTemplate(typeof(MainPage_Default))
});
#endif
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:supportsRtl="true" android:label="RoboBin"></application>
<application android:allowBackup="true" android:supportsRtl="true" android:label="RoboBin"></application>
<!-- Required permissions -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
......@@ -10,6 +10,4 @@
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
</manifest>
\ No newline at end of file
<?xml version="1.0" ?>
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg width="800px" height="800px" viewBox="0 0 48 48" data-name="Layer 1" id="Layer_1" xmlns="http://www.w3.org/2000/svg">
<defs>
<style>.cls-1{fill:#55aae1;}.cls-2{opacity:0.35;}</style>
</defs>
<title/>
<path class="cls-1" d="M36,44H12a3,3,0,0,1-3-3V12a1,1,0,0,1,1-1H38a1,1,0,0,1,1,1V41A3,3,0,0,1,36,44ZM11,13V41a1,1,0,0,0,1,1H36a1,1,0,0,0,1-1V13Z"/>
<g class="cls-2">
<path class="cls-1" d="M35,12V38a2,2,0,0,1-2,2H10v1a2,2,0,0,0,2,2H36a2,2,0,0,0,2-2V12Z"/>
</g>
<path class="cls-1" d="M43,13H5a1,1,0,0,1,0-2H43a1,1,0,0,1,0,2Z"/>
<path class="cls-1" d="M17,35a1,1,0,0,1-1-1V20a1,1,0,0,1,2,0V34A1,1,0,0,1,17,35Z"/>
<path class="cls-1" d="M31,35a1,1,0,0,1-1-1V20a1,1,0,0,1,2,0V34A1,1,0,0,1,31,35Z"/>
<path class="cls-1" d="M24,37a1,1,0,0,1-1-1V18a1,1,0,0,1,2,0V36A1,1,0,0,1,24,37Z"/>
<path class="cls-1" d="M33,13H15a1,1,0,0,1-1-1V7a3,3,0,0,1,3-3H31a3,3,0,0,1,3,3v5A1,1,0,0,1,33,13ZM16,11H32V7a1,1,0,0,0-1-1H17a1,1,0,0,0-1,1Z"/>
</svg>
\ No newline at end of file
App/RobobinApp/Platforms/Android/Resources/mipmap/robobinlogo1.png

19.3 KiB

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="456" height="456" viewBox="0 0 456 456" version="1.1" xmlns="http://www.w3.org/2000/svg">
<rect x="0" y="0" width="456" height="456" fill="#512BD4" />
</svg>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="456" height="456" viewBox="0 0 456 456" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<path d="m 105.50037,281.60863 c -2.70293,0 -5.00091,-0.90042 -6.893127,-2.70209 -1.892214,-1.84778 -2.837901,-4.04181 -2.837901,-6.58209 0,-2.58722 0.945687,-4.80389 2.837901,-6.65167 1.892217,-1.84778 4.190197,-2.77167 6.893127,-2.77167 2.74819,0 5.06798,0.92389 6.96019,2.77167 1.93749,1.84778 2.90581,4.06445 2.90581,6.65167 0,2.54028 -0.96832,4.73431 -2.90581,6.58209 -1.89221,1.80167 -4.212,2.70209 -6.96019,2.70209 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
<path d="M 213.56111,280.08446 H 195.99044 L 149.69953,207.0544 c -1.17121,-1.84778 -2.14037,-3.76515 -2.90581,-5.75126 h -0.40578 c 0.36051,2.12528 0.54076,6.67515 0.54076,13.6496 v 65.13172 h -15.54349 v -99.36009 h 18.71925 l 44.7374,71.29798 c 1.89222,2.95695 3.1087,4.98917 3.64945,6.09751 h 0.26996 c -0.45021,-2.6325 -0.67573,-7.09015 -0.67573,-13.37293 v -64.02256 h 15.47557 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
<path d="m 289.25134,280.08446 h -54.40052 v -99.36009 h 52.23835 v 13.99669 h -36.15411 v 28.13085 h 33.31621 v 13.9271 h -33.31621 v 29.37835 h 38.31628 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
<path d="M 366.56466,194.72106 H 338.7222 v 85.3634 h -16.08423 v -85.3634 h -27.77455 v -13.99669 h 71.70124 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
</svg>
\ No newline at end of file
<?xml version="1.0" ?>
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg width="800px" height="800px" viewBox="0 0 48 48" data-name="Layer 1" id="Layer_1" xmlns="http://www.w3.org/2000/svg">
<defs>
<style>.cls-1{fill:#55aae1;}.cls-2{opacity:0.35;}</style>
</defs>
<title/>
<path class="cls-1" d="M36,44H12a3,3,0,0,1-3-3V12a1,1,0,0,1,1-1H38a1,1,0,0,1,1,1V41A3,3,0,0,1,36,44ZM11,13V41a1,1,0,0,0,1,1H36a1,1,0,0,0,1-1V13Z"/>
<g class="cls-2">
<path class="cls-1" d="M35,12V38a2,2,0,0,1-2,2H10v1a2,2,0,0,0,2,2H36a2,2,0,0,0,2-2V12Z"/>
</g>
<path class="cls-1" d="M43,13H5a1,1,0,0,1,0-2H43a1,1,0,0,1,0,2Z"/>
<path class="cls-1" d="M17,35a1,1,0,0,1-1-1V20a1,1,0,0,1,2,0V34A1,1,0,0,1,17,35Z"/>
<path class="cls-1" d="M31,35a1,1,0,0,1-1-1V20a1,1,0,0,1,2,0V34A1,1,0,0,1,31,35Z"/>
<path class="cls-1" d="M24,37a1,1,0,0,1-1-1V18a1,1,0,0,1,2,0V36A1,1,0,0,1,24,37Z"/>
<path class="cls-1" d="M33,13H15a1,1,0,0,1-1-1V7a3,3,0,0,1,3-3H31a3,3,0,0,1,3,3v5A1,1,0,0,1,33,13ZM16,11H32V7a1,1,0,0,0-1-1H17a1,1,0,0,0-1,1Z"/>
</svg>
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-->TargetFrameworks>net8.0-ios;net8.0-maccatalyst</TargetFrameworks-->
<TargetFrameworks>net8.0-android</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>Robobin</RootNamespace>
......@@ -12,20 +12,38 @@
<ApplicationId>com.companyname.robobin</ApplicationId>
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android|AnyCPU'">
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
</PropertyGroup>
<ItemGroup>
<MauiIcon Include="Platforms\Android\Resources\mipmap\robobinlogo1.png" />
<MauiIcon Include="Resources\AppIcon\robobinlogo.png" />
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />
<MauiFont Include="Resources\Fonts\*" />
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
<MauiSplashScreen Include="Platforms\Android\Resources\drawable\bin.svg">
<Color>#512BD4</Color>
<BaseSize>128,128</BaseSize>
</MauiSplashScreen>
<MauiSplashScreen Include="Resources\Splash\bin.svg" Color="#8185b4" BaseSize="128,128" />
</ItemGroup>
<ItemGroup>
<AndroidResource Remove="Platforms\Android\Resources\mipmap\robobinlogo1.png" />
</ItemGroup>
<ItemGroup>
<None Remove="Platforms\Android\Resources\drawable\bin.svg" />
<None Remove="Platforms\Android\Resources\mipmap\robobinlogo1.png" />
</ItemGroup>
<ItemGroup>
......@@ -50,6 +68,9 @@
<Compile Update="Views\ConnectionPage.xaml.cs">
<DependentUpon>ConnectionPage.xaml</DependentUpon>
</Compile>
<Compile Update="Views\MainPage_Android.xaml.cs">
<DependentUpon>MainPage_Android.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
......@@ -62,6 +83,9 @@
<MauiXaml Update="Views\ConnectionPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\MainPage_Android.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\SideBox.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
......
......@@ -2,9 +2,9 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IsFirstTimeProjectOpen>False</IsFirstTimeProjectOpen>
<ActiveDebugFramework>net8.0-windows10.0.19041.0</ActiveDebugFramework>
<ActiveDebugProfile>Windows Machine</ActiveDebugProfile>
<SelectedPlatformGroup>Emulator</SelectedPlatformGroup>
<ActiveDebugFramework>net8.0-android</ActiveDebugFramework>
<ActiveDebugProfile>Samsung SM-A805F (Android 9.0 - API 28)</ActiveDebugProfile>
<SelectedPlatformGroup>PhysicalDevice</SelectedPlatformGroup>
<DefaultDevice>pixel_5_-_api_34</DefaultDevice>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android|AnyCPU'">
......@@ -26,6 +26,9 @@
<MauiXaml Update="Views\ConnectionPage.xaml">
<SubType>Designer</SubType>
</MauiXaml>
<MauiXaml Update="Views\MainPage_Android.xaml">
<SubType>Designer</SubType>
</MauiXaml>
<MauiXaml Update="Views\SideBox.xaml">
<SubType>Designer</SubType>
</MauiXaml>
......
......@@ -13,12 +13,16 @@ using RobobinApp.Models;
using System.Net.NetworkInformation;
using System.Collections.Generic;
#if WINDOWS
using Windows.Networking.Connectivity;
using Windows.Devices.WiFi;
using System.Reflection.PortableExecutable;
using Plugin.BLE.Windows;
using System.Text;
using System.Windows.Documents;
#endif
using System.Text;
using RobobinApp.Networking;
namespace RobobinApp.ViewModels
......@@ -328,8 +332,8 @@ namespace RobobinApp.ViewModels
private void OnDeviceDiscovered(object? sender, DeviceEventArgs e)
{
Debug.WriteLine($"Discovered device: {e.Device.Name ?? e.Device.Id.ToString()}");
if (e.Device.Name.Equals("RoboBin-BT"))
{
//if (e.Device.Name.Equals("RoboBin-BT"))
//{
var bluetoothDevice = new BluetoothDevice(
string.IsNullOrWhiteSpace(e.Device.Name) ? e.Device.Id.ToString() : e.Device.Name,
e.Device.Id.ToString()
......@@ -341,7 +345,7 @@ namespace RobobinApp.ViewModels
// Device is new, add it
Microsoft.Maui.Controls.Device.BeginInvokeOnMainThread(() => BluetoothDevices.Add(bluetoothDevice));
}
}
//}
}
......
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:RobobinApp.Views"
xmlns:viewModels="clr-namespace:RobobinApp.ViewModels"
xmlns:drawable="clr-namespace:RobobinApp.Views"
x:Class="RobobinApp.Views.MainPage_Android"
Title="">
<ContentPage.BindingContext>
<viewModels:MainPageViewModel />
</ContentPage.BindingContext>
<ContentPage.Resources>
<ResourceDictionary>
<drawable:GraphicsDrawable x:Key="drawable" />
<StyleSheet Source="/Resources/Styles/appstyle.css" />
</ResourceDictionary>
</ContentPage.Resources>
<!-- Make the entire content scrollable -->
<ScrollView>
<VerticalStackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<!-- Top Frame -->
<VerticalStackLayout StyleClass="sideFrame"
HorizontalOptions="FillAndExpand"
VerticalOptions="Start">
<HorizontalStackLayout HorizontalOptions="Start" VerticalOptions="End">
<Button Text="Admin" Command="{Binding ConnectToRobobinCommand}"/>
<Button Text="Setup" Command="{Binding ConnectToRobobinCommand}"/>
<Button Text="Info" />
<Picker Title="Select Graph"
ItemsSource="{Binding GraphNames}"
SelectedIndexChanged="OnGraphSelected"
HorizontalOptions="Center" />
</HorizontalStackLayout>
<local:SideBox HeaderTitle="Queue:" />
<local:SideBox HeaderTitle="Status:" />
</VerticalStackLayout>
<!-- Main Drawable Area with specific HeightRequest to ensure visibility -->
<Frame StyleClass="mainFrame"
HorizontalOptions="FillAndExpand"
VerticalOptions="Center"
HeightRequest="400">
<!-- Adjust this value as needed -->
<GraphicsView x:Name="GraphicsView"
Drawable="{StaticResource drawable}">
<GraphicsView.GestureRecognizers>
<TapGestureRecognizer Tapped="OnGraphicsViewTapped" />
</GraphicsView.GestureRecognizers>
</GraphicsView>
</Frame>
<!-- Bottom Frame -->
<VerticalStackLayout StyleClass="sideFrame"
HorizontalOptions="FillAndExpand"
VerticalOptions="End">
<local:SideBox HeaderTitle="Mode:" />
<local:SideBox HeaderTitle="Admin:" />
</VerticalStackLayout>
</VerticalStackLayout>
</ScrollView>
</ContentPage>
using Microsoft.Maui.Controls;
using RobobinApp.ViewModels;
using RobobinApp.Models;
using System.Diagnostics;
using RobobinApp.Views;
using Robobin.Models;
namespace RobobinApp.Views
{
public partial class MainPage_Android : ContentPage
{
public MainPage_Android()
{
InitializeComponent();
var drawable = (GraphicsDrawable)Resources["drawable"];
if (BindingContext is MainPageViewModel viewModel)
{
drawable.SetGraph(viewModel.Graph);
}
}
private void OnGraphSelected(object sender, EventArgs e)
{
if (sender is Picker picker && BindingContext is MainPageViewModel viewModel)
{
viewModel.SelectGraphCommand.Execute(picker.SelectedIndex);
var drawable = (GraphicsDrawable)Resources["drawable"];
var newGraph = viewModel.Graphs.FirstOrDefault(g => g.Name == viewModel.Graph.Name);
if (newGraph != null)
{
drawable.SetGraph(newGraph);
GraphicsView.Invalidate();
Debug.WriteLine("New Graph picked and drawn");
}
else
{
Debug.WriteLine("Graph not found!");
}
}
}
private void OnGraphicsViewTapped(object sender, TappedEventArgs e)
{
var tapPoint = e.GetPosition(GraphicsView);
var drawable = (GraphicsDrawable)Resources["drawable"];
float scale = drawable.CurrentScale;
var offset = drawable.CurrentOffset;
var tapPointX = (float)tapPoint.Value.X;
var tapPointY = (float)tapPoint.Value.Y;
var nearestNode = drawable.FindNearestNode(tapPointX, tapPointY, scale, offset.X, offset.Y);
// Highlight the nearest node
drawable.HighlightNode(nearestNode);
if (nearestNode != null)
{
// Find the home node
Node homeNode = drawable.GetHomeNode();
if (homeNode != null)
{
List<Node> path = drawable.AStarPathfinding(nearestNode, homeNode);
drawable.Path = path;
GraphicsView.Invalidate();
}
DisplayAlert("Node Clicked", $"You clicked on node: {nearestNode.Name}", "OK");
}
else
{
DisplayAlert("No Node", "No node was clicked.", "OK");
}
// Invalidate to trigger a redraw and highlight the node
GraphicsView.Invalidate();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment