-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/signatures
- Loading branch information
Showing
18 changed files
with
169 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using Android.Content; | ||
using Android.Net; | ||
using Diplomatic.Droid.Classes; | ||
using Diplomatic.Interfaces; | ||
using Java.IO; | ||
|
||
[assembly: Xamarin.Forms.Dependency(typeof(Picture_Droid))] | ||
|
||
namespace Diplomatic.Droid.Classes | ||
{ | ||
public class Picture_Droid : IPicture | ||
{ | ||
public void SavePictureToDisk(string filename, byte[] imageArray) | ||
{ | ||
File dir = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDcim); | ||
string pictures = dir.Path; | ||
|
||
string FilePath = System.IO.Path.Combine(pictures, filename+".png"); | ||
try | ||
{ | ||
// Write file to the android disk | ||
System.IO.File.WriteAllBytes(FilePath, imageArray); | ||
|
||
// Now it needs to be added to image gallery | ||
var mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile); | ||
mediaScanIntent.SetData(Android.Net.Uri.FromFile(new File(FilePath))); | ||
Android.App.Application.Context.SendBroadcast(mediaScanIntent); | ||
} | ||
catch (System.Exception e) | ||
{ | ||
System.Console.WriteLine(e.ToString()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.Diplomatic" android:installLocation="auto"> | ||
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="27" /> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
<application android:label="Diplomatic.Android" android:icon="@drawable/icon512"></application> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,5 @@ | |
android:gravity="center"/> | ||
</item> | ||
</layer-list> | ||
|
||
<!----> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using Diplomatic.Interfaces; | ||
using Diplomatic.iOS.Classes; | ||
using Foundation; | ||
using UIKit; | ||
|
||
[assembly: Xamarin.Forms.Dependency(typeof(Picture_iOS))] | ||
namespace Diplomatic.iOS.Classes | ||
{ | ||
public class Picture_iOS : IPicture | ||
{ | ||
public void SavePictureToDisk(string filename, byte[] imageArray) | ||
{ | ||
var Img = new UIImage(NSData.FromArray(imageArray)); | ||
Img.SaveToPhotosAlbum((image, error) => | ||
{ | ||
if (error != null) | ||
{ | ||
Console.WriteLine(error); | ||
} | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using System; | ||
namespace Diplomatic.Interfaces | ||
{ | ||
public interface IPicture | ||
{ | ||
void SavePictureToDisk(string filename, byte[] imageArray); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Xamarin.Forms; | ||
|
||
namespace Diplomatic.Utils.Triggers | ||
{ | ||
public class OpacityTriggerAction : TriggerAction<VisualElement> | ||
{ | ||
public int StartsFrom { set; get; } = 0; | ||
|
||
protected override void Invoke(VisualElement visual) | ||
{ | ||
visual.Animate("label", new Animation((d) => { | ||
var val = StartsFrom == 0 ? d : 1 - d; | ||
visual.Opacity = val; | ||
|
||
}), | ||
length: 500, | ||
easing: Easing.Linear); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
using Xamarin.Forms; | ||
using Xamarin.Forms; | ||
|
||
namespace Diplomatic.Utils.Triggers | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using System.Net; | ||
using Diplomatic.Interfaces; | ||
using Diplomatic.ViewModels; | ||
using Xamarin.Forms; | ||
using Xamarin.Forms.Xaml; | ||
|
||
namespace Diplomatic.Views | ||
{ | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
public partial class Result : ContentPage | ||
{ | ||
public Result () | ||
{ | ||
InitializeComponent (); | ||
} | ||
} | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
public partial class Result : ContentPage | ||
{ | ||
public Result() | ||
{ | ||
InitializeComponent(); | ||
} | ||
public async void SaveButtonClicked(object sender, EventArgs e) | ||
{ | ||
using (var webClient = new WebClient()) | ||
{ | ||
string Filename = ((ResultViewModel)BindingContext).Filename; | ||
byte[] imageBytes = await webClient.DownloadDataTaskAsync(((ResultViewModel)BindingContext).ImageUri); | ||
DependencyService.Get<IPicture>().SavePictureToDisk(Filename, imageBytes); | ||
await DisplayAlert("Save diploma", "Your diploma has been saved!", "OK"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters