Skip to content

Commit 1070836

Browse files
committed
feat: Add Facebook Android interop wrapper and related documentation
- Introduced a new interop wrapper for Facebook Login on Android, including necessary AARs. - Created CODE_OF_CONDUCT.md and CONTRIBUTING.md for community guidelines. - Added DependencyLocks for deterministic AAR restoration. - Developed integration and source mode documentation for developers. - Implemented a sample Android application demonstrating the interop functionality. - Established a security policy for reporting vulnerabilities. - Included third-party notices for compliance with Facebook SDK licensing. - Configured build scripts and Gradle settings for Android native components.
1 parent 4d16d81 commit 1070836

38 files changed

Lines changed: 1066 additions & 1 deletion

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
9+
[*.cs]
10+
indent_style = tab
11+
indent_size = 4
12+
13+
[*.{yml,yaml,json,md,sh,gradle,kts,xml}]
14+
indent_style = space
15+
indent_size = 2

.github/pull_request_template.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Summary
2+
3+
- What does this change do?
4+
5+
## Checklist
6+
7+
- [ ] No secrets committed
8+
- [ ] Built wrapper: `bash src/Kapusch.FacebookApisForAndroidComponents/Native/Android/build.sh`
9+
- [ ] Restored pinned AARs: `bash src/Kapusch.FacebookApisForAndroidComponents/Native/Android/restore-facebook-aars.sh`
10+
- [ ] Packed NuGet: `dotnet pack src/Kapusch.FacebookApisForAndroidComponents/Kapusch.FacebookApisForAndroidComponents.csproj -c Release -o artifacts/nuget`
11+
- [ ] Updated docs if behavior/integration changed

.github/workflows/ci.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: ci
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
build_pack_android:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- uses: actions/setup-dotnet@v4
17+
with:
18+
dotnet-version: "10.0.x"
19+
20+
- uses: actions/setup-java@v4
21+
with:
22+
distribution: "microsoft"
23+
java-version: "21"
24+
25+
- name: Setup Android SDK
26+
uses: android-actions/setup-android@v3
27+
28+
- name: Install Android workload
29+
run: |
30+
dotnet workload install android
31+
32+
- name: Cache NuGet
33+
uses: actions/cache@v4
34+
with:
35+
path: ~/.nuget/packages
36+
key: ${{ runner.os }}-nuget-${{ hashFiles('global.json', '**/*.csproj') }}
37+
38+
- name: Build Android wrapper
39+
run: |
40+
bash src/Kapusch.FacebookApisForAndroidComponents/Native/Android/build.sh
41+
42+
- name: Restore pinned Facebook AARs
43+
run: |
44+
bash src/Kapusch.FacebookApisForAndroidComponents/Native/Android/restore-facebook-aars.sh
45+
46+
- name: Pack
47+
run: |
48+
dotnet pack src/Kapusch.FacebookApisForAndroidComponents/Kapusch.FacebookApisForAndroidComponents.csproj \
49+
-c Release \
50+
-o artifacts/nuget
51+
52+
- name: Build Android sample
53+
run: |
54+
dotnet build samples/Kapusch.Facebook.Android.Sample/Kapusch.Facebook.Android.Sample.csproj -c Debug
55+
56+
- uses: actions/upload-artifact@v4
57+
with:
58+
name: nuget
59+
path: artifacts/nuget/*.nupkg

.github/workflows/publish.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: publish
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- "v*"
8+
9+
permissions:
10+
contents: read
11+
packages: write
12+
13+
jobs:
14+
pack_and_publish:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Determine package version
22+
id: version
23+
shell: bash
24+
run: |
25+
if [[ "${{ github.ref }}" =~ ^refs/tags/v ]]; then
26+
REF="${{ github.ref }}"
27+
VERSION="${REF#refs/tags/v}"
28+
else
29+
CSPROJ="src/Kapusch.FacebookApisForAndroidComponents/Kapusch.FacebookApisForAndroidComponents.csproj"
30+
BASE_VERSION=$(grep -oE '<Version>[^<]+' "$CSPROJ" | head -n 1 | sed 's/<Version>//' || echo "0.1.0")
31+
COMMIT_SHORT=$(git rev-parse --short HEAD)
32+
RUN_NUMBER="${{ github.run_number }}"
33+
VERSION="${BASE_VERSION}-prerelease.${RUN_NUMBER}.${COMMIT_SHORT}"
34+
fi
35+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
36+
echo "Package version: ${VERSION}"
37+
38+
- uses: actions/setup-dotnet@v4
39+
with:
40+
dotnet-version: "10.0.x"
41+
42+
- uses: actions/setup-java@v4
43+
with:
44+
distribution: "microsoft"
45+
java-version: "21"
46+
47+
- name: Setup Android SDK
48+
uses: android-actions/setup-android@v3
49+
50+
- name: Install Android workload
51+
run: |
52+
dotnet workload install android
53+
54+
- name: Cache NuGet
55+
uses: actions/cache@v4
56+
with:
57+
path: ~/.nuget/packages
58+
key: ${{ runner.os }}-nuget-${{ hashFiles('global.json', '**/*.csproj') }}
59+
60+
- name: Build Android wrapper
61+
run: |
62+
bash src/Kapusch.FacebookApisForAndroidComponents/Native/Android/build.sh
63+
64+
- name: Restore pinned Facebook AARs
65+
run: |
66+
bash src/Kapusch.FacebookApisForAndroidComponents/Native/Android/restore-facebook-aars.sh
67+
68+
- name: Pack
69+
run: |
70+
dotnet pack src/Kapusch.FacebookApisForAndroidComponents/Kapusch.FacebookApisForAndroidComponents.csproj \
71+
-c Release \
72+
-o artifacts/nuget \
73+
/p:PackageVersion="${{ steps.version.outputs.version }}"
74+
75+
- name: Push to GitHub Packages
76+
env:
77+
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
run: |
79+
dotnet nuget push artifacts/nuget/*.nupkg \
80+
--api-key "$NUGET_AUTH_TOKEN" \
81+
--source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \
82+
--skip-duplicate

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# .NET
2+
bin/
3+
obj/
4+
*.user
5+
*.suo
6+
*.userosscache
7+
*.sln.docstates
8+
9+
# NuGet
10+
*.nupkg
11+
*.snupkg
12+
artifacts/
13+
14+
# macOS
15+
.DS_Store
16+
17+
# Gradle / Android
18+
.gradle/
19+
**/.gradle/
20+
local.properties
21+
**/local.properties
22+
**/build/
23+
24+
# Local caches used by restore
25+
.kapusch/
26+
27+
# Native build output (repo-only)
28+
src/**/Native/Android/build/
29+
30+
# Sample local config
31+
samples/**/google-services.json
32+
samples/**/secrets.*

AGENTS.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Kapusch.FacebookApisForAndroidComponents — AI Working Agreement
2+
3+
## Goals
4+
- Produce a reproducible Android NuGet package for Facebook Login interop.
5+
- Do not commit secrets.
6+
7+
## Packaging constraints
8+
- Public OSS repo: keep docs/sample generic and not app-specific.
9+
- The NuGet ships the required `.aar` artifacts and injects them into consuming apps via `buildTransitive` `AndroidAarLibrary`.
10+
- Consuming apps must not download native deps at build time.
11+
- This repo may download dependencies during CI/build, but consuming apps must not.
12+
13+
## Repo layout
14+
- `src/Kapusch.FacebookApisForAndroidComponents/` — NuGet project (managed API + buildTransitive MSBuild)
15+
- `src/Kapusch.FacebookApisForAndroidComponents/Native/Android/` — Gradle wrapper library + scripts (repo-only)
16+
- `DependencyLocks/` — pinned third-party artifacts (URLs + SHA256)
17+
- `Docs/` — integration docs
18+
- `samples/` — optional sample template (no secrets committed)
19+
20+
## Safety
21+
- Do not add new dependency ingestion paths without documenting them in `README.md`.
22+
- Do not commit real app ids/secrets.

CODE_OF_CONDUCT.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Code of Conduct
2+
3+
## Our Pledge
4+
5+
We pledge to make participation in this project and our community a harassment-free experience for everyone.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to a positive environment include:
10+
- Being respectful and considerate in language and actions
11+
- Giving and gracefully accepting constructive feedback
12+
- Focusing on what is best for the community
13+
14+
Examples of unacceptable behavior include:
15+
- Harassment, discrimination, or hateful conduct
16+
- Trolling, insulting or derogatory comments, and personal or political attacks
17+
- Publishing others’ private information without explicit permission
18+
19+
## Enforcement
20+
21+
Project maintainers are responsible for clarifying and enforcing standards.
22+
23+
To report a Code of Conduct issue, contact the project maintainers.
24+
25+
## Attribution
26+
27+
This document is based on the Contributor Covenant.

CONTRIBUTING.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Contributing
2+
3+
Thanks for contributing!
4+
5+
## Prerequisites
6+
7+
- JDK 21
8+
- Android SDK installed (set `ANDROID_SDK_ROOT` or `ANDROID_HOME`)
9+
- .NET SDK 10 (this repo pins `10.0.100` via `global.json`)
10+
11+
## Local build
12+
13+
If you are working without the NuGet (ProjectReference), see `Docs/SourceMode.md`.
14+
15+
Build the Android wrapper AAR:
16+
17+
- `bash src/Kapusch.FacebookApisForAndroidComponents/Native/Android/build.sh`
18+
19+
Restore pinned Facebook AARs:
20+
21+
- `bash src/Kapusch.FacebookApisForAndroidComponents/Native/Android/restore-facebook-aars.sh`
22+
23+
Pack the NuGet:
24+
25+
- `dotnet pack src/Kapusch.FacebookApisForAndroidComponents/Kapusch.FacebookApisForAndroidComponents.csproj -c Release -o artifacts/nuget`
26+
27+
## Formatting
28+
29+
- C#: follow `.editorconfig` (tabs, LF).
30+
- Java/Kotlin/Gradle: keep changes minimal and consistent with existing style.
31+
32+
## Pull requests
33+
34+
- Keep PRs focused and well-scoped.
35+
- Do not commit secrets.
36+
- If you update the Facebook SDK version, update both:
37+
- `src/Kapusch.FacebookApisForAndroidComponents/Native/Android/facebookinterop/build.gradle.kts`
38+
- `DependencyLocks/Android/lockstate.txt` (URLs + SHA256)
39+
40+
## License
41+
42+
By contributing, you agree that your contributions will be licensed under the repository license (MIT).
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Pinned Android artifacts for deterministic restore.
2+
# Format: <url> <sha256> <filename>
3+
4+
https://repo1.maven.org/maven2/com/facebook/android/facebook-login/18.1.3/facebook-login-18.1.3.aar 30a0bb79b74244228c63101c26353ad61a973e156ca55b712b59fe56fc952100 facebook-login-18.1.3.aar
5+
https://repo1.maven.org/maven2/com/facebook/android/facebook-core/18.1.3/facebook-core-18.1.3.aar ef480916149e078f955195981130b05746ca33b41618911e7093aa32c03d601b facebook-core-18.1.3.aar
6+
https://repo1.maven.org/maven2/com/facebook/android/facebook-common/18.1.3/facebook-common-18.1.3.aar 62adfb1cd05184065d69033a9f917709b392004f87a8aa1cc1c4f0e9fb5ca781 facebook-common-18.1.3.aar
7+
https://repo1.maven.org/maven2/com/facebook/android/facebook-bolts/18.1.3/facebook-bolts-18.1.3.aar 05c6bae0130487e63add05854a3bbd21465c06a295a2104b3948d8759536b699 facebook-bolts-18.1.3.aar

Docs/Integration.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Integration (Android)
2+
3+
This package injects a small Android Activity (provided by an embedded AAR) that runs the Facebook Login flow and returns its result via `Intent` extras.
4+
5+
## Required AndroidManifest entries
6+
7+
You must include the required Meta/Facebook Android SDK entries in your app manifest (example only; use resources, do not hardcode secrets):
8+
9+
- `com.facebook.sdk.ApplicationId`
10+
- `com.facebook.sdk.ClientToken`
11+
12+
You also need to declare `com.facebook.FacebookActivity` and `com.facebook.CustomTabActivity` as per Facebook SDK documentation.
13+
14+
## Launching the flow
15+
16+
From your app, start the interop Activity:
17+
- `AndroidFacebookInterop.LoginActivityClassName`
18+
19+
Then parse the `Intent` extras:
20+
- `AndroidFacebookInterop.ExtraStatus`
21+
- `AndroidFacebookInterop.ExtraAccessToken`
22+
- `AndroidFacebookInterop.ExtraUserId`
23+
- `AndroidFacebookInterop.ExtraErrorCode`
24+
- `AndroidFacebookInterop.ExtraErrorMessage`
25+
26+
## Sign-out
27+
28+
Call `AndroidFacebookInterop.SendSignOutBroadcast(context)`.

0 commit comments

Comments
 (0)