2021-07-12 10:14:26 +02:00
|
|
|
package audio.funkwhale.ffa.activities
|
2019-10-23 20:21:18 +02:00
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import android.content.Intent
|
|
|
|
import android.os.Bundle
|
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
2021-07-21 09:11:07 +02:00
|
|
|
import audio.funkwhale.ffa.FFA
|
2021-07-12 10:14:26 +02:00
|
|
|
import audio.funkwhale.ffa.utils.AppContext
|
2021-07-23 14:10:13 +02:00
|
|
|
import audio.funkwhale.ffa.utils.OAuth
|
2021-07-30 10:57:49 +02:00
|
|
|
import audio.funkwhale.ffa.utils.OAuthFactory
|
2021-07-12 10:14:26 +02:00
|
|
|
import audio.funkwhale.ffa.utils.Settings
|
2019-10-23 20:21:18 +02:00
|
|
|
|
|
|
|
class SplashActivity : AppCompatActivity() {
|
2021-07-16 10:03:52 +02:00
|
|
|
|
2021-07-30 10:57:49 +02:00
|
|
|
private lateinit var oAuth: OAuth
|
|
|
|
|
2019-10-23 20:21:18 +02:00
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
super.onCreate(savedInstanceState)
|
|
|
|
|
2021-07-30 10:57:49 +02:00
|
|
|
oAuth = OAuthFactory.instance()
|
|
|
|
|
2021-07-23 14:10:13 +02:00
|
|
|
getSharedPreferences(AppContext.PREFS_CREDENTIALS, Context.MODE_PRIVATE)
|
|
|
|
.apply {
|
2021-07-30 10:57:49 +02:00
|
|
|
when (oAuth.isAuthorized(this@SplashActivity) || Settings.isAnonymous()) {
|
2021-07-23 14:10:13 +02:00
|
|
|
true -> Intent(this@SplashActivity, MainActivity::class.java).apply {
|
|
|
|
flags = Intent.FLAG_ACTIVITY_NO_ANIMATION
|
|
|
|
startActivity(this)
|
|
|
|
}
|
|
|
|
|
|
|
|
false -> Intent(this@SplashActivity, LoginActivity::class.java).apply {
|
|
|
|
FFA.get().deleteAllData()
|
|
|
|
flags = Intent.FLAG_ACTIVITY_NO_ANIMATION
|
|
|
|
startActivity(this)
|
|
|
|
}
|
2019-10-23 20:21:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-07-02 13:55:49 +02:00
|
|
|
}
|