Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ android {
minifyEnabled false
buildConfigField "String", "BASE_URL", "\"https://cataas.com/api/\""
}
benchmark {
initWith buildTypes.release
signingConfig signingConfigs.debug
matchingFallbacks = ['release']
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'benchmark-rules.pro'
}
}
compileOptions.coreLibraryDesugaringEnabled = true

Expand Down Expand Up @@ -151,6 +157,7 @@ dependencies {

implementation "androidx.palette:palette-ktx:1.0.0"

implementation "androidx.profileinstaller:profileinstaller:1.2.0"

debugImplementation "com.github.YarikSOffice.Venom:venom:0.5.0"
releaseImplementation "com.github.YarikSOffice.Venom:venom-no-op:0.5.0"
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/full_backup_content"
tools:targetApi="32">
<profileable
android:shell="true"
tools:targetApi="q" />

<activity
android:name="com.skyyo.samples.application.activity.MainActivity"
android:exported="true"
Expand All @@ -44,6 +48,11 @@
<intent-filter>
<action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE" />
</intent-filter>
<intent-filter>
<action android:name="com.skyyo.samples.OPEN_FEATURE"/>

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

<meta-data
android:name="health_permissions"
Expand Down
8,673 changes: 8,673 additions & 0 deletions app/src/main/baseline-prof.txt

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions app/src/main/java/com/skyyo/samples/application/Application.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package com.skyyo.samples.application

import android.app.Application
import com.github.venom.Venom
// import com.github.venom.Venom
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class Application : Application() {

override fun onCreate() {
super.onCreate()
Venom.createInstance(this).apply {
initialize()
start()
}
}
// override fun onCreate() {
// super.onCreate()
// Venom.createInstance(this).apply {
// initialize()
// start()
// }
// }
}
4 changes: 4 additions & 0 deletions app/src/main/java/com/skyyo/samples/application/Constants.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
package com.skyyo.samples.application

const val PACKAGE_NAME = "com.skyyo.samples"
const val CODE_200 = 200
const val STATE_FLOW_SUB_TIME = 5000L

const val INTENT_ACTION_OPEN_FEATURE = "$PACKAGE_NAME.OPEN_FEATURE"
const val INTENT_EXTRA_FEATURE_ROUTE = "$PACKAGE_NAME.FEATURE_ROUTE"
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.skyyo.samples.application.activity

import android.content.Intent
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
Expand All @@ -20,7 +21,9 @@ import com.google.accompanist.navigation.animation.rememberAnimatedNavController
import com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApi
import com.google.accompanist.navigation.material.ModalBottomSheetLayout
import com.google.accompanist.navigation.material.rememberBottomSheetNavigator
import com.skyyo.samples.application.INTENT_ACTION_OPEN_FEATURE
import com.skyyo.samples.application.Destination
import com.skyyo.samples.application.INTENT_EXTRA_FEATURE_ROUTE
import com.skyyo.samples.application.persistance.DataStoreManager
import com.skyyo.samples.theme.IgdbBrowserTheme
import com.skyyo.samples.utils.NavigationDispatcher
Expand Down Expand Up @@ -81,7 +84,7 @@ class MainActivity : AppCompatActivity() {
ModalBottomSheetLayout(bottomSheetNavigator) {
Surface(modifier = Modifier.fillMaxSize()) {
PopulatedNavHost(
startDestination = Destination.SampleContainer.route,
startDestination = provideStartDestination(intent),
navController = navController
)
}
Expand All @@ -90,6 +93,13 @@ class MainActivity : AppCompatActivity() {
}
}

private fun provideStartDestination(intent: Intent): String = when (intent.action) {
INTENT_ACTION_OPEN_FEATURE -> {
intent.extras?.getString(INTENT_EXTRA_FEATURE_ROUTE) ?: Destination.SampleContainer.route
}
else -> Destination.SampleContainer.route
}

private fun applyEdgeToEdge() {
WindowCompat.setDecorFitsSystemWindows(window, false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.compose.ui.unit.dp
import kotlinx.coroutines.launch

Expand All @@ -22,6 +26,7 @@ private const val BOTTOM_SHEET_HEIGHT_FRACTION = .96f
* can be used both as modal & persistent sheet,
* just not fit for destinations
*/
@OptIn(ExperimentalComposeUiApi::class)
@ExperimentalMaterialApi
@Composable
fun BottomSheetScaffoldScreen() {
Expand All @@ -36,6 +41,7 @@ fun BottomSheetScaffoldScreen() {
val currentValue = scaffoldState.bottomSheetState.currentValue

BottomSheetScaffold(
modifier = Modifier.semantics { testTagsAsResourceId = true },
scaffoldState = scaffoldState,
sheetShape = remember(cornerRadius) {
RoundedCornerShape(
Expand All @@ -54,7 +60,7 @@ fun BottomSheetScaffoldScreen() {
horizontalAlignment = Alignment.CenterHorizontally
) {
Button(
modifier = Modifier.fillMaxWidth(),
modifier = Modifier.fillMaxWidth().testTag("switchButton"),
onClick = {
coroutineScope.launch {
if (scaffoldState.bottomSheetState.isCollapsed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ import androidx.compose.foundation.layout.*
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.lerp
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.compose.ui.unit.dp
import com.google.accompanist.pager.ExperimentalPagerApi
import com.google.accompanist.pager.HorizontalPager
Expand All @@ -23,6 +27,7 @@ import kotlin.math.absoluteValue
private const val INFINITE_PAGER_MAX_PAGE_COUNT = 100000
const val INFINITE_PAGER_INITIAL_PAGE = INFINITE_PAGER_MAX_PAGE_COUNT / 2

@OptIn(ExperimentalComposeUiApi::class)
@ExperimentalPagerApi
@Composable
fun InfiniteViewPagerScreen() {
Expand Down Expand Up @@ -51,10 +56,15 @@ fun InfiniteViewPagerScreen() {
}
}

Column(modifier = Modifier.fillMaxSize().statusBarsPadding()) {
Column(
modifier = Modifier
.fillMaxSize()
.statusBarsPadding()
.semantics { testTagsAsResourceId = true }
) {
HorizontalPager(
state = pagerState,
modifier = Modifier.fillMaxWidth().padding(bottom = 16.dp)
modifier = Modifier.fillMaxWidth().padding(16.dp).testTag("horizontalPager")
) { page ->
key(page) {
val currentPage = (page - INFINITE_PAGER_INITIAL_PAGE).floorMod(pages.size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.CarRepair
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.lerp
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.lerp
Expand All @@ -28,6 +32,7 @@ import kotlinx.coroutines.launch
import kotlin.math.absoluteValue
import kotlin.math.max

@OptIn(ExperimentalComposeUiApi::class)
@Suppress("LongMethod")
@ExperimentalPagerApi
@Composable
Expand Down Expand Up @@ -63,6 +68,7 @@ fun ViewPagerScreen() {
Modifier
.fillMaxSize()
.statusBarsPadding()
.semantics { testTagsAsResourceId = true }
) {
ScrollableTabRow(
selectedTabIndex = pagerState.currentPage,
Expand Down Expand Up @@ -100,7 +106,10 @@ fun ViewPagerScreen() {
}
)
Spacer(modifier = Modifier.height(16.dp))
HorizontalPager(state = pagerState, modifier = Modifier.fillMaxWidth()) { page ->
HorizontalPager(
state = pagerState,
modifier = Modifier.fillMaxWidth().testTag("horizontalPager")
) { page ->
key(page) {
PagerCard(
pageOffset = this@HorizontalPager.calculateCurrentOffsetForPage(page).absoluteValue,
Expand Down Expand Up @@ -150,7 +159,10 @@ fun ViewPagerScreen() {
}

@ExperimentalPagerApi
fun Modifier.scrollableTabIndicatorOffset(pagerState: PagerState, tabPositions: List<TabPosition>): Modifier = composed {
fun Modifier.scrollableTabIndicatorOffset(
pagerState: PagerState,
tabPositions: List<TabPosition>
): Modifier = composed {
// If there are no pages, nothing to show
if (pagerState.pageCount == 0) return@composed this

Expand Down
1 change: 1 addition & 0 deletions benchmark/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
53 changes: 53 additions & 0 deletions benchmark/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
plugins {
id 'com.android.test'
id 'org.jetbrains.kotlin.android'
}

android {
compileSdk 33
namespace "com.skyyo.samplesBenchmark"

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = "1.8"
}

defaultConfig {
minSdk 23
targetSdk 32

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
// This benchmark buildType is used for benchmarking, and should function like your
// release build (for example, with minification on). It's signed with a debug key
// for easy local/CI testing.
benchmark {
debuggable = true
signingConfig = debug.signingConfig
matchingFallbacks = ["release"]
}
}

targetProjectPath = ":app"
experimentalProperties["android.experimental.self-instrumenting"] = true
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.7.10"
implementation 'androidx.test.ext:junit:1.1.3'
implementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'androidx.test.uiautomator:uiautomator:2.2.0'
implementation 'androidx.benchmark:benchmark-macro-junit4:1.2.0-alpha02'
}

androidComponents {
beforeVariants(selector().all()) {
enabled = buildType == "benchmark"
}
}
8 changes: 8 additions & 0 deletions benchmark/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.skyyo.samplesBenchmark">

<queries>
<package android:name="com.example.application" />
</queries>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.skyyo.samplesBenchmark

import androidx.benchmark.macro.ExperimentalBaselineProfilesApi
import androidx.benchmark.macro.junit4.BaselineProfileRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@OptIn(ExperimentalBaselineProfilesApi::class)
@RunWith(AndroidJUnit4::class)
class BaselineProfileGenerator {

@get:Rule
val baselineProfileRule = BaselineProfileRule()

@Test
fun startup() = baselineProfileRule.collectBaselineProfile(packageName = TARGET_PACKAGE) {
pressHome()
startActivityAndWait()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.skyyo.samplesBenchmark

const val TARGET_PACKAGE = "com.skyyo.samples"
const val ACTION_OPEN_FEATURE = "$TARGET_PACKAGE.OPEN_FEATURE"
const val EXTRA_FEATURE_ROUTE = "$TARGET_PACKAGE.FEATURE_ROUTE"
Loading