Repository navigation
Fix app not progressing after LoginActivity due to Bluetooth - #181
Conversation
| try { | ||
| this.serviceLocator.getBluetoothHandler().start(); | ||
| } catch (NoBluetoothException e) { | ||
| LOGGER.info("Bluetooth not available on device, hiding button"); |
There was a problem hiding this comment.
Can you show an information dialog to inform the user about this?
There was a problem hiding this comment.
I don't think that is necessary, as they are probably aware they don't have Bluetooth, right?
There was a problem hiding this comment.
I don't think it's necessary as well, but if you put
new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE) .setTitleText(getString(R.string.foo)) .setContentText(getString(R.string.bar)) .setConfirmText(getString(R.string.dialog_ok)) .setConfirmClickListener(null) .show();
in it, then the user doesn't even have to remember that he doesn't have Bluetooth
There was a problem hiding this comment.
That's why I'm hiding the Bluetooth button in the connection options
| final View v = this.findViewById(R.id.pairing_menu_bluetooth); | ||
| v.setVisibility(View.GONE); | ||
| } catch (IOException e) { | ||
| LOGGER.info("Bluetooth handler not started, most likely Bluetooth is not enabled"); |
There was a problem hiding this comment.
Could you show a dialog to inform the user about this and ask him if Bluetooth should be turned on?
This can help you: https://stackoverflow.com/questions/3806536/how-to-enable-disable-bluetooth-programmatically-in-android
| /** | ||
| * Simple {@link RuntimeException} that is used to notify usage of Bluetooth is not avaiable. | ||
| */ | ||
| public class NoBluetoothException extends RuntimeException { |
There was a problem hiding this comment.
Go to Settings -> Editor -> Inspections -> Java and enable everything from Class metrics, from Code style issues "Instance field access not qualified with this, Instance method not qualified with this", everything from concurrency and for this line of code specifically: everything from serialization. When you hover over the classname our brilliant idea will hint you to generate a serialversionuid and nice readobject/writeobject methods.
There was a problem hiding this comment.
And why do we want that? 😕
There was a problem hiding this comment.
class metrics, because you can't run SIG locally. instance field access / methods not qualified with this because you like to use this apparently. Everything from concurrency because it really are good practices and Checkstyle, PMD and Findbugs don't know anything about those. Everything from serialization, because serialversionuid: (copied from the documentation)
The serialization runtime associates with each serializable class a version number, called a serialVersionUID, which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization. If the receiver has loaded a class for the object that has a different serialVersionUID than that of the corresponding sender's class, then deserialization will result in an InvalidClassException. If a serializable class does not explicitly declare a serialVersionUID, then the serialization runtime will calculate a default serialVersionUID value for that class based on various aspects of the class, as described in the Java(TM) Object Serialization Specification. However, it is strongly recommended that all serializable classes explicitly declare serialVersionUID values, since the default serialVersionUID computation is highly sensitive to class details that may vary depending on compiler implementations, and can thus result in unexpected InvalidClassExceptions during deserialization. Therefore, to guarantee a consistent serialVersionUID value across different java compiler implementations, a serializable class must declare an explicit serialVersionUID value.
Also, http://index-of.es/JAVA/Effective%20Java.pdf , very bottom page 301. The readobject/writeobject are needed to that we can extend the exception with new fields in a later release. Great explanation at the beginning of page 299, http://index-of.es/JAVA/Effective%20Java.pdf
There was a problem hiding this comment.
instance field access / methods not qualified with this because you like to use this apparently.
Kind of a weird place to give this advice, but thanks anyway 😄
Everything from concurrency because it really are good practices...
Again, kinda of a weird place to mention this. Not getting any errors in this class from that...
Everything from serialization, because serialversionuid...
I added a serialVersionUID but am not convinced of adding a default readObject & writeObject method...
a3983ad
…ousfish into hotfix/no-bluetooth
What
The app on
developcurrently doesn't work when the emulator/device has no Bluetooth or Bluetooth not enabled, this is fixed with this PR.Why
We want the app on develop to be working as good as it can, so it is kinda important that you can use the app further then just the
LoginActivity.How
Open the app on an emulator, login and see for yourself that it works.
Alternative implementation
None considered, a working app is more important for now 😅
Notes
n/a