-
-
Save codenamejason/54b70b9409e6cfe768b72573567b19a6 to your computer and use it in GitHub Desktop.
Revisions
-
JonDouglas revised this gist
Jul 5, 2016 . 1 changed file with 57 additions and 34 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,39 +1,62 @@ using System; using System.Timers; using LoginScreen; namespace LoginScreen.Android.Sample { public class TestCredentialsProvider : ICredentialsProvider { readonly Random rnd = new Random (); public bool NeedLoginAfterRegistration { get { return false; } } public bool ShowPasswordResetLink { get { return true; } } public bool ShowRegistration { get { return true; } } public void Login (string userName, string password, Action successCallback, Action<LoginScreenFaultDetails> failCallback) { DelayInvoke (EquiprobableSelect (successCallback, () => failCallback (new LoginScreenFaultDetails { CommonErrorMessage = "Something wrong happened." }))); CustomApplication.ChangeActivity(); } public void Register (string email, string userName, string password, Action successCallback, Action<LoginScreenFaultDetails> failCallback) { DelayInvoke (() => { if (password.Length < 4) { failCallback (new LoginScreenFaultDetails { PasswordErrorMessage = "Password must be at least 4 chars." }); } else { successCallback (); } }); } public void ResetPassword (string email, Action successCallback, Action<LoginScreenFaultDetails> failCallback) { DelayInvoke (EquiprobableSelect (successCallback, () => failCallback (new LoginScreenFaultDetails { CommonErrorMessage = "Something wrong happened." }))); } private void DelayInvoke (Action operation) { Timer timer = new Timer (); timer.AutoReset = false; timer.Interval = 3000; timer.Elapsed += (object sender, ElapsedEventArgs e) => operation.Invoke (); timer.Start (); } private T EquiprobableSelect<T> (T first, T second) { return rnd.Next (100) < 50 ? first : second; } } } -
JonDouglas created this gist
Jul 5, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ using System; using Android.App; using Android.Content; using Android.Runtime; using Android.Views; using Android.Widget; using Android.OS; using LoginScreen; namespace LoginScreen.Android.Sample { [Activity (Label = "LoginScreen.Android.Sample", MainLauncher = true)] public class Activity1 : Activity { protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); FindViewById<Button>(Resource.Id.loginButton).Click += (sender, e) => LoginScreenControl<TestCredentialsProvider>.Activate(this); } } } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ using System; using Android.App; using Android.Content; using Android.Runtime; using Android.Views; using Android.Widget; using Android.OS; using LoginScreen; namespace LoginScreen.Android.Sample { [Activity (Label = "Activity2")] public class Activity2 : Activity { protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); Button b = FindViewById<Button>(Resource.Id.loginButton); b.Text = "Activity 2 Button"; } } } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; using Android.App; using Android.Content; using Android.OS; using Android.Runtime; using Android.Views; using Android.Widget; namespace LoginScreen.Android.Sample { [Application] public class CustomApplication : Application { public CustomApplication(IntPtr handle, JniHandleOwnership ownerShip) : base(handle, ownerShip) { } public override void OnCreate() { base.OnCreate(); } public static Context GetAppContext() { return CustomApplication.Context; } public static void ChangeActivity() { Intent i = new Intent(Context, typeof(Activity2)); i.AddFlags(ActivityFlags.NewTask); Context.StartActivity(i); } } } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#FFFFFF"> <Button android:id="@+id/loginButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:textColor="#000000" android:text="Login" /> </RelativeLayout> This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; using Android.App; using Android.Content; using Android.OS; using Android.Runtime; using Android.Views; using Android.Widget; namespace LoginScreen.Android.Sample { [Application] public class CustomApplication : Application { public CustomApplication(IntPtr handle, JniHandleOwnership ownerShip) : base(handle, ownerShip) { } public override void OnCreate() { base.OnCreate(); } public static Context GetAppContext() { return CustomApplication.Context; } public static void ChangeActivity() { Intent i = new Intent(Context, typeof(Activity2)); i.AddFlags(ActivityFlags.NewTask); Context.StartActivity(i); } } }