Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update splash screen to properly use the Androidx SplashScreen library #4413

Merged
merged 6 commits into from
May 12, 2024

Conversation

cbeyls
Copy link
Contributor

@cbeyls cbeyls commented May 3, 2024

The Androidx SplashScreen library is added as a dependency to the project but isn't properly enabled in the current code. This pull request configures the splash screen properly.

  • Remove SplashScreenActivity which is not needed and use MainActivity as main entry point to the application. MainActivity inherits from BaseActivity which already detects if no account is configured and redirects to LoginActivity if needed, just like SplashScreenActivity.
  • Initialize the SplashScreen library in MainActivity.onCreate().
  • Instead of letting the SplashScreen library set the final theme from the postSplashScreenTheme attribute in SplashTheme, let BaseActivity set it according to the user settings.
  • When no account is available in MainActivity.onCreate(), keep the splash screen shown until LoginActivity appears.
  • Disable the slide-in animation when launching LoginActivity when no account is available because the detection happens in onCreate() and an Activity that finishes itself in onCreate() will not be drawn, so the slide-in animation will not be visible either and only LoginActivity will appear.
  • Upgrade core-splashscreen to 1.2.0-alpha01 which contains a fix for corrupted app theme on API 31+.

cbeyls added 3 commits May 3, 2024 22:41
… MainActivity.

The final theme is set manually in BaseActivity.onCreate() so no need to specify it in SplashTheme.
…e-in animation which will never be visible if the activity is finished in onCreate().
@connyduck
Copy link
Collaborator

I get an extra toolbar now?
Screenshot_20240510_144144

# Conflicts:
#	app/src/main/java/com/keylesspalace/tusky/BaseActivity.java
#	app/src/main/java/com/keylesspalace/tusky/SplashActivity.kt
#	app/src/main/java/com/keylesspalace/tusky/di/ActivitiesModule.kt
@cbeyls
Copy link
Contributor Author

cbeyls commented May 10, 2024

I get an extra toolbar now?

Looks like a bug in the SplashScreen library that was fixed recently:

Reset enforceNavigationBarContrast to system default value from API 31, so the splash screen theme won't corrupt activity's theme.

I upgraded to the latest alpha which contains the fix.

# Conflicts:
#	app/src/main/java/com/keylesspalace/tusky/MainActivity.kt
@connyduck connyduck merged commit 45d36a6 into tuskyapp:develop May 12, 2024
3 checks passed
connyduck pushed a commit that referenced this pull request May 31, 2024
The pull request to integrate the SplashScreen library (#4413) required
overriding the theme before setting the layout in
`MainActivity.onCreate()`, in order to switch from `SplashTheme` to
`TuskyTheme`. Since the parent `BaseActivity` already contained code to
override the theme in case the user selects the "black" theme, that
logic was added at the same spot in `BaseActivity`.

However, since other Activities inherit from `BaseActivity` and
sometimes declare a different default theme than `TuskyTheme` in the
Manifest, the wrong theme was set for those Activities when not in Black
theme mode.

This pull request ensures that the theme will only be overridden to
`TuskyTheme` in `MainActivity`, the only Activity that uses a splash
screen.
@cbeyls cbeyls deleted the fix/splash_screen branch June 1, 2024 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants