Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve settings #95

Merged
merged 8 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion Nearby Sharing Windows.sln
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{F0E5B489
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShortDev.Microsoft.ConnectedDevices.Test", "tests\ShortDev.Microsoft.ConnectedDevices.Test\ShortDev.Microsoft.ConnectedDevices.Test.csproj", "{B0DE3385-5FD7-4D05-8296-6E298A3F1BA2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShortDev.Microsoft.Bond.SourceGenerator", "ShortDev.Microsoft.Bond.SourceGenerator\ShortDev.Microsoft.Bond.SourceGenerator.csproj", "{4480CB98-4FC4-4EF4-B1D3-010ED43B6980}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShortDev.Microsoft.Bond.SourceGenerator", "ShortDev.Microsoft.Bond.SourceGenerator\ShortDev.Microsoft.Bond.SourceGenerator.csproj", "{4480CB98-4FC4-4EF4-B1D3-010ED43B6980}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lib", "lib", "{D891AC11-E26F-434D-AA9D-0FE6F162DCB9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShortDev.Android.Preferences", "lib\ShortDev.Android.Preferences\ShortDev.Android.Preferences.csproj", "{B80E8155-B326-41BD-B1CC-689801E460AE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -166,13 +170,26 @@ Global
{4480CB98-4FC4-4EF4-B1D3-010ED43B6980}.Release|x64.Build.0 = Release|Any CPU
{4480CB98-4FC4-4EF4-B1D3-010ED43B6980}.Release|x86.ActiveCfg = Release|Any CPU
{4480CB98-4FC4-4EF4-B1D3-010ED43B6980}.Release|x86.Build.0 = Release|Any CPU
{B80E8155-B326-41BD-B1CC-689801E460AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B80E8155-B326-41BD-B1CC-689801E460AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B80E8155-B326-41BD-B1CC-689801E460AE}.Debug|x64.ActiveCfg = Debug|Any CPU
{B80E8155-B326-41BD-B1CC-689801E460AE}.Debug|x64.Build.0 = Debug|Any CPU
{B80E8155-B326-41BD-B1CC-689801E460AE}.Debug|x86.ActiveCfg = Debug|Any CPU
{B80E8155-B326-41BD-B1CC-689801E460AE}.Debug|x86.Build.0 = Debug|Any CPU
{B80E8155-B326-41BD-B1CC-689801E460AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B80E8155-B326-41BD-B1CC-689801E460AE}.Release|Any CPU.Build.0 = Release|Any CPU
{B80E8155-B326-41BD-B1CC-689801E460AE}.Release|x64.ActiveCfg = Release|Any CPU
{B80E8155-B326-41BD-B1CC-689801E460AE}.Release|x64.Build.0 = Release|Any CPU
{B80E8155-B326-41BD-B1CC-689801E460AE}.Release|x86.ActiveCfg = Release|Any CPU
{B80E8155-B326-41BD-B1CC-689801E460AE}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{CFABE26A-FBFF-4CF9-8C94-B603B317A223} = {B1BBE46E-5DC6-410A-84FC-157E31F31E92}
{B0DE3385-5FD7-4D05-8296-6E298A3F1BA2} = {F0E5B489-0FD2-4A7E-B660-C28450479583}
{B80E8155-B326-41BD-B1CC-689801E460AE} = {D891AC11-E26F-434D-AA9D-0FE6F162DCB9}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {86DED607-FA3F-4D8A-B226-8AE9C9F08F84}
Expand Down
4 changes: 2 additions & 2 deletions Nearby Sharing Windows/AndroidBluetoothHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task ScanBLeAsync(ScanOptions scanOptions, CancellationToken cancel
{
var address = result.Device?.Address ?? throw new InvalidDataException("No address");
var beaconData = result.ScanRecord?.GetManufacturerSpecificData(Constants.BLeBeaconManufacturerId);
if (beaconData != null && CdpAdvertisement.TryParse(beaconData, out var data))
if (beaconData != null && BLeBeacon.TryParse(beaconData, out var data))
scanOptions.OnDeviceDiscovered?.Invoke(data);
}
catch (InvalidDataException) { }
Expand Down Expand Up @@ -89,7 +89,7 @@ public async Task AdvertiseBLeBeaconAsync(AdvertiseOptions options, Cancellation
.Build();

var data = new AdvertiseData.Builder()
.AddManufacturerData(options.ManufacturerId, options.BeaconData!)!
.AddManufacturerData(options.ManufacturerId, options.BeaconData.ToArray())!
.Build();

BLeAdvertiseCallback callback = new();
Expand Down
2 changes: 1 addition & 1 deletion Nearby Sharing Windows/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-feature android:name="android.hardware.bluetooth" android:required="false" />
<uses-feature android:name="android.hardware.bluetooth_le" android:required="false" />
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme">
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme" android:localeConfig="@xml/locales_config">
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="de.shortdev.nearshare.FileProvider"
Expand Down
20 changes: 20 additions & 0 deletions Nearby Sharing Windows/App.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Android.Runtime;
using AndroidX.AppCompat.App;
using Nearby_Sharing_Windows.Settings;

namespace Nearby_Sharing_Windows;

[Application]
public sealed class App : Application
{
public App(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
{
}

public override void OnCreate()
{
base.OnCreate();

AppCompatDelegate.DefaultNightMode = SettingsFragment.ShouldForceDarkMode(this) ? AppCompatDelegate.ModeNightYes : AppCompatDelegate.ModeNightFollowSystem;
}
}
6 changes: 1 addition & 5 deletions Nearby Sharing Windows/Assets/de/MacAddressInfo.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
Diese Funktion befindet sich derzeit in der Alpha-Phase. Bitte erwarten Sie <i>langsame</i> und <i>unzuverlässige</i> Übertragungen sowie andere Arten von Fehlern.
<br />
Sie können derzeit nur eine (kleine) Datei gleichzeitig empfangen, und der einzige verfügbare Transport ist Bluetooth.
<br />
Wenn Sie keine Daten empfangen können, überprüfen Sie die Einstellungen, das Debug-Protokoll und werfen Sie einen Blick in die FAQ (in den Einstellungen).
Wenn Sie keine Daten empfangen können, überprüfen Sie die Einstellungen, das Debug-Protokoll und werfen Sie einen Blick in die FAQ (in den Einstellungen).
<br />
Wenn Sie auf ein Problem stoßen, melden Sie es bitte direkt über GitHub!
<br />
Expand Down
11 changes: 2 additions & 9 deletions Nearby Sharing Windows/Assets/en/MacAddressInfo.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
This feature is currently in alpha, please expect <i>slow</i> and <i>unreliable</i> transfers as well as any other kinds of bugs.
<br />
You can currently only receive one (small) file at a time and the only transport available is bluetooth.
<br />
If you can't receive data check your settings, debug log and have a look at the FAQ (in the Settings).
If you can't receive data check your settings, debug log and have a look at the FAQ (in the Settings).
<br />
If you encounter an issue, please report it directly via GitHub!
<br />
Expand All @@ -19,7 +15,4 @@ <h2>Required Action</h2>
<br />
You can find it in the settings at <i>System <b>></b> About <b>></b> Bluetooth MAC address</i>.
<br />
If this address is invalid, you will not be able to receive any data!
<br />
<br />
I just want to test, how other devices out there feel about my implementation so please don't feel too disappointed...
If this address is invalid, you will not be able to receive any data!
9 changes: 1 addition & 8 deletions Nearby Sharing Windows/Assets/es/MacAddressInfo.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
Esta característica se encuentra actualmente en vesión alfa, por lo tanto, espera transferencias <i>lentas</i> e <i>inestables </i> además de cualquier otro tipo de fallos.
<br />
Actualmente solo puedes recibir un archivo (pequeño) a la vez y solo puede ser enviado a través de Bluetooth.
<br />
Si no puedes recibir datos comprueba tus ajustes, registro de depuración y échale un vistazo a las preguntas frecuentes (en los ajustes).
<br />
¡Si te encuentras con algún problema, por favor, repórtalo directamente vía GitHub!
Expand All @@ -19,7 +15,4 @@ <h2>Acciones requeridas</h2>
<br />
Puedes encontrarla dentro de los ajustes en: <i>Sistema <b>></b> Sobre el télefono <b>></b> Dirección MAC del Bluetooth</i>.
<br />
¡Si esta dirección es incorrecta no podrás recibir ningún dato!
<br />
<br />
Solamente quiero probar cómo otros dispositivos responden a mi implementación, así que no te sientas demasiado decepcionado ...
¡Si esta dirección es incorrecta no podrás recibir ningún dato!
12 changes: 2 additions & 10 deletions Nearby Sharing Windows/Assets/fr/MacAddressInfo.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@

Cette fonctionnalité en test, attendez-vous à des partages <i>lent</i> et <i>instable</i> ou autres problèmes.
<br />
Pour le moment, vous ne pouvez recevoir qu’un seul (petit) fichier à chaque fois et uniquement par Bluetooth.
<br />
Si vous ne pouvez pas recevoir de fichier, verifier vos paramètres, le journal de débogage et de jeter un œil à la FAQ (dans les paramètres).
Si vous ne pouvez pas recevoir de fichier, verifier vos paramètres, le journal de débogage et de jeter un œil à la FAQ (dans les paramètres).
<br />
Si vous rencontrer un problème, merci de le signaler directement sur GitHub !
<br />
Expand All @@ -20,7 +15,4 @@ <h2>Actions requise</h2>
<br />
Vous pouvez la trouver dans les paramètres dans <i>Système <b>></b> À propos <b>></b> Adresse Bluetooth</i>.
<br />
Si cette adresse est invalide, vous ne pourrez pas recevoir quoi que ce soit !
<br />
<br />
Je veux juste tester comment d’autres appareils réagissent à mon développement, alors ne soyez pas déçu...
Si cette adresse est invalide, vous ne pourrez pas recevoir quoi que ce soit !
9 changes: 1 addition & 8 deletions Nearby Sharing Windows/Assets/pl/MacAddressInfo.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
Ta funkcja jest w fazie alpha, <i>wolne</i> i <i>niepewne</i> transfery są spodziewane jak również wszelkich innych błędow.
<br />
Obecnie można odbierać jeden (mały) plik naraz, a jedynym sposobem jest przez Bluetooth.
<br />
Jeżeli nie możesz odbierać plików, sprawdź ustawienia, dziennik debugów oraz zajrzyj do FAQ (w ustawieniach).
Jeżeli nie możesz odbierać plików, sprawdź ustawienia, dziennik debugów oraz zajrzyj do FAQ (w ustawieniach).
<br />
Jeżeli napotkasz jakiś problem, zgłoś go bezpośrednio przez GitHub!
<br />
Expand All @@ -20,6 +16,3 @@ <h2>Wymagane działania</h2>
Możesz go znaleźć w ustawieniach w <b>System <b>></b> O telefonie</b> Adres MAC Bluetooth</i>.
<br />
Jeżeli adres jest nieprawidłowy, nie będziesz w stanie otrzymywać żadnych danych!
<br />
<br />
Chcę tylko przetestować, jak inne urządzenia czują się z moją implementacją, więc nie czuj się zbyt rozczarowany...
12 changes: 1 addition & 11 deletions Nearby Sharing Windows/Assets/ro/MacAddressInfo.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
Această funcție este deocamdată în alpha, așadar te poți aștepta la transferuri
<i>încete</i> și <i>instabile</i> precum și alte bug-uri.
<br />
Deocamdată poți primi doar câte un fișier (mic) și singurul mod de transfer este
bluetooth-ul.
<br />
Dacă nu poți primi datele, verifică-ți setările, jurnalul de depanare și aruncă
Dacă nu poți primi datele, verifică-ți setările, jurnalul de depanare și aruncă
un ochi în secțiunea de întrebări frecvente (în Setări).
<br />
Dacă întâmpini o problemă, te rog raporteaz-o direct pe Github!
Expand All @@ -26,7 +20,3 @@ <h2>Acțiuni necesare</h2>
<i>Sistem <b>></b> Despre <b>></b> Adresa MAC Bluetooth</i>.
<br />
Dacă adresa nu este corectă, nu vei putea să primești nimic!
<br />
<br />
Vreau doar să testez cum funcționează pe alte dispozitive implementarea mea, așa
că nu te simți prea dezamăgit...
6 changes: 1 addition & 5 deletions Nearby Sharing Windows/Assets/ru/MacAddressInfo.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
Эта функция в настоящее время находится в альфа-версии, поэтому ожидайте <i>медленных</i> и <i>ненадежных</i> передач и любых других ошибок.
<br />
В настоящее время вы можете получать только один маленький файл за раз, и доступным способом передачи является только Bluetooth.
<br />
Если у вас не получается получить данные, проверьте настройки, журнал отладки и обратитесь к FAQ (в настройках).
Если у вас не получается получить данные, проверьте настройки, журнал отладки и обратитесь к FAQ (в настройках).
<br />
Если вы столкнетесь с проблемой, сообщите о ней непосредственно через GitHub!
<br />
Expand Down
7 changes: 1 addition & 6 deletions Nearby Sharing Windows/Assets/uk/MacAddressInfo.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
На даний момент ця функція знаходиться в альфа-версії, тому очікуйте <i>повільних</i> чи <i>ненадійних</i> надсилань та будь-яких інших помилок.
<br />
На даний момент ви можете отримувати лише один маленький файл за раз, а доступним способом передачі є тільки Bluetooth.
<br />
Якщо вам не вдається отримати дані, перевірте свої налаштування, журнал налагодження або зверніться до FAQ (в налаштуваннях).
<br />
Якщо ви зіткнетесь з проблемою, повідомте про неї безпосередньо через GitHub!
Expand All @@ -19,5 +15,4 @@ <h2>Необхідні дії</h2>
<br />
Ви можете знайти його в налаштуваннях у розділі <i>Система <b>></b> Про систему <b>></b> Адрес Bluetooth</i>.
<br />
Якщо цей пункт вказаний неправильно, ви не зможете отримувати файли!
<br />
Якщо цей пункт вказаний неправильно, ви не зможете отримувати файли!
11 changes: 2 additions & 9 deletions Nearby Sharing Windows/Assets/zh/MacAddressInfo.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
此功能目前在alpha测试中, 传输可能会出现<i>缓慢</i> , <i>不稳定</i> ,或其他问题。
<br />
您目前只能同时通过蓝牙接收一个(小体积的)文件。
<br />
如果您不能接收数据,请查看设置,调试日志,和(设置中的)常见问题手册。
如果您不能接收数据,请查看设置,调试日志,和(设置中的)常见问题手册。
<br />
如果您遇到任何问题,请直接在GitHub中报告!
<br />
Expand All @@ -19,7 +15,4 @@ <h2>必要的设置</h2>
<br />
您可以在 <i> 系统 <b>></b> 关于 <b>></b> 蓝牙Mac地址 </i> 中找到它。
<br />
如果此地址无效,您将无法接收任何数据!
<br />
<br />
我只想测试其他设备对此应用的反应,所以请不要太失望。。。
如果此地址无效,您将无法接收任何数据!
2 changes: 2 additions & 0 deletions Nearby Sharing Windows/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
global using AndroidUri = Android.Net.Uri;
global using ManifestPermission = Android.Manifest.Permission;
4 changes: 2 additions & 2 deletions Nearby Sharing Windows/Nearby Sharing Windows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
<ItemGroup>
<PackageReference Include="Sentry" Version="3.31.0" />
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.6.1.1" />
<PackageReference Include="Xamarin.AndroidX.Preference" Version="1.2.0.5" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.8.0.1" />
<PackageReference Include="Xamarin.Essentials" Version="1.7.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\lib\ShortDev.Android.Preferences\ShortDev.Android.Preferences.csproj" />
<ProjectReference Include="..\ShortDev.Android.FluentIcons\ShortDev.Android.FluentIcons.csproj" />
<ProjectReference Include="..\ShortDev.Android\ShortDev.Android.csproj">
<Project>{195c941f-5eef-45a9-a65c-16186e4bb131}</Project>
Expand All @@ -37,6 +37,6 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<TransformFile Include="Resources\xml\preferences.xml" />
<AndroidAsset Include="../Credits.md" Link="Assets/Credits.md" />
</ItemGroup>
</Project>
12 changes: 5 additions & 7 deletions Nearby Sharing Windows/ReceiveActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using AndroidX.AppCompat.App;
using AndroidX.RecyclerView.Widget;
using Google.Android.Material.ProgressIndicator;
using Nearby_Sharing_Windows.Settings;
using ShortDev.Android.UI;
using ShortDev.Microsoft.ConnectedDevices;
using ShortDev.Microsoft.ConnectedDevices.Encryption;
Expand Down Expand Up @@ -153,9 +154,10 @@ void InitializeCDP()
var service = (BluetoothManager)GetSystemService(BluetoothService)!;
_btAdapter = service.Adapter!;

var deviceName = SettingsFragment.GetDeviceName(this, _btAdapter);
FindViewById<TextView>(Resource.Id.deviceInfoTextView)!.Text = this.Localize(
Resource.String.visible_as_template,
$"{_btAdapter.Name!}.\n" +
$"\"{deviceName}\".\n" +
$"Address: {btAddress.ToStringFormatted()}\n" +
$"IP-Address: {AndroidNetworkHandler.GetLocalIp(this)}");
debugLogTextView = FindViewById<TextView>(Resource.Id.debugLogTextView)!;
Expand All @@ -166,7 +168,7 @@ void InitializeCDP()
_cdp = new(new()
{
Type = DeviceType.Android,
Name = _btAdapter.Name ?? throw new NullReferenceException("Could not find device name"),
Name = deviceName,
OemModelName = Build.Model ?? string.Empty,
OemManufacturerName = Build.Manufacturer ?? string.Empty,
DeviceCertificate = ConnectedDevicesPlatform.CreateDeviceCertificate(CdpEncryptionParams.Default),
Expand All @@ -180,11 +182,7 @@ void InitializeCDP()
_cdp.AddTransport<NetworkTransport>(new(networkHandler));

_cdp.Listen(_cancellationTokenSource.Token);
_cdp.Advertise(new CdpAdvertisement(
DeviceType.Android,
btAddress, // "00:fa:21:3e:fb:19"
_btAdapter.Name!
), _cancellationTokenSource.Token);
_cdp.Advertise(_cancellationTokenSource.Token);

NearShareReceiver.Start(_cdp, this);
}
Expand Down
10 changes: 0 additions & 10 deletions Nearby Sharing Windows/Resources/drawable/file_download_48.xml

This file was deleted.

10 changes: 0 additions & 10 deletions Nearby Sharing Windows/Resources/drawable/file_upload_48.xml

This file was deleted.

2 changes: 1 addition & 1 deletion Nearby Sharing Windows/Resources/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="@string/generic_send"
app:icon="@drawable/file_upload_48"
app:icon="@drawable/ic_fluent_send_copy_24_regular"
style="@style/AppTheme.NearbyShareButton" />
<Button
android:id="@+id/receiveButton"
Expand Down
4 changes: 2 additions & 2 deletions Nearby Sharing Windows/Resources/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<LinearLayout
<FrameLayout
android:id="@+id/settings_container"
android:orientation="vertical"
android:animateLayoutChanges="true"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

Expand Down
2 changes: 1 addition & 1 deletion Nearby Sharing Windows/Resources/menu/menu_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools">
<item
android:id="@+id/action_help"
android:icon="@drawable/ic_fluent_chat_help_24_regular"
android:icon="@drawable/ic_fluent_question_circle_24_regular"
android:title="@string/open_faq_title"
android:showAsAction="ifRoom" />
<item
Expand Down
Loading