diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7f93a22..75325fa 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -16,8 +16,7 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:theme="@style/AppTheme"> - + android:theme="@style/Theme.AppCompat.Light.NoActionBar"> diff --git a/app/src/main/java/im/status/keycard/connect/ui/MainActivity.kt b/app/src/main/java/im/status/keycard/connect/ui/MainActivity.kt index 9763885..0d2000a 100644 --- a/app/src/main/java/im/status/keycard/connect/ui/MainActivity.kt +++ b/app/src/main/java/im/status/keycard/connect/ui/MainActivity.kt @@ -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(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 diff --git a/app/src/main/java/im/status/keycard/connect/ui/SettingsActivity.kt b/app/src/main/java/im/status/keycard/connect/ui/SettingsActivity.kt deleted file mode 100644 index b339b8f..0000000 --- a/app/src/main/java/im/status/keycard/connect/ui/SettingsActivity.kt +++ /dev/null @@ -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() - } -} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 8727c50..e26f03c 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -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" /> - -