Skip to content

Instantly share code, notes, and snippets.

View baileysh9's full-sized avatar

Scott Bailey baileysh9

View GitHub Profile
<?xml version="1.0" encoding="UTF-8" ?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="my_images" path="Android/data/com.yourcompany.appname/files/Pictures" />
</paths>
@baileysh9
baileysh9 / MainActivity.cs
Last active March 4, 2021 00:56
Handling Images from the Camera and Photo Gallery in Xamarin Android
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
//Camera Request
if (requestCode == 0)
{
if (resultCode == Result.Ok)
{
Task.Run(() =>
@baileysh9
baileysh9 / CameraManager.cs
Last active January 24, 2018 20:07
Launching Camera and Photo Gallery in Xamarin Android
public enum FileFormatEnum
{
PNG,
JPEG
}
public void BringUpCamera(string imageId, FileFormatEnum fileType)
{
var intent = new Intent(MediaStore.ActionImageCapture);
@baileysh9
baileysh9 / gist:c5c8b8fd0f72054d68202c5dc20377be
Created January 24, 2018 19:53
FileProvider in AndroidManifest.xml
<provider android:name="android.support.v4.content.FileProvider" android:authorities="com.yourcompany.appname.fileprovider" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data>
</provider>
@baileysh9
baileysh9 / AppDelegate.cs
Created January 9, 2018 20:05
Using the iOSDevice class
iOSDevice iosDevice = new iOSDevice();
App.onIphoneX = iosDevice.deviceHasNotch();
@baileysh9
baileysh9 / iOSDevice.cs
Created January 9, 2018 19:58
Checks if the iOS device is an iPhone X
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Foundation;
public class iOSDevice
{
List<string> iphonesWithNotch = new List<string>();
public iOSDevice()
public GradientTestPage()
{
InitializeComponent();
Color[] gradientColors = new Color[] { Color.Black, Color.Orange, Color.Black };
GradientModel g = new GradientModel()
{
GradientColors = gradientColors,
ViewWidth = 300,
@baileysh9
baileysh9 / GradientViewRenderer.cs
Last active July 14, 2017 17:54
iOS Implementation of Gradient View Render
public void CreateGradient()
{
CAGradientLayer gradient = new CAGradientLayer();
CGRect tempRect = new CGRect(0, 0, this.viewWidth, this.viewHeight);
gradient.Frame = tempRect;
//Need to convert the colors to CGColor objects
CGColor[] cgColors = new CGColor[gradientColors.Count()];
for (int i = 0; i < gradientColors.Count(); i++)
@baileysh9
baileysh9 / GradientViewRenderer.cs
Last active July 19, 2018 20:53
Android implementation of the Gradient View Render
public void CreateGradient()
{
//Need to convert the colors to Android Color objects
int[] androidColors = new int[gradientColors.Count()];
for (int i = 0; i < gradientColors.Count(); i++)
{
Xamarin.Forms.Color temp = gradientColors[i];
androidColors[i] = temp.ToAndroid();
}
public class GradientViewRender : View
{
public static readonly BindableProperty GradientColorsProperty = BindableProperty.Create<GradientViewRender, Color[]>(p => p.GradientColors, new Color[]{Color.White} );
public Color[] GradientColors
{
get { return (Color[])base.GetValue(GradientColorsProperty); }
set { base.SetValue(GradientColorsProperty, value); }
}