Delete downloaded tracks on logout. Cache is not deleted for now (until I find a way).

This commit is contained in:
Antoine POPINEAU 2020-06-21 18:06:38 +02:00
parent 874b79d0d5
commit bab7040b8f
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
2 changed files with 9 additions and 4 deletions

View File

@ -75,6 +75,12 @@ class Otter : Application() {
} }
} }
fun deleteAllData() {
PowerPreference.getFileByName(AppContext.PREFS_CREDENTIALS).clear()
exoDownloadManager.removeAllDownloads()
}
inner class CrashReportHandler : Thread.UncaughtExceptionHandler { inner class CrashReportHandler : Thread.UncaughtExceptionHandler {
override fun uncaughtException(t: Thread, e: Throwable) { override fun uncaughtException(t: Thread, e: Throwable) {
val now = Date(Date().time - (5 * 60 * 1000)) val now = Date(Date().time - (5 * 60 * 1000))

View File

@ -11,6 +11,7 @@ import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SeekBarPreference import androidx.preference.SeekBarPreference
import com.github.apognu.otter.BuildConfig import com.github.apognu.otter.BuildConfig
import com.github.apognu.otter.Otter
import com.github.apognu.otter.R import com.github.apognu.otter.R
import com.github.apognu.otter.utils.* import com.github.apognu.otter.utils.*
import com.preference.PowerPreference import com.preference.PowerPreference
@ -78,12 +79,10 @@ class SettingsFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedP
.setTitle(context.getString(R.string.logout_title)) .setTitle(context.getString(R.string.logout_title))
.setMessage(context.getString(R.string.logout_content)) .setMessage(context.getString(R.string.logout_content))
.setPositiveButton(android.R.string.yes) { _, _ -> .setPositiveButton(android.R.string.yes) { _, _ ->
PowerPreference.getFileByName(AppContext.PREFS_CREDENTIALS).clear()
context.cacheDir.deleteRecursively()
CommandBus.send(Command.ClearQueue) CommandBus.send(Command.ClearQueue)
Otter.get().deleteAllData()
activity?.setResult(MainActivity.ResultCode.LOGOUT.code) activity?.setResult(MainActivity.ResultCode.LOGOUT.code)
activity?.finish() activity?.finish()
} }