From d4493d3f760211bdceabd62b0568d2aaa4a6c006 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Fri, 3 Jan 2025 11:37:04 +0100 Subject: [PATCH] enable power warning for emulators Signed-off-by: tobiasKaminsky --- .../com/nextcloud/client/SyncedFoldersActivityIT.java | 2 +- .../android/ui/activity/SyncedFoldersActivity.kt | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/androidTest/java/com/nextcloud/client/SyncedFoldersActivityIT.java b/app/src/androidTest/java/com/nextcloud/client/SyncedFoldersActivityIT.java index 4bc1377a7f17..31317079c187 100644 --- a/app/src/androidTest/java/com/nextcloud/client/SyncedFoldersActivityIT.java +++ b/app/src/androidTest/java/com/nextcloud/client/SyncedFoldersActivityIT.java @@ -92,7 +92,7 @@ public void showPowerCheckDialog() { AlertDialog sut = activity.buildPowerCheckDialog(); - activity.runOnUiThread(sut::show); + activity.runOnUiThread(activity::showPowerCheckDialog); getInstrumentation().waitForIdleSync(); shortSleep(); diff --git a/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt index d18c26825cb6..873f310efe9b 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt @@ -26,6 +26,7 @@ import androidx.drawerlayout.widget.DrawerLayout import androidx.lifecycle.Lifecycle import androidx.recyclerview.widget.GridLayoutManager import com.google.android.material.dialog.MaterialAlertDialogBuilder +import com.nextcloud.client.appinfo.AppInfo import com.nextcloud.client.core.Clock import com.nextcloud.client.device.PowerManagementService import com.nextcloud.client.di.Injectable @@ -143,6 +144,9 @@ class SyncedFoldersActivity : @Inject lateinit var syncedFolderProvider: SyncedFolderProvider + @Inject + lateinit var appInfo: AppInfo + lateinit var binding: SyncedFoldersLayoutBinding lateinit var adapter: SyncedFolderAdapter @@ -816,7 +820,10 @@ class SyncedFoldersActivity : } private fun showBatteryOptimizationInfo() { - if (powerManagementService.isPowerSavingExclusionAvailable || checkIfBatteryOptimizationEnabled()) { + if (powerManagementService.isPowerSavingExclusionAvailable || + checkIfBatteryOptimizationEnabled() || + appInfo.isDebugBuild + ) { val alertDialogBuilder = MaterialAlertDialogBuilder(this, R.style.Theme_ownCloud_Dialog) .setTitle(getString(R.string.battery_optimization_title)) .setMessage(getString(R.string.battery_optimization_message))