Skip to content
This repository was archived by the owner on Mar 26, 2024. It is now read-only.

Remove access to External Storage, Update Packages #54

Merged
merged 1 commit into from
Apr 5, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v11.0</TargetFrameworkVersion>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
Expand All @@ -30,6 +30,10 @@
<AndroidLinkMode>None</AndroidLinkMode>
<AndroidSupportedAbis>armeabi-v7a;x86</AndroidSupportedAbis>
<MandroidI18n />
<AotAssemblies>false</AotAssemblies>
<EnableLLVM>false</EnableLLVM>
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
<BundleAssemblies>false</BundleAssemblies>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
Expand Down Expand Up @@ -106,23 +110,31 @@
<PackageReference Include="UXDivers.GorillaPlayer.SDK">
<Version>1.5.5</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.AppCompat">
<Version>1.1.0.2</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.MediaRouter">
<Version>1.2.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.FFImageLoading.Forms">
<Version>2.4.11.982</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="4.5.0.617" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2083" />
<PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v4" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v7.CardView" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v7.MediaRouter" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.1.0.5-rc3" />
<PackageReference Include="Xamarin.AndroidX.Palette" Version="1.0.0.5" />
<PackageReference Include="ZXing.Net.Mobile.Forms">
<Version>2.4.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.FFImageLoading.Transformations">
<Version>2.4.11.982</Version>
</PackageReference>
<PackageReference Include="Xamarin.Essentials">
<Version>1.5.2</Version>
<Version>1.7.0</Version>
</PackageReference>
<PackageReference Include="Rg.Plugins.Popup">
<Version>2.0.0.2</Version>
Expand Down Expand Up @@ -192,4 +204,4 @@
<UserProperties TriggeredFromHotReload="False" />
</VisualStudio>
</ProjectExtensions>
</Project>
</Project>
26 changes: 14 additions & 12 deletions src/Hyperledger.Aries.Max.Android/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Android;
using Android.App;
using Android.Content.PM;
using Android.OS;
using Android.Systems;
using FFImageLoading.Forms.Platform;
using Java.Lang;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Hyperledger.Aries.Max.Android;
using Xamarin.Forms;
using Resource = Hyperledger.Aries.Max.Android.Resource;
using Xamarin.Essentials;
using Xamarin.Forms.Xaml;

namespace Hyperledger.Aries.Max.Droid
{
[Activity(Label = "AriesMax", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
[Activity(Label = "AriesMax", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, Exported = true)]
[XamlCompilation(XamlCompilationOptions.Compile)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
Expand All @@ -40,9 +42,11 @@ protected override void OnCreate(Bundle bundle)

// Initializing User Dialogs
// Android requires that we set content root.
var host = Hyperledger.Aries.Max.App.BuildHost(typeof(PlatformModule).Assembly)
.UseContentRoot(System.Environment.GetFolderPath(
System.Environment.SpecialFolder.Personal)).Build();
var host = App.BuildHost(typeof(PlatformModule).Assembly)
.UseContentRoot(System.Environment.GetFolderPath(
System.Environment.SpecialFolder.Personal)).Build();

Os.Setenv("EXTERNAL_STORAGE", FileSystem.AppDataDirectory, true);

//Loading dependent libindy
JavaSystem.LoadLibrary("c++_shared");
Expand All @@ -55,8 +59,6 @@ protected override void OnCreate(Bundle bundle)

readonly string[] _permissionsRequired =
{
Manifest.Permission.ReadExternalStorage,
Manifest.Permission.WriteExternalStorage,
Manifest.Permission.Camera
};

Expand Down Expand Up @@ -85,9 +87,9 @@ public override void OnRequestPermissionsResult(int requestCode, string[] permis
System.Diagnostics.Debug.WriteLine("All permissions required that werent granted, have now been granted");
else
System.Diagnostics.Debug.WriteLine("Some permissions requested were denied by the user");
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);

Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
}
Expand Down
13 changes: 7 additions & 6 deletions src/Hyperledger.Aries.Max.Android/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="0.1.0" package="com.ariesmax" android:installLocation="internalOnly">
<uses-sdk android:minSdkVersion="25" android:targetSdkVersion="29" />
<application android:requestLegacyExternalStorage="true" android:label="AriesMax"></application>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:versionCode="1" android:versionName="0.1.0" package="com.ariesmax" android:installLocation="internalOnly">
<uses-sdk android:minSdkVersion="25" android:targetSdkVersion="30" />
<application android:label="AriesMax" android:allowBackup="false" android:fullBackupOnly="false"></application>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" tools:node="remove" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:node="remove" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="remove" />
<uses-permission android:name="android.permission.CAMERA" />
</manifest>
2 changes: 0 additions & 2 deletions src/Hyperledger.Aries.Max.Android/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Android.App;

Expand Down Expand Up @@ -31,4 +30,3 @@

// Add some common permissions, these can be removed if not needed
[assembly: UsesPermission(Android.Manifest.Permission.Internet)]
[assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@
<PackageReference Include="Xamarin.FFImageLoading.Forms">
<Version>2.4.11.982</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="4.5.0.617" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2083" />
<PackageReference Include="ZXing.Net.Mobile.Forms">
<Version>2.4.1</Version>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions src/Hyperledger.Aries.Max/Hyperledger.Aries.Max.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
<PackageReference Include="ReactiveUI" Version="11.3.1" />
<PackageReference Include="Rg.Plugins.Popup" Version="2.0.0.2" />
<PackageReference Include="Xamarin.FFImageLoading.Forms" Version="2.4.11.982" />
<PackageReference Include="Xamarin.Forms" Version="4.5.0.617" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2083" />
<PackageReference Include="ZXing.Net.Mobile" Version="2.4.1" />
<PackageReference Include="ZXing.Net.Mobile.Forms" Version="2.4.1" />
<PackageReference Include="West.Extensions.XamarinHosting" Version="3.0.0-preview1" />
<PackageReference Include="Xamarin.FFImageLoading.Transformations" Version="2.4.11.982" />
<PackageReference Include="Xamarin.Essentials" Version="1.5.2" />
<PackageReference Include="Xamarin.Essentials" Version="1.7.0" />
<PackageReference Include="Hyperledger.Aries.Routing.Edge" Version="1.6.2" />
</ItemGroup>

Expand Down
3 changes: 2 additions & 1 deletion src/Hyperledger.Aries.Max/Services/PoolConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public async Task ConfigurePoolsAsync()
try
{
// Path for bundled genesis txn
var filename = Path.Combine(FileSystem.CacheDirectory, "genesis.txn");
var filesDir = FileSystem.AppDataDirectory;
var filename = Path.Combine(filesDir, config.Value);

// Dump file contents to cached filename
using (var stream = await FileSystem.OpenAppPackageFileAsync(config.Value))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public async Task RefreshConnections()
var records = await _connectionService.ListAsync(context);

IList<ConnectionViewModel> connectionVms = new List<ConnectionViewModel>();
foreach (var record in records)
foreach (var record in records.OrderByDescending(c => c.CreatedAtUtc))
{
var connection = _scope.Resolve<ConnectionViewModel>(new NamedParameter("record", record));
connectionVms.Add(connection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private async Task CreateInvitation()
TheirAlias = new ConnectionAlias { Name = "Invitation" },
AutoAcceptConnection = true
});
invitation.label = "AriesMax"
invitation.Label = "AriesMax";
string barcodeValue = invitation.ServiceEndpoint + "?c_i=" + Uri.EscapeDataString(invitation.ToByteArray().ToBase64String());
QrCodeValue = barcodeValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public CredentialViewModel(IUserDialogs userDialogs,
this._credential = credential;
this._connection = connection;

CredentialName = _credential.SchemaId.ToCredentialName();
CredentialName = _connection.Alias.Name;
CredentialImageUrl = _connection.Alias.ImageUrl;
CredentialSubtitle = _connection.Alias.Name;
CredentialSubtitle = _credential.State.ToString();
CreatedAt = _credential.CreatedAtUtc?.ToLocalTime();
CredentialState = _credential.State;
_isNew = IsCredentialNew(_credential);
Expand All @@ -65,7 +65,7 @@ public CredentialViewModel(IUserDialogs userDialogs,
Name = x.Name,
Value = x.Value != null ? x.Value.ToString() : string.Empty,
Type = x.MimeType
}));
}).OrderBy(x => x.Name));
}

//#if DEBUG
Expand Down Expand Up @@ -125,7 +125,7 @@ async Task AcceptCredential()
var context = await agentContextProvider.GetContextAsync();

var (request, _) = await credentialService.CreateRequestAsync(context, _credential.Id);
await messageService.SendAsync(context, request, _connection );
await messageService.SendAsync(context, request, _connection);

eventAggregator.Publish(new ApplicationEvent() { Type = ApplicationEventType.CredentialsUpdated });
await NavigationService.PopModalAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public async Task RefreshCredentials()
//#endif

IList<CredentialViewModel> credentialsVms = new List<CredentialViewModel>();
foreach (var credentialRecord in credentialsRecords)
foreach (var credentialRecord in credentialsRecords.OrderByDescending(c => c.CreatedAtUtc))
{
if (credentialRecord.State == CredentialState.Rejected)
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public async Task RefreshProofRequests()
IEnumerable<ProofRecord> proofRequests = (await _proofService.ListRequestedAsync(agentContext));

IList<ProofRequestViewModel> proofRequestVms = new List<ProofRequestViewModel>();
foreach (var proofReq in proofRequests)
foreach (var proofReq in proofRequests.OrderByDescending(c => c.CreatedAtUtc))
{
var connection = await _connectionService.GetAsync(agentContext, proofReq.ConnectionId);
var proofRequestViewModel = _scope.Resolve<ProofRequestViewModel>(new NamedParameter("proofRecord", proofReq), new NamedParameter("connection", connection));
Expand Down