update
This commit is contained in:
parent
de5cf41385
commit
e1bc98509d
@ -40,8 +40,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
private lateinit var ipInput: TextInputEditText
|
private lateinit var ipInput: TextInputEditText
|
||||||
private lateinit var portInput: TextInputEditText
|
private lateinit var portInput: TextInputEditText
|
||||||
|
|
||||||
private lateinit var deviceName: TextView
|
private lateinit var btDeviceName: TextView
|
||||||
private lateinit var deviceAddress: TextView
|
private lateinit var btDeviceMac: TextView
|
||||||
|
|
||||||
private lateinit var tabLayout: TabLayout
|
private lateinit var tabLayout: TabLayout
|
||||||
|
|
||||||
@ -51,16 +51,19 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
mContext = applicationContext
|
mContext = applicationContext
|
||||||
|
|
||||||
ipInput = findViewById(R.id.ip_input)
|
// TCP
|
||||||
portInput = findViewById(R.id.port_input)
|
|
||||||
val buttonConnect = findViewById<Button>(R.id.button_connect)
|
|
||||||
|
|
||||||
val ipLayout = findViewById<TextInputLayout>(R.id.ip_input_layout)
|
val ipLayout = findViewById<TextInputLayout>(R.id.ip_input_layout)
|
||||||
val portLayout = findViewById<TextInputLayout>(R.id.port_input_layout)
|
val portLayout = findViewById<TextInputLayout>(R.id.port_input_layout)
|
||||||
|
ipInput = findViewById(R.id.ip_input)
|
||||||
|
portInput = findViewById(R.id.port_input)
|
||||||
|
|
||||||
|
// Bluetooth
|
||||||
val selectedDevice = findViewById<ConstraintLayout>(R.id.selected)
|
val selectedDevice = findViewById<ConstraintLayout>(R.id.selected)
|
||||||
deviceName = findViewById(R.id.textView_device_name)
|
btDeviceName = findViewById(R.id.textView_device_name)
|
||||||
deviceAddress = findViewById(R.id.textView_device_address)
|
btDeviceMac = findViewById(R.id.textView_device_mac)
|
||||||
|
|
||||||
|
|
||||||
|
val buttonConnect = findViewById<Button>(R.id.button_connect)
|
||||||
|
|
||||||
val sourceLink = findViewById<TextView>(R.id.textView_github)
|
val sourceLink = findViewById<TextView>(R.id.textView_github)
|
||||||
sourceLink.movementMethod = LinkMovementMethod.getInstance()
|
sourceLink.movementMethod = LinkMovementMethod.getInstance()
|
||||||
@ -131,11 +134,11 @@ class MainActivity : AppCompatActivity() {
|
|||||||
portLayout.error = getString(R.string.invalid_port)
|
portLayout.error = getString(R.string.invalid_port)
|
||||||
}
|
}
|
||||||
} else if (tabLayout.selectedTabPosition == 1) {
|
} else if (tabLayout.selectedTabPosition == 1) {
|
||||||
if (deviceAddress.text.isNotBlank()) {
|
if (btDeviceMac.text.isNotBlank()) {
|
||||||
saveSharedPref()
|
saveSharedPref()
|
||||||
val intent = Intent(this, ControlActivity::class.java).apply {
|
val intent = Intent(this, ControlActivity::class.java).apply {
|
||||||
putExtra("interface", "Bluetooth")
|
putExtra("interface", "Bluetooth")
|
||||||
putExtra("mac", deviceAddress.text.toString())
|
putExtra("mac", btDeviceMac.text.toString())
|
||||||
}
|
}
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
@ -168,8 +171,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
// There are no request codes
|
// There are no request codes
|
||||||
val data: Intent? = result.data
|
val data: Intent? = result.data
|
||||||
|
|
||||||
deviceName.text = data!!.getStringExtra("device_name")
|
btDeviceName.text = data!!.getStringExtra("device_name")
|
||||||
deviceAddress.text = data.getStringExtra("device_address")
|
btDeviceMac.text = data.getStringExtra("device_address")
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -238,8 +241,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
tab!!.select()
|
tab!!.select()
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceName.text = prefs.getString(SHARED_PREFS_DEVICE_NAME, "Click to select a device")
|
btDeviceName.text = prefs.getString(SHARED_PREFS_DEVICE_NAME, "Click to select a device")
|
||||||
deviceAddress.text = prefs.getString(SHARED_PREFS_DEVICE_ADDRESS, "")
|
btDeviceMac.text = prefs.getString(SHARED_PREFS_DEVICE_ADDRESS, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveSharedPref() {
|
private fun saveSharedPref() {
|
||||||
@ -256,8 +259,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
editor.putString(SHARED_PREFS_TAB, "Bluetooth")
|
editor.putString(SHARED_PREFS_TAB, "Bluetooth")
|
||||||
}
|
}
|
||||||
|
|
||||||
editor.putString(SHARED_PREFS_DEVICE_NAME, deviceName.text.toString())
|
editor.putString(SHARED_PREFS_DEVICE_NAME, btDeviceName.text.toString())
|
||||||
editor.putString(SHARED_PREFS_DEVICE_ADDRESS, deviceAddress.text.toString())
|
editor.putString(SHARED_PREFS_DEVICE_ADDRESS, btDeviceMac.text.toString())
|
||||||
|
|
||||||
editor.apply()
|
editor.apply()
|
||||||
}
|
}
|
||||||
|
@ -27,13 +27,13 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?attr/textAppearanceBody1"
|
android:textAppearance="?attr/textAppearanceBody1"
|
||||||
android:text="TextView"
|
android:text="TextView"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/textView_device_address"
|
app:layout_constraintBottom_toTopOf="@+id/textView_device_mac"
|
||||||
app:layout_constraintStart_toEndOf="@+id/imageView"
|
app:layout_constraintStart_toEndOf="@+id/imageView"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintVertical_chainStyle="packed" />
|
app:layout_constraintVertical_chainStyle="packed" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView_device_address"
|
android:id="@+id/textView_device_mac"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?attr/textAppearanceCaption"
|
android:textAppearance="?attr/textAppearanceCaption"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user