Loading app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt +80 −75 Original line number Diff line number Diff line Loading @@ -143,23 +143,28 @@ class FusedAPIImpl @Inject constructor( * To prevent waiting so long and fail early, use withTimeout{}. */ withTimeout(timeoutDurationInMillis) { if (applicationType != APP_TYPE_ANY) { val response = if (applicationType == APP_TYPE_OPEN) { cleanAPKRepository.getHomeScreenData( if (preferenceManagerModule.isGplaySelected()) { list.addAll(fetchGPlayHome(authData)) } if (preferenceManagerModule.isOpenSourceSelected()) { val response = cleanAPKRepository.getHomeScreenData( CleanAPKInterface.APP_TYPE_ANY, CleanAPKInterface.APP_SOURCE_FOSS ).body() } else { cleanAPKRepository.getHomeScreenData( response?.home?.let { list.addAll(generateCleanAPKHome(it, applicationType)) } } if (preferenceManagerModule.isPWASelected()) { val response = cleanAPKRepository.getHomeScreenData( CleanAPKInterface.APP_TYPE_PWA, CleanAPKInterface.APP_SOURCE_ANY ).body() } response?.home?.let { list.addAll(generateCleanAPKHome(it, applicationType)) } } else { list.addAll(fetchGPlayHome(authData)) } } } catch (e: TimeoutCancellationException) { Loading Loading @@ -190,20 +195,12 @@ class FusedAPIImpl @Inject constructor( var apiStatus: ResultStatus = ResultStatus.OK var applicationCategoryType = preferredApplicationType if (preferredApplicationType != APP_TYPE_ANY) { handleCleanApkCategories(preferredApplicationType, categoriesList, type).run { if (this != ResultStatus.OK) { apiStatus = this } } } else { handleAllSourcesCategories(categoriesList, type, authData).run { if (first != ResultStatus.OK) { apiStatus = first applicationCategoryType = second } } } categoriesList.sortBy { item -> item.title.lowercase() } return Triple(categoriesList, applicationCategoryType, apiStatus) } Loading Loading @@ -803,6 +800,7 @@ class FusedAPIImpl @Inject constructor( var apiStatus = ResultStatus.OK var errorApplicationCategory = "" if (preferenceManagerModule.isOpenSourceSelected()) { /* * Try within timeout limit for open source native apps categories. */ Loading @@ -824,6 +822,9 @@ class FusedAPIImpl @Inject constructor( errorApplicationCategory = APP_TYPE_OPEN apiStatus = ResultStatus.UNKNOWN }) } if (preferenceManagerModule.isPWASelected()) { /* * Try within timeout limit to get PWA categories Loading @@ -844,6 +845,9 @@ class FusedAPIImpl @Inject constructor( errorApplicationCategory = APP_TYPE_PWA apiStatus = ResultStatus.UNKNOWN }) } if (preferenceManagerModule.isGplaySelected()) { /* * Try within timeout limit to get native app categories from Play Store Loading @@ -862,6 +866,7 @@ class FusedAPIImpl @Inject constructor( errorApplicationCategory = APP_TYPE_ANY apiStatus = ResultStatus.UNKNOWN }) } return Pair(apiStatus, errorApplicationCategory) } Loading app/src/main/java/foundation/e/apps/settings/SettingsFragment.kt +10 −9 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.widget.Toast import androidx.fragment.app.viewModels import androidx.navigation.findNavController import androidx.navigation.fragment.findNavController import androidx.preference.CheckBoxPreference import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat import androidx.work.ExistingPeriodicWorkPolicy Loading Loading @@ -69,9 +70,9 @@ class SettingsFragment : PreferenceFragmentCompat() { setPreferencesFromResource(R.xml.settings_preferences, rootKey) // Show applications preferences val showAllApplications = findPreference<RadioButtonPreference>("showAllApplications") val showFOSSApplications = findPreference<RadioButtonPreference>("showFOSSApplications") val showPWAApplications = findPreference<RadioButtonPreference>("showPWAApplications") val showAllApplications = findPreference<CheckBoxPreference>("showAllApplications") val showFOSSApplications = findPreference<CheckBoxPreference>("showFOSSApplications") val showPWAApplications = findPreference<CheckBoxPreference>("showPWAApplications") val updateCheckInterval = preferenceManager.findPreference<Preference>(getString(R.string.update_check_intervals)) Loading @@ -88,22 +89,22 @@ class SettingsFragment : PreferenceFragmentCompat() { } showAllApplications?.setOnPreferenceChangeListener { _, _ -> showFOSSApplications?.isChecked = false showPWAApplications?.isChecked = false // showFOSSApplications?.isChecked = false // showPWAApplications?.isChecked = false backToMainActivity() true } showFOSSApplications?.setOnPreferenceChangeListener { _, _ -> showAllApplications?.isChecked = false showPWAApplications?.isChecked = false // showAllApplications?.isChecked = false // showPWAApplications?.isChecked = false backToMainActivity() true } showPWAApplications?.setOnPreferenceChangeListener { _, _ -> showFOSSApplications?.isChecked = false showAllApplications?.isChecked = false // showFOSSApplications?.isChecked = false // showAllApplications?.isChecked = false backToMainActivity() true } Loading app/src/main/java/foundation/e/apps/utils/modules/PreferenceManagerModule.kt +4 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,10 @@ class PreferenceManagerModule @Inject constructor( } } fun isOpenSourceSelected() = preferenceManager.getBoolean("showFOSSApplications", false) fun isPWASelected() = preferenceManager.getBoolean("showPWAApplications", false) fun isGplaySelected() = preferenceManager.getBoolean("showAllApplications", false) fun autoUpdatePreferred(): Boolean { return preferenceManager.getBoolean("updateInstallAuto", false) } Loading app/src/main/res/xml/settings_preferences.xml +5 −3 Original line number Diff line number Diff line Loading @@ -53,16 +53,18 @@ <PreferenceCategory android:title="@string/Show_applications"> <foundation.e.apps.settings.RadioButtonPreference <CheckBoxPreference android:defaultValue="true" android:key="showAllApplications" android:title="@string/Show_all_apps" /> <foundation.e.apps.settings.RadioButtonPreference <CheckBoxPreference android:defaultValue="true" android:key="showFOSSApplications" android:title="@string/show_only_open_source_apps" /> <foundation.e.apps.settings.RadioButtonPreference <CheckBoxPreference android:defaultValue="true" android:key="showPWAApplications" android:title="@string/show_only_pwa_apps" /> </PreferenceCategory> Loading Loading
app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt +80 −75 Original line number Diff line number Diff line Loading @@ -143,23 +143,28 @@ class FusedAPIImpl @Inject constructor( * To prevent waiting so long and fail early, use withTimeout{}. */ withTimeout(timeoutDurationInMillis) { if (applicationType != APP_TYPE_ANY) { val response = if (applicationType == APP_TYPE_OPEN) { cleanAPKRepository.getHomeScreenData( if (preferenceManagerModule.isGplaySelected()) { list.addAll(fetchGPlayHome(authData)) } if (preferenceManagerModule.isOpenSourceSelected()) { val response = cleanAPKRepository.getHomeScreenData( CleanAPKInterface.APP_TYPE_ANY, CleanAPKInterface.APP_SOURCE_FOSS ).body() } else { cleanAPKRepository.getHomeScreenData( response?.home?.let { list.addAll(generateCleanAPKHome(it, applicationType)) } } if (preferenceManagerModule.isPWASelected()) { val response = cleanAPKRepository.getHomeScreenData( CleanAPKInterface.APP_TYPE_PWA, CleanAPKInterface.APP_SOURCE_ANY ).body() } response?.home?.let { list.addAll(generateCleanAPKHome(it, applicationType)) } } else { list.addAll(fetchGPlayHome(authData)) } } } catch (e: TimeoutCancellationException) { Loading Loading @@ -190,20 +195,12 @@ class FusedAPIImpl @Inject constructor( var apiStatus: ResultStatus = ResultStatus.OK var applicationCategoryType = preferredApplicationType if (preferredApplicationType != APP_TYPE_ANY) { handleCleanApkCategories(preferredApplicationType, categoriesList, type).run { if (this != ResultStatus.OK) { apiStatus = this } } } else { handleAllSourcesCategories(categoriesList, type, authData).run { if (first != ResultStatus.OK) { apiStatus = first applicationCategoryType = second } } } categoriesList.sortBy { item -> item.title.lowercase() } return Triple(categoriesList, applicationCategoryType, apiStatus) } Loading Loading @@ -803,6 +800,7 @@ class FusedAPIImpl @Inject constructor( var apiStatus = ResultStatus.OK var errorApplicationCategory = "" if (preferenceManagerModule.isOpenSourceSelected()) { /* * Try within timeout limit for open source native apps categories. */ Loading @@ -824,6 +822,9 @@ class FusedAPIImpl @Inject constructor( errorApplicationCategory = APP_TYPE_OPEN apiStatus = ResultStatus.UNKNOWN }) } if (preferenceManagerModule.isPWASelected()) { /* * Try within timeout limit to get PWA categories Loading @@ -844,6 +845,9 @@ class FusedAPIImpl @Inject constructor( errorApplicationCategory = APP_TYPE_PWA apiStatus = ResultStatus.UNKNOWN }) } if (preferenceManagerModule.isGplaySelected()) { /* * Try within timeout limit to get native app categories from Play Store Loading @@ -862,6 +866,7 @@ class FusedAPIImpl @Inject constructor( errorApplicationCategory = APP_TYPE_ANY apiStatus = ResultStatus.UNKNOWN }) } return Pair(apiStatus, errorApplicationCategory) } Loading
app/src/main/java/foundation/e/apps/settings/SettingsFragment.kt +10 −9 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.widget.Toast import androidx.fragment.app.viewModels import androidx.navigation.findNavController import androidx.navigation.fragment.findNavController import androidx.preference.CheckBoxPreference import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat import androidx.work.ExistingPeriodicWorkPolicy Loading Loading @@ -69,9 +70,9 @@ class SettingsFragment : PreferenceFragmentCompat() { setPreferencesFromResource(R.xml.settings_preferences, rootKey) // Show applications preferences val showAllApplications = findPreference<RadioButtonPreference>("showAllApplications") val showFOSSApplications = findPreference<RadioButtonPreference>("showFOSSApplications") val showPWAApplications = findPreference<RadioButtonPreference>("showPWAApplications") val showAllApplications = findPreference<CheckBoxPreference>("showAllApplications") val showFOSSApplications = findPreference<CheckBoxPreference>("showFOSSApplications") val showPWAApplications = findPreference<CheckBoxPreference>("showPWAApplications") val updateCheckInterval = preferenceManager.findPreference<Preference>(getString(R.string.update_check_intervals)) Loading @@ -88,22 +89,22 @@ class SettingsFragment : PreferenceFragmentCompat() { } showAllApplications?.setOnPreferenceChangeListener { _, _ -> showFOSSApplications?.isChecked = false showPWAApplications?.isChecked = false // showFOSSApplications?.isChecked = false // showPWAApplications?.isChecked = false backToMainActivity() true } showFOSSApplications?.setOnPreferenceChangeListener { _, _ -> showAllApplications?.isChecked = false showPWAApplications?.isChecked = false // showAllApplications?.isChecked = false // showPWAApplications?.isChecked = false backToMainActivity() true } showPWAApplications?.setOnPreferenceChangeListener { _, _ -> showFOSSApplications?.isChecked = false showAllApplications?.isChecked = false // showFOSSApplications?.isChecked = false // showAllApplications?.isChecked = false backToMainActivity() true } Loading
app/src/main/java/foundation/e/apps/utils/modules/PreferenceManagerModule.kt +4 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,10 @@ class PreferenceManagerModule @Inject constructor( } } fun isOpenSourceSelected() = preferenceManager.getBoolean("showFOSSApplications", false) fun isPWASelected() = preferenceManager.getBoolean("showPWAApplications", false) fun isGplaySelected() = preferenceManager.getBoolean("showAllApplications", false) fun autoUpdatePreferred(): Boolean { return preferenceManager.getBoolean("updateInstallAuto", false) } Loading
app/src/main/res/xml/settings_preferences.xml +5 −3 Original line number Diff line number Diff line Loading @@ -53,16 +53,18 @@ <PreferenceCategory android:title="@string/Show_applications"> <foundation.e.apps.settings.RadioButtonPreference <CheckBoxPreference android:defaultValue="true" android:key="showAllApplications" android:title="@string/Show_all_apps" /> <foundation.e.apps.settings.RadioButtonPreference <CheckBoxPreference android:defaultValue="true" android:key="showFOSSApplications" android:title="@string/show_only_open_source_apps" /> <foundation.e.apps.settings.RadioButtonPreference <CheckBoxPreference android:defaultValue="true" android:key="showPWAApplications" android:title="@string/show_only_pwa_apps" /> </PreferenceCategory> Loading