Skip to content

Commit

Permalink
Merge branch 'LawnchairLauncher:14-dev' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
Goooler authored Jan 25, 2024
2 parents 88e7000 + 29bd631 commit 87640fe
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 84 deletions.
2 changes: 1 addition & 1 deletion baseline-profile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ dependencies {
implementation 'androidx.test.ext:junit:1.1.5'
implementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'androidx.test.uiautomator:uiautomator:2.2.0'
implementation 'androidx.benchmark:benchmark-macro-junit4:1.2.2'
implementation 'androidx.benchmark:benchmark-macro-junit4:1.2.3'
}
17 changes: 8 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import com.android.build.gradle.api.AndroidBasePlugin
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id 'com.android.application' version "8.2.1"
id 'com.android.library' version "8.2.1" apply false
id 'com.android.test' version '8.2.1' apply false
id 'androidx.baselineprofile' version '1.2.2'
id 'com.android.application' version "8.2.2"
id 'com.android.library' version "8.2.2" apply false
id 'com.android.test' version '8.2.2' apply false
id 'androidx.baselineprofile' version '1.2.3'
id 'org.jetbrains.kotlin.android' version "1.9.22"
id 'org.jetbrains.kotlin.plugin.parcelize' version "1.9.22"
id 'org.jetbrains.kotlin.plugin.serialization' version "1.9.22"
Expand All @@ -15,7 +15,7 @@ plugins {
id 'app.cash.licensee' version "1.8.0"
id 'dev.rikka.tools.refine' version "4.4.0"
id 'org.gradle.android.cache-fix' version '3.0'
id 'com.diffplug.spotless' version '6.24.0'
id 'com.diffplug.spotless' version '6.25.0'
}

allprojects {
Expand Down Expand Up @@ -324,7 +324,7 @@ dependencies {
implementation 'com.github.ChickenHook:RestrictionBypass:2.2'
implementation 'dev.rikka.tools.refine:runtime:4.4.0'

implementation platform("androidx.compose:compose-bom:2023.10.01")
implementation platform("androidx.compose:compose-bom:2024.01.00")
implementation "androidx.compose.ui:ui"
implementation "androidx.compose.ui:ui-util"
debugImplementation "androidx.compose.ui:ui-tooling"
Expand All @@ -340,13 +340,12 @@ dependencies {
implementation "androidx.navigation:navigation-compose:2.7.6"
implementation "androidx.palette:palette-ktx:1.0.0"
implementation "androidx.slice:slice-core:1.1.0-alpha02"
def accompanistVersion = '0.32.0'
def accompanistVersion = '0.34.0'
implementation "com.google.accompanist:accompanist-drawablepainter:$accompanistVersion"
implementation "com.google.accompanist:accompanist-insets-ui:$accompanistVersion"
implementation "com.google.accompanist:accompanist-permissions:$accompanistVersion"
implementation "com.google.accompanist:accompanist-systemuicontroller:$accompanistVersion"
implementation "com.google.android.material:material:1.11.0"
implementation "io.github.fornewid:material-motion-compose-core:1.0.7"
implementation "io.github.fornewid:material-motion-compose-core:1.1.1"
implementation 'dev.kdrag0n:colorkt:1.0.5'
implementation 'io.coil-kt:coil-compose:2.5.0'
implementation 'me.xdrop:fuzzywuzzy:1.4.0'
Expand Down
6 changes: 2 additions & 4 deletions lawnchair/src/app/lawnchair/BlankActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.os.Handler
import android.os.Looper
import android.os.ResultReceiver
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.result.ActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
Expand All @@ -20,8 +21,6 @@ import androidx.compose.material3.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.core.os.bundleOf
import androidx.core.view.WindowCompat
import app.lawnchair.ui.preferences.components.layout.SystemUi
import app.lawnchair.ui.theme.LawnchairTheme
import app.lawnchair.util.unsafeLazy
import kotlin.coroutines.resume
Expand All @@ -36,13 +35,12 @@ class BlankActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
WindowCompat.setDecorFitsSystemWindows(window, false)
enableEdgeToEdge()
if (!intent.hasExtra("dialogTitle")) {
startTargetActivity()
return
}
setContent {
SystemUi()
LawnchairTheme {
Surface(
modifier = Modifier.fillMaxSize(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.annotation.LayoutRes
import androidx.annotation.StringRes
import app.lawnchair.util.isPackageInstalledAndEnabled
import com.android.launcher3.R
import kotlinx.collections.immutable.persistentListOf

sealed class SmartspaceMode(
@StringRes val nameResourceId: Int,
Expand All @@ -22,7 +23,7 @@ sealed class SmartspaceMode(
/**
* @return The list of all time format options.
*/
fun values() = listOf(
fun values() = persistentListOf(
LawnchairSmartspace,
GoogleSmartspace,
GoogleSearchSmartspace,
Expand Down
6 changes: 4 additions & 2 deletions lawnchair/src/app/lawnchair/theme/color/ColorMode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import androidx.annotation.StringRes
import androidx.compose.ui.res.stringResource
import app.lawnchair.ui.preferences.components.controls.ListPreferenceEntry
import com.android.launcher3.R
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toPersistentList

enum class ColorMode(
@StringRes val labelResourceId: Int,
Expand All @@ -28,8 +30,8 @@ enum class ColorMode(

fun fromString(string: String) = values().firstOrNull { it.toString() == string }

fun entries() = values().map {
fun entries(): ImmutableList<ListPreferenceEntry<ColorMode>> = values().map {
ListPreferenceEntry(value = it) { stringResource(id = it.labelResourceId) }
}
}.toPersistentList()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.net.toUri
import androidx.core.view.WindowCompat
import app.lawnchair.ui.theme.LawnchairTheme

class PreferenceActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
WindowCompat.setDecorFitsSystemWindows(window, false)
enableEdgeToEdge()
setContent {
LawnchairTheme {
Preferences()
Expand Down
2 changes: 0 additions & 2 deletions lawnchair/src/app/lawnchair/ui/preferences/Preferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import app.lawnchair.backup.ui.createBackupGraph
import app.lawnchair.backup.ui.restoreBackupGraph
import app.lawnchair.ui.preferences.about.aboutGraph
import app.lawnchair.ui.preferences.components.colorpreference.colorSelectionGraph
import app.lawnchair.ui.preferences.components.layout.SystemUi
import app.lawnchair.ui.preferences.destinations.PreferencesDashboard
import app.lawnchair.ui.preferences.destinations.appDrawerGraph
import app.lawnchair.ui.preferences.destinations.debugMenuGraph
Expand Down Expand Up @@ -91,7 +90,6 @@ fun Preferences(
val isRtl = LocalLayoutDirection.current == LayoutDirection.Rtl
val slideDistance = rememberSlideDistance()

SystemUi()
Providers {
Surface {
CompositionLocalProvider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import app.lawnchair.ui.preferences.components.controls.ListPreference
import app.lawnchair.ui.preferences.components.controls.ListPreferenceEntry
import com.android.launcher3.R
import com.google.accompanist.drawablepainter.rememberDrawablePainter
import kotlinx.collections.immutable.toImmutableList
import kotlinx.collections.immutable.toPersistentList

data class ProviderInfo(
val name: String,
Expand Down Expand Up @@ -49,14 +49,14 @@ fun getEntries(context: Context) = getProviders(context).map {
},
label = { it.name },
)
}
}.toPersistentList()

@Composable
fun FeedPreference() {
val context = LocalContext.current
val adapter = preferenceManager().feedProvider.getAdapter()
val preferredPackage = adapter.state.value
val entries = remember { getEntries(context).toImmutableList() }
val entries = remember { getEntries(context) }
val resolvedPackage = remember(preferredPackage) {
FeedBridge.getInstance(context).resolveBridge(preferredPackage)?.packageName ?: "com.google.android.googlequicksearchbox"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ object ThemeChoice {
const val SYSTEM = "system"
}

val themeEntries = listOf(
val themeEntries = sequenceOf(
ListPreferenceEntry(ThemeChoice.LIGHT) { stringResource(id = R.string.theme_light) },
ListPreferenceEntry(ThemeChoice.DARK) { stringResource(id = R.string.theme_dark) },
ListPreferenceEntry(ThemeChoice.SYSTEM) {
Expand All @@ -28,13 +28,13 @@ val themeEntries = listOf(
ThemeChoice.SYSTEM -> Utilities.ATLEAST_O_MR1
else -> true
}
}
}.toPersistentList()

@Composable
fun ThemePreference() {
ListPreference(
adapter = preferenceManager().launcherTheme.getAdapter(),
entries = themeEntries.toPersistentList(),
entries = themeEntries,
label = stringResource(id = R.string.theme_label),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import app.lawnchair.theme.color.ColorOption
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toPersistentList

val staticColors: ImmutableList<ColorPreferenceEntry<ColorOption>> = listOf(
val staticColors: ImmutableList<ColorPreferenceEntry<ColorOption>> = sequenceOf(
ColorOption.CustomColor(0xFFF32020),
ColorOption.CustomColor(0xFFF20D69),
ColorOption.CustomColor(0xFF7452FF),
Expand All @@ -17,13 +17,13 @@ val staticColors: ImmutableList<ColorPreferenceEntry<ColorOption>> = listOf(
ColorOption.CustomColor(0xFFFF9800),
ColorOption.CustomColor(0xFF7C5445),
ColorOption.CustomColor(0xFF67818E),
).asSequence().map(ColorOption::colorPreferenceEntry).toPersistentList()
).map(ColorOption::colorPreferenceEntry).toPersistentList()

val dynamicColors: ImmutableList<ColorPreferenceEntry<ColorOption>> = listOf(ColorOption.SystemAccent, ColorOption.WallpaperPrimary)
.asSequence()
.filter(ColorOption::isSupported)
.map(ColorOption::colorPreferenceEntry)
.toPersistentList()
val dynamicColors: ImmutableList<ColorPreferenceEntry<ColorOption>> =
sequenceOf(ColorOption.SystemAccent, ColorOption.WallpaperPrimary)
.filter(ColorOption::isSupported)
.map(ColorOption::colorPreferenceEntry)
.toPersistentList()

val dynamicColorsWithDefault: ImmutableList<ColorPreferenceEntry<ColorOption>> =
(dynamicColors.asSequence() + ColorOption.Default.colorPreferenceEntry).toPersistentList()
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import androidx.annotation.StringRes
import androidx.datastore.preferences.core.Preferences
import app.lawnchair.theme.color.ColorOption
import com.patrykmichalik.opto.domain.Preference
import kotlinx.collections.immutable.ImmutableList

data class ColorPreferenceModel(
val prefObject: Preference<ColorOption, String, Preferences.Key<String>>,
@StringRes val labelRes: Int,
val dynamicEntries: List<ColorPreferenceEntry<ColorOption>>,
val dynamicEntries: ImmutableList<ColorPreferenceEntry<ColorOption>>,
)
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import app.lawnchair.ui.preferences.preferenceGraph
import com.android.launcher3.R
import com.patrykmichalik.opto.domain.Preference
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toPersistentList
import kotlinx.coroutines.launch

fun NavGraphBuilder.colorSelectionGraph(route: String) {
Expand All @@ -58,7 +57,7 @@ fun NavGraphBuilder.colorSelectionGraph(route: String) {
ColorSelection(
label = stringResource(id = model.labelRes),
preference = model.prefObject,
dynamicEntries = model.dynamicEntries.toPersistentList(),
dynamicEntries = model.dynamicEntries,
)
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ private fun HotseatModePreference(
label = { stringResource(id = mode.nameResourceId) },
enabled = mode.isAvailable(context = context),
)
}
}.toPersistentList()
}

ListPreference(
adapter = adapter,
entries = entries.toPersistentList(),
entries = entries,
label = stringResource(id = R.string.hotseat_mode_label),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import app.lawnchair.ui.preferences.subRoute
import app.lawnchair.util.collectAsStateBlocking
import com.android.launcher3.R
import com.android.launcher3.Utilities
import kotlinx.collections.immutable.toPersistentList
import kotlinx.coroutines.launch

object HomeScreenRoutes {
Expand Down Expand Up @@ -195,7 +194,7 @@ fun HomeScreenPreferences() {
fun HomeScreenTextColorPreference() {
ListPreference(
adapter = preferenceManager2().workspaceTextColor.getAdapter(),
entries = ColorMode.entries().toPersistentList(),
entries = ColorMode.entries(),
label = stringResource(id = R.string.home_screen_text_color),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ fun SmartspaceProviderPreference(
label = { stringResource(id = mode.nameResourceId) },
enabled = mode.isAvailable(context = context),
)
}
}.toPersistentList()
}

ListPreference(
adapter = adapter,
entries = entries.toPersistentList(),
entries = entries,
label = stringResource(id = R.string.smartspace_mode_label),
endWidget = endWidget,
)
Expand Down Expand Up @@ -241,14 +241,14 @@ fun SmartspaceCalendarPreference() {
val entries = remember {
SmartspaceCalendar.values().map { calendar ->
ListPreferenceEntry(calendar) { stringResource(id = calendar.nameResourceId) }
}
}.toPersistentList()
}

val adapter = preferenceManager2().smartspaceCalendar.getAdapter()

ListPreference(
adapter = adapter,
entries = entries.toPersistentList(),
entries = entries,
label = stringResource(id = R.string.smartspace_calendar),
)
}
Expand Down

0 comments on commit 87640fe

Please sign in to comment.