Skip to content

Commit

Permalink
Merge branch 'main' into ashnohe_update
Browse files Browse the repository at this point in the history
  • Loading branch information
ashnohe authored Dec 11, 2024
2 parents c631a39 + 73625a4 commit 2b98049
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ dependencies {
implementation(libs.splashscreen)
implementation(libs.concurrent.kts)

implementation(libs.core.performance)
implementation(libs.core.performance.play.services)

implementation(libs.camera.core)
implementation(libs.camera2)
implementation(libs.camera.lifecycle)
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />

<!--
minSdk for this project is 21, but the PlayServicesDevicePerformance from the
core-performance-play-services dependency requires minSdk 24. We fall back to using
DefaultDevicePerformance from the core-performance dependency (minSdk 19) if the SDK level
is <24.
-->
<uses-sdk tools:overrideLibrary="androidx.core.performance.play.services" />

<application
android:name=".SocialApp"
android:allowBackup="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,15 @@ fun Settings(
}
}
}
item {
Box(modifier = Modifier.padding(32.dp)) {
Text(
text = stringResource(
R.string.performance_class_level,
viewModel.mediaPerformanceClass,
),
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.google.android.samples.socialite.ui.home

import android.content.Context
import android.widget.Toast
import androidx.core.performance.DevicePerformance
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.google.android.samples.socialite.data.DatabaseManager
Expand All @@ -34,7 +35,9 @@ class SettingsViewModel @Inject constructor(
@ApplicationContext private val application: Context,
private val repository: ChatRepository,
private val databaseManager: DatabaseManager,
devicePerformance: DevicePerformance,
) : ViewModel() {
val mediaPerformanceClass = devicePerformance.mediaPerformanceClass

fun clearMessages() {
viewModelScope.launch {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (C) 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
*
* http://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.
*/

package com.google.android.samples.socialite.ui.home.di

import android.content.Context
import android.os.Build
import androidx.core.performance.DefaultDevicePerformance
import androidx.core.performance.DevicePerformance
import androidx.core.performance.play.services.PlayServicesDevicePerformance
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object DevicePerformanceBindingModule {
@Provides
@Singleton
fun provideDevicePerformance(@ApplicationContext context: Context): DevicePerformance {
return when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.N -> PlayServicesDevicePerformance(context)
else -> DefaultDevicePerformance()
}
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<!-- Settings -->
<eat-comment />
<string name="clear_message_history">Clear message history</string>
<string name="performance_class_level">This device is Media Performance Class level %1$d</string>

<!-- Video Edit Screen -->
<string name="remove_audio">Remove audio</string>
Expand Down
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ composeCompiler = "1.5.4" # Used in app/build.gradle.kts
compose-foundation = "1.6.0-beta03"
concurrent = "1.2.0"
core = "1.15.0"
core-performance = "1.0.0"
core-splashscreen = "1.0.1"
espresso = "3.6.1"
graphics = "1.0.1"
Expand Down Expand Up @@ -81,6 +82,8 @@ compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
concurrent-kts = { group = "androidx.concurrent", name = "concurrent-futures-ktx", version.ref = "concurrent" }
core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core" }
core-performance = { group = "androidx.core", name = "core-performance", version.ref = "core-performance" }
core-performance-play-services = { group = "androidx.core", name = "core-performance-play-services", version.ref = "core-performance" }
espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso" }
ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "test" }
glance-appwidget = { group = "androidx.glance", name = "glance-appwidget", version.ref = "glance" }
Expand Down
6 changes: 6 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"local>android/.github:renovate-config"
]
}

0 comments on commit 2b98049

Please sign in to comment.