Skip to content

Commit

Permalink
Upgrade AGP to 8.1 and configure per app language (bitfireAT/davx5#338)
Browse files Browse the repository at this point in the history
* Upgraded AGP

Signed-off-by: Arnau Mora <[email protected]>

* Enabled automatic locale config generation

Signed-off-by: Arnau Mora <[email protected]>

* Added fallback language

Signed-off-by: Arnau Mora <[email protected]>

* Added legacy service

Signed-off-by: Arnau Mora <[email protected]>

* Added `Accept-Language` header to custom tabs

Signed-off-by: Arnau Mora <[email protected]>

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

---------

Signed-off-by: Arnau Mora <[email protected]>
Co-authored-by: Ricki Hirner <[email protected]>
  • Loading branch information
ArnyminerZ and rfc2822 committed Jul 28, 2023
1 parent 4f192c2 commit f806122
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 27 deletions.
4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ android {
excludes += ['META-INF/*.md']
}
}

androidResources {
generateLocaleConfig true
}
}

ksp {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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? -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,25 @@ 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
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
Expand All @@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,27 @@ 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
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
Expand All @@ -51,7 +53,6 @@ import java.net.HttpURLConnection
import java.net.URI
import javax.inject.Inject


class NextcloudLoginFlowFragment: Fragment() {

companion object {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/at/bitfire/davdroid/util/CompatUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ fun ContentProviderClient.closeCompat() {
close()
else
release()
}
}
2 changes: 2 additions & 0 deletions app/src/main/res/resources.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Set default locale
unqualifiedResLocale=en-US
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit f806122

Please sign in to comment.