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

Scan QR code from image file #3593

Merged
merged 2 commits into from
Aug 2, 2024

Conversation

Navid200
Copy link
Collaborator

There are times a QR code scan is not possible.
This is an example: #2960

This PR adds a new capability allowing the user to scan the QR code from a saved image file.


Tests
Android 8, 9, 11 and 15 have been tested.
The OB1 debug QR code, a saved settings QR code from xDrip, and the G7 QR code have been used for tests.


If you have any comments for improving the new strings, please do not hesitate to tell me.

If you see anything in the code that you don't like, please tell me.

Thanks

@Navid200
Copy link
Collaborator Author

Navid200 commented Jul 26, 2024

After this PR, tapping on auto config, will bring you to a new page shown below.
Screenshot_20240726-181754

Tapping on the button at the top does exactly what auto config button does now.
Tapping on the button at the bottom lets user go through the storage and choose an image file.
If the image file has the right format, it will be imported. If it doesn't, appropriate logs will be issued.

@Navid200
Copy link
Collaborator Author

Navid200 commented Jul 26, 2024

Tapping on the button at the bottom on the new page to scan from an image file, the user will see a page like this:



Screenshot_20240726-182730

It allows user to navigate through the different folders in storage to find the image file.
Tapping on the correct QR code image file, xDrip will show the confirmation request page for accepting the settings contained in the QR code. The same confirmation you see if you scan using the camera.

@Navid200
Copy link
Collaborator Author

Navid200 commented Aug 1, 2024

I just tested this using a Pixel (Android 7) virtual machine and it worked to confirm that it works on Android 7 as well.

@@ -39,6 +39,10 @@
<string name="pref_header_cloud_storage">Cloud Storage</string>
<string name="auto_configure_title">Auto configure</string>
<string name="prefs_auto_config_summary">Auto configure using a barcode.</string>
<string name="auto_config_cam_title">Scanner</string>
<string name="auto_config_cam_summary">Scan a QR code with your mobile (recommended)</string>
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't you mention "camera" here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I spent some time with ChatGPT for these. But, I see your point.
The problem is if I focus on the meaning of the sentence, saying scan with your camera, it may be taken as take a camera, not your phone, out of your pocket and use it to scan.

What if I change that to the following?

Scan a QR code with your mobile camera

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, I even confused myself. I will think about this and improve the strings.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How about this?

Title: Scanner (camera)
Summary: Scan a QR code with your mobile camera

android:key="auto_configure"
android:summary="@string/auto_config_cam_summary"
android:title="@string/auto_config_cam_title" />
<Preference
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't we just have these one underneath each other in the same way as other preferences?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Definitely! I can do that.

The only reason I did this was because I wanted to give more prominence to the existing scheme. I mean if user can use camera, they should never use the second option.
That's the only reason I did this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have made both of those changes.

This is what it looks like now:
Screenshot_20240802-131859

Choose a reason for hiding this comment

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

I'll probably keep the QR code on my storage somewhere and almost always use that instead of Camera. That way I don't have to hunt for the code every time I need to reconfigure my app for G7

@jamorham jamorham merged commit 31cc86e into NightscoutFoundation:master Aug 2, 2024
1 check passed
@Navid200 Navid200 deleted the Navid_2024_07_09 branch August 2, 2024 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants