Skip to content

Commit de3c51f

Browse files
author
Mihai-Cristian Condrea
committed
feat: Added splash screen animation and updated ad banner implementation
Implemented a new animated splash screen for a more engaging initial app experience: - Added a new `anim_splash_screen.xml` file with an animated vector graphic. - Updated splash screen theme to use the new animation. - Modified ad banner implementation to support different banner sizes and improved loading behavior. - Added `il_square_image_error.xml` to handle errors on load images. - Added `crossfade` to all image loaders. - Updated app usage notification to provide better summarization. - Updated Gemini model from `gemini-1.5-pro` to `gemini-1.5-flash` for StudioBot. - Added `usesCleartextTraffic="true"` to the manifest file. - Changed `baseUrl` to `release` on `HomeRepositoryImplementation`. - Updated AppToolkit dependency version. - Changed icon app to a new design.
1 parent 65af824 commit de3c51f

File tree

19 files changed

+232
-177
lines changed

19 files changed

+232
-177
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ android {
108108
dependencies {
109109

110110
// App Core
111-
implementation(dependencyNotation = "com.github.D4rK7355608:AppToolkit:0.0.43") {
111+
implementation(dependencyNotation = "com.github.D4rK7355608:AppToolkit:0.0.44") {
112112
isTransitive = true
113113
}
114114

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
android:roundIcon="@mipmap/ic_launcher_round"
2727
android:supportsRtl="true"
2828
android:theme="@style/AppTheme"
29+
android:usesCleartextTraffic="true"
2930
tools:targetApi="33">
3031

3132
<activity

app/src/main/kotlin/com/d4rk/androidtutorials/ui/components/ads/BannerAds.kt

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.d4rk.androidtutorials.ui.components.ads
22

33
import androidx.compose.foundation.layout.fillMaxWidth
4+
import androidx.compose.foundation.layout.height
45
import androidx.compose.runtime.Composable
56
import androidx.compose.runtime.collectAsState
67
import androidx.compose.runtime.getValue
78
import androidx.compose.ui.Modifier
9+
import androidx.compose.ui.unit.dp
810
import androidx.compose.ui.viewinterop.AndroidView
911
import com.d4rk.androidtutorials.data.core.AppCoreManager
1012
import com.d4rk.androidtutorials.utils.constants.ads.AdsConstants
@@ -13,49 +15,15 @@ import com.google.android.gms.ads.AdSize
1315
import com.google.android.gms.ads.AdView
1416

1517
@Composable
16-
fun AdBanner(
17-
modifier : Modifier = Modifier
18-
) {
18+
fun AdBanner(modifier : Modifier = Modifier , adSize : AdSize = AdSize.BANNER) {
1919
val showAds : Boolean by AppCoreManager.dataStore.ads.collectAsState(initial = true)
2020

2121
if (showAds) {
22-
AndroidView(modifier = modifier.fillMaxWidth() , factory = { context ->
22+
AndroidView(modifier = modifier
23+
.fillMaxWidth()
24+
.height(height = adSize.height.dp) , factory = { context ->
2325
AdView(context).apply {
24-
setAdSize(AdSize.BANNER)
25-
adUnitId = AdsConstants.BANNER_AD_UNIT_ID
26-
loadAd(AdRequest.Builder().build())
27-
}
28-
})
29-
}
30-
}
31-
32-
@Composable
33-
fun AdBannerFull(
34-
modifier : Modifier = Modifier
35-
) {
36-
val showAds : Boolean by AppCoreManager.dataStore.ads.collectAsState(initial = true)
37-
38-
if (showAds) {
39-
AndroidView(modifier = modifier.fillMaxWidth() , factory = { context ->
40-
AdView(context).apply {
41-
setAdSize(AdSize.FULL_BANNER)
42-
adUnitId = AdsConstants.BANNER_AD_UNIT_ID
43-
loadAd(AdRequest.Builder().build())
44-
}
45-
})
46-
}
47-
}
48-
49-
@Composable
50-
fun LargeBannerAdsComposable(
51-
modifier : Modifier = Modifier
52-
) {
53-
val showAds : Boolean by AppCoreManager.dataStore.ads.collectAsState(initial = true)
54-
55-
if (showAds) {
56-
AndroidView(modifier = modifier.fillMaxWidth() , factory = { context ->
57-
AdView(context).apply {
58-
setAdSize(AdSize.LARGE_BANNER)
26+
setAdSize(adSize)
5927
adUnitId = AdsConstants.BANNER_AD_UNIT_ID
6028
loadAd(AdRequest.Builder().build())
6129
}

app/src/main/kotlin/com/d4rk/androidtutorials/ui/components/layouts/LessonContentLayout.kt

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,19 @@ import coil3.ImageLoader
4343
import coil3.compose.AsyncImage
4444
import coil3.gif.AnimatedImageDecoder
4545
import coil3.gif.GifDecoder
46+
import coil3.request.crossfade
4647
import com.d4rk.android.libs.apptoolkit.ui.components.modifiers.bounceClick
4748
import com.d4rk.android.libs.apptoolkit.ui.components.spacers.ButtonHorizontalSpacer
4849
import com.d4rk.android.libs.apptoolkit.ui.components.spacers.LargeVerticalSpacer
4950
import com.d4rk.android.libs.apptoolkit.ui.components.spacers.SmallVerticalSpacer
5051
import com.d4rk.android.libs.apptoolkit.utils.helpers.ClipboardHelper
5152
import com.d4rk.androidtutorials.data.model.ui.screens.UiLessonScreen
5253
import com.d4rk.androidtutorials.ui.components.ads.AdBanner
53-
import com.d4rk.androidtutorials.ui.components.ads.AdBannerFull
54-
import com.d4rk.androidtutorials.ui.components.ads.LargeBannerAdsComposable
5554
import com.d4rk.androidtutorials.ui.screens.settings.display.theme.style.Colors
5655
import com.d4rk.androidtutorials.ui.screens.settings.display.theme.style.TextStyles
5756
import com.d4rk.androidtutorials.utils.constants.ui.lessons.LessonCodeConstants
5857
import com.d4rk.androidtutorials.utils.constants.ui.lessons.LessonContentTypes
58+
import com.google.android.gms.ads.AdSize
5959
import com.wakaztahir.codeeditor.highlight.model.CodeLang
6060
import com.wakaztahir.codeeditor.highlight.prettify.PrettifyParser
6161
import com.wakaztahir.codeeditor.highlight.theme.CodeTheme
@@ -79,17 +79,13 @@ fun LessonContentLayout(
7979
when (contentItem.contentType) {
8080
LessonContentTypes.HEADER -> {
8181
StyledText(
82-
text = contentItem.contentText ,
83-
style = TextStyles.header() ,
84-
color = Colors.primaryText()
82+
text = contentItem.contentText , style = TextStyles.header() , color = Colors.primaryText()
8583
)
8684
}
8785

8886
LessonContentTypes.TEXT -> {
8987
StyledText(
90-
text = contentItem.contentText ,
91-
style = TextStyles.body() ,
92-
color = Colors.secondaryText()
88+
text = contentItem.contentText , style = TextStyles.body() , color = Colors.secondaryText()
9389
)
9490
}
9591

@@ -110,11 +106,11 @@ fun LessonContentLayout(
110106
}
111107

112108
LessonContentTypes.AD_BANNER_FULL -> {
113-
AdBannerFull()
109+
AdBanner(adSize = AdSize.FULL_BANNER)
114110
}
115111

116112
LessonContentTypes.AD_LARGE_BANNER -> {
117-
LargeBannerAdsComposable()
113+
AdBanner(adSize = AdSize.LARGE_BANNER)
118114
}
119115

120116
else -> {
@@ -134,7 +130,7 @@ fun StyledText(
134130
style : TextStyle = TextStyles.body() ,
135131
color : Color = Colors.primaryText() ,
136132
) {
137-
val annotatedString = AnnotatedString.fromHtml(htmlString = text)
133+
val annotatedString : AnnotatedString = AnnotatedString.fromHtml(htmlString = text)
138134

139135
Text(
140136
text = annotatedString , style = style , color = color
@@ -148,14 +144,14 @@ fun StyledImage(
148144
modifier : Modifier = Modifier ,
149145
) {
150146
val context : Context = LocalContext.current
151-
val imageLoader = ImageLoader.Builder(context = context).components {
147+
val imageLoader : ImageLoader = ImageLoader.Builder(context = context).components {
152148
if (SDK_INT >= 28) {
153149
add(factory = AnimatedImageDecoder.Factory())
154150
}
155151
else {
156152
add(factory = GifDecoder.Factory())
157153
}
158-
}.build()
154+
}.crossfade(enable = true).build()
159155
Card(
160156
modifier = modifier.fillMaxWidth() ,
161157
) {
@@ -343,32 +339,20 @@ fun CodeBlock(code : String , language : String?) {
343339
Row(
344340
modifier = Modifier
345341
.fillMaxWidth()
346-
.padding(horizontal = 16.dp) ,
347-
horizontalArrangement = Arrangement.SpaceBetween ,
348-
verticalAlignment = Alignment.CenterVertically
342+
.padding(horizontal = 16.dp) , horizontalArrangement = Arrangement.SpaceBetween , verticalAlignment = Alignment.CenterVertically
349343
) {
350344
Text(
351-
text = language ?: "unknown" ,
352-
style = MaterialTheme.typography.bodyMedium ,
353-
modifier = Modifier.padding(end = 8.dp)
345+
text = language ?: "unknown" , style = MaterialTheme.typography.bodyMedium , modifier = Modifier.padding(end = 8.dp)
354346
)
355347
TextButton(modifier = Modifier.bounceClick() , onClick = {
356-
ClipboardHelper.copyTextToClipboard(
357-
context = context ,
358-
label = "Code" ,
359-
text = code ,
360-
onShowSnackbar = {
361-
Toast.makeText(
362-
context ,
363-
"Code copied to clipboard" ,
364-
Toast.LENGTH_SHORT
365-
).show()
366-
})
348+
ClipboardHelper.copyTextToClipboard(context = context , label = "Code" , text = code , onShowSnackbar = {
349+
Toast.makeText(
350+
context , "Code copied to clipboard" , Toast.LENGTH_SHORT
351+
).show()
352+
})
367353
} , contentPadding = PaddingValues(horizontal = 8.dp)) {
368354
Icon(
369-
imageVector = Icons.Outlined.CopyAll ,
370-
contentDescription = "Copy Code" ,
371-
modifier = Modifier.size(size = ButtonDefaults.IconSize)
355+
imageVector = Icons.Outlined.CopyAll , contentDescription = "Copy Code" , modifier = Modifier.size(size = ButtonDefaults.IconSize)
372356
)
373357
ButtonHorizontalSpacer()
374358
Text(text = stringResource(id = android.R.string.copy))
@@ -377,8 +361,7 @@ fun CodeBlock(code : String , language : String?) {
377361
Spacer(modifier = Modifier.height(height = 2.dp))
378362
SelectionContainer {
379363
Text(
380-
text = textFieldValue.annotatedString ,
381-
modifier = Modifier
364+
text = textFieldValue.annotatedString , modifier = Modifier
382365
.fillMaxWidth()
383366
.padding(horizontal = 8.dp)
384367
)

0 commit comments

Comments
 (0)