Skip to content

Instantly share code, notes, and snippets.

@wislon
wislon / SdkBeforeCleanFix.txt
Last active August 28, 2018 23:17
Fix '_SdkBeforeClean' build error when building xamarin xplat app
It seems to only be a problem on xplat solutions, as they set up a chain of 'clean'-task dependencies,
which apparently other solutions don't.
This is caused by a missing `;` in one of the msbuild `.targets` files as described here
(and is a bug in dotnet core 2.1.3 sdk, and VS 2017 15.8.x):
* https://github.com/onovotny/MSBuildSdkExtras/issues/89
which led to
@wislon
wislon / BluetoothHelper.cs
Created November 22, 2017 21:20
Android Bluetooth Helper (power up/down adapter, build config based on SDK level etc.)
public static class BluetoothHelper
{
private static readonly BluetoothManager _manager;
private static readonly BluetoothAdapter _adapter;
static BluetoothHelper()
{
var context = Application.Context;
_manager = (BluetoothManager)context.GetSystemService("bluetooth");
_adapter = _manager.Adapter;
@wislon
wislon / boxstarter01.ps1
Last active September 15, 2017 05:32
BoxStarter scripts For initial windoze setup
##################
# Blatantly swiped from
# - Nick Craver's gist at https://gist.github.com/NickCraver/7ebf9efbfd0c3eab72e9
# - Jess Frazelle's at https://gist.github.com/jessfraz/7c319b046daa101a4aaef937a20ff41f
##################
# To run this locally, do
# Install-BoxstarterPackage -PackageName <this.RAW.gist.url> -DisableReboots
# i.e. Install-BoxstarterPackage -PackageName https://gist.githubusercontent.com/wislon/a2a7716fad4dccf58961d1d408d74b89/raw/bdb7f16939800586cef71bd4df7c9596370506ed/boxstarter01.ps1 -DisableReboots
# If you allow reboots, you will likely be prompted for your password so it can reboot/relog in as necessary.
@wislon
wislon / Android Privacy Policy Template
Created March 12, 2017 01:22 — forked from alphamu/Android Privacy Policy Template
A template for creating your own privacy policy for Android apps. Look for "[" and "<!--" to see where you need to edit this app in order to create your own privacy olicy.
<html>
<body>
<h2>Privacy Policy</h2>
<p>[Individual or Company Name] built the [App Name] app as a [open source | free | freemium | ad-supported | commercial] app. This SERVICE is provided by [Individual or company name] [at no cost] and is intended
for use as is.</p>
<p>This page is used to inform website visitors regarding [my|our] policies with the collection, use, and
disclosure of Personal Information if anyone decided to use [my|our] Service.</p>
<p>If you choose to use [my|our] Service, then you agree to the collection and use of information in
relation with this policy. The Personal Information that [I|we] collect are used for providing and
improving the Service. [I|We] will not use or share your information with anyone except as described
@wislon
wislon / 1_IPlatformCookieStore.cs
Last active February 27, 2022 03:02
Xamarin Forms xplat WebView Cookie Demo
using System.Collections.Generic;
using System.Net;
public interface IPlatformCookieStore
{
/// <summary>
/// List of cookies pulled from the cookie storage manager
/// on the device/platform you're on. Can be quite an expensive call,
/// so use it sparingly.
/// </summary>
@wislon
wislon / datatemplate_itemtemplate_xaml_template.md
Last active September 25, 2015 05:46
Xamarin Forms XAML Dynamic ListView ItemTemplate Selection

Sample Grid XAML DataTemplate with a Grid layout

Has a basic 5-column, 6-row layout, with padding/spacing columns/rows delineated with coloured boxviews (since gridview cells don't have borders, we can't see where one cell stops and another begins)

Note, to get the design-time intellisense for the DataContext binding, you'll need to add the following namespaces to the top of your XAML file (can go beneath the usual xamarin forms namespaces, order isn't really important):

 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@wislon
wislon / xaml-xcc-info.md
Last active November 18, 2020 13:18
Xam.Forms XAML conditional compilation& design-time bindings intellisense in VS

Xam.Forms XAML conditional compilation& design-time bindings intellisense

Original article:

http://adventuresinxamarinforms.com/2015/03/17/xaml-v-code/

add (to each xaml file, near the top with the other xmlns definitions)

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
@wislon
wislon / getcookiesgist.cs
Created September 10, 2015 20:46
Get Cookies from HTTPClient instance (using CookieContainer, or raw headers)
/// <summary>
/// Will return null if the cookie you were looking for isn't in the container.
/// </summary>
/// <param name="cookieName"></param>
/// <param name="cookieContainer"></param>
/// <returns></returns>
protected async Task<Cookie> ExtractCookieWithName(string cookieName, CookieContainer cookieContainer)
{
var cookies = cookieContainer.GetCookies(new Uri(SharedConstants.WebsiteBaseUrl));
var cookie = cookies[cookieName];
@wislon
wislon / fragment.xml
Last active April 26, 2019 10:39
Transparent WebView Load Animated Gif (Xamarin Android)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<WebView
android:id="@+id/webLoadingIcon"
android:layout_width="44dp"
@wislon
wislon / ViewExtensions.cs
Last active August 29, 2015 14:15
Animation code samples
using Android.Content;
using Android.Views;
using Android.Views.Animations;
namespace Mobile.Droid.Extensions
{
// invoke with anyView.BringViewInWithAnimation/TakeViewOutWithAnimation
// where animation param is predefined animations from xml, code, etc.
// e.g. inAnimation = AnimationUtils.LoadAnimation(Activity, Resource.Animation.bottom_slide_in);