diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d80ac9b9..2078939f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -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"> diff --git a/app/src/main/java/de/mm20/launcher2/activity/SettingsActivity.kt b/app/src/main/java/de/mm20/launcher2/activity/SettingsActivity.kt index dc51b4b7..6ae2df69 100644 --- a/app/src/main/java/de/mm20/launcher2/activity/SettingsActivity.kt +++ b/app/src/main/java/de/mm20/launcher2/activity/SettingsActivity.kt @@ -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(android.R.id.content)?.setBackgroundColor(getColor(R.color.settings_window_background)) } override fun onSaveInstanceState(outState: Bundle) { diff --git a/app/src/main/java/de/mm20/launcher2/fragment/PreferencesAboutFragment.kt b/app/src/main/java/de/mm20/launcher2/fragment/PreferencesAboutFragment.kt index 67726743..7213dbbb 100644 --- a/app/src/main/java/de/mm20/launcher2/fragment/PreferencesAboutFragment.kt +++ b/app/src/main/java/de/mm20/launcher2/fragment/PreferencesAboutFragment.kt @@ -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("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 } diff --git a/app/src/main/java/de/mm20/launcher2/fragment/PreferencesAppearanceFragment.kt b/app/src/main/java/de/mm20/launcher2/fragment/PreferencesAppearanceFragment.kt index 640dcaa2..ed9622e4 100644 --- a/app/src/main/java/de/mm20/launcher2/fragment/PreferencesAppearanceFragment.kt +++ b/app/src/main/java/de/mm20/launcher2/fragment/PreferencesAppearanceFragment.kt @@ -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("card_background")?.setOnPreferenceChangeListener { _, newValue -> + requireActivity().recreate() + true + } + findPreference("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("legacy_icon_bg")?.setOnPreferenceChangeListener { _, _ -> - iconRepository.clearCache() + iconRepository.recreate() true } diff --git a/app/src/main/java/de/mm20/launcher2/fragment/PreferencesCardFragment.kt b/app/src/main/java/de/mm20/launcher2/fragment/PreferencesCardFragment.kt index 7564bfc3..a15f2a4f 100644 --- a/app/src/main/java/de/mm20/launcher2/fragment/PreferencesCardFragment.kt +++ b/app/src/main/java/de/mm20/launcher2/fragment/PreferencesCardFragment.kt @@ -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("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() diff --git a/app/src/main/res/layout/fragment_card_settings.xml b/app/src/main/res/layout/fragment_card_settings.xml index d492d631..1503873e 100644 --- a/app/src/main/res/layout/fragment_card_settings.xml +++ b/app/src/main/res/layout/fragment_card_settings.xml @@ -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"> diff --git a/app/src/main/res/xml/preferences_appearance.xml b/app/src/main/res/xml/preferences_appearance.xml index 74c114fd..40392ee6 100644 --- a/app/src/main/res/xml/preferences_appearance.xml +++ b/app/src/main/res/xml/preferences_appearance.xml @@ -8,6 +8,15 @@ app:key="theme" app:summary="%s" app:title="@string/preference_theme" /> + + - - \ No newline at end of file diff --git a/applications/src/main/java/de/mm20/launcher2/applications/AppRepository.kt b/applications/src/main/java/de/mm20/launcher2/applications/AppRepository.kt index fe106336..0510772e 100644 --- a/applications/src/main/java/de/mm20/launcher2/applications/AppRepository.kt +++ b/applications/src/main/java/de/mm20/launcher2/applications/AppRepository.kt @@ -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) } diff --git a/applications/src/main/java/de/mm20/launcher2/applications/Module.kt b/applications/src/main/java/de/mm20/launcher2/applications/Module.kt index b7017c0c..26e7b4be 100644 --- a/applications/src/main/java/de/mm20/launcher2/applications/Module.kt +++ b/applications/src/main/java/de/mm20/launcher2/applications/Module.kt @@ -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()) } } \ No newline at end of file diff --git a/applications/src/main/java/de/mm20/launcher2/search/data/LauncherApp.kt b/applications/src/main/java/de/mm20/launcher2/search/data/LauncherApp.kt index ce935217..4bf0b6be 100644 --- a/applications/src/main/java/de/mm20/launcher2/search/data/LauncherApp.kt +++ b/applications/src/main/java/de/mm20/launcher2/search/data/LauncherApp.kt @@ -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() - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { - val launcherApps = context.getSystemService()!! - 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() - } - 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() + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { + val launcherApps = context.getSystemService()!! + 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() } - 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 diff --git a/base/src/main/res/values-night-v31/color-schemes.xml b/base/src/main/res/values-night-v31/color-schemes.xml new file mode 100644 index 00000000..c5cc52ae --- /dev/null +++ b/base/src/main/res/values-night-v31/color-schemes.xml @@ -0,0 +1,31 @@ + + + \ No newline at end of file diff --git a/base/src/main/res/values-night/color-schemes.xml b/base/src/main/res/values-night/color-schemes.xml new file mode 100644 index 00000000..f3ee9f25 --- /dev/null +++ b/base/src/main/res/values-night/color-schemes.xml @@ -0,0 +1,61 @@ + + + + + \ No newline at end of file diff --git a/base/src/main/res/values-night/colors.xml b/base/src/main/res/values-night/colors.xml index 367f4d29..959051a5 100644 --- a/base/src/main/res/values-night/colors.xml +++ b/base/src/main/res/values-night/colors.xml @@ -1,5 +1,6 @@ + #00DE7A #E57373 #F06292 #BA68C8 diff --git a/base/src/main/res/values-night/styles.xml b/base/src/main/res/values-night/styles.xml index e6ff1207..6f6b580d 100644 --- a/base/src/main/res/values-night/styles.xml +++ b/base/src/main/res/values-night/styles.xml @@ -3,6 +3,11 @@ + + + + + \ No newline at end of file diff --git a/base/src/main/res/values-v31/color-schemes.xml b/base/src/main/res/values-v31/color-schemes.xml new file mode 100644 index 00000000..88383b07 --- /dev/null +++ b/base/src/main/res/values-v31/color-schemes.xml @@ -0,0 +1,31 @@ + + + \ No newline at end of file diff --git a/base/src/main/res/values/color-schemes.xml b/base/src/main/res/values/color-schemes.xml new file mode 100644 index 00000000..73633df6 --- /dev/null +++ b/base/src/main/res/values/color-schemes.xml @@ -0,0 +1,61 @@ + + + + + \ No newline at end of file diff --git a/base/src/main/res/values/colors.xml b/base/src/main/res/values/colors.xml index 3f06735d..ecea76b4 100644 --- a/base/src/main/res/values/colors.xml +++ b/base/src/main/res/values/colors.xml @@ -2,6 +2,7 @@ #8A000000 + #00A55B #E53935 #D81B60 #9C27B0 diff --git a/base/src/main/res/values/styles.xml b/base/src/main/res/values/styles.xml index 7f2c22ce..0cb62b09 100644 --- a/base/src/main/res/values/styles.xml +++ b/base/src/main/res/values/styles.xml @@ -1,6 +1,6 @@ - - - - - - diff --git a/base/src/main/res/values/themes.xml b/base/src/main/res/values/themes.xml new file mode 100644 index 00000000..acff2b54 --- /dev/null +++ b/base/src/main/res/values/themes.xml @@ -0,0 +1,42 @@ + + + + + + + + + + \ No newline at end of file diff --git a/crashreporter/src/main/res/layout/activity_log_message.xml b/crashreporter/src/main/res/layout/activity_log_message.xml index bd16c5e8..69a6f8e7 100644 --- a/crashreporter/src/main/res/layout/activity_log_message.xml +++ b/crashreporter/src/main/res/layout/activity_log_message.xml @@ -10,19 +10,15 @@ android:layout_height="wrap_content" android:orientation="vertical"> - + android:layout_height="wrap_content"> + android:layout_height="?attr/actionBarSize" /> @@ -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" /> diff --git a/crashreporter/src/main/res/layout/crash_reporter_activity.xml b/crashreporter/src/main/res/layout/crash_reporter_activity.xml index 59e46bf7..85be3d33 100644 --- a/crashreporter/src/main/res/layout/crash_reporter_activity.xml +++ b/crashreporter/src/main/res/layout/crash_reporter_activity.xml @@ -7,24 +7,20 @@ tools:context="com.balsikandar.crashreporter.ui.CrashReporterActivity"> - + android:layout_height="wrap_content"> - + android:layout_height="wrap_content"/> + android:layout_height="?attr/actionBarSize" /> diff --git a/crashreporter/src/main/res/values/styles.xml b/crashreporter/src/main/res/values/styles.xml index d08da4cc..44640ab1 100644 --- a/crashreporter/src/main/res/values/styles.xml +++ b/crashreporter/src/main/res/values/styles.xml @@ -1,9 +1,8 @@ - \ No newline at end of file diff --git a/database/src/main/java/de/mm20/launcher2/database/IconDao.kt b/database/src/main/java/de/mm20/launcher2/database/IconDao.kt index 444c8ca3..0a6bdeb5 100644 --- a/database/src/main/java/de/mm20/launcher2/database/IconDao.kt +++ b/database/src/main/java/de/mm20/launcher2/database/IconDao.kt @@ -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) @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) { + deleteIcons(packageName) + insertAll(icons) + } + @Insert fun installIconPack(iconPack: IconPackEntity) @Query("SELECT * FROM IconPack") - fun getInstalledIconPacks(): List + suspend fun getInstalledIconPacks(): List @Query("SELECT * FROM IconPack") fun getInstalledIconPacksLiveData(): LiveData> @@ -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 + suspend fun getPacks(packageName: String, version: String): List @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 + suspend fun getIconBacks(pack: String): List @Query("SELECT drawable FROM Icons WHERE iconPack = :pack AND type = 'iconupon'") - fun getIconUpons(pack: String): List + suspend fun getIconUpons(pack: String): List @Query("SELECT drawable FROM Icons WHERE iconPack = :pack AND type = 'iconmask'") - fun getIconMasks(pack: String): List + suspend fun getIconMasks(pack: String): List @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? } \ No newline at end of file diff --git a/i18n/src/main/res/values-de/strings.xml b/i18n/src/main/res/values-de/strings.xml index b771d0d0..e5ce7d45 100644 --- a/i18n/src/main/res/values-de/strings.xml +++ b/i18n/src/main/res/values-de/strings.xml @@ -381,7 +381,7 @@ 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. Alle anzeigen Hintergrund - Standard (weiß/dunkelgrau) + Standard Weiß/schwarz Farbig (aus Hintergrundbild) Farbschema diff --git a/i18n/src/main/res/values/strings.xml b/i18n/src/main/res/values/strings.xml index 6e157b85..564dd65b 100644 --- a/i18n/src/main/res/values/strings.xml +++ b/i18n/src/main/res/values/strings.xml @@ -379,7 +379,7 @@ "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." Show all Background - Default (white/dark gray) + Default White/black Colored (from wallpaper) diff --git a/preferences/src/main/java/de/mm20/launcher2/preferences/LauncherPreferences.kt b/preferences/src/main/java/de/mm20/launcher2/preferences/LauncherPreferences.kt index b5923107..315943e3 100644 --- a/preferences/src/main/java/de/mm20/launcher2/preferences/LauncherPreferences.kt +++ b/preferences/src/main/java/de/mm20/launcher2/preferences/LauncherPreferences.kt @@ -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 } } } diff --git a/ui/build.gradle.kts b/ui/build.gradle.kts index b3c16b74..28109208 100644 --- a/ui/build.gradle.kts +++ b/ui/build.gradle.kts @@ -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) diff --git a/ui/src/main/java/de/mm20/launcher2/ui/AppTheme.kt b/ui/src/main/java/de/mm20/launcher2/ui/AppTheme.kt index c70760ae..63fc38e4 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/AppTheme.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/AppTheme.kt @@ -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 - ) + } \ No newline at end of file diff --git a/ui/src/main/java/de/mm20/launcher2/ui/ColorSchemeTest.kt b/ui/src/main/java/de/mm20/launcher2/ui/ColorSchemeTest.kt index a5fec47d..d49f45e3 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/ColorSchemeTest.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/ColorSchemeTest.kt @@ -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)) } } \ No newline at end of file diff --git a/ui/src/main/java/de/mm20/launcher2/ui/InformationText.kt b/ui/src/main/java/de/mm20/launcher2/ui/InformationText.kt index 045c359a..74e31770 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/InformationText.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/InformationText.kt @@ -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) ) } diff --git a/ui/src/main/java/de/mm20/launcher2/ui/LegacyAppTheme.kt b/ui/src/main/java/de/mm20/launcher2/ui/LegacyAppTheme.kt index 95253be8..be083743 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/LegacyAppTheme.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/LegacyAppTheme.kt @@ -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() ) } \ No newline at end of file diff --git a/ui/src/main/java/de/mm20/launcher2/ui/ShapedLauncherIcon.kt b/ui/src/main/java/de/mm20/launcher2/ui/ShapedLauncherIcon.kt index 62c58e5f..d68898c6 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/ShapedLauncherIcon.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/ShapedLauncherIcon.kt @@ -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 } diff --git a/ui/src/main/java/de/mm20/launcher2/ui/activity/ComposeActivity.kt b/ui/src/main/java/de/mm20/launcher2/ui/activity/ComposeActivity.kt index f5391b83..67af56cb 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/activity/ComposeActivity.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/activity/ComposeActivity.kt @@ -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() } diff --git a/ui/src/main/java/de/mm20/launcher2/ui/compat/AnimatedVectorResourcePolyfill.kt b/ui/src/main/java/de/mm20/launcher2/ui/compat/AnimatedVectorResourcePolyfill.kt deleted file mode 100644 index a90cb720..00000000 --- a/ui/src/main/java/de/mm20/launcher2/ui/compat/AnimatedVectorResourcePolyfill.kt +++ /dev/null @@ -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) - } -} \ No newline at end of file diff --git a/ui/src/main/java/de/mm20/launcher2/ui/component/Chip.kt b/ui/src/main/java/de/mm20/launcher2/ui/component/Chip.kt index acd551b2..834d25f2 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/component/Chip.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/component/Chip.kt @@ -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 diff --git a/ui/src/main/java/de/mm20/launcher2/ui/component/Clocks.kt b/ui/src/main/java/de/mm20/launcher2/ui/component/Clocks.kt index c077fc98..ddcf8d92 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/component/Clocks.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/component/Clocks.kt @@ -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, diff --git a/ui/src/main/java/de/mm20/launcher2/ui/component/ColorPicker.kt b/ui/src/main/java/de/mm20/launcher2/ui/component/ColorPicker.kt index 4c7e838b..db3b0d9e 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/component/ColorPicker.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/component/ColorPicker.kt @@ -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) diff --git a/ui/src/main/java/de/mm20/launcher2/ui/component/DefaultSwipeActions.kt b/ui/src/main/java/de/mm20/launcher2/ui/component/DefaultSwipeActions.kt index 10ceb787..15f5c780 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/component/DefaultSwipeActions.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/component/DefaultSwipeActions.kt @@ -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), diff --git a/ui/src/main/java/de/mm20/launcher2/ui/component/LottieIcon.kt b/ui/src/main/java/de/mm20/launcher2/ui/component/LottieIcon.kt index 3623f585..5fdd33a4 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/component/LottieIcon.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/component/LottieIcon.kt @@ -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 diff --git a/ui/src/main/java/de/mm20/launcher2/ui/component/SearchBar.kt b/ui/src/main/java/de/mm20/launcher2/ui/component/SearchBar.kt index 0b76f831..d01d9619 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/component/SearchBar.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/component/SearchBar.kt @@ -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 ) } } diff --git a/ui/src/main/java/de/mm20/launcher2/ui/component/SearchColumn.kt b/ui/src/main/java/de/mm20/launcher2/ui/component/SearchColumn.kt index 364ee8b9..9926bd14 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/component/SearchColumn.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/component/SearchColumn.kt @@ -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 diff --git a/ui/src/main/java/de/mm20/launcher2/ui/component/TextClock.kt b/ui/src/main/java/de/mm20/launcher2/ui/component/TextClock.kt index 492b47ab..d732878b 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/component/TextClock.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/component/TextClock.kt @@ -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 diff --git a/ui/src/main/java/de/mm20/launcher2/ui/component/Toolbar.kt b/ui/src/main/java/de/mm20/launcher2/ui/component/Toolbar.kt index 05a849b1..dc9003ba 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/component/Toolbar.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/component/Toolbar.kt @@ -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, 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, onDismiss: () -> U ) { Text( action.label, - style = MaterialTheme.typography.subtitle2 + style = MaterialTheme.typography.titleMedium ) } } @@ -125,7 +127,7 @@ fun ColumnScope.OverflowMenuItems(items: List, onDismiss: () -> U }) { Text( action.label, - style = MaterialTheme.typography.subtitle2 + style = MaterialTheme.typography.titleMedium ) } } diff --git a/ui/src/main/java/de/mm20/launcher2/ui/component/WidgetColumn.kt b/ui/src/main/java/de/mm20/launcher2/ui/component/WidgetColumn.kt index 270f7040..aa4d4d93 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/component/WidgetColumn.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/component/WidgetColumn.kt @@ -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 }) diff --git a/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/ColorPreference.kt b/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/ColorPreference.kt index 728f6f0e..31a57da7 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/ColorPreference.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/ColorPreference.kt @@ -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 ) {} diff --git a/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/ListPreference.kt b/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/ListPreference.kt index a78d5a55..268c6b37 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/ListPreference.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/ListPreference.kt @@ -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 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 ) diff --git a/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/Preference.kt b/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/Preference.kt index 7ee5b8ca..1d7b33c1 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/Preference.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/Preference.kt @@ -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) ) } diff --git a/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/PreferenceCategory.kt b/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/PreferenceCategory.kt index 06d73321..e15d66dc 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/PreferenceCategory.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/PreferenceCategory.kt @@ -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 ) } } diff --git a/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/PreferenceScreen.kt b/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/PreferenceScreen.kt index 29a35591..c59d1ede 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/PreferenceScreen.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/PreferenceScreen.kt @@ -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, ) } } diff --git a/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/SwitchPreference.kt b/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/SwitchPreference.kt index 093ee0d6..be78be28 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/SwitchPreference.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/component/preferences/SwitchPreference.kt @@ -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 )) } ) diff --git a/ui/src/main/java/de/mm20/launcher2/ui/icons/Searchable.kt b/ui/src/main/java/de/mm20/launcher2/ui/icons/Searchable.kt index c46044fb..8027a140 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/icons/Searchable.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/icons/Searchable.kt @@ -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 ) } diff --git a/ui/src/main/java/de/mm20/launcher2/ui/legacy/search/ApplicationDetailRepresentation.kt b/ui/src/main/java/de/mm20/launcher2/ui/legacy/search/ApplicationDetailRepresentation.kt index 2be9344e..a28e45a4 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/legacy/search/ApplicationDetailRepresentation.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/legacy/search/ApplicationDetailRepresentation.kt @@ -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) diff --git a/ui/src/main/java/de/mm20/launcher2/ui/legacy/view/LauncherCardView.kt b/ui/src/main/java/de/mm20/launcher2/ui/legacy/view/LauncherCardView.kt index 209b590d..a7794a84 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/legacy/view/LauncherCardView.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/legacy/view/LauncherCardView.kt @@ -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 diff --git a/ui/src/main/java/de/mm20/launcher2/ui/legacy/widget/MusicWidget.kt b/ui/src/main/java/de/mm20/launcher2/ui/legacy/widget/MusicWidget.kt index e188d9f1..3aab2119 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/legacy/widget/MusicWidget.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/legacy/widget/MusicWidget.kt @@ -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() } diff --git a/ui/src/main/java/de/mm20/launcher2/ui/legacy/widget/WeatherWidget.kt b/ui/src/main/java/de/mm20/launcher2/ui/legacy/widget/WeatherWidget.kt index 9f6d84f8..3ce9c2d2 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/legacy/widget/WeatherWidget.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/legacy/widget/WeatherWidget.kt @@ -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() } diff --git a/ui/src/main/java/de/mm20/launcher2/ui/locals/CompositionLocals.kt b/ui/src/main/java/de/mm20/launcher2/ui/locals/CompositionLocals.kt index 112bbcdb..53d427c2 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/locals/CompositionLocals.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/locals/CompositionLocals.kt @@ -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(defaultFactory = { n val LocalWallpaperColors = compositionLocalOf { null } -val LocalColorScheme = compositionLocalOf { DefaultColorScheme() } +val LocalColorScheme = compositionLocalOf { DefaultColorPalette() } val LocalNavController = compositionLocalOf { null } \ No newline at end of file diff --git a/ui/src/main/java/de/mm20/launcher2/ui/screens/LauncherMainScreen.kt b/ui/src/main/java/de/mm20/launcher2/ui/screens/LauncherMainScreen.kt index 016b8bb0..9b5c9c31 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/screens/LauncherMainScreen.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/screens/LauncherMainScreen.kt @@ -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 diff --git a/ui/src/main/java/de/mm20/launcher2/ui/screens/settings/SettingsAboutScreen.kt b/ui/src/main/java/de/mm20/launcher2/ui/screens/settings/SettingsAboutScreen.kt index da280718..3fa9475e 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/screens/settings/SettingsAboutScreen.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/screens/settings/SettingsAboutScreen.kt @@ -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() { ) ) }) - } + }*/ } } ) diff --git a/ui/src/main/java/de/mm20/launcher2/ui/screens/settings/SettingsColorsScreen.kt b/ui/src/main/java/de/mm20/launcher2/ui/screens/settings/SettingsColorsScreen.kt index 3fb8128d..a50da0de 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/screens/settings/SettingsColorsScreen.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/screens/settings/SettingsColorsScreen.kt @@ -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, ) \ No newline at end of file diff --git a/ui/src/main/java/de/mm20/launcher2/ui/screens/settings/SettingsLicenseScreen.kt b/ui/src/main/java/de/mm20/launcher2/ui/screens/settings/SettingsLicenseScreen.kt index 2202459d..bc801cfb 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/screens/settings/SettingsLicenseScreen.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/screens/settings/SettingsLicenseScreen.kt @@ -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( diff --git a/ui/src/main/java/de/mm20/launcher2/ui/search/ApplicationItem.kt b/ui/src/main/java/de/mm20/launcher2/ui/search/ApplicationItem.kt index fe32898d..e4b7f750 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/search/ApplicationItem.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/search/ApplicationItem.kt @@ -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, ) diff --git a/ui/src/main/java/de/mm20/launcher2/ui/search/BasicGridItem.kt b/ui/src/main/java/de/mm20/launcher2/ui/search/BasicGridItem.kt index 210c186f..2a539b87 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/search/BasicGridItem.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/search/BasicGridItem.kt @@ -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 diff --git a/ui/src/main/java/de/mm20/launcher2/ui/search/CalculatorItem.kt b/ui/src/main/java/de/mm20/launcher2/ui/search/CalculatorItem.kt index a7ccf381..50e39763 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/search/CalculatorItem.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/search/CalculatorItem.kt @@ -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]+"))) { diff --git a/ui/src/main/java/de/mm20/launcher2/ui/search/FileItem.kt b/ui/src/main/java/de/mm20/launcher2/ui/search/FileItem.kt index f956385b..2f95046d 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/search/FileItem.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/search/FileItem.kt @@ -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, ) diff --git a/ui/src/main/java/de/mm20/launcher2/ui/search/GridItemLabel.kt b/ui/src/main/java/de/mm20/launcher2/ui/search/GridItemLabel.kt index bc2e6aff..6f017f87 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/search/GridItemLabel.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/search/GridItemLabel.kt @@ -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() diff --git a/ui/src/main/java/de/mm20/launcher2/ui/search/SearchableGrid.kt b/ui/src/main/java/de/mm20/launcher2/ui/search/SearchableGrid.kt index 55e97290..ac8d23fd 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/search/SearchableGrid.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/search/SearchableGrid.kt @@ -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, 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) diff --git a/ui/src/main/java/de/mm20/launcher2/ui/search/SearchableItem.kt b/ui/src/main/java/de/mm20/launcher2/ui/search/SearchableItem.kt index ff693568..96df210b 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/search/SearchableItem.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/search/SearchableItem.kt @@ -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 ) { diff --git a/ui/src/main/java/de/mm20/launcher2/ui/search/SearchableList.kt b/ui/src/main/java/de/mm20/launcher2/ui/search/SearchableList.kt index 45dcb381..830cd8e4 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/search/SearchableList.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/search/SearchableList.kt @@ -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()) } \ No newline at end of file diff --git a/ui/src/main/java/de/mm20/launcher2/ui/search/WikipediaItem.kt b/ui/src/main/java/de/mm20/launcher2/ui/search/WikipediaItem.kt index 1eff2002..7cf32a42 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/search/WikipediaItem.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/search/WikipediaItem.kt @@ -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( diff --git a/ui/src/main/java/de/mm20/launcher2/ui/searchable/CalendarEventItem.kt b/ui/src/main/java/de/mm20/launcher2/ui/searchable/CalendarEventItem.kt index 8a26ca8b..da78cc90 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/searchable/CalendarEventItem.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/searchable/CalendarEventItem.kt @@ -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 ) } } diff --git a/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/BlackWhiteColorScheme.kt b/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/BlackWhiteColorPalette.kt similarity index 56% rename from ui/src/main/java/de/mm20/launcher2/ui/theme/colors/BlackWhiteColorScheme.kt rename to ui/src/main/java/de/mm20/launcher2/ui/theme/colors/BlackWhiteColorPalette.kt index 184d9c68..7c37f6e8 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/BlackWhiteColorScheme.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/BlackWhiteColorPalette.kt @@ -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 } \ No newline at end of file diff --git a/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/ColorPalette.kt b/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/ColorPalette.kt new file mode 100644 index 00000000..9e9825c7 --- /dev/null +++ b/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/ColorPalette.kt @@ -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, + ) +} \ No newline at end of file diff --git a/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/ColorScheme.kt b/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/ColorScheme.kt deleted file mode 100644 index fd5495a3..00000000 --- a/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/ColorScheme.kt +++ /dev/null @@ -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 -} \ No newline at end of file diff --git a/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/ColorSwatch.kt b/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/ColorSwatch.kt index 665c1183..6c7e3f01 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/ColorSwatch.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/ColorSwatch.kt @@ -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 })), ) } \ No newline at end of file diff --git a/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/CustomColorScheme.kt b/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/CustomColorPalette.kt similarity index 85% rename from ui/src/main/java/de/mm20/launcher2/ui/theme/colors/CustomColorScheme.kt rename to ui/src/main/java/de/mm20/launcher2/ui/theme/colors/CustomColorPalette.kt index 1ce07570..932fbe6c 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/CustomColorScheme.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/CustomColorPalette.kt @@ -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) } diff --git a/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/DefaultColorPalette.kt b/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/DefaultColorPalette.kt new file mode 100644 index 00000000..3295043b --- /dev/null +++ b/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/DefaultColorPalette.kt @@ -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)) + +} \ No newline at end of file diff --git a/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/DefaultColorScheme.kt b/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/DefaultColorScheme.kt deleted file mode 100644 index 1ceadf70..00000000 --- a/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/DefaultColorScheme.kt +++ /dev/null @@ -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)) - -} \ No newline at end of file diff --git a/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/MM20ColorPalette.kt b/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/MM20ColorPalette.kt new file mode 100644 index 00000000..65723fb0 --- /dev/null +++ b/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/MM20ColorPalette.kt @@ -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)) +} \ No newline at end of file diff --git a/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/MM20ColorScheme.kt b/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/MM20ColorScheme.kt deleted file mode 100644 index c2e42b3c..00000000 --- a/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/MM20ColorScheme.kt +++ /dev/null @@ -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)) -} \ No newline at end of file diff --git a/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/SystemColorPalette.kt b/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/SystemColorPalette.kt new file mode 100644 index 00000000..633f9399 --- /dev/null +++ b/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/SystemColorPalette.kt @@ -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)), + ) +} \ No newline at end of file diff --git a/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/SystemColorScheme.kt b/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/SystemColorScheme.kt deleted file mode 100644 index 914d7a5d..00000000 --- a/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/SystemColorScheme.kt +++ /dev/null @@ -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)), - ) -} \ No newline at end of file diff --git a/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/WallpaperColorScheme.kt b/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/WallpaperColorPalette.kt similarity index 71% rename from ui/src/main/java/de/mm20/launcher2/ui/theme/colors/WallpaperColorScheme.kt rename to ui/src/main/java/de/mm20/launcher2/ui/theme/colors/WallpaperColorPalette.kt index 5e36886f..887d724f 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/WallpaperColorScheme.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/theme/colors/WallpaperColorPalette.kt @@ -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 { diff --git a/ui/src/main/java/de/mm20/launcher2/ui/weather/AnimatedWeatherIcon.kt b/ui/src/main/java/de/mm20/launcher2/ui/weather/AnimatedWeatherIcon.kt index 1f6e771c..a5cd2d20 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/weather/AnimatedWeatherIcon.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/weather/AnimatedWeatherIcon.kt @@ -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) ) } diff --git a/ui/src/main/java/de/mm20/launcher2/ui/weather/WeatherIcon.kt b/ui/src/main/java/de/mm20/launcher2/ui/weather/WeatherIcon.kt index f9c7944a..07bad8b5 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/weather/WeatherIcon.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/weather/WeatherIcon.kt @@ -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) ) } } \ No newline at end of file diff --git a/ui/src/main/java/de/mm20/launcher2/ui/widget/CalendarWidget.kt b/ui/src/main/java/de/mm20/launcher2/ui/widget/CalendarWidget.kt index 9e111f27..2dc30937 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/widget/CalendarWidget.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/widget/CalendarWidget.kt @@ -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() } diff --git a/ui/src/main/java/de/mm20/launcher2/ui/widget/ClockWidget.kt b/ui/src/main/java/de/mm20/launcher2/ui/widget/ClockWidget.kt index a84bb4da..a1396aa9 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/widget/ClockWidget.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/widget/ClockWidget.kt @@ -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) { diff --git a/ui/src/main/java/de/mm20/launcher2/ui/widget/MusicWidget.kt b/ui/src/main/java/de/mm20/launcher2/ui/widget/MusicWidget.kt index 8fd29cec..c0e6638d 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/widget/MusicWidget.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/widget/MusicWidget.kt @@ -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) ) } diff --git a/ui/src/main/java/de/mm20/launcher2/ui/widget/PlatformWidget.kt b/ui/src/main/java/de/mm20/launcher2/ui/widget/PlatformWidget.kt index b6a8ac69..afae5f49 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/widget/PlatformWidget.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/widget/PlatformWidget.kt @@ -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 = { diff --git a/ui/src/main/java/de/mm20/launcher2/ui/widget/WeatherWidget.kt b/ui/src/main/java/de/mm20/launcher2/ui/widget/WeatherWidget.kt index 2ae3a50f..b8b5c58b 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/widget/WeatherWidget.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/widget/WeatherWidget.kt @@ -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) ) } diff --git a/ui/src/main/java/de/mm20/launcher2/ui/widget/parts/DatePart.kt b/ui/src/main/java/de/mm20/launcher2/ui/widget/parts/DatePart.kt index 91dcf1df..91d1a2f9 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/widget/parts/DatePart.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/widget/parts/DatePart.kt @@ -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 ) } \ No newline at end of file diff --git a/ui/src/main/res/layout/activity_launcher.xml b/ui/src/main/res/layout/activity_launcher.xml index 27059102..b958497f 100644 --- a/ui/src/main/res/layout/activity_launcher.xml +++ b/ui/src/main/res/layout/activity_launcher.xml @@ -126,6 +126,7 @@ android:animateLayoutChanges="true" android:clipChildren="false" android:clipToPadding="false" + android:paddingTop="8dp" android:orientation="vertical"> + app:icon="@drawable/ic_edit" /> @@ -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" /> diff --git a/ui/src/main/res/values-night/weather_colors.xml b/ui/src/main/res/values-night/weather_colors.xml new file mode 100644 index 00000000..83d6016f --- /dev/null +++ b/ui/src/main/res/values-night/weather_colors.xml @@ -0,0 +1,20 @@ + + + @color/amber + #E0E0E0 + #ECEFF1 + #CFD8DC + #78909C + #607D8B + #546E7A + #455A64 + #F5F5F5 + @color/blue + #E3F2FD + @color/red + @color/lightblue + #CFD8DC + #78909C + @color/weather_cloud_light_2 + @color/amber + \ No newline at end of file diff --git a/ui/src/main/res/values/weather_colors.xml b/ui/src/main/res/values/weather_colors.xml new file mode 100644 index 00000000..3ddcc78f --- /dev/null +++ b/ui/src/main/res/values/weather_colors.xml @@ -0,0 +1,20 @@ + + + @color/amber + #9E9E9E + #ECEFF1 + #90A4AE + #546E7A + #455a64 + #37474F + #263238 + #E0E0E0 + @color/blue + #BBDEFB + @color/red + @color/lightblue + #90A4AE + #546E7A + @color/weather_cloud_light_2 + @color/amber + \ No newline at end of file