Clear settings on logout (#395)
This commit is contained in:
parent
78d5744139
commit
ca5186d20a
@ -14,11 +14,11 @@ import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.TextView
|
||||
import androidx.preference.PreferenceManager
|
||||
import apps.amine.bou.readerforselfoss.api.selfoss.SelfossApi
|
||||
import apps.amine.bou.readerforselfoss.api.selfoss.SuccessResponse
|
||||
import apps.amine.bou.readerforselfoss.databinding.ActivityLoginBinding
|
||||
import apps.amine.bou.readerforselfoss.themes.AppColors
|
||||
import apps.amine.bou.readerforselfoss.utils.Config
|
||||
import apps.amine.bou.readerforselfoss.utils.isBaseUrlValid
|
||||
import apps.amine.bou.readerforselfoss.utils.network.isNetworkAccessible
|
||||
import com.mikepenz.aboutlibraries.LibsBuilder
|
||||
@ -52,7 +52,7 @@ class LoginActivity : AppCompatActivity() {
|
||||
|
||||
handleBaseUrlFail()
|
||||
|
||||
settings = getSharedPreferences(Config.settingsName, Context.MODE_PRIVATE)
|
||||
settings = PreferenceManager.getDefaultSharedPreferences(applicationContext)
|
||||
userIdentifier = settings.getString("unique_id", "")!!
|
||||
|
||||
editor = settings.edit()
|
||||
|
@ -4,11 +4,12 @@ import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import androidx.preference.PreferenceManager
|
||||
import apps.amine.bou.readerforselfoss.LoginActivity
|
||||
|
||||
class Config(c: Context) {
|
||||
|
||||
val settings: SharedPreferences = c.getSharedPreferences(settingsName, Context.MODE_PRIVATE)
|
||||
val settings: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(c)
|
||||
|
||||
val baseUrl: String
|
||||
get() = settings.getString("url", "")!!
|
||||
@ -42,17 +43,15 @@ class Config(c: Context) {
|
||||
|
||||
var apiVersion = 0
|
||||
|
||||
/* Execute logout and clear all settings to default */
|
||||
fun logoutAndRedirect(
|
||||
c: Context,
|
||||
callingActivity: Activity,
|
||||
editor: SharedPreferences.Editor,
|
||||
baseUrlFail: Boolean = false
|
||||
): Boolean {
|
||||
editor.remove("url")
|
||||
editor.remove("login")
|
||||
editor.remove("password")
|
||||
editor.remove("apiVersionMajor")
|
||||
editor.apply()
|
||||
val settings = PreferenceManager.getDefaultSharedPreferences(c)
|
||||
settings.edit().clear().commit()
|
||||
val intent = Intent(c, LoginActivity::class.java)
|
||||
if (baseUrlFail) {
|
||||
intent.putExtra("baseUrlFail", baseUrlFail)
|
||||
|
Loading…
Reference in New Issue
Block a user