Don't show Bluetooth visibility dialog so often.
This commit is contained in:
parent
6eed89f8c0
commit
ee621a7d78
2 changed files with 19 additions and 4 deletions
|
@ -76,7 +76,9 @@ class FirstStartActivity extends AppCompatActivity with OnEditorActionListener w
|
||||||
}
|
}
|
||||||
|
|
||||||
def startMainActivity(): Unit = {
|
def startMainActivity(): Unit = {
|
||||||
startActivity(new Intent(this, classOf[MainActivity]))
|
val intent = new Intent(this, classOf[MainActivity])
|
||||||
|
intent.setAction(MainActivity.ActionRequestBluetooth)
|
||||||
|
startActivity(intent)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,18 @@ import com.nutomic.ensichat.protocol.Address
|
||||||
|
|
||||||
object MainActivity {
|
object MainActivity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If this action is set, a dialog will be shown to request the device to be discoverable.
|
||||||
|
*
|
||||||
|
* This should only be used when the app is started from a launcher
|
||||||
|
* (eg from [[FirstStartActivity]]).
|
||||||
|
*/
|
||||||
|
val ActionRequestBluetooth = "request_bluetooth"
|
||||||
|
|
||||||
val ActionOpenChat = "open_chat"
|
val ActionOpenChat = "open_chat"
|
||||||
|
|
||||||
val ExtraAddress = "address"
|
val ExtraAddress = "address"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,9 +44,13 @@ class MainActivity extends EnsichatActivity {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
|
|
||||||
val intent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE)
|
if (getIntent.getAction == MainActivity.ActionRequestBluetooth) {
|
||||||
intent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 0)
|
val intent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE)
|
||||||
startActivityForResult(intent, RequestSetDiscoverable)
|
intent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 0)
|
||||||
|
startActivityForResult(intent, RequestSetDiscoverable)
|
||||||
|
// Make sure this code isn't executed after screen rotate etc.
|
||||||
|
getIntent.setAction(null)
|
||||||
|
}
|
||||||
|
|
||||||
val fm = getFragmentManager
|
val fm = getFragmentManager
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
|
|
Reference in a new issue