Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Baseline profile, Compose migration to alpha9, benchamrking etc #101

Merged
merged 1 commit into from
Sep 18, 2023
Merged
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
2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.kapt)
alias(libs.plugins.hilt)
alias(libs.plugins.androidx.baselineprofile)
}

android {
Expand All @@ -25,6 +26,12 @@ android {
"proguard-rules.pro",
)
}
create("benchmark") {
initWith(buildTypes.getByName("release"))
signingConfig = signingConfigs.getByName("debug")
matchingFallbacks += listOf("release")
isDebuggable = false
}
}

buildFeatures {
Expand All @@ -39,8 +46,13 @@ android {
correctErrorTypes = true
}

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

kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
jvmTarget = JavaVersion.VERSION_17.toString()
}
}

Expand All @@ -57,6 +69,8 @@ dependencies {
implementation(libs.bundles.compose.accompanist)

implementation(libs.hilt.android)
implementation(libs.profileinstaller)
"baselineProfile"(project(":baselineprofile"))
kapt(libs.hilt.compiler)
implementation(libs.androidx.hilt.navigation.compose)

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.ComposeTV">

<profileable android:shell="true"/>

<activity
android:name=".MainActivity"
android:banner="@drawable/ic_app"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.activity.ComponentActivity
import androidx.activity.addCallback
import androidx.core.os.BuildCompat

@androidx.annotation.OptIn(BuildCompat.PrereleaseSdkCheck::class)
fun ComponentActivity.registerOnBackPress(onBackPress: () -> Unit) {
if (BuildCompat.isAtLeastT()) {
onBackInvokedDispatcher.registerOnBackInvokedCallback(
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/java/com/techlads/composetv/MainApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import timber.log.Timber
class MainApp : Application() {
override fun onCreate() {
super.onCreate()
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
}
Timber.plant(Timber.DebugTree())
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:OptIn(ExperimentalTvMaterial3Api::class, ExperimentalTvMaterial3Api::class)

package com.techlads.composetv.features.favorites

import androidx.compose.foundation.layout.PaddingValues
Expand All @@ -10,6 +12,7 @@ import androidx.compose.ui.unit.dp
import androidx.tv.foundation.lazy.grid.TvGridCells
import androidx.tv.foundation.lazy.grid.TvGridItemSpan
import androidx.tv.foundation.lazy.grid.TvLazyVerticalGrid
import androidx.tv.material3.ExperimentalTvMaterial3Api
import androidx.tv.material3.Text
import com.techlads.composetv.features.home.carousel.VerticalCarouselItem

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.techlads.composetv.features.home
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import com.techlads.composetv.features.home.carousel.HomeCarousel
import com.techlads.composetv.features.home.hero.HeroItem
Expand All @@ -12,8 +14,18 @@ fun HomeNestedScreen(
onItemFocus: (parent: Int, child: Int) -> Unit,
onItemClick: (parent: Int, child: Int) -> Unit,
) {

val focusState = remember {
mutableStateOf(FocusPosition(0, 0))
}

Column(Modifier.fillMaxSize()) {
HeroItem()
HomeCarousel(Modifier.weight(1f), onItemFocus = onItemFocus, onItemClick = onItemClick)
HomeCarousel(Modifier.weight(1f), onItemFocus = { parent, child ->
focusState.value = FocusPosition(parent, child)
onItemFocus(parent, child)
}, onItemClick = onItemClick)
}
}

typealias FocusPosition = Pair<Int, Int>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.techlads.composetv.features.home

import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.layout.Row
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -31,12 +30,10 @@ fun HomeScreenContent(
}
}

Row {
HomeDrawer(content = {
NestedHomeNavigation(navController, onItemFocus, onSongClick)
}, selectedId = selectedId.value) {
navController.navigate(it.id)
}
HomeDrawer(content = {
NestedHomeNavigation(navController, onItemFocus, onSongClick)
}, selectedId = selectedId.value) {
navController.navigate(it.id)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.techlads.composetv.widgets.BorderedFocusableItem

@Composable
fun CarouselItem(
modifier: Modifier = Modifier,
parent: Int,
child: Int,
onItemFocus: (parent: Int, child: Int) -> Unit,
Expand All @@ -27,7 +28,7 @@ fun CarouselItem(
BorderedFocusableItem(
onClick = { onItemClick(parent, child) },
borderRadius = 12.dp,
modifier = Modifier
modifier = modifier
.padding(horizontal = 8.dp)
.aspectRatio(1.8f)
.onFocusChanged {
Expand Down Expand Up @@ -61,7 +62,7 @@ fun VerticalCarouselItem(parent: Int, child: Int, onItemFocus: (parent: Int, chi
@Preview
@Composable
fun CarouselItemPrev() {
CarouselItem(1, 1, onItemClick = { _, _ -> }, onItemFocus = { _, _ -> })
CarouselItem(Modifier,1, 1, onItemClick = { _, _ -> }, onItemFocus = { _, _ -> })
}

@Preview
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.techlads.composetv.features.home.carousel

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
Expand All @@ -23,5 +24,7 @@ fun HomeCarousel(
@Preview
@Composable
fun HomeCarouselPrev() {
HomeCarousel(Modifier, onItemFocus = { _, _ -> }, onItemClick = { _, _ -> })
}
Column {
HomeCarousel(Modifier, onItemFocus = { _, _ -> }) { _, _ -> }
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:OptIn(ExperimentalTvMaterial3Api::class)

package com.techlads.composetv.features.home.carousel

import androidx.compose.foundation.layout.Column
Expand All @@ -9,6 +11,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.tv.foundation.lazy.list.TvLazyRow
import androidx.tv.material3.ExperimentalTvMaterial3Api
import androidx.tv.material3.Text

@Composable
Expand All @@ -29,6 +32,7 @@ fun HorizontalCarouselItem(
) {
items(15) { child ->
CarouselItem(
Modifier,
parent,
child,
onItemClick = onItemClick,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:OptIn(ExperimentalTvMaterial3Api::class)

package com.techlads.composetv.features.home.leftmenu

import androidx.compose.animation.core.animateFloatAsState
Expand All @@ -14,6 +16,7 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.tv.material3.ExperimentalTvMaterial3Api
import androidx.tv.material3.LocalContentColor
import androidx.tv.material3.Text
import com.techlads.composetv.theme.ComposeTvTheme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ val navigationRow: @Composable (

Surface(
onClick = { onMenuSelected?.invoke(menu) },
color = ClickableSurfaceDefaults.color(
color = if (isSelected) MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.5f) else MaterialTheme.colorScheme.surface,
colors = ClickableSurfaceDefaults.colors(
containerColor = if (isSelected) MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.5f) else MaterialTheme.colorScheme.surface,
),
modifier = modifier
.padding(vertical = 4.dp)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
@file:OptIn(ExperimentalTvMaterial3Api::class)

package com.techlads.composetv.features.login.withEmailPassword

import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import androidx.tv.material3.ExperimentalTvMaterial3Api
import androidx.tv.material3.Text

@Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:OptIn(ExperimentalTvMaterial3Api::class)

package com.techlads.composetv.features.movies

import androidx.compose.foundation.layout.PaddingValues
Expand All @@ -10,6 +12,7 @@ import androidx.compose.ui.unit.dp
import androidx.tv.foundation.lazy.grid.TvGridCells
import androidx.tv.foundation.lazy.grid.TvGridItemSpan
import androidx.tv.foundation.lazy.grid.TvLazyVerticalGrid
import androidx.tv.material3.ExperimentalTvMaterial3Api
import androidx.tv.material3.Text
import com.techlads.composetv.features.home.carousel.VerticalCarouselItem

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:OptIn(ExperimentalTvMaterial3Api::class)

package com.techlads.composetv.features.mp3.player

import androidx.compose.foundation.Image
Expand Down Expand Up @@ -48,7 +50,6 @@ fun AudioPlayerScreenContent(modifier: Modifier){
}
}

@OptIn(ExperimentalTvMaterial3Api::class)
@Composable
fun Mp3Controls() {
Row {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ fun VideoPlayerControlsIcon(
modifier = modifier.size(40.dp),
onClick = onClick,
shape = ClickableSurfaceDefaults.shape(shape = CircleShape),
color = ClickableSurfaceDefaults.color(
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.2f),
colors = ClickableSurfaceDefaults.colors(
containerColor = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.2f),
),
scale = ClickableSurfaceDefaults.scale(focusedScale = 1.05f),
interactionSource = interactionSource,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:OptIn(ExperimentalTvMaterial3Api::class)

package com.techlads.composetv.features.search

import androidx.compose.foundation.background
Expand All @@ -18,6 +20,7 @@ import androidx.compose.ui.unit.dp
import androidx.tv.foundation.lazy.grid.TvGridCells
import androidx.tv.foundation.lazy.grid.TvGridItemSpan
import androidx.tv.foundation.lazy.grid.TvLazyVerticalGrid
import androidx.tv.material3.ExperimentalTvMaterial3Api
import androidx.tv.material3.Text
import com.techlads.composetv.features.home.carousel.VerticalCarouselItem
import com.techlads.composetv.features.keyboard.MiniKeyboard
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:OptIn(ExperimentalTvMaterial3Api::class)

package com.techlads.composetv.features.settings.screens

import androidx.compose.foundation.background
Expand All @@ -14,6 +16,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.tv.material3.ExperimentalTvMaterial3Api
import androidx.tv.material3.LocalContentColor
import androidx.tv.material3.MaterialTheme
import androidx.tv.material3.Text
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
@file:OptIn(ExperimentalTvMaterial3Api::class)

package com.techlads.composetv.features.settings.screens.about

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.tv.material3.ExperimentalTvMaterial3Api
import androidx.tv.material3.LocalContentColor
import androidx.tv.material3.MaterialTheme
import androidx.tv.material3.Text
Expand Down
Loading