Upgrade AGP to 8.1 and configure per app language (bitfireAT/davx5#338)

* Upgraded AGP

Signed-off-by: Arnau Mora <arnyminerz@proton.me>

* Enabled automatic locale config generation

Signed-off-by: Arnau Mora <arnyminerz@proton.me>

* Added fallback language

Signed-off-by: Arnau Mora <arnyminerz@proton.me>

* Added legacy service

Signed-off-by: Arnau Mora <arnyminerz@proton.me>

* Added `Accept-Language` header to custom tabs

Signed-off-by: Arnau Mora <arnyminerz@proton.me>

* Nextcloud Login Flow/Google OAuth: also send language tag for default locale

---------

Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Co-authored-by: Ricki Hirner <hirner@bitfire.at>
This commit is contained in:
Arnau Mora 2023-07-27 19:38:09 +02:00 committed by Ricki Hirner
parent 4f192c253d
commit f806122b00
7 changed files with 23 additions and 27 deletions

View file

@ -102,6 +102,10 @@ android {
excludes += ['META-INF/*.md']
}
}
androidResources {
generateLocaleConfig true
}
}
ksp {

View file

@ -294,6 +294,7 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/debug_paths" />
</provider>
</application>
<!-- package visiblity which apps do we need to see? -->

View file

@ -17,21 +17,11 @@ import android.view.ViewGroup
import android.widget.TextView
import androidx.activity.result.contract.ActivityResultContract
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.Card
import androidx.compose.material.MaterialTheme
import androidx.compose.material.OutlinedTextField
import androidx.compose.material.Text
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Warning
import androidx.compose.runtime.Composable
@ -39,13 +29,13 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.intl.Locale
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
@ -68,14 +58,7 @@ import dagger.hilt.android.AndroidEntryPoint
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import net.openid.appauth.AuthState
import net.openid.appauth.AuthorizationException
import net.openid.appauth.AuthorizationRequest
import net.openid.appauth.AuthorizationResponse
import net.openid.appauth.AuthorizationService
import net.openid.appauth.AuthorizationServiceConfiguration
import net.openid.appauth.ResponseTypeValues
import net.openid.appauth.TokenResponse
import net.openid.appauth.*
import org.apache.commons.lang3.StringUtils
import java.net.URI
import java.util.logging.Level
@ -87,7 +70,7 @@ class GoogleLoginFragment(private val defaultEmail: String? = null): Fragment()
companion object {
// Google API Services User Data Policy
val GOOGLE_POLICY_URL = "https://developers.google.com/terms/api-services-user-data-policy#additional_requirements_for_specific_api_scopes"
const val GOOGLE_POLICY_URL = "https://developers.google.com/terms/api-services-user-data-policy#additional_requirements_for_specific_api_scopes"
// Support site
val URI_TESTED_WITH_GOOGLE: Uri = Uri.parse("https://www.davx5.com/tested-with/google")
@ -152,6 +135,7 @@ class GoogleLoginFragment(private val defaultEmail: String? = null): Fragment()
val authRequest = authRequestBuilder(clientId)
.setScopes(*SCOPES)
.setLoginHint(accountEmail)
.setUiLocales(Locale.current.toLanguageTag())
.build()
try {

View file

@ -9,14 +9,16 @@ import android.app.Application
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.provider.Browser
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.UiThread
import androidx.annotation.WorkerThread
import androidx.browser.customtabs.CustomTabsIntent
import androidx.browser.customtabs.CustomTabsService.ACTION_CUSTOM_TABS_CONNECTION
import androidx.compose.ui.text.intl.Locale
import androidx.core.net.toUri
import androidx.core.os.bundleOf
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.fragment.app.viewModels
@ -24,10 +26,10 @@ import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.MutableLiveData
import at.bitfire.dav4jvm.exception.DavException
import at.bitfire.dav4jvm.exception.HttpException
import at.bitfire.davdroid.network.HttpClient
import at.bitfire.davdroid.R
import at.bitfire.davdroid.db.Credentials
import at.bitfire.davdroid.log.Logger
import at.bitfire.davdroid.network.HttpClient
import at.bitfire.davdroid.ui.DebugInfoActivity
import at.bitfire.davdroid.ui.UiUtils.haveCustomTabs
import com.google.android.material.snackbar.Snackbar
@ -51,7 +53,6 @@ import java.net.HttpURLConnection
import java.net.URI
import javax.inject.Inject
class NextcloudLoginFlowFragment: Fragment() {
companion object {
@ -94,6 +95,10 @@ class NextcloudLoginFlowFragment: Fragment() {
.setToolbarColor(resources.getColor(R.color.primaryColor))
.build()
browser.intent.data = loginUri
browser.intent.putExtra(
Browser.EXTRA_HEADERS,
bundleOf("Accept-Language" to Locale.current.toLanguageTag())
)
startActivityForResult(browser.intent, REQUEST_BROWSER, browser.startAnimationBundle)
} else {

View file

@ -13,4 +13,4 @@ fun ContentProviderClient.closeCompat() {
close()
else
release()
}
}

View file

@ -0,0 +1,2 @@
# Set default locale
unqualifiedResLocale=en-US

View file

@ -32,7 +32,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:8.0.2'
classpath 'com.android.tools.build:gradle:8.1.0'
classpath "com.google.dagger:hilt-android-gradle-plugin:${versions.hilt}"
classpath "com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:${versions.aboutLibraries}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"