Material 3 theme [WIP]

This commit is contained in:
MM20 2021-12-04 12:24:16 +01:00
parent d7f549795a
commit 0e1ca1c1f9
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389
95 changed files with 1154 additions and 902 deletions

View File

@ -50,7 +50,7 @@
android:parentActivityName=".ui.legacy.activity.LauncherActivity"
android:screenOrientation="portrait"
android:taskAffinity="de.mm20.launcher2.settings"
android:theme="@style/SettingsTheme">
android:theme="@style/SettingsTheme.DefaultColors">
<intent-filter>
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
<category android:name="android.intent.category.DEFAULT" />

View File

@ -11,12 +11,18 @@ import de.mm20.launcher2.fragment.PreferencesCalendarFragment
import de.mm20.launcher2.fragment.PreferencesMainFragment
import de.mm20.launcher2.fragment.PreferencesServicesFragment
import de.mm20.launcher2.fragment.PreferencesWeatherFragment
import de.mm20.launcher2.preferences.ColorSchemes
import de.mm20.launcher2.preferences.LauncherPreferences
import de.mm20.launcher2.ui.legacy.activity.LauncherActivity
class SettingsActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
when(LauncherPreferences.instance.colorScheme) {
ColorSchemes.BLACK -> setTheme(R.style.SettingsTheme_BlackWhiteColors)
else -> setTheme(R.style.SettingsTheme_DefaultColors)
}
if (savedInstanceState == null) {
val fragment = getStartFragment()
setupActionBar()
@ -32,7 +38,6 @@ class SettingsActivity : AppCompatActivity() {
.replace(android.R.id.content, fragment)
.commit()
}
findViewById<View>(android.R.id.content)?.setBackgroundColor(getColor(R.color.settings_window_background))
}
override fun onSaveInstanceState(outState: Bundle) {

View File

@ -1,21 +1,26 @@
package de.mm20.launcher2.fragment
import android.annotation.SuppressLint
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.FileProvider
import androidx.lifecycle.lifecycleScope
import androidx.preference.Preference
import androidx.preference.PreferenceCategory
import androidx.preference.PreferenceFragmentCompat
import com.afollestad.materialdialogs.MaterialDialog
import com.google.android.material.snackbar.Snackbar
import de.mm20.launcher2.R
import de.mm20.launcher2.crashreporter.CrashReporter
import de.mm20.launcher2.debug.DebugInformationDumper
import de.mm20.launcher2.ktx.tryStartActivity
import de.mm20.launcher2.licenses.AppLicense
import de.mm20.launcher2.licenses.OpenSourceLicenses
import kotlinx.coroutines.launch
import java.io.File
class PreferencesAboutFragment : PreferenceFragmentCompat() {
@ -96,14 +101,27 @@ class PreferencesAboutFragment : PreferenceFragmentCompat() {
findPreference<Preference>("export_debug")?.setOnPreferenceClickListener {
lifecycleScope.launch {
val path = DebugInformationDumper().dump(requireContext())
Toast.makeText(
activity,
Snackbar.make(
requireView(),
getString(
R.string.debug_export_information_file,
path
),
Toast.LENGTH_SHORT
).show()
Snackbar.LENGTH_LONG
)
.setAction(R.string.menu_share) {
val context = requireContext()
context.tryStartActivity(Intent(Intent.ACTION_SEND).apply {
type = "text/plain"
putExtra(
Intent.EXTRA_STREAM, FileProvider.getUriForFile(
context,
context.applicationContext.packageName + ".fileprovider",
File(path)
)
)
})
}.show()
}
true
}

View File

@ -1,7 +1,5 @@
package de.mm20.launcher2.fragment
import android.Manifest
import android.app.WallpaperManager
import android.content.Intent
import android.graphics.drawable.ColorDrawable
import android.os.Build
@ -11,7 +9,6 @@ import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.app.ActivityCompat
import androidx.lifecycle.lifecycleScope
import androidx.preference.ListPreference
import androidx.preference.Preference
@ -23,7 +20,6 @@ import de.mm20.launcher2.R
import de.mm20.launcher2.icons.IconPackManager
import de.mm20.launcher2.icons.IconRepository
import de.mm20.launcher2.icons.LauncherIcon
import de.mm20.launcher2.ktx.checkPermission
import de.mm20.launcher2.preferences.IconShape
import de.mm20.launcher2.preferences.LauncherPreferences
import de.mm20.launcher2.preferences.Themes
@ -48,6 +44,11 @@ class PreferencesAppearanceFragment : PreferenceFragmentCompat() {
true
}
findPreference<Preference>("card_background")?.setOnPreferenceChangeListener { _, newValue ->
requireActivity().recreate()
true
}
findPreference<Preference>("wallpaper")?.setOnPreferenceClickListener {
requireContext().startActivity(Intent.createChooser(Intent(Intent.ACTION_SET_WALLPAPER), null))
true
@ -79,18 +80,18 @@ class PreferencesAppearanceFragment : PreferenceFragmentCompat() {
}
setOnPreferenceChangeListener { _, newValue ->
val index = (newValue as String).toInt()
iconRepository.clearCache()
if (index == -1) iconPackManager.selectIconPack("")
else {
iconPackManager.selectIconPack(packs[index].packageName)
}
iconRepository.recreate()
true
}
}
}
findPreference<Preference>("legacy_icon_bg")?.setOnPreferenceChangeListener { _, _ ->
iconRepository.clearCache()
iconRepository.recreate()
true
}

View File

@ -6,23 +6,15 @@ import android.app.WallpaperManager
import android.graphics.*
import android.os.Bundle
import android.view.View
import android.view.ViewOutlineProvider
import androidx.core.content.res.ResourcesCompat
import androidx.core.view.doOnNextLayout
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import de.mm20.launcher2.R
import de.mm20.launcher2.ktx.dp
import de.mm20.launcher2.ktx.translate
import de.mm20.launcher2.preferences.CardBackground
import de.mm20.launcher2.preferences.LauncherPreferences
import kotlinx.android.synthetic.main.fragment_card_settings.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.File
import kotlin.math.roundToInt
class PreferencesCardFragment : Fragment(R.layout.fragment_card_settings) {
@ -68,18 +60,6 @@ class PreferencesCardFragment : Fragment(R.layout.fragment_card_settings) {
true
}
}
findPreference<Preference>("card_background")?.let {
it.setOnPreferenceChangeListener { preference, newValue ->
val background = CardBackground.byValue(newValue as String)
var color = when (background) {
CardBackground.BLACK -> context.getColor(R.color.cardview_background_black)
else -> context.getColor(R.color.cardview_background)
}
color = color and ((previewCard.backgroundOpacity shl 24) or 0xFFFFFF)
previewCard.setCardBackgroundColor(color)
true
}
}
}
childFragmentManager.beginTransaction()
@ -89,8 +69,6 @@ class PreferencesCardFragment : Fragment(R.layout.fragment_card_settings) {
}
private var blurBitmap: Bitmap? = null
private var animator: Animator? = null
override fun onStart() {
super.onStart()

View File

@ -9,6 +9,7 @@
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="232dp"
android:background="?colorPrimaryContainer"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

View File

@ -8,6 +8,15 @@
app:key="theme"
app:summary="%s"
app:title="@string/preference_theme" />
<ListPreference
app:key="card_background"
android:defaultValue="0"
app:summary="%s"
app:title="@string/preference_screen_colors"
app:entries="@array/preference_card_background_entries"
app:entryValues="@array/preference_card_background_values"
/>
<Preference
app:key="cards"
app:summary="@string/preference_cards_summary"

View File

@ -24,13 +24,4 @@
app:min="0"
app:updatesContinuously="true" />
<ListPreference
app:key="card_background"
android:defaultValue="0"
app:summary="%s"
app:title="@string/preference_card_background"
app:entries="@array/preference_card_background_entries"
app:entryValues="@array/preference_card_background_values"
/>
</PreferenceScreen>

View File

@ -15,10 +15,8 @@ import androidx.lifecycle.MutableLiveData
import de.mm20.launcher2.badges.Badge
import de.mm20.launcher2.badges.BadgeProvider
import de.mm20.launcher2.hiddenitems.HiddenItemsRepository
import de.mm20.launcher2.icons.IconRepository
import de.mm20.launcher2.preferences.LauncherPreferences
import de.mm20.launcher2.search.BaseSearchableRepository
import de.mm20.launcher2.search.SearchRepository
import de.mm20.launcher2.search.data.AppInstallation
import de.mm20.launcher2.search.data.Application
import de.mm20.launcher2.search.data.LauncherApp
@ -27,7 +25,6 @@ import kotlinx.coroutines.withContext
class AppRepository(
val context: Context,
val iconRepository: IconRepository,
hiddenItemsRepository: HiddenItemsRepository,
badgeProvider: BadgeProvider
) : BaseSearchableRepository() {
@ -148,10 +145,7 @@ class AppRepository(
override fun onBadgingChanged(sessionId: Int) {
val inst = installations.value ?: mutableListOf()
inst.removeAll {
if (it.session.sessionId == sessionId) {
iconRepository.removeIconFromCache(it)
true
} else false
it.session.sessionId == sessionId
}
onCreated(sessionId)
}

View File

@ -5,6 +5,6 @@ import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.dsl.module
val applicationsModule = module {
single { AppRepository(androidContext(), get(), get(), get()) }
single { AppRepository(androidContext(), get(), get()) }
viewModel { AppViewModel(get()) }
}

View File

@ -7,53 +7,59 @@ import android.content.pm.LauncherActivityInfo
import android.content.pm.LauncherApps
import android.content.pm.PackageManager
import android.content.pm.ShortcutInfo
import android.graphics.drawable.AdaptiveIconDrawable
import android.os.*
import androidx.core.content.getSystemService
import de.mm20.launcher2.icons.IconPackManager
import de.mm20.launcher2.icons.LauncherIcon
import de.mm20.launcher2.ktx.getSerialNumber
import de.mm20.launcher2.preferences.LauncherPreferences
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.json.JSONObject
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
/**
* An [Application] based on an [android.content.pm.LauncherActivityInfo]
*/
class LauncherApp(
context: Context,
private val launcherActivityInfo: LauncherActivityInfo
context: Context,
public val launcherActivityInfo: LauncherActivityInfo
) : Application(
label = launcherActivityInfo.label.toString(),
`package` = launcherActivityInfo.applicationInfo.packageName,
activity = launcherActivityInfo.name,
flags = launcherActivityInfo.applicationInfo.flags,
version = getPackageVersionName(context, launcherActivityInfo.applicationInfo.packageName),
shortcuts = run {
val appShortcuts = mutableListOf<AppShortcut>()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
val launcherApps = context.getSystemService<LauncherApps>()!!
if (!launcherApps.hasShortcutHostPermission()) return@run appShortcuts
val query = LauncherApps.ShortcutQuery()
.setPackage(launcherActivityInfo.applicationInfo.packageName)
.setQueryFlags(LauncherApps.ShortcutQuery.FLAG_MATCH_DYNAMIC or LauncherApps.ShortcutQuery.FLAG_MATCH_MANIFEST)
val shortcuts = try {
launcherApps.getShortcuts(query, launcherActivityInfo.user)
} catch (e: IllegalStateException) {
emptyList<ShortcutInfo>()
}
appShortcuts.addAll(shortcuts?.map { AppShortcut(context, it, launcherActivityInfo.label.toString()) }
?: emptyList())
label = launcherActivityInfo.label.toString(),
`package` = launcherActivityInfo.applicationInfo.packageName,
activity = launcherActivityInfo.name,
flags = launcherActivityInfo.applicationInfo.flags,
version = getPackageVersionName(context, launcherActivityInfo.applicationInfo.packageName),
shortcuts = run {
val appShortcuts = mutableListOf<AppShortcut>()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
val launcherApps = context.getSystemService<LauncherApps>()!!
if (!launcherApps.hasShortcutHostPermission()) return@run appShortcuts
val query = LauncherApps.ShortcutQuery()
.setPackage(launcherActivityInfo.applicationInfo.packageName)
.setQueryFlags(LauncherApps.ShortcutQuery.FLAG_MATCH_DYNAMIC or LauncherApps.ShortcutQuery.FLAG_MATCH_MANIFEST)
val shortcuts = try {
launcherApps.getShortcuts(query, launcherActivityInfo.user)
} catch (e: IllegalStateException) {
emptyList<ShortcutInfo>()
}
appShortcuts
appShortcuts.addAll(shortcuts?.map {
AppShortcut(
context,
it,
launcherActivityInfo.label.toString()
)
}
?: emptyList())
}
appShortcuts
}
), KoinComponent {
internal val userSerialNumber: Long = launcherActivityInfo.user.getSerialNumber(context)
private val isMainProfile = launcherActivityInfo.user == Process.myUserHandle()
override val badgeKey: String = if (isMainProfile) "app://${`package`}" else "profile://$userSerialNumber"
override val badgeKey: String =
if (isMainProfile) "app://${`package`}" else "profile://$userSerialNumber"
override val key: String
get() = if (isMainProfile) "app://$`package`:$activity" else "app://$`package`:$activity:${userSerialNumber}"
@ -63,9 +69,31 @@ class LauncherApp(
}
override suspend fun loadIconAsync(context: Context, size: Int): LauncherIcon? {
val iconPackManager: IconPackManager by inject()
return withContext(Dispatchers.IO) {
iconPackManager.getIcon(context, launcherActivityInfo, size)
try {
val icon =
withContext(Dispatchers.IO) {
launcherActivityInfo.getIcon(context.resources.displayMetrics.densityDpi)
} ?: return null
when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && icon is AdaptiveIconDrawable -> {
return LauncherIcon(
foreground = icon.foreground ?: return null,
background = icon.background,
foregroundScale = 1.5f,
backgroundScale = 1.5f
)
}
else -> {
return LauncherIcon(
foreground = icon,
foregroundScale = 0.7f,
autoGenerateBackgroundMode = LauncherPreferences.instance.legacyIconBg.toInt()
)
}
}
} catch (e: PackageManager.NameNotFoundException) {
return null
}
}
@ -79,10 +107,10 @@ class LauncherApp(
} else {
try {
launcherApps.startMainActivity(
ComponentName(`package`, activity),
launcherActivityInfo.user,
null,
options
ComponentName(`package`, activity),
launcherActivityInfo.user,
null,
options
)
} catch (e: SecurityException) {
return false

View File

@ -0,0 +1,31 @@
<resources>
<style name="DefaultColors" parent="Theme.Material3.DayNight">
<item name="colorPrimary">@android:color/system_accent1_200</item>
<item name="colorOnPrimary">@android:color/system_accent1_800</item>
<item name="colorPrimaryContainer">@android:color/system_accent1_700</item>
<item name="colorOnPrimaryContainer">@android:color/system_accent1_100</item>
<item name="colorPrimaryInverse">@android:color/system_accent1_600</item>
<item name="colorSecondary">@android:color/system_accent2_200</item>
<item name="colorOnSecondary">@android:color/system_accent2_800</item>
<item name="colorSecondaryContainer">@android:color/system_accent2_700</item>
<item name="colorOnSecondaryContainer">@android:color/system_accent2_100</item>
<item name="colorTertiary">@android:color/system_accent3_200</item>
<item name="colorOnTertiary">@android:color/system_accent3_800</item>
<item name="colorTertiaryContainer">@android:color/system_accent3_700</item>
<item name="colorOnTertiaryContainer">@android:color/system_accent3_100</item>
<item name="colorError">#fff2b8b5</item>
<item name="colorOnError">#ff601410</item>
<item name="colorErrorContainer">#ff8c1d18</item>
<item name="colorOnErrorContainer">#fff2b8b5</item>
<item name="colorOutline">@android:color/system_neutral2_400</item>
<item name="android:colorBackground">@android:color/system_neutral1_900</item>
<item name="colorOnBackground">@android:color/system_neutral1_100</item>
<item name="colorSurface">@android:color/system_neutral1_900</item>
<item name="colorOnSurface">@android:color/system_neutral1_200</item>
<item name="colorSurfaceVariant">@android:color/system_neutral2_700</item>
<item name="colorOnSurfaceVariant">@android:color/system_neutral2_200</item>
<item name="colorSurfaceInverse">@android:color/system_neutral1_100</item>
<item name="colorOnSurfaceInverse">@android:color/system_neutral1_800</item>
<item name="elevationOverlayEnabled">true</item>
</style>
</resources>

View File

@ -0,0 +1,61 @@
<resources>
<style name="DefaultColors" parent="Theme.Material3.DayNight">
<item name="colorPrimary">#72D1FF</item>
<item name="colorOnPrimary">#003549</item>
<item name="colorPrimaryContainer">#004D68</item>
<item name="colorOnPrimaryContainer">#BFE8FF</item>
<item name="colorPrimaryInverse">#006689</item>
<item name="colorSecondary">#A2D824</item>
<item name="colorOnSecondary">#243600</item>
<item name="colorSecondaryContainer">#354E00</item>
<item name="colorOnSecondaryContainer">#BDF542</item>
<item name="colorTertiary">#FEBB2B</item>
<item name="colorOnTertiary">#422C00</item>
<item name="colorTertiaryContainer">#5F4100</item>
<item name="colorOnTertiaryContainer">#FFDEA4</item>
<item name="colorError">#FFB4A9</item>
<item name="colorOnError">#680003</item>
<item name="colorErrorContainer">#930006</item>
<item name="colorOnErrorContainer">#FFDAD4</item>
<item name="colorOutline">#8B9298</item>
<item name="android:colorBackground">#191C1E</item>
<item name="colorOnBackground">#E1E2E4</item>
<item name="colorSurface">#191C1E</item>
<item name="colorOnSurface">#E1E2E4</item>
<item name="colorSurfaceVariant">#41484D</item>
<item name="colorOnSurfaceVariant">#C0C7CD</item>
<item name="colorSurfaceInverse">#E1E2E4</item>
<item name="colorOnSurfaceInverse">#191C1E</item>
<item name="elevationOverlayEnabled">true</item>
</style>
<style name="BlackWhiteColors" parent="Theme.Material3.DayNight">
<item name="colorPrimary">@android:color/white</item>
<item name="colorOnPrimary">@android:color/black</item>
<item name="colorPrimaryContainer">@android:color/black</item>
<item name="colorOnPrimaryContainer">@android:color/white</item>
<item name="colorPrimaryInverse">@android:color/black</item>
<item name="colorSecondary">@android:color/white</item>
<item name="colorOnSecondary">@android:color/black</item>
<item name="colorSecondaryContainer">@android:color/black</item>
<item name="colorOnSecondaryContainer">@android:color/white</item>
<item name="colorTertiary">@android:color/white</item>
<item name="colorOnTertiary">@android:color/black</item>
<item name="colorTertiaryContainer">@android:color/black</item>
<item name="colorOnTertiaryContainer">@android:color/white</item>
<item name="colorError">@android:color/black</item>
<item name="colorOnError">@android:color/white</item>
<item name="colorErrorContainer">@android:color/black</item>
<item name="colorOnErrorContainer">@android:color/white</item>
<item name="colorOutline">@android:color/white</item>
<item name="android:colorBackground">@android:color/black</item>
<item name="colorOnBackground">@android:color/white</item>
<item name="colorSurface">@android:color/black</item>
<item name="colorOnSurface">@android:color/white</item>
<item name="colorSurfaceVariant">@android:color/black</item>
<item name="colorOnSurfaceVariant">@android:color/white</item>
<item name="colorSurfaceInverse">@android:color/white</item>
<item name="colorOnSurfaceInverse">@android:color/black</item>
<item name="elevationOverlayEnabled">false</item>
</style>
</resources>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<color name="android_green">#00DE7A</color>
<color name="red">#E57373</color>
<color name="pink">#F06292</color>
<color name="purple">#BA68C8</color>

View File

@ -3,6 +3,11 @@
<style name="BaseLauncherTheme.Settings">
<item name="android:windowLightStatusBar">false</item>
<item name="actionBarTheme">@style/ActionBarSettings</item>
</style>
<style name="ActionBarSettings">
<item name="titleTextColor">@android:color/white</item>
</style>
<style name="LauncherTheme.IconStyle">

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="SettingsTheme.DefaultColors" parent="DefaultColors">
<item name="android:statusBarColor">?colorSurface</item>
<item name="android:windowLightStatusBar">false</item>
</style>
<style name="SettingsTheme.BlackWhiteColors" parent="BlackWhiteColors">
<item name="android:statusBarColor">?colorSurface</item>
<item name="android:windowLightStatusBar">false</item>
</style>
</resources>

View File

@ -0,0 +1,31 @@
<resources>
<style name="DefaultColors" parent="Theme.Material3.DayNight">
<item name="colorPrimary">@android:color/system_accent1_600</item>
<item name="colorOnPrimary">@android:color/system_accent1_0</item>
<item name="colorPrimaryContainer">@android:color/system_accent1_100</item>
<item name="colorOnPrimaryContainer">@android:color/system_accent1_900</item>
<item name="colorPrimaryInverse">@android:color/system_accent1_200</item>
<item name="colorSecondary">@android:color/system_accent2_600</item>
<item name="colorOnSecondary">@android:color/system_accent2_0</item>
<item name="colorSecondaryContainer">@android:color/system_accent2_100</item>
<item name="colorOnSecondaryContainer">@android:color/system_accent2_900</item>
<item name="colorTertiary">@android:color/system_accent3_600</item>
<item name="colorOnTertiary">@android:color/system_accent3_0</item>
<item name="colorTertiaryContainer">@android:color/system_accent3_100</item>
<item name="colorOnTertiaryContainer">@android:color/system_accent3_900</item>
<item name="colorError">#ffb3261e</item>
<item name="colorOnError">@android:color/white</item>
<item name="colorErrorContainer">#fff9dedc</item>
<item name="colorOnErrorContainer">#ff410e0b</item>
<item name="colorOutline">@android:color/system_neutral2_500</item>
<item name="android:colorBackground">@android:color/system_neutral1_10</item>
<item name="colorOnBackground">@android:color/system_neutral1_900</item>
<item name="colorSurface">@android:color/system_neutral1_10</item>
<item name="colorOnSurface">@android:color/system_neutral1_900</item>
<item name="colorSurfaceVariant">@android:color/system_neutral2_100</item>
<item name="colorOnSurfaceVariant">@android:color/system_neutral2_700</item>
<item name="colorSurfaceInverse">@android:color/system_neutral2_800</item>
<item name="colorOnSurfaceInverse">@android:color/system_neutral2_50</item>
<item name="elevationOverlayEnabled">false</item>
</style>
</resources>

View File

@ -0,0 +1,61 @@
<resources>
<style name="DefaultColors" parent="Theme.Material3.DayNight">
<item name="colorPrimary">#006689</item>
<item name="colorOnPrimary">@android:color/white</item>
<item name="colorPrimaryContainer">#BFE8FF</item>
<item name="colorOnPrimaryContainer">#001E2C</item>
<item name="colorPrimaryInverse">#72D1FF</item>
<item name="colorSecondary">#496800</item>
<item name="colorOnSecondary">@android:color/white</item>
<item name="colorSecondaryContainer">#BDF542</item>
<item name="colorOnSecondaryContainer">#131F00</item>
<item name="colorTertiary">#7D5700</item>
<item name="colorOnTertiary">@android:color/white</item>
<item name="colorTertiaryContainer">#FFDEA4</item>
<item name="colorOnTertiaryContainer">#281900</item>
<item name="colorError">#BA1B1B</item>
<item name="colorOnError">@android:color/white</item>
<item name="colorErrorContainer">#FFDAD4</item>
<item name="colorOnErrorContainer">#410001</item>
<item name="colorOutline">#71787D</item>
<item name="android:colorBackground">#FBFCFE</item>
<item name="colorOnBackground">#191C1E</item>
<item name="colorSurface">#FBFCFE</item>
<item name="colorOnSurface">#191C1E</item>
<item name="colorSurfaceVariant">#DCE3E9</item>
<item name="colorOnSurfaceVariant">#41484D</item>
<item name="colorSurfaceInverse">#2E3133</item>
<item name="colorOnSurfaceInverse">#F0F1F3</item>
<item name="elevationOverlayEnabled">false</item>
</style>
<style name="BlackWhiteColors" parent="Theme.Material3.DayNight">
<item name="colorPrimary">@android:color/black</item>
<item name="colorOnPrimary">@android:color/white</item>
<item name="colorPrimaryContainer">@android:color/white</item>
<item name="colorOnPrimaryContainer">@android:color/black</item>
<item name="colorPrimaryInverse">@android:color/white</item>
<item name="colorSecondary">@android:color/black</item>
<item name="colorOnSecondary">@android:color/white</item>
<item name="colorSecondaryContainer">@android:color/white</item>
<item name="colorOnSecondaryContainer">@android:color/black</item>
<item name="colorTertiary">@android:color/black</item>
<item name="colorOnTertiary">@android:color/white</item>
<item name="colorTertiaryContainer">@android:color/white</item>
<item name="colorOnTertiaryContainer">@android:color/black</item>
<item name="colorError">@android:color/white</item>
<item name="colorOnError">@android:color/black</item>
<item name="colorErrorContainer">@android:color/white</item>
<item name="colorOnErrorContainer">@android:color/black</item>
<item name="colorOutline">@android:color/black</item>
<item name="android:colorBackground">@android:color/white</item>
<item name="colorOnBackground">@android:color/black</item>
<item name="colorSurface">@android:color/white</item>
<item name="colorOnSurface">@android:color/black</item>
<item name="colorSurfaceVariant">@android:color/white</item>
<item name="colorOnSurfaceVariant">@android:color/black</item>
<item name="colorSurfaceInverse">@android:color/black</item>
<item name="colorOnSurfaceInverse">@android:color/white</item>
<item name="elevationOverlayEnabled">false</item>
</style>
</resources>

View File

@ -2,6 +2,7 @@
<resources>
<color name="badge_text">#8A000000</color>
<color name="android_green">#00A55B</color>
<color name="red">#E53935</color>
<color name="pink">#D81B60</color>
<color name="purple">#9C27B0</color>

View File

@ -1,6 +1,6 @@
<resources>
<style name="BaseLauncherTheme" parent="Theme.MaterialComponents.DayNight">
<style name="BaseLauncherTheme" parent="Theme.Material3.DayNight">
<item name="android:colorPrimary">@color/blue</item>
<item name="android:colorAccent">@color/blue</item>
<item name="colorPrimary">@color/blue</item>
@ -46,28 +46,28 @@
<item name="android:windowShowWallpaper">true</item>
</style>
<style name="AlertDialogTheme" parent="ThemeOverlay.MaterialComponents.Dialog.Alert">
<style name="AlertDialogTheme" parent="ThemeOverlay.Material3.Dialog.Alert">
<item name="buttonBarButtonStyle">@style/AlertDialogButtonStyle</item>
<item name="dialogCornerRadius">8dp</item>
</style>
<style name="AlertDialogButtonStyle" parent="Widget.MaterialComponents.Button.UnelevatedButton">
<style name="AlertDialogButtonStyle" parent="Widget.Material3.Button.UnelevatedButton">
<item name="android:textColor">?colorAccent</item>
<item name="android:letterSpacing">0</item>
<item name="android:background">?selectableItemBackground</item>
</style>
<style name="CardViewStyle" parent="Widget.MaterialComponents.CardView">
<style name="CardViewStyle" parent="Widget.Material3.CardView.Elevated">
<item name="cardCornerRadius">8dp</item>
</style>
<style name="InnerCardViewStyle" parent="Widget.MaterialComponents.CardView">
<style name="InnerCardViewStyle" parent="Widget.Material3.CardView.Outlined">
<item name="cardElevation">0dp</item>
<item name="strokeWidth">1dp</item>
<item name="strokeColor">@color/color_divider</item>
</style>
<style name="ElevatedInnerCardViewStyle" parent="Widget.MaterialComponents.CardView">
<style name="ElevatedInnerCardViewStyle" parent="Widget.Material3.CardView.Elevated">
<item name="cardElevation">4dp</item>
</style>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="SettingsTheme.DefaultColors" parent="DefaultColors">
<item name="android:statusBarColor">?colorSurface</item>
<item name="android:windowLightStatusBar">true</item>
</style>
<style name="SettingsTheme.BlackWhiteColors" parent="BlackWhiteColors">
<item name="android:statusBarColor">?colorSurface</item>
<item name="android:windowLightStatusBar">true</item>
</style>
<style name="LauncherTheme.DefaultColors" parent="DefaultColors">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowShowWallpaper">true</item>
<item name="android:colorPrimaryDark">#0000</item>
<item name="android:statusBarColor">#00000000</item>
<item name="android:navigationBarColor">#00000000</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:enforceStatusBarContrast">false</item>
<item name="android:enforceNavigationBarContrast">false</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="LauncherTheme.BlackWhiteColors" parent="BlackWhiteColors">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowShowWallpaper">true</item>
<item name="android:colorPrimaryDark">#0000</item>
<item name="android:statusBarColor">#00000000</item>
<item name="android:navigationBarColor">#00000000</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:enforceStatusBarContrast">false</item>
<item name="android:enforceNavigationBarContrast">false</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
</resources>

View File

@ -10,19 +10,15 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.DayNight.ActionBar">
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.DayNight" />
android:layout_height="?attr/actionBarSize" />
</com.google.android.material.appbar.AppBarLayout>
@ -42,8 +38,8 @@
android:id="@+id/appInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:layout_marginTop="10dp"
android:textColor="?android:textColorPrimary"/>
android:padding="10dp"
android:textColor="?android:textColorPrimary" />
</LinearLayout>
</ScrollView>

View File

@ -7,24 +7,20 @@
tools:context="com.balsikandar.crashreporter.ui.CrashReporterActivity">
<com.google.android.material.appbar.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.DayNight.ActionBar">
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.DayNight" />
android:layout_height="wrap_content"/>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="?attr/actionBarSize" />
</com.google.android.material.appbar.AppBarLayout>

View File

@ -1,9 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CrashReporter.Theme" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="colorAccent">@color/blue</item>
<item name="colorPrimary">@color/settings_color_primary</item>
<item name="colorPrimaryDark">@color/settings_color_primary_dark</item>
<style name="CrashReporter.Theme" parent="SettingsTheme.DefaultColors">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
</resources>

View File

@ -1,5 +1,6 @@
package de.mm20.launcher2.database
import android.content.ComponentName
import androidx.lifecycle.LiveData
import androidx.room.*
import de.mm20.launcher2.database.entities.IconEntity
@ -11,10 +12,10 @@ interface IconDao {
fun insertAll(icons: List<IconEntity>)
@Query("SELECT drawable FROM Icons WHERE componentName = :componentName AND iconPack = :iconPack")
fun getIconName(componentName: String, iconPack: String): String?
suspend fun getIconName(componentName: String, iconPack: String): String?
@Query("SELECT * FROM Icons WHERE componentName = :componentName AND iconPack = :iconPack")
fun getIcon(componentName: String, iconPack: String): IconEntity?
suspend fun getIcon(componentName: String, iconPack: String): IconEntity?
@Query("DELETE FROM Icons WHERE iconPack = :iconPack")
fun deleteIcons(iconPack: String)
@ -27,11 +28,17 @@ interface IconDao {
installIconPack(iconPack)
}
@Transaction
fun installGrayscaleIconMap(packageName: String, icons: List<IconEntity>) {
deleteIcons(packageName)
insertAll(icons)
}
@Insert
fun installIconPack(iconPack: IconPackEntity)
@Query("SELECT * FROM IconPack")
fun getInstalledIconPacks(): List<IconPackEntity>
suspend fun getInstalledIconPacks(): List<IconPackEntity>
@Query("SELECT * FROM IconPack")
fun getInstalledIconPacksLiveData(): LiveData<List<IconPackEntity>>
@ -40,10 +47,10 @@ interface IconDao {
fun deleteIconPack(iconPack: IconPackEntity)
@Query("SELECT * FROM IconPack WHERE packageName = :packageName AND version = :version")
fun getPacks(packageName: String, version: String): List<IconPackEntity>
suspend fun getPacks(packageName: String, version: String): List<IconPackEntity>
@Transaction
fun isInstalled(iconPack: IconPackEntity): Boolean {
suspend fun isInstalled(iconPack: IconPackEntity): Boolean {
return getPacks(iconPack.packageName, iconPack.version).isNotEmpty()
}
@ -60,14 +67,17 @@ interface IconDao {
}
@Query("SELECT drawable FROM Icons WHERE iconPack = :pack AND type = 'iconback'")
fun getIconBacks(pack: String): List<String>
suspend fun getIconBacks(pack: String): List<String>
@Query("SELECT drawable FROM Icons WHERE iconPack = :pack AND type = 'iconupon'")
fun getIconUpons(pack: String): List<String>
suspend fun getIconUpons(pack: String): List<String>
@Query("SELECT drawable FROM Icons WHERE iconPack = :pack AND type = 'iconmask'")
fun getIconMasks(pack: String): List<String>
suspend fun getIconMasks(pack: String): List<String>
@Query("SELECT scale FROM IconPack WHERE packageName = :pack")
fun getScale(pack: String): Float?
suspend fun getScale(pack: String): Float?
@Query("SELECT * FROM Icons WHERE type = 'greyscale_icon' AND componentName = :componentName")
suspend fun getGreyscaleIcon(componentName: String): IconEntity?
}

View File

@ -381,7 +381,7 @@
<string name="disclaimer_currency_converter">Wechselkurse so wie sie einmal täglich von der Europäischen Zentralbank herausgegeben werden. Alle Angaben sind ohne Gewähr. Es wird keine Haftung für die hier dargestellten Informationen übernommen.</string>
<string name="unit_converter_show_all">Alle anzeigen</string>
<string name="preference_card_background">Hintergrund</string>
<string name="preference_card_background_default">Standard (weiß/dunkelgrau)</string>
<string name="preference_card_background_default">Standard</string>
<string name="preference_card_background_black">Weiß/schwarz</string>
<string name="preference_card_background_colored">Farbig (aus Hintergrundbild)</string>
<string name="preference_screen_colors">Farbschema</string>

View File

@ -379,7 +379,7 @@
<string name="disclaimer_currency_converter">"Exchange rates as published once per day by the European Central Bank. All information is provided \"as is\" without any kind of guarantee. No liability is assumed for these information."</string>
<string name="unit_converter_show_all">Show all</string>
<string name="preference_card_background">Background</string>
<string name="preference_card_background_default">Default (white/dark gray)</string>
<string name="preference_card_background_default">Default</string>
<string name="preference_card_background_black">White/black</string>
<string name="preference_card_background_colored">Colored (from wallpaper)</string>

View File

@ -88,7 +88,7 @@ class LauncherPreferences(val context: Application, version: Int = 3) {
var iconShape by EnumPreference("icon_shape", default = IconShape.PLATFORM_DEFAULT)
var firstRunVersion by IntPreference("first_run_version", default = 0)
var cardBackground by EnumPreference("card_background", default = CardBackground.DEFAULT)
var colorScheme by EnumPreference("card_background", default = ColorSchemes.DEFAULT)
var cardOpacity by IntPreference("card_opacity", default = 0xFF)
var cardStrokeWidth by IntPreference("card_stroke_width", default = 0)
var cardRadius by IntPreference("card_radius", default = 8)
@ -169,11 +169,11 @@ enum class WeatherProviders(override val value: String) : PreferenceEnum {
}
}
enum class CardBackground(override val value: String) : PreferenceEnum {
enum class ColorSchemes(override val value: String) : PreferenceEnum {
DEFAULT("0"),
BLACK("2");
companion object {
fun byValue(value: String): CardBackground {
fun byValue(value: String): ColorSchemes {
return values().first { it.value == value }
}
}

View File

@ -57,6 +57,7 @@ dependencies {
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.uitooling)
implementation(libs.androidx.compose.material)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.compose.materialicons)
implementation(libs.androidx.compose.animation)
implementation(libs.androidx.compose.animationgraphics)

View File

@ -1,34 +1,28 @@
package de.mm20.launcher2.ui
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.material.darkColors
import androidx.compose.material.lightColors
import androidx.compose.material3.Typography
import androidx.compose.material3.lightColorScheme
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import de.mm20.launcher2.preferences.Settings
import de.mm20.launcher2.preferences.Settings.AppearanceSettings.Theme
import de.mm20.launcher2.preferences.dataStore
import de.mm20.launcher2.ui.locals.LocalColorScheme
import de.mm20.launcher2.ui.theme.colors.toDarkColorScheme
import de.mm20.launcher2.ui.theme.colors.toLightColorScheme
import kotlinx.coroutines.flow.map
val lightPalette = lightColors(
primary = Color(0, 114, 255)
)
val darkPalette = darkColors(
primary = Color(0, 114, 255)
)
val Inter = FontFamily(
Font(R.font.inter_thin, FontWeight.Thin),
Font(R.font.inter_extralight, FontWeight.ExtraLight),
@ -43,193 +37,80 @@ val Inter = FontFamily(
val typography = Typography(
h1 = TextStyle(
fontSize = 96.sp,
fontWeight = FontWeight.Light,
fontFamily = Inter
),
h2 = TextStyle(
fontSize = 60.sp,
fontWeight = FontWeight.Light,
fontFamily = Inter
),
h3 = TextStyle(
fontSize = 48.sp,
fontWeight = FontWeight.Normal,
fontFamily = Inter
),
h4 = TextStyle(
fontSize = 34.sp,
fontWeight = FontWeight.Normal,
fontFamily = Inter
),
h5 = TextStyle(
fontSize = 24.sp,
fontWeight = FontWeight.Medium,
fontFamily = Inter
),
h6 = TextStyle(
fontSize = 20.sp,
fontWeight = FontWeight.Bold,
fontFamily = Inter
),
caption = TextStyle(
displayLarge = TextStyle(
fontFamily = Inter,
fontSize = 13.sp
fontSize = 57.sp,
fontWeight = FontWeight.Normal,
),
subtitle1 = TextStyle(
displayMedium = TextStyle(
fontFamily = Inter,
fontSize = 45.sp,
fontWeight = FontWeight.Normal,
),
displaySmall = TextStyle(
fontFamily = Inter,
fontSize = 36.sp,
fontWeight = FontWeight.Normal,
),
headlineLarge = TextStyle(
fontFamily = Inter,
fontSize = 32.sp,
fontWeight = FontWeight.Normal,
),
headlineMedium = TextStyle(
fontFamily = Inter,
fontSize = 28.sp,
fontWeight = FontWeight.Normal,
),
headlineSmall = TextStyle(
fontFamily = Inter,
fontSize = 24.sp,
fontWeight = FontWeight.Normal,
),
titleLarge = TextStyle(
fontFamily = Inter,
fontSize = 22.sp,
fontWeight = FontWeight.Normal,
),
titleMedium = TextStyle(
fontFamily = Inter,
fontSize = 16.sp,
fontWeight = FontWeight.Bold,
fontWeight = FontWeight.Medium,
),
subtitle2 = TextStyle(
titleSmall = TextStyle(
fontFamily = Inter,
fontWeight = FontWeight.SemiBold,
fontSize = 14.sp,
fontWeight = FontWeight.Medium,
),
body1 = TextStyle(
fontSize = 13.sp
bodyLarge = TextStyle(
fontSize = 16.sp,
fontWeight = FontWeight.Normal,
),
bodyMedium = TextStyle(
fontSize = 14.sp,
fontWeight = FontWeight.Normal,
),
bodySmall = TextStyle(
fontSize = 12.sp,
fontWeight = FontWeight.Normal,
),
labelLarge = TextStyle(
fontFamily = Inter,
fontSize = 14.sp,
fontWeight = FontWeight.Medium,
),
labelMedium = TextStyle(
fontFamily = Inter,
fontSize = 12.sp,
fontWeight = FontWeight.Medium,
),
labelSmall = TextStyle(
fontFamily = Inter,
fontSize = 11.sp,
fontWeight = FontWeight.Medium,
),
body2 = TextStyle(
fontSize = 12.sp
)
)
val shapes = Shapes(
medium = RoundedCornerShape(8.dp)
)
val Colors.red: Color
get() = if (isLight) Color(0xFFE53935) else Color(0xFFE57373)
val Colors.pink: Color
get() = if (isLight) Color(0xFFD81B60) else Color(0xFFF06292)
val Colors.purple: Color
get() = if (isLight) Color(0xFF8E24AA) else Color(0xFFBA68C8)
val Colors.deepPurple: Color
get() = if (isLight) Color(0xFF5E35B1) else Color(0xFF9575CD)
val Colors.indigo: Color
get() = if (isLight) Color(0xFF3949AB) else Color(0xFF7986CB)
val Colors.blue: Color
get() = if (isLight) Color(0xFF039BE5) else Color(0xFF4FC3F7)
val Colors.lightBlue: Color
get() = if (isLight) Color(0xFF1E88E5) else Color(0xFF64B5F6)
val Colors.cyan: Color
get() = if (isLight) Color(0xFF00ACC1) else Color(0xFF4DD0E1)
val Colors.teal: Color
get() = if (isLight) Color(0xFF00897B) else Color(0xFF4DB6AC)
val Colors.green: Color
get() = if (isLight) Color(0xFF388E3C) else Color(0xFF81C784)
val Colors.lightGreen: Color
get() = if (isLight) Color(0xFF7CB342) else Color(0xFFAED581)
val Colors.lime: Color
get() = if (isLight) Color(0xFFC0CA33) else Color(0xFFDCE775)
val Colors.yellow: Color
get() = if (isLight) Color(0xFFFDD835) else Color(0xFFFFF176)
val Colors.amber: Color
get() = if (isLight) Color(0xFFFFB300) else Color(0xFFFFD54F)
val Colors.orange: Color
get() = if (isLight) Color(0xFFFB8C00) else Color(0xFFFFB74D)
val Colors.deepOrange: Color
get() = if (isLight) Color(0xFFF4511E) else Color(0xFFFF8A65)
val Colors.brown: Color
get() = if (isLight) Color(0xFF6D4C41) else Color(0xFFA1887F)
val Colors.gray: Color
get() = if (isLight) Color(0xFF757575) else Color(0xFFE0E0E0)
val Colors.blueGray: Color
get() = if (isLight) Color(0xFF546E7A) else Color(0xFF90A4AE)
val Colors.androidGreen: Color
get() = if (isLight) Color(0xFF00A55B) else Color(0xFF00DE7A)
val Colors.weatherSkyClear: Color
get() = Color(0xff4482ac)
val Colors.weatherSkyClearNight: Color
get() = deepPurple
val Colors.weatherSkyCloudy: Color
get() = gray
val Colors.weatherSkyCloudyNight: Color
get() = gray
val Colors.weatherSkyThunder: Color
get() = gray
val Colors.weatherSkyThunderNight: Color
get() = gray
val Colors.weatherCloudLight1: Color
get() = Color(0xFFECEFF1)
val Colors.weatherCloudLight2: Color
get() = if (isLight) Color(0xFF90A4AE) else Color(0xFFCFD8DC)
val Colors.weatherCloudMedium1: Color
get() = if (isLight) Color(0xFF546E7A) else Color(0xFF78909C)
val Colors.weatherCloudMedium2: Color
get() = if (isLight) Color(0xFF455a64) else Color(0xFF607D8B)
val Colors.weatherCloudDark1: Color
get() = if (isLight) Color(0xFF37474F) else Color(0xFF546E7A)
val Colors.weatherCloudDark2: Color
get() = if (isLight) Color(0xFF263238) else Color(0xFF455A64)
val Colors.weatherSun: Color
get() = amber
val Colors.weatherMoon: Color
get() = if (isLight) Color(0xFF9E9E9E) else Color(0xFFE0E0E0)
val Colors.weatherBolt: Color
get() = amber
val Colors.weatherHot: Color
get() = red
val Colors.weatherCold: Color
get() = lightBlue
val Colors.weatherWind: Color
get() = if (isLight) Color(0xFF90A4AE) else Color(0xFFCFD8DC)
val Colors.weatherWindDark: Color
get() = if (isLight) Color(0xFF546E7A) else Color(0xFF78909C)
val Colors.weatherRain: Color
get() = blue
val Colors.weatherHail: Color
get() = if (isLight) Color(0xFFBBDEFB) else Color(0xFFE3F2FD)
val Colors.weatherSnow: Color
get() = if (isLight) Color(0xFFE0E0E0) else Color(0xFFF5F5F5)
val Colors.weatherFog: Color
get() = weatherCloudLight2
@Composable
fun LauncherTheme(content: @Composable () -> Unit) {
@ -244,33 +125,20 @@ fun LauncherTheme(content: @Composable () -> Unit) {
val colorScheme = LocalColorScheme.current
val colors = if (darkTheme) {
darkColors(
onSurface = colorScheme.neutral2.shade10,
surface = colorScheme.neutral2.shade800,
onBackground = colorScheme.neutral2.shade10,
background = colorScheme.neutral2.shade900,
primary = colorScheme.accent1.shade300,
primaryVariant = colorScheme.accent1.shade400,
secondary = colorScheme.accent2.shade300,
secondaryVariant = colorScheme.accent3.shade300,
)
colorScheme.toDarkColorScheme()
} else {
lightColors(
surface = colorScheme.neutral1.shade0,
onSurface = colorScheme.neutral2.shade1000,
onBackground = colorScheme.neutral2.shade1000,
background = colorScheme.neutral1.shade50,
primary = colorScheme.accent1.shade600,
primaryVariant = colorScheme.accent1.shade700,
secondary = colorScheme.accent2.shade600,
secondaryVariant = colorScheme.accent3.shade600,
colorScheme.toLightColorScheme()
}
androidx.compose.material.MaterialTheme(
colors = if (darkTheme) darkColors() else lightColors()
) {
MaterialTheme(
colorScheme = colors,
typography = typography,
content = content
)
}
MaterialTheme(
colors = colors,
typography = typography,
shapes = shapes,
content = content
)
}

View File

@ -15,11 +15,11 @@ fun ColorSchemeTest() {
Card {
Column {
SwatchRow(swatch = colorScheme.neutral1)
SwatchRow(swatch = colorScheme.neutral2)
SwatchRow(swatch = colorScheme.accent1)
SwatchRow(swatch = colorScheme.accent2)
SwatchRow(swatch = colorScheme.accent3)
SwatchRow(swatch = colorScheme.neutral)
SwatchRow(swatch = colorScheme.neutralVariant)
SwatchRow(swatch = colorScheme.primary)
SwatchRow(swatch = colorScheme.secondary)
SwatchRow(swatch = colorScheme.tertiary)
}
}
}
@ -31,42 +31,42 @@ fun SwatchRow(swatch: ColorSwatch) {
) {
Box(modifier = Modifier
.height(24.dp).weight(1f)
.background(swatch.shade0))
.background(swatch.shade100))
Box(modifier = Modifier
.height(24.dp).weight(1f)
.background(swatch.shade10))
.background(swatch.shade99))
Box(modifier = Modifier
.height(24.dp).weight(1f)
.background(swatch.shade95))
Box(modifier = Modifier
.height(24.dp).weight(1f)
.background(swatch.shade90))
Box(modifier = Modifier
.height(24.dp).weight(1f)
.background(swatch.shade80))
Box(modifier = Modifier
.height(24.dp).weight(1f)
.background(swatch.shade70))
Box(modifier = Modifier
.height(24.dp).weight(1f)
.background(swatch.shade60))
Box(modifier = Modifier
.height(24.dp).weight(1f)
.background(swatch.shade50))
Box(modifier = Modifier
.height(24.dp).weight(1f)
.background(swatch.shade100))
.background(swatch.shade40))
Box(modifier = Modifier
.height(24.dp).weight(1f)
.background(swatch.shade200))
.background(swatch.shade30))
Box(modifier = Modifier
.height(24.dp).weight(1f)
.background(swatch.shade300))
.background(swatch.shade20))
Box(modifier = Modifier
.height(24.dp).weight(1f)
.background(swatch.shade400))
.background(swatch.shade10))
Box(modifier = Modifier
.height(24.dp).weight(1f)
.background(swatch.shade500))
Box(modifier = Modifier
.height(24.dp).weight(1f)
.background(swatch.shade600))
Box(modifier = Modifier
.height(24.dp).weight(1f)
.background(swatch.shade700))
Box(modifier = Modifier
.height(24.dp).weight(1f)
.background(swatch.shade800))
Box(modifier = Modifier
.height(24.dp).weight(1f)
.background(swatch.shade900))
Box(modifier = Modifier
.height(24.dp).weight(1f)
.background(swatch.shade1000))
.background(swatch.shade0))
}
}

View File

@ -4,7 +4,10 @@ import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.*
import androidx.compose.material.Card
import androidx.compose.material.ContentAlpha
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Modifier
@ -27,7 +30,7 @@ fun InformationText(
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
Text(
text = text,
style = MaterialTheme.typography.body2,
style = MaterialTheme.typography.bodyMedium,
modifier = (if (onClick != null) Modifier.clickable(onClick = onClick) else Modifier).padding(12.dp)
)
}

View File

@ -1,57 +1,73 @@
package de.mm20.launcher2.ui
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Typography
import androidx.compose.material.darkColors
import androidx.compose.material.lightColors
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
val legacyTypography = Typography(
h1 = TextStyle(
fontSize = 96.sp,
fontWeight = FontWeight.Light,
),
h2 = TextStyle(
fontSize = 60.sp,
fontWeight = FontWeight.Light,
),
h3 = TextStyle(
fontSize = 48.sp,
displayLarge = TextStyle(
fontSize = 57.sp,
fontWeight = FontWeight.Normal,
),
h4 = TextStyle(
fontSize = 34.sp,
displayMedium = TextStyle(
fontSize = 45.sp,
fontWeight = FontWeight.Normal,
),
h5 = TextStyle(
displaySmall = TextStyle(
fontSize = 36.sp,
fontWeight = FontWeight.Normal,
),
headlineLarge = TextStyle(
fontSize = 32.sp,
fontWeight = FontWeight.Normal,
),
headlineMedium = TextStyle(
fontSize = 28.sp,
fontWeight = FontWeight.Normal,
),
headlineSmall = TextStyle(
fontSize = 24.sp,
fontWeight = FontWeight.Normal,
),
titleLarge = TextStyle(
fontSize = 22.sp,
fontWeight = FontWeight.Normal,
),
titleMedium = TextStyle(
fontSize = 16.sp,
fontWeight = FontWeight.Medium,
),
h6 = TextStyle(
fontSize = 20.sp,
fontWeight = FontWeight.Bold,
),
caption = TextStyle(
fontSize = 13.sp
),
subtitle1 = TextStyle(
fontSize = 16.sp,
fontWeight = FontWeight.Bold,
),
subtitle2 = TextStyle(
fontWeight = FontWeight.SemiBold,
titleSmall = TextStyle(
fontSize = 14.sp,
fontWeight = FontWeight.Medium,
),
body1 = TextStyle(
fontSize = 14.sp
bodyLarge = TextStyle(
fontSize = 16.sp,
fontWeight = FontWeight.Normal,
),
bodyMedium = TextStyle(
fontSize = 14.sp,
fontWeight = FontWeight.Normal,
),
bodySmall = TextStyle(
fontSize = 12.sp,
fontWeight = FontWeight.Normal,
),
labelLarge = TextStyle(
fontSize = 14.sp,
fontWeight = FontWeight.Medium,
),
labelMedium = TextStyle(
fontSize = 12.sp,
fontWeight = FontWeight.Medium,
),
labelSmall = TextStyle(
fontSize = 11.sp,
fontWeight = FontWeight.Medium,
),
body2 = TextStyle(
fontSize = 13.sp
)
)
@Composable
@ -59,6 +75,6 @@ fun LegacyLauncherTheme(content: @Composable () -> Unit) {
MaterialTheme(
typography = legacyTypography,
content = content,
colors = if (isSystemInDarkTheme()) darkColors() else lightColors()
colorScheme = if (isSystemInDarkTheme()) darkColorScheme() else lightColorScheme()
)
}

View File

@ -8,9 +8,9 @@ import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.layout.size
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -85,7 +85,7 @@ fun ShapedLauncherIcon(
Surface(
shape = iconShape,
elevation = animateDpAsState(if (isPressed) 4.dp else 1.dp).value,
shadowElevation = animateDpAsState(if (isPressed) 4.dp else 1.dp).value,
modifier = modifier
.requiredSize(size)
) {
@ -94,7 +94,7 @@ fun ShapedLauncherIcon(
.requiredSize(size)
.background(
color = if (icon == null) {
placeholder.color.copy(alpha = 0.4f).compositeOver(MaterialTheme.colors.surface)
placeholder.color.copy(alpha = 0.4f).compositeOver(MaterialTheme.colorScheme.surface)
} else {
Color.Gray
}

View File

@ -59,24 +59,24 @@ class ComposeActivity : AppCompatActivity() {
.collectAsState(initial = Settings.AppearanceSettings.ColorScheme.Default)
val colorScheme = when (colorSchemePreference) {
Settings.AppearanceSettings.ColorScheme.MM20 -> MM20ColorScheme()
Settings.AppearanceSettings.ColorScheme.MM20 -> MM20ColorPalette()
Settings.AppearanceSettings.ColorScheme.Wallpaper -> {
if (isAtLeastApiLevel(Build.VERSION_CODES.O_MR1)) {
val wallpaperColors by wallpaperColorsAsState()
WallpaperColorScheme(wallpaperColors)
} else DefaultColorScheme()
WallpaperColorPalette(wallpaperColors)
} else DefaultColorPalette()
}
Settings.AppearanceSettings.ColorScheme.MaterialYou -> {
if (isAtLeastApiLevel(Build.VERSION_CODES.S)) {
SystemColorScheme(context)
} else DefaultColorScheme()
SystemColorPalette(context)
} else DefaultColorPalette()
}
Settings.AppearanceSettings.ColorScheme.BlackAndWhite -> BlackWhiteColorScheme()
Settings.AppearanceSettings.ColorScheme.BlackAndWhite -> BlackWhiteColorPalette()
Settings.AppearanceSettings.ColorScheme.Custom -> {
val customColors by customColorsAsState()
CustomColorScheme(customColors)
CustomColorPalette(customColors)
}
else -> DefaultColorScheme()
else -> DefaultColorPalette()
}

View File

@ -1,23 +0,0 @@
package de.mm20.launcher2.ui.compat
import androidx.annotation.DrawableRes
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.painter.ColorPainter
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.painterResource
import de.mm20.launcher2.ui.R
@Composable
fun animatedVectorResource(@DrawableRes id: Int): AnimatedVectorResourceStub {
return AnimatedVectorResourceStub(id)
}
class AnimatedVectorResourceStub(
val res: Int
) {
@Composable
fun painterFor(atEnd: Boolean): Painter {
return ColorPainter(MaterialTheme.colors.onSurface)
}
}

View File

@ -4,7 +4,7 @@ import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.padding
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
@ -15,7 +15,7 @@ fun Chip(
) {
Row(
modifier = Modifier
.border(1.dp, MaterialTheme.colors.onSurface.copy(alpha = 0.1f), shape = MaterialTheme.shapes.large)
.border(1.dp, MaterialTheme.colorScheme.onSurface.copy(alpha = 0.1f))
.padding(horizontal = 16.dp, vertical = 8.dp),
content = content

View File

@ -5,10 +5,10 @@ import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.LocalContentColor
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -37,7 +37,7 @@ fun DigitalClock(time: Long) {
Text(
modifier = Modifier.padding(4.dp),
text = format.format(time),
style = MaterialTheme.typography.h1.copy(
style = MaterialTheme.typography.displayLarge.copy(
fontSize = 100.sp,
fontWeight = FontWeight.Black,
textAlign = TextAlign.Center,
@ -86,12 +86,12 @@ fun AnalogClock(time: Long) {
date.timeInMillis = time
val minute = date[Calendar.MINUTE]
val hour = date[Calendar.HOUR]
val dark = !MaterialTheme.colors.isLight
val dark = true//!MaterialTheme.colors.isLight
val cs = LocalColorScheme.current
val bgColor = if (dark) cs.accent1.shade800 else cs.accent1.shade200
val hourColor = if (dark) cs.accent1.shade300 else cs.accent1.shade600
val minuteColor = if (dark) cs.accent1.shade200 else cs.accent1.shade700
val textColor = if (dark) cs.accent1.shade500 else cs.accent1.shade400
val bgColor = if (dark) cs.primary.shade20 else cs.primary.shade80
val hourColor = if (dark) cs.primary.shade70 else cs.primary.shade40
val minuteColor = if (dark) cs.primary.shade80 else cs.primary.shade30
val textColor = if (dark) cs.primary.shade50 else cs.primary.shade60
val hourAngle = 30f * hour + 0.5f * minute
val minuteAngle = 6f * minute
@ -102,7 +102,7 @@ fun AnalogClock(time: Long) {
.size(156.dp),
shape = CircleShape,
color = bgColor,
elevation = 8.dp
shadowElevation = 8.dp
) {
Box(
modifier = Modifier.fillMaxSize()
@ -110,7 +110,7 @@ fun AnalogClock(time: Long) {
Text(
text = "12",
style = MaterialTheme.typography.subtitle1.copy(
style = MaterialTheme.typography.headlineMedium.copy(
fontSize = 32.sp,
lineHeight = 32.sp,
),
@ -121,7 +121,7 @@ fun AnalogClock(time: Long) {
)
Text(
text = "3",
style = MaterialTheme.typography.subtitle1.copy(
style = MaterialTheme.typography.headlineMedium.copy(
fontSize = 32.sp
),
color = textColor,
@ -131,7 +131,7 @@ fun AnalogClock(time: Long) {
)
Text(
text = "6",
style = MaterialTheme.typography.subtitle1.copy(
style = MaterialTheme.typography.headlineMedium.copy(
fontSize = 32.sp
),
color = textColor,
@ -141,7 +141,7 @@ fun AnalogClock(time: Long) {
)
Text(
text = "9",
style = MaterialTheme.typography.subtitle1.copy(
style = MaterialTheme.typography.headlineMedium.copy(
fontSize = 32.sp
),
color = textColor,

View File

@ -2,10 +2,10 @@ package de.mm20.launcher2.ui.component
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material.OutlinedTextField
import androidx.compose.material.Slider
import androidx.compose.material.Text
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -82,7 +82,7 @@ fun ColorPicker(
Text(
"Hex: ",
modifier = Modifier.weight(2f),
style = MaterialTheme.typography.subtitle2
style = MaterialTheme.typography.titleMedium
)
OutlinedTextField(
value = hex,
@ -114,7 +114,7 @@ private fun SliderRow(
Text(
label,
modifier = Modifier.weight(1f),
style = MaterialTheme.typography.subtitle2
style = MaterialTheme.typography.titleMedium
)
Box(
modifier = Modifier.weight(7f)

View File

@ -13,6 +13,8 @@ import androidx.compose.material.icons.rounded.Star
import androidx.compose.material.icons.rounded.StarBorder
import androidx.compose.material.icons.rounded.Visibility
import androidx.compose.material.icons.rounded.VisibilityOff
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
@ -24,7 +26,6 @@ import androidx.compose.ui.res.colorResource
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import de.mm20.launcher2.favorites.FavoritesViewModel
import de.mm20.launcher2.search.data.Searchable
import de.mm20.launcher2.ui.R
@ -45,7 +46,7 @@ fun DefaultSwipeActions(
val isPinned by viewModel.isPinned(item).observeAsState()
val isHidden by viewModel.isHidden(item).observeAsState()
val state = rememberSwipeableState(
val state = androidx.compose.material.rememberSwipeableState(
SwipeAction.Default,
confirmStateChange = {
if (it == SwipeAction.Favorites) {
@ -96,7 +97,7 @@ fun DefaultSwipeActions(
modifier = Modifier.matchParentSize()
) {
Card(
backgroundColor = MaterialTheme.colors.onSurface.copy(alpha = ContentAlpha.divider),
backgroundColor = MaterialTheme.colorScheme.onSurface.copy(alpha = ContentAlpha.divider),
modifier = Modifier.fillMaxSize(),
elevation = 0.dp
) {
@ -132,7 +133,7 @@ fun DefaultSwipeActions(
Icons.Rounded.VisibilityOff
}
},
tint = animateColorAsState(if (isDismissing) MaterialTheme.colors.onPrimary else MaterialTheme.colors.onSurface).value,
tint = animateColorAsState(if (isDismissing) MaterialTheme.colorScheme.onPrimary else MaterialTheme.colorScheme.onSurface).value,
modifier = Modifier
.padding(horizontal = 16.dp)
.scale(animateFloatAsState(if (isDismissing) 1.2f else 1f).value),

View File

@ -4,7 +4,7 @@ package de.mm20.launcher2.ui.component
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.layout.size
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material3.LocalContentAlpha
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha

View File

@ -8,8 +8,14 @@ import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.BasicText
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.material.*
import androidx.compose.material3.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Search
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -142,7 +148,7 @@ fun SearchBar(
}) {
Text(
stringResource(id = R.string.wallpaper),
style = MaterialTheme.typography.subtitle2
style = MaterialTheme.typography.titleMedium
)
}
DropdownMenuItem(onClick = {
@ -151,7 +157,7 @@ fun SearchBar(
}) {
Text(
stringResource(id = R.string.title_activity_settings),
style = MaterialTheme.typography.subtitle2
style = MaterialTheme.typography.titleMedium
)
}
}

View File

@ -7,8 +7,8 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.material.Divider
import androidx.compose.material.LocalContentColor
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Modifier
@ -26,7 +26,7 @@ fun SearchColumn(
Box(
modifier = modifier
.background(MaterialTheme.colors.background)
.background(MaterialTheme.colorScheme.background)
.fillMaxHeight()
.statusBarsPadding()
.navigationBarsWithImePadding()
@ -39,7 +39,7 @@ fun SearchColumn(
val wikipedia = wikipediaResult()
CompositionLocalProvider(LocalContentColor provides MaterialTheme.colors.onSurface) {
CompositionLocalProvider(LocalContentColor provides MaterialTheme.colorScheme.onSurface) {
LazyColumn(
contentPadding = PaddingValues(8.dp),
state = listState

View File

@ -5,8 +5,8 @@ import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.text.format.DateUtils
import androidx.compose.material.LocalTextStyle
import androidx.compose.material.Text
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color

View File

@ -2,7 +2,9 @@ package de.mm20.launcher2.ui.component
import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.material.DropdownMenu
import androidx.compose.material.DropdownMenuItem
import androidx.compose.material3.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.*
import androidx.compose.runtime.*
@ -103,7 +105,7 @@ fun ColumnScope.OverflowMenuItems(items: List<ToolbarAction>, onDismiss: () -> U
) {
Text(
action.label, modifier = Modifier.weight(1f),
style = MaterialTheme.typography.subtitle2
style = MaterialTheme.typography.titleMedium
)
Icon(imageVector = Icons.Rounded.ArrowRight, contentDescription = null)
}
@ -114,7 +116,7 @@ fun ColumnScope.OverflowMenuItems(items: List<ToolbarAction>, onDismiss: () -> U
) {
Text(
action.label,
style = MaterialTheme.typography.subtitle2
style = MaterialTheme.typography.titleMedium
)
}
}
@ -125,7 +127,7 @@ fun ColumnScope.OverflowMenuItems(items: List<ToolbarAction>, onDismiss: () -> U
}) {
Text(
action.label,
style = MaterialTheme.typography.subtitle2
style = MaterialTheme.typography.titleMedium
)
}
}

View File

@ -9,7 +9,7 @@ import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.*
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
@ -48,7 +48,7 @@ fun WidgetColumn(
widgets = viewModel.getWidgets()
}
val isLightTheme = MaterialTheme.colors.isLight
val isLightTheme = androidx.compose.material.MaterialTheme.colors.isLight
val windowHeight = LocalWindowSize.current.height
@ -60,7 +60,7 @@ fun WidgetColumn(
.background(
Brush.verticalGradient(
background to Color.Transparent,
background to MaterialTheme.colors.background
background to MaterialTheme.colorScheme.background
)
)
) {
@ -94,7 +94,7 @@ fun WidgetColumn(
icon = {
Icon(painter = icon.painterFor(atEnd = editMode), contentDescription = null)
},
backgroundColor = MaterialTheme.colors.surface,
containerColor = MaterialTheme.colorScheme.tertiaryContainer,
onClick = {
editMode = !editMode
})

View File

@ -5,7 +5,8 @@ import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.*
import androidx.compose.material.Card
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@ -53,7 +54,7 @@ fun ColorPreference(
) {
Text(
text = title,
style = MaterialTheme.typography.h6,
style = MaterialTheme.typography.headlineMedium,
modifier = Modifier.padding(
start = 24.dp, end = 24.dp, top = 16.dp, bottom = 8.dp
)
@ -86,7 +87,6 @@ fun ColorPreference(
fun ColorPreview(color: Color) {
Surface(
modifier = Modifier.size(32.dp),
elevation = 0.dp,
shape = RoundedCornerShape(16.dp),
color = color
) {}

View File

@ -4,7 +4,9 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.*
import androidx.compose.material.Card
import androidx.compose.material.RadioButton
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -45,7 +47,7 @@ fun <T> ListPreference(
) {
Text(
text = title,
style = MaterialTheme.typography.h6,
style = MaterialTheme.typography.headlineMedium,
modifier = Modifier.padding(
start = 24.dp, end = 24.dp, top = 16.dp, bottom = 8.dp
)

View File

@ -2,7 +2,9 @@ package de.mm20.launcher2.ui.component.preferences
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.material.ContentAlpha
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
@ -39,18 +41,18 @@ fun Preference(
modifier = Modifier.padding(start = 4.dp),
imageVector = icon,
contentDescription = null,
tint = MaterialTheme.colors.primary,
tint = MaterialTheme.colorScheme.primary,
)
}
}
Column(
modifier = Modifier.weight(1f)
) {
Text(text = title, style = MaterialTheme.typography.subtitle2)
Text(text = title, style = MaterialTheme.typography.titleMedium)
if (summary != null) {
Text(
text = summary,
style = MaterialTheme.typography.body1,
style = MaterialTheme.typography.bodyMedium,
modifier = Modifier.padding(top = 1.dp)
)
}

View File

@ -1,9 +1,9 @@
package de.mm20.launcher2.ui.component.preferences
import androidx.compose.foundation.layout.*
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
@ -15,7 +15,8 @@ fun PreferenceCategory(
content: @Composable ColumnScope.() -> Unit
) {
Surface(
elevation = 2.dp,
shadowElevation = 2.dp,
tonalElevation = 2.dp,
modifier = Modifier.padding(bottom = 4.dp).fillMaxWidth()
) {
Column {
@ -27,8 +28,8 @@ fun PreferenceCategory(
Text(
modifier = Modifier.padding(start = 56.dp),
text = title,
style = MaterialTheme.typography.subtitle2,
color = MaterialTheme.colors.primary
style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.primary
)
}
}

View File

@ -5,9 +5,9 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.ArrowBack
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@ -15,24 +15,23 @@ import com.google.accompanist.insets.systemBarsPadding
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import de.mm20.launcher2.ui.locals.LocalNavController
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun PreferenceScreen(
title: String,
scaffoldState: ScaffoldState = rememberScaffoldState(),
content: LazyListScope.() -> Unit
) {
val navController = LocalNavController.current
val systemUiController = rememberSystemUiController()
systemUiController.setStatusBarColor(MaterialTheme.colors.surface)
systemUiController.setStatusBarColor(MaterialTheme.colorScheme.surface)
systemUiController.setNavigationBarColor(Color.Black)
Box(
modifier = Modifier.systemBarsPadding()
) {
Scaffold(
scaffoldState = scaffoldState,
topBar = {
TopAppBar(
backgroundColor = MaterialTheme.colors.surface,
SmallTopAppBar(
title = {
Text(title)
},
@ -42,14 +41,14 @@ fun PreferenceScreen(
}) {
Icon(imageVector = Icons.Rounded.ArrowBack, contentDescription = "Back")
}
}
},
)
}) {
LazyColumn(
modifier = Modifier
.fillMaxSize()
.padding(it),
content = content
content = content,
)
}
}

View File

@ -1,6 +1,6 @@
package de.mm20.launcher2.ui.component.preferences
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material.Switch
import androidx.compose.material.SwitchDefaults
import androidx.compose.runtime.Composable
@ -25,7 +25,7 @@ fun SwitchPreference(
},
controls = {
Switch(checked = value, onCheckedChange = onValueChanged, colors = SwitchDefaults.colors(
uncheckedThumbColor = MaterialTheme.colors.onSurface
uncheckedThumbColor = MaterialTheme.colorScheme.onSurface
))
}
)

View File

@ -1,11 +1,12 @@
package de.mm20.launcher2.ui.icons
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.colorResource
import de.mm20.launcher2.search.data.Application
import de.mm20.launcher2.search.data.File
import de.mm20.launcher2.search.data.Searchable
@ -31,7 +32,7 @@ fun Searchable.getPlaceholderIcon(): PlaceholderIcon {
@Composable
fun Application.getPlaceholderIcon(): PlaceholderIcon {
return PlaceholderIcon(
MaterialTheme.colors.androidGreen,
colorResource(id = R.color.android_green),
Icons.Rounded.Android
)
}
@ -40,19 +41,19 @@ fun Application.getPlaceholderIcon(): PlaceholderIcon {
fun File.getPlaceholderIcon(): PlaceholderIcon {
return when {
isDirectory -> PlaceholderIcon(
MaterialTheme.colors.lightBlue,
colorResource(id = R.color.lightblue),
Icons.Rounded.Folder
)
mimeType.startsWith("image/") -> PlaceholderIcon(
MaterialTheme.colors.teal,
colorResource(id = R.color.teal),
Icons.Rounded.Image
)
mimeType.startsWith("audio/") -> PlaceholderIcon(
MaterialTheme.colors.orange,
colorResource(id = R.color.orange),
Icons.Rounded.Audiotrack
)
mimeType.startsWith("video/") -> PlaceholderIcon(
MaterialTheme.colors.purple,
colorResource(id = R.color.purple),
Icons.Rounded.Movie
)
/*
@ -66,7 +67,7 @@ fun File.getPlaceholderIcon(): PlaceholderIcon {
}*/
else -> when (mimeType) {
"application/pdf" -> PlaceholderIcon(
MaterialTheme.colors.red,
colorResource(id = R.color.red),
Icons.Rounded.Pdf
)
"application/zip",
@ -78,7 +79,7 @@ fun File.getPlaceholderIcon(): PlaceholderIcon {
"application/x-zip-compressed",
"application/x-gzip",
"application/x-bzip2" -> PlaceholderIcon(
MaterialTheme.colors.brown,
colorResource(id = R.color.brown),
Icons.Rounded.Archive
)
"application/vnd.oasis.opendocument.text",
@ -88,7 +89,7 @@ fun File.getPlaceholderIcon(): PlaceholderIcon {
"application/x-iwork-pages-sffpages",
"application/vnd.apple.pages",
"application/vnd.google-apps.document" -> PlaceholderIcon(
MaterialTheme.colors.blue,
colorResource(id = R.color.blue),
Icons.Rounded.Notes
)
"application/vnd.oasis.opendocument.spreadsheet",
@ -97,7 +98,7 @@ fun File.getPlaceholderIcon(): PlaceholderIcon {
"application/x-iwork-numbers-sffnumbers",
"application/vnd.apple.numbers",
"application/vnd.google-apps.spreadsheet" -> PlaceholderIcon(
MaterialTheme.colors.lightGreen,
colorResource(id = R.color.lightgreen),
Icons.Rounded.BorderAll
)
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
@ -105,11 +106,11 @@ fun File.getPlaceholderIcon(): PlaceholderIcon {
"application/x-iwork-keynote-sffkey",
"application/vnd.apple.keynote",
"application/vnd.google-apps.presentation" -> PlaceholderIcon(
MaterialTheme.colors.amber,
colorResource(id = R.color.amber),
Icons.Rounded.Slideshow
)
"application/vnd.android.package-archive" -> PlaceholderIcon(
MaterialTheme.colors.androidGreen,
colorResource(id = R.color.android_green),
Icons.Rounded.Android
)
"text/x-asm",
@ -120,24 +121,24 @@ fun File.getPlaceholderIcon(): PlaceholderIcon {
"text/x-script.perl",
"text/javascript",
"application/json" -> PlaceholderIcon(
MaterialTheme.colors.pink,
colorResource(id = R.color.pink),
Icons.Rounded.Code
)
"text/xml",
"text/html" -> PlaceholderIcon(
MaterialTheme.colors.deepOrange,
colorResource(id = R.color.deeporange),
Icons.Rounded.Code
)
"application/vnd.google-apps.form" -> PlaceholderIcon(
MaterialTheme.colors.deepPurple,
colorResource(id = R.color.deeppurple),
Icons.Rounded.ViewList
)
"application/epub+zip" -> PlaceholderIcon(
MaterialTheme.colors.blue,
colorResource(id = R.color.blue),
Icons.Rounded.Book
)
else -> PlaceholderIcon(
MaterialTheme.colors.blueGray,
colorResource(id = R.color.bluegrey),
Icons.Rounded.InsertDriveFile
)
}

View File

@ -272,7 +272,10 @@ class ApplicationDetailRepresentation : Representation, KoinComponent {
val viewModel : FavoritesViewModel by (context as AppCompatActivity).viewModel()
var count = 0
for (si in shortcuts) {
if (count > 4) break
count++
val view = Chip(context)
view.text = si.label
@ -282,6 +285,8 @@ class ApplicationDetailRepresentation : Representation, KoinComponent {
context.resources.displayMetrics.densityDpi
)
view.chipIconTint = null
view.chipStrokeWidth = 1 * context.dp
view.chipStrokeColor =
ContextCompat.getColorStateList(context, R.color.chip_stroke)

View File

@ -5,7 +5,6 @@ import android.content.res.ColorStateList
import android.util.AttributeSet
import com.google.android.material.card.MaterialCardView
import de.mm20.launcher2.ktx.dp
import de.mm20.launcher2.preferences.CardBackground
import de.mm20.launcher2.preferences.LauncherPreferences
import de.mm20.launcher2.ui.R
import kotlin.math.roundToInt
@ -41,12 +40,12 @@ open class LauncherCardView @JvmOverloads constructor(
}
init {
val cardColor = when (LauncherPreferences.instance.cardBackground) {
/*val cardColor = when (LauncherPreferences.instance.cardBackground) {
CardBackground.DEFAULT-> context.getColor(R.color.cardview_background)
CardBackground.BLACK -> context.getColor(R.color.cardview_background_black)
}
setCardBackgroundColor(cardColor)
strokeColor = cardColor
setCardBackgroundColor(cardColor)*/
strokeColor = cardBackgroundColor.defaultColor
strokeWidth = (LauncherPreferences.instance.cardStrokeWidth * dp).roundToInt()
radius = LauncherPreferences.instance.cardRadius * dp

View File

@ -9,8 +9,8 @@ import android.view.View
import android.widget.FrameLayout
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.layout.Column
import androidx.compose.material.LocalContentColor
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.platform.ComposeView
import androidx.core.app.NotificationManagerCompat
@ -59,7 +59,7 @@ class MusicWidget : LauncherWidget {
composeView.setContent {
LegacyLauncherTheme {
// TODO: Temporary solution until parent widget card is rewritten in Compose
CompositionLocalProvider(LocalContentColor provides MaterialTheme.colors.onSurface) {
CompositionLocalProvider(LocalContentColor provides MaterialTheme.colorScheme.onSurface) {
Column {
MusicWidget()
}

View File

@ -5,8 +5,8 @@ import android.util.AttributeSet
import android.view.View
import android.widget.FrameLayout
import androidx.compose.foundation.layout.Column
import androidx.compose.material.LocalContentColor
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.platform.ComposeView
import de.mm20.launcher2.ui.LegacyLauncherTheme
@ -44,7 +44,7 @@ class WeatherWidget : LauncherWidget {
composeView.setContent {
LegacyLauncherTheme {
// TODO: Temporary solution until parent widget card is rewritten in Compose
CompositionLocalProvider(LocalContentColor provides MaterialTheme.colors.onSurface) {
CompositionLocalProvider(LocalContentColor provides MaterialTheme.colorScheme.onSurface) {
Column {
WeatherWidget()
}

View File

@ -5,8 +5,8 @@ import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.geometry.Size
import androidx.navigation.NavController
import de.mm20.launcher2.ui.theme.WallpaperColors
import de.mm20.launcher2.ui.theme.colors.ColorScheme
import de.mm20.launcher2.ui.theme.colors.DefaultColorScheme
import de.mm20.launcher2.ui.theme.colors.ColorPalette
import de.mm20.launcher2.ui.theme.colors.DefaultColorPalette
val LocalWindowSize = compositionLocalOf { Size(0f, 0f) }
@ -14,6 +14,6 @@ val LocalAppWidgetHost = compositionLocalOf<AppWidgetHost?>(defaultFactory = { n
val LocalWallpaperColors = compositionLocalOf<WallpaperColors?> { null }
val LocalColorScheme = compositionLocalOf<ColorScheme> { DefaultColorScheme() }
val LocalColorScheme = compositionLocalOf<ColorPalette> { DefaultColorPalette() }
val LocalNavController = compositionLocalOf<NavController?> { null }

View File

@ -7,8 +7,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.rememberScrollState
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@ -31,7 +30,6 @@ import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.launch
@OptIn(
ExperimentalMaterialApi::class,
ExperimentalAnimationApi::class,
ExperimentalPagerApi::class,
InternalCoroutinesApi::class
@ -45,7 +43,7 @@ fun LauncherMainScreen() {
val searchColumnState = rememberLazyListState()
val widgetColumnState = rememberScrollState()
val isLightTheme = MaterialTheme.colors.isLight
val isLightTheme = androidx.compose.material.MaterialTheme.colors.isLight
val windowHeight = LocalWindowSize.current.height

View File

@ -2,11 +2,9 @@ package de.mm20.launcher2.ui.screens.settings
import android.content.Intent
import android.net.Uri
import androidx.compose.material.SnackbarDuration
import androidx.compose.material.SnackbarResult
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Info
import androidx.compose.material.rememberScaffoldState
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.platform.LocalContext
@ -27,15 +25,14 @@ import de.mm20.launcher2.ui.locals.LocalNavController
import kotlinx.coroutines.launch
import java.io.File
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SettingsAboutScreen() {
val context = LocalContext.current
val navController = LocalNavController.current
val scaffoldState = rememberScaffoldState()
val scope = rememberCoroutineScope()
PreferenceScreen(
title = stringResource(id = R.string.preference_screen_about),
scaffoldState = scaffoldState
) {
item {
PreferenceCategory {
@ -109,7 +106,7 @@ fun SettingsAboutScreen() {
onClick = {
scope.launch {
val path = DebugInformationDumper().dump(context)
val result = scaffoldState.snackbarHostState.showSnackbar(
/*val result = scaffoldState.snackbarHostState.showSnackbar(
context.getString(R.string.debug_export_information_file, path),
actionLabel = context.getString(R.string.menu_share),
duration = SnackbarDuration.Long
@ -125,7 +122,7 @@ fun SettingsAboutScreen() {
)
)
})
}
}*/
}
}
)
@ -134,7 +131,7 @@ fun SettingsAboutScreen() {
onClick = {
scope.launch {
val path = DebugInformationDumper().exportDatabases(context)
val result = scaffoldState.snackbarHostState.showSnackbar(
/*val result = scaffoldState.snackbarHostState.showSnackbar(
context.getString(R.string.debug_export_information_file, path),
actionLabel = context.getString(R.string.menu_share),
duration = SnackbarDuration.Long
@ -150,7 +147,7 @@ fun SettingsAboutScreen() {
)
)
})
}
}*/
}
}
)

View File

@ -3,7 +3,7 @@ package de.mm20.launcher2.ui.screens.settings
import android.os.Build
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.RadioButtonChecked
import androidx.compose.material.icons.rounded.RadioButtonUnchecked
@ -43,17 +43,17 @@ fun SettingsColorsScreen() {
val schemes = mutableListOf(
ColorSchemeItem(
ColorSchemeOption.Default,
DefaultColorScheme(),
DefaultColorPalette(),
stringResource(id = R.string.preference_colors_default)
),
ColorSchemeItem(
ColorSchemeOption.MM20,
MM20ColorScheme(),
MM20ColorPalette(),
stringResource(id = R.string.preference_colors_mm20)
),
ColorSchemeItem(
ColorSchemeOption.BlackAndWhite,
BlackWhiteColorScheme(),
BlackWhiteColorPalette(),
stringResource(id = R.string.preference_colors_bw)
)
)
@ -61,7 +61,7 @@ fun SettingsColorsScreen() {
schemes.add(
ColorSchemeItem(
ColorSchemeOption.MaterialYou,
SystemColorScheme(context),
SystemColorPalette(context),
stringResource(id = R.string.preference_colors_mdyou)
)
)
@ -71,7 +71,7 @@ fun SettingsColorsScreen() {
schemes.add(
ColorSchemeItem(
ColorSchemeOption.Wallpaper,
WallpaperColorScheme(wallpaperColors),
WallpaperColorPalette(wallpaperColors),
stringResource(id = R.string.preference_colors_wallpaper)
)
)
@ -79,7 +79,7 @@ fun SettingsColorsScreen() {
schemes.add(
ColorSchemeItem(
ColorSchemeOption.Custom,
CustomColorScheme(customColors),
CustomColorPalette(customColors),
stringResource(id = R.string.preference_colors_custom)
)
)
@ -89,7 +89,7 @@ fun SettingsColorsScreen() {
title = scheme.label,
icon = if (colorScheme == scheme.value) Icons.Rounded.RadioButtonChecked else Icons.Rounded.RadioButtonUnchecked,
controls = {
ColorSchemePreview(scheme.colorScheme)
ColorSchemePreview(scheme.colorPalette)
},
onClick = {
scope.launch {
@ -196,13 +196,13 @@ fun SettingsColorsScreen() {
}
@Composable
private fun ColorSchemePreview(colorScheme: ColorScheme) {
val isDark = !MaterialTheme.colors.isLight
val neutral1 = if (isDark) colorScheme.neutral1.shade800 else colorScheme.neutral1.shade100
val neutral2 = if (isDark) colorScheme.neutral2.shade800 else colorScheme.neutral2.shade100
val accent1 = if (isDark) colorScheme.accent1.shade300 else colorScheme.accent1.shade500
val accent2 = if (isDark) colorScheme.accent2.shade300 else colorScheme.accent2.shade500
val accent3 = if (isDark) colorScheme.accent3.shade300 else colorScheme.accent3.shade500
private fun ColorSchemePreview(colorPalette: ColorPalette) {
val isDark = !androidx.compose.material.MaterialTheme.colors.isLight
val neutral1 = if (isDark) colorPalette.neutral.shade20 else colorPalette.neutral.shade90
val neutral2 = if (isDark) colorPalette.neutralVariant.shade20 else colorPalette.neutralVariant.shade90
val accent1 = if (isDark) colorPalette.primary.shade70 else colorPalette.primary.shade50
val accent2 = if (isDark) colorPalette.secondary.shade70 else colorPalette.secondary.shade50
val accent3 = if (isDark) colorPalette.tertiary.shade70 else colorPalette.tertiary.shade50
Box(
modifier = Modifier.height(48.dp),
contentAlignment = Alignment.Center
@ -250,6 +250,6 @@ private fun ColorSchemePreview(colorScheme: ColorScheme) {
private data class ColorSchemeItem(
val value: ColorSchemeOption,
val colorScheme: ColorScheme,
val colorPalette: ColorPalette,
val label: String,
)

View File

@ -7,10 +7,10 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Icon
import androidx.compose.material.LocalContentColor
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.OpenInBrowser
import androidx.compose.runtime.Composable
@ -40,11 +40,11 @@ fun SettingsLicenseScreen(libraryName: String? = null) {
Column(
modifier = Modifier.padding(16.dp)
) {
Text(text = library.name, style = MaterialTheme.typography.subtitle1)
Text(text = library.name, style = MaterialTheme.typography.titleMedium)
library.description?.let { Text(text = it) }
}
CompositionLocalProvider(
LocalContentColor provides MaterialTheme.colors.primary
LocalContentColor provides MaterialTheme.colorScheme.primary
) {
Row(
modifier = Modifier
@ -61,7 +61,7 @@ fun SettingsLicenseScreen(libraryName: String? = null) {
Text(
modifier = Modifier.padding(start = 8.dp),
text = stringResource(id = R.string.open_webpage),
style = MaterialTheme.typography.button
style = MaterialTheme.typography.labelMedium
)
}
}
@ -74,7 +74,7 @@ fun SettingsLicenseScreen(libraryName: String? = null) {
) {
Text(
text = stringResource(id = library.licenseName),
style = MaterialTheme.typography.subtitle2
style = MaterialTheme.typography.titleMedium
)
library.copyrightNote?.let {
Text(

View File

@ -5,8 +5,8 @@ import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.spring
import androidx.compose.foundation.layout.*
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.ArrowBack
import androidx.compose.material.icons.rounded.Delete
@ -62,21 +62,21 @@ fun ApplicationItem(
Column {
Text(
text = app.label,
style = MaterialTheme.typography.subtitle1,
style = MaterialTheme.typography.titleLarge,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
app.version?.let {
Text(
text = it,
style = MaterialTheme.typography.body1,
style = MaterialTheme.typography.bodyMedium,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}
Text(
text = app.`package`,
style = MaterialTheme.typography.body1,
style = MaterialTheme.typography.bodyMedium,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)

View File

@ -4,8 +4,8 @@ import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier

View File

@ -4,7 +4,10 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.material.*
import androidx.compose.material.Card
import androidx.compose.material.ContentAlpha
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.getValue
@ -39,7 +42,7 @@ fun calculatorItem(): LazyListScope.() -> Unit {
}
Text(
text = "= ${it.formattedString}",
style = MaterialTheme.typography.subtitle1,
style = MaterialTheme.typography.titleLarge,
modifier = Modifier.align(Alignment.End),
)
if (it.term.matches(Regex("(0x|0b)?[0-9]+"))) {

View File

@ -9,8 +9,8 @@ import androidx.compose.animation.core.spring
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.*
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.ArrowBack
import androidx.compose.material.icons.rounded.Delete
@ -74,7 +74,7 @@ fun FileItem(
Column {
Text(
text = file.label,
style = MaterialTheme.typography.subtitle2,
style = MaterialTheme.typography.titleLarge,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)

View File

@ -3,8 +3,8 @@ package de.mm20.launcher2.ui.search
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -22,7 +22,7 @@ fun ColumnScope.GridItemLabel(
maxLines = 1,
overflow = TextOverflow.Ellipsis,
textAlign = TextAlign.Center,
style = MaterialTheme.typography.body2,
style = MaterialTheme.typography.bodySmall,
softWrap = false,
modifier = Modifier
.fillMaxWidth()

View File

@ -5,6 +5,7 @@ import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.animateContentSize
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.LazyListState
@ -94,11 +95,11 @@ fun LazyListScope.NotSoLazySearchableGrid(
}
}
@OptIn(ExperimentalAnimationApi::class)
@OptIn(ExperimentalAnimationApi::class, ExperimentalFoundationApi::class)
fun LazyListScope.SearchableGrid(
items: List<Searchable>,
columns: Int = 5,
listState: LazyListState
listState: LazyListState,
) {
val rows = (items.size + columns - 1) / columns
@ -109,6 +110,7 @@ fun LazyListScope.SearchableGrid(
Row(
modifier = Modifier
.requiredHeight(100.dp)
.animateItemPlacement()
.zIndex(
animateFloatAsState(
if (focusedItem != -1 && rowIndex == focusedItem / columns) 100f else 0f
@ -125,7 +127,8 @@ fun LazyListScope.SearchableGrid(
hasFocus = itemIndex == focusedItem,
requestFocus = {
focusedItem = if (it) itemIndex else -1
})
}
)
} else {
Spacer(Modifier.weight(1f, fill = true))
}
@ -144,7 +147,8 @@ fun RowScope.GridItem(
column: Int,
totalColumns: Int,
hasFocus: Boolean,
requestFocus: (Boolean) -> Unit
requestFocus: (Boolean) -> Unit,
modifier: Modifier = Modifier,
) {
val insets = LocalWindowInsets.current.systemBars
@ -178,7 +182,7 @@ fun RowScope.GridItem(
val windowSize = LocalWindowSize.current
Box(
modifier = Modifier
modifier = modifier
.weight(1f, fill = true)
.fillMaxHeight()
.zIndex(z)

View File

@ -7,7 +7,7 @@ import androidx.compose.animation.core.updateTransition
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Card
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
@ -73,7 +73,7 @@ fun SearchableItem(
Card(
backgroundColor = MaterialTheme.colors.surface.copy(alpha = cardAlpha),
backgroundColor = MaterialTheme.colorScheme.surface.copy(alpha = cardAlpha),
elevation = cardElevation
) {

View File

@ -1,8 +1,11 @@
package de.mm20.launcher2.ui.search
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.lazy.LazyItemScope
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.items
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import de.mm20.launcher2.search.data.Searchable
import de.mm20.launcher2.ui.component.SectionDivider
@ -17,7 +20,8 @@ fun LazyListScope.SearchableList(
}
}
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun ListItem(item: Searchable) {
SearchableItem(item = item)
fun LazyItemScope.ListItem(item: Searchable) {
SearchableItem(item = item, modifier = Modifier.animateItemPlacement())
}

View File

@ -5,8 +5,8 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.ContentAlpha
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.ArrowBack
import androidx.compose.material.icons.rounded.Share
@ -36,7 +36,7 @@ fun WikipediaItem(
) {
Text(
text = wikipedia.label,
style = MaterialTheme.typography.subtitle1,
style = MaterialTheme.typography.titleLarge,
)
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
Text(

View File

@ -10,7 +10,8 @@ import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.material.Card
import androidx.compose.material3.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.ArrowBack
import androidx.compose.material.icons.rounded.Star
@ -35,7 +36,7 @@ import de.mm20.launcher2.ui.search.Representation
import de.mm20.launcher2.ui.toPixels
import java.net.URLEncoder
@OptIn(ExperimentalMaterialApi::class, ExperimentalAnimationApi::class)
@OptIn(ExperimentalAnimationApi::class)
@Composable
fun CalendarEventItem(
event: CalendarEvent,
@ -56,7 +57,7 @@ fun CalendarEventItem(
elevation = animateDpAsState(if (representation == Representation.Full) 4.dp else 0.dp).value,
border = BorderStroke(
width = animateDpAsState(if (representation == Representation.List) 1.dp else 0.dp).value,
color = MaterialTheme.colors.onSurface.copy(alpha = animateFloatAsState(if (representation == Representation.List) 0.18f else 0f).value)
color = MaterialTheme.colorScheme.onSurface.copy(alpha = animateFloatAsState(if (representation == Representation.List) 0.18f else 0f).value)
),
modifier = modifier
) {
@ -80,14 +81,14 @@ fun CalendarEventItem(
) {
Text(
text = event.label,
style = MaterialTheme.typography.subtitle2
style = MaterialTheme.typography.titleMedium
)
AnimatedVisibility(
representation == Representation.List
) {
Text(
text = formatEventTime(event = event),
style = MaterialTheme.typography.body1
style = MaterialTheme.typography.bodyMedium
)
}
}

View File

@ -2,8 +2,8 @@ package de.mm20.launcher2.ui.theme.colors
import androidx.compose.ui.graphics.Color
class BlackWhiteColorScheme: ColorScheme() {
override val neutral1: ColorSwatch
class BlackWhiteColorPalette: ColorPalette() {
override val neutral: ColorSwatch
get() = ColorSwatch(
Color.White,
Color.White,
@ -19,12 +19,12 @@ class BlackWhiteColorScheme: ColorScheme() {
Color.Black,
Color.Black,
)
override val neutral2: ColorSwatch
get() = neutral1
override val accent1: ColorSwatch
get() = neutral1
override val accent2: ColorSwatch
get() = neutral1
override val accent3: ColorSwatch
get() = neutral1
override val neutralVariant: ColorSwatch
get() = neutral
override val primary: ColorSwatch
get() = neutral
override val secondary: ColorSwatch
get() = neutral
override val tertiary: ColorSwatch
get() = neutral
}

View File

@ -0,0 +1,66 @@
package de.mm20.launcher2.ui.theme.colors
import androidx.compose.material3.ColorScheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
abstract class ColorPalette {
abstract val neutral: ColorSwatch
abstract val neutralVariant: ColorSwatch
abstract val primary: ColorSwatch
abstract val secondary: ColorSwatch
abstract val tertiary: ColorSwatch
}
fun ColorPalette.toDarkColorScheme() : ColorScheme {
return darkColorScheme(
primary = primary.shade80,
onPrimary = primary.shade20,
primaryContainer = primary.shade30,
onPrimaryContainer = primary.shade90,
secondary = secondary.shade80,
onSecondary = secondary.shade20,
secondaryContainer = secondary.shade30,
onSecondaryContainer = secondary.shade90,
tertiary = tertiary.shade80,
onTertiary = tertiary.shade20,
tertiaryContainer = tertiary.shade30,
onTertiaryContainer = tertiary.shade90,
background = neutral.shade10,
onBackground = neutral.shade90,
surface = neutral.shade10,
onSurface = neutral.shade80,
surfaceVariant = neutralVariant.shade30,
onSurfaceVariant = neutralVariant.shade80,
outline = neutralVariant.shade60,
inverseOnSurface = neutralVariant.shade20,
inverseSurface = neutralVariant.shade90,
)
}
fun ColorPalette.toLightColorScheme() : ColorScheme {
return lightColorScheme(
primary = primary.shade40,
onPrimary = primary.shade100,
primaryContainer = primary.shade90,
onPrimaryContainer = primary.shade10,
secondary = secondary.shade40,
onSecondary = secondary.shade100,
secondaryContainer = secondary.shade90,
onSecondaryContainer = secondary.shade10,
tertiary = tertiary.shade40,
onTertiary = tertiary.shade100,
tertiaryContainer = tertiary.shade90,
onTertiaryContainer = tertiary.shade10,
background = neutral.shade99,
onBackground = neutral.shade10,
surface = neutral.shade99,
onSurface = neutral.shade10,
surfaceVariant = neutralVariant.shade90,
onSurfaceVariant = neutralVariant.shade30,
outline = neutralVariant.shade50,
inverseOnSurface = neutralVariant.shade95,
inverseSurface = neutralVariant.shade20,
)
}

View File

@ -1,12 +0,0 @@
package de.mm20.launcher2.ui.theme.colors
import androidx.compose.ui.graphics.Color
abstract class ColorScheme {
abstract val neutral1: ColorSwatch
abstract val neutral2: ColorSwatch
abstract val accent1: ColorSwatch
abstract val accent2: ColorSwatch
abstract val accent3: ColorSwatch
}

View File

@ -1,7 +1,6 @@
package de.mm20.launcher2.ui.theme.colors
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.compositeOver
import androidx.compose.ui.graphics.toArgb
import androidx.core.graphics.ColorUtils
import androidx.core.graphics.blue
@ -9,19 +8,19 @@ import androidx.core.graphics.green
import androidx.core.graphics.red
data class ColorSwatch(
val shade0: Color,
val shade10: Color,
val shade50: Color,
val shade100: Color,
val shade200: Color,
val shade300: Color,
val shade400: Color,
val shade500: Color,
val shade600: Color,
val shade700: Color,
val shade800: Color,
val shade900: Color,
val shade1000: Color,
val shade99: Color,
val shade95: Color,
val shade90: Color,
val shade80: Color,
val shade70: Color,
val shade60: Color,
val shade50: Color,
val shade40: Color,
val shade30: Color,
val shade20: Color,
val shade10: Color,
val shade0: Color,
)
fun colorSwatch(color: Color): ColorSwatch {
@ -30,18 +29,18 @@ fun colorSwatch(color: Color): ColorSwatch {
ColorUtils.RGBToHSL(rgb.red, rgb.green, rgb.blue, hsl)
return ColorSwatch(
shade0 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 1f })),
shade10 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0.99f })),
shade50 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0.95f })),
shade100 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0.9f })),
shade200 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0.8f })),
shade300 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0.7f })),
shade400 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0.6f })),
shade500 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0.49f })),
shade600 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0.4f })),
shade700 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0.3f })),
shade800 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0.2f })),
shade900 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0.1f })),
shade1000 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0f })),
shade100 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 1f })),
shade99 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0.99f })),
shade95 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0.95f })),
shade90 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0.9f })),
shade80 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0.8f })),
shade70 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0.7f })),
shade60 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0.6f })),
shade50 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0.49f })),
shade40 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0.4f })),
shade30 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0.3f })),
shade20 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0.2f })),
shade10 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0.1f })),
shade0 = Color(ColorUtils.HSLToColor(hsl.also { it[2] = 0f })),
)
}

View File

@ -9,16 +9,16 @@ import androidx.compose.ui.platform.LocalContext
import de.mm20.launcher2.preferences.dataStore
import kotlinx.coroutines.flow.map
class CustomColorScheme(val colors: CustomColors) : ColorScheme() {
override val neutral1: ColorSwatch
class CustomColorPalette(val colors: CustomColors) : ColorPalette() {
override val neutral: ColorSwatch
get() = colorSwatch(colors.neutral1)
override val neutral2: ColorSwatch
override val neutralVariant: ColorSwatch
get() = colorSwatch(colors.neutral2)
override val accent1: ColorSwatch
override val primary: ColorSwatch
get() = colorSwatch(colors.accent1)
override val accent2: ColorSwatch
override val secondary: ColorSwatch
get() = colorSwatch(colors.accent2)
override val accent3: ColorSwatch
override val tertiary: ColorSwatch
get() = colorSwatch(colors.accent3)
}

View File

@ -0,0 +1,18 @@
package de.mm20.launcher2.ui.theme.colors
import androidx.compose.ui.graphics.Color
class DefaultColorPalette: ColorPalette() {
override val neutral = colorSwatch(Color.Black)
override val neutralVariant = neutral
override val primary = colorSwatch(Color(0xFF39A0ED))
override val secondary = colorSwatch(Color(0xFF4C6085))
override val tertiary = colorSwatch(Color(0xFFF59CA9))
}

View File

@ -1,18 +0,0 @@
package de.mm20.launcher2.ui.theme.colors
import androidx.compose.ui.graphics.Color
class DefaultColorScheme: ColorScheme() {
override val neutral1 = colorSwatch(Color.Black)
override val neutral2 = neutral1
override val accent1 = colorSwatch(Color(0xFF39A0ED))
override val accent2 = colorSwatch(Color(0xFF4C6085))
override val accent3 = colorSwatch(Color(0xFFF59CA9))
}

View File

@ -0,0 +1,11 @@
package de.mm20.launcher2.ui.theme.colors
import androidx.compose.ui.graphics.Color
class MM20ColorPalette: ColorPalette() {
override val neutral = colorSwatch(Color(0xff233139))
override val neutralVariant = colorSwatch(Color(0xff233139))
override val primary = colorSwatch(Color(0xfface330))
override val secondary = colorSwatch(Color(0xff496777))
override val tertiary = colorSwatch(Color(0xfface330))
}

View File

@ -1,11 +0,0 @@
package de.mm20.launcher2.ui.theme.colors
import androidx.compose.ui.graphics.Color
class MM20ColorScheme: ColorScheme() {
override val neutral1 = colorSwatch(Color(0xff233139))
override val neutral2 = colorSwatch(Color(0xff233139))
override val accent1 = colorSwatch(Color(0xfface330))
override val accent2 = colorSwatch(Color(0xff496777))
override val accent3 = colorSwatch(Color(0xfface330))
}

View File

@ -0,0 +1,89 @@
package de.mm20.launcher2.ui.theme.colors
import android.content.Context
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.compose.ui.graphics.Color
@RequiresApi(api = Build.VERSION_CODES.S)
class SystemColorPalette(context: Context) : ColorPalette() {
override val neutral = ColorSwatch(
shade100 = Color(context.getColor(android.R.color.system_neutral1_0)),
shade99 = Color(context.getColor(android.R.color.system_neutral1_10)),
shade95 = Color(context.getColor(android.R.color.system_neutral1_50)),
shade90 = Color(context.getColor(android.R.color.system_neutral1_100)),
shade80 = Color(context.getColor(android.R.color.system_neutral1_200)),
shade70 = Color(context.getColor(android.R.color.system_neutral1_300)),
shade60 = Color(context.getColor(android.R.color.system_neutral1_400)),
shade50 = Color(context.getColor(android.R.color.system_neutral1_500)),
shade40 = Color(context.getColor(android.R.color.system_neutral1_600)),
shade30 = Color(context.getColor(android.R.color.system_neutral1_700)),
shade20 = Color(context.getColor(android.R.color.system_neutral1_800)),
shade10 = Color(context.getColor(android.R.color.system_neutral1_900)),
shade0 = Color(context.getColor(android.R.color.system_neutral1_1000)),
)
override val neutralVariant = ColorSwatch(
shade100 = Color(context.getColor(android.R.color.system_neutral2_0)),
shade99 = Color(context.getColor(android.R.color.system_neutral2_10)),
shade95 = Color(context.getColor(android.R.color.system_neutral2_50)),
shade90 = Color(context.getColor(android.R.color.system_neutral2_100)),
shade80 = Color(context.getColor(android.R.color.system_neutral2_200)),
shade70 = Color(context.getColor(android.R.color.system_neutral2_300)),
shade60 = Color(context.getColor(android.R.color.system_neutral2_400)),
shade50 = Color(context.getColor(android.R.color.system_neutral2_500)),
shade40 = Color(context.getColor(android.R.color.system_neutral2_600)),
shade30 = Color(context.getColor(android.R.color.system_neutral2_700)),
shade20 = Color(context.getColor(android.R.color.system_neutral2_800)),
shade10 = Color(context.getColor(android.R.color.system_neutral2_900)),
shade0 = Color(context.getColor(android.R.color.system_neutral2_1000)),
)
override val primary = ColorSwatch(
shade100 = Color(context.getColor(android.R.color.system_accent1_0)),
shade99 = Color(context.getColor(android.R.color.system_accent1_10)),
shade95 = Color(context.getColor(android.R.color.system_accent1_50)),
shade90 = Color(context.getColor(android.R.color.system_accent1_100)),
shade80 = Color(context.getColor(android.R.color.system_accent1_200)),
shade70 = Color(context.getColor(android.R.color.system_accent1_300)),
shade60 = Color(context.getColor(android.R.color.system_accent1_400)),
shade50 = Color(context.getColor(android.R.color.system_accent1_500)),
shade40 = Color(context.getColor(android.R.color.system_accent1_600)),
shade30 = Color(context.getColor(android.R.color.system_accent1_700)),
shade20 = Color(context.getColor(android.R.color.system_accent1_800)),
shade10 = Color(context.getColor(android.R.color.system_accent1_900)),
shade0 = Color(context.getColor(android.R.color.system_accent1_1000)),
)
override val secondary = ColorSwatch(
shade100 = Color(context.getColor(android.R.color.system_accent2_0)),
shade99 = Color(context.getColor(android.R.color.system_accent2_10)),
shade95 = Color(context.getColor(android.R.color.system_accent2_50)),
shade90 = Color(context.getColor(android.R.color.system_accent2_100)),
shade80 = Color(context.getColor(android.R.color.system_accent2_200)),
shade70 = Color(context.getColor(android.R.color.system_accent2_300)),
shade60 = Color(context.getColor(android.R.color.system_accent2_400)),
shade50 = Color(context.getColor(android.R.color.system_accent2_500)),
shade40 = Color(context.getColor(android.R.color.system_accent2_600)),
shade30 = Color(context.getColor(android.R.color.system_accent2_700)),
shade20 = Color(context.getColor(android.R.color.system_accent2_800)),
shade10 = Color(context.getColor(android.R.color.system_accent2_900)),
shade0 = Color(context.getColor(android.R.color.system_accent2_1000)),
)
override val tertiary = ColorSwatch(
shade100 = Color(context.getColor(android.R.color.system_accent3_0)),
shade99 = Color(context.getColor(android.R.color.system_accent3_10)),
shade95 = Color(context.getColor(android.R.color.system_accent3_50)),
shade90 = Color(context.getColor(android.R.color.system_accent3_100)),
shade80 = Color(context.getColor(android.R.color.system_accent3_200)),
shade70 = Color(context.getColor(android.R.color.system_accent3_300)),
shade60 = Color(context.getColor(android.R.color.system_accent3_400)),
shade50 = Color(context.getColor(android.R.color.system_accent3_500)),
shade40 = Color(context.getColor(android.R.color.system_accent3_600)),
shade30 = Color(context.getColor(android.R.color.system_accent3_700)),
shade20 = Color(context.getColor(android.R.color.system_accent3_800)),
shade10 = Color(context.getColor(android.R.color.system_accent3_900)),
shade0 = Color(context.getColor(android.R.color.system_accent3_1000)),
)
}

View File

@ -1,89 +0,0 @@
package de.mm20.launcher2.ui.theme.colors
import android.content.Context
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.compose.ui.graphics.Color
@RequiresApi(api = Build.VERSION_CODES.S)
class SystemColorScheme(context: Context) : ColorScheme() {
override val neutral1 = ColorSwatch(
shade0 = Color(context.getColor(android.R.color.system_neutral1_0)),
shade10 = Color(context.getColor(android.R.color.system_neutral1_10)),
shade50 = Color(context.getColor(android.R.color.system_neutral1_50)),
shade100 = Color(context.getColor(android.R.color.system_neutral1_100)),
shade200 = Color(context.getColor(android.R.color.system_neutral1_200)),
shade300 = Color(context.getColor(android.R.color.system_neutral1_300)),
shade400 = Color(context.getColor(android.R.color.system_neutral1_400)),
shade500 = Color(context.getColor(android.R.color.system_neutral1_500)),
shade600 = Color(context.getColor(android.R.color.system_neutral1_600)),
shade700 = Color(context.getColor(android.R.color.system_neutral1_700)),
shade800 = Color(context.getColor(android.R.color.system_neutral1_800)),
shade900 = Color(context.getColor(android.R.color.system_neutral1_900)),
shade1000 = Color(context.getColor(android.R.color.system_neutral1_1000)),
)
override val neutral2 = ColorSwatch(
shade0 = Color(context.getColor(android.R.color.system_neutral2_0)),
shade10 = Color(context.getColor(android.R.color.system_neutral2_10)),
shade50 = Color(context.getColor(android.R.color.system_neutral2_50)),
shade100 = Color(context.getColor(android.R.color.system_neutral2_100)),
shade200 = Color(context.getColor(android.R.color.system_neutral2_200)),
shade300 = Color(context.getColor(android.R.color.system_neutral2_300)),
shade400 = Color(context.getColor(android.R.color.system_neutral2_400)),
shade500 = Color(context.getColor(android.R.color.system_neutral2_500)),
shade600 = Color(context.getColor(android.R.color.system_neutral2_600)),
shade700 = Color(context.getColor(android.R.color.system_neutral2_700)),
shade800 = Color(context.getColor(android.R.color.system_neutral2_800)),
shade900 = Color(context.getColor(android.R.color.system_neutral2_900)),
shade1000 = Color(context.getColor(android.R.color.system_neutral2_1000)),
)
override val accent1 = ColorSwatch(
shade0 = Color(context.getColor(android.R.color.system_accent1_0)),
shade10 = Color(context.getColor(android.R.color.system_accent1_10)),
shade50 = Color(context.getColor(android.R.color.system_accent1_50)),
shade100 = Color(context.getColor(android.R.color.system_accent1_100)),
shade200 = Color(context.getColor(android.R.color.system_accent1_200)),
shade300 = Color(context.getColor(android.R.color.system_accent1_300)),
shade400 = Color(context.getColor(android.R.color.system_accent1_400)),
shade500 = Color(context.getColor(android.R.color.system_accent1_500)),
shade600 = Color(context.getColor(android.R.color.system_accent1_600)),
shade700 = Color(context.getColor(android.R.color.system_accent1_700)),
shade800 = Color(context.getColor(android.R.color.system_accent1_800)),
shade900 = Color(context.getColor(android.R.color.system_accent1_900)),
shade1000 = Color(context.getColor(android.R.color.system_accent1_1000)),
)
override val accent2 = ColorSwatch(
shade0 = Color(context.getColor(android.R.color.system_accent2_0)),
shade10 = Color(context.getColor(android.R.color.system_accent2_10)),
shade50 = Color(context.getColor(android.R.color.system_accent2_50)),
shade100 = Color(context.getColor(android.R.color.system_accent2_100)),
shade200 = Color(context.getColor(android.R.color.system_accent2_200)),
shade300 = Color(context.getColor(android.R.color.system_accent2_300)),
shade400 = Color(context.getColor(android.R.color.system_accent2_400)),
shade500 = Color(context.getColor(android.R.color.system_accent2_500)),
shade600 = Color(context.getColor(android.R.color.system_accent2_600)),
shade700 = Color(context.getColor(android.R.color.system_accent2_700)),
shade800 = Color(context.getColor(android.R.color.system_accent2_800)),
shade900 = Color(context.getColor(android.R.color.system_accent2_900)),
shade1000 = Color(context.getColor(android.R.color.system_accent2_1000)),
)
override val accent3 = ColorSwatch(
shade0 = Color(context.getColor(android.R.color.system_accent3_0)),
shade10 = Color(context.getColor(android.R.color.system_accent3_10)),
shade50 = Color(context.getColor(android.R.color.system_accent3_50)),
shade100 = Color(context.getColor(android.R.color.system_accent3_100)),
shade200 = Color(context.getColor(android.R.color.system_accent3_200)),
shade300 = Color(context.getColor(android.R.color.system_accent3_300)),
shade400 = Color(context.getColor(android.R.color.system_accent3_400)),
shade500 = Color(context.getColor(android.R.color.system_accent3_500)),
shade600 = Color(context.getColor(android.R.color.system_accent3_600)),
shade700 = Color(context.getColor(android.R.color.system_accent3_700)),
shade800 = Color(context.getColor(android.R.color.system_accent3_800)),
shade900 = Color(context.getColor(android.R.color.system_accent3_900)),
shade1000 = Color(context.getColor(android.R.color.system_accent3_1000)),
)
}

View File

@ -5,14 +5,14 @@ import androidx.compose.ui.graphics.toArgb
import androidx.core.graphics.ColorUtils
import de.mm20.launcher2.ui.theme.WallpaperColors
class WallpaperColorScheme(
class WallpaperColorPalette(
wallpaperColors: WallpaperColors
) : ColorScheme() {
override val neutral1: ColorSwatch
override val neutral2: ColorSwatch
override val accent1: ColorSwatch
override val accent2: ColorSwatch
override val accent3: ColorSwatch
) : ColorPalette() {
override val neutral: ColorSwatch
override val neutralVariant: ColorSwatch
override val primary: ColorSwatch
override val secondary: ColorSwatch
override val tertiary: ColorSwatch
init {
val primary = wallpaperColors.primary
@ -35,11 +35,11 @@ class WallpaperColorScheme(
?: primary
neutral1 = colorSwatch(neutral)
neutral2 = neutral1
accent1 = colorSwatch(acc1)
accent2 = colorSwatch(acc2)
accent3 = neutral1
this.neutral = colorSwatch(neutral)
neutralVariant = this.neutral
this.primary = colorSwatch(acc1)
this.secondary = colorSwatch(acc2)
this.tertiary = this.neutral
}
private fun isBrown(color: Color): Boolean {

View File

@ -7,7 +7,9 @@ import androidx.compose.animation.core.*
import androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi
import androidx.compose.animation.graphics.res.animatedVectorResource
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.material.DropdownMenu
import androidx.compose.material.DropdownMenuItem
import androidx.compose.material3.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.AcUnit
import androidx.compose.material.icons.rounded.Air
@ -20,6 +22,7 @@ import androidx.compose.ui.draw.clipToBounds
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.draw.scale
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import de.mm20.launcher2.ui.*
@ -65,7 +68,7 @@ private fun SunMoon(icon: WeatherIcon, night: Boolean) {
val transition = updateTransition(targetState = icon, "AnimatedWeatherIcon")
val color by animateColorAsState(
if (night) MaterialTheme.colors.weatherMoon else MaterialTheme.colors.weatherSun
if (night)colorResource(id = R.color.weather_moon) else colorResource(id = R.color.weather_sun)
)
val scale by transition.animateFloat(label = "sunScale") {
when (it) {
@ -129,7 +132,7 @@ private fun LightningBolt(icon: WeatherIcon) {
.size(32.dp)
.offset(offset.x.dp, offset.y.dp)
.scale(scale),
tint = MaterialTheme.colors.weatherBolt
tint = colorResource(id = R.color.weather_lightning_bolt)
)
}
@ -159,7 +162,7 @@ private fun LightningBolt2(icon: WeatherIcon) {
.size(32.dp)
.offset(offset.x.dp, offset.y.dp)
.scale(scale),
tint = MaterialTheme.colors.weatherBolt
tint = colorResource(id = R.color.weather_lightning_bolt)
)
}
@ -216,19 +219,19 @@ private fun Cloud1(icon: WeatherIcon) {
WeatherIcon.ThunderstormWithRain,
WeatherIcon.HeavyThunderstorm,
WeatherIcon.HeavyThunderstormWithRain,
WeatherIcon.Storm -> MaterialTheme.colors.weatherCloudDark2
WeatherIcon.Storm -> colorResource(id = R.color.weather_cloud_dark_2)
WeatherIcon.Showers,
WeatherIcon.Sleet,
WeatherIcon.Hail,
WeatherIcon.Cloudy,
WeatherIcon.Wind,
WeatherIcon.Fog -> MaterialTheme.colors.weatherCloudDark1
WeatherIcon.Fog -> colorResource(id = R.color.weather_cloud_dark_1)
WeatherIcon.Drizzle,
WeatherIcon.Snow -> MaterialTheme.colors.weatherCloudMedium2
WeatherIcon.MostlyCloudy -> MaterialTheme.colors.weatherCloudLight2
WeatherIcon.Snow -> colorResource(id = R.color.weather_cloud_medium_2)
WeatherIcon.MostlyCloudy -> colorResource(id = R.color.weather_cloud_light_2)
WeatherIcon.PartlyCloudy,
WeatherIcon.BrokenClouds -> MaterialTheme.colors.weatherCloudLight1
else -> MaterialTheme.colors.weatherCloudMedium2
WeatherIcon.BrokenClouds -> colorResource(id = R.color.weather_cloud_light_1)
else -> colorResource(id = R.color.weather_cloud_medium_2)
}
}
@ -289,12 +292,12 @@ private fun Cloud2(icon: WeatherIcon) {
}
val color by transition.animateColor(label = "color") {
when (it) {
WeatherIcon.BrokenClouds -> MaterialTheme.colors.weatherCloudLight2
WeatherIcon.BrokenClouds -> colorResource(id = R.color.weather_cloud_light_2)
WeatherIcon.Thunderstorm,
WeatherIcon.ThunderstormWithRain,
WeatherIcon.HeavyThunderstorm,
WeatherIcon.HeavyThunderstormWithRain,
WeatherIcon.Storm -> MaterialTheme.colors.weatherCloudMedium2
WeatherIcon.Storm -> colorResource(id = R.color.weather_cloud_medium_2)
WeatherIcon.Showers,
WeatherIcon.Drizzle,
WeatherIcon.Sleet,
@ -302,9 +305,9 @@ private fun Cloud2(icon: WeatherIcon) {
WeatherIcon.Hail,
WeatherIcon.Cloudy,
WeatherIcon.Wind,
WeatherIcon.Fog -> MaterialTheme.colors.weatherCloudMedium1
WeatherIcon.MostlyCloudy -> MaterialTheme.colors.weatherCloudMedium1
else -> MaterialTheme.colors.weatherCloudMedium2
WeatherIcon.Fog -> colorResource(id = R.color.weather_cloud_medium_1)
WeatherIcon.MostlyCloudy -> colorResource(id = R.color.weather_cloud_medium_1)
else -> colorResource(id = R.color.weather_cloud_medium_2)
}
}
@ -363,15 +366,15 @@ private fun Cloud3(icon: WeatherIcon) {
WeatherIcon.ThunderstormWithRain,
WeatherIcon.HeavyThunderstorm,
WeatherIcon.HeavyThunderstormWithRain,
WeatherIcon.Storm -> MaterialTheme.colors.weatherCloudDark1
WeatherIcon.Storm -> colorResource(id = R.color.weather_cloud_dark_1)
WeatherIcon.Showers,
WeatherIcon.Sleet,
WeatherIcon.Hail,
WeatherIcon.Cloudy,
WeatherIcon.Wind -> MaterialTheme.colors.weatherCloudMedium2
WeatherIcon.Wind -> colorResource(id = R.color.weather_cloud_medium_2)
WeatherIcon.Drizzle,
WeatherIcon.Snow -> MaterialTheme.colors.weatherCloudLight2
else -> MaterialTheme.colors.weatherCloudMedium2
WeatherIcon.Snow -> colorResource(id = R.color.weather_cloud_light_2)
else -> colorResource(id = R.color.weather_cloud_medium_2)
}
}
@ -401,7 +404,7 @@ private fun Hot(icon: WeatherIcon) {
modifier = Modifier
.scale(scale)
.size(32.dp),
tint = MaterialTheme.colors.weatherHot
tint = colorResource(id = R.color.weather_hot)
)
}
@ -420,7 +423,7 @@ private fun Cold(icon: WeatherIcon) {
modifier = Modifier
.scale(scale)
.size(32.dp),
tint = MaterialTheme.colors.weatherCold
tint = colorResource(id = R.color.weather_cold)
)
}
@ -440,7 +443,7 @@ private fun Wind1(icon: WeatherIcon) {
.scale(scale)
.offset(12.dp, 11.dp)
.size(32.dp),
tint = MaterialTheme.colors.weatherWind
tint = colorResource(id = R.color.weather_wind)
)
}
@ -460,7 +463,7 @@ private fun Wind2(icon: WeatherIcon) {
.scale(scale)
.offset(8.dp, -1.dp)
.size(32.dp),
tint = MaterialTheme.colors.weatherWindDark
tint = colorResource(id = R.color.weather_wind_dark)
)
}
@ -528,7 +531,7 @@ private fun Precipitation(icon: WeatherIcon) {
.offset(y = 8.dp + 11.dp * animProgress),
imageVector = Icons.Rounded.WeatherLightRainAnimatable,
contentDescription = null,
tint = MaterialTheme.colors.weatherRain
tint = colorResource(id = R.color.weather_rain)
)
}
WeatherIcon.Hail -> {
@ -544,7 +547,7 @@ private fun Precipitation(icon: WeatherIcon) {
.offset(y = 8.dp + 11.dp * animProgress),
imageVector = Icons.Rounded.WeatherHailAnimatable,
contentDescription = null,
tint = MaterialTheme.colors.weatherHail
tint = colorResource(id = R.color.weather_hail)
)
}
WeatherIcon.Snow -> {
@ -563,7 +566,7 @@ private fun Precipitation(icon: WeatherIcon) {
),
imageVector = Icons.Rounded.WeatherHailAnimatable,
contentDescription = null,
tint = MaterialTheme.colors.weatherSnow
tint = colorResource(id = R.color.weather_snow)
)
}
WeatherIcon.Showers,
@ -581,7 +584,7 @@ private fun Precipitation(icon: WeatherIcon) {
.offset(y = 8.dp + 11.dp * animProgress),
imageVector = Icons.Rounded.WeatherRainAnimatable,
contentDescription = null,
tint = MaterialTheme.colors.weatherRain
tint = colorResource(id = R.color.weather_rain)
)
}
WeatherIcon.Sleet -> {
@ -597,7 +600,7 @@ private fun Precipitation(icon: WeatherIcon) {
.offset(y = 8.dp + 11.dp * animProgress),
imageVector = Icons.Rounded.WeatherSleetRainAnimatable,
contentDescription = null,
tint = MaterialTheme.colors.weatherRain
tint = colorResource(id = R.color.weather_rain)
)
Icon(
modifier = Modifier
@ -605,7 +608,7 @@ private fun Precipitation(icon: WeatherIcon) {
.offset(y = 8.dp + 11.dp * animProgress),
imageVector = Icons.Rounded.WeatherSleetSnowAnimatable,
contentDescription = null,
tint = MaterialTheme.colors.weatherSnow
tint = colorResource(id = R.color.weather_snow)
)
}
}
@ -624,7 +627,7 @@ private fun Fog(icon: WeatherIcon) {
.offset(x = 6.dp, y = 7.dp),
imageVector = Icons.Rounded.WeatherFog,
contentDescription = null,
tint = MaterialTheme.colors.weatherFog
tint = colorResource(id = R.color.weather_fog)
)
}

View File

@ -3,8 +3,7 @@ package de.mm20.launcher2.ui.weather
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.size
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.Icon
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.*
import androidx.compose.runtime.Composable
@ -12,6 +11,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.scale
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.dp
import de.mm20.launcher2.ui.*
@ -51,7 +51,7 @@ private fun SunMoon(icon: WeatherIcon, night: Boolean) {
else -> return
}
val color = if (night) MaterialTheme.colors.weatherMoon else MaterialTheme.colors.weatherSun
val color = if (night) colorResource(id = R.color.weather_moon) else colorResource(id = R.color.weather_sun)
val scale = when (icon) {
WeatherIcon.Clear,
@ -139,18 +139,18 @@ private fun Cloud1(icon: WeatherIcon) {
WeatherIcon.Thunderstorm,
WeatherIcon.ThunderstormWithRain,
WeatherIcon.HeavyThunderstorm,
WeatherIcon.HeavyThunderstormWithRain -> MaterialTheme.colors.weatherCloudDark2
WeatherIcon.HeavyThunderstormWithRain -> colorResource(id = R.color.weather_cloud_dark_2)
WeatherIcon.Showers,
WeatherIcon.Sleet,
WeatherIcon.Hail,
WeatherIcon.Cloudy,
WeatherIcon.Fog -> MaterialTheme.colors.weatherCloudDark1
WeatherIcon.Fog -> colorResource(id = R.color.weather_cloud_dark_1)
WeatherIcon.Drizzle,
WeatherIcon.Snow -> MaterialTheme.colors.weatherCloudMedium2
WeatherIcon.MostlyCloudy -> MaterialTheme.colors.weatherCloudLight2
WeatherIcon.Snow -> colorResource(id = R.color.weather_cloud_medium_2)
WeatherIcon.MostlyCloudy -> colorResource(id = R.color.weather_cloud_light_2)
WeatherIcon.PartlyCloudy,
WeatherIcon.BrokenClouds -> MaterialTheme.colors.weatherCloudLight1
else -> MaterialTheme.colors.weatherCloudMedium2
WeatherIcon.BrokenClouds -> colorResource(id = R.color.weather_cloud_light_1)
else -> colorResource(id = R.color.weather_cloud_medium_2)
}
Icon(
@ -218,20 +218,20 @@ private fun Cloud2(icon: WeatherIcon) {
else -> DpOffset.Zero
}
val color = when (icon) {
WeatherIcon.BrokenClouds -> MaterialTheme.colors.weatherCloudLight2
WeatherIcon.BrokenClouds -> colorResource(id = R.color.weather_cloud_light_2)
WeatherIcon.Thunderstorm,
WeatherIcon.ThunderstormWithRain,
WeatherIcon.HeavyThunderstorm,
WeatherIcon.HeavyThunderstormWithRain -> MaterialTheme.colors.weatherCloudMedium2
WeatherIcon.HeavyThunderstormWithRain -> colorResource(id = R.color.weather_cloud_medium_2)
WeatherIcon.Showers,
WeatherIcon.Drizzle,
WeatherIcon.Sleet,
WeatherIcon.Snow,
WeatherIcon.Hail,
WeatherIcon.Cloudy,
WeatherIcon.Fog -> MaterialTheme.colors.weatherCloudMedium1
WeatherIcon.MostlyCloudy -> MaterialTheme.colors.weatherCloudMedium1
else -> MaterialTheme.colors.weatherCloudMedium2
WeatherIcon.Fog -> colorResource(id = R.color.weather_cloud_medium_1)
WeatherIcon.MostlyCloudy -> colorResource(id = R.color.weather_cloud_medium_1)
else -> colorResource(id = R.color.weather_cloud_medium_2)
}
Icon(
@ -280,14 +280,14 @@ private fun Cloud3(icon: WeatherIcon) {
WeatherIcon.Thunderstorm,
WeatherIcon.ThunderstormWithRain,
WeatherIcon.HeavyThunderstorm,
WeatherIcon.HeavyThunderstormWithRain -> MaterialTheme.colors.weatherCloudDark1
WeatherIcon.HeavyThunderstormWithRain -> colorResource(id = R.color.weather_cloud_dark_1)
WeatherIcon.Showers,
WeatherIcon.Sleet,
WeatherIcon.Hail,
WeatherIcon.Cloudy -> MaterialTheme.colors.weatherCloudMedium2
WeatherIcon.Cloudy -> colorResource(id = R.color.weather_cloud_medium_2)
WeatherIcon.Drizzle,
WeatherIcon.Snow -> MaterialTheme.colors.weatherCloudLight2
else -> MaterialTheme.colors.weatherCloudMedium2
WeatherIcon.Snow -> colorResource(id = R.color.weather_cloud_light_2)
else -> colorResource(id = R.color.weather_cloud_medium_2)
}
Icon(
@ -309,7 +309,7 @@ private fun Precipitation(icon: WeatherIcon) {
.size(32.dp),
imageVector = Icons.Rounded.WeatherSleetSnow,
contentDescription = null,
tint = MaterialTheme.colors.weatherSnow
tint = colorResource(id = R.color.weather_snow)
)
Icon(
modifier = Modifier
@ -317,7 +317,7 @@ private fun Precipitation(icon: WeatherIcon) {
.size(32.dp),
imageVector = Icons.Rounded.WeatherSleetRain,
contentDescription = null,
tint = MaterialTheme.colors.weatherRain
tint = colorResource(id = R.color.weather_rain)
)
return
}
@ -344,9 +344,9 @@ private fun Precipitation(icon: WeatherIcon) {
WeatherIcon.Drizzle,
WeatherIcon.Showers,
WeatherIcon.ThunderstormWithRain,
WeatherIcon.HeavyThunderstormWithRain -> MaterialTheme.colors.weatherRain
WeatherIcon.Hail -> MaterialTheme.colors.weatherHail
WeatherIcon.Snow -> MaterialTheme.colors.weatherSnow
WeatherIcon.HeavyThunderstormWithRain -> colorResource(id = R.color.weather_rain)
WeatherIcon.Hail -> colorResource(id = R.color.weather_hail)
WeatherIcon.Snow -> colorResource(id = R.color.weather_snow)
else -> Color.Unspecified
}
Icon(
@ -367,7 +367,7 @@ private fun HotCold(icon: WeatherIcon) {
.size(32.dp),
imageVector = Icons.Rounded.Thermostat,
contentDescription = null,
tint = MaterialTheme.colors.weatherHot
tint = colorResource(id = R.color.weather_hot)
)
}
if (icon == WeatherIcon.Cold) {
@ -376,7 +376,7 @@ private fun HotCold(icon: WeatherIcon) {
.size(32.dp),
imageVector = Icons.Rounded.AcUnit,
contentDescription = null,
tint = MaterialTheme.colors.weatherCold
tint = colorResource(id = R.color.weather_cold)
)
}
}
@ -390,7 +390,7 @@ private fun Wind(icon: WeatherIcon) {
.size(24.dp),
imageVector = Icons.Rounded.Air,
contentDescription = null,
tint = MaterialTheme.colors.weatherWindDark
tint = colorResource(id = R.color.weather_wind_dark)
)
}
if (icon == WeatherIcon.Wind || icon == WeatherIcon.Storm) {
@ -399,7 +399,7 @@ private fun Wind(icon: WeatherIcon) {
.size(if(icon == WeatherIcon.Wind) 32.dp else 24.dp),
imageVector = Icons.Rounded.Air,
contentDescription = null,
tint = MaterialTheme.colors.weatherWind
tint = colorResource(id = R.color.weather_wind)
)
}
}
@ -417,7 +417,7 @@ private fun Fog(icon: WeatherIcon) {
.offset(x = 3.dp, y = 4.dp),
imageVector = Icons.Rounded.WeatherFog,
contentDescription = null,
tint = MaterialTheme.colors.weatherFog
tint = colorResource(id = R.color.weather_fog)
)
}
@ -440,7 +440,7 @@ private fun LightningBolts(icon: WeatherIcon) {
.offset(x = if (isHeavy) 4.dp else 1.dp, y = 6.dp),
imageVector = Icons.Rounded.Bolt,
contentDescription = null,
tint = MaterialTheme.colors.weatherBolt
tint = colorResource(id = R.color.weather_lightning_bolt)
)
if (icon == WeatherIcon.HeavyThunderstorm || icon == WeatherIcon.HeavyThunderstormWithRain) {
@ -450,7 +450,7 @@ private fun LightningBolts(icon: WeatherIcon) {
.offset(x = -3.dp, y = 6.dp),
imageVector = Icons.Rounded.Bolt,
contentDescription = null,
tint = MaterialTheme.colors.weatherBolt
tint = colorResource(id = R.color.weather_lightning_bolt)
)
}
}

View File

@ -7,7 +7,9 @@ import android.widget.FrameLayout
import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.material.DropdownMenu
import androidx.compose.material.DropdownMenuItem
import androidx.compose.material3.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.*
import androidx.compose.runtime.*
@ -123,7 +125,7 @@ fun CalendarWidget() {
if (pinnedEvents.isNotEmpty()) {
Text(
text = stringResource(id = R.string.calendar_widget_pinned_events),
style = MaterialTheme.typography.subtitle1
style = MaterialTheme.typography.titleLarge
)
DeprecatedSearchableList(
items = pinnedEvents,
@ -179,7 +181,7 @@ fun DaySelector(
modifier = Modifier
.wrapContentWidth(),
text = formatDay(LocalContext.current, selectedDay),
style = MaterialTheme.typography.subtitle1
style = MaterialTheme.typography.titleLarge
)
Icon(
imageVector = Icons.Rounded.ArrowDropDown,
@ -199,7 +201,7 @@ fun DaySelector(
}) {
Text(
text = formatDay(LocalContext.current, day),
style = MaterialTheme.typography.subtitle2
style = MaterialTheme.typography.titleMedium
)
}
}
@ -245,7 +247,7 @@ object CalendarWidgetShim {
composeView.id = FrameLayout.generateViewId()
composeView.setContent {
LauncherTheme {
CompositionLocalProvider(LocalContentColor provides MaterialTheme.colors.onSurface) {
CompositionLocalProvider(LocalContentColor provides MaterialTheme.colorScheme.onSurface) {
Column {
CalendarWidget()
}

View File

@ -6,8 +6,8 @@ import android.content.Intent
import android.content.IntentFilter
import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.layout.*
import androidx.compose.material.LocalContentColor
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -39,7 +39,7 @@ fun ClockWidget(
contentAlignment = Alignment.BottomCenter
) {
val contentColor by animateColorAsState(
if (transparentBackground) Color.White else MaterialTheme.colors.onSurface
if (transparentBackground) Color.White else MaterialTheme.colorScheme.onSurface
)
CompositionLocalProvider(LocalContentColor provides contentColor) {

View File

@ -7,10 +7,10 @@ import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.*
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.MusicNote
import androidx.compose.material.icons.rounded.SkipNext
@ -65,20 +65,20 @@ fun MusicWidget() {
) {
Text(
text = title ?: "---",
style = MaterialTheme.typography.subtitle1,
style = MaterialTheme.typography.titleMedium,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
Text(
text = artist ?: "---",
modifier = Modifier.padding(vertical = 2.dp),
style = MaterialTheme.typography.body1,
style = MaterialTheme.typography.bodySmall,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
Text(
text = album ?: "---",
style = MaterialTheme.typography.body1,
style = MaterialTheme.typography.bodySmall,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
@ -131,7 +131,7 @@ fun MusicWidget() {
.conditional(
albumArt == null,
Modifier.background(
LocalColorScheme.current.accent1.shade200
LocalColorScheme.current.primary.shade80
)
),
contentAlignment = Alignment.Center
@ -149,7 +149,7 @@ fun MusicWidget() {
Icon(
imageVector = Icons.Rounded.MusicNote,
contentDescription = null,
tint = LocalColorScheme.current.accent1.shade600,
tint = LocalColorScheme.current.primary.shade40,
modifier = Modifier.size(56.dp)
)
}

View File

@ -4,7 +4,7 @@ import android.appwidget.AppWidgetManager
import android.os.Build
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalContext
@ -26,7 +26,7 @@ fun PlatformWidget(widget: Widget) {
}
val height = widget.height.dp.toPixels().toInt()
val isLightTheme = MaterialTheme.colors.isLight
val isLightTheme = androidx.compose.material.MaterialTheme.colors.isLight
AndroidView(
factory = {

View File

@ -4,28 +4,25 @@ import android.content.Context
import android.content.Intent
import android.net.Uri
import android.text.format.DateUtils
import android.view.View
import android.widget.FrameLayout
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.material.ContentAlpha
import androidx.compose.material.DropdownMenu
import androidx.compose.material.DropdownMenuItem
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowDropDown
import androidx.compose.material.icons.rounded.ArrowDropDown
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.DpOffset
@ -34,10 +31,7 @@ import androidx.compose.ui.unit.sp
import androidx.lifecycle.viewmodel.compose.viewModel
import de.mm20.launcher2.ktx.tryStartActivity
import de.mm20.launcher2.preferences.LauncherPreferences
import de.mm20.launcher2.ui.LauncherTheme
import de.mm20.launcher2.ui.LegacyLauncherTheme
import de.mm20.launcher2.ui.R
import de.mm20.launcher2.ui.legacyTypography
import de.mm20.launcher2.ui.weather.AnimatedWeatherIcon
import de.mm20.launcher2.ui.weather.WeatherIcon
import de.mm20.launcher2.weather.DailyForecast
@ -81,7 +75,7 @@ fun WeatherWidget() {
) {
Text(
text = selectedForecast.location,
style = MaterialTheme.typography.subtitle1
style = MaterialTheme.typography.titleMedium
)
Text(
text = convertTemperature(
@ -96,7 +90,7 @@ fun WeatherWidget() {
)
Text(
text = selectedForecast.condition,
style = MaterialTheme.typography.body1
style = MaterialTheme.typography.bodySmall
)
Row(
@ -107,7 +101,7 @@ fun WeatherWidget() {
.padding(vertical = 12.dp)
) {
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
Text(text = stringResource(id = if (detailsExpanded) R.string.weather_widget_hide_details else R.string.weather_widget_show_details))
Text(text = stringResource(id = if (detailsExpanded) R.string.weather_widget_hide_details else R.string.weather_widget_show_details), style = MaterialTheme.typography.bodySmall)
}
}
@ -146,7 +140,7 @@ fun WeatherWidget() {
Spacer(modifier = Modifier.weight(1f))
Surface(
shape = RoundedCornerShape(topStartPercent = 50, bottomStartPercent = 50),
color = MaterialTheme.colors.onSurface.copy(alpha = 0.12f),
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.12f),
modifier = Modifier.align(Alignment.End)
) {
@ -207,11 +201,11 @@ fun WeatherDetailRow(title: String, value: String) {
Text(
text = title,
modifier = Modifier.padding(end = 8.dp),
style = MaterialTheme.typography.body2,
style = MaterialTheme.typography.bodySmall,
)
Text(
text = value,
style = MaterialTheme.typography.body2,
style = MaterialTheme.typography.bodySmall,
)
}
}
@ -241,7 +235,7 @@ fun WeatherDaySelector(
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.high) {
Text(
text = dateFormat.format(selectedDay.timestamp),
style = MaterialTheme.typography.subtitle2,
style = MaterialTheme.typography.labelSmall,
modifier = Modifier
.align(Alignment.CenterVertically)
.padding(start = 16.dp, end = 8.dp)
@ -253,7 +247,7 @@ fun WeatherDaySelector(
selectedDay.minTemp
)
}° / ${convertTemperature(imperialUnits, selectedDay.maxTemp)}°",
style = MaterialTheme.typography.body2,
style = MaterialTheme.typography.bodySmall,
modifier = Modifier.align(Alignment.CenterVertically)
)
Icon(
@ -281,7 +275,7 @@ fun WeatherDaySelector(
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.high) {
Text(
text = dateFormat.format(d.timestamp),
style = MaterialTheme.typography.subtitle2,
style = MaterialTheme.typography.labelSmall,
softWrap = false,
modifier = Modifier
.align(Alignment.CenterVertically)
@ -296,7 +290,7 @@ fun WeatherDaySelector(
)
}° / ${convertTemperature(imperialUnits, d.maxTemp)}°",
softWrap = false,
style = MaterialTheme.typography.body2,
style = MaterialTheme.typography.bodySmall,
modifier = Modifier.align(Alignment.CenterVertically)
)
}
@ -332,7 +326,7 @@ fun WeatherTimeSelector(
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.high) {
Text(
text = dateFormat.format(selectedForecast.timestamp),
style = MaterialTheme.typography.subtitle2,
style = MaterialTheme.typography.titleSmall,
modifier = Modifier.align(Alignment.CenterVertically)
)
}
@ -358,7 +352,7 @@ fun WeatherTimeSelector(
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.high) {
Text(
text = dateFormat.format(fc.timestamp),
style = MaterialTheme.typography.subtitle2,
style = MaterialTheme.typography.titleSmall,
softWrap = false,
modifier = Modifier
.align(Alignment.CenterVertically)
@ -370,7 +364,7 @@ fun WeatherTimeSelector(
Text(
text = "${convertTemperature(imperialUnits, fc.temperature)}°",
softWrap = false,
style = MaterialTheme.typography.body2,
style = MaterialTheme.typography.bodySmall,
modifier = Modifier.align(Alignment.CenterVertically)
)
}

View File

@ -1,7 +1,7 @@
package de.mm20.launcher2.ui.widget.parts
import android.text.format.DateUtils
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import de.mm20.launcher2.ui.component.TextClock
@ -9,6 +9,6 @@ import de.mm20.launcher2.ui.component.TextClock
fun DatePart() {
TextClock(
formatFlags = DateUtils.FORMAT_SHOW_WEEKDAY or DateUtils.FORMAT_SHOW_DATE or DateUtils.FORMAT_SHOW_YEAR,
style = MaterialTheme.typography.subtitle1
style = MaterialTheme.typography.titleMedium
)
}

View File

@ -126,6 +126,7 @@
android:animateLayoutChanges="true"
android:clipChildren="false"
android:clipToPadding="false"
android:paddingTop="8dp"
android:orientation="vertical">
<de.mm20.launcher2.view.ElevationImageView
@ -163,10 +164,7 @@
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"
android:text="@string/menu_edit_widgets"
android:textColor="@color/text_color_primary"
app:backgroundTint="?colorSurface"
app:icon="@drawable/ic_edit"
app:iconTint="@color/text_color_primary" />
app:icon="@drawable/ic_edit" />
</LinearLayout>
</LinearLayout>
@ -185,10 +183,10 @@
android:id="@+id/editWidgetToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?colorSurface"
android:elevation="4dp"
android:translationY="-56dp"
android:visibility="gone"
style="@style/Widget.Material3.Toolbar.Surface"
app:title="@string/menu_edit_widgets" />
</FrameLayout>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="weather_sun">@color/amber</color>
<color name="weather_moon">#E0E0E0</color>
<color name="weather_cloud_light_1">#ECEFF1</color>
<color name="weather_cloud_light_2">#CFD8DC</color>
<color name="weather_cloud_medium_1">#78909C</color>
<color name="weather_cloud_medium_2">#607D8B</color>
<color name="weather_cloud_dark_1">#546E7A</color>
<color name="weather_cloud_dark_2">#455A64</color>
<color name="weather_snow">#F5F5F5</color>
<color name="weather_rain">@color/blue</color>
<color name="weather_hail">#E3F2FD</color>
<color name="weather_hot">@color/red</color>
<color name="weather_cold">@color/lightblue</color>
<color name="weather_wind">#CFD8DC</color>
<color name="weather_wind_dark">#78909C</color>
<color name="weather_fog">@color/weather_cloud_light_2</color>
<color name="weather_lightning_bolt">@color/amber</color>
</resources>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="weather_sun">@color/amber</color>
<color name="weather_moon">#9E9E9E</color>
<color name="weather_cloud_light_1">#ECEFF1</color>
<color name="weather_cloud_light_2">#90A4AE</color>
<color name="weather_cloud_medium_1">#546E7A</color>
<color name="weather_cloud_medium_2">#455a64</color>
<color name="weather_cloud_dark_1">#37474F</color>
<color name="weather_cloud_dark_2">#263238</color>
<color name="weather_snow">#E0E0E0</color>
<color name="weather_rain">@color/blue</color>
<color name="weather_hail">#BBDEFB</color>
<color name="weather_hot">@color/red</color>
<color name="weather_cold">@color/lightblue</color>
<color name="weather_wind">#90A4AE</color>
<color name="weather_wind_dark">#546E7A</color>
<color name="weather_fog">@color/weather_cloud_light_2</color>
<color name="weather_lightning_bolt">@color/amber</color>
</resources>