Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Commit 44148ef

Browse files
committed
Merge branch 'samples-forms'
2 parents 9f87fbb + 687a886 commit 44148ef

File tree

91 files changed

+8760
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+8760
-0
lines changed

.gitattributes

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
###############################################################################
2+
# Set default behavior to automatically normalize line endings.
3+
###############################################################################
4+
* text=auto
5+
6+
###############################################################################
7+
# Set default behavior for command prompt diff.
8+
#
9+
# This is need for earlier builds of msysgit that does not have it on by
10+
# default for csharp files.
11+
# Note: This is only used by command line
12+
###############################################################################
13+
#*.cs diff=csharp
14+
15+
###############################################################################
16+
# Set the merge driver for project and solution files
17+
#
18+
# Merging from the command prompt will add diff markers to the files if there
19+
# are conflicts (Merging from VS is not affected by the settings below, in VS
20+
# the diff markers are never inserted). Diff markers may cause the following
21+
# file extensions to fail to load in VS. An alternative would be to treat
22+
# these files as binary and thus will always conflict and require user
23+
# intervention with every merge. To do so, just uncomment the entries below
24+
###############################################################################
25+
#*.sln merge=binary
26+
#*.csproj merge=binary
27+
#*.vbproj merge=binary
28+
#*.vcxproj merge=binary
29+
#*.vcproj merge=binary
30+
#*.dbproj merge=binary
31+
#*.fsproj merge=binary
32+
#*.lsproj merge=binary
33+
#*.wixproj merge=binary
34+
#*.modelproj merge=binary
35+
#*.sqlproj merge=binary
36+
#*.wwaproj merge=binary
37+
38+
###############################################################################
39+
# behavior for image files
40+
#
41+
# image files are treated as binary by default.
42+
###############################################################################
43+
#*.jpg binary
44+
#*.png binary
45+
#*.gif binary
46+
47+
###############################################################################
48+
# diff behavior for common document formats
49+
#
50+
# Convert binary document formats to text before diffing them. This feature
51+
# is only available from the command line. Turn it on by uncommenting the
52+
# entries below.
53+
###############################################################################
54+
#*.doc diff=astextplain
55+
#*.DOC diff=astextplain
56+
#*.docx diff=astextplain
57+
#*.DOCX diff=astextplain
58+
#*.dot diff=astextplain
59+
#*.DOT diff=astextplain
60+
#*.pdf diff=astextplain
61+
#*.PDF diff=astextplain
62+
#*.rtf diff=astextplain
63+
#*.RTF diff=astextplain

samples/DO.Samples.Forms/DO.Samples.Forms.sln

Lines changed: 469 additions & 0 deletions
Large diffs are not rendered by default.
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 you 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: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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>{7CC8DA5D-8A92-43EB-A55C-DC885D90035E}</ProjectGuid>
7+
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
8+
<OutputType>Library</OutputType>
9+
<RootNamespace>DO.Samples.Forms.Droid</RootNamespace>
10+
<AssemblyName>DO.Samples.Forms.Android</AssemblyName>
11+
<TargetFrameworkVersion>v8.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+
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
18+
<AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
19+
<NuGetPackageImportStamp>
20+
</NuGetPackageImportStamp>
21+
</PropertyGroup>
22+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
23+
<DebugSymbols>true</DebugSymbols>
24+
<DebugType>full</DebugType>
25+
<Optimize>false</Optimize>
26+
<OutputPath>bin\Debug</OutputPath>
27+
<DefineConstants>DEBUG;</DefineConstants>
28+
<ErrorReport>prompt</ErrorReport>
29+
<WarningLevel>4</WarningLevel>
30+
<AndroidLinkMode>None</AndroidLinkMode>
31+
<AotAssemblies>false</AotAssemblies>
32+
<EnableLLVM>false</EnableLLVM>
33+
<BundleAssemblies>false</BundleAssemblies>
34+
</PropertyGroup>
35+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
36+
<DebugSymbols>true</DebugSymbols>
37+
<DebugType>pdbonly</DebugType>
38+
<Optimize>true</Optimize>
39+
<OutputPath>bin\Release</OutputPath>
40+
<ErrorReport>prompt</ErrorReport>
41+
<WarningLevel>4</WarningLevel>
42+
<AndroidManagedSymbols>true</AndroidManagedSymbols>
43+
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
44+
</PropertyGroup>
45+
<ItemGroup>
46+
<Reference Include="Mono.Android" />
47+
<Reference Include="System" />
48+
<Reference Include="System.Core" />
49+
<Reference Include="System.Xml.Linq" />
50+
<Reference Include="System.Xml" />
51+
</ItemGroup>
52+
<ItemGroup>
53+
<PackageReference Include="Plugin.CurrentActivity">
54+
<Version>1.0.1</Version>
55+
</PackageReference>
56+
<PackageReference Include="Xamarin.Forms" Version="2.5.0.122203" />
57+
<PackageReference Include="Xamarin.Android.Support.Design" Version="25.4.0.2" />
58+
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="25.4.0.2" />
59+
<PackageReference Include="Xamarin.Android.Support.v4" Version="25.4.0.2" />
60+
<PackageReference Include="Xamarin.Android.Support.v7.CardView" Version="25.4.0.2" />
61+
<PackageReference Include="Xamarin.Android.Support.v7.MediaRouter" Version="25.4.0.2" />
62+
</ItemGroup>
63+
<ItemGroup>
64+
<Compile Include="MainActivity.cs" />
65+
<Compile Include="Resources\Resource.Designer.cs" />
66+
<Compile Include="Properties\AssemblyInfo.cs" />
67+
</ItemGroup>
68+
<ItemGroup>
69+
<None Include="Resources\AboutResources.txt" />
70+
<None Include="Assets\AboutAssets.txt" />
71+
</ItemGroup>
72+
<ItemGroup>
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+
<ItemGroup>
79+
<None Include="Properties\AndroidManifest.xml" />
80+
</ItemGroup>
81+
<ItemGroup>
82+
<AndroidResource Include="Resources\layout\Tabbar.axml" />
83+
<AndroidResource Include="Resources\layout\Toolbar.axml" />
84+
<AndroidResource Include="Resources\values\styles.xml">
85+
<SubType>Designer</SubType>
86+
</AndroidResource>
87+
</ItemGroup>
88+
<ItemGroup>
89+
<ProjectReference Include="..\..\..\..\src\DeviceOrientation\Plugin.DeviceOrientation.Abstractions\Plugin.DeviceOrientation.Abstractions.csproj">
90+
<Project>{dbc0d79e-5fcc-4c55-84f7-1425bb651b3d}</Project>
91+
<Name>Plugin.DeviceOrientation.Abstractions</Name>
92+
</ProjectReference>
93+
<ProjectReference Include="..\..\..\..\src\DeviceOrientation\Plugin.DeviceOrientation.Android\Plugin.DeviceOrientation.Android.csproj">
94+
<Project>{56a56f17-7de1-4ca1-9617-bf32e971ac84}</Project>
95+
<Name>Plugin.DeviceOrientation.Android</Name>
96+
</ProjectReference>
97+
<ProjectReference Include="..\DO.Samples.Forms\DO.Samples.Forms.csproj">
98+
<Project>{098B640F-9C25-4E70-A013-634372556F4B}</Project>
99+
<Name>DO.Samples.Forms</Name>
100+
</ProjectReference>
101+
</ItemGroup>
102+
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
103+
</Project>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using Android.App;
2+
using Android.Content.PM;
3+
using Android.OS;
4+
using Plugin.CurrentActivity;
5+
using Android.Content.Res;
6+
using Plugin.DeviceOrientation;
7+
8+
namespace DO.Samples.Forms.Droid
9+
{
10+
[Activity(Label = "DO.Samples.Forms", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
11+
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
12+
{
13+
protected override void OnCreate(Bundle bundle)
14+
{
15+
TabLayoutResource = Resource.Layout.Tabbar;
16+
ToolbarResource = Resource.Layout.Toolbar;
17+
18+
base.OnCreate(bundle);
19+
20+
// Step 1:
21+
CrossCurrentActivity.Current.Activity = this;
22+
23+
// Step 2:
24+
DeviceOrientationImplementation.Init();
25+
26+
// ...
27+
28+
global::Xamarin.Forms.Forms.Init(this, bundle);
29+
LoadApplication(new App());
30+
}
31+
32+
// Step 3:
33+
public override void OnConfigurationChanged(Configuration newConfig)
34+
{
35+
base.OnConfigurationChanged(newConfig);
36+
37+
DeviceOrientationImplementation.NotifyOrientationChange(newConfig);
38+
}
39+
}
40+
}
41+
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="name.pakalo.evgeniy.dop" android:installLocation="auto">
3+
<uses-sdk android:minSdkVersion="15" />
4+
<application android:label="DO.Samples.Forms.Android"></application>
5+
</manifest>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
using Android.App;
5+
6+
// General Information about an assembly is controlled through the following
7+
// set of attributes. Change these attribute values to modify the information
8+
// associated with an assembly.
9+
[assembly: AssemblyTitle("DO.Samples.Forms.Android")]
10+
[assembly: AssemblyDescription("")]
11+
[assembly: AssemblyConfiguration("")]
12+
[assembly: AssemblyCompany("")]
13+
[assembly: AssemblyProduct("DO.Samples.Forms.Android")]
14+
[assembly: AssemblyCopyright("Copyright © 2018 Yauheni Pakala")]
15+
[assembly: AssemblyTrademark("")]
16+
[assembly: AssemblyCulture("")]
17+
[assembly: ComVisible(false)]
18+
19+
// Version information for an assembly consists of the following four values:
20+
//
21+
// Major Version
22+
// Minor Version
23+
// Build Number
24+
// Revision
25+
//
26+
// You can specify all the values or you can default the Build and Revision Numbers
27+
// by using the '*' as shown below:
28+
// [assembly: AssemblyVersion("1.0.*")]
29+
[assembly: AssemblyVersion("1.0.0.0")]
30+
[assembly: AssemblyFileVersion("1.0.0.0")]
31+
32+
// Add some common permissions, these can be removed if not needed
33+
[assembly: UsesPermission(Android.Manifest.Permission.Internet)]
34+
[assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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.xml),
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-hdpi/
12+
icon.png
13+
14+
drawable-ldpi/
15+
icon.png
16+
17+
drawable-mdpi/
18+
icon.png
19+
20+
layout/
21+
main.xml
22+
23+
values/
24+
strings.xml
25+
26+
In order to get the build system to recognize Android resources, set the build action to
27+
"AndroidResource". The native Android APIs do not operate directly with filenames, but
28+
instead operate on resource IDs. When you compile an Android application that uses resources,
29+
the build system will package the resources for distribution and generate a class called
30+
"Resource" that contains the tokens for each one of the resources included. For example,
31+
for the above Resources layout, this is what the Resource class would expose:
32+
33+
public class Resource {
34+
public class drawable {
35+
public const int icon = 0x123;
36+
}
37+
38+
public class layout {
39+
public const int main = 0x456;
40+
}
41+
42+
public class strings {
43+
public const int first_string = 0xabc;
44+
public const int second_string = 0xbcd;
45+
}
46+
}
47+
48+
You would then use R.drawable.icon to reference the drawable/icon.png file, or Resource.layout.main
49+
to reference the layout/main.xml file, or Resource.strings.first_string to reference the first
50+
string in the dictionary file values/strings.xml.

0 commit comments

Comments
 (0)