Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: gas sensor automatic record without sensor #2153

Closed

Conversation

SpandanBasu
Copy link

Fixes #2093

Changes: Changes are made in PSLabSensor.java at onOptionsItemSelected(MenuItem item) function a check is added for gas sensor. (If a gas sensor is connected, only then a recording of data will start)

Screenshot/s for the changes:
https://user-images.githubusercontent.com/62503399/103482147-193a8280-4e05-11eb-829d-38a307c52344.mp4
https://user-images.githubusercontent.com/62503399/103482149-1a6baf80-4e05-11eb-9afc-de0b85f6525b.mp4
https://user-images.githubusercontent.com/62503399/103482150-1b044600-4e05-11eb-9a74-d8601a9d366f.mp4

Checklist:

  • [x ] I have used resources from strings.xml, dimens.xml and colors.xml without hard-coding them
  • No modifications done at the end of resource files strings.xml, dimens.xml or colors.xml
  • [x ] I have reformatted code in every file included in this PR [CTRL+ALT+L]
  • My code does not contain any extra lines or extra spaces
  • I have requested reviews from other members

APK for testing:
app-fdroid-debug.zip

@@ -10,6 +10,7 @@
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.util.Log;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

@@ -886,6 +886,9 @@
<string name="gas_sensor_description">Air quality sensor for detecting a wide range of gases, including NH3, NOx, alcohol, benzene, smoke and CO2</string>
<string name="gas_sensor_label">Gas Contents (PPM)</string>
<string name="gas_sensor_unit">PPM</string>
<string name="gas_sensor_not_connected">Sensor not Found</string>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<string name="gas_sensor_not_connected">Sensor not Found</string>
<string name="gas_sensor_not_connected">Sensor not found</string>

@@ -886,6 +886,9 @@
<string name="gas_sensor_description">Air quality sensor for detecting a wide range of gases, including NH3, NOx, alcohol, benzene, smoke and CO2</string>
<string name="gas_sensor_label">Gas Contents (PPM)</string>
<string name="gas_sensor_unit">PPM</string>
<string name="gas_sensor_not_connected">Sensor not Found</string>
<string name="gas_sensor_not_connected_description">Please connect a device or choose an phone sensor (if available)</string>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use existing device not connected message instead of this

Comment on lines 347 to 374
else
{
try {
CustomSnackBar.showSnackBar(sensorParentView, NOT_CONNECTED, null, null, Snackbar.LENGTH_LONG);

AlertDialog.Builder builder1 = new AlertDialog.Builder(this);
builder1.setTitle(R.string.gas_sensor_not_connected);
builder1.setMessage(R.string.gas_sensor_not_connected_description);
builder1.setCancelable(true);

builder1.setPositiveButton(
R.string.gas_sensor_configure_button,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});

builder1.setNegativeButton(
R.string.cancel,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
builder1.setIcon(android.R.drawable.ic_dialog_alert);
AlertDialog alert11 = builder1.create();
alert11.show();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need of many dialog boxes

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, sure I will resolve these issues very soon. Thanks.

@SpandanBasu
Copy link
Author

All changes are done, Please review this

Copy link
Collaborator

@CloudyPadmal CloudyPadmal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Need to reformat to fix spacing and indentation

Comment on lines 345 to 356
}
else
{
try {
CustomSnackBar.showSnackBar(sensorParentView, NOT_CONNECTED, null, null, Snackbar.LENGTH_LONG);

}catch (IllegalStateException e)
{
e.printStackTrace();
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reformat this file using Android Studio

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

@SpandanBasu
Copy link
Author

Spaces and indentation perfected

Copy link
Collaborator

@CloudyPadmal CloudyPadmal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PSLab.java is an abstract class. We don't implement unit specific features inside an abstract class. Instead that is done inside the class extending it.

@CloudyPadmal CloudyPadmal added the Fix Solution to an existing issue in app label Apr 1, 2021
@CloudyPadmal CloudyPadmal changed the title Fixed Gas Sensor automatic Record without Sensor fix: gas sensor automatic record without sensor Apr 1, 2021
@CloudyPadmal CloudyPadmal added the Status: Abandoned Creator doesn't follow up on the task anymore label Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Solution to an existing issue in app Status: Abandoned Creator doesn't follow up on the task anymore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Recording start even when device not connected
2 participants