-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added samples from xamarin-forms-samples
- Loading branch information
1 parent
95525c4
commit 9a6f956
Showing
626 changed files
with
27,427 additions
and
0 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,20 @@ | ||
# Set the default behavior, in case people don't have core.autocrlf set. | ||
* text=auto | ||
|
||
# Explicitly declare text files you want to always be normalized and converted | ||
# to native line endings on checkout. | ||
*.c text | ||
*.h text | ||
*.cs text | ||
*.csproj text | ||
|
||
# Declare files that will always have CRLF line endings on checkout. | ||
*.sln text eol=crlf | ||
packages.config text eol=crlf | ||
|
||
# Declare files that will always have LF line endings on checkout. | ||
*.sh text eol=lf | ||
|
||
# Denote all files that are truly binary and should not be modified. | ||
*.png binary | ||
*.jpg binary |
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,195 @@ | ||
## Ignore Visual Studio temporary files, build results, and | ||
## files generated by popular Visual Studio add-ons. | ||
|
||
# Visual Studio (>=2015) project-specific, machine local files | ||
.vs/ | ||
|
||
# User-specific files | ||
*.suo | ||
*.user | ||
*.sln.docstates | ||
*.userprefs | ||
|
||
# ignore Xamarin.Android Resource.Designer.cs files | ||
**/*.Droid/**/[Rr]esource.[Dd]esigner.cs | ||
**/*.Android/**/[Rr]esource.[Dd]esigner.cs | ||
**/Android/**/[Rr]esource.[Dd]esigner.cs | ||
**/Droid/**/[Rr]esource.[Dd]esigner.cs | ||
|
||
# Xamarin Components | ||
Components/ | ||
|
||
# Build results | ||
[Dd]ebug/ | ||
[Dd]ebugPublic/ | ||
[Rr]elease/ | ||
x64/ | ||
build/ | ||
bld/ | ||
[Bb]in/ | ||
[Oo]bj/ | ||
|
||
# MSTest test Results | ||
[Tt]est[Rr]esult*/ | ||
[Bb]uild[Ll]og.* | ||
|
||
#NUNIT | ||
*.VisualState.xml | ||
TestResult.xml | ||
|
||
# Build Results of an ATL Project | ||
[Dd]ebugPS/ | ||
[Rr]eleasePS/ | ||
dlldata.c | ||
|
||
*_i.c | ||
*_p.c | ||
*_i.h | ||
*.ilk | ||
*.meta | ||
*.obj | ||
*.pch | ||
*.pdb | ||
*.pgc | ||
*.pgd | ||
*.rsp | ||
*.sbr | ||
*.tlb | ||
*.tli | ||
*.tlh | ||
*.tmp | ||
*.tmp_proj | ||
*.log | ||
*.vspscc | ||
*.vssscc | ||
.builds | ||
*.pidb | ||
*.svclog | ||
*.scc | ||
|
||
# Chutzpah Test files | ||
_Chutzpah* | ||
|
||
# Visual C++ cache files | ||
ipch/ | ||
*.aps | ||
*.ncb | ||
*.opensdf | ||
*.sdf | ||
*.cachefile | ||
|
||
# Visual Studio profiler | ||
*.psess | ||
*.vsp | ||
*.vspx | ||
|
||
# TFS 2012 Local Workspace | ||
$tf/ | ||
|
||
# Guidance Automation Toolkit | ||
*.gpState | ||
|
||
# ReSharper is a .NET coding add-in | ||
_ReSharper*/ | ||
*.[Rr]e[Ss]harper | ||
*.DotSettings.user | ||
|
||
# JustCode is a .NET coding addin-in | ||
.JustCode | ||
|
||
# TeamCity is a build add-in | ||
_TeamCity* | ||
|
||
# DotCover is a Code Coverage Tool | ||
*.dotCover | ||
|
||
# NCrunch | ||
*.ncrunch* | ||
_NCrunch_* | ||
.*crunch*.local.xml | ||
|
||
# MightyMoose | ||
*.mm.* | ||
AutoTest.Net/ | ||
|
||
# Web workbench (sass) | ||
.sass-cache/ | ||
|
||
# Installshield output folder | ||
[Ee]xpress/ | ||
|
||
# DocProject is a documentation generator add-in | ||
DocProject/buildhelp/ | ||
DocProject/Help/*.HxT | ||
DocProject/Help/*.HxC | ||
DocProject/Help/*.hhc | ||
DocProject/Help/*.hhk | ||
DocProject/Help/*.hhp | ||
DocProject/Help/Html2 | ||
DocProject/Help/html | ||
|
||
# Click-Once directory | ||
publish/ | ||
|
||
# Publish Web Output | ||
*.[Pp]ublish.xml | ||
*.azurePubxml | ||
|
||
# NuGet Packages Directory | ||
packages/ | ||
*.nuget.targets | ||
*.lock.json | ||
*.nuget.props | ||
|
||
## TODO: If the tool you use requires repositories.config uncomment the next line | ||
#!packages/repositories.config | ||
|
||
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets | ||
# This line needs to be after the ignore of the build folder (and the packages folder if the line above has been uncommented) | ||
!packages/build/ | ||
|
||
# Windows Azure Build Output | ||
csx/ | ||
*.build.csdef | ||
|
||
# Windows Store app package directory | ||
AppPackages/ | ||
|
||
# Others | ||
sql/ | ||
*.Cache | ||
ClientBin/ | ||
[Ss]tyle[Cc]op.* | ||
~$* | ||
*~ | ||
*.dbmdl | ||
*.dbproj.schemaview | ||
*.pfx | ||
*.publishsettings | ||
node_modules/ | ||
.DS_Store | ||
*.bak | ||
|
||
# RIA/Silverlight projects | ||
Generated_Code/ | ||
|
||
# Backup & report files from converting an old project file to a newer | ||
# Visual Studio version. Backup files are not needed, because we have git ;-) | ||
_UpgradeReport_Files/ | ||
Backup*/ | ||
UpgradeLog*.XML | ||
UpgradeLog*.htm | ||
|
||
# SQL Server files | ||
*.mdf | ||
*.ldf | ||
|
||
# Business Intelligence projects | ||
*.rdl.data | ||
*.bim.layout | ||
*.bim_*.settings | ||
|
||
# Microsoft Fakes | ||
FakesAssemblies/ | ||
|
||
.vscode/settings.json |
19 changes: 19 additions & 0 deletions
19
samples/Demos/Demos/SkiaSharpFormsDemos.Droid/Assets/AboutAssets.txt
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,19 @@ | ||
Any raw assets you want to be deployed with your application can be placed in | ||
this directory (and child directories) and given a Build Action of "AndroidAsset". | ||
|
||
These files will be deployed with you package and will be accessible using Android's | ||
AssetManager, like this: | ||
|
||
public class ReadAsset : Activity | ||
{ | ||
protected override void OnCreate (Bundle bundle) | ||
{ | ||
base.OnCreate (bundle); | ||
|
||
InputStream input = Assets.Open ("my_asset.txt"); | ||
} | ||
} | ||
|
||
Additionally, some Android functions will automatically load asset files: | ||
|
||
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); |
51 changes: 51 additions & 0 deletions
51
samples/Demos/Demos/SkiaSharpFormsDemos.Droid/MainActivity.cs
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,51 @@ | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
|
||
using Android.App; | ||
using Android.Content; | ||
using Android.Content.PM; | ||
using Android.OS; | ||
|
||
namespace SkiaSharpFormsDemos.Droid | ||
{ | ||
[Activity(Label = "SkiaSharpFormsDemos", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)] | ||
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity | ||
{ | ||
internal static MainActivity Instance { get; private set; } | ||
|
||
protected override void OnCreate(Bundle bundle) | ||
{ | ||
base.OnCreate(bundle); | ||
Instance = this; | ||
global::Xamarin.Forms.Forms.Init(this, bundle); | ||
LoadApplication(new App()); | ||
} | ||
|
||
// Field, property, and method for Picture Picker | ||
public static readonly int PickImageId = 1000; | ||
|
||
public TaskCompletionSource<Stream> PickImageTaskCompletionSource { set; get; } | ||
|
||
protected override void OnActivityResult(int requestCode, Result resultCode, Intent intent) | ||
{ | ||
base.OnActivityResult(requestCode, resultCode, intent); | ||
|
||
if (requestCode == PickImageId) | ||
{ | ||
if ((resultCode == Result.Ok) && (intent != null)) | ||
{ | ||
Android.Net.Uri uri = intent.Data; | ||
Stream stream = ContentResolver.OpenInputStream(uri); | ||
|
||
// Set the Stream as the completion of the Task | ||
PickImageTaskCompletionSource.SetResult(stream); | ||
} | ||
else | ||
{ | ||
PickImageTaskCompletionSource.SetResult(null); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
80 changes: 80 additions & 0 deletions
80
samples/Demos/Demos/SkiaSharpFormsDemos.Droid/PhotoLibrary.cs
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,80 @@ | ||
// using System; | ||
// using System.IO; | ||
using System.Threading.Tasks; | ||
|
||
using Android.Content; | ||
using Android.Media; | ||
using Android.OS; | ||
using Java.IO; | ||
|
||
using Xamarin.Forms; | ||
|
||
using SkiaSharpFormsDemos.Droid; | ||
|
||
[assembly: Dependency(typeof(PhotoLibrary))] | ||
|
||
namespace SkiaSharpFormsDemos.Droid | ||
{ | ||
public class PhotoLibrary : IPhotoLibrary | ||
{ | ||
public Task<System.IO.Stream> PickPhotoAsync() | ||
{ | ||
// Define the Intent for getting images | ||
Intent intent = new Intent(); | ||
intent.SetType("image/*"); | ||
intent.SetAction(Intent.ActionGetContent); | ||
|
||
// Start the picture-picker activity (resumes in MainActivity.cs) | ||
MainActivity.Instance.StartActivityForResult( | ||
Intent.CreateChooser(intent, "Select Picture"), | ||
MainActivity.PickImageId); | ||
|
||
// Save the TaskCompletionSource object as a MainActivity property | ||
MainActivity.Instance.PickImageTaskCompletionSource = new TaskCompletionSource<System.IO.Stream>(); | ||
|
||
// Return Task object | ||
return MainActivity.Instance.PickImageTaskCompletionSource.Task; | ||
} | ||
|
||
// Saving photos requires android.permission.WRITE_EXTERNAL_STORAGE in AndroidManifest.xml | ||
|
||
public async Task<bool> SavePhotoAsync(byte[] data, string folder, string filename) | ||
{ | ||
try | ||
{ | ||
File picturesDirectory = Environment.GetExternalStoragePublicDirectory(Environment.DirectoryPictures); | ||
File folderDirectory = picturesDirectory; | ||
|
||
if (!string.IsNullOrEmpty(folder)) | ||
{ | ||
folderDirectory = new File(picturesDirectory, folder); | ||
folderDirectory.Mkdirs(); | ||
} | ||
|
||
using (File bitmapFile = new File(folderDirectory, filename)) | ||
{ | ||
bitmapFile.CreateNewFile(); | ||
|
||
using (FileOutputStream outputStream = new FileOutputStream(bitmapFile)) | ||
{ | ||
await outputStream.WriteAsync(data); | ||
} | ||
|
||
// Make sure it shows up in the Photos gallery promptly. | ||
MediaScannerConnection.ScanFile(MainActivity.Instance, | ||
new string[] { bitmapFile.Path }, | ||
new string[] { "image/png", "image/jpeg" }, null); | ||
} | ||
} | ||
catch | ||
{ | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} | ||
|
||
|
||
|
6 changes: 6 additions & 0 deletions
6
samples/Demos/Demos/SkiaSharpFormsDemos.Droid/Properties/AndroidManifest.xml
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto"> | ||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29" /> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
<application android:label="SkiaSharpFormsDemos.Droid"></application> | ||
</manifest> |
Oops, something went wrong.