Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2019-2025 Uwe Trottmann
// SPDX-FileCopyrightText: Copyright © 2019 Uwe Trottmann <[email protected]>

package com.battlelancer.seriesguide.backend

Expand All @@ -21,6 +21,7 @@ import com.battlelancer.seriesguide.databinding.FragmentCloudSetupBinding
import com.battlelancer.seriesguide.sync.SgSyncAdapter
import com.battlelancer.seriesguide.sync.SyncProgress
import com.battlelancer.seriesguide.traktapi.ConnectTraktActivity
import com.battlelancer.seriesguide.ui.SeriesGuidePreferences
import com.battlelancer.seriesguide.util.Errors
import com.battlelancer.seriesguide.util.ThemeUtils
import com.battlelancer.seriesguide.util.safeShow
Expand Down Expand Up @@ -253,11 +254,8 @@ class CloudSetupFragment : Fragment() {
val intent = AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(hexagonTools.firebaseSignInProviders)
.setIsSmartLockEnabled(hexagonTools.isGoogleSignInAvailable)
// AuthUI is not compatible with edge-to-edge on Android 15 (target SDK 35),
// so opt out its activities.
// https://github.com/firebase/FirebaseUI-Android/issues/2177
.setTheme(R.style.Theme_SeriesGuide_DayNight_OptOutEdgeToEdge)
.setCredentialManagerEnabled(hexagonTools.isGoogleSignInAvailable)
.setTheme(SeriesGuidePreferences.THEME)
.setAuthMethodPickerLayout(authPickerLayout)
.build()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2014-2025 Uwe Trottmann
// SPDX-FileCopyrightText: Copyright © 2014 Uwe Trottmann <[email protected]>

package com.battlelancer.seriesguide.backend

Expand All @@ -10,7 +10,6 @@ import com.battlelancer.seriesguide.backend.CloudEndpointUtils.updateBuilder
import com.battlelancer.seriesguide.backend.settings.HexagonSettings
import com.battlelancer.seriesguide.jobs.NetworkJobProcessor
import com.battlelancer.seriesguide.modules.ApplicationContext
import com.battlelancer.seriesguide.util.Errors
import com.battlelancer.seriesguide.util.Errors.Companion.logAndReportHexagon
import com.battlelancer.seriesguide.util.isRetryError
import com.firebase.ui.auth.AuthUI
Expand All @@ -21,7 +20,6 @@ import com.github.michaelbull.result.runCatching
import com.github.michaelbull.result.throwUnless
import com.google.android.gms.common.ConnectionResult
import com.google.android.gms.common.GoogleApiAvailability
import com.google.android.gms.tasks.Tasks
import com.google.api.client.http.HttpRequestInitializer
import com.google.api.client.http.HttpTransport
import com.google.api.client.http.javanet.NetHttpTransport
Expand All @@ -35,9 +33,7 @@ import com.uwetrottmann.seriesguide.backend.lists.Lists
import com.uwetrottmann.seriesguide.backend.movies.Movies
import com.uwetrottmann.seriesguide.backend.shows.Shows
import com.uwetrottmann.seriesguide.backend.shows.model.SgCloudShow
import timber.log.Timber
import java.io.IOException
import java.util.concurrent.ExecutionException
import javax.inject.Inject
import javax.inject.Singleton

Expand Down Expand Up @@ -190,8 +186,10 @@ class HexagonTools @Inject constructor(
* Make sure to check [FirebaseHttpRequestInitializer.firebaseUser] is not null (the
* account might have gotten signed out).
*
* @param checkSignInState If enabled, tries to silently sign in with Google. If it fails, sets
* the [HexagonSettings.setShouldValidateAccount] flag. If successful, clears the flag.
* @param checkSignInState If set, tries to retrieve the signed in user from [FirebaseAuth] (if
* [FirebaseHttpRequestInitializer.firebaseUser] is null and [isTimeForSignInStateCheck]).
* If it fails, sets the [HexagonSettings.setShouldValidateAccount] flag.
* If successful, clears the flag.
*/
@Synchronized
private fun getHttpRequestInitializer(checkSignInState: Boolean): FirebaseHttpRequestInitializer {
Expand All @@ -216,45 +214,10 @@ class HexagonTools @Inject constructor(
}
lastSignInCheck = SystemClock.elapsedRealtime()

var account = FirebaseAuth.getInstance().currentUser
val account = FirebaseAuth.getInstance().currentUser
if (account != null) {
// still signed in
httpRequestInitializer.firebaseUser = account
} else {
// Try to silently sign in. This is fine as Cloud was enabled by the user
// and they reasonably expect to stay signed in.
val signInTask = AuthUI.getInstance().silentSignIn(context, firebaseSignInProviders)
try {
val authResult = Tasks.await(signInTask)
if (authResult?.user != null) {
Timber.i("%s: successful", ACTION_SILENT_SIGN_IN)
authResult.user.let {
account = it
httpRequestInitializer.firebaseUser = it
}
} else {
Errors.logAndReportHexagonAuthError(
HexagonAuthError(ACTION_SILENT_SIGN_IN, "FirebaseUser is null")
)
}
} catch (e: Exception) {
// https://developers.google.com/android/reference/com/google/android/gms/tasks/Tasks#public-static-tresult-await-tasktresult-task
if (e is InterruptedException) {
// Do not report thread interruptions, it's expected.
Timber.w(e, ACTION_SILENT_SIGN_IN)
} else {
val cause = if (e is ExecutionException) {
e.cause ?: e // The Task failed, getCause returns the original exception.
} else {
e // Unexpected exception.
}
// Do not report sign in required errors, this is expected and handled below.
val authEx = HexagonAuthError.build(ACTION_SILENT_SIGN_IN, cause)
if (!authEx.isSignInRequiredError()) {
Errors.logAndReportHexagonAuthError(authEx)
}
}
}
}

val shouldFixAccount = account == null
Expand Down Expand Up @@ -309,7 +272,6 @@ class HexagonTools @Inject constructor(
}

companion object {
private const val ACTION_SILENT_SIGN_IN = "silent sign-in"
private val JSON_FACTORY: JsonFactory = GsonFactory()
private val HTTP_TRANSPORT: HttpTransport = NetHttpTransport()
private const val SIGN_IN_CHECK_INTERVAL_MS = 5 * DateUtils.MINUTE_IN_MILLIS
Expand Down
13 changes: 0 additions & 13 deletions app/src/main/res/values-v35/themes.xml

This file was deleted.

10 changes: 0 additions & 10 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@

<style name="Theme.SeriesGuide.DayNight" parent="Theme.SeriesGuide.Light" />

<!--
Opts an activity out of enforced edge-to-edge display on Android 15+.
https://medium.com/androiddevelopers/insets-handling-tips-for-android-15s-edge-to-edge-enforcement-872774e8839b
WARNING This will stop working once targeting Android 16 (SDK 36).
https://developer.android.com/about/versions/16/behavior-changes-16#edge-to-edge
-->
<style name="Theme.SeriesGuide.DayNight.OptOutEdgeToEdge">
<!-- Only configured on API-level 35 (Android 15) or higher, see values-v35/themes.xml -->
</style>

<style name="Theme.BaseSeriesGuide.Dark" parent="Theme.Material3.Dark.NoActionBar">

<!-- All customizations that are SPECIFIC to API-level 23 go here. -->
Expand Down
2 changes: 0 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ plugins {
buildscript {
val sgCompileSdk by extra(36) // Android 16 (BAKLAVA)
val sgMinSdk by extra(23) // Android 6 (M)
// WARNING Can not increase to 36 (Android 16) until Theme.SeriesGuide.DayNight.OptOutEdgeToEdge
// is no longer used as windowOptOutEdgeToEdgeEnforcement will be ignored (see notes on theme).
val sgTargetSdk by extra(35) // Android 15 (VANILLA_ICE_CREAM)

// YYYY.<release-of-year>.<build> - like 2024.1.0
Expand Down
10 changes: 10 additions & 0 deletions docs/guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,13 @@ As it is a `LinearLayout`, [until this is fixed](https://github.com/material-com

</com.google.android.material.textfield.TextInputLayout>
```

## Dependencies

To inspect dependencies use

```bash
./gradlew :app:dependencies --configuration pureDebugCompileClasspath
```

When adding a new dependency, list it and its license in [credits](/CREDITS.txt).
8 changes: 3 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,12 @@ androidutils = "com.uwetrottmann.androidutils:androidutils:4.0.0"
photoview = "com.github.chrisbanes:PhotoView:2.3.0"

# https://developers.google.com/android/guides/releases
# 21.0.0 removes Credentials API used by firebase-ui-auth
play-services-auth = "com.google.android.gms:play-services-auth:20.7.0"
play-services-auth = "com.google.android.gms:play-services-auth:21.4.0"
# https://firebase.google.com/support/release-notes/android
firebase-crashlytics = "com.google.firebase:firebase-crashlytics:19.0.1"
# 23.0.0 requires min SDK 23
firebase-auth = "com.google.firebase:firebase-auth:22.3.1"
firebase-auth = "com.google.firebase:firebase-auth:24.0.1"
# https://github.com/firebase/FirebaseUI-Android/releases
firebase-ui-auth = "com.firebaseui:firebase-ui-auth:8.0.2"
firebase-ui-auth = "com.firebaseui:firebase-ui-auth:9.1.1"
# https://github.com/googleapis/google-api-java-client/releases
google-api-client = "com.google.api-client:google-api-client:2.6.0"
google-api-client-android = "com.google.api-client:google-api-client-android:2.6.0"
Expand Down