Skip to content

Commit

Permalink
Impl Beacon dApp deeplink, fix iOS libsodium, refactoring. (#75)
Browse files Browse the repository at this point in the history
* Impl deeplinks for iOS + connect dApp by deeplink

* Impl deeplinks for Android

* Change deepLink format

* Impl logic of connection on deep link

* Dapp connect with scan and copy/paste methods

* Constants and structures to Models + refactor

* Revert to static libsodium library, increase beacon v1.0.12

* Add beacon nuget

* Resolve dapp connection by deep link with locked wallet
  • Loading branch information
mismirnov authored Dec 19, 2022
1 parent 0e885fa commit 37c5d4f
Show file tree
Hide file tree
Showing 79 changed files with 5,211 additions and 3,637 deletions.
3 changes: 3 additions & 0 deletions atomex.Android/Atomex.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2291" />
<PackageReference Include="Xamarin.Android.Support.Core.Utils" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Essentials" Version="1.7.1" />
<PackageReference Include="Xamarin.Forms.AppLinks">
<Version>5.0.0.2515</Version>
</PackageReference>
<PackageReference Include="ZXing.Net.Mobile.Forms">
<Version>2.4.1</Version>
</PackageReference>
Expand Down
39 changes: 35 additions & 4 deletions atomex.Android/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.Gms.Extensions;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Firebase.Messaging;
using Plugin.Fingerprint;
using Sentry;
Expand All @@ -18,15 +18,29 @@
using atomex.Common.FileSystem;
using Atomex.Common;
using Atomex.TzktEvents;
using Firebase;
using Xamarin.Forms.Platform.Android.AppLinks;

namespace atomex.Droid
{
[Activity(Label = "Atomex", Icon = "@mipmap/icon", Theme = "@style/MainTheme",
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, LaunchMode = LaunchMode.SingleTask,
ScreenOrientation = ScreenOrientation.Locked)]

[IntentFilter(new[] { Intent.ActionView },
Categories = new[]
{
Intent.CategoryDefault,
Intent.CategoryBrowsable
},
DataScheme = "atomex",
DataPathPrefix = "",
DataHost = "",
AutoVerify = true)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
public static MainActivity Instance { get; private set; }
private App _app { get; set; }

protected override void OnCreate(Bundle bundle)
{
Expand All @@ -44,7 +58,7 @@ protected override void OnCreate(Bundle bundle)

//Window.DecorView.SystemUiVisibility = (StatusBarVisibility)SystemUiFlags.LightNavigationBar;

Window.SetNavigationBarColor(
Window?.SetNavigationBarColor(
Android.Graphics.Color.ParseColor(ApplicationContext.Resources.GetString(Resource.Color.colorPrimary)));

CrossFingerprint.SetCurrentActivityResolver(() => this);
Expand All @@ -56,18 +70,35 @@ protected override void OnCreate(Bundle bundle)
Rg.Plugins.Popup.Popup.Init(this);
Xamarin.Essentials.Platform.Init(this, bundle);
Forms.Init(this, bundle);
FirebaseApp.InitializeApp(this);
AndroidAppLinks.Init(this);

Instance = this;

global::ZXing.Net.Mobile.Forms.Android.Platform.Init();
ZXing.Net.Mobile.Forms.Android.Platform.Init();

App.FileSystem = Device.Android;

_ = GetDeviceTokenAsync();

AndroidEnvironment.UnhandledExceptionRaiser += AndroidUnhandledExceptionRaiser;

LoadApplication(new App());
_app = new App();
LoadApplication(_app);
}

protected override void OnNewIntent(Intent intent)
{
base.OnNewIntent(intent);
if (Intent.ActionView != intent.Action || string.IsNullOrWhiteSpace(intent.DataString))
return;

var type = intent.Data?.GetQueryParameter("type");
if (string.IsNullOrEmpty(intent.Data?.Host) && type == "tzip10")
{
string data = intent.Data?.GetQueryParameter("data");
_app.OnDeepLinkReceived(data);
}
}

protected override void OnDestroy()
Expand Down
6,307 changes: 3,538 additions & 2,769 deletions atomex.Android/Resources/Resource.designer.cs

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion atomex.iOS/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Runtime.InteropServices;
using Foundation;
using Sentry;
Expand Down Expand Up @@ -29,6 +30,8 @@ public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsAppli
//
private string DeviceToken { get; set; }

private App _app { get; set; }

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
ConfigureLogging();
Expand Down Expand Up @@ -63,13 +66,28 @@ public override bool FinishedLaunching(UIApplication app, NSDictionary options)

UIApplication.SharedApplication.RegisterForRemoteNotifications();

LoadApplication(new App());
_app = new App();
LoadApplication(_app);

Plugin.InputKit.Platforms.iOS.Config.Init();

return base.FinishedLaunching(app, options);
}

public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
{
NSUrlComponents urlComponents = new NSUrlComponents(url, false);
NSUrlQueryItem[] allItems = urlComponents.QueryItems;
var type = allItems?.First(i => i.Name == "type").Value;
if (string.IsNullOrEmpty(urlComponents.Host) && type == "tzip10")
{
var qrCodeString = allItems?.First(i => i.Name == "data").Value;
_app.OnDeepLinkReceived(qrCodeString);
}

return true;
}

public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
try
Expand Down
15 changes: 13 additions & 2 deletions atomex.iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
<string>com.atomex.ios</string>
<key>CFBundleVersion</key>
<string>1.21.0</string>
<key>Executable</key>
<string>libsodium</string>
<key>UILaunchStoryboardName</key>
<string>AtomexLaunchScreen</string>
<key>CFBundleName</key>
Expand All @@ -46,6 +44,19 @@
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.atomex.deepliks</string>
<key>CFBundleURLSchemes</key>
<array>
<string>atomex</string>
</array>
<key>CFBundleTypeRole</key>
<string>None</string>
</dict>
</array>
<key>UIAppFonts</key>
<array>
<string>Roboto-Bold.ttf</string>
Expand Down
4 changes: 3 additions & 1 deletion atomex.iOS/Main.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UIKit;
using Beacon.Sdk.Core.Infrastructure.Cryptography.Libsodium;
using UIKit;

namespace atomex.iOS
{
Expand All @@ -7,6 +8,7 @@ public class Application
// This is the main entry point of the application.
static void Main(string[] args)
{
Sodium.SetLibraryType(SodiumLibraryType.StaticInternal);
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, "AppDelegate");
Expand Down
22 changes: 19 additions & 3 deletions atomex.iOS/atomex.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<AssemblyName>atomex.iOS</AssemblyName>
<MtouchEnableSGenConc>true</MtouchEnableSGenConc>
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
<MtouchExtraArgs>--interpreter -gcc_flags "-L${ProjectDir} -lsodium -force_load ${ProjectDir}/libsodium.a"</MtouchExtraArgs>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -29,6 +30,7 @@
<CodesignKey>Apple Development: Igor Matcak (572BY3ZBQR)</CodesignKey>
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
<CodesignProvision>VS: com.atomex.ios Development</CodesignProvision>
<MtouchExtraArgs>--interpreter -gcc_flags "-L${ProjectDir} -lsodium -force_load ${ProjectDir}/libsodium.a"</MtouchExtraArgs>
<LangVersion>8.0</LangVersion>
<MtouchExtraArgs>--interpreter</MtouchExtraArgs>
</PropertyGroup>
Expand All @@ -42,6 +44,7 @@
<MtouchLink>None</MtouchLink>
<MtouchArch>x86_64</MtouchArch>
<CodesignKey>Apple Distribution: ATOMEX OU (BJT6S7XYJV)</CodesignKey>
<MtouchExtraArgs>--interpreter -gcc_flags "-L${ProjectDir} -lsodium -force_load ${ProjectDir}/libsodium.a"</MtouchExtraArgs>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
Expand All @@ -60,7 +63,7 @@
<LangVersion>8.0</LangVersion>
<MtouchInterpreter>-all</MtouchInterpreter>
<CodesignProvision>Atomex Development</CodesignProvision>
<MtouchExtraArgs>--interpreter</MtouchExtraArgs>
<MtouchExtraArgs>--interpreter -gcc_flags "-L${ProjectDir} -lsodium -force_load ${ProjectDir}/libsodium.a"</MtouchExtraArgs>
<MtouchFastDev>false</MtouchFastDev>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
Expand All @@ -71,6 +74,7 @@
<WarningLevel>4</WarningLevel>
<MtouchArch>ARM64</MtouchArch>
<CodesignKey>iPhone Distribution</CodesignKey>
<MtouchExtraArgs>--interpreter -gcc_flags "-L${ProjectDir} -lsodium -force_load ${ProjectDir}/libsodium.a"</MtouchExtraArgs>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<MtouchFloat32>true</MtouchFloat32>
<MtouchLink>SdkOnly</MtouchLink>
Expand All @@ -92,7 +96,6 @@
<Compile Include="CustomElements\CustomPickerRenderer.cs" />
<Compile Include="CustomElements\CustomViewCellRenderer.cs" />
<None Include="EntitlementsDev.plist" />
<None Include="libsodium.framework\libsodium" />
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="Resources\LaunchScreen.storyboard" />
Expand Down Expand Up @@ -734,6 +737,9 @@
<Reference Include="System.Numerics.Vectors" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Beacon.Sdk">
<Version>1.0.12</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2291" />
<PackageReference Include="Xamarin.Essentials" Version="1.7.1" />
<PackageReference Include="ZXing.Net.Mobile.Forms">
Expand Down Expand Up @@ -959,7 +965,6 @@
<Folder Include="Assets.xcassets\ic_exchange.imageset\" />
<Folder Include="Assets.xcassets\USDT_XTZ.imageset\" />
<Folder Include="Assets.xcassets\ic_forward.imageset\" />
<Folder Include="libsodium.framework\" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\Agency-FB.ttf" />
Expand Down Expand Up @@ -988,4 +993,15 @@
<BundleResource Include="Resources\Inter-SemiBold.ttf" />
<BundleResource Include="Resources\Inter-Thin.ttf" />
</ItemGroup>
<ItemGroup>
<None Include="libsodium.a">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<NativeReference Include="libsodium.a">
<Kind>Static</Kind>
<SmartLink>False</SmartLink>
</NativeReference>
</ItemGroup>
</Project>
Binary file added atomex.iOS/libsodium.a
Binary file not shown.
Binary file removed atomex.iOS/libsodium.framework/libsodium
Binary file not shown.
18 changes: 18 additions & 0 deletions atomex.sln
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,24 @@ Global
{973E3C65-B305-4DB3-AE78-7694E7F38A92}.ReleasePlayMarket|iPhone.Build.0 = Release|Any CPU
{973E3C65-B305-4DB3-AE78-7694E7F38A92}.ReleasePlayMarket|iPhoneSimulator.ActiveCfg = Release|Any CPU
{973E3C65-B305-4DB3-AE78-7694E7F38A92}.ReleasePlayMarket|iPhoneSimulator.Build.0 = Release|Any CPU
{4025F737-1DBA-4AFA-BE9B-E76D9FB48B08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4025F737-1DBA-4AFA-BE9B-E76D9FB48B08}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4025F737-1DBA-4AFA-BE9B-E76D9FB48B08}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{4025F737-1DBA-4AFA-BE9B-E76D9FB48B08}.Debug|iPhone.Build.0 = Debug|Any CPU
{4025F737-1DBA-4AFA-BE9B-E76D9FB48B08}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{4025F737-1DBA-4AFA-BE9B-E76D9FB48B08}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{4025F737-1DBA-4AFA-BE9B-E76D9FB48B08}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4025F737-1DBA-4AFA-BE9B-E76D9FB48B08}.Release|Any CPU.Build.0 = Release|Any CPU
{4025F737-1DBA-4AFA-BE9B-E76D9FB48B08}.Release|iPhone.ActiveCfg = Release|Any CPU
{4025F737-1DBA-4AFA-BE9B-E76D9FB48B08}.Release|iPhone.Build.0 = Release|Any CPU
{4025F737-1DBA-4AFA-BE9B-E76D9FB48B08}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{4025F737-1DBA-4AFA-BE9B-E76D9FB48B08}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{4025F737-1DBA-4AFA-BE9B-E76D9FB48B08}.ReleasePlayMarket|Any CPU.ActiveCfg = Debug|Any CPU
{4025F737-1DBA-4AFA-BE9B-E76D9FB48B08}.ReleasePlayMarket|Any CPU.Build.0 = Debug|Any CPU
{4025F737-1DBA-4AFA-BE9B-E76D9FB48B08}.ReleasePlayMarket|iPhone.ActiveCfg = Debug|Any CPU
{4025F737-1DBA-4AFA-BE9B-E76D9FB48B08}.ReleasePlayMarket|iPhone.Build.0 = Debug|Any CPU
{4025F737-1DBA-4AFA-BE9B-E76D9FB48B08}.ReleasePlayMarket|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{4025F737-1DBA-4AFA-BE9B-E76D9FB48B08}.ReleasePlayMarket|iPhoneSimulator.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
18 changes: 17 additions & 1 deletion atomex/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public App()
StartViewModel startViewModel = new StartViewModel(AtomexApp);
var mainPage = new StartPage(startViewModel);
MainPage = new NavigationPage(mainPage);
startViewModel?.SetNavigationService(mainPage);
startViewModel.SetNavigationService(mainPage);
}

protected override void OnStart()
Expand All @@ -118,6 +118,22 @@ protected override void OnResume()
// Handle when your app resumes
}

public void OnDeepLinkReceived(string value)
{
var mainPage = MainPage;
if (mainPage is NavigationPage)
{
var navigation = mainPage as NavigationPage;
var root = navigation?.RootPage as INavigationService;
root?.ConnectDappByDeepLink(value);

return;
}

var tabbedPage = mainPage as INavigationService;
tabbedPage?.ConnectDappByDeepLink(value);
}

private void LoadStyles()
{
if (IsSmallScreen)
Expand Down
19 changes: 19 additions & 0 deletions atomex/Models/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace atomex.Models
{
public static class Constants
{
public const string YoutubeUrl = "https://www.youtube.com/c/BakingBad";
public const string TwitterUrl = "https://twitter.com/atomex_official";
public const string TelegramUrl = "https://t.me/atomex_official";
public const string SupportUrl = "mailto:[email protected]";

public static string[] WertRedirectedUrls =
{
"https://widget.wert.io/terms-and-conditions",
"https://widget.wert.io/privacy-policy",
"https://support.wert.io/",
"https://sandbox.wert.io/terms-and-conditions",
"https://sandbox.wert.io/privacy-policy"
};
}
}
11 changes: 11 additions & 0 deletions atomex/Models/CurrencyActionType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.ComponentModel;

namespace atomex.Models
{
public enum CurrencyActionType
{
[Description("Show")] Show,
[Description("Send")] Send,
[Description("Receive")] Receive
}
}
15 changes: 15 additions & 0 deletions atomex/Models/CurrencyTab.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.ComponentModel;

namespace atomex.Models
{
public enum CurrencyTab
{
[Description("Activity")] Activity,
[Description("Collectibles")] Collectibles,
[Description("Addresses")] Addresses,
[Description("Delegations")] Delegations,
[Description("Tokens")] Tokens,
[Description("Details")] Details,
[Description("Dapps")] Dapps
}
}
10 changes: 10 additions & 0 deletions atomex/Models/DelegationSortField.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace atomex.Models
{
public enum DelegationSortField
{
ByRating,
ByRoi,
ByValidator,
ByMinTez
}
}
Loading

0 comments on commit 37c5d4f

Please sign in to comment.