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

Commit b23d4c8

Browse files
authored
Merge pull request #16 from wcoder/faeture/migrate-to-net
Migrate solution to .NET6
2 parents fd4e806 + 4da82ec commit b23d4c8

20 files changed

+227
-416
lines changed

.github/workflows/pr.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Build Solution
2+
3+
on:
4+
push:
5+
pull_request:
6+
branches: [ main ]
7+
paths-ignore:
8+
- 'README.md'
9+
10+
jobs:
11+
build:
12+
name: Build
13+
runs-on: macOS-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Setup .NET
19+
uses: actions/setup-dotnet@v4
20+
with:
21+
global-json-file: global.json
22+
23+
- name: Install .NET Workloads
24+
run: dotnet workload install android
25+
26+
- name: Install NuGet dependencies
27+
run: dotnet restore
28+
29+
- name: Build
30+
run: dotnet build --configuration Debug --no-restore --verbosity detailed
31+
32+
# - name: Test
33+
# run: dotnet test --no-restore --verbosity normal

.github/workflows/release.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Release NuGet
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build:
8+
name: Build
9+
runs-on: macOS-latest
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Setup .NET
15+
uses: actions/setup-dotnet@v4
16+
with:
17+
global-json-file: global.json
18+
19+
- name: Install .NET Workloads
20+
run: dotnet workload install android
21+
22+
- name: Install NuGet dependencies
23+
run: dotnet restore
24+
25+
- name: Pack
26+
run: dotnet pack --configuration Release --no-restore --output . --verbosity detailed
27+
28+
- name: Upload artifact
29+
uses: actions/upload-artifact@v3
30+
with:
31+
name: build-artifact
32+
path: Xamarin.ShortcutBadger.*.nupkg
33+
34+
publish-nuget:
35+
name: Publish to NuGet.org
36+
needs: build
37+
runs-on: ubuntu-latest
38+
39+
steps:
40+
- name: Download artifact
41+
uses: actions/download-artifact@v3
42+
with:
43+
name: build-artifact
44+
45+
- name: Publish
46+
run: dotnet nuget push "*.nupkg" --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json
47+
48+
# - name: Create Release
49+
# run:

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2014-2017 Leo Lin, Yauheni Pakala
1+
Copyright 2014-2024 Leo Lin, Yauheni Pakala
22

33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
<p align="center"><img src="logo/horizontalversion.png" alt="ShortcutBadger" height="130px"></p>
1+
<center><img src="logo/horizontalversion.png" alt="ShortcutBadger" height="130px"></center>
22

3-
# ShortcutBadger ![version](http://img.shields.io/badge/original-v1.1.21-brightgreen.svg?style=flat) [![NuGet Badge](https://buildstats.info/nuget/Xamarin.ShortcutBadger)](https://www.nuget.org/packages/Xamarin.ShortcutBadger/) ![VSTS build status](https://yauhenipakala.visualstudio.com/_apis/public/build/definitions/b0170656-dd62-445e-bbb7-d6a336f4a889/2/badge)
3+
# ShortcutBadger
4+
5+
![version](http://img.shields.io/badge/original-v1.1.21-brightgreen.svg?style=flat) [![NuGet Badge](https://buildstats.info/nuget/Xamarin.ShortcutBadger)](https://www.nuget.org/packages/Xamarin.ShortcutBadger/) [![Build](https://github.com/wcoder/ShortcutBadger/actions/workflows/pr.yml/badge.svg?branch=master)](https://github.com/wcoder/ShortcutBadger/actions/workflows/pr.yml)
46

57
Port of [ShortcutBadger](https://github.com/leolin310148/ShortcutBadger) for Xamarin.Android
68

@@ -197,7 +199,7 @@ please use version 1.1.0+!
197199
LICENSE
198200
===================================
199201

200-
Copyright 2014-2017 Leo Lin, Yauheni Pakala
202+
Copyright 2014-2024 Leo Lin, Yauheni Pakala
201203

202204
Licensed under the Apache License, Version 2.0 (the "License");
203205
you may not use this file except in compliance with the License.

ShortcutBadger.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamarinShortcutBadger", "src\XamarinShortcutBadger\XamarinShortcutBadger.csproj", "{A3D001F3-A38F-4EE1-B084-2E20C5581DF7}"
4+
EndProject
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExampleShortcutBadgerApp", "example\ExampleShortcutBadgerApp\ExampleShortcutBadgerApp.csproj", "{29FE9562-AC3F-41CD-9B5B-8E75A407FC10}"
6+
EndProject
7+
Global
8+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9+
Debug|Any CPU = Debug|Any CPU
10+
Release|Any CPU = Release|Any CPU
11+
EndGlobalSection
12+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
13+
{A3D001F3-A38F-4EE1-B084-2E20C5581DF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
14+
{A3D001F3-A38F-4EE1-B084-2E20C5581DF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
15+
{A3D001F3-A38F-4EE1-B084-2E20C5581DF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
16+
{A3D001F3-A38F-4EE1-B084-2E20C5581DF7}.Release|Any CPU.Build.0 = Release|Any CPU
17+
{29FE9562-AC3F-41CD-9B5B-8E75A407FC10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18+
{29FE9562-AC3F-41CD-9B5B-8E75A407FC10}.Debug|Any CPU.Build.0 = Debug|Any CPU
19+
{29FE9562-AC3F-41CD-9B5B-8E75A407FC10}.Release|Any CPU.ActiveCfg = Release|Any CPU
20+
{29FE9562-AC3F-41CD-9B5B-8E75A407FC10}.Release|Any CPU.Build.0 = Release|Any CPU
21+
EndGlobalSection
22+
EndGlobal

example/ExampleShortcutBadgerApp.sln

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 13 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,17 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1+
<Project Sdk="Microsoft.NET.Sdk">
32
<PropertyGroup>
4-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6-
<ProductVersion>8.0.30703</ProductVersion>
7-
<SchemaVersion>2.0</SchemaVersion>
8-
<ProjectGuid>{4EC74AAB-4146-4B8B-A384-AB11E52543C9}</ProjectGuid>
9-
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
10-
<OutputType>Library</OutputType>
11-
<AppDesignerFolder>Properties</AppDesignerFolder>
12-
<RootNamespace>ExampleShortcutBadgerApp</RootNamespace>
13-
<AssemblyName>ExampleShortcutBadgerApp</AssemblyName>
14-
<FileAlignment>512</FileAlignment>
15-
<AndroidApplication>true</AndroidApplication>
16-
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
17-
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
18-
<AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
19-
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
20-
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
3+
<TargetFramework>net6.0-android</TargetFramework>
4+
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
5+
<OutputType>Exe</OutputType>
6+
<Nullable>enable</Nullable>
7+
<IsPackable>false</IsPackable>
8+
<ImplicitUsings>enable</ImplicitUsings>
9+
<ApplicationId>ExampleShortcutBadgerApp.ExampleShortcutBadgerApp</ApplicationId>
10+
<ApplicationVersion>1</ApplicationVersion>
11+
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
2112
</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;TRACE</DefineConstants>
28-
<ErrorReport>prompt</ErrorReport>
29-
<WarningLevel>4</WarningLevel>
30-
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
31-
<AndroidLinkMode>None</AndroidLinkMode>
32-
</PropertyGroup>
33-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
34-
<DebugType>pdbonly</DebugType>
35-
<Optimize>true</Optimize>
36-
<OutputPath>bin\Release\</OutputPath>
37-
<DefineConstants>TRACE</DefineConstants>
38-
<ErrorReport>prompt</ErrorReport>
39-
<WarningLevel>4</WarningLevel>
40-
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
41-
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
42-
</PropertyGroup>
43-
<ItemGroup>
44-
<Reference Include="Mono.Android" />
45-
<Reference Include="mscorlib" />
46-
<Reference Include="System" />
47-
<Reference Include="System.Core" />
48-
<Reference Include="System.Xml.Linq" />
49-
<Reference Include="System.Xml" />
50-
</ItemGroup>
51-
<ItemGroup>
52-
<Compile Include="MainActivity.cs" />
53-
<Compile Include="Resources\Resource.Designer.cs" />
54-
<Compile Include="Properties\AssemblyInfo.cs" />
55-
</ItemGroup>
56-
<ItemGroup>
57-
<None Include="Resources\AboutResources.txt" />
58-
<None Include="Assets\AboutAssets.txt" />
59-
</ItemGroup>
60-
<ItemGroup>
61-
<AndroidResource Include="Resources\layout\Main.axml" />
62-
</ItemGroup>
63-
<ItemGroup>
64-
<AndroidResource Include="Resources\values\Strings.xml" />
65-
</ItemGroup>
66-
<ItemGroup>
67-
<AndroidResource Include="Resources\drawable\Icon.png" />
68-
</ItemGroup>
69-
<ItemGroup>
70-
<None Include="Properties\AndroidManifest.xml" />
71-
</ItemGroup>
13+
7214
<ItemGroup>
73-
<ProjectReference Include="..\..\src\XamarinShortcutBadger\XamarinShortcutBadger.csproj">
74-
<Project>{77AC5D70-FC29-4192-A2ED-4325C410CBF4}</Project>
75-
<Name>XamarinShortcutBadger</Name>
76-
</ProjectReference>
15+
<ProjectReference Include="..\..\src\XamarinShortcutBadger\XamarinShortcutBadger.csproj" />
7716
</ItemGroup>
78-
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
79-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
80-
Other similar extension points exist, see Microsoft.Common.targets.
81-
<Target Name="BeforeBuild">
82-
</Target>
83-
<Target Name="AfterBuild">
84-
</Target>
85-
-->
86-
</Project>
17+
</Project>
Lines changed: 44 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,51 @@
1-
using Android.App;
2-
using Android.Widget;
3-
using Android.OS;
4-
using XamarinShortcutBadger;
1+
using XamarinShortcutBadger;
52

6-
namespace ExampleShortcutBadgerApp
3+
namespace ExampleShortcutBadgerApp;
4+
5+
[Activity(Label = "ExampleShortcutBadgerApp", MainLauncher = true, Icon = "@drawable/icon")]
6+
public class MainActivity : Activity
77
{
8-
[Activity(Label = "ExampleShortcutBadgerApp", MainLauncher = true, Icon = "@drawable/icon")]
9-
public class MainActivity : Activity
10-
{
11-
protected override void OnCreate(Bundle bundle)
12-
{
13-
base.OnCreate(bundle);
14-
15-
SetContentView(Resource.Layout.Main);
16-
17-
var editText = FindViewById<EditText>(Resource.Id.badgeValue);
18-
var button = FindViewById<Button>(Resource.Id.updateButton);
19-
20-
button.Click += delegate
21-
{
22-
var count = int.Parse(editText.Text);
23-
var isSupported = ShortcutBadger.IsBadgeCounterSupported(this);
24-
25-
if (isSupported)
26-
{
27-
ShortcutBadger.ApplyCount(this, count);
28-
29-
Toast.MakeText(this, "Success!", ToastLength.Short);
30-
}
31-
else
32-
{
33-
Toast.MakeText(this, "Not supported!", ToastLength.Short);
34-
}
8+
protected override void OnCreate(Bundle? bundle)
9+
{
10+
base.OnCreate(bundle);
11+
12+
SetContentView(Resource.Layout.Main);
13+
14+
var editText = FindViewById<EditText>(Resource.Id.badgeValue);
15+
var button = FindViewById<Button>(Resource.Id.updateButton);
16+
17+
button!.Click += delegate
18+
{
19+
var count = int.Parse(editText!.Text!);
20+
var isSupported = ShortcutBadger.IsBadgeCounterSupported(this);
21+
22+
if (isSupported)
23+
{
24+
ShortcutBadger.ApplyCount(this, count);
25+
26+
Toast.MakeText(this, "Success!", ToastLength.Short);
27+
}
28+
else
29+
{
30+
Toast.MakeText(this, "Not supported!", ToastLength.Short);
31+
}
3532

3633

3734

38-
// For Xiaomi:
39-
// From https://github.com/leolin310148/ShortcutBadger/blob/master/SampleApp/src/main/java/me/leolin/shortcutbadger/example/BadgeIntentService.java
40-
/*
41-
var notificationId = 1;
42-
var mNotificationManager = (NotificationManager)GetSystemService(NotificationService);
43-
var builder = new Notification.Builder(ApplicationContext)
44-
.SetContentTitle("")
45-
.SetContentText("")
46-
.SetSmallIcon(Resource.Drawable.Icon);
47-
Notification notification = builder.Build();
48-
ShortcutBadger.ApplyNotification(ApplicationContext, notification, count);
49-
mNotificationManager.Notify(notificationId, notification);
50-
*/
51-
};
52-
}
53-
}
35+
// For Xiaomi:
36+
// From https://github.com/leolin310148/ShortcutBadger/blob/master/SampleApp/src/main/java/me/leolin/shortcutbadger/example/BadgeIntentService.java
37+
/*
38+
var notificationId = 1;
39+
var mNotificationManager = (NotificationManager)GetSystemService(NotificationService);
40+
var builder = new Notification.Builder(ApplicationContext)
41+
.SetContentTitle("")
42+
.SetContentText("")
43+
.SetSmallIcon(Resource.Drawable.Icon);
44+
Notification notification = builder.Build();
45+
ShortcutBadger.ApplyNotification(ApplicationContext, notification, count);
46+
mNotificationManager.Notify(notificationId, notification);
47+
*/
48+
};
49+
}
5450
}
5551

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ExampleShortcutBadgerApp.ExampleShortcutBadgerApp" android:versionCode="1" android:versionName="1.0">
3-
<uses-sdk android:minSdkVersion="16" />
3+
<uses-sdk android:minSdkVersion="21" />
44
<application android:label="ExampleShortcutBadgerApp"></application>
55
</manifest>

0 commit comments

Comments
 (0)