session-android/app/src/main/java/org/thoughtcrime/securesms/loki/activities/LandingActivity.kt

53 lines
2 KiB
Kotlin
Raw Normal View History

2020-05-11 08:19:26 +02:00
package org.thoughtcrime.securesms.loki.activities
2019-12-16 11:43:08 +01:00
import android.content.Intent
import android.os.Bundle
import android.widget.Toast
2019-12-16 11:43:08 +01:00
import kotlinx.android.synthetic.main.activity_landing.*
import network.loki.messenger.R
import org.thoughtcrime.securesms.ApplicationContext
2019-12-16 11:43:08 +01:00
import org.thoughtcrime.securesms.BaseActionBarActivity
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil
2020-05-11 08:19:26 +02:00
import org.thoughtcrime.securesms.loki.utilities.push
import org.thoughtcrime.securesms.loki.utilities.setUpActionBarSessionLogo
import org.thoughtcrime.securesms.util.TextSecurePreferences
2019-12-16 11:43:08 +01:00
class LandingActivity : BaseActionBarActivity() {
2019-12-16 11:43:08 +01:00
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_landing)
2020-09-18 08:54:40 +02:00
setUpActionBarSessionLogo(true)
2019-12-16 16:20:48 +01:00
fakeChatView.startAnimating()
2019-12-16 11:43:08 +01:00
registerButton.setOnClickListener { register() }
restoreButton.setOnClickListener { restoreFromRecoveryPhrase() }
restoreBackupButton.setOnClickListener { restoreFromBackup() }
2020-05-13 04:29:31 +02:00
if (TextSecurePreferences.getWasUnlinked(this)) {
2020-05-25 07:24:55 +02:00
Toast.makeText(this, R.string.activity_landing_device_unlinked_dialog_title, Toast.LENGTH_LONG).show()
}
}
2019-12-16 11:43:08 +01:00
private fun register() {
val intent = Intent(this, RegisterActivity::class.java)
2019-12-17 15:15:13 +01:00
push(intent)
2019-12-16 11:43:08 +01:00
}
private fun restoreFromRecoveryPhrase() {
val intent = Intent(this, RecoveryPhraseRestoreActivity::class.java)
2019-12-17 15:15:13 +01:00
push(intent)
2019-12-16 11:43:08 +01:00
}
private fun restoreFromBackup() {
val intent = Intent(this, BackupRestoreActivity::class.java)
push(intent)
}
private fun reset() {
2020-10-29 05:03:51 +01:00
IdentityKeyUtil.delete(this, IdentityKeyUtil.LOKI_SEED)
TextSecurePreferences.removeLocalNumber(this)
TextSecurePreferences.setHasSeenWelcomeScreen(this, false)
TextSecurePreferences.setPromptedPushRegistration(this, false)
val application = ApplicationContext.getInstance(this)
2020-07-08 02:48:09 +02:00
application.stopPolling()
}
2019-12-16 11:43:08 +01:00
}