├── Sample
├── Resources
│ ├── mipmap-hdpi
│ │ └── Icon.png
│ ├── mipmap-mdpi
│ │ └── Icon.png
│ ├── mipmap-xhdpi
│ │ └── Icon.png
│ ├── mipmap-xxhdpi
│ │ └── Icon.png
│ ├── mipmap-xxxhdpi
│ │ └── Icon.png
│ ├── values
│ │ └── Strings.xml
│ ├── layout
│ │ ├── Main.axml
│ │ └── FirstLayout.axml
│ └── AboutResources.txt
├── Properties
│ ├── AndroidManifest.xml
│ └── AssemblyInfo.cs
├── packages.config
├── Assets
│ └── AboutAssets.txt
├── MainActivity.cs
└── Sample.csproj
├── Xamarin.Android.ActivityController
├── Resources
│ ├── values
│ │ └── Strings.xml
│ └── AboutResources.txt
├── IActivityResult.cs
├── ActivityResults
│ ├── ContactPickerActivityResult.cs
│ └── MediaPickerActivityResult.cs
├── packages.config
├── ActivityResult.cs
├── Properties
│ └── AssemblyInfo.cs
├── ActivityControllerExtensions.cs
├── ActivityControllerRegistry.cs
├── Xamarin.Android.ActivityController.csproj
├── ControllerActivity.cs
└── ActivityController.cs
├── .gitignore
├── LICENSE.md
├── Xamarin.Android.ActivityController.nuspec
├── Xamarin.Android.ActivityController.sln
├── README.md
└── code-behind-x-a.diff
/Sample/Resources/mipmap-hdpi/Icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/android-activity-controller/HEAD/Sample/Resources/mipmap-hdpi/Icon.png
--------------------------------------------------------------------------------
/Sample/Resources/mipmap-mdpi/Icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/android-activity-controller/HEAD/Sample/Resources/mipmap-mdpi/Icon.png
--------------------------------------------------------------------------------
/Sample/Resources/mipmap-xhdpi/Icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/android-activity-controller/HEAD/Sample/Resources/mipmap-xhdpi/Icon.png
--------------------------------------------------------------------------------
/Sample/Resources/mipmap-xxhdpi/Icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/android-activity-controller/HEAD/Sample/Resources/mipmap-xxhdpi/Icon.png
--------------------------------------------------------------------------------
/Sample/Resources/mipmap-xxxhdpi/Icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/android-activity-controller/HEAD/Sample/Resources/mipmap-xxxhdpi/Icon.png
--------------------------------------------------------------------------------
/Xamarin.Android.ActivityController/Resources/values/Strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Xamarin.Android.ActivityController
4 |
5 |
--------------------------------------------------------------------------------
/Sample/Resources/values/Strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello World, Click Me!
4 | XamActivityController
5 |
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | tools
2 | bin
3 | obj
4 | *.xam
5 | *.DS_Store
6 | *.pidb
7 | *.userprefs
8 | *.dotSettings
9 | *.suo
10 | Resource.designer.cs
11 |
12 | *.a
13 |
14 | *.xcuserstate
15 |
16 | *.xcuserstate
17 |
18 | packages/
19 | externals/
20 | output/
21 |
22 |
--------------------------------------------------------------------------------
/Sample/Resources/layout/Main.axml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Sample/Properties/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Xamarin.Android.ActivityController/IActivityResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Android.Content;
3 |
4 | namespace Android.App
5 | {
6 | public interface IActivityResult
7 | {
8 | Result ResultCode { get; }
9 | int RequestCode { get; }
10 | Intent Data { get; }
11 | }
12 |
13 | public interface ITypedActivityResult : IActivityResult
14 | {
15 | void Parse(Result resultCode, int requestCode, Intent data);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Sample/Resources/layout/FirstLayout.axml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
11 |
--------------------------------------------------------------------------------
/Xamarin.Android.ActivityController/ActivityResults/ContactPickerActivityResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Android.Content;
3 |
4 | namespace Android.App
5 | {
6 | public class ContactPickerActivityResult : ActivityResult
7 | {
8 | public ContactPickerActivityResult(Result resultCode, int requestCode, Intent data)
9 | : base(resultCode, requestCode, data) { }
10 |
11 | public Android.Net.Uri SelectedContactUri { get { return Data?.Data; } }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Sample/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Xamarin.Android.ActivityController/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Xamarin.Android.ActivityController/ActivityResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Android.Content;
3 |
4 | namespace Android.App
5 | {
6 | public class ActivityResult : IActivityResult
7 | {
8 | public ActivityResult(Result resultCode, int requestCode, Intent data)
9 | {
10 | ResultCode = resultCode;
11 | RequestCode = requestCode;
12 | Data = data;
13 | }
14 |
15 | public Result ResultCode { get; private set; }
16 | public int RequestCode { get; private set; }
17 | public Intent Data { get; private set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Sample/Assets/AboutAssets.txt:
--------------------------------------------------------------------------------
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");
20 |
--------------------------------------------------------------------------------
/Xamarin.Android.ActivityController/ActivityResults/MediaPickerActivityResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using Android.Content;
4 |
5 | namespace Android.App
6 | {
7 | public class MediaPickerActivityResult : ActivityResult
8 | {
9 | public MediaPickerActivityResult(Result resultCode, int requestCode, Intent data)
10 | : base(resultCode, requestCode, data) { }
11 |
12 | public Android.Net.Uri SelectedMediaUri { get { return Data?.Data; } }
13 |
14 | public Stream GetMediaStream(Context context)
15 | {
16 | var uri = SelectedMediaUri;
17 | if (uri == null)
18 | return null;
19 |
20 | return context.ContentResolver.OpenInputStream(uri);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | Copyright (c) 2016 Microsoft Corporation
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5 |
6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 |
8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/Sample/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
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("XamActivityController")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Xamarin")]
12 | [assembly: AssemblyProduct("")]
13 | [assembly: AssemblyCopyright("Xamarin")]
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("")]
28 |
--------------------------------------------------------------------------------
/Xamarin.Android.ActivityController.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Xamarin.Android.ActivityController
5 | Xamarin.Android Activity Controller
6 | $version$
7 | Xamarin Inc.
8 | Xamarin Inc.
9 | Manage your Activities in a more .NET friendly way, including StartActivityForResultAsync
10 |
11 | Manage your Activities in a more .NET friendly way, including StartActivityForResultAsync
12 |
13 | Copyright © Microsoft Corporation
14 | https://github.com/xamarin/android-activity-controller
15 | https://github.com/xamarin/android-activity-controller/blob/master/LICENSE.md
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Xamarin.Android.ActivityController/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 |
4 | // Information about this assembly is defined by the following attributes.
5 | // Change them to the values specific to your project.
6 |
7 | [assembly: AssemblyTitle("Xamarin.Android.ActivityController")]
8 | [assembly: AssemblyDescription("")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("Xamarin")]
11 | [assembly: AssemblyProduct("")]
12 | [assembly: AssemblyCopyright("Xamarin")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision,
18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision.
19 |
20 | [assembly: AssemblyVersion("1.0.0")]
21 |
22 | // The following attributes are used to specify the signing key for the assembly,
23 | // if desired. See the Mono documentation for more information about signing.
24 |
25 | //[assembly: AssemblyDelaySign(false)]
26 | //[assembly: AssemblyKeyFile("")]
27 |
--------------------------------------------------------------------------------
/Xamarin.Android.ActivityController.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Android.ActivityController", "Xamarin.Android.ActivityController\Xamarin.Android.ActivityController.csproj", "{520D62E8-76B4-4387-9CF0-C8E1D8D60253}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample", "Sample\Sample.csproj", "{7C81088B-3E56-40C8-AE3A-CEACC83CF4CF}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {520D62E8-76B4-4387-9CF0-C8E1D8D60253}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {520D62E8-76B4-4387-9CF0-C8E1D8D60253}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {520D62E8-76B4-4387-9CF0-C8E1D8D60253}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {520D62E8-76B4-4387-9CF0-C8E1D8D60253}.Release|Any CPU.Build.0 = Release|Any CPU
18 | {7C81088B-3E56-40C8-AE3A-CEACC83CF4CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {7C81088B-3E56-40C8-AE3A-CEACC83CF4CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {7C81088B-3E56-40C8-AE3A-CEACC83CF4CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {7C81088B-3E56-40C8-AE3A-CEACC83CF4CF}.Release|Any CPU.Build.0 = Release|Any CPU
22 | EndGlobalSection
23 | EndGlobal
24 |
--------------------------------------------------------------------------------
/Sample/Resources/AboutResources.txt:
--------------------------------------------------------------------------------
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.
45 |
--------------------------------------------------------------------------------
/Xamarin.Android.ActivityController/Resources/AboutResources.txt:
--------------------------------------------------------------------------------
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.
45 |
--------------------------------------------------------------------------------
/Sample/MainActivity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Android.App;
3 | using Android.Content;
4 | using Android.Provider;
5 | using Android.Support.V7.App;
6 | using Android.Widget;
7 | using Xamarin.Android;
8 |
9 | namespace XamActivityController
10 | {
11 | [Activity(MainLauncher = true, Label = "Activity Controller Test", Theme = "@style/Theme.AppCompat")]
12 | public class MainActivity : ControllerActivity
13 | {
14 | public class MainController : ActivityController
15 | {
16 | protected override void OnCreate(Android.OS.Bundle savedInstanceState)
17 | {
18 | base.OnCreate(savedInstanceState);
19 |
20 | SetContentView(Resource.Layout.FirstLayout);
21 |
22 | FindViewById