From b5f1a00a97a912f8ee3d52b49ea853b57db5ed62 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Wed, 25 Jan 2023 18:38:31 +0530 Subject: [PATCH 01/19] remove unused view argument --- .../java/foundation/e/apps/home/model/HomeChildRVAdapter.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/home/model/HomeChildRVAdapter.kt b/app/src/main/java/foundation/e/apps/home/model/HomeChildRVAdapter.kt index 5eecedc3c..89b4f57d2 100644 --- a/app/src/main/java/foundation/e/apps/home/model/HomeChildRVAdapter.kt +++ b/app/src/main/java/foundation/e/apps/home/model/HomeChildRVAdapter.kt @@ -104,10 +104,10 @@ class HomeChildRVAdapter( when (homeApp.status) { Status.INSTALLED -> { - handleInstalled(view, homeApp) + handleInstalled(homeApp) } Status.UPDATABLE -> { - handleUpdatable(view, homeApp) + handleUpdatable(homeApp) } Status.UNAVAILABLE -> { handleUnavailable(homeApp, holder) @@ -210,7 +210,6 @@ class HomeChildRVAdapter( } private fun HomeChildListItemBinding.handleUpdatable( - view: View, homeApp: FusedApp ) { installButton.apply { @@ -229,7 +228,6 @@ class HomeChildRVAdapter( } private fun HomeChildListItemBinding.handleInstalled( - view: View, homeApp: FusedApp ) { installButton.apply { -- GitLab From 735370a71cda5402fdbf72f723ee622fc7762af9 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Wed, 25 Jan 2023 18:40:11 +0530 Subject: [PATCH 02/19] replace use of view argument --- .../e/apps/home/model/HomeChildRVAdapter.kt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/home/model/HomeChildRVAdapter.kt b/app/src/main/java/foundation/e/apps/home/model/HomeChildRVAdapter.kt index 89b4f57d2..e30eb8d24 100644 --- a/app/src/main/java/foundation/e/apps/home/model/HomeChildRVAdapter.kt +++ b/app/src/main/java/foundation/e/apps/home/model/HomeChildRVAdapter.kt @@ -113,28 +113,27 @@ class HomeChildRVAdapter( handleUnavailable(homeApp, holder) } Status.QUEUED, Status.AWAITING, Status.DOWNLOADING, Status.DOWNLOADED -> { - handleQueued(view, homeApp) + handleQueued(homeApp) } Status.INSTALLING -> { handleInstalling() } Status.BLOCKED -> { - handleBlocked(view) + handleBlocked() } Status.INSTALLATION_ISSUE -> { - handleInstallationIssue(view, homeApp) + handleInstallationIssue(homeApp) } } } } private fun HomeChildListItemBinding.handleInstallationIssue( - view: View, homeApp: FusedApp ) { installButton.apply { enableInstallButton() - text = view.context.getString(R.string.retry) + text = context.getString(R.string.retry) setOnClickListener { installApplication(homeApp, appIcon) } @@ -142,7 +141,8 @@ class HomeChildRVAdapter( progressBarInstall.visibility = View.GONE } - private fun HomeChildListItemBinding.handleBlocked(view: View) { + private fun HomeChildListItemBinding.handleBlocked() { + val view = this.root installButton.enableInstallButton() installButton.setOnClickListener { val errorMsg = when (mainActivityViewModel.getUser()) { @@ -167,7 +167,6 @@ class HomeChildRVAdapter( } private fun HomeChildListItemBinding.handleQueued( - view: View, homeApp: FusedApp ) { installButton.apply { @@ -175,11 +174,11 @@ class HomeChildRVAdapter( text = context.getString(R.string.cancel) setTextColor(context.getColor(R.color.colorAccent)) backgroundTintList = ContextCompat.getColorStateList( - view.context, + context, android.R.color.transparent ) strokeColor = - ContextCompat.getColorStateList(view.context, R.color.colorAccent) + ContextCompat.getColorStateList(context, R.color.colorAccent) setOnClickListener { cancelDownload(homeApp) -- GitLab From 0b689e159281d2470ff480e00b061c212e304ff7 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Wed, 25 Jan 2023 18:41:20 +0530 Subject: [PATCH 03/19] miscellaneous lint warning fixes --- app/src/main/java/foundation/e/apps/MainActivity.kt | 3 +-- .../main/java/foundation/e/apps/api/DownloadManager.kt | 2 -- .../apps/api/cleanapk/blockedApps/BlockedAppRepository.kt | 8 ++++---- .../e/apps/applicationlist/ApplicationListFragment.kt | 2 +- .../e/apps/applicationlist/ApplicationListRVAdapter.kt | 1 + .../foundation/e/apps/home/model/HomeChildRVAdapter.kt | 1 + 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/MainActivity.kt b/app/src/main/java/foundation/e/apps/MainActivity.kt index 00b90776f..e8d578f91 100644 --- a/app/src/main/java/foundation/e/apps/MainActivity.kt +++ b/app/src/main/java/foundation/e/apps/MainActivity.kt @@ -304,8 +304,7 @@ class MainActivity : AppCompatActivity() { // TODO: move storage availability code to FileManager Class private fun isStorageAvailable(fusedDownload: FusedDownload): Boolean { - var availableSpace = 0L - availableSpace = calculateAvailableDiskSpace() + val availableSpace = calculateAvailableDiskSpace() return availableSpace > fusedDownload.appSize + (500 * (1000 * 1000)) } diff --git a/app/src/main/java/foundation/e/apps/api/DownloadManager.kt b/app/src/main/java/foundation/e/apps/api/DownloadManager.kt index 3d6f64dbf..758704399 100644 --- a/app/src/main/java/foundation/e/apps/api/DownloadManager.kt +++ b/app/src/main/java/foundation/e/apps/api/DownloadManager.kt @@ -103,8 +103,6 @@ class DownloadManager @Inject constructor( downloadManager.query(downloadManagerQuery.setFilterById(downloadId)) .use { cursor -> if (cursor.moveToFirst()) { - val id = - cursor.getLong(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_ID)) val status = cursor.getInt(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_STATUS)) val totalSizeBytes = diff --git a/app/src/main/java/foundation/e/apps/api/cleanapk/blockedApps/BlockedAppRepository.kt b/app/src/main/java/foundation/e/apps/api/cleanapk/blockedApps/BlockedAppRepository.kt index 2ab84a662..5e09583ce 100644 --- a/app/src/main/java/foundation/e/apps/api/cleanapk/blockedApps/BlockedAppRepository.kt +++ b/app/src/main/java/foundation/e/apps/api/cleanapk/blockedApps/BlockedAppRepository.kt @@ -50,15 +50,15 @@ class BlockedAppRepository @Inject constructor( fun fetchUpdateOfAppWarningList() { downloadManager.downloadFileInCache( APP_WARNING_LIST_FILE_URL, - fileName = "app-lounge-warning-list.json" - ) { success, path -> + fileName = WARNING_LIST_FILE_NAME + ) { success, _ -> if (success) { - parseBlockedAppDataFromFile(path) + parseBlockedAppDataFromFile() } } } - private fun parseBlockedAppDataFromFile(path: String) { + private fun parseBlockedAppDataFromFile() { coroutineScope.launch { val outputPath = "$cacheDir/warning_list/" FileManager.moveFile("$cacheDir/", WARNING_LIST_FILE_NAME, outputPath) diff --git a/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListFragment.kt b/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListFragment.kt index aa1bb75d1..5515d46b4 100644 --- a/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListFragment.kt +++ b/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListFragment.kt @@ -112,7 +112,7 @@ class ApplicationListFragment : recyclerView.apply { adapter = listAdapter - layoutManager = LinearLayoutManager(view?.context) + layoutManager = LinearLayoutManager(view.context) } } diff --git a/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListRVAdapter.kt b/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListRVAdapter.kt index a6daaca27..63eadb5c6 100644 --- a/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListRVAdapter.kt +++ b/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListRVAdapter.kt @@ -281,6 +281,7 @@ class ApplicationListRVAdapter( Status.INSTALLATION_ISSUE -> { handleInstallationIssue(view, searchApp) } + else -> {} } } diff --git a/app/src/main/java/foundation/e/apps/home/model/HomeChildRVAdapter.kt b/app/src/main/java/foundation/e/apps/home/model/HomeChildRVAdapter.kt index e30eb8d24..bbce856c3 100644 --- a/app/src/main/java/foundation/e/apps/home/model/HomeChildRVAdapter.kt +++ b/app/src/main/java/foundation/e/apps/home/model/HomeChildRVAdapter.kt @@ -124,6 +124,7 @@ class HomeChildRVAdapter( Status.INSTALLATION_ISSUE -> { handleInstallationIssue(homeApp) } + else -> {} } } } -- GitLab From 2c2734428cf70d6c368ece8d64cabb6b7b856200 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Wed, 25 Jan 2023 18:45:41 +0530 Subject: [PATCH 04/19] remove unused category and category type arguments --- .../main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt b/app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt index 8f29b0569..889cbb999 100644 --- a/app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt +++ b/app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt @@ -948,7 +948,7 @@ class FusedAPIImpl @Inject constructor( runCodeBlockWithTimeout({ val playResponse = gPlayAPIRepository.getCategoriesList(type, authData).map { app -> val category = app.transformToFusedCategory() - updateCategoryDrawable(category, app) + updateCategoryDrawable(category) category } categoryList.addAll(playResponse) @@ -1045,7 +1045,6 @@ class FusedAPIImpl @Inject constructor( private fun updateCategoryDrawable( category: FusedCategory, - app: Category ) { category.drawable = getCategoryIconResource(getCategoryIconName(category)) @@ -1083,7 +1082,7 @@ class FusedAPIImpl @Inject constructor( tag: AppTag ): List { return categories.apps.map { category -> - createFusedCategoryFromCategory(category, categories, Category.Type.APPLICATION, tag) + createFusedCategoryFromCategory(category, categories, tag) } } @@ -1092,14 +1091,13 @@ class FusedAPIImpl @Inject constructor( tag: AppTag ): List { return categories.games.map { category -> - createFusedCategoryFromCategory(category, categories, Category.Type.GAME, tag) + createFusedCategoryFromCategory(category, categories, tag) } } private fun createFusedCategoryFromCategory( category: String, categories: Categories, - appType: Category.Type, tag: AppTag ): FusedCategory { return FusedCategory( -- GitLab From e0b12f95afd8cd59e611bf1266b6d79ed8eeb91e Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Wed, 25 Jan 2023 19:01:25 +0530 Subject: [PATCH 05/19] fix lint warnings for @OptIn annotations --- app/build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index 23109f24a..055b62fdc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -112,6 +112,9 @@ android { lint { lintConfig file('lint.xml') } + kotlin.sourceSets.all { + languageSettings.useExperimentalAnnotation("kotlin.RequiresOptIn") + } } kapt { -- GitLab From 31607fb0e30c4be934e18598a519ad9d19ce069c Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Wed, 25 Jan 2023 19:03:42 +0530 Subject: [PATCH 06/19] remove some suggested removals --- .../main/java/foundation/e/apps/login/api/GoogleLoginApi.kt | 4 ++-- .../main/java/foundation/e/apps/manager/fused/FileManager.kt | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/login/api/GoogleLoginApi.kt b/app/src/main/java/foundation/e/apps/login/api/GoogleLoginApi.kt index 47c7bb19a..ffcc455f8 100644 --- a/app/src/main/java/foundation/e/apps/login/api/GoogleLoginApi.kt +++ b/app/src/main/java/foundation/e/apps/login/api/GoogleLoginApi.kt @@ -43,7 +43,7 @@ class GoogleLoginApi( * Issue: https://gitlab.e.foundation/e/backlog/-/issues/5680 */ suspend fun getAC2DMResponse(email: String, oauthToken: String): PlayResponse { - var response = PlayResponse() + var response: PlayResponse withContext(Dispatchers.IO) { response = aC2DMTask.getAC2DMResponse(email, oauthToken) } @@ -55,7 +55,7 @@ class GoogleLoginApi( * Issue: https://gitlab.e.foundation/e/backlog/-/issues/5680 */ override suspend fun fetchAuthData(email: String, aasToken: String): AuthData? { - var authData: AuthData? = null + var authData: AuthData? withContext(Dispatchers.IO) { authData = AuthHelper.build(email, aasToken, nativeDeviceProperty) } diff --git a/app/src/main/java/foundation/e/apps/manager/fused/FileManager.kt b/app/src/main/java/foundation/e/apps/manager/fused/FileManager.kt index 43b57cb58..209d77052 100644 --- a/app/src/main/java/foundation/e/apps/manager/fused/FileManager.kt +++ b/app/src/main/java/foundation/e/apps/manager/fused/FileManager.kt @@ -38,9 +38,7 @@ object FileManager { Timber.e(e.stackTraceToString()) } finally { inputStream?.close() - inputStream = null outputStream?.close() - outputStream = null } } } -- GitLab From 6ee46339a3b3aa64161609e8a2d89c44cf1852cf Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Wed, 25 Jan 2023 19:07:54 +0530 Subject: [PATCH 07/19] add delicate apt annotation for GlobalScope --- .../java/foundation/e/apps/manager/pkg/InstallerService.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/foundation/e/apps/manager/pkg/InstallerService.kt b/app/src/main/java/foundation/e/apps/manager/pkg/InstallerService.kt index 15543d16d..9a5f65cf8 100644 --- a/app/src/main/java/foundation/e/apps/manager/pkg/InstallerService.kt +++ b/app/src/main/java/foundation/e/apps/manager/pkg/InstallerService.kt @@ -36,6 +36,7 @@ import kotlinx.coroutines.MainScope import kotlinx.coroutines.launch import timber.log.Timber import javax.inject.Inject +import kotlinx.coroutines.DelicateCoroutinesApi @AndroidEntryPoint class InstallerService : Service() { @@ -105,6 +106,7 @@ class InstallerService : Service() { return null } + @OptIn(DelicateCoroutinesApi::class) private fun updateDownloadStatus(pkgName: String) { if (pkgName.isEmpty()) { Timber.d("updateDownloadStatus: package name should not be empty!") @@ -116,6 +118,7 @@ class InstallerService : Service() { } } + @OptIn(DelicateCoroutinesApi::class) private fun updateInstallationIssue(pkgName: String) { if (pkgName.isEmpty()) { Timber.d("updateDownloadStatus: package name should not be empty!") -- GitLab From 5c6ee644a8783ecd49161db94bfc1e43e78077ed Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Wed, 25 Jan 2023 20:15:11 +0530 Subject: [PATCH 08/19] change how keyboard is shown in search --- .../java/foundation/e/apps/search/SearchFragment.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/search/SearchFragment.kt b/app/src/main/java/foundation/e/apps/search/SearchFragment.kt index e995e3e5a..58fd4ce17 100644 --- a/app/src/main/java/foundation/e/apps/search/SearchFragment.kt +++ b/app/src/main/java/foundation/e/apps/search/SearchFragment.kt @@ -25,6 +25,7 @@ import android.os.Bundle import android.provider.BaseColumns import android.view.View import android.view.inputmethod.InputMethodManager +import android.widget.EditText import android.widget.ImageView import android.widget.LinearLayout import androidx.appcompat.app.AlertDialog @@ -430,9 +431,13 @@ class SearchFragment : } private fun showKeyboard() { - val imm = - requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager - imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY) + val imm = requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + searchView?.javaClass?.getDeclaredField("mSearchSrcTextView")?.runCatching { + isAccessible = true + get(searchView)as EditText + }?.onSuccess { + imm.showSoftInput(it, InputMethodManager.SHOW_FORCED) + } } private fun populateSuggestionsAdapter(suggestions: List?) { -- GitLab From 661f21b77eb9c951ba8f3e9292d60627d3a07449 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Wed, 25 Jan 2023 20:15:51 +0530 Subject: [PATCH 09/19] change how return works in InstallAppWorker.kt --- .../foundation/e/apps/manager/workmanager/InstallAppWorker.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/manager/workmanager/InstallAppWorker.kt b/app/src/main/java/foundation/e/apps/manager/workmanager/InstallAppWorker.kt index fd7f68da5..e3ba92e4b 100644 --- a/app/src/main/java/foundation/e/apps/manager/workmanager/InstallAppWorker.kt +++ b/app/src/main/java/foundation/e/apps/manager/workmanager/InstallAppWorker.kt @@ -106,7 +106,7 @@ class InstallAppWorker @AssistedInject constructor( packageManagerModule.isInstalled(it.packageName) if (!fusedDownload.isAppInstalling()) { - return Result.success() + return@let } setForeground( @@ -130,8 +130,8 @@ class InstallAppWorker @AssistedInject constructor( } } finally { Timber.i("doWork: RESULT SUCCESS: ${fusedDownload?.name}") - return Result.success() } + return Result.success() } private suspend fun InstallAppWorker.checkUpdateWork( -- GitLab From 114f5bd44912eba71a7608f0081291e548c206b8 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Wed, 25 Jan 2023 21:15:14 +0530 Subject: [PATCH 10/19] change deprecated PackageInfo.versionCode and use longVersionCode --- .../foundation/e/apps/splitinstall/SplitInstallBinder.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/splitinstall/SplitInstallBinder.kt b/app/src/main/java/foundation/e/apps/splitinstall/SplitInstallBinder.kt index c6df4de3c..f6783a5e5 100644 --- a/app/src/main/java/foundation/e/apps/splitinstall/SplitInstallBinder.kt +++ b/app/src/main/java/foundation/e/apps/splitinstall/SplitInstallBinder.kt @@ -19,6 +19,7 @@ package foundation.e.apps.splitinstall import android.content.Context +import androidx.core.content.pm.PackageInfoCompat import com.aurora.gplayapi.data.models.AuthData import foundation.e.apps.ISplitInstallService import foundation.e.apps.api.DownloadManager @@ -86,8 +87,9 @@ class SplitInstallBinder( } private fun getPackageVersionCode(packageName: String): Int { - val applicationInfo = context.packageManager.getPackageInfo(packageName, 0) - return applicationInfo.versionCode + val packageInfo = context.packageManager.getPackageInfo(packageName, 0) + val longVersionCode = PackageInfoCompat.getLongVersionCode(packageInfo) + return longVersionCode.toInt() } private suspend fun fetchModuleUrl( -- GitLab From 773f59fe04bd78ece538e1fa0e99572bffa189a2 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Wed, 25 Jan 2023 21:22:09 +0530 Subject: [PATCH 11/19] more miscellaneous lint warning fixes --- .../java/foundation/e/apps/home/model/HomeChildRVAdapter.kt | 1 - .../main/java/foundation/e/apps/settings/LongPressPreference.kt | 2 +- .../java/foundation/e/apps/updates/manager/UpdatesWorker.kt | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/home/model/HomeChildRVAdapter.kt b/app/src/main/java/foundation/e/apps/home/model/HomeChildRVAdapter.kt index bbce856c3..8cf88f29c 100644 --- a/app/src/main/java/foundation/e/apps/home/model/HomeChildRVAdapter.kt +++ b/app/src/main/java/foundation/e/apps/home/model/HomeChildRVAdapter.kt @@ -77,7 +77,6 @@ class HomeChildRVAdapter( } override fun onBindViewHolder(holder: ViewHolder, position: Int) { - val view = holder.itemView val homeApp = getItem(position) val shimmerDrawable = ShimmerDrawable().apply { setShimmer(shimmer) } diff --git a/app/src/main/java/foundation/e/apps/settings/LongPressPreference.kt b/app/src/main/java/foundation/e/apps/settings/LongPressPreference.kt index c25fec2df..3ef4c53c2 100644 --- a/app/src/main/java/foundation/e/apps/settings/LongPressPreference.kt +++ b/app/src/main/java/foundation/e/apps/settings/LongPressPreference.kt @@ -29,7 +29,7 @@ import androidx.preference.PreferenceViewHolder */ class LongPressPreference : Preference { - private var longClickListener: View.OnLongClickListener = View.OnLongClickListener { v -> true } + private var longClickListener: View.OnLongClickListener = View.OnLongClickListener { true } constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super( context, diff --git a/app/src/main/java/foundation/e/apps/updates/manager/UpdatesWorker.kt b/app/src/main/java/foundation/e/apps/updates/manager/UpdatesWorker.kt index 9d0bec750..979fb95dc 100644 --- a/app/src/main/java/foundation/e/apps/updates/manager/UpdatesWorker.kt +++ b/app/src/main/java/foundation/e/apps/updates/manager/UpdatesWorker.kt @@ -108,7 +108,6 @@ class UpdatesWorker @AssistedInject constructor( /* * If user in UNAVAILABLE, don't do anything. */ - resultStatus = ResultStatus.OK Timber.w("User is not available! User is required during update!") return } -- GitLab From 6f4020402a81fddd7bbd5aa5f537f0609c09eff9 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Fri, 27 Jan 2023 09:28:43 +0100 Subject: [PATCH 12/19] Make ResultSupreme nullable --- .../e/apps/applicationlist/ApplicationListFragment.kt | 6 ++++-- .../e/apps/applicationlist/ApplicationListViewModel.kt | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListFragment.kt b/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListFragment.kt index 5515d46b4..49896be4c 100644 --- a/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListFragment.kt +++ b/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListFragment.kt @@ -161,8 +161,10 @@ class ApplicationListFragment : private fun observeAppListLiveData() { viewModel.appListLiveData.observe(viewLifecycleOwner) { stopLoadingUI() - if (it.isSuccess()) { - observeDownloadList(listAdapter, it) + if (it != null) { + if (it.isSuccess()) { + observeDownloadList(listAdapter, it) + } } } } diff --git a/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListViewModel.kt b/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListViewModel.kt index d3045d919..7eb43ebe4 100644 --- a/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListViewModel.kt +++ b/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListViewModel.kt @@ -38,7 +38,7 @@ class ApplicationListViewModel @Inject constructor( private val fusedAPIRepository: FusedAPIRepository ) : LoadingViewModel() { - val appListLiveData: MutableLiveData>> = MutableLiveData() + val appListLiveData: MutableLiveData>?> = MutableLiveData() var isLoading = false @@ -118,7 +118,7 @@ class ApplicationListViewModel @Inject constructor( isLoading = true val result = fusedAPIRepository.loadMore(authData, browseUrl) isLoading = false - appListLiveData.postValue(result.first!!) + appListLiveData.postValue(result.first) /* * Check if a placeholder app is to be added at the end. * If yes then post the updated result. @@ -127,7 +127,7 @@ class ApplicationListViewModel @Inject constructor( * list, and none at the middle of the list. */ if (fusedAPIRepository.addPlaceHolderAppIfNeeded(result.first)) { - appListLiveData.postValue(result.first!!) + appListLiveData.postValue(result.first) } /* -- GitLab From 33a13b7f77fe4458acce8c9071fd1fbc4933fa50 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Mon, 30 Jan 2023 21:02:05 +0530 Subject: [PATCH 13/19] set default longClickListener to null --- .../main/java/foundation/e/apps/settings/LongPressPreference.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/foundation/e/apps/settings/LongPressPreference.kt b/app/src/main/java/foundation/e/apps/settings/LongPressPreference.kt index 3ef4c53c2..14b4b592e 100644 --- a/app/src/main/java/foundation/e/apps/settings/LongPressPreference.kt +++ b/app/src/main/java/foundation/e/apps/settings/LongPressPreference.kt @@ -29,7 +29,7 @@ import androidx.preference.PreferenceViewHolder */ class LongPressPreference : Preference { - private var longClickListener: View.OnLongClickListener = View.OnLongClickListener { true } + private var longClickListener: View.OnLongClickListener? = null constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super( context, -- GitLab From fa7f1712c3479de86bc4429bdc109ca3b4bf923e Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Mon, 30 Jan 2023 21:03:47 +0530 Subject: [PATCH 14/19] rename variable imm to inputMethodManager --- app/src/main/java/foundation/e/apps/search/SearchFragment.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/search/SearchFragment.kt b/app/src/main/java/foundation/e/apps/search/SearchFragment.kt index 58fd4ce17..f88407c97 100644 --- a/app/src/main/java/foundation/e/apps/search/SearchFragment.kt +++ b/app/src/main/java/foundation/e/apps/search/SearchFragment.kt @@ -431,12 +431,12 @@ class SearchFragment : } private fun showKeyboard() { - val imm = requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + val inputMethodManager = requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager searchView?.javaClass?.getDeclaredField("mSearchSrcTextView")?.runCatching { isAccessible = true get(searchView)as EditText }?.onSuccess { - imm.showSoftInput(it, InputMethodManager.SHOW_FORCED) + inputMethodManager.showSoftInput(it, InputMethodManager.SHOW_FORCED) } } -- GitLab From 7c14deb2d57a23f934f628649b50dd97b95be174 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Mon, 30 Jan 2023 21:14:21 +0530 Subject: [PATCH 15/19] add suggestions --- .../e/apps/applicationlist/ApplicationListFragment.kt | 6 ++---- .../e/apps/applicationlist/ApplicationListRVAdapter.kt | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListFragment.kt b/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListFragment.kt index 49896be4c..186d7b617 100644 --- a/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListFragment.kt +++ b/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListFragment.kt @@ -161,10 +161,8 @@ class ApplicationListFragment : private fun observeAppListLiveData() { viewModel.appListLiveData.observe(viewLifecycleOwner) { stopLoadingUI() - if (it != null) { - if (it.isSuccess()) { - observeDownloadList(listAdapter, it) - } + if (it != null && it.isSuccess()) { + observeDownloadList(listAdapter, it) } } } diff --git a/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListRVAdapter.kt b/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListRVAdapter.kt index 63eadb5c6..19f47e9bf 100644 --- a/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListRVAdapter.kt +++ b/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListRVAdapter.kt @@ -281,7 +281,8 @@ class ApplicationListRVAdapter( Status.INSTALLATION_ISSUE -> { handleInstallationIssue(view, searchApp) } - else -> {} + else -> { + } } } -- GitLab From 893e16424206801642e208dd040e135daa14efa9 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Fri, 3 Feb 2023 16:48:36 +0530 Subject: [PATCH 16/19] resolve preference manager editor warning --- app/src/main/java/foundation/e/apps/login/LoginDataStore.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/login/LoginDataStore.kt b/app/src/main/java/foundation/e/apps/login/LoginDataStore.kt index 30f633487..1d544a0f7 100644 --- a/app/src/main/java/foundation/e/apps/login/LoginDataStore.kt +++ b/app/src/main/java/foundation/e/apps/login/LoginDataStore.kt @@ -149,10 +149,11 @@ class LoginDataStore @Inject constructor( fun isGplaySelected() = preferenceManager.getBoolean(PREFERENCE_SHOW_GPLAY, true) fun setSource(source: String, value: Boolean) { - preferenceManager.edit().run { + val editor = preferenceManager.edit() + editor.run { this.putBoolean(source, value) - apply() } + editor.apply() } // Clear data -- GitLab From 6cc288419d2203258374503569aeea36c84cba03 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Mon, 6 Feb 2023 05:39:38 +0530 Subject: [PATCH 17/19] change drawable syntax --- app/src/main/res/layout/fragment_application.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/layout/fragment_application.xml b/app/src/main/res/layout/fragment_application.xml index 62958a2a3..e2c467ad6 100644 --- a/app/src/main/res/layout/fragment_application.xml +++ b/app/src/main/res/layout/fragment_application.xml @@ -82,7 +82,7 @@ android:layout_marginRight="10dp" android:gravity="center_vertical" android:textColor="@android:color/white" - android:drawableLeft="@drawable/ic_warning_white" + app:drawableLeftCompat="@drawable/ic_warning_white" android:drawablePadding="15dp" android:text="@string/this_app_may_not_work_properly" /> @@ -111,7 +111,7 @@ android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:gravity="center" - android:drawableEnd="@drawable/ic_warning_black" + app:drawableEndCompat="@drawable/ic_warning_black" android:drawablePadding="15dp" android:textColor="?android:textColorPrimary" android:text="@string/why_open_source_version" /> -- GitLab From 2f213c798c80a38902ced768c8480caf940e8017 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Fri, 3 Feb 2023 19:31:18 +0530 Subject: [PATCH 18/19] remove unnecessary lint check errors. --- lint.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lint.xml b/lint.xml index 1e93dd895..f272eed7c 100644 --- a/lint.xml +++ b/lint.xml @@ -10,7 +10,7 @@ - - + + -- GitLab From d4ba564f8b7a5fedb2632b7cc4c5cb75e41249a5 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Tue, 7 Feb 2023 17:16:47 +0530 Subject: [PATCH 19/19] Add timber logging for else case. --- .../e/apps/applicationlist/ApplicationListRVAdapter.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListRVAdapter.kt b/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListRVAdapter.kt index 19f47e9bf..498fa3733 100644 --- a/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListRVAdapter.kt +++ b/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListRVAdapter.kt @@ -53,6 +53,7 @@ import foundation.e.apps.utils.enums.Origin import foundation.e.apps.utils.enums.Status import foundation.e.apps.utils.enums.User import javax.inject.Singleton +import timber.log.Timber @Singleton class ApplicationListRVAdapter( @@ -282,6 +283,7 @@ class ApplicationListRVAdapter( handleInstallationIssue(view, searchApp) } else -> { + Timber.w("ApplicationListRVAdapter: Unknown status") } } } -- GitLab