Skip to content

Commit

Permalink
ATM-199 Mobile app optimization (#65)
Browse files Browse the repository at this point in the history
* Load improvements, caching VMs with disposing, TezosTokenVMCreator and Fa2CurrencyVM created

* Loader for token transfers, refactoring

* Client core related changes

* Loader for tezos tokens, refactoring

* USDT (Fa2) support

* Binding height for all listviews on currency page

* Token restoring changed + few fixes

* Disabled tokens to user data

* Is restoring snackbar for portfolio

* Unhandled exception fix

* Update launcher icon

* All addresses to AddressesVM

* Few fixes

* Unsubscribe events after disposing VMs

* Fixed exception, daily percent layout changes

* Balance updated event handler optimization

* Add final swap params checking

* Add Sentry and Serilog logging to Atomex.Android, fix bug with static view model creators

* Boost TezosTokenViewModel creation

* Add reference to Atomex.TzktEvents

* Build v1.15.2

* Fix ATM-260 and ATM-263

* Increase versions to v1.16.0

Co-authored-by: mismirnov <[email protected]>
  • Loading branch information
matsakiv and mismirnov authored Jul 12, 2022
1 parent 929d359 commit 14a4949
Show file tree
Hide file tree
Showing 113 changed files with 2,594 additions and 1,186 deletions.
34 changes: 26 additions & 8 deletions atomex.Android/Atomex.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
<Reference Include="System.Numerics.Vectors" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Serilog.Sinks.Xamarin">
<Version>0.2.0.64</Version>
</PackageReference>
<PackageReference Include="System.Net.Http">
<Version>4.3.4</Version>
</PackageReference>
<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" />
Expand Down Expand Up @@ -167,10 +173,6 @@
<SubType></SubType>
<Generator></Generator>
</AndroidResource>
<AndroidResource Include="Resources\drawable\ic_launcher.png">
<SubType></SubType>
<Generator></Generator>
</AndroidResource>
<AndroidResource Include="Resources\drawable\RightArrow__black.xml">
<SubType></SubType>
<Generator></Generator>
Expand Down Expand Up @@ -304,10 +306,6 @@
<SubType></SubType>
<Generator></Generator>
</AndroidResource>
<AndroidResource Include="Resources\drawable-night\ic_launcher.png">
<SubType></SubType>
<Generator></Generator>
</AndroidResource>
<AndroidResource Include="Resources\drawable-night\ic_notification.png">
<SubType></SubType>
<Generator></Generator>
Expand Down Expand Up @@ -852,6 +850,22 @@
<SubType></SubType>
<Generator></Generator>
</AndroidResource>
<AndroidResource Include="Resources\drawable\USDT_XTZ.xml">
<SubType></SubType>
<Generator></Generator>
</AndroidResource>
<AndroidResource Include="Resources\drawable-night\USDT_XTZ.xml">
<SubType></SubType>
<Generator></Generator>
</AndroidResource>
<AndroidResource Include="Resources\drawable\ic_launcher.png">
<SubType></SubType>
<Generator></Generator>
</AndroidResource>
<AndroidResource Include="Resources\drawable-night\ic_launcher.png">
<SubType></SubType>
<Generator></Generator>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\drawable\" />
Expand All @@ -863,6 +877,10 @@
<Folder Include="Assets\Animations\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\atomex.client.core\Atomex.TzktEvents\Atomex.TzktEvents.csproj">
<Project>{4E3C8932-3924-4519-A49B-4D76F9FB2117}</Project>
<Name>Atomex.TzktEvents</Name>
</ProjectReference>
<ProjectReference Include="..\atomex\atomex.csproj">
<Project>{6A6C43B1-1489-4B8D-AA37-941EF60E36F0}</Project>
<Name>atomex</Name>
Expand Down
101 changes: 69 additions & 32 deletions atomex.Android/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
using Android.App;
using System;
using System.Net.Http;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;

using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Gms.Extensions;
using Android.OS;
using Atomex.Common;
using atomex.Common.FileSystem;
using Plugin.Fingerprint;
using Android.Runtime;
using Android.Views;
using Xamarin.Forms;
using Firebase.Messaging;
using Android.Gms.Extensions;
using System.Threading.Tasks;
using Serilog.Debugging;
using Plugin.Fingerprint;
using Sentry;
using Serilog;
using Serilog.Events;
using Sentry;
using Xamarin.Forms;

using atomex.Common.FileSystem;
using Atomex.Common;
using Atomex.TzktEvents;

namespace atomex.Droid
{
Expand All @@ -24,13 +30,18 @@ public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompa

protected override void OnCreate(Bundle bundle)
{
ConfigureLogging();

Forms.SetFlags("Brush_Experimental");
Forms.SetFlags("Shapes_Experimental");

base.OnCreate(bundle);

FileSystem.UseFileSystem(new AndroidFileSystem());

// disable ssl certificate check for TzKT
TzktEventsClient.ServerCertificateCustomValidationCallback = ServerCertificateCustomValidationCallback;

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

Window.SetNavigationBarColor(Android.Graphics.Color.ParseColor(ApplicationContext.Resources.GetString(Resource.Color.colorPrimary)));
Expand All @@ -50,16 +61,22 @@ protected override void OnCreate(Bundle bundle)
global::ZXing.Net.Mobile.Forms.Android.Platform.Init();

App.FileSystem = Device.Android;
_ = GetDeviceToken();

_ = GetDeviceTokenAsync();

AndroidEnvironment.UnhandledExceptionRaiser += AndroidUnhandledExceptionRaiser;

LoadApplication(new App());
}

protected override void OnDestroy()
{
base.OnDestroy();
}

private void AndroidUnhandledExceptionRaiser(object sender, RaiseThrowableEventArgs e)
{
SentrySdk.CaptureException(e.Exception);
Log.Error(e.Exception, "Android unhandled exception");
}

public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
Expand All @@ -70,42 +87,62 @@ public override void OnRequestPermissionsResult(int requestCode, string[] permis
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}

private async Task GetDeviceToken()
private async Task GetDeviceTokenAsync()
{
string token = (await FirebaseMessaging.Instance.GetToken()).ToString();
App.DeviceToken = token;
//StartSentry();
}
try
{
var token = await FirebaseMessaging.Instance.GetToken();

private void StartSentry()
{
SelfLog.Enable(m => Log.Error(m));
SentrySdk.Init("https://newsentry.baking-bad.org/api/4/?sentry_key=dee6b20f797d4dff97b8bcdbd738a583");
App.DeviceToken = token.ToString();

//SentryXamarin.Init(o =>
//{
// o.Dsn = "https://newsentry.baking-bad.org/api/4/?sentry_key=dee6b20f797d4dff97b8bcdbd738a583";
// o.Debug = true;
//});
Log.Debug("DeviceToken: {@token}", App.DeviceToken);

SentrySdk.ConfigureScope(scope =>
// apply device token to sentry
SentrySdk.ConfigureScope(scope =>
{
scope.SetTag("device_token", App.DeviceToken);
});
}
catch (Exception e)
{
Log.Error(e, "Get device token error");
}
}

private void ConfigureLogging()
{
SentryXamarin.Init(o =>
{
scope.SetTag("platform", "android");
scope.SetTag("device_token", App.DeviceToken);
o.Dsn = "https://[email protected]/4";
o.CreateHttpClientHandler = () => new HttpClientHandler()
{
ServerCertificateCustomValidationCallback = ServerCertificateCustomValidationCallback
};
});

Log.Logger = new LoggerConfiguration()
.Enrich.FromLogContext()
.MinimumLevel.Debug()
.WriteTo.AndroidLog()
.WriteTo.Sentry(o =>
{
o.TracesSampleRate = 1.0;
//o.TracesSampleRate = 1.0;
o.MinimumEventLevel = LogEventLevel.Error;
o.MinimumBreadcrumbLevel = LogEventLevel.Error;
o.AttachStacktrace = true;
o.SendDefaultPii = true;
//o.SendDefaultPii = true;
o.InitializeSdk = false;
}).CreateLogger();
})
.CreateLogger();
}

private static bool ServerCertificateCustomValidationCallback(
HttpRequestMessage message,
X509Certificate2 cert,
X509Chain chan,
SslPolicyErrors policyErrors)
{
return true;
}
}
}
2 changes: 1 addition & 1 deletion atomex.Android/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.15.0" package="com.atomex.android" android:versionCode="26">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.16.0" package="com.atomex.android" android:versionCode="30">
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="30" />
<application android:label="Atomex" android:allowBackup="false" android:icon="@drawable/ic_launcher">
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/ic_notification" />
Expand Down
13 changes: 8 additions & 5 deletions atomex.Android/Resources/Resource.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions atomex.Android/Resources/drawable-night/USDT_XTZ.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="30dp"
android:viewportWidth="32"
android:viewportHeight="30">
<path
android:pathData="M0.021,12.6845L5.1264,2.1179C5.1431,2.0823 5.1699,2.0522 5.2036,2.0313C5.2372,2.0104 5.2763,1.9995 5.3161,2H22.6846C22.7242,1.9999 22.763,2.011 22.7964,2.0321C22.8297,2.0531 22.8562,2.0832 22.8727,2.1187L27.9781,12.6853C27.9975,12.7246 28.0037,12.769 27.9957,12.812C27.9944,12.8187 27.9928,12.8253 27.9909,12.8318C27.4903,12.6146 26.9651,12.4356 26.418,12.2992C21.0612,10.9636 15.6347,14.2242 14.2996,19.582C13.7922,21.6159 13.9474,23.6597 14.6285,25.4859L14.1451,25.9423C14.106,25.9793 14.0538,26 13.9995,26C13.9453,26 13.8931,25.9793 13.8539,25.9423L0.0655,12.9234C0.0332,12.8935 0.0114,12.8542 0.0034,12.8112C-0.0046,12.7682 0.0016,12.7238 0.021,12.6845Z"
android:fillColor="#50AF95"
android:fillType="evenOdd"/>
<path
android:pathData="M14.0198,13.8065C15.1606,13.8065 15.6721,13.7765 15.7711,13.7691L15.7678,13.7683C16.8587,13.7207 17.8633,13.6295 18.7293,13.5047C18.391,13.7146 18.0651,13.9445 17.7536,14.1935C17.1298,14.2592 16.4651,14.309 15.7702,14.3405V16.319C15.1052,17.2821 14.5993,18.3792 14.2996,19.582C14.1747,20.0823 14.09,20.5831 14.0434,21.0812H12.2413V14.343C8.2726,14.1625 5.2881,13.3887 5.2881,12.4605C5.2881,11.5323 8.2726,10.7577 12.2413,10.578V8.4761H7.3586V5.2695H20.6546V8.4761H15.7711V10.5781C15.7708,10.578 15.7705,10.578 15.7702,10.578L15.7711,10.5788V10.5781C19.2134,10.7349 21.9121,11.3397 22.5604,12.1039C22.3287,12.1377 22.0989,12.1796 21.8713,12.2294C21.7168,11.5403 19.1591,10.9708 15.7678,10.8219V13.1709C15.6696,13.1798 15.1243,13.2245 14.0355,13.2245C13.1281,13.2245 12.4714,13.1863 12.2421,13.1701V10.8202C8.7354,10.9747 6.1179,11.5753 6.1179,12.2955C6.1179,13.0157 8.7354,13.6171 12.2421,13.7691C12.4681,13.7797 13.1124,13.8065 14.0198,13.8065Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
<path
android:pathData="M24,22m-8,0a8,8 0,1 1,16 0a8,8 0,1 1,-16 0"
android:fillColor="#0C60FF"/>
<path
android:pathData="M27.6903,24.3401C27.5833,22.5319 25.2001,21.71 24.972,21.6256C24.9627,21.6212 24.9627,21.6123 24.9674,21.6034L27.425,19.2487V18.9955C27.425,18.9555 27.3878,18.9199 27.3459,18.9199H22.8169V17.5027V17.0762L21.1459,17.4094V17.6493H21.239C21.239,17.6493 21.6486,17.6493 21.6486,18.0403V18.9155H20.3547C20.3314,18.9155 20.3081,18.9377 20.3081,18.9599V19.5153H21.6533C21.6533,19.5153 21.6533,20.1062 21.6533,20.7948V22.5319C21.6533,23.4782 22.291,24.1358 23.4081,24.0469C23.6455,24.0291 23.8642,23.9403 24.0504,23.8248C24.1342,23.7715 24.1854,23.6871 24.1854,23.5893V23.2916C23.8223,23.5227 23.5151,23.5093 23.5151,23.5093C22.8076,23.5093 22.8216,22.6519 22.8216,22.6519V19.5153H26.0798L23.7339,21.7722C23.7293,22.0699 23.7246,22.3009 23.7246,22.3053C23.7246,22.3142 23.7293,22.3187 23.7386,22.3187C25.889,22.6652 26.4708,23.9936 26.4708,24.3801C26.4708,24.3801 26.7036,26.2594 24.7347,26.3883C24.7347,26.3883 23.4453,26.4416 23.2172,25.9484C23.2079,25.9307 23.2172,25.9129 23.2359,25.904C23.45,25.8107 23.5943,25.6286 23.5943,25.3842C23.5943,25.0199 23.3615,24.7222 22.8728,24.7222C22.4772,24.7222 22.1513,25.0199 22.1513,25.3842C22.1513,25.3842 21.9652,26.9658 24.73,26.9214C27.8858,26.8681 27.6903,24.3401 27.6903,24.3401Z"
android:fillColor="#ffffff"/>
</vector>
Binary file modified atomex.Android/Resources/drawable-night/ic_launcher.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions atomex.Android/Resources/drawable/USDT_XTZ.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="30dp"
android:viewportWidth="32"
android:viewportHeight="30">
<path
android:pathData="M0.021,12.6845L5.1264,2.1179C5.1431,2.0823 5.1699,2.0522 5.2036,2.0313C5.2372,2.0104 5.2763,1.9995 5.3161,2H22.6846C22.7242,1.9999 22.763,2.011 22.7964,2.0321C22.8297,2.0531 22.8562,2.0832 22.8727,2.1187L27.9781,12.6853C27.9975,12.7246 28.0037,12.769 27.9957,12.812C27.9944,12.8187 27.9928,12.8253 27.9909,12.8318C27.4903,12.6146 26.9651,12.4356 26.418,12.2992C21.0612,10.9636 15.6347,14.2242 14.2996,19.582C13.7922,21.6159 13.9474,23.6597 14.6285,25.4859L14.1451,25.9423C14.106,25.9793 14.0538,26 13.9995,26C13.9453,26 13.8931,25.9793 13.8539,25.9423L0.0655,12.9234C0.0332,12.8935 0.0114,12.8542 0.0034,12.8112C-0.0046,12.7682 0.0016,12.7238 0.021,12.6845Z"
android:fillColor="#50AF95"
android:fillType="evenOdd"/>
<path
android:pathData="M14.0198,13.8065C15.1606,13.8065 15.6721,13.7765 15.7711,13.7691L15.7678,13.7683C16.8587,13.7207 17.8633,13.6295 18.7293,13.5047C18.391,13.7146 18.0651,13.9445 17.7536,14.1935C17.1298,14.2592 16.4651,14.309 15.7702,14.3405V16.319C15.1052,17.2821 14.5993,18.3792 14.2996,19.582C14.1747,20.0823 14.09,20.5831 14.0434,21.0812H12.2413V14.343C8.2726,14.1625 5.2881,13.3887 5.2881,12.4605C5.2881,11.5323 8.2726,10.7577 12.2413,10.578V8.4761H7.3586V5.2695H20.6546V8.4761H15.7711V10.5781C15.7708,10.578 15.7705,10.578 15.7702,10.578L15.7711,10.5788V10.5781C19.2134,10.7349 21.9121,11.3397 22.5604,12.1039C22.3287,12.1377 22.0989,12.1796 21.8713,12.2294C21.7168,11.5403 19.1591,10.9708 15.7678,10.8219V13.1709C15.6696,13.1798 15.1243,13.2245 14.0355,13.2245C13.1281,13.2245 12.4714,13.1863 12.2421,13.1701V10.8202C8.7354,10.9747 6.1179,11.5753 6.1179,12.2955C6.1179,13.0157 8.7354,13.6171 12.2421,13.7691C12.4681,13.7797 13.1124,13.8065 14.0198,13.8065Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
<path
android:pathData="M24,22m-8,0a8,8 0,1 1,16 0a8,8 0,1 1,-16 0"
android:fillColor="#0C60FF"/>
<path
android:pathData="M27.6903,24.3401C27.5833,22.5319 25.2001,21.71 24.972,21.6256C24.9627,21.6212 24.9627,21.6123 24.9674,21.6034L27.425,19.2487V18.9955C27.425,18.9555 27.3878,18.9199 27.3459,18.9199H22.8169V17.5027V17.0762L21.1459,17.4094V17.6493H21.239C21.239,17.6493 21.6486,17.6493 21.6486,18.0403V18.9155H20.3547C20.3314,18.9155 20.3081,18.9377 20.3081,18.9599V19.5153H21.6533C21.6533,19.5153 21.6533,20.1062 21.6533,20.7948V22.5319C21.6533,23.4782 22.291,24.1358 23.4081,24.0469C23.6455,24.0291 23.8642,23.9403 24.0504,23.8248C24.1342,23.7715 24.1854,23.6871 24.1854,23.5893V23.2916C23.8223,23.5227 23.5151,23.5093 23.5151,23.5093C22.8076,23.5093 22.8216,22.6519 22.8216,22.6519V19.5153H26.0798L23.7339,21.7722C23.7293,22.0699 23.7246,22.3009 23.7246,22.3053C23.7246,22.3142 23.7293,22.3187 23.7386,22.3187C25.889,22.6652 26.4708,23.9936 26.4708,24.3801C26.4708,24.3801 26.7036,26.2594 24.7347,26.3883C24.7347,26.3883 23.4453,26.4416 23.2172,25.9484C23.2079,25.9307 23.2172,25.9129 23.2359,25.904C23.45,25.8107 23.5943,25.6286 23.5943,25.3842C23.5943,25.0199 23.3615,24.7222 22.8728,24.7222C22.4772,24.7222 22.1513,25.0199 22.1513,25.3842C22.1513,25.3842 21.9652,26.9658 24.73,26.9214C27.8858,26.8681 27.6903,24.3401 27.6903,24.3401Z"
android:fillColor="#ffffff"/>
</vector>
Binary file modified atomex.Android/Resources/drawable/ic_launcher.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion atomex.client.core
Loading

0 comments on commit 14a4949

Please sign in to comment.