Skip to content

Commit 08c0ad2

Browse files
committed
initial commit
0 parents  commit 08c0ad2

24 files changed

Lines changed: 1079 additions & 0 deletions

File tree

‎.editorconfig‎

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

‎.github/workflows/checks.yml‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Checks
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
packages: read
12+
13+
concurrency:
14+
group: checks-${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
checks:
19+
name: Android SDK 36
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 20
22+
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
26+
steps:
27+
- name: Check out repository
28+
uses: actions/checkout@v7
29+
30+
- name: Set up JDK
31+
uses: actions/setup-java@v5
32+
with:
33+
distribution: temurin
34+
java-version: "17"
35+
36+
- name: Set up Gradle
37+
uses: gradle/actions/setup-gradle@v6
38+
39+
- name: Test, lint, and build
40+
run: ./gradlew --no-daemon testDebugUnitTest lintDebug assembleDebug

‎.gitignore‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Android Studio and Gradle local state
2+
.gradle/
3+
.kotlin/
4+
.idea/
5+
.vscode/
6+
.fleet/
7+
.settings/
8+
.project
9+
.classpath
10+
*.iml
11+
local.properties
12+
13+
# Build output
14+
build/
15+
app/build/
16+
/app/release/
17+
out/
18+
captures/
19+
.externalNativeBuild/
20+
.cxx/
21+
*.apk
22+
*.aab
23+
*.ap_
24+
*.dex
25+
26+
# Local environment, credentials, and signing files
27+
.env
28+
.env.*
29+
!.env.example
30+
secrets.properties
31+
keystore.properties
32+
*.jks
33+
*.keystore
34+
*.p12
35+
*.pem
36+
*.key
37+
google-services.json
38+
service-account*.json
39+
40+
# Operating system files
41+
.DS_Store
42+
Thumbs.db
43+
*.swp
44+
*.swo
45+
*~
46+
*.log

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2026 Fahad Heylaal (https://fahad19.com)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

‎Makefile‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.PHONY: build test clean
2+
3+
GRADLE ?= ./gradlew --no-daemon
4+
5+
build:
6+
$(GRADLE) testDebugUnitTest lintDebug assembleDebug
7+
8+
test:
9+
$(GRADLE) testDebugUnitTest
10+
11+
clean:
12+
$(GRADLE) clean

‎README.md‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# messagevisor-example-android
2+
3+
A small native Android application written in Kotlin, showing how to use the published [Messagevisor Java SDK](https://github.com/messagevisor/messagevisor-java).
4+
5+
The application downloads a production Messagevisor datafile, creates an SDK instance with the ICU module, and renders plain and formatted translations.
6+
7+
Learn more at [messagevisor.com](https://messagevisor.com).
8+
9+
## Requirements
10+
11+
Install Android Studio with Android SDK 36 and JDK 17.
12+
13+
The project uses the Kotlin support built into Android Gradle Plugin 9, so it does not require the older Kotlin Android Gradle plugin.
14+
15+
Messagevisor Java is published through GitHub Packages. Add your GitHub username and a personal access token with the `read:packages` scope to `~/.gradle/gradle.properties`:
16+
17+
```properties
18+
gpr.user=YOUR_GITHUB_USERNAME
19+
gpr.key=YOUR_GITHUB_TOKEN
20+
```
21+
22+
Keep these credentials outside the repository. For GitHub Actions, grant the example repository read access to the Messagevisor Java packages.
23+
24+
## Run the application
25+
26+
1. Open the repository in Android Studio.
27+
2. Allow Gradle to sync and resolve Messagevisor Java 0.2.0.
28+
3. Select an Android emulator or connected device.
29+
4. Run the `app` configuration.
30+
31+
## Messagevisor usage
32+
33+
The application fetches this production datafile:
34+
35+
```text
36+
https://messagevisor-example-cloudflare-pages.pages.dev/production/messagevisor-mobile-en-US.json
37+
```
38+
39+
The important SDK usage is in `MainActivity.kt`:
40+
41+
```kotlin
42+
val m = Messagevisor.create(
43+
MessagevisorOptions.builder()
44+
.datafile(datafileJson)
45+
.timeZone("America/New_York")
46+
.addModule(IcuModule.create())
47+
.build(),
48+
)
49+
50+
val signIn = m.translate("auth.signin")
51+
val contact = m.translate(
52+
"nav.contact",
53+
mapOf("closingTime" to closingTime),
54+
)
55+
```
56+
57+
## Checks
58+
59+
Run unit tests, Android lint, and a debug build with:
60+
61+
```sh
62+
make build
63+
```
64+
65+
Learn more in the [Messagevisor Java SDK documentation](https://messagevisor.com/docs/sdks/java/).
66+
67+
## License
68+
69+
[MIT](LICENSE)

‎app/build.gradle.kts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
plugins {
2+
id("com.android.application")
3+
}
4+
5+
android {
6+
namespace = "com.messagevisor.example.android"
7+
// Android 17 API 37 is still a preview SDK.
8+
//noinspection GradleDependency
9+
compileSdk = 36
10+
11+
defaultConfig {
12+
applicationId = "com.messagevisor.example.android"
13+
minSdk = 23
14+
//noinspection OldTargetApi
15+
targetSdk = 36
16+
versionCode = 1
17+
versionName = "1.0"
18+
}
19+
20+
compileOptions {
21+
isCoreLibraryDesugaringEnabled = true
22+
sourceCompatibility = JavaVersion.VERSION_17
23+
targetCompatibility = JavaVersion.VERSION_17
24+
}
25+
}
26+
27+
dependencies {
28+
implementation("com.messagevisor:messagevisor-sdk:0.2.0")
29+
implementation("com.messagevisor:messagevisor-module-icu:0.2.0")
30+
31+
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5")
32+
33+
testImplementation("junit:junit:4.13.2")
34+
}

‎app/src/main/AndroidManifest.xml‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
<uses-permission android:name="android.permission.INTERNET" />
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@drawable/ic_launcher"
8+
android:label="@string/app_name"
9+
android:supportsRtl="true"
10+
android:theme="@style/Theme.MessagevisorExample">
11+
<activity
12+
android:name=".MainActivity"
13+
android:exported="true">
14+
<intent-filter>
15+
<action android:name="android.intent.action.MAIN" />
16+
17+
<category android:name="android.intent.category.LAUNCHER" />
18+
</intent-filter>
19+
</activity>
20+
</application>
21+
</manifest>

0 commit comments

Comments
 (0)