-
-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3994 from kiwix/Fixes#3991
Fixed: Online library cannot be retrieved in the Play Store variant.
- Loading branch information
Showing
26 changed files
with
566 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
app/src/main/java/org/kiwix/kiwixmobile/zimManager/AppProgressListenerProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* 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/>. | ||
* | ||
*/ | ||
|
||
package org.kiwix.kiwixmobile.zimManager | ||
|
||
import org.kiwix.kiwixmobile.core.R | ||
import org.kiwix.kiwixmobile.core.data.remote.OnlineLibraryProgressListener | ||
import org.kiwix.kiwixmobile.core.downloader.downloadManager.DEFAULT_INT_VALUE | ||
import org.kiwix.kiwixmobile.core.downloader.downloadManager.HUNDERED | ||
import org.kiwix.kiwixmobile.core.downloader.downloadManager.ZERO | ||
|
||
class AppProgressListenerProvider( | ||
private val zimManageViewModel: ZimManageViewModel | ||
) : OnlineLibraryProgressListener { | ||
@Suppress("MagicNumber") | ||
override fun onProgress(bytesRead: Long, contentLength: Long) { | ||
val progress = | ||
if (contentLength == DEFAULT_INT_VALUE.toLong()) { | ||
ZERO | ||
} else { | ||
(bytesRead * HUNDERED / contentLength).toInt() * 3 | ||
} | ||
zimManageViewModel.downloadProgress.postValue( | ||
zimManageViewModel.context.getString( | ||
R.string.downloading_library, | ||
zimManageViewModel.context.getString(R.string.percentage, progress) | ||
) | ||
) | ||
} | ||
} |
Oops, something went wrong.