Skip to content

Commit 5bf31b3

Browse files
ErikUggeldahlErikUggeldahl
ErikUggeldahl
andcommitted
Documentation Updates
As I've explored the surface area of the Android SDK, I've made a TLC pass on the documentation. This isn't exhaustive, but it includes everything I've looked at. Note that I've installed within my Android Studio a plugin "Kotlin KDoc Formatter". This has reformatted our KDocs to respect a given width and remove some inconsistent manual formatting. And who has time for that? There's a few very minor changes beyond just documentation: - Consistent use of default values - Normalized the Gradle file - Changed some method assertions to use `check` rather than `require` as this is semantically more what we're doing - checking state rather than requiring a parameter - In one instance used `entries` rather than `values` - a suggestion made by Android Studio - Using an uppercase constant `RIVE_ANDROID` ## To-do - [x] Move XML documentation to `attrs.xml` - [x] Normalize the module `build.gradle` - [x] Normalize the app `build.gradle` Diffs= f3f3c5c4d2 Documentation Updates (#8481) Co-authored-by: Erik <[email protected]>
1 parent cd87ae3 commit 5bf31b3

Some content is hidden

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

55 files changed

+723
-857
lines changed

Diff for: .editorconfig

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[*.kt]
2+
max_line_length = 100

Diff for: .gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@ build.nexus.sh
3030
.settings
3131
.classpath
3232
kotlin/src/main/jniLibs/*
33-
kotlin/.cxx
33+
kotlin/.cxx
34+
# Notification of missing NDK
35+
kotlin/src/main/cpp/rive_build_x86.log

Diff for: .rive_head

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
f34822a1249d46f46e6ca60daa6ea3f3045f3981
1+
f3f3c5c4d20b6caf81400470b7d2908ab61320a0

Diff for: LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020-2021 Rive
3+
Copyright (c) 2020-2024 Rive
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Diff for: app/build.gradle

+33-34
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
apply plugin: 'com.android.application'
2-
apply plugin: 'kotlin-android'
1+
apply plugin: "com.android.application"
2+
apply plugin: "kotlin-android"
33

44
android {
55
compileSdk 34
6+
namespace "app.rive.runtime.example"
7+
ndkVersion "25.1.8937393"
68

79
defaultConfig {
810
applicationId "app.rive.runtime.example"
@@ -22,18 +24,18 @@ android {
2224
debuggable true
2325
minifyEnabled false
2426
shrinkResources false
25-
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
27+
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
2628
}
2729
release {
2830
minifyEnabled true
2931
shrinkResources true
30-
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
32+
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
3133
}
3234
preview {
3335
debuggable true
3436
minifyEnabled false
3537
shrinkResources false
36-
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
38+
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
3739
getIsDefault().set(true)
3840
signingConfig signingConfigs.debug
3941
}
@@ -47,49 +49,46 @@ android {
4749
jvmTarget = JavaVersion.VERSION_1_8.toString()
4850
}
4951

50-
5152
buildFeatures {
5253
viewBinding true
5354
compose true
5455
}
55-
namespace 'app.rive.runtime.example'
5656
composeOptions {
57-
kotlinCompilerExtensionVersion '1.5.10'
57+
kotlinCompilerExtensionVersion "1.5.10"
5858
}
5959
packagingOptions {
6060
resources {
61-
excludes += '/META-INF/{AL2.0,LGPL2.1}'
61+
excludes += "/META-INF/{AL2.0,LGPL2.1}"
6262
}
6363
}
64-
ndkVersion '25.1.8937393'
6564
}
6665

6766
dependencies {
68-
implementation fileTree(dir: "libs", include: ["*.jar"])
69-
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
70-
implementation 'androidx.core:core-ktx:1.13.1'
71-
implementation 'androidx.appcompat:appcompat:1.7.0'
72-
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
73-
implementation 'androidx.fragment:fragment-ktx:1.8.3'
74-
implementation 'androidx.activity:activity:1.9.2'
75-
debugImplementation project(path: ':kotlin')
76-
releaseImplementation project(path: ':kotlin')
77-
previewImplementation 'app.rive:rive-android:+'
78-
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.6'
79-
implementation 'com.google.android.material:material:1.12.0'
80-
implementation 'androidx.activity:activity-compose:1.9.2'
81-
implementation "androidx.compose.ui:ui:$compose_version"
67+
implementation "androidx.activity:activity-compose:1.9.2"
68+
implementation "androidx.activity:activity:1.9.2"
69+
implementation "androidx.appcompat:appcompat:1.7.0"
70+
implementation "androidx.compose.material3:material3:1.3.0"
8271
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
83-
implementation 'androidx.compose.material3:material3:1.3.0'
84-
implementation 'androidx.startup:startup-runtime:1.2.0'
85-
implementation 'com.android.volley:volley:1.2.1'
72+
implementation "androidx.compose.ui:ui:$compose_version"
73+
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
74+
implementation "androidx.core:core-ktx:1.13.1"
75+
implementation "androidx.fragment:fragment-ktx:1.8.3"
76+
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.8.6"
77+
implementation "androidx.startup:startup-runtime:1.2.0"
78+
implementation "com.android.volley:volley:1.2.1"
79+
implementation "com.google.android.material:material:1.12.0"
80+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
81+
implementation fileTree(dir: "libs", include: ["*.jar"])
82+
debugImplementation project(path: ":kotlin")
83+
releaseImplementation project(path: ":kotlin")
84+
previewImplementation "app.rive:rive-android:+"
8685

87-
testImplementation 'junit:junit:4.13.2'
88-
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
89-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
90-
androidTestImplementation 'androidx.compose.ui:ui-test-junit4:1.7.2'
91-
androidTestImplementation project(path: ':kotlin')
92-
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
86+
testImplementation "junit:junit:4.13.2"
87+
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.7.2"
88+
androidTestImplementation "androidx.test.espresso:espresso-core:3.6.1"
89+
androidTestImplementation "androidx.test.ext:junit:1.2.1"
90+
androidTestImplementation project(path: ":kotlin")
9391
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
94-
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.14'
92+
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
93+
debugImplementation "com.squareup.leakcanary:leakcanary-android:2.14"
9594
}

Diff for: app/src/main/java/app/rive/runtime/example/ViewPagerActivity.kt

-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ import app.rive.runtime.kotlin.controllers.ControllerStateManagement
1717
class ViewPagerActivity : AppCompatActivity() {
1818
private lateinit var binding: ViewPagerBinding
1919

20-
companion object {
21-
const val TAG = "ViewPagerActivity"
22-
}
23-
2420
override fun onCreate(savedInstanceState: Bundle?) {
2521
super.onCreate(savedInstanceState)
2622

Diff for: build.gradle

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
apply plugin: "io.github.gradle-nexus.publish-plugin"
3-
apply plugin: 'com.palantir.git-version'
3+
apply plugin: "com.palantir.git-version"
44

55
def details = versionDetails()
66

77
ext {
8-
PUBLISH_GROUP_ID = 'app.rive'
8+
PUBLISH_GROUP_ID = "app.rive"
99
PUBLISH_VERSION = details.lastTag
10-
PUBLISH_ARTIFACT_ID = 'rive-android'
10+
PUBLISH_ARTIFACT_ID = "rive-android"
1111
}
1212
buildscript {
1313
ext {
14-
gradle_version = '8.6.1'
15-
kotlin_version = '1.9.22'
14+
gradle_version = "8.6.1"
15+
kotlin_version = "1.9.22"
1616
dokkaVersion = "1.4.30"
17-
compose_version = '1.6.7'
17+
compose_version = "1.6.7"
1818
}
1919

2020
repositories {
@@ -26,11 +26,11 @@ buildscript {
2626
}
2727

2828
dependencies {
29-
classpath "com.android.tools.build:gradle:$gradle_version"
30-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
29+
classpath("com.android.tools.build:gradle:$gradle_version")
30+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
3131
classpath("org.jetbrains.dokka:dokka-gradle-plugin:${dokkaVersion}")
3232
classpath("io.github.gradle-nexus:publish-plugin:1.3.0")
33-
classpath "com.palantir.gradle.gitversion:gradle-git-version:3.0.0"
33+
classpath("com.palantir.gradle.gitversion:gradle-git-version:3.0.0")
3434
// NOTE: Do not place your application dependencies here; they belong
3535
// in the individual module build.gradle files
3636
}
@@ -44,14 +44,14 @@ allprojects {
4444
}
4545
}
4646

47-
tasks.register('cleanDeps', Exec) {
48-
workingDir './kotlin/src/main/cpp'
49-
commandLine './clean_all.sh'
47+
tasks.register("cleanDeps", Exec) {
48+
workingDir("./kotlin/src/main/cpp")
49+
commandLine("./clean_all.sh")
5050
}
5151

52-
tasks.register('clean', Delete) {
52+
tasks.register("clean", Delete) {
5353
dependsOn(cleanDeps)
54-
delete rootProject.buildDir
54+
delete(rootProject.buildDir)
5555
}
5656

5757
apply from: "${rootDir}/scripts/publish-root.gradle"

Diff for: kotlin/build.gradle

+23-21
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
apply plugin: 'com.android.library'
2-
apply plugin: 'kotlin-android'
3-
apply plugin: 'org.jetbrains.dokka'
4-
1+
apply plugin: "com.android.library"
2+
apply plugin: "kotlin-android"
3+
apply plugin: "org.jetbrains.dokka"
54

65
android {
76
compileSdk 34
87
ndkVersion "25.1.8937393"
8+
namespace "app.rive.runtime.kotlin"
99

1010
defaultConfig {
1111
minSdkVersion 21
@@ -15,25 +15,28 @@ android {
1515
consumerProguardFiles "consumer-rules.pro"
1616
externalNativeBuild {
1717
cmake {
18-
abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
18+
abiFilters "arm64-v8a", "armeabi-v7a", "x86", "x86_64"
1919
arguments "-DCMAKE_VERBOSE_MAKEFILE=1", "-DANDROID_ALLOW_UNDEFINED_SYMBOLS=ON",
20-
'-DANDROID_CPP_FEATURES=no-exceptions no-rtti', "-DANDROID_STL=c++_shared"
20+
"-DANDROID_CPP_FEATURES=no-exceptions no-rtti", "-DANDROID_STL=c++_shared"
2121
}
2222
}
2323
}
2424

2525
kotlinOptions {
2626
jvmTarget = JavaVersion.VERSION_1_8.toString()
2727
}
28+
2829
externalNativeBuild {
2930
cmake {
30-
path file('src/main/cpp/CMakeLists.txt')
31-
version '3.22.1'
31+
path file("src/main/cpp/CMakeLists.txt")
32+
version "3.22.1"
3233
}
3334
}
35+
3436
testOptions {
3537
unitTests.includeAndroidResources = true
3638
}
39+
3740
dokkaGfm {
3841
dokkaSourceSets {
3942
named("main") {
@@ -43,27 +46,26 @@ android {
4346
}
4447
}
4548
}
46-
namespace 'app.rive.runtime.kotlin'
4749
}
50+
4851
configurations.configureEach {
4952
resolutionStrategy.force "junit:junit:4.13.2"
5053
}
5154

5255
dependencies {
53-
implementation 'com.android.volley:volley:1.2.1'
56+
implementation "com.android.volley:volley:1.2.1"
5457
implementation fileTree(dir: "libs", include: ["*.jar"])
5558
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
56-
implementation 'androidx.core:core-ktx:1.13.1'
57-
implementation 'androidx.appcompat:appcompat:1.7.0'
58-
implementation 'com.getkeepsafe.relinker:relinker:1.4.5'
59-
implementation 'androidx.startup:startup-runtime:1.2.0'
60-
61-
testImplementation 'junit:junit:4.13.2'
62-
testImplementation 'androidx.test:core-ktx:1.6.1'
59+
implementation "androidx.core:core-ktx:1.13.1"
60+
implementation "androidx.appcompat:appcompat:1.7.0"
61+
implementation "com.getkeepsafe.relinker:relinker:1.4.5"
62+
implementation "androidx.startup:startup-runtime:1.2.0"
6363

64+
testImplementation "junit:junit:4.13.2"
65+
testImplementation "androidx.test:core-ktx:1.6.1"
6466

65-
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
66-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
67+
androidTestImplementation "androidx.test.ext:junit:1.2.1"
68+
androidTestImplementation "androidx.test.espresso:espresso-core:3.6.1"
6769
}
6870

6971
// Commenting this out, this only really helps when you're doing local dev, but it means our git actions need abd!
@@ -72,8 +74,8 @@ dependencies {
7274
// }
7375

7476
// task buildJNI(type: Exec) {
75-
// workingDir '../cpp'
76-
// commandLine './build.rive.for.sh', '-a', getDeviceAbi()
77+
// workingDir "../cpp"
78+
// commandLine "./build.rive.for.sh", "-a", getDeviceAbi()
7779
// }
7880

7981
apply from: "${rootProject.projectDir}/scripts/publish-module.gradle"

Diff for: kotlin/src/androidTest/java/app/rive/runtime/kotlin/fonts/FontHelpersTest.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class FontHelpersTest {
4848
fun systemFontMatch() {
4949
val font = FontHelper.getFallbackFont()
5050
assertNotNull(font)
51-
assertEquals(font, Fonts.Font.DEFAULT)
51+
assertEquals(Fonts.Font.DEFAULT, font)
5252

5353
val notFound =
5454
FontHelper.getFallbackFont(
@@ -61,8 +61,8 @@ class FontHelpersTest {
6161
Fonts.FontOpts(familyName = "arial", style = "italic")
6262
)
6363
assertNotNull(withAlias)
64-
assertEquals(withAlias?.name, "Roboto-Italic.ttf")
65-
assertEquals(withAlias?.weight, Fonts.Weight.NORMAL)
64+
assertEquals("Roboto-Italic.ttf", withAlias?.name)
65+
assertEquals(Fonts.Weight.NORMAL, withAlias?.weight)
6666
}
6767

6868
@Test

Diff for: kotlin/src/main/cpp/CMakeLists.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ file(GLOB SOURCES CONFIGURE_DEPENDS
8484
src/bindings/*.cpp
8585
src/helpers/*.cpp
8686
src/models/*.cpp
87-
)
87+
)
8888

8989
add_library(rive-android SHARED ${SOURCES})
9090

@@ -96,14 +96,14 @@ set(static_libs
9696
rive_skia_renderer
9797
rive_pls_renderer
9898
skia
99-
)
99+
)
100100

101101
foreach (X IN LISTS static_libs)
102102
add_library(${X}-lib STATIC IMPORTED)
103103
set_target_properties(${X}-lib
104104
PROPERTIES IMPORTED_LOCATION
105105
${CMAKE_CURRENT_SOURCE_DIR}/build/${CONFIG}/${CMAKE_ANDROID_ARCH_ABI}/lib${X}.a
106-
)
106+
)
107107
endforeach ()
108108

109109
target_include_directories(rive-android PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
@@ -127,4 +127,4 @@ target_link_libraries(rive-android
127127
${egl-lib}
128128
${gles-lib}
129129
jnigraphics
130-
)
130+
)

Diff for: kotlin/src/main/cpp/build.rive.for.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then
3232
fi
3333

3434
if [ -z "$HOST_TAG" ]; then
35-
echo "Unkown host tag for OS: $OSTYPE"
35+
echo "Unknown host tag for OS: $OSTYPE"
3636
exit 1
3737
fi
3838

Diff for: kotlin/src/main/cpp/include/models/dimensions_helper.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef _RIVE_ANDROID_DIMENSIONS_RENDERER_HPP_
2-
#define _RIVE_ANDROID_DIMENSIONS_RENDERER_HPP_
1+
#ifndef _RIVE_ANDROID_DIMENSIONS_HELPER_HPP_
2+
#define _RIVE_ANDROID_DIMENSIONS_HELPER_HPP_
33

44
#include "rive/renderer.hpp"
55
#include <jni.h>

Diff for: kotlin/src/main/cpp/src/helpers/general.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ JNIEnv* GetJNIEnv()
3131
int getEnvStat = g_JVM->GetEnv((void**)&g_env, JNI_VERSION_1_6);
3232
if (getEnvStat == JNI_EDETACHED)
3333
{
34-
LOGW("JVM::GetEnv - Not Attached.");
34+
LOGW("GetJNIEnv - Not Attached.");
3535
if (g_JVM->AttachCurrentThread((JNIEnv**)&g_env, NULL) != 0)
3636
{
3737
LOGE("Failed to attach current thread.");
@@ -43,10 +43,11 @@ JNIEnv* GetJNIEnv()
4343
}
4444
else if (getEnvStat == JNI_EVERSION)
4545
{
46-
LOGE("JVM::GetEnv: unsupported version %d", getEnvStat);
46+
LOGE("GetJNIEnv: unsupported version %d", getEnvStat);
4747
}
4848
return g_env;
4949
}
50+
5051
void DetachThread()
5152
{
5253
if (g_JVM->DetachCurrentThread() != JNI_OK)

0 commit comments

Comments
 (0)