diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/localLibrary/CopyMoveFileHandlerRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/localLibrary/CopyMoveFileHandlerRobot.kt index ed32babe6..4e3571508 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/localLibrary/CopyMoveFileHandlerRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/localLibrary/CopyMoveFileHandlerRobot.kt @@ -28,7 +28,6 @@ import androidx.test.espresso.web.sugar.Web import androidx.test.espresso.web.webdriver.DriverAtoms import androidx.test.espresso.web.webdriver.Locator import applyWithViewHierarchyPrinting -import com.adevinta.android.barista.interaction.BaristaSleepInteractions import org.kiwix.kiwixmobile.BaseRobot import org.kiwix.kiwixmobile.Findable import org.kiwix.kiwixmobile.R.id @@ -39,8 +38,8 @@ import org.kiwix.kiwixmobile.core.utils.dialog.ALERT_DIALOG_MESSAGE_TEXT_TESTING import org.kiwix.kiwixmobile.core.utils.dialog.ALERT_DIALOG_NATURAL_BUTTON_TESTING_TAG import org.kiwix.kiwixmobile.nav.destination.library.local.NO_FILE_TEXT_TESTING_TAG import org.kiwix.kiwixmobile.storage.STORAGE_SELECTION_DIALOG_TITLE_TESTING_TAG -import org.kiwix.kiwixmobile.testutils.TestUtils import org.kiwix.kiwixmobile.testutils.TestUtils.testFlakyView +import org.kiwix.kiwixmobile.testutils.TestUtils.waitUntilTimeout import org.kiwix.kiwixmobile.ui.STORAGE_DEVICE_ITEM_TESTING_TAG fun copyMoveFileHandler(func: CopyMoveFileHandlerRobot.() -> Unit) = @@ -48,9 +47,8 @@ fun copyMoveFileHandler(func: CopyMoveFileHandlerRobot.() -> Unit) = class CopyMoveFileHandlerRobot : BaseRobot() { fun assertCopyMoveDialogDisplayed(composeTestRule: ComposeContentTestRule) { - pauseForBetterTestPerformance() composeTestRule.apply { - waitForIdle() + waitUntilTimeout() onNodeWithTag(ALERT_DIALOG_MESSAGE_TEXT_TESTING_TAG) .assertTextEquals(context.getString(R.string.copy_move_files_dialog_description)) } @@ -59,7 +57,7 @@ class CopyMoveFileHandlerRobot : BaseRobot() { fun assertCopyMoveDialogNotDisplayed(composeTestRule: ComposeContentTestRule) { testFlakyView({ composeTestRule.apply { - waitForIdle() + waitUntilTimeout() onNodeWithTag(ALERT_DIALOG_MESSAGE_TEXT_TESTING_TAG) .assertDoesNotExist() } @@ -69,7 +67,7 @@ class CopyMoveFileHandlerRobot : BaseRobot() { fun assertStorageSelectionDialogDisplayed(composeTestRule: ComposeContentTestRule) { testFlakyView({ composeTestRule.apply { - waitForIdle() + waitUntilTimeout() onNodeWithTag(STORAGE_SELECTION_DIALOG_TITLE_TESTING_TAG) .assertTextEquals(context.getString(R.string.choose_storage_to_copy_move_zim_file)) } @@ -77,21 +75,18 @@ class CopyMoveFileHandlerRobot : BaseRobot() { } fun clickOnInternalStorage(composeTestRule: ComposeContentTestRule) { - pauseForBetterTestPerformance() testFlakyView({ - testFlakyView({ - composeTestRule.apply { - waitForIdle() - onAllNodesWithTag(STORAGE_DEVICE_ITEM_TESTING_TAG)[0].performClick() - } - }) + composeTestRule.apply { + waitUntilTimeout() + onAllNodesWithTag(STORAGE_DEVICE_ITEM_TESTING_TAG)[0].performClick() + } }) } fun clickOnCopy(composeTestRule: ComposeContentTestRule) { testFlakyView({ composeTestRule.apply { - waitForIdle() + waitUntilTimeout() onNodeWithTag(ALERT_DIALOG_CONFIRM_BUTTON_TESTING_TAG) .assertTextEquals(context.getString(R.string.action_copy).uppercase()) .performClick() @@ -121,8 +116,8 @@ class CopyMoveFileHandlerRobot : BaseRobot() { }) } - fun assertZimFileCopiedAndShowingIntoTheReader() { - pauseForBetterTestPerformance() + fun assertZimFileCopiedAndShowingIntoTheReader(composeTestRule: ComposeContentTestRule) { + composeTestRule.waitUntilTimeout() isVisible(Findable.ViewId(id.readerFragment)) testFlakyView({ Web.onWebView() @@ -143,8 +138,4 @@ class CopyMoveFileHandlerRobot : BaseRobot() { // do nothing zim file is added in the local library } } - - fun pauseForBetterTestPerformance() { - BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS_FOR_SEARCH_TEST.toLong()) - } } diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/localLibrary/CopyMoveFileHandlerTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/localLibrary/CopyMoveFileHandlerTest.kt index b801612be..bb366edfc 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/localLibrary/CopyMoveFileHandlerTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/localLibrary/CopyMoveFileHandlerTest.kt @@ -54,6 +54,7 @@ import org.kiwix.kiwixmobile.nav.destination.library.CopyMoveFileHandler import org.kiwix.kiwixmobile.nav.destination.library.local.LocalLibraryFragment import org.kiwix.kiwixmobile.testutils.RetryRule import org.kiwix.kiwixmobile.testutils.TestUtils +import org.kiwix.kiwixmobile.testutils.TestUtils.waitUntilTimeout import org.kiwix.kiwixmobile.zimManager.Fat32Checker import org.kiwix.kiwixmobile.zimManager.FileWritingFileSystemChecker import java.io.File @@ -116,7 +117,7 @@ class CopyMoveFileHandlerTest : BaseActivityTest() { kiwixMainActivity = it kiwixMainActivity.navigate(R.id.libraryFragment) } - copyMoveFileHandler(CopyMoveFileHandlerRobot::pauseForBetterTestPerformance) + composeTestRule.waitUntilTimeout() // test with first launch sharedPreferenceUtil.shouldShowStorageSelectionDialog = true showMoveFileToPublicDirectoryDialog() @@ -126,7 +127,7 @@ class CopyMoveFileHandlerTest : BaseActivityTest() { clickOnCopy(composeTestRule) assertStorageSelectionDialogDisplayed(composeTestRule) clickOnInternalStorage(composeTestRule) - assertZimFileCopiedAndShowingIntoTheReader() + assertZimFileCopiedAndShowingIntoTheReader(composeTestRule) } assertZimFileAddedInTheLocalLibrary() @@ -138,7 +139,7 @@ class CopyMoveFileHandlerTest : BaseActivityTest() { copyMoveFileHandler { assertCopyMoveDialogDisplayed(composeTestRule) clickOnCopy(composeTestRule) - assertZimFileCopiedAndShowingIntoTheReader() + assertZimFileCopiedAndShowingIntoTheReader(composeTestRule) } assertZimFileAddedInTheLocalLibrary() deleteAllFilesInDirectory(parentFile) @@ -155,7 +156,7 @@ class CopyMoveFileHandlerTest : BaseActivityTest() { kiwixMainActivity = it kiwixMainActivity.navigate(R.id.libraryFragment) } - copyMoveFileHandler(CopyMoveFileHandlerRobot::pauseForBetterTestPerformance) + composeTestRule.waitUntilTimeout() // test with first launch sharedPreferenceUtil.shouldShowStorageSelectionDialog = true showMoveFileToPublicDirectoryDialog() @@ -165,7 +166,7 @@ class CopyMoveFileHandlerTest : BaseActivityTest() { clickOnMove(composeTestRule) assertStorageSelectionDialogDisplayed(composeTestRule) clickOnInternalStorage(composeTestRule) - assertZimFileCopiedAndShowingIntoTheReader() + assertZimFileCopiedAndShowingIntoTheReader(composeTestRule) } assertZimFileAddedInTheLocalLibrary() // Test with second launch, this time permission dialog should not show. @@ -177,7 +178,7 @@ class CopyMoveFileHandlerTest : BaseActivityTest() { copyMoveFileHandler { assertCopyMoveDialogDisplayed(composeTestRule) clickOnMove(composeTestRule) - assertZimFileCopiedAndShowingIntoTheReader() + assertZimFileCopiedAndShowingIntoTheReader(composeTestRule) } assertZimFileAddedInTheLocalLibrary() kiwixMainActivity.lifecycleScope.launch { @@ -312,7 +313,7 @@ class CopyMoveFileHandlerTest : BaseActivityTest() { kiwixMainActivity = it kiwixMainActivity.navigate(R.id.libraryFragment) } - copyMoveFileHandler(CopyMoveFileHandlerRobot::pauseForBetterTestPerformance) + composeTestRule.waitUntilTimeout() sharedPreferenceUtil.apply { shouldShowStorageSelectionDialog = false setIsPlayStoreBuildType(true) diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/localLibrary/OpeningFilesFromStorageTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/localLibrary/OpeningFilesFromStorageTest.kt index 608c098c4..70d92ccfe 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/localLibrary/OpeningFilesFromStorageTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/localLibrary/OpeningFilesFromStorageTest.kt @@ -123,7 +123,7 @@ class OpeningFilesFromStorageTest : BaseActivityTest() { clickOnMove(composeTestRule) assertStorageSelectionDialogDisplayed(composeTestRule) clickOnInternalStorage(composeTestRule) - assertZimFileCopiedAndShowingIntoTheReader() + assertZimFileCopiedAndShowingIntoTheReader(composeTestRule) } } catch (ignore: Exception) { fail("Could not open file from file manager. Original exception = $ignore") @@ -153,7 +153,7 @@ class OpeningFilesFromStorageTest : BaseActivityTest() { clickOnMove(composeTestRule) assertStorageSelectionDialogDisplayed(composeTestRule) clickOnInternalStorage(composeTestRule) - assertZimFileCopiedAndShowingIntoTheReader() + assertZimFileCopiedAndShowingIntoTheReader(composeTestRule) } } catch (ignore: Exception) { fail("Could not open file from file manager. Original exception = $ignore") diff --git a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/CopyMoveFileHandler.kt b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/CopyMoveFileHandler.kt index 36f4469fd..79acfdb27 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/CopyMoveFileHandler.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/CopyMoveFileHandler.kt @@ -18,34 +18,41 @@ package org.kiwix.kiwixmobile.nav.destination.library -import android.annotation.SuppressLint import android.app.Activity import android.content.ContentResolver import android.net.Uri import android.provider.DocumentsContract -import android.widget.ProgressBar -import android.widget.TextView -import androidx.appcompat.app.AlertDialog +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.mutableStateOf +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp import androidx.core.net.toUri import androidx.documentfile.provider.DocumentFile import androidx.fragment.app.FragmentManager -import org.kiwix.kiwixmobile.storage.STORAGE_SELECT_STORAGE_TITLE_TEXTVIEW_SIZE import eu.mhutti1.utils.storage.StorageDevice -import org.kiwix.kiwixmobile.storage.StorageSelectDialog import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.Disposable import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -import org.kiwix.kiwixmobile.R.id -import org.kiwix.kiwixmobile.R.layout import org.kiwix.kiwixmobile.core.R +import org.kiwix.kiwixmobile.core.downloader.downloadManager.ZERO import org.kiwix.kiwixmobile.core.extensions.deleteFile import org.kiwix.kiwixmobile.core.extensions.isFileExist import org.kiwix.kiwixmobile.core.reader.ZimReaderSource import org.kiwix.kiwixmobile.core.settings.StorageCalculator import org.kiwix.kiwixmobile.core.ui.components.ContentLoadingProgressBar +import org.kiwix.kiwixmobile.core.ui.components.ProgressBarStyle +import org.kiwix.kiwixmobile.core.utils.ComposeDimens.EIGHT_DP +import org.kiwix.kiwixmobile.core.utils.ComposeDimens.SIXTEEN_DP import org.kiwix.kiwixmobile.core.utils.EXTERNAL_SELECT_POSITION import org.kiwix.kiwixmobile.core.utils.INTERNAL_SELECT_POSITION import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil @@ -53,6 +60,8 @@ import org.kiwix.kiwixmobile.core.utils.dialog.AlertDialogShower import org.kiwix.kiwixmobile.core.utils.dialog.KiwixDialog import org.kiwix.kiwixmobile.core.utils.files.FileUtils import org.kiwix.kiwixmobile.main.KiwixMainActivity +import org.kiwix.kiwixmobile.storage.STORAGE_SELECT_STORAGE_TITLE_TEXTVIEW_SIZE +import org.kiwix.kiwixmobile.storage.StorageSelectDialog import org.kiwix.kiwixmobile.zimManager.Fat32Checker import org.kiwix.kiwixmobile.zimManager.Fat32Checker.Companion.FOUR_GIGABYTES_IN_KILOBYTES import org.kiwix.kiwixmobile.zimManager.Fat32Checker.FileSystemState.CannotWrite4GbFile @@ -73,21 +82,27 @@ class CopyMoveFileHandler @Inject constructor( private var fileCopyMoveCallback: FileCopyMoveCallback? = null private var selectedFileUri: Uri? = null private var selectedFile: DocumentFile? = null - private var progressBarDialog: AlertDialog? = null private var lifecycleScope: CoroutineScope? = null - private var progressBar: ProgressBar? = null - private var progressBarTextView: TextView? = null + + /** + * Holds the state for the copy/move progress bar. + * + * A [Pair] containing: + * - [String]: The message to display below the progress bar. + * - [Int]: The current progress value (0 to 100). + */ + private var progressBarState = mutableStateOf(Pair("", ZERO)) var isMoveOperation = false var shouldValidateZimFile: Boolean = false private var fileSystemDisposable: Disposable? = null private lateinit var fragmentManager: FragmentManager private lateinit var alertDialogShower: AlertDialogShower - private val copyMoveTitle: String by lazy { + private val copyMoveTitle: Int by lazy { if (isMoveOperation) { - activity.getString(R.string.moving_zim_file) + R.string.moving_zim_file } else { - activity.getString(R.string.copying_zim_file) + R.string.copying_zim_file } } @@ -96,9 +111,9 @@ class CopyMoveFileHandler @Inject constructor( } private fun updateProgress(progress: Int) { - progressBar?.post { - progressBarTextView?.text = activity.getString(R.string.percentage, progress) - progressBar?.setProgress(progress, true) + synchronized(this) { + progressBarState.value = + activity.getString(R.string.percentage, progress) to progress } } @@ -388,7 +403,7 @@ class CopyMoveFileHandler @Inject constructor( errorMessage: String?, destinationFile: File ) { - dismissProgressDialog() + dismissCopyMoveProgressDialog() fileCopyMoveCallback?.onError("$errorMessage").also { // Clean up the destination file if an error occurs lifecycleScope?.launch { @@ -402,7 +417,7 @@ class CopyMoveFileHandler @Inject constructor( handleInvalidZimFile(destinationFile, sourceUri) return } - dismissProgressDialog() + dismissCopyMoveProgressDialog() if (isMoveOperation) { deleteSourceFile(sourceUri) fileCopyMoveCallback?.onFileMoved(destinationFile) @@ -425,7 +440,7 @@ class CopyMoveFileHandler @Inject constructor( if (moveSuccessful) { // If files is moved back using the documentContract then show the error message to user - dismissProgressDialog() + dismissCopyMoveProgressDialog() fileCopyMoveCallback?.onError(errorMessage) } else { // Show error message and delete the moved file if move failed. @@ -520,32 +535,37 @@ class CopyMoveFileHandler @Inject constructor( alertDialogShower.dismiss() } - @SuppressLint("InflateParams") private fun showProgressDialog() { - val dialogView = - activity.layoutInflater.inflate(layout.copy_move_progress_bar, null) - progressBar = - dialogView.findViewById(id.progressBar).apply { - isIndeterminate = false - } - progressBarTextView = - dialogView.findViewById(id.progressTextView) - val builder = AlertDialog.Builder(activity).apply { - setTitle(copyMoveTitle) - setView(dialogView) - setCancelable(false) - } - - progressBarDialog = builder.create() - progressBarDialog?.show() + progressBarState.value = + activity.getString(R.string.percentage, ZERO) to ZERO + alertDialogShower.show( + KiwixDialog.CopyMoveProgressBarDialog( + titleId = copyMoveTitle, + customViewBottomPadding = ZERO.dp, + customGetView = { CopyMoveProgressDialog() } + ) + ) } - fun dismissProgressDialog() { - if (progressBarDialog?.isShowing == true) { - progressBarDialog?.dismiss() + @Composable + private fun CopyMoveProgressDialog() { + Column(horizontalAlignment = Alignment.End, modifier = Modifier.fillMaxWidth()) { + ContentLoadingProgressBar( + progress = progressBarState.value.second, + progressBarStyle = ProgressBarStyle.HORIZONTAL + ) + Spacer(modifier = Modifier.height(EIGHT_DP)) + Text( + progressBarState.value.first, + modifier = Modifier.padding(end = SIXTEEN_DP, bottom = SIXTEEN_DP) + ) } } + fun dismissCopyMoveProgressDialog() { + hidePreparingCopyMoveDialog() + } + suspend fun getStorageDeviceList() = (activity as KiwixMainActivity).getStorageDeviceList() diff --git a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/online/OnlineLibraryScreen.kt b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/online/OnlineLibraryScreen.kt index a4ad14d3d..fe3822264 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/online/OnlineLibraryScreen.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/online/OnlineLibraryScreen.kt @@ -74,7 +74,8 @@ import org.kiwix.kiwixmobile.zimManager.libraryView.adapter.LibraryListItem import org.kiwix.kiwixmobile.zimManager.libraryView.adapter.LibraryListItem.DividerItem const val ONLINE_LIBRARY_SEARCH_VIEW_TESTING_TAG = "onlineLibrarySearchViewTestingTag" -const val ONLINE_LIBRARY_SEARCH_VIEW_CLOSE_BUTTON_TESTING_TAG = "onlineLibrarySearchViewCloseButtonTestingTag" +const val ONLINE_LIBRARY_SEARCH_VIEW_CLOSE_BUTTON_TESTING_TAG = + "onlineLibrarySearchViewCloseButtonTestingTag" const val NO_CONTENT_VIEW_TEXT_TESTING_TAG = "noContentViewTextTestingTag" const val SHOW_FETCHING_LIBRARY_LAYOUT_TESTING_TAG = "showFetchingLibraryLayoutTestingTag" diff --git a/app/src/main/res/layout/copy_move_progress_bar.xml b/app/src/main/res/layout/copy_move_progress_bar.xml deleted file mode 100644 index 295027e05..000000000 --- a/app/src/main/res/layout/copy_move_progress_bar.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - diff --git a/app/src/test/java/org/kiwix/kiwixmobile/localLibrary/CopyMoveFileHandlerTest.kt b/app/src/test/java/org/kiwix/kiwixmobile/localLibrary/CopyMoveFileHandlerTest.kt index e08ba88cc..da7267098 100644 --- a/app/src/test/java/org/kiwix/kiwixmobile/localLibrary/CopyMoveFileHandlerTest.kt +++ b/app/src/test/java/org/kiwix/kiwixmobile/localLibrary/CopyMoveFileHandlerTest.kt @@ -318,7 +318,7 @@ class CopyMoveFileHandlerTest { fileHandler.notifyFileOperationSuccess(destinationFile, sourceUri) verify { fileCopyMoveCallback.onFileMoved(destinationFile) } - verify { fileHandler.dismissProgressDialog() } + verify { fileHandler.dismissCopyMoveProgressDialog() } coVerify { fileHandler.deleteSourceFile(sourceUri) } } @@ -332,7 +332,7 @@ class CopyMoveFileHandlerTest { fileHandler.notifyFileOperationSuccess(destinationFile, sourceUri) verify { fileCopyMoveCallback.onFileCopied(destinationFile) } - verify { fileHandler.dismissProgressDialog() } + verify { fileHandler.dismissCopyMoveProgressDialog() } } @Test @@ -356,7 +356,7 @@ class CopyMoveFileHandlerTest { fileHandler.handleInvalidZimFile(destinationFile, sourceUri) - verify { fileHandler.dismissProgressDialog() } + verify { fileHandler.dismissCopyMoveProgressDialog() } verify { fileCopyMoveCallback.onError( activity.getString( diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/dialog/AlertDialogShower.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/dialog/AlertDialogShower.kt index aa8dbb4d3..b4babddd2 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/dialog/AlertDialogShower.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/dialog/AlertDialogShower.kt @@ -67,7 +67,6 @@ import org.kiwix.kiwixmobile.core.ui.theme.KiwixDialogTheme import org.kiwix.kiwixmobile.core.utils.ComposeDimens.DIALOG_BUTTONS_TEXT_SIZE import org.kiwix.kiwixmobile.core.utils.ComposeDimens.DIALOG_BUTTON_ROW_BOTTOM_PADDING import org.kiwix.kiwixmobile.core.utils.ComposeDimens.DIALOG_BUTTON_TEXT_LETTER_SPACING -import org.kiwix.kiwixmobile.core.utils.ComposeDimens.DIALOG_CUSTOM_VIEW_BOTTOM_PADDING import org.kiwix.kiwixmobile.core.utils.ComposeDimens.DIALOG_DEFAULT_PADDING_FOR_CONTENT import org.kiwix.kiwixmobile.core.utils.ComposeDimens.DIALOG_ICON_END_PADDING import org.kiwix.kiwixmobile.core.utils.ComposeDimens.DIALOG_ICON_SIZE @@ -152,7 +151,7 @@ fun ShowCustomComposeView(dialog: KiwixDialog) { modifier = Modifier .fillMaxWidth() .wrapContentHeight() - .padding(bottom = DIALOG_CUSTOM_VIEW_BOTTOM_PADDING), + .padding(bottom = dialog.customComposeViewBottomPadding), contentAlignment = Alignment.TopStart ) { it.invoke() diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/dialog/KiwixDialog.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/dialog/KiwixDialog.kt index da6a19350..c7130d72c 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/dialog/KiwixDialog.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/dialog/KiwixDialog.kt @@ -20,9 +20,11 @@ package org.kiwix.kiwixmobile.core.utils.dialog import android.app.Activity import androidx.compose.runtime.Composable +import androidx.compose.ui.unit.Dp import org.kiwix.kiwixmobile.core.R import org.kiwix.kiwixmobile.core.main.CoreMainActivity import org.kiwix.kiwixmobile.core.ui.models.IconItem +import org.kiwix.kiwixmobile.core.utils.ComposeDimens.DIALOG_CUSTOM_VIEW_BOTTOM_PADDING @Suppress("LongParameterList") sealed class KiwixDialog( @@ -33,7 +35,8 @@ sealed class KiwixDialog( val cancelable: Boolean = true, val iconItem: IconItem? = null, val neutralButtonText: Int? = null, - val customComposeView: (@Composable (() -> Unit))? = null + val customComposeView: (@Composable (() -> Unit))? = null, + val customComposeViewBottomPadding: Dp = DIALOG_CUSTOM_VIEW_BOTTOM_PADDING ) { data class DeleteZims(override val args: List) : KiwixDialog( @@ -127,6 +130,20 @@ sealed class KiwixDialog( cancelable = false ) + data class CopyMoveProgressBarDialog( + private val titleId: Int, + private val customViewBottomPadding: Dp, + private val customGetView: @Composable (() -> Unit)? + ) : KiwixDialog( + title = titleId, + message = null, + cancelable = false, + confirmButtonText = R.string.empty_string, + dismissButtonText = null, + customComposeView = customGetView, + customComposeViewBottomPadding = customViewBottomPadding + ) + data object ShowWarningAboutSplittedZimFile : KiwixDialog( R.string.verify_zim_chunk_dialog_title, R.string.verify_zim_chunks_dialog_message,