Browse Source

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

housekeeping/remove-warnings
Antoine POPINEAU 4 years ago
parent
commit
bab7040b8f
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
  1. 6
      app/src/main/java/com/github/apognu/otter/Otter.kt
  2. 7
      app/src/main/java/com/github/apognu/otter/activities/SettingsActivity.kt

6
app/src/main/java/com/github/apognu/otter/Otter.kt

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

7
app/src/main/java/com/github/apognu/otter/activities/SettingsActivity.kt

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

Loading…
Cancel
Save