0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-23 11:45:11 +00:00

added option to delete downloaded file

This commit is contained in:
X1nto 2020-08-07 11:07:49 +04:00
parent b5eba37e53
commit 10be21c875
5 changed files with 18 additions and 1 deletions

View file

@ -33,6 +33,7 @@ class MicrogDownloadService: Service() {
private fun downloadMicrog() {
runBlocking {
launch {
getExternalFilesDir("apk")?.delete()
val url = getObjectFromJson(
"${PreferenceManager.getDefaultSharedPreferences(this@MicrogDownloadService)
.getString("install_url", baseUrl)}/microg.json", "url"

View file

@ -41,6 +41,7 @@ class VancedDownloadService: Service() {
val context = this
runBlocking {
launch {
getExternalFilesDir("apks")?.delete()
val defPrefs = PreferenceManager.getDefaultSharedPreferences(context)
val installUrl = defPrefs.getString("install_url", baseUrl)
val vancedVer = getObjectFromJson("$installUrl/vanced.json", "version")

View file

@ -91,6 +91,15 @@ class SettingsFragment : PreferenceFragmentCompat() {
true
}
findPreference<Preference>("clear_files")?.setOnPreferenceClickListener {
with(requireActivity()) {
getExternalFilesDir("apk")?.delete()
getExternalFilesDir("apks")?.delete()
Toast.makeText(this, getString(R.string.cleared_files), Toast.LENGTH_SHORT)
}
true
}
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {

View file

@ -49,12 +49,14 @@
<string name="accent_purple">Purple</string>
<string name="accent_red">Red</string>
<string name="accent_yellow">Yellow</string>
<string name="check_updates">Check for updates</string>
<string name="category_interface">Interface</string>
<string name="category_manager">Manager</string>
<string name="check_updates">Check for updates</string>
<string name="chosen_install_values">Chosen installation preferences</string>
<string name="chosen_lang">Language(s): %1$s</string>
<string name="chosen_theme">Theme: %1$s</string>
<string name="clear_files">Clear downloaded files</string>
<string name="cleared_files">Successfully cleared files</string>
<string name="link_title">Use Chrome Custom Tabs</string>
<string name="link_custom_tabs">Links will open in Chrome Custom Tabs</string>
<string name="link_external_browser">Links will open in an External Browser</string>

View file

@ -67,6 +67,10 @@
android:title="@string/update_url"
android:key="install_url" />
<Preference
android:title="@string/clear_files"
android:key="clear_files"/>
</PreferenceCategory>
</PreferenceScreen>