Skip to content

Commit 186a1de

Browse files
authored
Merge pull request #451 from android/mlykotom/compose-perf-main
Code for Compose Performance Codelab
2 parents 0cb58eb + 79f0b81 commit 186a1de

Some content is hidden

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

61 files changed

+39751
-0
lines changed

PerformanceCodelab/.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
*.iml
2+
.gradle
3+
local.properties
4+
.idea/*
5+
!.idea/copyright
6+
# Keep the code styles.
7+
!/.idea/codeStyles
8+
/.idea/codeStyles/*
9+
!/.idea/codeStyles/Project.xml
10+
!/.idea/codeStyles/codeStyleConfig.xml
11+
12+
.DS_Store
13+
/build
14+
/captures
15+
.externalNativeBuild
16+
.cxx

PerformanceCodelab/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Performance with Jetpack Compose Codelab
2+
3+
The folder contains the source code for the Performance with Jetpack Compose codelab.
4+
5+
## Formatting
6+
To run spotless use the following command
7+
```
8+
./gradlew spotlessApply
9+
```
10+
11+
## License
12+
```
13+
Copyright 2024 The Android Open Source Project
14+
15+
Licensed under the Apache License, Version 2.0 (the "License");
16+
you may not use this file except in compliance with the License.
17+
You may obtain a copy of the License at
18+
19+
https://www.apache.org/licenses/LICENSE-2.0
20+
21+
Unless required by applicable law or agreed to in writing, software
22+
distributed under the License is distributed on an "AS IS" BASIS,
23+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24+
See the License for the specific language governing permissions and
25+
limitations under the License.
26+
```

PerformanceCodelab/app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
* Copyright 2024 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
plugins {
17+
alias(libs.plugins.com.android.application)
18+
alias(libs.plugins.org.jetbrains.kotlin.android)
19+
alias(libs.plugins.androidx.baselineprofile)
20+
alias(libs.plugins.compose)
21+
}
22+
23+
android {
24+
namespace = "com.compose.performance"
25+
compileSdk = 34
26+
27+
defaultConfig {
28+
applicationId = "com.compose.performance"
29+
minSdk = 21
30+
targetSdk = 34
31+
versionCode = 1
32+
versionName = "1.0"
33+
34+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
35+
vectorDrawables {
36+
useSupportLibrary = true
37+
}
38+
}
39+
40+
buildTypes {
41+
release {
42+
isMinifyEnabled = true
43+
isProfileable = true
44+
isShrinkResources = true
45+
proguardFiles(
46+
getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
47+
)
48+
}
49+
}
50+
compileOptions {
51+
sourceCompatibility = JavaVersion.VERSION_17
52+
targetCompatibility = JavaVersion.VERSION_17
53+
isCoreLibraryDesugaringEnabled = true
54+
}
55+
kotlinOptions {
56+
jvmTarget = JavaVersion.VERSION_17.toString()
57+
}
58+
buildFeatures {
59+
compose = true
60+
}
61+
packaging {
62+
resources {
63+
excludes += "/META-INF/{AL2.0,LGPL2.1}"
64+
}
65+
}
66+
}
67+
68+
composeCompiler {
69+
// This settings enables strong-skipping mode for all module in this project.
70+
// As an effect, Compose can skip a composable even if it's unstable by comparing it's instance equality (===).
71+
// TODO Codelab task: Enable Strong Skipping Mode
72+
enableStrongSkippingMode = false
73+
74+
// TODO Codelab task: Enable Stability Configuration file
75+
}
76+
77+
dependencies {
78+
coreLibraryDesugaring(libs.desugar.jdk.libs)
79+
implementation(libs.kotlinx.datetime)
80+
implementation(libs.core.ktx)
81+
implementation(libs.lifecycle.runtime.ktx)
82+
implementation(libs.activity.compose)
83+
implementation(platform(libs.compose.bom))
84+
implementation(libs.ui)
85+
implementation(libs.ui.graphics)
86+
implementation(libs.ui.tooling.preview)
87+
implementation(libs.material3)
88+
implementation(libs.androidx.material.icons.core)
89+
implementation(libs.androidx.lifecycle.viewmodel.compose)
90+
implementation(libs.profileinstaller)
91+
implementation(libs.androidx.tracing.ktx)
92+
93+
// TODO Codelab task: Add androidx.runtime-tracing dependency to enable Composition Tracing
94+
95+
implementation(libs.coil.compose)
96+
implementation(libs.androidx.media3.exoplayer)
97+
implementation(libs.androidx.media3.ui)
98+
99+
baselineProfile(project(":measure"))
100+
101+
testImplementation(libs.junit)
102+
androidTestImplementation(libs.androidx.test.ext.junit)
103+
androidTestImplementation(libs.espresso.core)
104+
androidTestImplementation(platform(libs.compose.bom))
105+
androidTestImplementation(libs.ui.test.junit4)
106+
107+
debugImplementation(libs.ui.tooling)
108+
debugImplementation(libs.ui.test.manifest)
109+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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
22+
23+
# Please add these rules to your existing keep rules in order to suppress warnings.
24+
# This is generated automatically by the Android Gradle plugin.
25+
-dontwarn kotlinx.serialization.KSerializer
26+
-dontwarn kotlinx.serialization.Serializable
27+
28+
-dontobfuscate
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<uses-permission android:name="android.permission.INTERNET" />
6+
7+
<application
8+
android:allowBackup="true"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:supportsRtl="true"
13+
android:theme="@style/Theme.ComposePerformance"
14+
tools:targetApi="31">
15+
<activity
16+
android:name="com.compose.performance.MainActivity"
17+
android:exported="true"
18+
android:theme="@style/Theme.ComposePerformance">
19+
<intent-filter>
20+
<action android:name="android.intent.action.MAIN" />
21+
22+
<category android:name="android.intent.category.LAUNCHER" />
23+
</intent-filter>
24+
</activity>
25+
</application>
26+
27+
</manifest>

0 commit comments

Comments
 (0)