Loading app/src/main/java/foundation/e/apps/data/gplay/GplayStoreRepositoryImpl.kt +18 −2 Original line number Diff line number Diff line Loading @@ -52,11 +52,10 @@ class GplayStoreRepositoryImpl @Inject constructor( private val loginSourceRepository: LoginSourceRepository ) : GplayStoreRepository { private val authData by lazy { loginSourceRepository.gplayAuth!! } override suspend fun getHomeScreenData(): Any { val homeScreenData = mutableMapOf<String, List<App>>() val homeElements = createTopChartElements() val authData = loginSourceRepository.gplayAuth ?: return homeScreenData homeElements.forEach { val chart = it.value.keys.iterator().next() Loading @@ -81,10 +80,13 @@ class GplayStoreRepositoryImpl @Inject constructor( query: String, ): Flow<Pair<List<App>, Boolean>> { return flow { /* * Variable names and logic made same as that of Aurora store. * Issue: https://gitlab.e.foundation/e/backlog/-/issues/5171 */ var authData = loginSourceRepository.gplayAuth ?: return@flow val searchHelper = SearchHelper(authData).using(gPlayHttpClient) val searchBundle = searchHelper.searchResults(query) Loading Loading @@ -148,6 +150,8 @@ class GplayStoreRepositoryImpl @Inject constructor( } override suspend fun getSearchSuggestions(query: String): List<SearchSuggestEntry> { val authData = loginSourceRepository.gplayAuth ?: return listOf() val searchData = mutableListOf<SearchSuggestEntry>() withContext(Dispatchers.IO) { val searchHelper = SearchHelper(authData).using(gPlayHttpClient) Loading @@ -157,6 +161,8 @@ class GplayStoreRepositoryImpl @Inject constructor( } override suspend fun getAppsByCategory(category: String, pageUrl: String?): StreamCluster { val authData = loginSourceRepository.gplayAuth ?: return StreamCluster() val subCategoryHelper = CategoryAppsHelper(authData).using(gPlayHttpClient) Loading @@ -173,6 +179,8 @@ class GplayStoreRepositoryImpl @Inject constructor( return categoryList } val authData = loginSourceRepository.gplayAuth ?: return categoryList withContext(Dispatchers.IO) { val categoryHelper = CategoryHelper(authData).using(gPlayHttpClient) categoryList.addAll(categoryHelper.getAllCategoriesList(getCategoryType(type))) Loading @@ -182,6 +190,8 @@ class GplayStoreRepositoryImpl @Inject constructor( override suspend fun getAppDetails(packageNameOrId: String): App? { var appDetails: App? val authData = loginSourceRepository.gplayAuth ?: return null withContext(Dispatchers.IO) { val appDetailsHelper = AppDetailsHelper(authData).using(gPlayHttpClient) appDetails = appDetailsHelper.getAppByPackageName(packageNameOrId) Loading @@ -191,6 +201,8 @@ class GplayStoreRepositoryImpl @Inject constructor( override suspend fun getAppsDetails(packageNamesOrIds: List<String>): List<App> { val appDetailsList = mutableListOf<App>() val authData = loginSourceRepository.gplayAuth ?: return appDetailsList withContext(Dispatchers.IO) { val appDetailsHelper = AppDetailsHelper(authData).using(gPlayHttpClient) appDetailsList.addAll(appDetailsHelper.getAppByPackageName(packageNamesOrIds)) Loading Loading @@ -267,6 +279,8 @@ class GplayStoreRepositoryImpl @Inject constructor( offerType: Int ): List<File> { val downloadData = mutableListOf<File>() val authData = loginSourceRepository.gplayAuth ?: return downloadData withContext(Dispatchers.IO) { val version = versionCode?.let { it as Int } ?: -1 val purchaseHelper = PurchaseHelper(authData).using(gPlayHttpClient) Loading @@ -282,6 +296,8 @@ class GplayStoreRepositoryImpl @Inject constructor( offerType: Int ): List<File> { val downloadData = mutableListOf<File>() val authData = loginSourceRepository.gplayAuth ?: return downloadData withContext(Dispatchers.IO) { val purchaseHelper = PurchaseHelper(authData).using(gPlayHttpClient) downloadData.addAll( Loading app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt +17 −3 Original line number Diff line number Diff line Loading @@ -118,7 +118,10 @@ class SearchFragment : authObjects.observe(viewLifecycleOwner) { val currentQuery = searchView?.query?.toString() ?: "" if (it == null || (currentQuery.isNotEmpty() && lastSearch == currentQuery)) return@observe if (it == null || shouldIgnore(it, currentQuery)) { return@observe } loadDataWhenNetworkAvailable(it) } Loading @@ -127,6 +130,16 @@ class SearchFragment : } } private fun shouldIgnore( authObjectList: List<AuthObject>?, currentQuery: String ) = ( currentQuery.isNotEmpty() && searchViewModel.isAuthObjectListSame( authObjectList ) && lastSearch == currentQuery ) private fun observeSearchResult(listAdapter: ApplicationListRVAdapter?) { searchViewModel.searchResult.observe(viewLifecycleOwner) { if (it.data?.first.isNullOrEmpty() && it.data?.second == false) { Loading Loading @@ -427,7 +440,8 @@ class SearchFragment : } private fun showKeyboard() { val inputMethodManager = 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 Loading app/src/main/java/foundation/e/apps/ui/search/SearchViewModel.kt +6 −2 Original line number Diff line number Diff line Loading @@ -47,6 +47,8 @@ class SearchViewModel @Inject constructor( private var searchResultLiveData: LiveData<ResultSupreme<Pair<List<FusedApp>, Boolean>>> = MutableLiveData() private var lastAuthObjects: List<AuthObject>? = null fun getSearchSuggestions(query: String, gPlayAuth: AuthObject.GPlayAuth) { viewModelScope.launch(Dispatchers.IO) { if (gPlayAuth.result.isSuccess()) Loading @@ -68,6 +70,7 @@ class SearchViewModel @Inject constructor( if (query.isBlank()) return this.lastAuthObjects = authObjectList super.onLoadData(authObjectList, { successAuthList, _ -> successAuthList.find { it is AuthObject.GPlayAuth }?.run { Loading Loading @@ -124,6 +127,7 @@ class SearchViewModel @Inject constructor( oldFusedApps: List<FusedApp> ) = fusedAPIRepository.isAnyFusedAppUpdated(newFusedApps, oldFusedApps) fun hasAnyAppInstallStatusChanged(currentList: List<FusedApp>) = fusedAPIRepository.isAnyAppInstallStatusChanged(currentList) fun isAuthObjectListSame(authObjectList: List<AuthObject>?): Boolean { return lastAuthObjects == authObjectList } } Loading
app/src/main/java/foundation/e/apps/data/gplay/GplayStoreRepositoryImpl.kt +18 −2 Original line number Diff line number Diff line Loading @@ -52,11 +52,10 @@ class GplayStoreRepositoryImpl @Inject constructor( private val loginSourceRepository: LoginSourceRepository ) : GplayStoreRepository { private val authData by lazy { loginSourceRepository.gplayAuth!! } override suspend fun getHomeScreenData(): Any { val homeScreenData = mutableMapOf<String, List<App>>() val homeElements = createTopChartElements() val authData = loginSourceRepository.gplayAuth ?: return homeScreenData homeElements.forEach { val chart = it.value.keys.iterator().next() Loading @@ -81,10 +80,13 @@ class GplayStoreRepositoryImpl @Inject constructor( query: String, ): Flow<Pair<List<App>, Boolean>> { return flow { /* * Variable names and logic made same as that of Aurora store. * Issue: https://gitlab.e.foundation/e/backlog/-/issues/5171 */ var authData = loginSourceRepository.gplayAuth ?: return@flow val searchHelper = SearchHelper(authData).using(gPlayHttpClient) val searchBundle = searchHelper.searchResults(query) Loading Loading @@ -148,6 +150,8 @@ class GplayStoreRepositoryImpl @Inject constructor( } override suspend fun getSearchSuggestions(query: String): List<SearchSuggestEntry> { val authData = loginSourceRepository.gplayAuth ?: return listOf() val searchData = mutableListOf<SearchSuggestEntry>() withContext(Dispatchers.IO) { val searchHelper = SearchHelper(authData).using(gPlayHttpClient) Loading @@ -157,6 +161,8 @@ class GplayStoreRepositoryImpl @Inject constructor( } override suspend fun getAppsByCategory(category: String, pageUrl: String?): StreamCluster { val authData = loginSourceRepository.gplayAuth ?: return StreamCluster() val subCategoryHelper = CategoryAppsHelper(authData).using(gPlayHttpClient) Loading @@ -173,6 +179,8 @@ class GplayStoreRepositoryImpl @Inject constructor( return categoryList } val authData = loginSourceRepository.gplayAuth ?: return categoryList withContext(Dispatchers.IO) { val categoryHelper = CategoryHelper(authData).using(gPlayHttpClient) categoryList.addAll(categoryHelper.getAllCategoriesList(getCategoryType(type))) Loading @@ -182,6 +190,8 @@ class GplayStoreRepositoryImpl @Inject constructor( override suspend fun getAppDetails(packageNameOrId: String): App? { var appDetails: App? val authData = loginSourceRepository.gplayAuth ?: return null withContext(Dispatchers.IO) { val appDetailsHelper = AppDetailsHelper(authData).using(gPlayHttpClient) appDetails = appDetailsHelper.getAppByPackageName(packageNameOrId) Loading @@ -191,6 +201,8 @@ class GplayStoreRepositoryImpl @Inject constructor( override suspend fun getAppsDetails(packageNamesOrIds: List<String>): List<App> { val appDetailsList = mutableListOf<App>() val authData = loginSourceRepository.gplayAuth ?: return appDetailsList withContext(Dispatchers.IO) { val appDetailsHelper = AppDetailsHelper(authData).using(gPlayHttpClient) appDetailsList.addAll(appDetailsHelper.getAppByPackageName(packageNamesOrIds)) Loading Loading @@ -267,6 +279,8 @@ class GplayStoreRepositoryImpl @Inject constructor( offerType: Int ): List<File> { val downloadData = mutableListOf<File>() val authData = loginSourceRepository.gplayAuth ?: return downloadData withContext(Dispatchers.IO) { val version = versionCode?.let { it as Int } ?: -1 val purchaseHelper = PurchaseHelper(authData).using(gPlayHttpClient) Loading @@ -282,6 +296,8 @@ class GplayStoreRepositoryImpl @Inject constructor( offerType: Int ): List<File> { val downloadData = mutableListOf<File>() val authData = loginSourceRepository.gplayAuth ?: return downloadData withContext(Dispatchers.IO) { val purchaseHelper = PurchaseHelper(authData).using(gPlayHttpClient) downloadData.addAll( Loading
app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt +17 −3 Original line number Diff line number Diff line Loading @@ -118,7 +118,10 @@ class SearchFragment : authObjects.observe(viewLifecycleOwner) { val currentQuery = searchView?.query?.toString() ?: "" if (it == null || (currentQuery.isNotEmpty() && lastSearch == currentQuery)) return@observe if (it == null || shouldIgnore(it, currentQuery)) { return@observe } loadDataWhenNetworkAvailable(it) } Loading @@ -127,6 +130,16 @@ class SearchFragment : } } private fun shouldIgnore( authObjectList: List<AuthObject>?, currentQuery: String ) = ( currentQuery.isNotEmpty() && searchViewModel.isAuthObjectListSame( authObjectList ) && lastSearch == currentQuery ) private fun observeSearchResult(listAdapter: ApplicationListRVAdapter?) { searchViewModel.searchResult.observe(viewLifecycleOwner) { if (it.data?.first.isNullOrEmpty() && it.data?.second == false) { Loading Loading @@ -427,7 +440,8 @@ class SearchFragment : } private fun showKeyboard() { val inputMethodManager = 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 Loading
app/src/main/java/foundation/e/apps/ui/search/SearchViewModel.kt +6 −2 Original line number Diff line number Diff line Loading @@ -47,6 +47,8 @@ class SearchViewModel @Inject constructor( private var searchResultLiveData: LiveData<ResultSupreme<Pair<List<FusedApp>, Boolean>>> = MutableLiveData() private var lastAuthObjects: List<AuthObject>? = null fun getSearchSuggestions(query: String, gPlayAuth: AuthObject.GPlayAuth) { viewModelScope.launch(Dispatchers.IO) { if (gPlayAuth.result.isSuccess()) Loading @@ -68,6 +70,7 @@ class SearchViewModel @Inject constructor( if (query.isBlank()) return this.lastAuthObjects = authObjectList super.onLoadData(authObjectList, { successAuthList, _ -> successAuthList.find { it is AuthObject.GPlayAuth }?.run { Loading Loading @@ -124,6 +127,7 @@ class SearchViewModel @Inject constructor( oldFusedApps: List<FusedApp> ) = fusedAPIRepository.isAnyFusedAppUpdated(newFusedApps, oldFusedApps) fun hasAnyAppInstallStatusChanged(currentList: List<FusedApp>) = fusedAPIRepository.isAnyAppInstallStatusChanged(currentList) fun isAuthObjectListSame(authObjectList: List<AuthObject>?): Boolean { return lastAuthObjects == authObjectList } }