Update MainActivity.kt
This commit is contained in:
parent
7136a33f63
commit
017199f318
@ -116,11 +116,13 @@ class MainActivity : AppCompatActivity() {
|
|||||||
// your code to perform when the user clicks on the button
|
// your code to perform when the user clicks on the button
|
||||||
|
|
||||||
// Toast.makeText(this@MainActivity, "You clicked me.", Toast.LENGTH_SHORT).show()
|
// Toast.makeText(this@MainActivity, "You clicked me.", Toast.LENGTH_SHORT).show()
|
||||||
|
if (tabLayout.selectedTabPosition == 0) {
|
||||||
if (isNumericAddress(ipInput.text.toString()) && portInput.text.toString()
|
if (isNumericAddress(ipInput.text.toString()) && portInput.text.toString()
|
||||||
.toInt() >= 0 && portInput.text.toString().toInt() <= 65535
|
.toInt() >= 0 && portInput.text.toString().toInt() <= 65535
|
||||||
) {
|
) {
|
||||||
saveSharedPref()
|
saveSharedPref()
|
||||||
val intent = Intent(this, ControlActivity::class.java).apply {
|
val intent = Intent(this, ControlActivity::class.java).apply {
|
||||||
|
putExtra("interface", "WiFi")
|
||||||
putExtra("ip", ipInput.text.toString())
|
putExtra("ip", ipInput.text.toString())
|
||||||
putExtra("port", portInput.text.toString())
|
putExtra("port", portInput.text.toString())
|
||||||
}
|
}
|
||||||
@ -130,6 +132,16 @@ class MainActivity : AppCompatActivity() {
|
|||||||
} else {
|
} else {
|
||||||
portLayout.error = getString(R.string.invalid_port)
|
portLayout.error = getString(R.string.invalid_port)
|
||||||
}
|
}
|
||||||
|
} else if (tabLayout.selectedTabPosition == 1) {
|
||||||
|
if(deviceAddress.text.isNotBlank()){
|
||||||
|
saveSharedPref()
|
||||||
|
val intent = Intent(this, ControlActivity::class.java).apply {
|
||||||
|
putExtra("interface", "Bluetooth")
|
||||||
|
putExtra("mac", deviceAddress.text.toString())
|
||||||
|
}
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -191,7 +203,11 @@ class MainActivity : AppCompatActivity() {
|
|||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||||
if (requestCode == BLUETOOTH_PERMISSION_CODE) {
|
if (requestCode == BLUETOOTH_PERMISSION_CODE) {
|
||||||
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
Toast.makeText(this@MainActivity, "Bluetooth Permission Granted", Toast.LENGTH_SHORT)
|
Toast.makeText(
|
||||||
|
this@MainActivity,
|
||||||
|
"Bluetooth Permission Granted",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
)
|
||||||
.show()
|
.show()
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(this@MainActivity, "Bluetooth Permission Denied", Toast.LENGTH_SHORT)
|
Toast.makeText(this@MainActivity, "Bluetooth Permission Denied", Toast.LENGTH_SHORT)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user