Skip to content
Snippets Groups Projects
Commit 75b1662f authored by plw1g21's avatar plw1g21
Browse files

Merge branch 'app-bluetooth-connection' into 'main'

App now has a basic structure and BLE support

See merge request !1
parents 6195f454 d55c6826
No related branches found
No related tags found
1 merge request!1App now has a basic structure and BLE support
Showing
with 270 additions and 563 deletions
......@@ -5,3 +5,5 @@
/App/RobobinApp/bin/
/App/RobobinApp/obj/
.DS_Store
/App/RobobinApp/<AndroidSdkPath>/
/App/RobobinApp/<JavaSdkPath>/
\ No newline at end of file
{
"ExpandedNodes": [
""
],
"SelectedNode": "\\App.sln",
"PreviewInSolutionExplorer": false
}
\ No newline at end of file
File added
......@@ -16,6 +16,7 @@ Global
{6D394E71-6C39-4FAC-A1D4-054609783EFF}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{6D394E71-6C39-4FAC-A1D4-054609783EFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D394E71-6C39-4FAC-A1D4-054609783EFF}.Release|Any CPU.Build.0 = Release|Any CPU
{6D394E71-6C39-4FAC-A1D4-054609783EFF}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -9,6 +9,8 @@
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
<StyleSheet Source="/Resources/Styles/appstyle.css" />
</ResourceDictionary>
</Application.Resources>
</Application>
namespace RobobinApp;
using Microsoft.Extensions.Logging;
namespace RobobinApp;
public partial class App : Application
{
public App()
{
InitializeComponent();
ConfigureLogging();
MainPage = new AppShell();
}
private void ConfigureLogging()
{
// Create a LoggerFactory
var loggerFactory = LoggerFactory.Create(builder =>
{
builder
.AddConsole()
.AddDebug();
});
// Store the logger factory for later use
Logger = loggerFactory.CreateLogger<App>();
}
public ILogger<App> Logger { get; private set; }
}
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="RobobinApp.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
<?xml version="1.0" encoding="utf-8" ?>
<Shell xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:RobobinApp"
Shell.FlyoutBehavior="Disabled"
Title="RobobinApp">
<ShellContent
Title="Home"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />
xmlns:views="clr-namespace:RobobinApp.Views"
x:Class="RobobinApp.AppShell">
<ShellContent ContentTemplate="{DataTemplate views:MainPage}" />
</Shell>
\ No newline at end of file
using Plugin.BLE.Abstractions.Contracts;
using Plugin.BLE;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Robobin.Interfaces
{
public class BluetoothLEService : IBluetoothLEService
{
public IBluetoothLE Current => CrossBluetoothLE.Current;
}
public class AdapterService : IAdapterService
{
public IAdapter Adapter => CrossBluetoothLE.Current.Adapter;
}
}
using Plugin.BLE.Abstractions.Contracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Robobin.Interfaces
{
public interface IBluetoothLEService
{
IBluetoothLE Current { get; }
}
public interface IAdapterService
{
IAdapter Adapter { get; }
}
}
<?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"
x:Class="RobobinApp.MainPage">
<ScrollView>
<VerticalStackLayout
Padding="30,0"
Spacing="25">
<Image
Source="dotnet_bot.png"
HeightRequest="185"
Aspect="AspectFit"
SemanticProperties.Description="dot net bot in a race car number eight" />
<Label
Text="Hello, World!"
Style="{StaticResource Headline}"
SemanticProperties.HeadingLevel="Level1" />
<Label
Text="Welcome to &#10;.NET Multi-platform App UI"
Style="{StaticResource SubHeadline}"
SemanticProperties.HeadingLevel="Level2"
SemanticProperties.Description="Welcome to dot net Multi platform App U I" />
<Button
x:Name="CounterBtn"
Text="Click me"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
HorizontalOptions="Fill" />
</VerticalStackLayout>
</ScrollView>
</ContentPage>
namespace RobobinApp;
public partial class MainPage : ContentPage
{
int count = 0;
public MainPage()
{
InitializeComponent();
}
private void OnCounterClicked(object sender, EventArgs e)
{
count++;
if (count == 1)
CounterBtn.Text = $"Clicked {count} time";
else
CounterBtn.Text = $"Clicked {count} times";
SemanticScreenReader.Announce(CounterBtn.Text);
}
}
using Microsoft.Extensions.Logging;

namespace RobobinApp;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
var builder = MauiApp
.CreateBuilder()
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
#if DEBUG
builder.Logging.AddDebug();
#endif
return builder.Build();
}
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RobobinApp.Models
{
public class BluetoothDevice
{
public string Name { get; set; }
public string MacAddress { get; set; }
public BluetoothDevice(string name, string macAddress)
{
Name = name;
MacAddress = macAddress;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RobobinApp.Models
{
public class WifiNetwork
{
public string SSID { get; set; }
public double SignalStrength { get; set; }
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
<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>
<!-- Required permissions -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<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
......@@ -12,4 +12,5 @@
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
</windowsSettings>
</application>
</assembly>
<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<Color x:Key="PrimaryColor">#4CAF50</Color>
<Color x:Key="SecondaryColor">#2196F3</Color>
<Color x:Key="BackgroundColor">#121212</Color>
<Color x:Key="TextColor">#FFFFFF</Color>
<Style TargetType="Label">
<Setter Property="TextColor" Value="{DynamicResource TextColor}"/>
</Style>
<Style TargetType="Button">
<Setter Property="BackgroundColor" Value="{DynamicResource PrimaryColor}"/>
<Setter Property="TextColor" Value="#FFFFFF"/>
</Style>
</ResourceDictionary>
<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<!-- Light Theme Colors -->
<Color x:Key="PrimaryColor">#4CAF50</Color>
<!-- Green -->
<Color x:Key="SecondaryColor">#2196F3</Color>
<!-- Blue -->
<Color x:Key="BackgroundColor">#FFFFFF</Color>
<!-- White -->
<Color x:Key="TextColor">#000000</Color>
<!-- Black -->
<!-- Default Styles -->
<Style TargetType="Label">
<Setter Property="TextColor" Value="{DynamicResource TextColor}"/>
</Style>
<Style TargetType="Button">
<Setter Property="BackgroundColor" Value="{DynamicResource PrimaryColor}"/>
<Setter Property="TextColor" Value="#FFFFFF"/>
</Style>
</ResourceDictionary>
This diff is collapsed.
navigationpage {
-maui-bar-background-color: lightgray;
}
^contentpage {
background-color: lightgray;
}
#listView {
background-color: lightgray;
}
stacklayout {
margin: 20;
-maui-spacing: 6;
}
grid {
row-gap: 6;
column-gap: 6;
}
.mainPageTitle {
font-style: bold;
font-size: 14;
}
.mainPageSubtitle {
margin-top: 15;
}
.detailPageTitle {
font-style: bold;
font-size: 14;
text-align: center;
}
.detailPageSubtitle {
text-align: center;
font-style: italic;
}
listview image {
height: 60;
width: 60;
}
stacklayout > image {
height: 200;
width: 200;
}
.mainFrame {
background-color: White;
border-color: Black;
corner-radius: 5;
}
.sideFrame {
background-color: #2B333E;
border-color: Black;
corner-radius: 5;
}
.sideBox {
margin: 0;
padding: 0;
}
.side-box-frame {
margin: 10;
padding: 0;
background-color: transparent;
border-color: transparent;
horizontal-options: fill-and-expand;
}
.side-box-header {
background-color: #647687;
padding: 10 5;
}
.side-box-header-text {
color: #FFFFFF;
font-size: 16;
}
.side-box-content {
background-color: #E8EDF1;
padding: 10;
height: 200;
}
.side-box-content Label {
margin: 0;
padding: 0;
}
.side-box-vertical-stack {
spacing: 0;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment