Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
Deprecate libraries in favor of Accompanist
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Rout committed Nov 29, 2022
1 parent 649ca20 commit 09f32ea
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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:<mdcThemeAdapterVersion>` to `com.google.accompanist:accompanist-themeadapter-material:<accompanistVersion>`
2. `com.google.android.material:compose-theme-adapter-3:<mdcThemeAdapter3Version>` to `com.google.accompanist:accompanist-themeadapter-material3:<accompanistVersion>`
3. `com.google.android.material:compose-theme-adapter-core:<mdcThemeAdapterCoreVersion>` to `com.google.accompanist:accompanist-themeadapter-core:<accompanistVersion>`
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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

@file:Suppress("DEPRECATION")

package com.google.android.material.composethemeadapter.core

import android.annotation.SuppressLint
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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? {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

@file:Suppress("DEPRECATION")

package com.google.android.material.composethemeadapter3.test

import androidx.compose.foundation.shape.CornerSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/

@file:JvmName("Mdc3Theme")
@file:Suppress("DEPRECATION")

package com.google.android.material.composethemeadapter3

import android.content.Context
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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?,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

@file:Suppress("DEPRECATION")

package com.google.android.material.composethemeadapter.test

import android.view.ContextThemeWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

@file:Suppress("DEPRECATION")

package com.google.android.material.composethemeadapter.test

import androidx.appcompat.app.AppCompatActivity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/

@file:JvmName("MdcTheme")
@file:Suppress("DEPRECATION")

package com.google.android.material.composethemeadapter

import android.content.Context
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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?,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

@file:Suppress("DEPRECATION")

package com.google.android.material.composethemeadapter.sample

import android.os.Bundle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

@file:Suppress("DEPRECATION")

package com.google.android.material.composethemeadapter.sample

import android.os.Bundle
Expand Down

0 comments on commit 09f32ea

Please sign in to comment.