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

65 lines
2.5 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.view.View
import android.widget.Toast
2019-12-16 11:43:08 +01:00
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.loki.views.FakeChatView
import org.thoughtcrime.securesms.service.KeyCachingService
import org.thoughtcrime.securesms.util.Util
2019-12-16 11:43:08 +01:00
2021-01-18 23:12:44 +01:00
import org.session.libsession.utilities.TextSecurePreferences
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)
findViewById<FakeChatView>(R.id.fakeChatView).startAnimating()
findViewById<View>(R.id.registerButton).setOnClickListener { register() }
findViewById<View>(R.id.restoreButton).setOnClickListener { restoreFromRecoveryPhrase() }
findViewById<View>(R.id.restoreBackupButton).setOnClickListener { restoreFromBackup() }
// Setup essentials for a new user.
IdentityKeyUtil.generateIdentityKeyPair(this)
TextSecurePreferences.setLastExperienceVersionCode(this, Util.getCanonicalVersionCode())
TextSecurePreferences.setPasswordDisabled(this, true)
TextSecurePreferences.setReadReceiptsEnabled(this, true)
TextSecurePreferences.setTypingIndicatorsEnabled(this, true)
//AC: This is a temporary workaround to trick the old code that the screen is unlocked.
KeyCachingService.setMasterSecret(applicationContext, Object())
}
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)
val application = ApplicationContext.getInstance(this)
2020-07-08 02:48:09 +02:00
application.stopPolling()
}
2019-12-16 11:43:08 +01:00
}