Skip to content

Commit

Permalink
Merge pull request #451 from android/mlykotom/compose-perf-main
Browse files Browse the repository at this point in the history
Code for Compose Performance Codelab
  • Loading branch information
mlykotom authored May 12, 2024
2 parents 0cb58eb + 79f0b81 commit 186a1de
Show file tree
Hide file tree
Showing 61 changed files with 39,751 additions and 0 deletions.
16 changes: 16 additions & 0 deletions PerformanceCodelab/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
*.iml
.gradle
local.properties
.idea/*
!.idea/copyright
# Keep the code styles.
!/.idea/codeStyles
/.idea/codeStyles/*
!/.idea/codeStyles/Project.xml
!/.idea/codeStyles/codeStyleConfig.xml

.DS_Store
/build
/captures
.externalNativeBuild
.cxx
26 changes: 26 additions & 0 deletions PerformanceCodelab/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Performance with Jetpack Compose Codelab

The folder contains the source code for the Performance with Jetpack Compose codelab.

## Formatting
To run spotless use the following command
```
./gradlew spotlessApply
```

## License
```
Copyright 2024 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
1 change: 1 addition & 0 deletions PerformanceCodelab/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
109 changes: 109 additions & 0 deletions PerformanceCodelab/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
plugins {
alias(libs.plugins.com.android.application)
alias(libs.plugins.org.jetbrains.kotlin.android)
alias(libs.plugins.androidx.baselineprofile)
alias(libs.plugins.compose)
}

android {
namespace = "com.compose.performance"
compileSdk = 34

defaultConfig {
applicationId = "com.compose.performance"
minSdk = 21
targetSdk = 34
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}

buildTypes {
release {
isMinifyEnabled = true
isProfileable = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
isCoreLibraryDesugaringEnabled = true
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
buildFeatures {
compose = true
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}

composeCompiler {
// This settings enables strong-skipping mode for all module in this project.
// As an effect, Compose can skip a composable even if it's unstable by comparing it's instance equality (===).
// TODO Codelab task: Enable Strong Skipping Mode
enableStrongSkippingMode = false

// TODO Codelab task: Enable Stability Configuration file
}

dependencies {
coreLibraryDesugaring(libs.desugar.jdk.libs)
implementation(libs.kotlinx.datetime)
implementation(libs.core.ktx)
implementation(libs.lifecycle.runtime.ktx)
implementation(libs.activity.compose)
implementation(platform(libs.compose.bom))
implementation(libs.ui)
implementation(libs.ui.graphics)
implementation(libs.ui.tooling.preview)
implementation(libs.material3)
implementation(libs.androidx.material.icons.core)
implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(libs.profileinstaller)
implementation(libs.androidx.tracing.ktx)

// TODO Codelab task: Add androidx.runtime-tracing dependency to enable Composition Tracing

implementation(libs.coil.compose)
implementation(libs.androidx.media3.exoplayer)
implementation(libs.androidx.media3.ui)

baselineProfile(project(":measure"))

testImplementation(libs.junit)
androidTestImplementation(libs.androidx.test.ext.junit)
androidTestImplementation(libs.espresso.core)
androidTestImplementation(platform(libs.compose.bom))
androidTestImplementation(libs.ui.test.junit4)

debugImplementation(libs.ui.tooling)
debugImplementation(libs.ui.test.manifest)
}
28 changes: 28 additions & 0 deletions PerformanceCodelab/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

# Please add these rules to your existing keep rules in order to suppress warnings.
# This is generated automatically by the Android Gradle plugin.
-dontwarn kotlinx.serialization.KSerializer
-dontwarn kotlinx.serialization.Serializable

-dontobfuscate
27 changes: 27 additions & 0 deletions PerformanceCodelab/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.ComposePerformance"
tools:targetApi="31">
<activity
android:name="com.compose.performance.MainActivity"
android:exported="true"
android:theme="@style/Theme.ComposePerformance">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Loading

0 comments on commit 186a1de

Please sign in to comment.