Skip to content

Commit d15c1f8

Browse files
authored
Add support for CustomPreviewAnnotations in Showkase 🚿 🌈 (#303)
* Add processing functions in showkase processor to write to internal custom annotation and return components annotated by the annotation * Add support for crossmodule custom annotation Retrieving metadata from classpath * Add test for processing test for KSP * Add comment about autogenetated file for the showkaseCustomAnnotationMetadata file gen * Add supported custom annotation types to supported types * Add ShowkaseBrowser tests and processor test for CustomPreviewAnnotation cases * Add paparazzi test for custom preview annotation * Add processor test for Custom preview annotation with injected preview parameter * Fix detekt issue * Regenerate paparazzi pictures * Fix detekt issue * update ksp flag on running kapt ui test we are checking if the flag is present, not that it is true * Update paparazzi screenshots * Add scroll actions so ensure we are verifying the components With the custom annotation feature we are having a bit to many components for the test emulator. We need to scroll town the page in the test to ensure that the components that we are verifying are visible * Address review comments * Remove compiler args for custom previews This was done because we figured out that the metadata generation strategy works and this will give a better result to the enduser. * Address review comments * Remove redundant annotation check * Add Seccond sample submodule * Add showkase browser test submodule and multimodular tests * Regenerate screenshots to screenshot tests for new submodule * Add case for multi modular processing and make it work for KAPT * Update compiler args to be seperate args * Add missing compiler arg in test * Regenerate screenshot tests
1 parent d26dca3 commit d15c1f8

File tree

126 files changed

+1673
-40
lines changed

Some content is hidden

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

126 files changed

+1673
-40
lines changed

.github/workflows/android.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
api-level: ${{ matrix.api-level }}
9393
target: ${{ matrix.target }}
9494
arch: x86_64
95-
script: ./gradlew connectedCheck --no-daemon --stacktrace -PuseKsp=false --debug
95+
script: ./gradlew connectedCheck --no-daemon --stacktrace --debug
9696

9797
- name: Run UI Tests w/ KSP
9898
uses: reactivecircus/android-emulator-runner@v2

sample-submodule-2/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

sample-submodule-2/build.gradle

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
plugins {
2+
id 'com.android.library'
3+
id 'kotlin-android'
4+
}
5+
6+
if (project.hasProperty('useKsp')) {
7+
apply plugin: 'com.google.devtools.ksp'
8+
} else {
9+
apply plugin: 'kotlin-kapt'
10+
kapt {
11+
correctErrorTypes = true
12+
arguments {
13+
arg("multiPreviewType", "com.airbnb.android.submodule.showkasesample.FontPreview")
14+
}
15+
}
16+
}
17+
18+
android {
19+
compileSdkVersion 32
20+
21+
defaultConfig {
22+
minSdkVersion 21
23+
targetSdkVersion 32
24+
25+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
26+
}
27+
28+
buildTypes {
29+
release {
30+
minifyEnabled false
31+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
32+
}
33+
}
34+
compileOptions {
35+
sourceCompatibility JavaVersion.VERSION_11
36+
targetCompatibility JavaVersion.VERSION_11
37+
}
38+
kotlinOptions {
39+
jvmTarget = '11'
40+
}
41+
buildFeatures {
42+
compose true
43+
}
44+
composeOptions {
45+
kotlinCompilerVersion "${versions.kotlinCompilerVersion}"
46+
kotlinCompilerExtensionVersion "${versions.composeCompiler}"
47+
48+
}
49+
// Added to avoid this error -
50+
// Execution failed for task ':app:mergeDebugAndroidTestJavaResource'.
51+
// > A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
52+
// > 2 files found with path 'META-INF/AL2.0' from inputs:
53+
packagingOptions {
54+
exclude 'META-INF/AL2.0'
55+
exclude 'META-INF/LGPL2.1'
56+
}
57+
}
58+
59+
dependencies {
60+
// Support Libraries
61+
implementation deps.support.appCompat
62+
implementation deps.support.ktx
63+
implementation deps.support.lifecycleExtensions
64+
65+
// Showkase
66+
implementation project(':showkase')
67+
implementation project(':sample-submodule')
68+
69+
if (project.hasProperty('useKsp')) {
70+
ksp project(':showkase-processor')
71+
} else {
72+
kapt project(':showkase-processor')
73+
}
74+
75+
// Compose
76+
implementation deps.compose.activityCompose
77+
implementation deps.compose.composeRuntime
78+
implementation deps.compose.constraintLayout
79+
implementation deps.compose.core
80+
implementation deps.compose.foundation
81+
implementation deps.compose.tooling
82+
implementation deps.compose.layout
83+
implementation deps.compose.material
84+
implementation deps.compose.savedInstanceState
85+
implementation deps.compose.uiLiveData
86+
androidTestImplementation deps.compose.uiTest
87+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest package="com.airbnb.android.second.submodule">
3+
4+
</manifest>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.airbnb.android.submodule.showkasesample
2+
3+
import androidx.compose.material.Text
4+
import androidx.compose.runtime.Composable
5+
6+
@FontPreview
7+
@Composable
8+
fun TextPreview() {
9+
Text(
10+
text = "Some Font Preview"
11+
)
12+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<resources>
2+
<string name="name">Sample Second Submodule</string>
3+
</resources>

sample-submodule/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ if (project.hasProperty('useKsp')) {
99
apply plugin: 'kotlin-kapt'
1010
kapt {
1111
correctErrorTypes = true
12+
arguments {
13+
arg("multiPreviewType","com.airbnb.android.submodule.showkasesample.LocalePreview")
14+
arg("multiPreviewType", "com.airbnb.android.submodule.showkasesample.FontPreview")
15+
}
1216
}
1317
}
1418

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.airbnb.android.submodule.showkasesample
2+
3+
import androidx.compose.ui.tooling.preview.Preview
4+
5+
@Preview(name = "Normal font size", group = "FontPreview", fontScale = 1f)
6+
annotation class FontPreview
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.airbnb.android.submodule.showkasesample
2+
3+
import androidx.compose.ui.tooling.preview.Preview
4+
5+
@Preview(name = "Norwegian", group = "LocalePreview", locale = "nb")
6+
annotation class LocalePreview

0 commit comments

Comments
 (0)