mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-08 06:42:21 -04:00
Merge pull request #4300 from kiwix/Fixes#4299
Migrated the `copy_move_progress_bar` to Jetpack Compose.
This commit is contained in:
commit
cb52d2d80a
@ -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())
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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")
|
||||
|
@ -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<ProgressBar>(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()
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Kiwix Android
|
||||
~ Copyright (c) 2024 Kiwix <android.kiwix.org>
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
~
|
||||
-->
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/progressTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/activity_horizontal_margin"
|
||||
android:paddingBottom="@dimen/activity_horizontal_margin"
|
||||
android:text="@string/copying_zim_file"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/progressBar" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/activity_horizontal_margin"
|
||||
android:max="100"
|
||||
android:progress="0"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -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(
|
||||
|
@ -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()
|
||||
|
@ -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<Any>) :
|
||||
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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user