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

Commit 09f32ea

Browse files
author
Nick Rout
committed
Deprecate libraries in favor of Accompanist
1 parent 649ca20 commit 09f32ea

File tree

11 files changed

+147
-0
lines changed

11 files changed

+147
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
# MDC-Android Compose Theme Adapter
22

3+
!!! warning
4+
**These libraries are deprecated in favor of the new [Accompanist][accompanist] Theme Adapter artifacts. The migration guide and original documentation is below.**
5+
6+
## Migration
7+
8+
MDC-Android Compose Theme Adapters have moved from:
9+
* The `compose-theme-adapter` artifact to the [`accompanist/themeadapter-material`][themeadaptermateriallib] artifact
10+
* The `compose-theme-adapter-3` artifact to the [`accompanist/themeadapter-material3`][themeadaptermaterial3lib] artifact
11+
* The `compose-theme-adapter-core` artifact to the [`accompanist/themeadapter-core`][themeadaptercorelib] artifact
12+
13+
The implementations are identical but the dependencies and import packages have changed.
14+
15+
### Migration steps
16+
17+
1. Change any dependencies from:
18+
1. `com.google.android.material:compose-theme-adapter:<mdcThemeAdapterVersion>` to `com.google.accompanist:accompanist-themeadapter-material:<accompanistVersion>`
19+
2. `com.google.android.material:compose-theme-adapter-3:<mdcThemeAdapter3Version>` to `com.google.accompanist:accompanist-themeadapter-material3:<accompanistVersion>`
20+
3. `com.google.android.material:compose-theme-adapter-core:<mdcThemeAdapterCoreVersion>` to `com.google.accompanist:accompanist-themeadapter-core:<accompanistVersion>`
21+
2. Change any imports from:
22+
1. `com.google.android.material.composethemeadapter.*` to `com.google.accompanist.themeadapter.material.*`
23+
2. `com.google.android.material.composethemeadapter3.*` to `com.google.accompanist.themeadapter.material3.*`
24+
3. `com.google.android.material.composethemeadapter.core.*` to `com.google.accompanist.themeadapter.core.*`
25+
26+
## Original Docs
27+
328
A library that enables reuse of [Material Components for Android][mdc] XML themes for theming in [Jetpack Compose][compose].
429

530
## Usage
@@ -234,3 +259,7 @@ limitations under the License.
234259
[m3colorscheme]: https://developer.android.com/reference/kotlin/androidx/compose/material3/ColorScheme
235260
[m3shapes]: https://developer.android.com/reference/kotlin/androidx/compose/material3/Shapes
236261
[m3typography]: https://developer.android.com/reference/kotlin/androidx/compose/material3/Typography
262+
[accompanist]: https://github.com/google/accompanist
263+
[themeadaptermateriallib]: https://google.github.io/accompanist/themeadapter-material
264+
[themeadaptermaterial3lib]: https://google.github.io/accompanist/themeadapter-material3
265+
[themeadaptercorelib]: https://google.github.io/accompanist/themeadapter-core

core/src/main/java/com/google/android/material/composethemeadapter/core/ResourceUtils.kt

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
@file:Suppress("DEPRECATION")
18+
1719
package com.google.android.material.composethemeadapter.core
1820

1921
import android.annotation.SuppressLint
@@ -57,6 +59,13 @@ import kotlin.concurrent.getOrSet
5759
* @param fallbackColor Value to return if the attribute is not defined or can't be coerced to a
5860
* [Color].
5961
*/
62+
@Deprecated(
63+
"""
64+
compose-theme-adapter-core is deprecated.
65+
The API has moved to accompanist/themeadapter/core.
66+
For more information, please visit https://google.github.io/accompanist/themeadapter-core
67+
"""
68+
)
6069
fun TypedArray.parseColor(
6170
index: Int,
6271
fallbackColor: Color = Color.Unspecified
@@ -71,6 +80,13 @@ fun TypedArray.parseColor(
7180
* @param setTextColors Whether to read and set text colors from the style. Defaults to `false`.
7281
* @param defaultFontFamily Optional default font family to use in [TextStyle]s.
7382
*/
83+
@Deprecated(
84+
"""
85+
compose-theme-adapter-core is deprecated.
86+
The API has moved to accompanist/themeadapter/core.
87+
For more information, please visit https://google.github.io/accompanist/themeadapter-core
88+
"""
89+
)
7490
fun parseTextAppearance(
7591
context: Context,
7692
@StyleRes id: Int,
@@ -165,6 +181,13 @@ fun parseTextAppearance(
165181
*
166182
* @param index Index of attribute to retrieve.
167183
*/
184+
@Deprecated(
185+
"""
186+
compose-theme-adapter-core is deprecated.
187+
The API has moved to accompanist/themeadapter/core.
188+
For more information, please visit https://google.github.io/accompanist/themeadapter-core
189+
"""
190+
)
168191
fun TypedArray.parseFontFamily(index: Int): FontFamilyWithWeight? {
169192
val tv = tempTypedValue.getOrSet(::TypedValue)
170193
if (getValue(index, tv) && tv.type == TypedValue.TYPE_STRING) {
@@ -200,6 +223,13 @@ fun TypedArray.parseFontFamily(index: Int): FontFamilyWithWeight? {
200223
/**
201224
* A lightweight class for storing a [FontFamily] and [FontWeight].
202225
*/
226+
@Deprecated(
227+
"""
228+
compose-theme-adapter-core is deprecated.
229+
The API has moved to accompanist/themeadapter/core.
230+
For more information, please visit https://google.github.io/accompanist/themeadapter-core
231+
"""
232+
)
203233
data class FontFamilyWithWeight(
204234
val fontFamily: FontFamily,
205235
val weight: FontWeight = FontWeight.Normal
@@ -211,6 +241,13 @@ data class FontFamilyWithWeight(
211241
*
212242
* @param id ID of XML resource to retrieve.
213243
*/
244+
@Deprecated(
245+
"""
246+
compose-theme-adapter-core is deprecated.
247+
The API has moved to accompanist/themeadapter/core.
248+
For more information, please visit https://google.github.io/accompanist/themeadapter-core
249+
"""
250+
)
214251
@SuppressLint("RestrictedApi") // FontResourcesParserCompat.*
215252
@RequiresApi(23) // XML font families with > 1 fonts are only supported on API 23+
216253
fun Resources.parseXmlFontFamily(id: Int): FontFamily? {
@@ -259,6 +296,13 @@ private fun fontWeightOf(weight: Int): FontWeight = when (weight) {
259296
* @param fallbackTextUnit Value to return if the attribute is not defined or can't be coerced to a
260297
* [TextUnit].
261298
*/
299+
@Deprecated(
300+
"""
301+
compose-theme-adapter-core is deprecated.
302+
The API has moved to accompanist/themeadapter/core.
303+
For more information, please visit https://google.github.io/accompanist/themeadapter-core
304+
"""
305+
)
262306
fun TypedArray.parseTextUnit(
263307
index: Int,
264308
density: Density,
@@ -289,6 +333,13 @@ fun TypedArray.parseTextUnit(
289333
* @param fallbackShape Value to return if the style resource ID is not defined or can't be coerced
290334
* to a [CornerBasedShape].
291335
*/
336+
@Deprecated(
337+
"""
338+
compose-theme-adapter-core is deprecated.
339+
The API has moved to accompanist/themeadapter/core.
340+
For more information, please visit https://google.github.io/accompanist/themeadapter-core
341+
"""
342+
)
292343
fun parseShapeAppearance(
293344
context: Context,
294345
@StyleRes id: Int,
@@ -349,6 +400,13 @@ fun parseShapeAppearance(
349400
*
350401
* @param index Index of attribute to retrieve.
351402
*/
403+
@Deprecated(
404+
"""
405+
compose-theme-adapter-core is deprecated.
406+
The API has moved to accompanist/themeadapter/core.
407+
For more information, please visit https://google.github.io/accompanist/themeadapter-core
408+
"""
409+
)
352410
fun TypedArray.parseCornerSize(index: Int): CornerSize? {
353411
val tv = tempTypedValue.getOrSet { TypedValue() }
354412
if (getValue(index, tv)) {

material3Lib/src/androidTest/java/com/google/android/material/composethemeadapter3/test/Mdc3ThemeTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
@file:Suppress("DEPRECATION")
18+
1719
package com.google.android.material.composethemeadapter3.test
1820

1921
import androidx.compose.foundation.shape.CornerSize

material3Lib/src/androidTest/java/com/google/android/material/composethemeadapter3/test/NotMdc3ThemeTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
@file:Suppress("DEPRECATION")
18+
1719
package com.google.android.material.composethemeadapter3.test
1820

1921
import androidx.compose.ui.test.junit4.createAndroidComposeRule

material3Lib/src/main/java/com/google/android/material/composethemeadapter3/Mdc3Theme.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616

1717
@file:JvmName("Mdc3Theme")
18+
@file:Suppress("DEPRECATION")
19+
1820
package com.google.android.material.composethemeadapter3
1921

2022
import android.content.Context
@@ -64,6 +66,13 @@ import java.lang.reflect.Method
6466
* @param setDefaultFontFamily whether to read and prioritize the `fontFamily` attributes from
6567
* [context]'s theme, over any specified in the MDC text appearances. Defaults to `false`.
6668
*/
69+
@Deprecated(
70+
"""
71+
compose-theme-adapter-3 is deprecated.
72+
The API has moved to accompanist/themeadapter/material3.
73+
For more information, please visit https://google.github.io/accompanist/themeadapter-material3
74+
"""
75+
)
6776
@Composable
6877
fun Mdc3Theme(
6978
context: Context = LocalContext.current,
@@ -115,6 +124,13 @@ fun Mdc3Theme(
115124
* This class contains the individual components of a [MaterialTheme]: [ColorScheme] and
116125
* [Typography].
117126
*/
127+
@Deprecated(
128+
"""
129+
compose-theme-adapter-3 is deprecated.
130+
The API has moved to accompanist/themeadapter/material3.
131+
For more information, please visit https://google.github.io/accompanist/themeadapter-material3
132+
"""
133+
)
118134
data class Theme3Parameters(
119135
val colorScheme: ColorScheme?,
120136
val typography: Typography?,
@@ -150,6 +166,13 @@ data class Theme3Parameters(
150166
* [context]'s theme, over any specified in the MDC text appearances. Defaults to `false`.
151167
* @return [Theme3Parameters] instance containing the resulting [ColorScheme] and [Typography].
152168
*/
169+
@Deprecated(
170+
"""
171+
compose-theme-adapter-3 is deprecated.
172+
The API has moved to accompanist/themeadapter/material3.
173+
For more information, please visit https://google.github.io/accompanist/themeadapter-material3
174+
"""
175+
)
153176
fun createMdc3Theme(
154177
context: Context,
155178
layoutDirection: LayoutDirection,

materialLib/src/androidTest/java/com/google/android/material/composethemeadapter/test/DefaultFontFamilyMdcThemeTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
@file:Suppress("DEPRECATION")
18+
1719
package com.google.android.material.composethemeadapter.test
1820

1921
import android.view.ContextThemeWrapper

materialLib/src/androidTest/java/com/google/android/material/composethemeadapter/test/MdcThemeTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
@file:Suppress("DEPRECATION")
18+
1719
package com.google.android.material.composethemeadapter.test
1820

1921
import androidx.appcompat.app.AppCompatActivity

materialLib/src/androidTest/java/com/google/android/material/composethemeadapter/test/NotMdcThemeTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
@file:Suppress("DEPRECATION")
18+
1719
package com.google.android.material.composethemeadapter.test
1820

1921
import androidx.compose.ui.test.junit4.createAndroidComposeRule

materialLib/src/main/java/com/google/android/material/composethemeadapter/MdcTheme.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616

1717
@file:JvmName("MdcTheme")
18+
@file:Suppress("DEPRECATION")
19+
1820
package com.google.android.material.composethemeadapter
1921

2022
import android.content.Context
@@ -71,6 +73,13 @@ import java.lang.reflect.Method
7173
* @param setDefaultFontFamily whether to read and prioritize the `fontFamily` attributes from
7274
* [context]'s theme, over any specified in the MDC text appearances. Defaults to `false`.
7375
*/
76+
@Deprecated(
77+
"""
78+
compose-theme-adapter is deprecated.
79+
The API has moved to accompanist/themeadapter/material.
80+
For more information, please visit https://google.github.io/accompanist/themeadapter-material
81+
"""
82+
)
7483
@Composable
7584
fun MdcTheme(
7685
context: Context = LocalContext.current,
@@ -122,6 +131,13 @@ fun MdcTheme(
122131
* This class contains the individual components of a [MaterialTheme]: [Colors], [Typography]
123132
* and [Shapes].
124133
*/
134+
@Deprecated(
135+
"""
136+
compose-theme-adapter is deprecated.
137+
The API has moved to accompanist/themeadapter/material.
138+
For more information, please visit https://google.github.io/accompanist/themeadapter-material
139+
"""
140+
)
125141
data class ThemeParameters(
126142
val colors: Colors?,
127143
val typography: Typography?,
@@ -158,6 +174,13 @@ data class ThemeParameters(
158174
* @return [ThemeParameters] instance containing the resulting [Colors], [Typography]
159175
* and [Shapes].
160176
*/
177+
@Deprecated(
178+
"""
179+
compose-theme-adapter is deprecated.
180+
The API has moved to accompanist/themeadapter/material.
181+
For more information, please visit https://google.github.io/accompanist/themeadapter-material
182+
"""
183+
)
161184
fun createMdcTheme(
162185
context: Context,
163186
layoutDirection: LayoutDirection,

sample/src/main/java/com/google/android/material/composethemeadapter/sample/Material3Integration.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
@file:Suppress("DEPRECATION")
18+
1719
package com.google.android.material.composethemeadapter.sample
1820

1921
import android.os.Bundle

0 commit comments

Comments
 (0)