android: fix last commit; update copyright notice to "LibrePods Contributors"

This commit is contained in:
Kavish Devar
2025-05-11 19:48:28 +05:30
parent aec9c7192e
commit 8e670c2481
7 changed files with 68 additions and 40 deletions

View File

@@ -1,7 +1,7 @@
/* /*
* LibrePods - AirPods liberated from Apples ecosystem * LibrePods - AirPods liberated from Apples ecosystem
* *
* Copyright (C) 2025 Kavish Devar * Copyright (C) 2025 LibrePods Contributors
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published * it under the terms of the GNU Affero General Public License as published

View File

@@ -1,7 +1,7 @@
/* /*
* LibrePods - AirPods liberated from Apples ecosystem * LibrePods - AirPods liberated from Apples ecosystem
* *
* Copyright (C) 2025 Kavish Devar * Copyright (C) 2025 LibrePods Contributors
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published * it under the terms of the GNU Affero General Public License as published

View File

@@ -1,7 +1,7 @@
/* /*
* LibrePods - AirPods liberated from Apples ecosystem * LibrePods - AirPods liberated from Apples ecosystem
* *
* Copyright (C) 2025 Kavish Devar * Copyright (C) 2025 LibrePods Contributors
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published * it under the terms of the GNU Affero General Public License as published

View File

@@ -64,8 +64,10 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.draw.scale import androidx.compose.ui.draw.scale
import androidx.compose.ui.draw.shadow import androidx.compose.ui.draw.shadow
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
@@ -78,16 +80,18 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import androidx.navigation.NavController import androidx.navigation.NavController
import dev.chrisbanes.haze.HazeDefaults import dev.chrisbanes.haze.HazeEffectScope
import dev.chrisbanes.haze.HazeState import dev.chrisbanes.haze.HazeState
import dev.chrisbanes.haze.haze import dev.chrisbanes.haze.hazeEffect
import dev.chrisbanes.haze.hazeChild import dev.chrisbanes.haze.hazeSource
import dev.chrisbanes.haze.materials.CupertinoMaterials
import dev.chrisbanes.haze.materials.ExperimentalHazeMaterialsApi
import me.kavishdevar.librepods.R import me.kavishdevar.librepods.R
import me.kavishdevar.librepods.composables.StyledSwitch import me.kavishdevar.librepods.composables.StyledSwitch
import me.kavishdevar.librepods.utils.RadareOffsetFinder import me.kavishdevar.librepods.utils.RadareOffsetFinder
import kotlin.math.roundToInt import kotlin.math.roundToInt
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class, ExperimentalHazeMaterialsApi::class)
@Composable @Composable
fun AppSettingsScreen(navController: NavController) { fun AppSettingsScreen(navController: NavController) {
val sharedPreferences = LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE) val sharedPreferences = LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE)
@@ -115,19 +119,31 @@ fun AppSettingsScreen(navController: NavController) {
var disconnectWhenNotWearing by remember { var disconnectWhenNotWearing by remember {
mutableStateOf(sharedPreferences.getBoolean("disconnect_when_not_wearing", false)) mutableStateOf(sharedPreferences.getBoolean("disconnect_when_not_wearing", false))
} }
var mDensity by remember { mutableFloatStateOf(0f) }
Scaffold( Scaffold(
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection), modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
topBar = { topBar = {
CenterAlignedTopAppBar( CenterAlignedTopAppBar(
modifier = Modifier.hazeChild( modifier = Modifier.hazeEffect(
state = hazeState, state = hazeState,
style = HazeDefaults.style( style = CupertinoMaterials.thick(),
backgroundColor = if (isDarkTheme) Color(0xFF000000).copy(alpha = 0.7f) block = fun HazeEffectScope.() {
else Color(0xFFF2F2F7).copy(alpha = 0.7f), alpha =
tint = Color.White.copy(alpha = 0.2f) if (scrollState.value > 60.dp.value * mDensity) 1f else 0f
) })
), .drawBehind {
mDensity = density
val strokeWidth = 0.7.dp.value * density
val y = size.height - strokeWidth / 2
if (scrollState.value > 60.dp.value * density) {
drawLine(
if (isDarkTheme) Color.DarkGray else Color.LightGray,
Offset(0f, y),
Offset(size.width, y),
strokeWidth
)
}
},
title = { title = {
Text( Text(
text = stringResource(R.string.app_settings), text = stringResource(R.string.app_settings),
@@ -177,10 +193,7 @@ fun AppSettingsScreen(navController: NavController) {
.padding(paddingValues) .padding(paddingValues)
.padding(horizontal = 16.dp) .padding(horizontal = 16.dp)
.verticalScroll(scrollState) .verticalScroll(scrollState)
.haze( .hazeSource(state = hazeState)
state = hazeState,
style = HazeDefaults.style(backgroundColor = Color.Transparent)
)
) { ) {
val isDarkTheme = isSystemInDarkTheme() val isDarkTheme = isSystemInDarkTheme()
val backgroundColor = if (isDarkTheme) Color(0xFF1C1C1E) else Color(0xFFFFFFFF) val backgroundColor = if (isDarkTheme) Color(0xFF1C1C1E) else Color(0xFFFFFFFF)

View File

@@ -72,6 +72,7 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.draw.scale import androidx.compose.ui.draw.scale
import androidx.compose.ui.geometry.CornerRadius import androidx.compose.ui.geometry.CornerRadius
import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Offset
@@ -101,10 +102,12 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import androidx.navigation.NavController import androidx.navigation.NavController
import dev.chrisbanes.haze.HazeDefaults import dev.chrisbanes.haze.HazeEffectScope
import dev.chrisbanes.haze.HazeState import dev.chrisbanes.haze.HazeState
import dev.chrisbanes.haze.haze import dev.chrisbanes.haze.hazeEffect
import dev.chrisbanes.haze.hazeChild import dev.chrisbanes.haze.hazeSource
import dev.chrisbanes.haze.materials.CupertinoMaterials
import dev.chrisbanes.haze.materials.ExperimentalHazeMaterialsApi
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@@ -117,6 +120,7 @@ import kotlin.math.cos
import kotlin.math.sin import kotlin.math.sin
import kotlin.random.Random import kotlin.random.Random
@ExperimentalHazeMaterialsApi
@RequiresApi(Build.VERSION_CODES.Q) @RequiresApi(Build.VERSION_CODES.Q)
@OptIn(ExperimentalMaterial3Api::class, ExperimentalAnimationApi::class) @OptIn(ExperimentalMaterial3Api::class, ExperimentalAnimationApi::class)
@Composable @Composable
@@ -136,18 +140,31 @@ fun HeadTrackingScreen(navController: NavController) {
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior() val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior()
val hazeState = remember { HazeState() } val hazeState = remember { HazeState() }
var mDensity by remember { mutableFloatStateOf(0f) }
Scaffold( Scaffold(
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection), modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
topBar = { topBar = {
CenterAlignedTopAppBar( CenterAlignedTopAppBar(
modifier = Modifier.hazeChild( modifier = Modifier.hazeEffect(
state = hazeState, state = hazeState,
style = HazeDefaults.style( style = CupertinoMaterials.thick(),
backgroundColor = if (isDarkTheme) Color(0xFF000000).copy(alpha = 0.7f) block = fun HazeEffectScope.() {
else Color(0xFFF2F2F7).copy(alpha = 0.7f), alpha =
tint = Color.White.copy(alpha = 0.2f) if (scrollState.value > 60.dp.value * mDensity) 1f else 0f
) })
), .drawBehind {
mDensity = density
val strokeWidth = 0.7.dp.value * density
val y = size.height - strokeWidth / 2
if (scrollState.value > 60.dp.value * density) {
drawLine(
if (isDarkTheme) Color.DarkGray else Color.LightGray,
Offset(0f, y),
Offset(size.width, y),
strokeWidth
)
}
},
title = { title = {
Text( Text(
stringResource(R.string.head_tracking), stringResource(R.string.head_tracking),
@@ -246,10 +263,7 @@ fun HeadTrackingScreen(navController: NavController) {
.padding(horizontal = 16.dp) .padding(horizontal = 16.dp)
.padding(top = 8.dp) .padding(top = 8.dp)
.verticalScroll(scrollState) .verticalScroll(scrollState)
.haze( .hazeSource(state = hazeState)
state = hazeState,
style = HazeDefaults.style(backgroundColor = Color.Transparent)
)
) { ) {
val sharedPreferences = val sharedPreferences =
LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE) LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE)
@@ -833,6 +847,7 @@ private fun AccelerationPlot() {
} }
} }
@ExperimentalHazeMaterialsApi
@RequiresApi(Build.VERSION_CODES.Q) @RequiresApi(Build.VERSION_CODES.Q)
@Preview @Preview
@Composable @Composable

View File

@@ -1,7 +1,7 @@
/* /*
* LibrePods - AirPods liberated from Apples ecosystem * LibrePods - AirPods liberated from Apples ecosystem
* *
* Copyright (C) 2025 Kavish Devar * Copyright (C) 2025 LibrePods Contributors
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published * it under the terms of the GNU Affero General Public License as published

View File

@@ -1,7 +1,7 @@
/* /*
* LibrePods - AirPods liberated from Apples ecosystem * LibrePods - AirPods liberated from Apples ecosystem
* *
* Copyright (C) 2025 Kavish Devar * Copyright (C) 2025 LibrePods Contributors
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published * it under the terms of the GNU Affero General Public License as published