Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Main Activity
Browse files Browse the repository at this point in the history
  • Loading branch information
moljac committed Mar 30, 2017
1 parent 77a4eb0 commit e79ed09
Showing 1 changed file with 64 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ private void Authenticate(Xamarin.Auth.Helpers.OAuth1 oauth1)

//#####################################################################
// Xamarin.Auth API - Breaking Change
// old API returned UIKit.UIViewController
// old API returned global::Android.Content.Intent
//Intent ui_intent_as_object = auth.GetUI ();
// new API returns System.Object
System.Object ui_intent_builder_as_object = Auth1.GetUI(this);
System.Object ui_object = Auth1.GetUI(this);
if (Auth1.IsUsingNativeUI == true)
{
//=================================================================
Expand All @@ -135,8 +135,12 @@ private void Authenticate(Xamarin.Auth.Helpers.OAuth1 oauth1)
System.Uri uri_netfx = Auth2.GetInitialUrlAsync().Result;
global::Android.Net.Uri uri_android = global::Android.Net.Uri.Parse(uri_netfx.AbsoluteUri);
global::Android.Support.CustomTabs.CustomTabsIntent.Builder ctib;
ctib = (global::Android.Support.CustomTabs.CustomTabsIntent.Builder)ui_intent_builder_as_object;
ctib = (global::Android.Support.CustomTabs.CustomTabsIntent.Builder)ui_object;
// add custom schema (App Linking) handling
// 1. add Activity with IntentFilter to the app
// 1.1. Define sheme[s] and host[s] in the IntentFilter
// 1.2. in Activity's OnCreate extract URL with custom schema from Intent
// 1.3. parse OAuth data from URL obtained in 1.2.
// NOTE[s]
// * custom scheme support only
// xamarinauth://localhost
Expand All @@ -151,6 +155,9 @@ private void Authenticate(Xamarin.Auth.Helpers.OAuth1 oauth1)
.SetShowTitle(true)
.EnableUrlBarHiding()
;
// TODO: warmup, prefetching
// TODO: menu
// TODO: bottom bar
//------------------------------------------------------------
// [REQUIRED] launching Custom Tabs
global::Android.Support.CustomTabs.CustomTabsIntent ct_intent = ctib.Build();
Expand All @@ -170,7 +177,7 @@ private void Authenticate(Xamarin.Auth.Helpers.OAuth1 oauth1)
// soon to be non-default
// optional API in the future (for backward compatibility)
global::Android.Content.Intent i = null;
i = (global::Android.Content.Intent)ui_intent_builder_as_object;
i = (global::Android.Content.Intent)ui_object;
StartActivity(i);
//=================================================================
}
Expand Down Expand Up @@ -239,10 +246,10 @@ private void Authenticate(Xamarin.Auth.Helpers.OAuth2 oauth2)

//#####################################################################
// Xamarin.Auth API - Breaking Change
// old API returned Intent
//Intent intent = auth.GetUI ();
// old API returned global::Android.Content.Intent
//Intent ui_intent_as_object = auth.GetUI ();
// new API returns System.Object
System.Object intent_as_object = Auth2.GetUI(this);
System.Object ui_object = Auth2.GetUI(this);
if (Auth2.IsUsingNativeUI == true)
{
//=================================================================
Expand All @@ -254,34 +261,63 @@ private void Authenticate(Xamarin.Auth.Helpers.OAuth2 oauth2)
// SafariServices.SFSafariViewController
// on 2014-04-20 google (and some other providers) will work only with this API
//
// 2017-03-25 NEW UPCOMMING API undocumented work in progress
//
// 2017-03-25
// NEW UPCOMMING API undocumented work in progress
// soon to be default
// optional API in the future (for backward compatibility)
//
// required part
// add
// following code
//
// following code:
System.Uri uri_netfx = Auth2.GetInitialUrlAsync().Result;
global::Android.Net.Uri uri_android = global::Android.Net.Uri.Parse(uri_netfx.AbsoluteUri);

// Add Android.Support.CustomTabs package
global::Android.Support.CustomTabs.CustomTabsActivityManager ctam = null;
ctam = new global::Android.Support.CustomTabs.CustomTabsActivityManager(this);

global::Android.Support.CustomTabs.CustomTabsIntent cti = null;
cti = (global::Android.Support.CustomTabs.CustomTabsIntent)intent_as_object;

cti.LaunchUrl(this, uri_android);
}
global::Android.Net.Uri uri_android = global::Android.Net.Uri.Parse(uri_netfx.AbsoluteUri);
global::Android.Support.CustomTabs.CustomTabsIntent.Builder ctib;
ctib = (global::Android.Support.CustomTabs.CustomTabsIntent.Builder)ui_object;
// add custom schema (App Linking) handling
// 1. add Activity with IntentFilter to the app
// 1.1. Define sheme[s] and host[s] in the IntentFilter
// 1.2. in Activity's OnCreate extract URL with custom schema from Intent
// 1.3. parse OAuth data from URL obtained in 1.2.
// NOTE[s]
// * custom scheme support only
// xamarinauth://localhost
// xamarin-auth://localhost
// xamarin.auth://localhost
// * no http[s] scheme support
//------------------------------------------------------------
// [OPTIONAL] UI customization
// CustomTabsIntent.Builder
ctib
.SetToolbarColor(color_xamarin_blue)
.SetShowTitle(true)
.EnableUrlBarHiding()
;
// TODO: warmup, prefetching
// TODO: menu
// TODO: bottom bar
//------------------------------------------------------------
// [REQUIRED] launching Custom Tabs
global::Android.Support.CustomTabs.CustomTabsIntent ct_intent = ctib.Build();
ct_intent.LaunchUrl(this, uri_android);
//=================================================================
}
else
{
// OLD API undocumented work in progress (soon to be deprecated)
// set to false to use old embedded browser API WebView and UIWebView
// on 2014-04-20 google login (and some other providers) will NOT work with this API
// This will be left as optional API for some devices (wearables) which do not support
// Chrome Custom Tabs on Android.
//=================================================================
// Xamarin.Auth API - embedded browsers support
// - Android - WebView
// - iOS - UIWebView
//
// on 2014-04-20 google (and some other providers) will work only with this API
//
// 2017-03-25
// soon to be non-default
// optional API in the future (for backward compatibility)
global::Android.Content.Intent i = null;
i = (global::Android.Content.Intent)intent_as_object;
StartActivity(i);
i = (global::Android.Content.Intent)ui_object;
StartActivity(i);
//=================================================================
}

return;
Expand Down

0 comments on commit e79ed09

Please sign in to comment.