Skip to content
This repository was archived by the owner on Oct 20, 2022. It is now read-only.

Commit b39ecba

Browse files
committed
Archive Xamarin.Auth content
1 parent c6ef31e commit b39ecba

40 files changed

+15394
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Any raw assets you want to be deployed with your application can be placed in
2+
this directory (and child directories) and given a Build Action of "AndroidAsset".
3+
4+
These files will be deployed with your package and will be accessible using Android's
5+
AssetManager, like this:
6+
7+
public class ReadAsset : Activity
8+
{
9+
protected override void OnCreate (Bundle bundle)
10+
{
11+
base.OnCreate (bundle);
12+
13+
InputStream input = Assets.Open ("my_asset.txt");
14+
}
15+
}
16+
17+
Additionally, some Android functions will automatically load asset files:
18+
19+
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using Android.App;
3+
using Android.Content;
4+
using Android.Content.PM;
5+
using Android.OS;
6+
7+
namespace OAuthNativeFlow.Droid
8+
{
9+
[Activity(Label = "CustomUrlSchemeInterceptorActivity", NoHistory = true, LaunchMode = LaunchMode.SingleTop)]
10+
[IntentFilter(
11+
new[] { Intent.ActionView },
12+
Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
13+
DataSchemes = new[] { "com.googleusercontent.apps.863494635082-a617p00qkuafejrf3k7hq8s346l0u36h" },
14+
DataPath = "/oauth2redirect")]
15+
public class CustomUrlSchemeInterceptorActivity : Activity
16+
{
17+
protected override void OnCreate(Bundle savedInstanceState)
18+
{
19+
base.OnCreate(savedInstanceState);
20+
21+
// Convert Android.Net.Url to Uri
22+
var uri = new Uri(Intent.Data.ToString());
23+
24+
// Load redirectUrl page
25+
AuthenticationState.Authenticator.OnPageLoading(uri);
26+
27+
Finish();
28+
}
29+
}
30+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Android.App;
2+
using Android.Content.PM;
3+
using Android.OS;
4+
5+
namespace OAuthNativeFlow.Droid
6+
{
7+
[Activity(Label = "OAuthNativeFlow.Droid", Icon = "@drawable/icon", Theme = "@style/MyTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
8+
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
9+
{
10+
protected override void OnCreate(Bundle bundle)
11+
{
12+
TabLayoutResource = Resource.Layout.Tabbar;
13+
ToolbarResource = Resource.Layout.Toolbar;
14+
15+
base.OnCreate(bundle);
16+
17+
global::Xamarin.Forms.Forms.Init(this, bundle);
18+
global::Xamarin.Auth.Presenters.XamarinAndroid.AuthenticationConfiguration.Init(this, bundle);
19+
20+
LoadApplication(new App());
21+
}
22+
}
23+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{EE2F865B-1504-4CFF-8DE0-B9C65D9CED5E}</ProjectGuid>
7+
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
8+
<OutputType>Library</OutputType>
9+
<RootNamespace>OAuthNativeFlow.Droid</RootNamespace>
10+
<AssemblyName>OAuthNativeFlow.Droid</AssemblyName>
11+
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
12+
<AndroidApplication>True</AndroidApplication>
13+
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
14+
<AndroidResgenClass>Resource</AndroidResgenClass>
15+
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
16+
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
17+
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
18+
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
19+
</PropertyGroup>
20+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
21+
<DebugSymbols>true</DebugSymbols>
22+
<DebugType>portable</DebugType>
23+
<Optimize>false</Optimize>
24+
<OutputPath>bin\Debug</OutputPath>
25+
<DefineConstants>DEBUG;</DefineConstants>
26+
<ErrorReport>prompt</ErrorReport>
27+
<WarningLevel>4</WarningLevel>
28+
<AndroidLinkMode>None</AndroidLinkMode>
29+
</PropertyGroup>
30+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
31+
<DebugSymbols>true</DebugSymbols>
32+
<DebugType>portable</DebugType>
33+
<Optimize>true</Optimize>
34+
<OutputPath>bin\Release</OutputPath>
35+
<ErrorReport>prompt</ErrorReport>
36+
<WarningLevel>4</WarningLevel>
37+
<AndroidManagedSymbols>true</AndroidManagedSymbols>
38+
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
39+
</PropertyGroup>
40+
<ItemGroup>
41+
<PackageReference Include="Xamarin.Forms" Version="4.5.0.396" />
42+
<PackageReference Include="Xamarin.Auth">
43+
<Version>1.6.0.2</Version>
44+
</PackageReference>
45+
</ItemGroup>
46+
<ItemGroup>
47+
<Reference Include="System" />
48+
<Reference Include="System.Xml" />
49+
<Reference Include="System.Core" />
50+
<Reference Include="Mono.Android" />
51+
</ItemGroup>
52+
<ItemGroup>
53+
<ProjectReference Include="..\OAuthNativeFlow\OAuthNativeFlow.csproj">
54+
<Project>{824CCA13-BBFB-4EE5-AE7D-2145651AE1D7}</Project>
55+
<Name>OAuthNativeFlow</Name>
56+
</ProjectReference>
57+
</ItemGroup>
58+
<ItemGroup>
59+
<Compile Include="MainActivity.cs" />
60+
<Compile Include="Resources\Resource.designer.cs" />
61+
<Compile Include="Properties\AssemblyInfo.cs" />
62+
<Compile Include="CustomUrlSchemeInterceptorActivity.cs" />
63+
</ItemGroup>
64+
<ItemGroup>
65+
<None Include="Resources\AboutResources.txt" />
66+
<None Include="Properties\AndroidManifest.xml" />
67+
<None Include="Assets\AboutAssets.txt" />
68+
</ItemGroup>
69+
<ItemGroup>
70+
<AndroidResource Include="Resources\layout\Tabbar.axml" />
71+
<AndroidResource Include="Resources\layout\Toolbar.axml" />
72+
<AndroidResource Include="Resources\values\styles.xml" />
73+
<AndroidResource Include="Resources\drawable\icon.png" />
74+
<AndroidResource Include="Resources\drawable-hdpi\icon.png" />
75+
<AndroidResource Include="Resources\drawable-xhdpi\icon.png" />
76+
<AndroidResource Include="Resources\drawable-xxhdpi\icon.png" />
77+
</ItemGroup>
78+
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
79+
</Project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.oauthnativeflow">
3+
<uses-sdk android:minSdkVersion="19" />
4+
<application android:label="OAuthNativeFlow"></application>
5+
</manifest>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using Android.App;
4+
5+
// Information about this assembly is defined by the following attributes.
6+
// Change them to the values specific to your project.
7+
8+
[assembly: AssemblyTitle("OAuthNativeFlow.Droid")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("")]
13+
[assembly: AssemblyCopyright("${AuthorCopyright}")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
18+
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
19+
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
20+
21+
[assembly: AssemblyVersion("1.0.0")]
22+
23+
// The following attributes are used to specify the signing key for the assembly,
24+
// if desired. See the Mono documentation for more information about signing.
25+
26+
//[assembly: AssemblyDelaySign(false)]
27+
//[assembly: AssemblyKeyFile("")]
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Images, layout descriptions, binary blobs and string dictionaries can be included
2+
in your application as resource files. Various Android APIs are designed to
3+
operate on the resource IDs instead of dealing with images, strings or binary blobs
4+
directly.
5+
6+
For example, a sample Android app that contains a user interface layout (main.axml),
7+
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8+
would keep its resources in the "Resources" directory of the application:
9+
10+
Resources/
11+
drawable/
12+
icon.png
13+
14+
layout/
15+
main.axml
16+
17+
values/
18+
strings.xml
19+
20+
In order to get the build system to recognize Android resources, set the build action to
21+
"AndroidResource". The native Android APIs do not operate directly with filenames, but
22+
instead operate on resource IDs. When you compile an Android application that uses resources,
23+
the build system will package the resources for distribution and generate a class called "R"
24+
(this is an Android convention) that contains the tokens for each one of the resources
25+
included. For example, for the above Resources layout, this is what the R class would expose:
26+
27+
public class R {
28+
public class drawable {
29+
public const int icon = 0x123;
30+
}
31+
32+
public class layout {
33+
public const int main = 0x456;
34+
}
35+
36+
public class strings {
37+
public const int first_string = 0xabc;
38+
public const int second_string = 0xbcd;
39+
}
40+
}
41+
42+
You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
43+
to reference the layout/main.axml file, or R.strings.first_string to reference the first
44+
string in the dictionary file values/strings.xml.

0 commit comments

Comments
 (0)