diff --git a/README.md b/README.md index 53e1ae3..d610a18 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,30 @@ # MDC-Android Compose Theme Adapter +!!! warning + **These libraries are deprecated in favor of the new [Accompanist][accompanist] Theme Adapter artifacts. The migration guide and original documentation is below.** + +## Migration + +MDC-Android Compose Theme Adapters have moved from: +* The `compose-theme-adapter` artifact to the [`accompanist/themeadapter-material`][themeadaptermateriallib] artifact +* The `compose-theme-adapter-3` artifact to the [`accompanist/themeadapter-material3`][themeadaptermaterial3lib] artifact +* The `compose-theme-adapter-core` artifact to the [`accompanist/themeadapter-core`][themeadaptercorelib] artifact + +The implementations are identical but the dependencies and import packages have changed. + +### Migration steps + +1. Change any dependencies from: + 1. `com.google.android.material:compose-theme-adapter:` to `com.google.accompanist:accompanist-themeadapter-material:` + 2. `com.google.android.material:compose-theme-adapter-3:` to `com.google.accompanist:accompanist-themeadapter-material3:` + 3. `com.google.android.material:compose-theme-adapter-core:` to `com.google.accompanist:accompanist-themeadapter-core:` +2. Change any imports from: + 1. `com.google.android.material.composethemeadapter.*` to `com.google.accompanist.themeadapter.material.*` + 2. `com.google.android.material.composethemeadapter3.*` to `com.google.accompanist.themeadapter.material3.*` + 3. `com.google.android.material.composethemeadapter.core.*` to `com.google.accompanist.themeadapter.core.*` + +## Original Docs + A library that enables reuse of [Material Components for Android][mdc] XML themes for theming in [Jetpack Compose][compose]. ## Usage @@ -234,3 +259,7 @@ limitations under the License. [m3colorscheme]: https://developer.android.com/reference/kotlin/androidx/compose/material3/ColorScheme [m3shapes]: https://developer.android.com/reference/kotlin/androidx/compose/material3/Shapes [m3typography]: https://developer.android.com/reference/kotlin/androidx/compose/material3/Typography + [accompanist]: https://github.com/google/accompanist + [themeadaptermateriallib]: https://google.github.io/accompanist/themeadapter-material + [themeadaptermaterial3lib]: https://google.github.io/accompanist/themeadapter-material3 + [themeadaptercorelib]: https://google.github.io/accompanist/themeadapter-core diff --git a/core/src/main/java/com/google/android/material/composethemeadapter/core/ResourceUtils.kt b/core/src/main/java/com/google/android/material/composethemeadapter/core/ResourceUtils.kt index 65fee25..42e7d1f 100644 --- a/core/src/main/java/com/google/android/material/composethemeadapter/core/ResourceUtils.kt +++ b/core/src/main/java/com/google/android/material/composethemeadapter/core/ResourceUtils.kt @@ -14,6 +14,8 @@ * limitations under the License. */ +@file:Suppress("DEPRECATION") + package com.google.android.material.composethemeadapter.core import android.annotation.SuppressLint @@ -57,6 +59,13 @@ import kotlin.concurrent.getOrSet * @param fallbackColor Value to return if the attribute is not defined or can't be coerced to a * [Color]. */ +@Deprecated( + """ + compose-theme-adapter-core is deprecated. + The API has moved to accompanist/themeadapter/core. + For more information, please visit https://google.github.io/accompanist/themeadapter-core + """ +) fun TypedArray.parseColor( index: Int, fallbackColor: Color = Color.Unspecified @@ -71,6 +80,13 @@ fun TypedArray.parseColor( * @param setTextColors Whether to read and set text colors from the style. Defaults to `false`. * @param defaultFontFamily Optional default font family to use in [TextStyle]s. */ +@Deprecated( + """ + compose-theme-adapter-core is deprecated. + The API has moved to accompanist/themeadapter/core. + For more information, please visit https://google.github.io/accompanist/themeadapter-core + """ +) fun parseTextAppearance( context: Context, @StyleRes id: Int, @@ -165,6 +181,13 @@ fun parseTextAppearance( * * @param index Index of attribute to retrieve. */ +@Deprecated( + """ + compose-theme-adapter-core is deprecated. + The API has moved to accompanist/themeadapter/core. + For more information, please visit https://google.github.io/accompanist/themeadapter-core + """ +) fun TypedArray.parseFontFamily(index: Int): FontFamilyWithWeight? { val tv = tempTypedValue.getOrSet(::TypedValue) if (getValue(index, tv) && tv.type == TypedValue.TYPE_STRING) { @@ -200,6 +223,13 @@ fun TypedArray.parseFontFamily(index: Int): FontFamilyWithWeight? { /** * A lightweight class for storing a [FontFamily] and [FontWeight]. */ +@Deprecated( + """ + compose-theme-adapter-core is deprecated. + The API has moved to accompanist/themeadapter/core. + For more information, please visit https://google.github.io/accompanist/themeadapter-core + """ +) data class FontFamilyWithWeight( val fontFamily: FontFamily, val weight: FontWeight = FontWeight.Normal @@ -211,6 +241,13 @@ data class FontFamilyWithWeight( * * @param id ID of XML resource to retrieve. */ +@Deprecated( + """ + compose-theme-adapter-core is deprecated. + The API has moved to accompanist/themeadapter/core. + For more information, please visit https://google.github.io/accompanist/themeadapter-core + """ +) @SuppressLint("RestrictedApi") // FontResourcesParserCompat.* @RequiresApi(23) // XML font families with > 1 fonts are only supported on API 23+ fun Resources.parseXmlFontFamily(id: Int): FontFamily? { @@ -259,6 +296,13 @@ private fun fontWeightOf(weight: Int): FontWeight = when (weight) { * @param fallbackTextUnit Value to return if the attribute is not defined or can't be coerced to a * [TextUnit]. */ +@Deprecated( + """ + compose-theme-adapter-core is deprecated. + The API has moved to accompanist/themeadapter/core. + For more information, please visit https://google.github.io/accompanist/themeadapter-core + """ +) fun TypedArray.parseTextUnit( index: Int, density: Density, @@ -289,6 +333,13 @@ fun TypedArray.parseTextUnit( * @param fallbackShape Value to return if the style resource ID is not defined or can't be coerced * to a [CornerBasedShape]. */ +@Deprecated( + """ + compose-theme-adapter-core is deprecated. + The API has moved to accompanist/themeadapter/core. + For more information, please visit https://google.github.io/accompanist/themeadapter-core + """ +) fun parseShapeAppearance( context: Context, @StyleRes id: Int, @@ -349,6 +400,13 @@ fun parseShapeAppearance( * * @param index Index of attribute to retrieve. */ +@Deprecated( + """ + compose-theme-adapter-core is deprecated. + The API has moved to accompanist/themeadapter/core. + For more information, please visit https://google.github.io/accompanist/themeadapter-core + """ +) fun TypedArray.parseCornerSize(index: Int): CornerSize? { val tv = tempTypedValue.getOrSet { TypedValue() } if (getValue(index, tv)) { diff --git a/material3Lib/src/androidTest/java/com/google/android/material/composethemeadapter3/test/Mdc3ThemeTest.kt b/material3Lib/src/androidTest/java/com/google/android/material/composethemeadapter3/test/Mdc3ThemeTest.kt index d1c2b75..72f3b58 100644 --- a/material3Lib/src/androidTest/java/com/google/android/material/composethemeadapter3/test/Mdc3ThemeTest.kt +++ b/material3Lib/src/androidTest/java/com/google/android/material/composethemeadapter3/test/Mdc3ThemeTest.kt @@ -14,6 +14,8 @@ * limitations under the License. */ +@file:Suppress("DEPRECATION") + package com.google.android.material.composethemeadapter3.test import androidx.compose.foundation.shape.CornerSize diff --git a/material3Lib/src/androidTest/java/com/google/android/material/composethemeadapter3/test/NotMdc3ThemeTest.kt b/material3Lib/src/androidTest/java/com/google/android/material/composethemeadapter3/test/NotMdc3ThemeTest.kt index 1e6df0e..8a5d294 100644 --- a/material3Lib/src/androidTest/java/com/google/android/material/composethemeadapter3/test/NotMdc3ThemeTest.kt +++ b/material3Lib/src/androidTest/java/com/google/android/material/composethemeadapter3/test/NotMdc3ThemeTest.kt @@ -14,6 +14,8 @@ * limitations under the License. */ +@file:Suppress("DEPRECATION") + package com.google.android.material.composethemeadapter3.test import androidx.compose.ui.test.junit4.createAndroidComposeRule diff --git a/material3Lib/src/main/java/com/google/android/material/composethemeadapter3/Mdc3Theme.kt b/material3Lib/src/main/java/com/google/android/material/composethemeadapter3/Mdc3Theme.kt index 4cebbdb..9b9b1c6 100644 --- a/material3Lib/src/main/java/com/google/android/material/composethemeadapter3/Mdc3Theme.kt +++ b/material3Lib/src/main/java/com/google/android/material/composethemeadapter3/Mdc3Theme.kt @@ -15,6 +15,8 @@ */ @file:JvmName("Mdc3Theme") +@file:Suppress("DEPRECATION") + package com.google.android.material.composethemeadapter3 import android.content.Context @@ -64,6 +66,13 @@ import java.lang.reflect.Method * @param setDefaultFontFamily whether to read and prioritize the `fontFamily` attributes from * [context]'s theme, over any specified in the MDC text appearances. Defaults to `false`. */ +@Deprecated( + """ + compose-theme-adapter-3 is deprecated. + The API has moved to accompanist/themeadapter/material3. + For more information, please visit https://google.github.io/accompanist/themeadapter-material3 + """ +) @Composable fun Mdc3Theme( context: Context = LocalContext.current, @@ -115,6 +124,13 @@ fun Mdc3Theme( * This class contains the individual components of a [MaterialTheme]: [ColorScheme] and * [Typography]. */ +@Deprecated( + """ + compose-theme-adapter-3 is deprecated. + The API has moved to accompanist/themeadapter/material3. + For more information, please visit https://google.github.io/accompanist/themeadapter-material3 + """ +) data class Theme3Parameters( val colorScheme: ColorScheme?, val typography: Typography?, @@ -150,6 +166,13 @@ data class Theme3Parameters( * [context]'s theme, over any specified in the MDC text appearances. Defaults to `false`. * @return [Theme3Parameters] instance containing the resulting [ColorScheme] and [Typography]. */ +@Deprecated( + """ + compose-theme-adapter-3 is deprecated. + The API has moved to accompanist/themeadapter/material3. + For more information, please visit https://google.github.io/accompanist/themeadapter-material3 + """ +) fun createMdc3Theme( context: Context, layoutDirection: LayoutDirection, diff --git a/materialLib/src/androidTest/java/com/google/android/material/composethemeadapter/test/DefaultFontFamilyMdcThemeTest.kt b/materialLib/src/androidTest/java/com/google/android/material/composethemeadapter/test/DefaultFontFamilyMdcThemeTest.kt index ebc835e..b9fc28a 100644 --- a/materialLib/src/androidTest/java/com/google/android/material/composethemeadapter/test/DefaultFontFamilyMdcThemeTest.kt +++ b/materialLib/src/androidTest/java/com/google/android/material/composethemeadapter/test/DefaultFontFamilyMdcThemeTest.kt @@ -14,6 +14,8 @@ * limitations under the License. */ +@file:Suppress("DEPRECATION") + package com.google.android.material.composethemeadapter.test import android.view.ContextThemeWrapper diff --git a/materialLib/src/androidTest/java/com/google/android/material/composethemeadapter/test/MdcThemeTest.kt b/materialLib/src/androidTest/java/com/google/android/material/composethemeadapter/test/MdcThemeTest.kt index 698e15b..1af3260 100644 --- a/materialLib/src/androidTest/java/com/google/android/material/composethemeadapter/test/MdcThemeTest.kt +++ b/materialLib/src/androidTest/java/com/google/android/material/composethemeadapter/test/MdcThemeTest.kt @@ -14,6 +14,8 @@ * limitations under the License. */ +@file:Suppress("DEPRECATION") + package com.google.android.material.composethemeadapter.test import androidx.appcompat.app.AppCompatActivity diff --git a/materialLib/src/androidTest/java/com/google/android/material/composethemeadapter/test/NotMdcThemeTest.kt b/materialLib/src/androidTest/java/com/google/android/material/composethemeadapter/test/NotMdcThemeTest.kt index fd20591..f07f9a7 100644 --- a/materialLib/src/androidTest/java/com/google/android/material/composethemeadapter/test/NotMdcThemeTest.kt +++ b/materialLib/src/androidTest/java/com/google/android/material/composethemeadapter/test/NotMdcThemeTest.kt @@ -14,6 +14,8 @@ * limitations under the License. */ +@file:Suppress("DEPRECATION") + package com.google.android.material.composethemeadapter.test import androidx.compose.ui.test.junit4.createAndroidComposeRule diff --git a/materialLib/src/main/java/com/google/android/material/composethemeadapter/MdcTheme.kt b/materialLib/src/main/java/com/google/android/material/composethemeadapter/MdcTheme.kt index ffba241..9886a47 100644 --- a/materialLib/src/main/java/com/google/android/material/composethemeadapter/MdcTheme.kt +++ b/materialLib/src/main/java/com/google/android/material/composethemeadapter/MdcTheme.kt @@ -15,6 +15,8 @@ */ @file:JvmName("MdcTheme") +@file:Suppress("DEPRECATION") + package com.google.android.material.composethemeadapter import android.content.Context @@ -71,6 +73,13 @@ import java.lang.reflect.Method * @param setDefaultFontFamily whether to read and prioritize the `fontFamily` attributes from * [context]'s theme, over any specified in the MDC text appearances. Defaults to `false`. */ +@Deprecated( + """ + compose-theme-adapter is deprecated. + The API has moved to accompanist/themeadapter/material. + For more information, please visit https://google.github.io/accompanist/themeadapter-material + """ +) @Composable fun MdcTheme( context: Context = LocalContext.current, @@ -122,6 +131,13 @@ fun MdcTheme( * This class contains the individual components of a [MaterialTheme]: [Colors], [Typography] * and [Shapes]. */ +@Deprecated( + """ + compose-theme-adapter is deprecated. + The API has moved to accompanist/themeadapter/material. + For more information, please visit https://google.github.io/accompanist/themeadapter-material + """ +) data class ThemeParameters( val colors: Colors?, val typography: Typography?, @@ -158,6 +174,13 @@ data class ThemeParameters( * @return [ThemeParameters] instance containing the resulting [Colors], [Typography] * and [Shapes]. */ +@Deprecated( + """ + compose-theme-adapter is deprecated. + The API has moved to accompanist/themeadapter/material. + For more information, please visit https://google.github.io/accompanist/themeadapter-material + """ +) fun createMdcTheme( context: Context, layoutDirection: LayoutDirection, diff --git a/sample/src/main/java/com/google/android/material/composethemeadapter/sample/Material3Integration.kt b/sample/src/main/java/com/google/android/material/composethemeadapter/sample/Material3Integration.kt index d54c35f..e9ebc67 100644 --- a/sample/src/main/java/com/google/android/material/composethemeadapter/sample/Material3Integration.kt +++ b/sample/src/main/java/com/google/android/material/composethemeadapter/sample/Material3Integration.kt @@ -14,6 +14,8 @@ * limitations under the License. */ +@file:Suppress("DEPRECATION") + package com.google.android.material.composethemeadapter.sample import android.os.Bundle diff --git a/sample/src/main/java/com/google/android/material/composethemeadapter/sample/MaterialIntegration.kt b/sample/src/main/java/com/google/android/material/composethemeadapter/sample/MaterialIntegration.kt index 85d6a20..4ac73a1 100644 --- a/sample/src/main/java/com/google/android/material/composethemeadapter/sample/MaterialIntegration.kt +++ b/sample/src/main/java/com/google/android/material/composethemeadapter/sample/MaterialIntegration.kt @@ -14,6 +14,8 @@ * limitations under the License. */ +@file:Suppress("DEPRECATION") + package com.google.android.material.composethemeadapter.sample import android.os.Bundle