FiltersPreference: Merge into UpdatesPreference
They only apply to updates as we try to show all available apps in installed and blacklist fragment to be clear about all possible apps aurora store can check updates for. Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Aurora Store
|
||||
* Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
|
||||
*
|
||||
* Aurora Store is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Aurora Store is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.aurora.store.view.ui.preferences
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.aurora.store.R
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
@AndroidEntryPoint
|
||||
class FilterPreference : PreferenceFragmentCompat() {
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.preferences_filter, rootKey)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
view.findViewById<Toolbar>(R.id.toolbar)?.apply {
|
||||
title = getString(R.string.action_filter)
|
||||
setNavigationOnClickListener { findNavController().navigateUp() }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,10 +34,6 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.preferences_settings, rootKey)
|
||||
|
||||
findPreference<Preference>("pref_filter")?.setOnPreferenceClickListener {
|
||||
findNavController().navigate(R.id.filterPreference)
|
||||
true
|
||||
}
|
||||
findPreference<Preference>("pref_install")?.setOnPreferenceClickListener {
|
||||
findNavController().navigate(R.id.installationPreference)
|
||||
true
|
||||
|
||||
@@ -30,6 +30,10 @@ import com.aurora.store.R
|
||||
import com.aurora.store.data.helper.UpdateHelper
|
||||
import com.aurora.store.data.model.PermissionType
|
||||
import com.aurora.store.data.model.UpdateMode
|
||||
import com.aurora.store.util.Preferences
|
||||
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_AURORA_ONLY
|
||||
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_FDROID
|
||||
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_GOOGLE
|
||||
import com.aurora.store.util.Preferences.PREFERENCE_UPDATES_AUTO
|
||||
import com.aurora.store.util.Preferences.PREFERENCE_UPDATES_CHECK_INTERVAL
|
||||
import com.aurora.store.util.Preferences.PREFERENCE_UPDATES_EXTENDED
|
||||
@@ -46,10 +50,19 @@ class UpdatesPreference : BasePreferenceFragment() {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.preferences_updates, rootKey)
|
||||
|
||||
val nonAuroraFilters: List<SwitchPreferenceCompat> = listOfNotNull(
|
||||
findPreference(PREFERENCE_FILTER_FDROID),
|
||||
findPreference(PREFERENCE_FILTER_GOOGLE)
|
||||
)
|
||||
|
||||
findPreference<ListPreference>(PREFERENCE_UPDATES_AUTO)
|
||||
?.setOnPreferenceChangeListener { _, newValue ->
|
||||
val updateCheckIntervalPref =
|
||||
findPreference<SeekBarPreference>(PREFERENCE_UPDATES_CHECK_INTERVAL)
|
||||
|
||||
when (UpdateMode.entries[newValue.toString().toInt()]) {
|
||||
UpdateMode.DISABLED -> {
|
||||
updateCheckIntervalPref?.isEnabled = false
|
||||
updateHelper.cancelAutomatedCheck()
|
||||
requireContext().save(PREFERENCE_UPDATES_AUTO, 0)
|
||||
true
|
||||
@@ -57,11 +70,13 @@ class UpdatesPreference : BasePreferenceFragment() {
|
||||
|
||||
UpdateMode.CHECK_AND_NOTIFY -> {
|
||||
if (permissionProvider.isGranted(PermissionType.POST_NOTIFICATIONS)) {
|
||||
updateCheckIntervalPref?.isEnabled = true
|
||||
updateHelper.scheduleAutomatedCheck()
|
||||
true
|
||||
} else {
|
||||
permissionProvider.request(PermissionType.POST_NOTIFICATIONS) {
|
||||
if (it) {
|
||||
updateCheckIntervalPref?.isEnabled = true
|
||||
requireContext().save(PREFERENCE_UPDATES_AUTO, 1)
|
||||
updateHelper.scheduleAutomatedCheck()
|
||||
activity?.recreate()
|
||||
@@ -73,11 +88,13 @@ class UpdatesPreference : BasePreferenceFragment() {
|
||||
|
||||
UpdateMode.CHECK_AND_INSTALL -> {
|
||||
if (permissionProvider.isGranted(PermissionType.DOZE_WHITELIST)) {
|
||||
updateCheckIntervalPref?.isEnabled = true
|
||||
updateHelper.scheduleAutomatedCheck()
|
||||
true
|
||||
} else {
|
||||
permissionProvider.request(PermissionType.DOZE_WHITELIST) {
|
||||
if (it) {
|
||||
updateCheckIntervalPref?.isEnabled = true
|
||||
requireContext().save(PREFERENCE_UPDATES_AUTO, 2)
|
||||
updateHelper.scheduleAutomatedCheck()
|
||||
activity?.recreate()
|
||||
@@ -91,11 +108,28 @@ class UpdatesPreference : BasePreferenceFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
findPreference<SeekBarPreference>(PREFERENCE_UPDATES_CHECK_INTERVAL)
|
||||
?.setOnPreferenceChangeListener { _, _ ->
|
||||
findPreference<SeekBarPreference>(PREFERENCE_UPDATES_CHECK_INTERVAL)?.apply {
|
||||
isEnabled = Preferences.getInteger(requireContext(), PREFERENCE_UPDATES_AUTO) != 0
|
||||
setOnPreferenceChangeListener { _, _ ->
|
||||
updateHelper.updateAutomatedCheck()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
findPreference<SwitchPreferenceCompat>(PREFERENCE_FILTER_AURORA_ONLY)
|
||||
?.setOnPreferenceChangeListener { _, newValue ->
|
||||
nonAuroraFilters.forEach { it.isEnabled = !newValue.toString().toBoolean() }
|
||||
updateHelper.checkUpdatesNow()
|
||||
true
|
||||
}
|
||||
|
||||
nonAuroraFilters.forEach {
|
||||
it.isEnabled = !Preferences.getBoolean(requireContext(), PREFERENCE_FILTER_AURORA_ONLY)
|
||||
it.setOnPreferenceChangeListener { _, _ ->
|
||||
updateHelper.checkUpdatesNow()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
findPreference<SwitchPreferenceCompat>(PREFERENCE_UPDATES_EXTENDED)
|
||||
?.setOnPreferenceChangeListener { _, _ ->
|
||||
|
||||
@@ -97,11 +97,6 @@
|
||||
android:name="com.aurora.store.view.ui.preferences.SettingsFragment"
|
||||
android:label="@string/title_settings"
|
||||
tools:layout="@layout/fragment_setting" />
|
||||
<fragment
|
||||
android:id="@+id/filterPreference"
|
||||
android:name="com.aurora.store.view.ui.preferences.FilterPreference"
|
||||
android:label="FilterPreference"
|
||||
tools:layout="@layout/fragment_setting" />
|
||||
<fragment
|
||||
android:id="@+id/installationPreference"
|
||||
android:name="com.aurora.store.view.ui.preferences.InstallationPreference"
|
||||
|
||||
@@ -210,9 +210,9 @@
|
||||
<string name="pref_dialog_to_apply_restart">"This setting will be applied after you restart the app"</string>
|
||||
<string name="pref_downloader_wifi_title">"Download using WiFi only"</string>
|
||||
<string name="pref_download_directory_error">"Selected path is not writable"</string>
|
||||
<string name="pref_filter_fdroid_summary">"Ignore F-Droid apps from Updates and Installed apps"</string>
|
||||
<string name="pref_filter_fdroid_summary">"Don't check updates for apps downloaded or installed from F-Droid"</string>
|
||||
<string name="pref_filter_fdroid_title">"Filter F-Droid apps"</string>
|
||||
<string name="pref_filter_google_summary">"Ignore Google apps from Updates and Installed apps"</string>
|
||||
<string name="pref_filter_google_summary">"Don't check updates for Google apps"</string>
|
||||
<string name="pref_filter_google_title">"Filter Google apps"</string>
|
||||
<string name="pref_install_delete_summary">Downloaded APKs will be deleted immediately after installation</string>
|
||||
<string name="pref_install_delete_title">"Delete APK post-install"</string>
|
||||
@@ -240,7 +240,7 @@
|
||||
<string name="pref_updates_incompatible">Incompatible updates</string>
|
||||
<string name="pref_updates_incompatible_desc">Show updates for incompatible or disabled apps that may fail to install</string>
|
||||
<string name="pref_aurora_only">Aurora Store apps only</string>
|
||||
<string name="pref_aurora_only_desc">Show only Aurora Store installed apps in Updates and Installed apps</string>
|
||||
<string name="pref_aurora_only_desc">Only check updates for apps installed by Aurora Store</string>
|
||||
<string name="purchase_failed">"Download Failed"</string>
|
||||
<string name="purchase_invalid">"App not purchased"</string>
|
||||
<string name="purchase_unsupported">"App not supported"</string>
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
<!--
|
||||
~ Aurora Store
|
||||
~ Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
|
||||
~
|
||||
~ Aurora Store is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 2 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ Aurora Store is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
|
||||
~
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="false"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="PREFERENCE_FILTER_AURORA_ONLY"
|
||||
app:summary="@string/pref_aurora_only_desc"
|
||||
app:title="@string/pref_aurora_only" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="false"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="PREFERENCE_FILTER_GOOGLE"
|
||||
app:summary="@string/pref_filter_google_summary"
|
||||
app:title="@string/pref_filter_google_title" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="true"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="PREFERENCE_FILTER_FDROID"
|
||||
app:summary="@string/pref_filter_fdroid_summary"
|
||||
app:title="@string/pref_filter_fdroid_title" />
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -18,11 +18,6 @@
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<Preference
|
||||
app:icon="@drawable/ic_filter"
|
||||
app:key="pref_filter"
|
||||
app:layout="@layout/item_preference"
|
||||
app:title="@string/action_filter" />
|
||||
|
||||
<Preference
|
||||
app:icon="@drawable/ic_installation"
|
||||
|
||||
@@ -40,6 +40,32 @@
|
||||
app:min="1"
|
||||
app:showSeekBarValue="true" />
|
||||
|
||||
<PreferenceCategory
|
||||
app:iconSpaceReserved="false"
|
||||
app:singleLineTitle="false"
|
||||
app:title="@string/action_filter" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="true"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="PREFERENCE_FILTER_FDROID"
|
||||
app:summary="@string/pref_filter_fdroid_summary"
|
||||
app:title="@string/pref_filter_fdroid_title" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="false"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="PREFERENCE_FILTER_GOOGLE"
|
||||
app:summary="@string/pref_filter_google_summary"
|
||||
app:title="@string/pref_filter_google_title" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="false"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="PREFERENCE_FILTER_AURORA_ONLY"
|
||||
app:summary="@string/pref_aurora_only_desc"
|
||||
app:title="@string/pref_aurora_only" />
|
||||
|
||||
<PreferenceCategory
|
||||
app:iconSpaceReserved="false"
|
||||
app:singleLineTitle="false"
|
||||
|
||||
Reference in New Issue
Block a user