From 0119ebddbe937300798d96a5475a36bcb52b42d0 Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Thu, 23 May 2019 15:28:05 +0200 Subject: [PATCH] Added back clearing repository cache --- .../com/topjohnwu/magisk/data/repository/ModuleRepository.kt | 2 ++ .../java/com/topjohnwu/magisk/ui/base/BasePreferenceFragment.kt | 2 ++ .../java/com/topjohnwu/magisk/ui/settings/SettingsFragment.java | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/data/repository/ModuleRepository.kt b/app/src/main/java/com/topjohnwu/magisk/data/repository/ModuleRepository.kt index 05106b5ab..a9edbfa14 100644 --- a/app/src/main/java/com/topjohnwu/magisk/data/repository/ModuleRepository.kt +++ b/app/src/main/java/com/topjohnwu/magisk/data/repository/ModuleRepository.kt @@ -59,6 +59,8 @@ class ModuleRepository( .fetchModuleInstaller() .map { it.writeToFile(context, FILE_MODULE_INSTALLER_SH) } + fun deleteAllCached() = repoDao.deleteAll() + private fun fetchProperties(module: String, lastChanged: Long) = apiRaw .fetchFile(module, "module.prop") diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/base/BasePreferenceFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/base/BasePreferenceFragment.kt index 024682310..2b52355b8 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/base/BasePreferenceFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/base/BasePreferenceFragment.kt @@ -13,6 +13,7 @@ import androidx.preference.* import androidx.recyclerview.widget.RecyclerView import com.topjohnwu.magisk.App import com.topjohnwu.magisk.R +import com.topjohnwu.magisk.data.repository.ModuleRepository import com.topjohnwu.magisk.data.repository.SettingRepository import org.koin.android.ext.android.inject @@ -22,6 +23,7 @@ abstract class BasePreferenceFragment : PreferenceFragmentCompat(), protected val prefs: SharedPreferences by inject() protected val app: App by inject() protected val settingRepo: SettingRepository by inject() + protected val moduleRepo: ModuleRepository by inject() override fun onCreateView( inflater: LayoutInflater, diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.java b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.java index 0285e5fc9..08e4e5cfc 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.java @@ -106,9 +106,9 @@ public final class SettingsFragment extends BasePreferenceFragment { return true; }); Preference clear = findPreference("clear"); - clear.setEnabled(false); // temporarily disable clearing cache as repos are not cached atm clear.setOnPreferenceClickListener(pref -> { getPrefs().edit().remove(Config.Key.ETAG_KEY).apply(); + getModuleRepo().deleteAllCached(); Utils.toast(R.string.repo_cache_cleared, Toast.LENGTH_SHORT); return true; });