Loading app/src/main/java/foundation/e/apps/data/DownloadManager.kt +10 −2 Original line number Diff line number Diff line Loading @@ -173,8 +173,16 @@ class DownloadManager @Inject constructor( } } fun isDownloadSuccessful(downloadId: Long): Boolean { return getDownloadStatus(downloadId) == DownloadManager.STATUS_SUCCESSFUL /** * Checks download is successful or not. * @param downloadId is the id of a particular download request * @return Pair<Boolean, Int>, Where first represents success/failure, * second represents status. */ fun isDownloadSuccessful(downloadId: Long): Pair<Boolean, Int> { val downloadStatus = getDownloadStatus(downloadId) val isSuccessFul = downloadStatus == DownloadManager.STATUS_SUCCESSFUL return Pair(isSuccessFul, downloadStatus) } fun hasDownloadFailed(downloadId: Long): Boolean { Loading app/src/main/java/foundation/e/apps/data/cleanapk/RetrofitModule.kt +2 −21 Original line number Diff line number Diff line Loading @@ -169,28 +169,9 @@ object RetrofitModule { "User-Agent", "Dalvik/2.1.0 (Linux; U; Android ${Build.VERSION.RELEASE};)" ).header("Accept-Language", Locale.getDefault().language) try { return@Interceptor chain.proceed(builder.build()) } catch (e: ConnectException) { return@Interceptor buildErrorResponse(e, chain) } catch (e: Exception) { return@Interceptor buildErrorResponse(e, chain) } } } private fun buildErrorResponse( e: Exception, chain: Interceptor.Chain ): Response { Timber.e("buildErrorResponse: ${e.localizedMessage}") return Response.Builder() .code(999) .message(e.localizedMessage ?: "Unknown error") .request(chain.request()) .protocol(Protocol.HTTP_1_1) .body("{}".toResponseBody("application/json; charset=utf-8".toMediaTypeOrNull())) .build() } @Singleton Loading app/src/main/java/foundation/e/apps/install/download/DownloadManagerUtils.kt +12 −3 Original line number Diff line number Diff line Loading @@ -106,10 +106,19 @@ class DownloadManagerUtils @Inject constructor( numberOfDownloadedItems: Int, fusedDownload: FusedDownload, downloadId: Long ) = downloadManager.isDownloadSuccessful(downloadId) && areAllFilesDownloaded( ): Boolean { val isDownloadSuccessful = downloadManager.isDownloadSuccessful(downloadId) // if download status code is unknown (-1), consider installation is failed. if (isDownloadSuccessful.second == -1) { handleDownloadFailed(fusedDownload, downloadId) } return isDownloadSuccessful.first && areAllFilesDownloaded( numberOfDownloadedItems, fusedDownload ) && checkCleanApkSignatureOK(fusedDownload) } private fun areAllFilesDownloaded( numberOfDownloadedItems: Int, fusedDownload: FusedDownload Loading app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListRVAdapter.kt +3 −5 Original line number Diff line number Diff line Loading @@ -519,11 +519,9 @@ class ApplicationListRVAdapter( if (searchApp.is_pwa) { mainActivityViewModel.launchPwa(searchApp) } else { context.startActivity( mainActivityViewModel.getLaunchIntentForPackageName( searchApp.package_name ) ) mainActivityViewModel.getLaunchIntentForPackageName(searchApp.package_name)?.let { context.startActivity(it) } } } } Loading app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt +3 −2 Original line number Diff line number Diff line Loading @@ -204,8 +204,9 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), ApplicationInstall viewHolder?.let { parentViewHolder -> val childRV = (parentViewHolder as HomeParentRVAdapter.ViewHolder).binding.childRV val adapter = childRV.adapter as HomeChildRVAdapter findDownloadingItemsToShowProgress(adapter, downloadProgress, childRV) (childRV.adapter as HomeChildRVAdapter?)?.let { findDownloadingItemsToShowProgress(it, downloadProgress, childRV) } } } } Loading Loading
app/src/main/java/foundation/e/apps/data/DownloadManager.kt +10 −2 Original line number Diff line number Diff line Loading @@ -173,8 +173,16 @@ class DownloadManager @Inject constructor( } } fun isDownloadSuccessful(downloadId: Long): Boolean { return getDownloadStatus(downloadId) == DownloadManager.STATUS_SUCCESSFUL /** * Checks download is successful or not. * @param downloadId is the id of a particular download request * @return Pair<Boolean, Int>, Where first represents success/failure, * second represents status. */ fun isDownloadSuccessful(downloadId: Long): Pair<Boolean, Int> { val downloadStatus = getDownloadStatus(downloadId) val isSuccessFul = downloadStatus == DownloadManager.STATUS_SUCCESSFUL return Pair(isSuccessFul, downloadStatus) } fun hasDownloadFailed(downloadId: Long): Boolean { Loading
app/src/main/java/foundation/e/apps/data/cleanapk/RetrofitModule.kt +2 −21 Original line number Diff line number Diff line Loading @@ -169,28 +169,9 @@ object RetrofitModule { "User-Agent", "Dalvik/2.1.0 (Linux; U; Android ${Build.VERSION.RELEASE};)" ).header("Accept-Language", Locale.getDefault().language) try { return@Interceptor chain.proceed(builder.build()) } catch (e: ConnectException) { return@Interceptor buildErrorResponse(e, chain) } catch (e: Exception) { return@Interceptor buildErrorResponse(e, chain) } } } private fun buildErrorResponse( e: Exception, chain: Interceptor.Chain ): Response { Timber.e("buildErrorResponse: ${e.localizedMessage}") return Response.Builder() .code(999) .message(e.localizedMessage ?: "Unknown error") .request(chain.request()) .protocol(Protocol.HTTP_1_1) .body("{}".toResponseBody("application/json; charset=utf-8".toMediaTypeOrNull())) .build() } @Singleton Loading
app/src/main/java/foundation/e/apps/install/download/DownloadManagerUtils.kt +12 −3 Original line number Diff line number Diff line Loading @@ -106,10 +106,19 @@ class DownloadManagerUtils @Inject constructor( numberOfDownloadedItems: Int, fusedDownload: FusedDownload, downloadId: Long ) = downloadManager.isDownloadSuccessful(downloadId) && areAllFilesDownloaded( ): Boolean { val isDownloadSuccessful = downloadManager.isDownloadSuccessful(downloadId) // if download status code is unknown (-1), consider installation is failed. if (isDownloadSuccessful.second == -1) { handleDownloadFailed(fusedDownload, downloadId) } return isDownloadSuccessful.first && areAllFilesDownloaded( numberOfDownloadedItems, fusedDownload ) && checkCleanApkSignatureOK(fusedDownload) } private fun areAllFilesDownloaded( numberOfDownloadedItems: Int, fusedDownload: FusedDownload Loading
app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListRVAdapter.kt +3 −5 Original line number Diff line number Diff line Loading @@ -519,11 +519,9 @@ class ApplicationListRVAdapter( if (searchApp.is_pwa) { mainActivityViewModel.launchPwa(searchApp) } else { context.startActivity( mainActivityViewModel.getLaunchIntentForPackageName( searchApp.package_name ) ) mainActivityViewModel.getLaunchIntentForPackageName(searchApp.package_name)?.let { context.startActivity(it) } } } } Loading
app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt +3 −2 Original line number Diff line number Diff line Loading @@ -204,8 +204,9 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), ApplicationInstall viewHolder?.let { parentViewHolder -> val childRV = (parentViewHolder as HomeParentRVAdapter.ViewHolder).binding.childRV val adapter = childRV.adapter as HomeChildRVAdapter findDownloadingItemsToShowProgress(adapter, downloadProgress, childRV) (childRV.adapter as HomeChildRVAdapter?)?.let { findDownloadingItemsToShowProgress(it, downloadProgress, childRV) } } } } Loading