From e4e123fa63ba1d802bf38dcdff3c1bfbc36c69cf Mon Sep 17 00:00:00 2001 From: Hasib Prince Date: Wed, 27 Apr 2022 14:54:30 +0600 Subject: [PATCH 1/2] App Lounge: fixed translation of categories --- .../foundation/e/apps/api/cleanapk/RetrofitModule.kt | 3 ++- .../java/foundation/e/apps/api/gplay/GPlayAPIImpl.kt | 12 ++++++++---- .../apps/applicationlist/ApplicationListViewModel.kt | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/api/cleanapk/RetrofitModule.kt b/app/src/main/java/foundation/e/apps/api/cleanapk/RetrofitModule.kt index dc95ec3bf..cd2594dac 100644 --- a/app/src/main/java/foundation/e/apps/api/cleanapk/RetrofitModule.kt +++ b/app/src/main/java/foundation/e/apps/api/cleanapk/RetrofitModule.kt @@ -41,6 +41,7 @@ import retrofit2.Retrofit import retrofit2.converter.jackson.JacksonConverterFactory import retrofit2.converter.moshi.MoshiConverterFactory import java.net.ConnectException +import java.util.Locale import javax.inject.Named import javax.inject.Singleton @@ -120,7 +121,7 @@ object RetrofitModule { builder.header( "User-Agent", "Dalvik/2.1.0 (Linux; U; Android ${Build.VERSION.RELEASE}; ${Build.FINGERPRINT})" - ) + ).header("Accept-Language", Locale.getDefault().language) try { return@Interceptor chain.proceed(builder.build()) } catch (e: ConnectException) { diff --git a/app/src/main/java/foundation/e/apps/api/gplay/GPlayAPIImpl.kt b/app/src/main/java/foundation/e/apps/api/gplay/GPlayAPIImpl.kt index 2e457e54d..3ff81c2f4 100644 --- a/app/src/main/java/foundation/e/apps/api/gplay/GPlayAPIImpl.kt +++ b/app/src/main/java/foundation/e/apps/api/gplay/GPlayAPIImpl.kt @@ -19,7 +19,13 @@ package foundation.e.apps.api.gplay import com.aurora.gplayapi.SearchSuggestEntry -import com.aurora.gplayapi.data.models.* +import com.aurora.gplayapi.data.models.App +import com.aurora.gplayapi.data.models.AuthData +import com.aurora.gplayapi.data.models.Category +import com.aurora.gplayapi.data.models.File +import com.aurora.gplayapi.data.models.SearchBundle +import com.aurora.gplayapi.data.models.StreamBundle +import com.aurora.gplayapi.data.models.StreamCluster import com.aurora.gplayapi.helpers.AppDetailsHelper import com.aurora.gplayapi.helpers.AuthValidator import com.aurora.gplayapi.helpers.CategoryHelper @@ -186,7 +192,6 @@ class GPlayAPIImpl @Inject constructor( urlList.addAll(streamClusters.map { it.clusterBrowseUrl }) nextStreamBundleUrl = streamBundle.streamNextPageUrl - } while (nextStreamBundleUrl.isNotBlank()) } } @@ -251,7 +256,7 @@ class GPlayAPIImpl @Inject constructor( * is not blank. */ streamClusters.values.forEach { streamCluster -> - list.addAll(streamCluster.clusterAppList) // Add all apps for this StreamCluster + list.addAll(streamCluster.clusterAppList) // Add all apps for this StreamCluster // Loop over possible next StreamClusters var currentStreamCluster = streamCluster @@ -265,7 +270,6 @@ class GPlayAPIImpl @Inject constructor( } nextStreamBundleUrl = streamBundle.streamNextPageUrl - } while (streamBundle.hasNext()) // TODO: DEAL WITH DUPLICATE AND LESS ITEMS 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 795fdbd97..cd710a731 100644 --- a/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListViewModel.kt +++ b/app/src/main/java/foundation/e/apps/applicationlist/ApplicationListViewModel.kt @@ -125,7 +125,7 @@ class ApplicationListViewModel @Inject constructor( val existingPackageNames = newList.map { it.package_name } newList.addAll(first.filter { it.package_name !in existingPackageNames }) appListLiveData.postValue(newList) - nextClusterUrl = second // set the next "clusterNextPageUrl" + nextClusterUrl = second // set the next "clusterNextPageUrl" } } } -- GitLab From 86c9e63ae5fed4c08e762e86ea0dc6c3555a5fa7 Mon Sep 17 00:00:00 2001 From: Hasib Prince Date: Thu, 28 Apr 2022 12:09:43 +0600 Subject: [PATCH 2/2] App Lounge: update user data on Locale change Update locale of authdata and clear cache of Httpclient on Locale change --- app/src/main/AndroidManifest.xml | 6 ++ .../e/apps/api/gplay/GPlayAPIImpl.kt | 6 +- .../signin/LocaleChangedBroadcastReceiver.kt | 58 +++++++++++++++++++ 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/foundation/e/apps/setup/signin/LocaleChangedBroadcastReceiver.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c9eae0e24..78fba17b6 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -82,6 +82,12 @@ + + + + + + . + */ + +package foundation.e.apps.setup.signin + +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import com.aurora.gplayapi.data.models.AuthData +import com.google.gson.Gson +import dagger.hilt.android.AndroidEntryPoint +import foundation.e.apps.utils.modules.DataStoreModule +import kotlinx.coroutines.DelicateCoroutinesApi +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext +import okhttp3.Cache +import javax.inject.Inject + +@AndroidEntryPoint +@DelicateCoroutinesApi +class LocaleChangedBroadcastReceiver : BroadcastReceiver() { + + @Inject + lateinit var dataStoreModule: DataStoreModule + @Inject + lateinit var gson: Gson + @Inject + lateinit var cache: Cache + + override fun onReceive(context: Context, intent: Intent) { + GlobalScope.launch { + val authDataJson = dataStoreModule.getAuthDataSync() + val authData = gson.fromJson(authDataJson, AuthData::class.java) + authData.locale = context.resources.configuration.locales[0] + dataStoreModule.saveCredentials(authData) + withContext(Dispatchers.IO) { + cache.evictAll() + } + } + } +} -- GitLab