From 01743702888707ae4046c9149e831e27119fa670 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Mon, 25 Nov 2024 12:27:33 +0100 Subject: [PATCH 01/17] upgrade the sdk version Signed-off-by: alperozturk --- app/build.gradle | 4 ++-- .../main/java/com/nextcloud/client/appinfo/AppInfoImpl.kt | 8 ++------ .../main/java/com/owncloud/android/utils/WebViewUtil.kt | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d95f3cc66a..9e188f39e9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -106,8 +106,8 @@ android { defaultConfig { applicationId "com.nextcloud.client" minSdkVersion 24 - targetSdkVersion 34 - compileSdk 34 + targetSdkVersion 35 + compileSdk 35 buildConfigField 'boolean', 'CI', ciBuild.toString() buildConfigField 'boolean', 'RUNTIME_PERF_ANALYSIS', perfAnalysis.toString() diff --git a/app/src/main/java/com/nextcloud/client/appinfo/AppInfoImpl.kt b/app/src/main/java/com/nextcloud/client/appinfo/AppInfoImpl.kt index 7fb222b6c2..4c97af52a3 100644 --- a/app/src/main/java/com/nextcloud/client/appinfo/AppInfoImpl.kt +++ b/app/src/main/java/com/nextcloud/client/appinfo/AppInfoImpl.kt @@ -18,12 +18,8 @@ class AppInfoImpl : AppInfo { override fun getAppVersion(context: Context): String { return try { - val pInfo = context.packageManager.getPackageInfo(context.packageName, 0) - if (pInfo != null) { - pInfo.versionName - } else { - "n/a" - } + val packageInfo = context.packageManager.getPackageInfo(context.packageName, 0) + packageInfo.versionName ?: "n/a" } catch (e: PackageManager.NameNotFoundException) { Log_OC.e(this, "Trying to get packageName", e.cause) "n/a" diff --git a/app/src/main/java/com/owncloud/android/utils/WebViewUtil.kt b/app/src/main/java/com/owncloud/android/utils/WebViewUtil.kt index c3dbbd73e7..b012242179 100644 --- a/app/src/main/java/com/owncloud/android/utils/WebViewUtil.kt +++ b/app/src/main/java/com/owncloud/android/utils/WebViewUtil.kt @@ -77,7 +77,7 @@ class WebViewUtil(private val context: Context) { return try { val pi = pm.getPackageInfo("com.google.android.webview", 0) - val fullVersion = pi.versionName + val fullVersion = pi.versionName ?: return null // Split the version string by "." and get the first part val versionParts = fullVersion.split("\\.".toRegex()).dropLastWhile { it.isEmpty() } From 71571916690c7d19788bd9db3dd000fc963c182c Mon Sep 17 00:00:00 2001 From: alperozturk Date: Thu, 28 Nov 2024 09:19:05 +0100 Subject: [PATCH 02/17] update com.nextcloud.appscan gradle file Signed-off-by: alperozturk --- appscan/build.gradle | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/appscan/build.gradle b/appscan/build.gradle index bdcab491ac..941be8e143 100644 --- a/appscan/build.gradle +++ b/appscan/build.gradle @@ -19,11 +19,11 @@ apply plugin: 'kotlin-android' android { namespace 'com.nextcloud.appscan' - compileSdk 34 defaultConfig { - minSdk 21 - targetSdk 34 + minSdk 24 + targetSdk 35 + compileSdk 35 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } @@ -45,6 +45,6 @@ android { } dependencies { - implementation "androidx.appcompat:appcompat:1.7.0" + implementation "androidx.appcompat:appcompat:$appCompatVersion" implementation "com.github.zynkware:Document-Scanning-Android-SDK:$documentScannerVersion" } From f8366443335871023ba9826faa38d83cdf566796 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Mon, 25 Nov 2024 16:30:02 +0100 Subject: [PATCH 03/17] Increase Build Speed Signed-off-by: alperozturk --- app/build.gradle | 6 +++++- build.gradle | 2 +- gradle.properties | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d95f3cc66a..6e348571aa 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -147,6 +147,7 @@ android { buildTypes { debug { testCoverageEnabled(project.hasProperty('coverage')) + resConfigs "en", "xxxhdpi" } } @@ -186,7 +187,6 @@ android { } } - testOptions { unitTests.returnDefaultValues = true animationsDisabled true @@ -261,6 +261,10 @@ android { // Adds exported schema location as test app assets. androidTest.assets.srcDirs += files("$projectDir/schemas".toString()) } + + kapt { + useBuildCache true + } } dependencies { diff --git a/build.gradle b/build.gradle index 58fcfd542f..9b5b8f1af1 100644 --- a/build.gradle +++ b/build.gradle @@ -37,9 +37,9 @@ buildscript { subprojects { buildscript { repositories { - gradlePluginPortal() google() mavenCentral() + gradlePluginPortal() } } repositories { diff --git a/gradle.properties b/gradle.properties index 8a056693e8..ff1f9ab00c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,12 +13,14 @@ android.nonFinalResIds=false # JVM arguments to optimize heap usage, enable heap dump on out-of-memory errors, and set the file encoding -org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +org.gradle.jvmargs=-Xmx2g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g org.gradle.dependency.verification.console=verbose -kotlin.daemon.jvmargs=-Xmx4096m +kotlin.daemon.jvmargs=-Xmx1536m org.gradle.caching=true org.gradle.parallel=true org.gradle.configureondemand=true # Needed for local libs # org.gradle.dependency.verification=lenient + +kapt.incremental.apt=true \ No newline at end of file From 077ff6ad58a92d726b94664fe80c5fdd9fd7882a Mon Sep 17 00:00:00 2001 From: alperozturk Date: Wed, 27 Nov 2024 16:17:18 +0100 Subject: [PATCH 04/17] increase kotlin.daemon.jvmargs due to failed build variants test Signed-off-by: alperozturk --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index ff1f9ab00c..78161b03f1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,7 +15,7 @@ android.nonFinalResIds=false # JVM arguments to optimize heap usage, enable heap dump on out-of-memory errors, and set the file encoding org.gradle.jvmargs=-Xmx2g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g org.gradle.dependency.verification.console=verbose -kotlin.daemon.jvmargs=-Xmx1536m +kotlin.daemon.jvmargs=-Xmx3072m org.gradle.caching=true org.gradle.parallel=true org.gradle.configureondemand=true From aa5a196961cc029c7ab6d5cbebf814fe7a39a650 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Wed, 27 Nov 2024 16:52:40 +0100 Subject: [PATCH 05/17] increase kotlin.daemon.jvmargs due to failed build variants test Signed-off-by: alperozturk --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 78161b03f1..8ac868a664 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,7 +15,7 @@ android.nonFinalResIds=false # JVM arguments to optimize heap usage, enable heap dump on out-of-memory errors, and set the file encoding org.gradle.jvmargs=-Xmx2g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g org.gradle.dependency.verification.console=verbose -kotlin.daemon.jvmargs=-Xmx3072m +kotlin.daemon.jvmargs=-Xmx6144m org.gradle.caching=true org.gradle.parallel=true org.gradle.configureondemand=true From 82baa59e323b8e153c9180207e9bf5feedc6b806 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Mon, 2 Dec 2024 12:27:59 +0100 Subject: [PATCH 06/17] add verify metedata Signed-off-by: alperozturk --- gradle.properties | 3 +-- gradle/verification-metadata.xml | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index 8ac868a664..9be64b0460 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,8 +19,7 @@ kotlin.daemon.jvmargs=-Xmx6144m org.gradle.caching=true org.gradle.parallel=true org.gradle.configureondemand=true +kapt.incremental.apt=true # Needed for local libs # org.gradle.dependency.verification=lenient - -kapt.incremental.apt=true \ No newline at end of file diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index c95bd32ac6..51391955ab 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -188,7 +188,10 @@ - + + + + @@ -5699,10 +5702,14 @@ - + + + - + + + @@ -14555,6 +14562,11 @@ + + + + + @@ -14580,6 +14592,11 @@ + + + + + From 565158cf7bdf6bbbe3794a93bdfcc8bd48956a37 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Tue, 3 Dec 2024 09:23:43 +0100 Subject: [PATCH 07/17] UseParallelGC Signed-off-by: alperozturk --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 9be64b0460..8c5e50aa38 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,7 +15,7 @@ android.nonFinalResIds=false # JVM arguments to optimize heap usage, enable heap dump on out-of-memory errors, and set the file encoding org.gradle.jvmargs=-Xmx2g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g org.gradle.dependency.verification.console=verbose -kotlin.daemon.jvmargs=-Xmx6144m +kotlin.daemon.jvmargs=-Xmx6144m -XX:+UseParallelGC org.gradle.caching=true org.gradle.parallel=true org.gradle.configureondemand=true From aa3c87aa7a0fe36d923fa7beb8e43fb943199f6d Mon Sep 17 00:00:00 2001 From: alperozturk Date: Thu, 5 Dec 2024 14:48:28 +0100 Subject: [PATCH 08/17] increase org.gradle.jvmargs Signed-off-by: alperozturk --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 8c5e50aa38..14f2cb920c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ android.nonFinalResIds=false # JVM arguments to optimize heap usage, enable heap dump on out-of-memory errors, and set the file encoding -org.gradle.jvmargs=-Xmx2g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g +org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g org.gradle.dependency.verification.console=verbose kotlin.daemon.jvmargs=-Xmx6144m -XX:+UseParallelGC org.gradle.caching=true From 2d65cee38e985f14d4da754b6ade2941daf110cf Mon Sep 17 00:00:00 2001 From: Nextcloud bot Date: Mon, 9 Dec 2024 03:03:26 +0000 Subject: [PATCH 09/17] Fix(l10n): Update translations from Transifex Signed-off-by: Nextcloud bot --- app/src/main/res/values-ca/strings.xml | 35 ++++++++++++++++++++++++++ app/src/main/res/values-it/strings.xml | 2 ++ 2 files changed, 37 insertions(+) diff --git a/app/src/main/res/values-ca/strings.xml b/app/src/main/res/values-ca/strings.xml index 66c9e258b5..b233effbdb 100644 --- a/app/src/main/res/values-ca/strings.xml +++ b/app/src/main/res/values-ca/strings.xml @@ -34,6 +34,14 @@ Paràmetres avançats Permet compartir de nou URL base + Inhabilitació del porta-retalls + Inhabilitació de la introducció + Inhabilitació del registre + Inhabilitació de llocs externs + Inhabilitació de compte múltiple + Inhabilitació de la compartició + Aplicació de la protecció + Nom del servidor intermediari Port del proxy Mostra un giny del tauler Cerca a %s @@ -54,6 +62,7 @@ La tasca s\'ha suprimit correctament No s\'ha pogut obtenir la llista de tasques. Comproveu la vostra connexió a Internet. Suprimeix la tasca + La sortida de la tasca encara no està a punt. No s\'han pogut obtenir els tipus de tasques. Comproveu la connexió a Internet. Assistent Desconegut @@ -93,6 +102,8 @@ S\'ha produït un error en processar la sol·licitud d\'inici de sessió. Torneu-ho a provar més tard. Completeu el procés d\'inici de sessió al navegador manté a la carpeta original, ja que és només de lectura + S\'ha canviat el comportament de la càrrega automàtica + A causa de les noves restriccions imposades per Google, la funció de càrrega automàtica ja no podrà eliminar automàticament els fitxers carregats. Pujada només quan hi hagi Wi-Fi sense límits /Càrrega automàtica Configura @@ -180,7 +191,10 @@ Conflicte de carpetes Fitxer local Si seleccioneu ambdues versions, s\'afegirà un numero al nom del fitxer local. + Si seleccioneu ambdues versions, la carpeta local tindrà un número afegit al nom. Fitxer del servidor + Còpia de seguretat dels contactes + Cal permís dels contactes. Icona d\'usuari per a la llista de contactes No s\'han concedit permisos, no s\'ha importat res Contactes @@ -207,6 +221,7 @@ Nova presentació Nou full de càlcul Afegiu una descripció per a la carpeta + Afegeix la descripció de la carpeta Credencials inhabilitades Còpia de seguretat diària Dades a fer una còpia de seguretat @@ -223,15 +238,21 @@ No s\'han verificat els duplicats. Aquest algorisme de resum no és disponible al vostre telèfon. l\'Inici de sessió via enllaç directe ha fallat! + Inicia la sessió amb %1$s a %2$s Inhabilita Descarta Descarta la notificació Mostra la vostra contrasenya de 12 paraules No molesteu + Múltiples imatges Fitxer PDF + Trieu el tipus d\'exportació + Ha fallat la generació del PDF + S\'està generant el PDF... Fet No esborrar No s\'ha pogut crear el fitxer local + Nom de fitxer no vàlid per al fitxer local Baixa la darrera versió de desenvolupament No s\'ha pogut baixar%1$s La baixada ha fallat, torneu a iniciar la sessió @@ -241,7 +262,10 @@ S\'està descarregant… %1$s descarregat Descarregat + Alguns fitxers s\'han cancel·lat durant la baixada que ha fet l\'usuari + S\'ha produït un error en baixar els fitxers Encara no s\'ha descarregat + S\'ha produït un error inesperat en baixar els fitxers Tanca la barra lateral Comunitat Imatge de fons de la capçalera del calaix @@ -250,9 +274,11 @@ Assistent Preferits Multimèdia + Carpetes de grup Inici Notificacions Al dispositiu + Fitxers personals Modificat recentment Compartit Fitxers suprimits @@ -262,12 +288,19 @@ %1$s de %2$s en ús %1$s en ús Pujada automàtica + El comptador és massa antic + No s\'ha trobat la funció resum E2E encara no està configurat + No és possible sense connexió a Internet + La signatura no coincideix Assistent Més + Notes Converses + Més aplicacions de Nextcloud Notes del Nextcloud Nextcloud Talk + No s\'ha pogut triar l\'adreça electrònica. Activa el xifrat Arranjament de xifrat S\'està desxifrant… @@ -298,7 +331,9 @@ Informa d\'un problema al seguidor? (requereix un compte de GitHub) S\'ha produït un error mentre es recuperava el fitxer S\'ha produït un error recuperant les plantilles + S\'ha produït un error en mostrar el quadre de diàleg de configuració del xifratge S\'ha produït un error iniciant la càmera + S\'ha produït un error en iniciar l\'escaneig del document Comptes S\'ha creat Nom de la tasca diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 10c45e1844..3ec6517f45 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -103,6 +103,8 @@ C\'è stato un problema nella richiesta di login. Per favore, riprova più tardi Completa il procedimento di login nel tuo browser lasciato nella cartella originale, poiché è in sola lettura + Il comportamento del caricamento automatico è stato modificato + A causa delle nuove restrizioni imposte da Google, la funzionalità di caricamento automatico non sarà più in grado di rimuovere automaticamente i file caricati. Carica solo su Wi-Fi senza limitazioni /AutoUpload Configura From 2a09f53f6c4c7b303e35b45c67e49a4cebd2a9df Mon Sep 17 00:00:00 2001 From: alperozturk Date: Thu, 28 Nov 2024 12:14:22 +0100 Subject: [PATCH 10/17] dont use programmatically padding and disabled deprecated apis Signed-off-by: alperozturk --- .../client/editimage/EditImageActivity.kt | 2 -- .../utils/extensions/ActionBarExtensions.kt | 19 ++++++++++ .../utils/extensions/ActivityExtensions.kt | 27 ++++++++++++++ .../utils/extensions/ContextExtensions.kt | 36 +++++++++++-------- .../android/ui/activity/BaseActivity.java | 15 ++++++-- .../ui/activity/NotificationsActivity.kt | 2 -- .../ui/preview/PreviewMediaActivity.kt | 36 ++++++++++++++++--- app/src/main/res/layout/activity_compose.xml | 1 - .../main/res/layout/activity_list_layout.xml | 1 - app/src/main/res/layout/community_layout.xml | 1 - .../main/res/layout/contacts_preference.xml | 3 +- app/src/main/res/layout/drawer.xml | 1 - app/src/main/res/layout/drawer_header.xml | 1 - .../main/res/layout/externalsite_webview.xml | 1 - .../layout/internal_two_way_sync_layout.xml | 1 - .../main/res/layout/richdocuments_webview.xml | 1 - .../main/res/layout/synced_folders_layout.xml | 1 - app/src/main/res/layout/test_layout.xml | 1 - app/src/main/res/layout/trashbin_activity.xml | 1 - .../main/res/layout/upload_list_layout.xml | 1 - 20 files changed, 112 insertions(+), 40 deletions(-) create mode 100644 app/src/main/java/com/nextcloud/utils/extensions/ActionBarExtensions.kt diff --git a/app/src/main/java/com/nextcloud/client/editimage/EditImageActivity.kt b/app/src/main/java/com/nextcloud/client/editimage/EditImageActivity.kt index 386c1bbe8e..39692a56aa 100644 --- a/app/src/main/java/com/nextcloud/client/editimage/EditImageActivity.kt +++ b/app/src/main/java/com/nextcloud/client/editimage/EditImageActivity.kt @@ -15,7 +15,6 @@ import android.view.Menu import android.view.MenuItem import android.view.View import androidx.appcompat.content.res.AppCompatResources -import androidx.core.content.ContextCompat import androidx.core.graphics.drawable.DrawableCompat import androidx.core.view.WindowCompat import androidx.core.view.WindowInsetsCompat @@ -82,7 +81,6 @@ class EditImageActivity : val windowInsetsController = WindowCompat.getInsetsController(window, window.decorView) windowInsetsController.hide(WindowInsetsCompat.Type.statusBars()) - window.statusBarColor = ContextCompat.getColor(this, R.color.black) window.navigationBarColor = getColor(R.color.black) setupCropper() diff --git a/app/src/main/java/com/nextcloud/utils/extensions/ActionBarExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/ActionBarExtensions.kt new file mode 100644 index 0000000000..3bafc9b850 --- /dev/null +++ b/app/src/main/java/com/nextcloud/utils/extensions/ActionBarExtensions.kt @@ -0,0 +1,19 @@ +/* + * Nextcloud - Android Client + * + * SPDX-FileCopyrightText: 2024 Alper Ozturk + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +package com.nextcloud.utils.extensions + +import android.text.Spannable +import android.text.SpannableString +import android.text.style.ForegroundColorSpan +import androidx.appcompat.app.ActionBar + +fun ActionBar.setTitleColor(color: Int) { + val text = SpannableString(title ?: "") + text.setSpan(ForegroundColorSpan(color), 0, text.length, Spannable.SPAN_INCLUSIVE_INCLUSIVE) + title = text +} diff --git a/app/src/main/java/com/nextcloud/utils/extensions/ActivityExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/ActivityExtensions.kt index 0bdbbbd0cb..a3473f8cd3 100644 --- a/app/src/main/java/com/nextcloud/utils/extensions/ActivityExtensions.kt +++ b/app/src/main/java/com/nextcloud/utils/extensions/ActivityExtensions.kt @@ -7,8 +7,15 @@ package com.nextcloud.utils.extensions +import android.view.View +import android.view.Window +import androidx.annotation.ColorInt import androidx.appcompat.app.AppCompatActivity +import androidx.core.content.ContextCompat +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat import androidx.fragment.app.Fragment +import com.owncloud.android.R fun AppCompatActivity.isDialogFragmentReady(fragment: Fragment): Boolean = isActive() && !fragment.isStateSaved @@ -17,3 +24,23 @@ fun AppCompatActivity.isActive(): Boolean = !isFinishing && !isDestroyed fun AppCompatActivity.fragments(): List = supportFragmentManager.fragments fun AppCompatActivity.lastFragment(): Fragment = fragments().last() + + +fun Window?.addStatusBarPadding() { + if (this == null) { + return + } + + val decorView: View = decorView + + ViewCompat.setOnApplyWindowInsetsListener(decorView) { v: View, insets: WindowInsetsCompat -> + val statusBarInsets = insets.getInsets(WindowInsetsCompat.Type.statusBars()) + v.setPadding( + v.paddingLeft, + statusBarInsets.top, + v.paddingRight, + v.paddingBottom + ) + insets + } +} diff --git a/app/src/main/java/com/nextcloud/utils/extensions/ContextExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/ContextExtensions.kt index 0cfc83439e..d69b1891d6 100644 --- a/app/src/main/java/com/nextcloud/utils/extensions/ContextExtensions.kt +++ b/app/src/main/java/com/nextcloud/utils/extensions/ContextExtensions.kt @@ -15,8 +15,11 @@ import android.content.IntentFilter import android.os.Build import android.os.Handler import android.os.Looper +import android.view.WindowInsets +import android.view.WindowManager import android.widget.Toast -import com.google.common.io.Resources +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat import com.owncloud.android.R import com.owncloud.android.datamodel.ReceiverFlag @@ -33,21 +36,24 @@ fun Context.registerBroadcastReceiver(receiver: BroadcastReceiver?, filter: Inte } } -/** - * - * @return The height of the status bar in pixel. - * - * @throws Resources.NotFoundException If the resource identifier for `status_bar_height` is not found. - * - */ -@SuppressLint("DiscouragedApi", "InternalInsetResource") fun Context.statusBarHeight(): Int { - return try { - resources.getDimensionPixelSize( - resources.getIdentifier("status_bar_height", "dimen", "android") - ) - } catch (e: android.content.res.Resources.NotFoundException) { - 0 + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + val windowInsets = (getSystemService(Context.WINDOW_SERVICE) as WindowManager) + .currentWindowMetrics + .windowInsets + val insets = windowInsets.getInsets(WindowInsets.Type.statusBars()) + insets.top + } else { + @Suppress("DEPRECATION") + val decorView = (getSystemService(Context.WINDOW_SERVICE) as WindowManager) + .defaultDisplay + .let { display -> + val decorView = android.view.View(this) + display.getRealMetrics(android.util.DisplayMetrics()) + decorView + } + val windowInsetsCompat = ViewCompat.getRootWindowInsets(decorView) + windowInsetsCompat?.getInsets(WindowInsetsCompat.Type.statusBars())?.top ?: 0 } } diff --git a/app/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java index d154b2dccf..c2a440ccde 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java @@ -9,6 +9,7 @@ package com.owncloud.android.ui.activity; import android.accounts.Account; import android.content.Intent; +import android.graphics.Color; import android.os.Bundle; import com.nextcloud.client.account.User; @@ -18,6 +19,7 @@ import com.nextcloud.client.mixins.MixinRegistry; import com.nextcloud.client.mixins.SessionMixin; import com.nextcloud.client.preferences.AppPreferences; import com.nextcloud.client.preferences.DarkMode; +import com.nextcloud.utils.extensions.ActivityExtensionsKt; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.common.utils.Log_OC; @@ -27,6 +29,8 @@ import java.util.Optional; import javax.inject.Inject; +import androidx.activity.EdgeToEdge; +import androidx.activity.SystemBarStyle; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; @@ -44,14 +48,14 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab private boolean paused; protected boolean enableAccountHandling = true; - private MixinRegistry mixinRegistry = new MixinRegistry(); + private final MixinRegistry mixinRegistry = new MixinRegistry(); private SessionMixin sessionMixin; @Inject UserAccountManager accountManager; @Inject AppPreferences preferences; @Inject FileDataStorageManager fileDataStorageManager; - private AppPreferences.Listener onPreferencesChanged = new AppPreferences.Listener() { + private final AppPreferences.Listener onPreferencesChanged = new AppPreferences.Listener() { @Override public void onDarkThemeModeChanged(DarkMode mode) { onThemeSettingsModeChanged(); @@ -64,6 +68,8 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab @Override protected void onCreate(@Nullable Bundle savedInstanceState) { + enableEdgeToEdge(); + ActivityExtensionsKt.addStatusBarPadding(getWindow()); super.onCreate(savedInstanceState); sessionMixin = new SessionMixin(this, accountManager); mixinRegistry.add(sessionMixin); @@ -73,6 +79,11 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab } } + private void enableEdgeToEdge() { + final var style = SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT); + EdgeToEdge.enable(this, style, style); + } + @Override protected void onPostCreate(@Nullable Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); diff --git a/app/src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.kt index 640cf95b6d..1840ca079c 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.kt @@ -17,7 +17,6 @@ import android.view.View import android.view.WindowInsetsController import androidx.annotation.VisibleForTesting import androidx.appcompat.app.AppCompatActivity -import androidx.core.content.ContextCompat import androidx.recyclerview.widget.LinearLayoutManager import com.google.android.material.snackbar.Snackbar import com.nextcloud.client.account.User @@ -108,7 +107,6 @@ class NotificationsActivity : AppCompatActivity(), NotificationsContract.View, I } private fun setupStatusBar() { - window.statusBarColor = ContextCompat.getColor(this, R.color.bg_default) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { val appearanceLightStatusBars = if (preferences.isDarkModeEnabled) { 0 diff --git a/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt b/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt index 4582cd5ca0..985cc64b0d 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt @@ -18,6 +18,8 @@ import android.content.DialogInterface import android.content.Intent import android.content.res.Configuration import android.graphics.BitmapFactory +import android.graphics.Color +import android.graphics.drawable.ColorDrawable import android.graphics.drawable.Drawable import android.net.Uri import android.os.AsyncTask @@ -34,6 +36,8 @@ import android.widget.LinearLayout import androidx.annotation.OptIn import androidx.annotation.StringRes import androidx.appcompat.content.res.AppCompatResources +import androidx.core.content.ContextCompat +import androidx.core.content.res.ResourcesCompat import androidx.core.graphics.drawable.DrawableCompat import androidx.core.view.ViewCompat import androidx.core.view.WindowCompat @@ -72,6 +76,7 @@ import com.nextcloud.ui.fileactions.FileActionsBottomSheet.Companion.newInstance import com.nextcloud.ui.fileactions.FileActionsBottomSheet.ResultListener import com.nextcloud.utils.extensions.getParcelableArgument import com.nextcloud.utils.extensions.logFileSize +import com.nextcloud.utils.extensions.setTitleColor import com.nextcloud.utils.extensions.statusBarHeight import com.owncloud.android.R import com.owncloud.android.databinding.ActivityPreviewMediaBinding @@ -234,22 +239,37 @@ class PreviewMediaActivity : return } - val isFileVideo = MimeTypeUtil.isVideo(file) + binding.exoplayerView.visibility = if (isFileVideo()) View.VISIBLE else View.GONE + binding.imagePreview.visibility = if (isFileVideo()) View.GONE else View.VISIBLE - binding.exoplayerView.visibility = if (isFileVideo) View.VISIBLE else View.GONE - binding.imagePreview.visibility = if (isFileVideo) View.GONE else View.VISIBLE - - if (isFileVideo) { + if (isFileVideo()) { binding.root.setBackgroundColor(resources.getColor(R.color.black, null)) } } + private fun isFileVideo(): Boolean = MimeTypeUtil.isVideo(file) + private fun configureSystemBars() { updateActionBarTitleAndHomeButton(file) supportActionBar?.let { it.setDisplayHomeAsUpEnabled(true) viewThemeUtils.files.themeActionBar(this, it) + + if (isFileVideo()) { + it.setTitleColor( + resources.getColor( + R.color.white, + null + ) + ) + + it.setHomeAsUpIndicator( + ResourcesCompat.getDrawable(resources, R.drawable.ic_arrow_back, theme) + ?.apply { setTint(Color.WHITE) }) + + it.setBackgroundDrawable(ColorDrawable(Color.BLACK)) + } } viewThemeUtils.platform.themeStatusBar( @@ -520,6 +540,12 @@ class PreviewMediaActivity : override fun onCreateOptionsMenu(menu: Menu?): Boolean { menuInflater.inflate(R.menu.custom_menu_placeholder, menu) + + if (isFileVideo()) { + val moreMenuItem = menu?.findItem(R.id.custom_menu_placeholder_item) + moreMenuItem?.icon?.setTint(ContextCompat.getColor(this, R.color.white)) + } + return true } diff --git a/app/src/main/res/layout/activity_compose.xml b/app/src/main/res/layout/activity_compose.xml index 48a7b07773..2e49ac23e7 100644 --- a/app/src/main/res/layout/activity_compose.xml +++ b/app/src/main/res/layout/activity_compose.xml @@ -12,7 +12,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:clickable="true" - android:fitsSystemWindows="true" android:focusable="true"> diff --git a/app/src/main/res/layout/contacts_preference.xml b/app/src/main/res/layout/contacts_preference.xml index e7524a6082..bce8b5ae69 100644 --- a/app/src/main/res/layout/contacts_preference.xml +++ b/app/src/main/res/layout/contacts_preference.xml @@ -9,8 +9,7 @@ + android:layout_height="match_parent"> diff --git a/app/src/main/res/layout/externalsite_webview.xml b/app/src/main/res/layout/externalsite_webview.xml index d2cfbf68a2..090f1c3b75 100644 --- a/app/src/main/res/layout/externalsite_webview.xml +++ b/app/src/main/res/layout/externalsite_webview.xml @@ -11,7 +11,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:clickable="true" - android:fitsSystemWindows="true" android:focusable="true"> diff --git a/app/src/main/res/layout/internal_two_way_sync_layout.xml b/app/src/main/res/layout/internal_two_way_sync_layout.xml index 43476a42db..19d3e50741 100644 --- a/app/src/main/res/layout/internal_two_way_sync_layout.xml +++ b/app/src/main/res/layout/internal_two_way_sync_layout.xml @@ -11,7 +11,6 @@ android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" - android:fitsSystemWindows="true" tools:openDrawer="start"> diff --git a/app/src/main/res/layout/synced_folders_layout.xml b/app/src/main/res/layout/synced_folders_layout.xml index 4e3af068df..ea30c5c95d 100644 --- a/app/src/main/res/layout/synced_folders_layout.xml +++ b/app/src/main/res/layout/synced_folders_layout.xml @@ -12,7 +12,6 @@ android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" - android:fitsSystemWindows="true" tools:openDrawer="start"> diff --git a/app/src/main/res/layout/trashbin_activity.xml b/app/src/main/res/layout/trashbin_activity.xml index d94459347c..1c8fd6e583 100644 --- a/app/src/main/res/layout/trashbin_activity.xml +++ b/app/src/main/res/layout/trashbin_activity.xml @@ -12,7 +12,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:clickable="true" - android:fitsSystemWindows="true" android:focusable="true"> diff --git a/app/src/main/res/layout/upload_list_layout.xml b/app/src/main/res/layout/upload_list_layout.xml index 4de7210cf9..8dfbe1fb69 100755 --- a/app/src/main/res/layout/upload_list_layout.xml +++ b/app/src/main/res/layout/upload_list_layout.xml @@ -12,7 +12,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:clickable="true" - android:fitsSystemWindows="true" android:focusable="true"> From 0ff17fbb133fb7a46a94d9229ab5356f24a149c8 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Thu, 28 Nov 2024 12:25:37 +0100 Subject: [PATCH 11/17] fix settings activity and preview video Signed-off-by: alperozturk --- .../utils/extensions/ActivityExtensions.kt | 27 ------------- .../utils/extensions/ViewExtensions.kt | 13 +++++++ .../utils/extensions/WindowExtensions.kt | 38 +++++++++++++++++++ .../android/ui/activity/BaseActivity.java | 6 ++- .../android/ui/activity/SettingsActivity.java | 17 +++++++++ app/src/main/res/values/dims.xml | 2 +- 6 files changed, 74 insertions(+), 29 deletions(-) create mode 100644 app/src/main/java/com/nextcloud/utils/extensions/WindowExtensions.kt diff --git a/app/src/main/java/com/nextcloud/utils/extensions/ActivityExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/ActivityExtensions.kt index a3473f8cd3..0bdbbbd0cb 100644 --- a/app/src/main/java/com/nextcloud/utils/extensions/ActivityExtensions.kt +++ b/app/src/main/java/com/nextcloud/utils/extensions/ActivityExtensions.kt @@ -7,15 +7,8 @@ package com.nextcloud.utils.extensions -import android.view.View -import android.view.Window -import androidx.annotation.ColorInt import androidx.appcompat.app.AppCompatActivity -import androidx.core.content.ContextCompat -import androidx.core.view.ViewCompat -import androidx.core.view.WindowInsetsCompat import androidx.fragment.app.Fragment -import com.owncloud.android.R fun AppCompatActivity.isDialogFragmentReady(fragment: Fragment): Boolean = isActive() && !fragment.isStateSaved @@ -24,23 +17,3 @@ fun AppCompatActivity.isActive(): Boolean = !isFinishing && !isDestroyed fun AppCompatActivity.fragments(): List = supportFragmentManager.fragments fun AppCompatActivity.lastFragment(): Fragment = fragments().last() - - -fun Window?.addStatusBarPadding() { - if (this == null) { - return - } - - val decorView: View = decorView - - ViewCompat.setOnApplyWindowInsetsListener(decorView) { v: View, insets: WindowInsetsCompat -> - val statusBarInsets = insets.getInsets(WindowInsetsCompat.Type.statusBars()) - v.setPadding( - v.paddingLeft, - statusBarInsets.top, - v.paddingRight, - v.paddingBottom - ) - insets - } -} diff --git a/app/src/main/java/com/nextcloud/utils/extensions/ViewExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/ViewExtensions.kt index c024fd4f65..02cdbc3f91 100644 --- a/app/src/main/java/com/nextcloud/utils/extensions/ViewExtensions.kt +++ b/app/src/main/java/com/nextcloud/utils/extensions/ViewExtensions.kt @@ -11,6 +11,7 @@ import android.content.Context import android.graphics.Outline import android.util.TypedValue import android.view.View +import android.view.ViewGroup import android.view.ViewOutlineProvider fun View?.setVisibleIf(condition: Boolean) { @@ -27,6 +28,18 @@ fun View?.makeRounded(context: Context, cornerRadius: Float) { } } +fun View?.setMargins(left: Int, top: Int, right: Int, bottom: Int) { + if (this == null) { + return + } + + if (layoutParams is ViewGroup.MarginLayoutParams) { + val param = layoutParams as ViewGroup.MarginLayoutParams + param.setMargins(left, top, right, bottom) + requestLayout() + } +} + fun createRoundedOutline(context: Context, cornerRadiusValue: Float): ViewOutlineProvider { return object : ViewOutlineProvider() { override fun getOutline(view: View, outline: Outline) { diff --git a/app/src/main/java/com/nextcloud/utils/extensions/WindowExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/WindowExtensions.kt new file mode 100644 index 0000000000..59e39108e8 --- /dev/null +++ b/app/src/main/java/com/nextcloud/utils/extensions/WindowExtensions.kt @@ -0,0 +1,38 @@ +/* + * Nextcloud - Android Client + * + * SPDX-FileCopyrightText: 2024 Alper Ozturk + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +package com.nextcloud.utils.extensions + +import android.view.View +import android.view.Window +import android.view.WindowManager +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat + +fun Window?.makeStatusBarTransparent() { + val flag = WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS + this?.setFlags(flag, flag) +} + +fun Window?.addStatusBarPadding() { + if (this == null) { + return + } + + val decorView: View = decorView + + ViewCompat.setOnApplyWindowInsetsListener(decorView) { v: View, insets: WindowInsetsCompat -> + val statusBarInsets = insets.getInsets(WindowInsetsCompat.Type.statusBars()) + v.setPadding( + v.paddingLeft, + statusBarInsets.top, + v.paddingRight, + v.paddingBottom + ) + insets + } +} diff --git a/app/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java index c2a440ccde..9c963aa26e 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java @@ -11,6 +11,7 @@ import android.accounts.Account; import android.content.Intent; import android.graphics.Color; import android.os.Bundle; +import android.view.WindowManager; import com.nextcloud.client.account.User; import com.nextcloud.client.account.UserAccountManager; @@ -20,6 +21,7 @@ import com.nextcloud.client.mixins.SessionMixin; import com.nextcloud.client.preferences.AppPreferences; import com.nextcloud.client.preferences.DarkMode; import com.nextcloud.utils.extensions.ActivityExtensionsKt; +import com.nextcloud.utils.extensions.WindowExtensionsKt; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.common.utils.Log_OC; @@ -33,6 +35,7 @@ import androidx.activity.EdgeToEdge; import androidx.activity.SystemBarStyle; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; +import androidx.core.view.WindowCompat; /** * Base activity with common behaviour for activities dealing with ownCloud {@link Account}s . @@ -69,7 +72,8 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab @Override protected void onCreate(@Nullable Bundle savedInstanceState) { enableEdgeToEdge(); - ActivityExtensionsKt.addStatusBarPadding(getWindow()); + WindowExtensionsKt.makeStatusBarTransparent(getWindow()); + WindowExtensionsKt.addStatusBarPadding(getWindow()); super.onCreate(savedInstanceState); sessionMixin = new SessionMixin(this, accountManager); mixinRegistry.add(sessionMixin); diff --git a/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java index e2619d45d4..973ecca38d 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java @@ -50,6 +50,8 @@ import com.nextcloud.client.network.ConnectivityService; import com.nextcloud.client.preferences.AppPreferences; import com.nextcloud.client.preferences.AppPreferencesImpl; import com.nextcloud.client.preferences.DarkMode; +import com.nextcloud.utils.extensions.ViewExtensionsKt; +import com.nextcloud.utils.extensions.WindowExtensionsKt; import com.nextcloud.utils.mdm.MDMConfig; import com.owncloud.android.MainApp; import com.owncloud.android.R; @@ -144,6 +146,8 @@ public class SettingsActivity extends PreferenceActivity @SuppressWarnings("deprecation") @Override public void onCreate(Bundle savedInstanceState) { + WindowExtensionsKt.makeStatusBarTransparent(getWindow()); + WindowExtensionsKt.addStatusBarPadding(getWindow()); super.onCreate(savedInstanceState); getDelegate().installViewFactory(); @@ -187,6 +191,19 @@ public class SettingsActivity extends PreferenceActivity // workaround for mismatched color when app dark mode and system dark mode don't agree setListBackground(); showPasscodeDialogIfEnforceAppProtection(); + adjustTopMarginForActionBar(); + } + + private void adjustTopMarginForActionBar() { + if (getListView() == null) { + return; + } + + float topMarginInDp = getResources().getDimension(R.dimen.settings_activity_padding); + int topMarginInPx = DisplayUtils.convertDpToPixel(topMarginInDp, this); + ViewExtensionsKt.setMargins(getListView(), 0, topMarginInPx, 0, 0); + + getWindow().getDecorView().setBackgroundColor(ContextCompat.getColor(this, R.color.bg_default)); } private void showPasscodeDialogIfEnforceAppProtection() { diff --git a/app/src/main/res/values/dims.xml b/app/src/main/res/values/dims.xml index af90df2b0f..ddcc166374 100644 --- a/app/src/main/res/values/dims.xml +++ b/app/src/main/res/values/dims.xml @@ -51,7 +51,7 @@ 12dp 3dp 16dp - + 24dp 10dp 72dp 0dp From 5c7cdafa104408aea66b70ac7584b922a3793936 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Thu, 28 Nov 2024 14:24:32 +0100 Subject: [PATCH 12/17] fix settings activity and preview video Signed-off-by: alperozturk --- .../java/com/nextcloud/utils/extensions/WindowExtensions.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/java/com/nextcloud/utils/extensions/WindowExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/WindowExtensions.kt index 59e39108e8..41cccada97 100644 --- a/app/src/main/java/com/nextcloud/utils/extensions/WindowExtensions.kt +++ b/app/src/main/java/com/nextcloud/utils/extensions/WindowExtensions.kt @@ -23,8 +23,6 @@ fun Window?.addStatusBarPadding() { return } - val decorView: View = decorView - ViewCompat.setOnApplyWindowInsetsListener(decorView) { v: View, insets: WindowInsetsCompat -> val statusBarInsets = insets.getInsets(WindowInsetsCompat.Type.statusBars()) v.setPadding( From 5dab2604d27e14388003cbf40990df7be471d38e Mon Sep 17 00:00:00 2001 From: alperozturk Date: Thu, 28 Nov 2024 14:26:59 +0100 Subject: [PATCH 13/17] fix code analytics Signed-off-by: alperozturk --- .../com/owncloud/android/ui/preview/PreviewMediaActivity.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt b/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt index 985cc64b0d..1f892cf181 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt @@ -266,7 +266,8 @@ class PreviewMediaActivity : it.setHomeAsUpIndicator( ResourcesCompat.getDrawable(resources, R.drawable.ic_arrow_back, theme) - ?.apply { setTint(Color.WHITE) }) + ?.apply { setTint(Color.WHITE) } + ) it.setBackgroundDrawable(ColorDrawable(Color.BLACK)) } From 42a9c1fa69ed2f0d448917d09be58b1d9146a4f9 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Thu, 28 Nov 2024 15:21:58 +0100 Subject: [PATCH 14/17] addSystemBarPaddings Signed-off-by: alperozturk --- .../utils/extensions/WindowExtensions.kt | 25 ++++++++----------- .../android/ui/activity/BaseActivity.java | 6 +---- .../android/ui/activity/SettingsActivity.java | 17 ------------- app/src/main/res/values/dims.xml | 1 - 4 files changed, 12 insertions(+), 37 deletions(-) diff --git a/app/src/main/java/com/nextcloud/utils/extensions/WindowExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/WindowExtensions.kt index 41cccada97..1cd98d039c 100644 --- a/app/src/main/java/com/nextcloud/utils/extensions/WindowExtensions.kt +++ b/app/src/main/java/com/nextcloud/utils/extensions/WindowExtensions.kt @@ -9,28 +9,25 @@ package com.nextcloud.utils.extensions import android.view.View import android.view.Window -import android.view.WindowManager import androidx.core.view.ViewCompat import androidx.core.view.WindowInsetsCompat +import androidx.core.view.updatePadding -fun Window?.makeStatusBarTransparent() { - val flag = WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS - this?.setFlags(flag, flag) -} - -fun Window?.addStatusBarPadding() { +fun Window?.addSystemBarPaddings() { if (this == null) { return } ViewCompat.setOnApplyWindowInsetsListener(decorView) { v: View, insets: WindowInsetsCompat -> - val statusBarInsets = insets.getInsets(WindowInsetsCompat.Type.statusBars()) - v.setPadding( - v.paddingLeft, - statusBarInsets.top, - v.paddingRight, - v.paddingBottom + val bars = insets.getInsets(WindowInsetsCompat.Type.systemBars()) + + v.updatePadding( + left = bars.left, + top = bars.top, + right = bars.right, + bottom = bars.bottom, ) - insets + + WindowInsetsCompat.CONSUMED } } diff --git a/app/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java index 9c963aa26e..8b11e60b4d 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java @@ -11,7 +11,6 @@ import android.accounts.Account; import android.content.Intent; import android.graphics.Color; import android.os.Bundle; -import android.view.WindowManager; import com.nextcloud.client.account.User; import com.nextcloud.client.account.UserAccountManager; @@ -20,7 +19,6 @@ import com.nextcloud.client.mixins.MixinRegistry; import com.nextcloud.client.mixins.SessionMixin; import com.nextcloud.client.preferences.AppPreferences; import com.nextcloud.client.preferences.DarkMode; -import com.nextcloud.utils.extensions.ActivityExtensionsKt; import com.nextcloud.utils.extensions.WindowExtensionsKt; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; @@ -35,7 +33,6 @@ import androidx.activity.EdgeToEdge; import androidx.activity.SystemBarStyle; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; -import androidx.core.view.WindowCompat; /** * Base activity with common behaviour for activities dealing with ownCloud {@link Account}s . @@ -72,8 +69,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab @Override protected void onCreate(@Nullable Bundle savedInstanceState) { enableEdgeToEdge(); - WindowExtensionsKt.makeStatusBarTransparent(getWindow()); - WindowExtensionsKt.addStatusBarPadding(getWindow()); + WindowExtensionsKt.addSystemBarPaddings(getWindow()); super.onCreate(savedInstanceState); sessionMixin = new SessionMixin(this, accountManager); mixinRegistry.add(sessionMixin); diff --git a/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java index 973ecca38d..e2619d45d4 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java @@ -50,8 +50,6 @@ import com.nextcloud.client.network.ConnectivityService; import com.nextcloud.client.preferences.AppPreferences; import com.nextcloud.client.preferences.AppPreferencesImpl; import com.nextcloud.client.preferences.DarkMode; -import com.nextcloud.utils.extensions.ViewExtensionsKt; -import com.nextcloud.utils.extensions.WindowExtensionsKt; import com.nextcloud.utils.mdm.MDMConfig; import com.owncloud.android.MainApp; import com.owncloud.android.R; @@ -146,8 +144,6 @@ public class SettingsActivity extends PreferenceActivity @SuppressWarnings("deprecation") @Override public void onCreate(Bundle savedInstanceState) { - WindowExtensionsKt.makeStatusBarTransparent(getWindow()); - WindowExtensionsKt.addStatusBarPadding(getWindow()); super.onCreate(savedInstanceState); getDelegate().installViewFactory(); @@ -191,19 +187,6 @@ public class SettingsActivity extends PreferenceActivity // workaround for mismatched color when app dark mode and system dark mode don't agree setListBackground(); showPasscodeDialogIfEnforceAppProtection(); - adjustTopMarginForActionBar(); - } - - private void adjustTopMarginForActionBar() { - if (getListView() == null) { - return; - } - - float topMarginInDp = getResources().getDimension(R.dimen.settings_activity_padding); - int topMarginInPx = DisplayUtils.convertDpToPixel(topMarginInDp, this); - ViewExtensionsKt.setMargins(getListView(), 0, topMarginInPx, 0, 0); - - getWindow().getDecorView().setBackgroundColor(ContextCompat.getColor(this, R.color.bg_default)); } private void showPasscodeDialogIfEnforceAppProtection() { diff --git a/app/src/main/res/values/dims.xml b/app/src/main/res/values/dims.xml index ddcc166374..e1a65104fc 100644 --- a/app/src/main/res/values/dims.xml +++ b/app/src/main/res/values/dims.xml @@ -51,7 +51,6 @@ 12dp 3dp 16dp - 24dp 10dp 72dp 0dp From aab9409ad395b832529db61b57971decf86b9240 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Thu, 28 Nov 2024 15:23:03 +0100 Subject: [PATCH 15/17] fix code analytics Signed-off-by: alperozturk --- .../java/com/nextcloud/utils/extensions/WindowExtensions.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/utils/extensions/WindowExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/WindowExtensions.kt index 1cd98d039c..e593456ed5 100644 --- a/app/src/main/java/com/nextcloud/utils/extensions/WindowExtensions.kt +++ b/app/src/main/java/com/nextcloud/utils/extensions/WindowExtensions.kt @@ -25,7 +25,7 @@ fun Window?.addSystemBarPaddings() { left = bars.left, top = bars.top, right = bars.right, - bottom = bars.bottom, + bottom = bars.bottom ) WindowInsetsCompat.CONSUMED From 9487e8b3c8f9aef9eabab243e6dd9b127d3412c0 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Thu, 28 Nov 2024 15:53:07 +0100 Subject: [PATCH 16/17] fix settings activity Signed-off-by: alperozturk --- .../utils/extensions/WindowExtensions.kt | 6 ++++++ .../android/ui/activity/SettingsActivity.java | 17 +++++++++++++++++ app/src/main/res/values/dims.xml | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/utils/extensions/WindowExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/WindowExtensions.kt index e593456ed5..7d6e38dd59 100644 --- a/app/src/main/java/com/nextcloud/utils/extensions/WindowExtensions.kt +++ b/app/src/main/java/com/nextcloud/utils/extensions/WindowExtensions.kt @@ -9,10 +9,16 @@ package com.nextcloud.utils.extensions import android.view.View import android.view.Window +import android.view.WindowManager import androidx.core.view.ViewCompat import androidx.core.view.WindowInsetsCompat import androidx.core.view.updatePadding +fun Window?.setNoLimitLayout() { + val flag = WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS + this?.setFlags(flag, flag) +} + fun Window?.addSystemBarPaddings() { if (this == null) { return diff --git a/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java index e2619d45d4..dd9427b436 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java @@ -50,6 +50,8 @@ import com.nextcloud.client.network.ConnectivityService; import com.nextcloud.client.preferences.AppPreferences; import com.nextcloud.client.preferences.AppPreferencesImpl; import com.nextcloud.client.preferences.DarkMode; +import com.nextcloud.utils.extensions.ViewExtensionsKt; +import com.nextcloud.utils.extensions.WindowExtensionsKt; import com.nextcloud.utils.mdm.MDMConfig; import com.owncloud.android.MainApp; import com.owncloud.android.R; @@ -144,6 +146,8 @@ public class SettingsActivity extends PreferenceActivity @SuppressWarnings("deprecation") @Override public void onCreate(Bundle savedInstanceState) { + WindowExtensionsKt.addSystemBarPaddings(getWindow()); + WindowExtensionsKt.setNoLimitLayout(getWindow()); super.onCreate(savedInstanceState); getDelegate().installViewFactory(); @@ -187,6 +191,19 @@ public class SettingsActivity extends PreferenceActivity // workaround for mismatched color when app dark mode and system dark mode don't agree setListBackground(); showPasscodeDialogIfEnforceAppProtection(); + adjustTopMarginForActionBar(); + } + + private void adjustTopMarginForActionBar() { + if (getListView() == null) { + return; + } + + float topMarginInDp = getResources().getDimension(R.dimen.settings_activity_padding); + int topMarginInPx = DisplayUtils.convertDpToPixel(topMarginInDp, this); + ViewExtensionsKt.setMargins(getListView(), 0, topMarginInPx, 0, 0); + + getWindow().getDecorView().setBackgroundColor(ContextCompat.getColor(this, R.color.bg_default)); } private void showPasscodeDialogIfEnforceAppProtection() { diff --git a/app/src/main/res/values/dims.xml b/app/src/main/res/values/dims.xml index e1a65104fc..1d1dba647e 100644 --- a/app/src/main/res/values/dims.xml +++ b/app/src/main/res/values/dims.xml @@ -135,7 +135,7 @@ 18sp 24dp 160dp - + 24dp 4 12dp 50dp From b9be105730b5c51588001facd72829a5ceadbc44 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Fri, 29 Nov 2024 12:31:32 +0100 Subject: [PATCH 17/17] Apply only for api level 35 Signed-off-by: alperozturk --- .../owncloud/android/ui/activity/BaseActivity.java | 10 ++++++++-- .../android/ui/activity/SettingsActivity.java | 14 +++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java index 8b11e60b4d..af85b9ebeb 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java @@ -10,6 +10,7 @@ package com.owncloud.android.ui.activity; import android.accounts.Account; import android.content.Intent; import android.graphics.Color; +import android.os.Build; import android.os.Bundle; import com.nextcloud.client.account.User; @@ -68,8 +69,13 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab @Override protected void onCreate(@Nullable Bundle savedInstanceState) { - enableEdgeToEdge(); - WindowExtensionsKt.addSystemBarPaddings(getWindow()); + boolean isApiLevel35OrHigher = (Build.VERSION.SDK_INT >= 35); + + if (isApiLevel35OrHigher) { + enableEdgeToEdge(); + WindowExtensionsKt.addSystemBarPaddings(getWindow()); + } + super.onCreate(savedInstanceState); sessionMixin = new SessionMixin(this, accountManager); mixinRegistry.add(sessionMixin); diff --git a/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java index dd9427b436..bde331c722 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java @@ -23,6 +23,7 @@ import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Configuration; import android.graphics.drawable.Drawable; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.preference.ListPreference; import android.preference.Preference; @@ -146,8 +147,12 @@ public class SettingsActivity extends PreferenceActivity @SuppressWarnings("deprecation") @Override public void onCreate(Bundle savedInstanceState) { - WindowExtensionsKt.addSystemBarPaddings(getWindow()); - WindowExtensionsKt.setNoLimitLayout(getWindow()); + boolean isApiLevel35OrHigher = (Build.VERSION.SDK_INT >= 35); + if (isApiLevel35OrHigher) { + WindowExtensionsKt.addSystemBarPaddings(getWindow()); + WindowExtensionsKt.setNoLimitLayout(getWindow()); + } + super.onCreate(savedInstanceState); getDelegate().installViewFactory(); @@ -191,7 +196,10 @@ public class SettingsActivity extends PreferenceActivity // workaround for mismatched color when app dark mode and system dark mode don't agree setListBackground(); showPasscodeDialogIfEnforceAppProtection(); - adjustTopMarginForActionBar(); + + if (isApiLevel35OrHigher) { + adjustTopMarginForActionBar(); + } } private void adjustTopMarginForActionBar() {