diff --git a/app/build.gradle b/app/build.gradle index 23109f24ad6d5897ebb05b676369ee947515ecb8..055b62fdc9581984aa266d5cd1d3af12c88a1d5e 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 { diff --git a/app/src/main/java/foundation/e/apps/MainActivity.kt b/app/src/main/java/foundation/e/apps/MainActivity.kt index 00b90776ff133b380fdeb83d82b4f4b81cd804d9..e8d578f918e2004ba57aa52ec7dafeb1457a2756 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 3d6f64dbfc2f703494c72708bc100098a7724122..75870439992ae8ee39d75f0e16f9adf4d746b3f1 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 2ab84a6627a323acc8fb6d44064965b354a6f79f..5e09583cebe950a3a4e98303cf626f57d35b5be6 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/api/fused/FusedAPIImpl.kt b/app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt index 8f29b05690534647a83f25520b215ef1ff4ccfbf..889cbb9993a6a285b02b47e9e803dc5b37bbde12 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( 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 aa1bb75d10a2cccd99c8903fb5ebfdc49f8ad48f..186d7b61753beaba5f3370b54747f5759d65c411 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) } } @@ -161,7 +161,7 @@ class ApplicationListFragment : private fun observeAppListLiveData() { viewModel.appListLiveData.observe(viewLifecycleOwner) { stopLoadingUI() - if (it.isSuccess()) { + 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 a6daaca27c4c5edd6ae1787ff4efc49004004fda..498fa3733fa349e95b3225218f2bc80125252681 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( @@ -281,6 +282,9 @@ class ApplicationListRVAdapter( Status.INSTALLATION_ISSUE -> { handleInstallationIssue(view, searchApp) } + else -> { + Timber.w("ApplicationListRVAdapter: Unknown status") + } } } 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 d3045d9194241b0df69d6f406d0dcaa4af786a89..7eb43ebe43d0db663822cf4c83dabf389600fc19 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) } /* 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 5eecedc3cf95959316df22ee443923b9d6a98d52..8cf88f29c8abbfc77bc74264db8f92b46f239a5f 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) } @@ -104,37 +103,37 @@ class HomeChildRVAdapter( when (homeApp.status) { Status.INSTALLED -> { - handleInstalled(view, homeApp) + handleInstalled(homeApp) } Status.UPDATABLE -> { - handleUpdatable(view, homeApp) + handleUpdatable(homeApp) } Status.UNAVAILABLE -> { 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) } + else -> {} } } } 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) @@ -210,7 +209,6 @@ class HomeChildRVAdapter( } private fun HomeChildListItemBinding.handleUpdatable( - view: View, homeApp: FusedApp ) { installButton.apply { @@ -229,7 +227,6 @@ class HomeChildRVAdapter( } private fun HomeChildListItemBinding.handleInstalled( - view: View, homeApp: FusedApp ) { installButton.apply { 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 30f633487c9ae45aa8edb612e41f37db3985ec93..1d544a0f71d010f21b4432931fb55cceed47304a 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 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 47c7bb19adc31fc3f572dd97c4f11b88e38cbcf3..ffcc455f8f20b36cddc29dcea2a691c700be8e99 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 43b57cb58af3d542fab13f0a4f1b3e5148ecb6e4..209d770523bb65dc869f2945c78861517ec039cb 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 } } } 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 15543d16d609736f6304fc915195a437a9cc9afa..9a5f65cf8f8e50c667cc1a0a7c2428b1d604494e 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!") 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 fd7f68da56426aa375c95de4a5061e1f3abf75e6..e3ba92e4bbee7eb4c48fbbb35cc5170728cda084 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( 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 e995e3e5a31705ddd8fac0ddf73dbed83955a04f..f88407c97fbb7935be3b114c93fc5faebef9d5de 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 inputMethodManager = requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + searchView?.javaClass?.getDeclaredField("mSearchSrcTextView")?.runCatching { + isAccessible = true + get(searchView)as EditText + }?.onSuccess { + inputMethodManager.showSoftInput(it, InputMethodManager.SHOW_FORCED) + } } private fun populateSuggestionsAdapter(suggestions: List?) { 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 c25fec2dfe3032310cce63fbde6484da457f82a9..14b4b592e57e74fd3a33ba81c5d910fc571efce7 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? = null constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super( context, 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 c6df4de3cce3f38566ce0e05a79549cd80eb914b..f6783a5e584b7a1701c677020d23885bbaf27fdb 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( 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 9d0bec750c9d74fb53de052dcf5684db0a29b924..979fb95dc4af93dd2bfba3cebc95eff98ffa0367 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 } diff --git a/app/src/main/res/layout/fragment_application.xml b/app/src/main/res/layout/fragment_application.xml index 62958a2a393623ae3426cf99da30b138ada0be89..e2c467ad64da72ed1cd9722f0b6fbe699d83abc5 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" /> diff --git a/lint.xml b/lint.xml index 1e93dd895f77bdac7f5ca649d0510401cb9fac2a..f272eed7caede752c3c7423ddb67b1f164870b33 100644 --- a/lint.xml +++ b/lint.xml @@ -10,7 +10,7 @@ - - + +