-
-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite session validation code to not use callbacks
- Loading branch information
1 parent
4777840
commit a6729a7
Showing
9 changed files
with
52 additions
and
80 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
app/src/main/java/org/jellyfin/androidtv/auth/ui/ActivityAuthenticationExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.jellyfin.androidtv.auth.ui | ||
|
||
import android.content.Intent | ||
import androidx.fragment.app.FragmentActivity | ||
import org.jellyfin.androidtv.auth.repository.SessionRepository | ||
import org.jellyfin.androidtv.ui.startup.StartupActivity | ||
import org.koin.android.ext.android.inject | ||
import timber.log.Timber | ||
|
||
/** | ||
* Extension function to check authentication. Should be called in [FragmentActivity.onCreate] and | ||
* [FragmentActivity.onResume]. It validates the current session and opens the authentication screen | ||
* when no session is found. | ||
* | ||
* @return whether to proceed creating the activity or not. When `false` is returned the | ||
* [FragmentActivity.finish] function is automatically called. | ||
*/ | ||
fun FragmentActivity.validateAuthentication(): Boolean { | ||
val sessionRepository by inject<SessionRepository>() | ||
|
||
if (sessionRepository.currentSession.value == null) { | ||
Timber.w("Activity ${this::class.qualifiedName} started without a session, bouncing to StartupActivity") | ||
startActivity(Intent(this, StartupActivity::class.java)) | ||
finish() | ||
return false | ||
} | ||
|
||
return true | ||
} |
10 changes: 0 additions & 10 deletions
10
app/src/main/java/org/jellyfin/androidtv/di/ActivityLifecycleCallbacksModule.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 0 additions & 21 deletions
21
app/src/main/java/org/jellyfin/androidtv/ui/shared/AbstractActivityLifecycleCallbacks.kt
This file was deleted.
Oops, something went wrong.
48 changes: 0 additions & 48 deletions
48
app/src/main/java/org/jellyfin/androidtv/ui/shared/AuthenticatedUserCallbacks.kt
This file was deleted.
Oops, something went wrong.