Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -9,12 +9,13 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Xamarin.Auth</RootNamespace>
<AssemblyName>Xamarin.Auth</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<XamarinAuthCustomPreprocessorConstantsDefines>
</XamarinAuthCustomPreprocessorConstantsDefines>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,11 @@ public static void Initialize(global::Android.App.Activity a)
"http://xamarin.com"
);
PackagesSupportingCustomTabs = PackageManagerHelper.PackagesSupportingCustomTabs;
PackageForCustomTabs = PackagesSupportingCustomTabs.FirstOrDefault().Value;
PackageForCustomTabs = PackagesSupportingCustomTabs.FirstOrDefault();

CustomTabsActivityManager = new CustomTabsActivityManager(a);
CustomTabsIntentBuilder = new CustomTabsIntent.Builder(CustomTabsActivityManager.Session);
CustomTabActivityHelper = new CustomTabActivityHelper();

return;
}

static global::Android.App.Activity activity = null;
Expand All @@ -76,7 +74,7 @@ public static void Initialize(global::Android.App.Activity a)
set;
}

public static Dictionary<string, string> PackagesSupportingCustomTabs
public static List<string> PackagesSupportingCustomTabs
{
get;
set;
Expand Down Expand Up @@ -466,7 +464,7 @@ public static PendingIntent CreatePendingIntent(int actionSourceId)
activity.ApplicationContext,
actionSourceId,
actionIntent,
0
PendingIntentFlags.CancelCurrent | PendingIntentFlags.Immutable
);
return broadcast;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.Content;
Expand All @@ -19,24 +20,11 @@ internal class PackageManagerHelper
public class PackageManagerHelper
#endif
{
/*
internal const string STABLE_PACKAGE = "com.android.chrome";
internal const string BETA_PACKAGE = "com.chrome.beta";
internal const string DEV_PACKAGE = "com.chrome.dev";
internal const string LOCAL_PACKAGE = "com.google.android.apps.chrome";
*/
public static Dictionary<string, string> PackagesSupportingCustomTabs
public static List<string> PackagesSupportingCustomTabs
{
get;
set;
} =
new Dictionary<string, string>()
{
{"STABLE_PACKAGE", "com.android.chrome"},
{"BETA_PACKAGE", "com.chrome.beta"},
{"DEV_PACKAGE", "com.chrome.dev"},
{"LOCAL_PACKAGE", "com.google.android.apps.chrome"},
};
} = new List<string>();

public static string CustomTabsExtraKeepAlive
{
Expand Down Expand Up @@ -117,7 +105,7 @@ string url
#if DEBUG
StringBuilder sb1 = new StringBuilder();
sb1.AppendLine($" package for url ");
sb1.AppendLine($" url = {url.ToString()}");
sb1.AppendLine($" url = {url}");
sb1.AppendLine($" resolve_info_default_view_handler.ResolvePackageName = {resolve_info_default_view_handler.ResolvePackageName}");
sb1.AppendLine($" resolve_info_default_view_handler.ActivityInfo.PackageName = {resolve_info_default_view_handler.ActivityInfo.PackageName}");
sb1.AppendLine($" resolve_info_default_view_handler.ActivityInfo.Name = {resolve_info_default_view_handler.ActivityInfo.Name}");
Expand Down Expand Up @@ -163,56 +151,18 @@ string url

// Now packagesSupportingCustomTabs contains all apps that can handle both VIEW intents
// and service calls.
if (packagesSupportingCustomTabs.Count == 0)
{
System.Diagnostics.Debug.WriteLine($" Packages Supporting CustomTabs Count = 0");
sPackageNameToUse = null;
}
else if (packagesSupportingCustomTabs.Count == 1)
{
System.Diagnostics.Debug.WriteLine($" Packages Supporting CustomTabs Count = 1");
System.Diagnostics.Debug.WriteLine($" Packages Supporting CustomTabs = {packagesSupportingCustomTabs[0]}");
sPackageNameToUse = packagesSupportingCustomTabs[0];
sPackageNamesToUse.Add(sPackageNameToUse);
}
else if
(
// !TextUtils.IsEmpty(defaultViewHandlerPackageName) // Android API
string.IsNullOrEmpty(defaultViewHandlerPackageName) // .NET API
&&
!HasSpecializedHandlerIntents(context, activityIntent)
&&
packagesSupportingCustomTabs.Contains(defaultViewHandlerPackageName)
)
{
sPackageNameToUse = defaultViewHandlerPackageName;
}
else if (packagesSupportingCustomTabs.Contains(PackagesSupportingCustomTabs["STABLE_PACKAGE"]))
{
sPackageNameToUse = PackagesSupportingCustomTabs["STABLE_PACKAGE"];
}
else if (packagesSupportingCustomTabs.Contains(PackagesSupportingCustomTabs["BETA_PACKAGE"]))
{
sPackageNameToUse = PackagesSupportingCustomTabs["BETA_PACKAGE"];
}
else if (packagesSupportingCustomTabs.Contains(PackagesSupportingCustomTabs["DEV_PACKAGE"]))
{
sPackageNameToUse = PackagesSupportingCustomTabs["DEV_PACKAGE"];
}
else if (packagesSupportingCustomTabs.Contains(PackagesSupportingCustomTabs["CANARY_PACKAGE"]))
{
sPackageNameToUse = PackagesSupportingCustomTabs["CANARY_PACKAGE"];
}
else if (packagesSupportingCustomTabs.Contains(PackagesSupportingCustomTabs["LOCAL_PACKAGE"]))
{
sPackageNameToUse = PackagesSupportingCustomTabs["LOCAL_PACKAGE"];
}

for (int i = 0; i < sPackageNamesToUse.Count; i++)
foreach (var package in packagesSupportingCustomTabs)
{
PackagesSupportingCustomTabs.Add($"Detected {i}", sPackageNamesToUse[i]);
if (string.IsNullOrEmpty(package) || PackagesSupportingCustomTabs.Contains(package))
{
continue;
}
sPackageNamesToUse.Add(package);
PackagesSupportingCustomTabs.Add(package);
}

sPackageNameToUse = sPackageNamesToUse.LastOrDefault();
return sPackageNamesToUse;
}

Expand Down Expand Up @@ -265,20 +215,6 @@ private static bool HasSpecializedHandlerIntents(Context context, Intent intent)


/// <returns> All possible chrome package names that provide custom tabs feature. </returns>
public static string[] Packages
{
get
{
return new string[]
{
"",
PackagesSupportingCustomTabs["STABLE_PACKAGE"],
PackagesSupportingCustomTabs["BETA_PACKAGE"],
PackagesSupportingCustomTabs["DEV_PACKAGE"],
PackagesSupportingCustomTabs["CANARY_PACKAGE"],
PackagesSupportingCustomTabs["LOCAL_PACKAGE"],
};
}
}
public static string[] Packages => PackagesSupportingCustomTabs.ToArray();
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{3EBB5946-5B7E-4EB3-8E3A-4FEE91D69ED6}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Xamarin.Auth</RootNamespace>
<AssemblyName>Xamarin.Auth.Extensions</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<XamarinAuthCustomPreprocessorConstantsDefines>
</XamarinAuthCustomPreprocessorConstantsDefines>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -73,10 +74,7 @@
http://laurentkempe.com/2009/12/03/ProjectReference-with-Condition-in-your-MSBuild-project-files/
msbuild Choose When ProjectReference Reference Include
-->
<ItemGroup>
<Folder Include="AccountStore\" />
<Folder Include="AccountStore\CryptoAccountManager\" />
</ItemGroup>
<ItemGroup />
<Choose>
<When Condition="! exists('..\..\Core\Xamarin.Auth.Common.LinkSource\Xamarin.Auth.Common.LinkSource.csproj')">
<!-- nuget packages (dll) refs -->
Expand All @@ -102,7 +100,7 @@
==================================================================================================
-->
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!--
<!--
<Import Project="..\..\packages\Microsoft.DotNet.BuildTools.GenAPI.1.0.0-beta-00081\build\Microsoft.DotNet.BuildTools.GenAPI.targets" Condition="Exists('..\..\packages\Microsoft.DotNet.BuildTools.GenAPI.1.0.0-beta-00081\build\Microsoft.DotNet.BuildTools.GenAPI.targets')" />
-->
</Project>