forked from dotnet/android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add .NET 6+ template for Android wear
Fixes dotnet#7003 This speaks for itself, lets add a template for Wear applications.
- Loading branch information
1 parent
2ca2a10
commit 5058553
Showing
30 changed files
with
251 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/Microsoft.Android.Templates/android-wear/.template.config/template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/template", | ||
"author": "Microsoft", | ||
"classifications": [ "Android", "Mobile" ], | ||
"identity": "Microsoft.Android.AndroidWearApp", | ||
"name": "Android Wear Application", | ||
"description": "A project for creating a .NET Android Wear application", | ||
"shortName": "androidwear", | ||
"tags": { | ||
"language": "C#", | ||
"type": "project" | ||
}, | ||
"sourceName": "AndroidApp1", | ||
"sources": [ | ||
{ | ||
"source": "./", | ||
"target": "./", | ||
"copyOnly": "**/Resources/**/*.png" | ||
} | ||
], | ||
"preferNameDirectory": true, | ||
"primaryOutputs": [ | ||
{ "path": "AndroidApp1.csproj" } | ||
], | ||
"symbols": { | ||
"packageName": { | ||
"type": "parameter", | ||
"description": "Overrides the package name in the AndroidManifest.xml", | ||
"datatype": "string", | ||
"replaces": "com.companyname.AndroidApp1" | ||
}, | ||
"supportedOSVersion": { | ||
"type": "parameter", | ||
"description": "Overrides $(SupportedOSPlatformVersion) in the project", | ||
"datatype": "string", | ||
"replaces": "SUPPORTED_OS_PLATFORM_VERSION", | ||
"defaultValue": "23" | ||
} | ||
}, | ||
"defaultName": "AndroidApp1" | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Microsoft.Android.Templates/android-wear/AndroidApp1.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net7.0-android</TargetFramework> | ||
<SupportedOSPlatformVersion>SUPPORTED_OS_PLATFORM_VERSION</SupportedOSPlatformVersion> | ||
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">AndroidApp1</RootNamespace> | ||
<OutputType>Exe</OutputType> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<ApplicationId>com.companyname.AndroidApp1</ApplicationId> | ||
<ApplicationVersion>1</ApplicationVersion> | ||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> | ||
<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);XA4218</MSBuildWarningsAsMessages> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Xamarin.AndroidX.Wear" Version="1.2.0.5" /> | ||
</ItemGroup> | ||
</Project> |
8 changes: 8 additions & 0 deletions
8
src/Microsoft.Android.Templates/android-wear/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0"> | ||
<uses-feature android:name="android.hardware.type.watch" /> | ||
<uses-permission android:name="android.permission.WAKE_LOCK" /> | ||
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:label="@string/app_name" android:supportsRtl="true" android:theme="@android:style/Theme.DeviceDefault"> | ||
<uses-library android:name="com.google.android.wearable" android:required="true" /> | ||
</application> | ||
</manifest> |
13 changes: 13 additions & 0 deletions
13
src/Microsoft.Android.Templates/android-wear/MainActivity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace AndroidApp1; | ||
|
||
[Activity(Label = "@string/app_name", MainLauncher = true)] | ||
public class MainActivity : Activity | ||
{ | ||
protected override void OnCreate(Bundle? savedInstanceState) | ||
{ | ||
base.OnCreate(savedInstanceState); | ||
|
||
// Set our view from the "main" layout resource | ||
SetContentView(Resource.Layout.activity_main); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/Microsoft.Android.Templates/android-wear/Resources/AboutResources.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
Images, layout descriptions, binary blobs and string dictionaries can be included | ||
in your application as resource files. Various Android APIs are designed to | ||
operate on the resource IDs instead of dealing with images, strings or binary blobs | ||
directly. | ||
|
||
For example, a sample Android app that contains a user interface layout (main.xml), | ||
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) | ||
would keep its resources in the "Resources" directory of the application: | ||
|
||
Resources/ | ||
drawable/ | ||
icon.png | ||
|
||
layout/ | ||
main.xml | ||
|
||
values/ | ||
strings.xml | ||
|
||
In order to get the build system to recognize Android resources, set the build action to | ||
"AndroidResource". The native Android APIs do not operate directly with filenames, but | ||
instead operate on resource IDs. When you compile an Android application that uses resources, | ||
the build system will package the resources for distribution and generate a class called "Resource" | ||
(this is an Android convention) that contains the tokens for each one of the resources | ||
included. For example, for the above Resources layout, this is what the Resource class would expose: | ||
|
||
public class Resource { | ||
public class Drawable { | ||
public const int icon = 0x123; | ||
} | ||
|
||
public class Layout { | ||
public const int main = 0x456; | ||
} | ||
|
||
public class Strings { | ||
public const int first_string = 0xabc; | ||
public const int second_string = 0xbcd; | ||
} | ||
} | ||
|
||
You would then use Resource.Drawable.icon to reference the drawable/icon.png file, or | ||
Resource.Layout.main to reference the layout/main.xml file, or Resource.Strings.first_string | ||
to reference the first string in the dictionary file values/strings.xml. |
19 changes: 19 additions & 0 deletions
19
src/Microsoft.Android.Templates/android-wear/Resources/layout/activity_main.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.wear.widget.BoxInsetLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:padding="@dimen/box_inset_layout_padding" | ||
tools:deviceIds="wear"> | ||
<FrameLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:padding="@dimen/inner_frame_layout_padding" | ||
app:boxedEdges="all"> | ||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@string/app_text" /> | ||
</FrameLayout> | ||
</androidx.wear.widget.BoxInsetLayout> |
1 change: 1 addition & 0 deletions
1
src/Microsoft.Android.Templates/android-wear/Resources/mipmap-anydpi-v26/appicon.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"><background android:drawable="@mipmap/appicon_background" /><foreground android:drawable="@mipmap/appicon_foreground" /></adaptive-icon> |
1 change: 1 addition & 0 deletions
1
src/Microsoft.Android.Templates/android-wear/Resources/mipmap-anydpi-v26/appicon_round.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"><background android:drawable="@mipmap/appicon_background" /><foreground android:drawable="@mipmap/appicon_foreground" /></adaptive-icon> |
Binary file added
BIN
+1.11 KB
src/Microsoft.Android.Templates/android-wear/Resources/mipmap-hdpi/appicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+532 Bytes
...oft.Android.Templates/android-wear/Resources/mipmap-hdpi/appicon_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.48 KB
...oft.Android.Templates/android-wear/Resources/mipmap-hdpi/appicon_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+868 Bytes
src/Microsoft.Android.Templates/android-wear/Resources/mipmap-mdpi/appicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+352 Bytes
...oft.Android.Templates/android-wear/Resources/mipmap-mdpi/appicon_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.25 KB
...oft.Android.Templates/android-wear/Resources/mipmap-mdpi/appicon_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.44 KB
src/Microsoft.Android.Templates/android-wear/Resources/mipmap-xhdpi/appicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+702 Bytes
...ft.Android.Templates/android-wear/Resources/mipmap-xhdpi/appicon_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.11 KB
...ft.Android.Templates/android-wear/Resources/mipmap-xhdpi/appicon_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.88 KB
src/Microsoft.Android.Templates/android-wear/Resources/mipmap-xxhdpi/appicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.02 KB
...t.Android.Templates/android-wear/Resources/mipmap-xxhdpi/appicon_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.56 KB
...t.Android.Templates/android-wear/Resources/mipmap-xxhdpi/appicon_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.5 KB
src/Microsoft.Android.Templates/android-wear/Resources/mipmap-xxxhdpi/appicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.69 KB
....Android.Templates/android-wear/Resources/mipmap-xxxhdpi/appicon_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.25 KB
....Android.Templates/android-wear/Resources/mipmap-xxxhdpi/appicon_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions
4
src/Microsoft.Android.Templates/android-wear/Resources/values-round/strings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="app_text">Hello, Android Wear!</string> | ||
</resources> |
15 changes: 15 additions & 0 deletions
15
src/Microsoft.Android.Templates/android-wear/Resources/values/dimens.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<!-- | ||
Because the window insets on round devices are larger than 15dp, this padding only applies | ||
to square screens. | ||
--> | ||
<dimen name="box_inset_layout_padding">0dp</dimen> | ||
|
||
<!-- | ||
This padding applies to both square and round screens. The total padding between the buttons | ||
and the window insets is box_inset_layout_padding (above variable) on square screens and | ||
inner_frame_layout_padding (below variable) on round screens. | ||
--> | ||
<dimen name="inner_frame_layout_padding">5dp</dimen> | ||
</resources> |
9 changes: 9 additions & 0 deletions
9
src/Microsoft.Android.Templates/android-wear/Resources/values/strings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="app_name">AndroidApp1</string> | ||
<!-- | ||
This string is used for square devices and overridden by hello_world in | ||
values-round/strings.xml for round devices. | ||
--> | ||
<string name="app_text">Hello, Android Wear!</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters