move all walletconnect stuff on main window
This commit is contained in:
parent
fa51817608
commit
40b77ad7fc
|
@ -16,8 +16,7 @@
|
|||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".ui.SettingsActivity" />
|
||||
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
|
||||
<activity android:name=".ui.ChangePairingPasswordActivity" />
|
||||
<activity android:name=".ui.ChangePUKActivity" />
|
||||
<activity android:name=".ui.ShowMnemonicActivity" />
|
||||
|
|
|
@ -15,12 +15,13 @@ import im.status.keycard.connect.Registry
|
|||
import im.status.keycard.connect.card.*
|
||||
import im.status.keycard.connect.data.*
|
||||
import im.status.keycard.connect.net.WalletConnectListener
|
||||
import org.walletconnect.Session
|
||||
import org.walletconnect.Session.Config.Companion.fromWCUri
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
class MainActivity : AppCompatActivity(), ScriptListener, WalletConnectListener {
|
||||
private lateinit var viewSwitcher: ViewSwitcher
|
||||
private lateinit var networkSpinner: Spinner
|
||||
private lateinit var walletPath: EditText
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
@ -34,21 +35,15 @@ class MainActivity : AppCompatActivity(), ScriptListener, WalletConnectListener
|
|||
Registry.init(this, this, this)
|
||||
Registry.scriptExecutor.defaultScript = cardCheckupScript()
|
||||
|
||||
val networkSpinner = findViewById<Spinner>(R.id.networkSpinner)
|
||||
networkSpinner = findViewById(R.id.networkSpinner)
|
||||
walletPath = findViewById(R.id.walletPathText)
|
||||
|
||||
ArrayAdapter.createFromResource(this, R.array.networks, android.R.layout.simple_spinner_item).also {
|
||||
it.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||
networkSpinner.adapter = it
|
||||
}
|
||||
networkSpinner.setSelection(CHAIN_IDS.indexOf(Registry.settingsManager.chainID))
|
||||
networkSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener{
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) { }
|
||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||
val chainID = CHAIN_IDS[position]
|
||||
Registry.settingsManager.chainID = chainID
|
||||
Registry.ethereumRPC.changeEndpoint(Registry.settingsManager.rpcEndpoint)
|
||||
Registry.walletConnect.updateChainAndDerivation(Registry.settingsManager.bip32Path, chainID)
|
||||
}
|
||||
}
|
||||
walletPath.setText(Registry.settingsManager.bip32Path)
|
||||
|
||||
handleIntent(intent)
|
||||
}
|
||||
|
@ -106,6 +101,17 @@ class MainActivity : AppCompatActivity(), ScriptListener, WalletConnectListener
|
|||
}
|
||||
}
|
||||
|
||||
fun updateConnection(view: View) {
|
||||
val chainID = CHAIN_IDS[networkSpinner.selectedItemPosition]
|
||||
Registry.settingsManager.chainID = chainID
|
||||
Registry.ethereumRPC.changeEndpoint(Registry.settingsManager.rpcEndpoint)
|
||||
|
||||
val bip32Path = walletPath.text.toString()
|
||||
Registry.settingsManager.bip32Path = bip32Path
|
||||
|
||||
Registry.walletConnect.updateChainAndDerivation(bip32Path, chainID)
|
||||
}
|
||||
|
||||
fun cancelNFC(@Suppress("UNUSED_PARAMETER") view: View) {
|
||||
Registry.scriptExecutor.cancelScript()
|
||||
}
|
||||
|
@ -154,10 +160,6 @@ class MainActivity : AppCompatActivity(), ScriptListener, WalletConnectListener
|
|||
startCommand(ReinstallActivity::class)
|
||||
}
|
||||
|
||||
fun settings(@Suppress("UNUSED_PARAMETER") view: View) {
|
||||
startCommand(SettingsActivity::class)
|
||||
}
|
||||
|
||||
private fun loadKeyHandler(resultCode: Int, data: Intent?) {
|
||||
if (resultCode != Activity.RESULT_OK || data == null) return
|
||||
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
package im.status.keycard.connect.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.EditText
|
||||
import android.widget.Spinner
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import im.status.keycard.connect.R
|
||||
import im.status.keycard.connect.Registry
|
||||
import im.status.keycard.connect.data.CHAIN_IDS
|
||||
|
||||
class SettingsActivity : AppCompatActivity() {
|
||||
lateinit var networkSpinner : Spinner
|
||||
lateinit var walletPath : EditText
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_settings)
|
||||
|
||||
networkSpinner = findViewById(R.id.networkSpinner)
|
||||
ArrayAdapter.createFromResource(this, R.array.networks, android.R.layout.simple_spinner_item).also {
|
||||
it.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||
networkSpinner.adapter = it
|
||||
}
|
||||
networkSpinner.setSelection(CHAIN_IDS.indexOf(Registry.settingsManager.chainID))
|
||||
|
||||
walletPath = findViewById(R.id.walletPathText)
|
||||
walletPath.setText(Registry.settingsManager.bip32Path)
|
||||
|
||||
}
|
||||
|
||||
fun ok(@Suppress("UNUSED_PARAMETER") view: View) {
|
||||
val chainID = CHAIN_IDS[networkSpinner.selectedItemPosition]
|
||||
Registry.settingsManager.chainID = chainID
|
||||
Registry.ethereumRPC.changeEndpoint(Registry.settingsManager.rpcEndpoint)
|
||||
|
||||
val bip32Path = walletPath.text.toString()
|
||||
Registry.settingsManager.bip32Path = bip32Path
|
||||
|
||||
Registry.walletConnect.updateChainAndDerivation(bip32Path, chainID)
|
||||
finish()
|
||||
}
|
||||
|
||||
fun cancel(@Suppress("UNUSED_PARAMETER") view: View) {
|
||||
finish()
|
||||
}
|
||||
}
|
|
@ -11,24 +11,11 @@
|
|||
android:id="@+id/walletConnectButton"
|
||||
android:layout_width="236dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="144dp"
|
||||
android:layout_marginTop="188dp"
|
||||
android:onClick="connectWallet"
|
||||
android:text="@string/connect_wallet"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.502"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/changePINButton"
|
||||
android:layout_width="131dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="228dp"
|
||||
android:onClick="changePIN"
|
||||
android:text="@string/change_pin"
|
||||
app:layout_constraintEnd_toStartOf="@+id/changePUKButton"
|
||||
app:layout_constraintHorizontal_bias="0.104"
|
||||
app:layout_constraintHorizontal_bias="0.497"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
@ -80,18 +67,6 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/changePairingPasswordButton" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/settingsButton"
|
||||
android:layout_width="236dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:onClick="settings"
|
||||
android:text="@string/settings"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.502"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/reinstall" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/removeKey"
|
||||
android:layout_width="236dp"
|
||||
|
@ -120,13 +95,26 @@
|
|||
android:id="@+id/changePUKButton"
|
||||
android:layout_width="149dp"
|
||||
android:layout_height="46dp"
|
||||
android:layout_marginTop="220dp"
|
||||
android:layout_marginEnd="48dp"
|
||||
android:onClick="changePUK"
|
||||
android:layout_marginTop="296dp"
|
||||
android:layout_marginEnd="60dp"
|
||||
android:onClick="updateConnection"
|
||||
android:text="@string/change_puk"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/changePINButton"
|
||||
android:layout_width="131dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="296dp"
|
||||
android:onClick="updateConnection"
|
||||
android:text="@string/change_pin"
|
||||
app:layout_constraintEnd_toStartOf="@+id/changePUKButton"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/networkSpinner"
|
||||
android:layout_width="407dp"
|
||||
|
@ -141,7 +129,29 @@
|
|||
android:layout_width="375dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:layout_marginTop="80dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/networkSpinner" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/walletPathText"
|
||||
android:layout_width="249dp"
|
||||
android:layout_height="42dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:ems="10"
|
||||
android:inputType="textPersonName"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/networkSpinner" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/updateButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="32dp"
|
||||
android:onClick="updateConnection"
|
||||
android:text="@string/update_connection"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/networkSpinner" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -45,4 +45,5 @@
|
|||
<string name="reinstall_ndef_checkbox">Install NDEF applet</string>
|
||||
<string name="reinstall_button">Select cap file and install</string>
|
||||
<string name="disconnect_wallet">Disconnect</string>
|
||||
<string name="update_connection">Update</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue