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
|
2020-12-15 06:44:38 +01:00
|
|
|
import android.view.View
|
2020-01-08 05:16:34 +01:00
|
|
|
import android.widget.Toast
|
2019-12-16 11:43:08 +01:00
|
|
|
import network.loki.messenger.R
|
2020-01-08 05:16:34 +01:00
|
|
|
import org.thoughtcrime.securesms.ApplicationContext
|
2019-12-16 11:43:08 +01:00
|
|
|
import org.thoughtcrime.securesms.BaseActionBarActivity
|
2020-01-08 05:16:34 +01:00
|
|
|
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
|
2020-12-15 06:44:38 +01:00
|
|
|
import org.thoughtcrime.securesms.loki.views.FakeChatView
|
2020-12-15 07:16:05 +01:00
|
|
|
import org.thoughtcrime.securesms.service.KeyCachingService
|
2020-12-15 06:44:38 +01:00
|
|
|
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
|
|
|
|
|
2020-12-04 06:00:52 +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)
|
2020-12-15 06:44:38 +01:00
|
|
|
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)
|
2020-12-15 07:16:05 +01:00
|
|
|
|
|
|
|
//AC: This is a temporary workaround to trick the old code that the screen is unlocked.
|
|
|
|
KeyCachingService.setMasterSecret(applicationContext, Object())
|
2020-01-08 05:16:34 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-12-04 06:00:52 +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
|
|
|
}
|
2020-01-08 05:16:34 +01:00
|
|
|
|
2020-12-04 06:00:52 +01:00
|
|
|
private fun restoreFromBackup() {
|
|
|
|
val intent = Intent(this, BackupRestoreActivity::class.java)
|
|
|
|
push(intent)
|
2020-01-08 05:16:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private fun reset() {
|
2020-10-29 05:03:51 +01:00
|
|
|
IdentityKeyUtil.delete(this, IdentityKeyUtil.LOKI_SEED)
|
2020-01-08 05:16:34 +01:00
|
|
|
TextSecurePreferences.removeLocalNumber(this)
|
|
|
|
TextSecurePreferences.setHasSeenWelcomeScreen(this, false)
|
2020-06-25 01:33:44 +02:00
|
|
|
val application = ApplicationContext.getInstance(this)
|
2020-07-08 02:48:09 +02:00
|
|
|
application.stopPolling()
|
2020-01-08 05:16:34 +01:00
|
|
|
}
|
2019-12-16 11:43:08 +01:00
|
|
|
}
|