add cache clear menu option

This commit is contained in:
Öppen 2020-08-19 12:33:16 +01:00
parent 171d7276b0
commit 37d05f2c91
4 changed files with 10 additions and 0 deletions

View File

@ -13,4 +13,6 @@ object RuntimeCache {
}
fun get(uri: URI): Pair<GeminiResponse.Header, List<String>>? = lruCache[uri.toString()]
fun clear() = lruCache.evictAll()
}

View File

@ -16,6 +16,7 @@ import com.google.android.material.snackbar.Snackbar
import oppen.tva.R
import oppen.tva.databinding.ActivityTvaBinding
import oppen.tva.io.GeminiResponse
import oppen.tva.io.RuntimeCache
import oppen.tva.io.TvaState
import oppen.tva.io.history.CacheInterface
import oppen.tva.ui.about.AboutDialog
@ -91,6 +92,10 @@ class TvaActivity : AppCompatActivity() {
startActivity(Intent.createChooser(this, null))
}
}
R.id.overflow_menu_clear_cache -> {
RuntimeCache.clear()
showAlert("Runtime cache cleared")
}
R.id.overflow_menu_about -> AboutDialog.show(this)
R.id.overflow_menu_set_home -> {
SetHomeDialog.show(this, binding.addressEdit.text.toString()){

View File

@ -9,6 +9,8 @@
android:title="@string/set_home" />
</group>
<group android:id="@+id/other" >
<item android:id="@+id/overflow_menu_clear_cache"
android:title="@string/clear_cache" />
<item android:id="@+id/overflow_menu_about"
android:title="@string/about" />
</group>

View File

@ -16,4 +16,5 @@
\nThis program 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 3 of the License, or any later version.\n
\nThis program 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.\n
\nYou should have received a copy of the GNU General Public License along with this program. If not, see www.gnu.org/licenses</string>
<string name="clear_cache">Clear cache</string>
</resources>