Skip to content

Commit

Permalink
Preferences: added option to skip intro animations
Browse files Browse the repository at this point in the history
  • Loading branch information
Javinator9889 committed Jan 2, 2021
1 parent 9be25fc commit 2261fe6
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ android {
applicationId "com.javinator9889.handwashingreminder"
minSdkVersion 16
targetSdkVersion 30
versionCode 146
versionCode 147
versionName "1.2.1-${gitCommitHash}"
multiDexEnabled true
resConfigs "en", "es"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class LauncherActivity : BaseFragmentActivity<SplashScreenBinding>() {
private val activityIntentDeferred = CompletableDeferred<Intent>()
private val splitInstallManager = SplitInstallManagerFactory.create(app)
private lateinit var binding: SplashScreenBinding

@get:LayoutRes
override val layoutId: Int = R.layout.splash_screen

Expand Down Expand Up @@ -127,14 +128,19 @@ class LauncherActivity : BaseFragmentActivity<SplashScreenBinding>() {
override fun onAnimationStart(animation: Animation?) {
Timber.d("Animation started!")
}

override fun onAnimationRepeat(animation: Animation?) {}
override fun onAnimationEnd(animation: Animation?) {
Timber.d("Animation is completed")
animationLoaded.complete(true)
binding.logo.playAnimation()
}
})
if (isThereAnySpecialEvent && !isDebuggable()) {
val introAnimationDisabled = sharedPreferences.getBoolean(
Preferences.INTRO_ANIMATIONS,
false
)
if (isThereAnySpecialEvent && !isDebuggable() && !introAnimationDisabled) {
Timber.d("Starting custom animation...")
binding.logo.setAnimation(AnimatedResources.STAY_SAFE_STAY_HOME.res)
binding.logo.addLottieOnCompositionLoadedListener {
Expand Down Expand Up @@ -256,8 +262,10 @@ class LauncherActivity : BaseFragmentActivity<SplashScreenBinding>() {
if (Ads.MODULE_NAME in splitInstallManager.installedModules &&
sharedPreferences.getBoolean(ADS_ENABLED, true)
) {
val className = "${Ads.PACKAGE_NAME}.${Ads
.CLASS_NAME}\$${Ads.PROVIDER_NAME}"
val className = "${Ads.PACKAGE_NAME}.${
Ads
.CLASS_NAME
}\$${Ads.PROVIDER_NAME}"
val adProvider = Class.forName(className).kotlin
.objectInstance as AdLoader.Provider
app.adLoader = adProvider.instance(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class DiseasesFragment : BaseFragmentView<MainDiseaseViewBinding>(),
lifecycleScope.launchWhenStarted {
loadingRecyclerViewBinding.loading.visibility = View.VISIBLE
handwashBinding.countLoader.visibility = View.VISIBLE
informationViewModel.parsedHTMLText.observe(viewLifecycleOwner) {
informationViewModel.parsedHTMLText.observe(owner = viewLifecycleOwner) {
if (it.isEmpty())
return@observe
lifecycleScope.launch {
Expand All @@ -110,7 +110,7 @@ class DiseasesFragment : BaseFragmentView<MainDiseaseViewBinding>(),
loadingRecyclerViewBinding.container.visibility = View.VISIBLE
}
}
handwashingViewModel.allData.observe(viewLifecycleOwner) {
handwashingViewModel.allData.observe(owner = viewLifecycleOwner) {
lifecycleScope.launch {
dataSet?.let { set ->
Timber.d("Adding new items to dataSet")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ class SettingsLoader(
Preferences.PERFORMANCE_ANIMATIONS,
Ionicons.Icon.ion_battery_low
).also { deferreds.add(it) }
setupPreferenceAsync(
Preferences.INTRO_ANIMATIONS,
Ionicons.Icon.ion_play
).also { deferreds.add(it) }
setupPreferenceAsync(
"notifications:settings",
onClickListener = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ object Preferences {
const val INITIAL_TUTORIAL_DONE = "app:tutorial:is_done"
const val ACTIVITY_MINIMUM_TIME = "activity:gms:minimumInterval"
const val PERFORMANCE_ANIMATIONS = "app:performance:animations"
const val INTRO_ANIMATIONS = "app:performance:intro_animation"
}

object TimeConfig {
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
público hay mucha gente y no sabes si están enfermos o no &#128567;.\n
Incluso en tu propio coche pueden haber enfermedades en los pomos o
en el volante &#128663;, así que lávate las manos lo antes que puedas
para evitar enfermedades &#128166;&#128079;
para evitar enfermedades &#128166;&#128079;
</string>
<string name="privacy_policy_title">Política de privacidad</string>
<string name="tos_title">Términos y condiciones</string>
Expand Down Expand Up @@ -299,6 +299,10 @@
<string name="animations_on">Actualmente, las animaciones están activadas.
Ten en cuenta que esto puede afectar tanto al rendimiento como a la batería</string>
<string name="animations_off">No se mostrará ninguna animación</string>
<string name="disable_intro_animation">Deshabilita las animaciones al inicio</string>
<string name="intro_animations_on">Si, al abrir la aplicación, hay algún evento especial, se muestra una animación.
Desmarca esta opción para saltarla</string>
<string name="intro_animations_off">No se mostrarán animaciones al iniciar la aplicación</string>
<string name="news_error">Error al cargar información sobre las noticias</string>
<string name="notification_settings">Ajustes de notificaciones</string>
<string name="just_washed">¡Acabo de lavarlas!</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@
<string name="animations_on">Currently, the app will play some animations.
Keep in mind that it can affect both performance and battery life</string>
<string name="animations_off">No animations will be played</string>
<string name="disable_intro_animation">Disable app\'s intro animations</string>
<string name="intro_animations_on">When opening the app, if there is an special
event, an animation is displayed. Uncheck this to skip that animation</string>
<string name="intro_animations_off">No animations will be played while opening the app</string>
<string name="news_error">Error while loading news data</string>
<string name="notification_settings">Edit notification settings</string>
<string name="just_washed">Just washed them!</string>
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@
android:summaryOff="@string/animations_off"
android:summaryOn="@string/animations_on"
android:title="@string/disable_animations" />

<SwitchPreference
android:defaultValue="true"
android:key="app:performance:intro_animation"
android:summaryOff="@string/intro_animations_off"
android:summaryOn="@string/intro_animations_on"
android:title="@string/disable_intro_animation" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/data_sharing_category">

Expand Down

0 comments on commit 2261fe6

Please sign in to comment.