Added back clearing repository cache

This commit is contained in:
Viktor De Pasquale 2019-05-23 15:28:05 +02:00
parent ea1f75f80e
commit 0119ebddbe
3 changed files with 5 additions and 1 deletions

View File

@ -59,6 +59,8 @@ class ModuleRepository(
.fetchModuleInstaller() .fetchModuleInstaller()
.map { it.writeToFile(context, FILE_MODULE_INSTALLER_SH) } .map { it.writeToFile(context, FILE_MODULE_INSTALLER_SH) }
fun deleteAllCached() = repoDao.deleteAll()
private fun fetchProperties(module: String, lastChanged: Long) = apiRaw private fun fetchProperties(module: String, lastChanged: Long) = apiRaw
.fetchFile(module, "module.prop") .fetchFile(module, "module.prop")

View File

@ -13,6 +13,7 @@ import androidx.preference.*
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.topjohnwu.magisk.App import com.topjohnwu.magisk.App
import com.topjohnwu.magisk.R import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.data.repository.ModuleRepository
import com.topjohnwu.magisk.data.repository.SettingRepository import com.topjohnwu.magisk.data.repository.SettingRepository
import org.koin.android.ext.android.inject import org.koin.android.ext.android.inject
@ -22,6 +23,7 @@ abstract class BasePreferenceFragment : PreferenceFragmentCompat(),
protected val prefs: SharedPreferences by inject() protected val prefs: SharedPreferences by inject()
protected val app: App by inject() protected val app: App by inject()
protected val settingRepo: SettingRepository by inject() protected val settingRepo: SettingRepository by inject()
protected val moduleRepo: ModuleRepository by inject()
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, inflater: LayoutInflater,

View File

@ -106,9 +106,9 @@ public final class SettingsFragment extends BasePreferenceFragment {
return true; return true;
}); });
Preference clear = findPreference("clear"); Preference clear = findPreference("clear");
clear.setEnabled(false); // temporarily disable clearing cache as repos are not cached atm
clear.setOnPreferenceClickListener(pref -> { clear.setOnPreferenceClickListener(pref -> {
getPrefs().edit().remove(Config.Key.ETAG_KEY).apply(); getPrefs().edit().remove(Config.Key.ETAG_KEY).apply();
getModuleRepo().deleteAllCached();
Utils.toast(R.string.repo_cache_cleared, Toast.LENGTH_SHORT); Utils.toast(R.string.repo_cache_cleared, Toast.LENGTH_SHORT);
return true; return true;
}); });