|
|
|
@ -116,11 +116,13 @@ class MainActivity : AppCompatActivity() {
|
|
|
|
|
// your code to perform when the user clicks on the button
|
|
|
|
|
|
|
|
|
|
// Toast.makeText(this@MainActivity, "You clicked me.", Toast.LENGTH_SHORT).show()
|
|
|
|
|
if (tabLayout.selectedTabPosition == 0) {
|
|
|
|
|
if (isNumericAddress(ipInput.text.toString()) && portInput.text.toString()
|
|
|
|
|
.toInt() >= 0 && portInput.text.toString().toInt() <= 65535
|
|
|
|
|
) {
|
|
|
|
|
saveSharedPref()
|
|
|
|
|
val intent = Intent(this, ControlActivity::class.java).apply {
|
|
|
|
|
putExtra("interface", "WiFi")
|
|
|
|
|
putExtra("ip", ipInput.text.toString())
|
|
|
|
|
putExtra("port", portInput.text.toString())
|
|
|
|
|
}
|
|
|
|
@ -130,6 +132,16 @@ class MainActivity : AppCompatActivity() {
|
|
|
|
|
} else {
|
|
|
|
|
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)
|
|
|
|
|
if (requestCode == BLUETOOTH_PERMISSION_CODE) {
|
|
|
|
|
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()
|
|
|
|
|
} else {
|
|
|
|
|
Toast.makeText(this@MainActivity, "Bluetooth Permission Denied", Toast.LENGTH_SHORT)
|
|
|
|
|