Commit graph

179 commits

Author SHA1 Message Date
Berthold Stoeger
de313bd01a mobile: save changes from main event loop
When autosync to cloud was enabled, the old code would crash,
because it synced to cloud from a signal handler, which executed
the main loop when checking the cloud connection, which deleted
the object which was causing the original signal. Or something
like that. See discussion in #4119.

To avoid such problems, send a signal via a 'QueuedConnection'
from QMLManager to itself. The slot will be called once the
signal handler terminates and the main event loop retakes
control.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-04 13:57:00 +02:00
Berthold Stoeger
2172e18298 mobile: pull undo/redo notification text up
When changes need saving, the notification text was set quite
deep in the calltree in "saveChangesLocal()". I don't know why
this was put so deep in the call tree. In any case, it prevents
asynchronous saving of the data. Therefore, pull it up to
chnagesNeedSaving().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-04 13:57:00 +02:00
Dirk Hohndel
4b0fe3bc38 mobile: show incorrect cloud password state
While the startup flow should make it obvious when a user is not
correctly logged into the cloud, we still do see fairly frequent
situations where a user has an incorrect password on a mobile device and
is confused about why their data isn't syncing with their PC. Now this
is clearly shown in the main menu.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2024-02-23 20:12:12 -08:00
Dirk Hohndel
f144fa0a1b mobile: allow sharing files via email
This will allow the user of the mobile app to export dive and dive site
data from their mobile device without using the Subsurface cloud.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-08-31 13:58:22 -07:00
Dirk Hohndel
ead15f622a mobile: remove export as UDDF
The export functionality is horridly poorly implemented, and the UDDF export
isn't actually functional on mobile. And why would we support this in the first
place? That's not a reasonable expectation for the mobile app.

So let's just completely remove that and good riddance.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-08-31 13:58:22 -07:00
Dirk Hohndel
87387b7e7e mobile: send logfiles as attachments on iOS as well
This was added for Android a while ago, but now this works on iOS as well which
is a very welcome addition for the recipient of these support emails (i.e. me).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-08-30 09:18:06 -07:00
Dirk Hohndel
32bc034f41 mobile: add ability to delete cloud account
Apple store rules require this.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-08-13 14:08:37 -07:00
Berthold Stoeger
9e0712d5dc core: replace dive master by dive guide
In general, replace "dive master" by "dive guide".

However, do not change written dive logs for now. On reading,
accept both versions.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-02-15 09:35:43 -08:00
Linus Torvalds
85392343fa Re-do the libdivecomputer fingerprint save/load code
This tries to make our fingerprinting code work better, by avoiding
using the "deviceid" field that has always been unreliable because we've
calculated it multiple different ways, and even for the same version of
subsurface, it ends up changing in the middle (ie we calculate one value
initially, then re-calculate it when we have a proper serial number
string).

So instead, the fingerprinting code will look up and save the
fingerprint file using purely "stable" information that is available
early during the download:

 - the device model name (which is a string with vendor and product name
   separated by a space)

 - the DC_EVENT_DEVINFO 32-bit 'serial' number (which is not necessarily
   a real serial number at all, but hopefully at least a unique number
   for the particular product)

but because the model name is not necessarily a good filename (think
slashes and other possibly invalid characters), we hash that model name
and use the resulting hex number in the fingerprint file name.

This way the fingerprint file is unambiguous at load and save time, and
depends purely on libdivecomputer data.

But because we also need to verify that we have the actual _dive_
associated with that fingerprint, we also need to save the final
deviceid and diveid when saving the fingerprint file, so that when we
load it again we can look up the dive and verify that we have it before
we use the fingerprint data.

To do that, the fingerprint file itself contains not just the
fingerprint data from libdivecomputer, but the last 8 bytes of the file
are the (subsurface) deviceid and the diveid of the dive that is
associated with the fingerprint.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-09-19 16:51:46 -07:00
Dirk Hohndel
6f813b9f8e mobile: remove GpsLocation
Only used in context of acquiring GPS locations with the mobile app, which
we no longer do.

Keep the DiveAndLocation structure around as that's needed by the
ApplyGpsFixes command.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-09-13 11:21:34 -07:00
Dirk Hohndel
5bc99194da mobile: remove locationService interfaces
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-09-13 11:21:34 -07:00
Dirk Hohndel
7bf90fd208 mobile: remove hasLocationSourceChanged interface
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-09-13 11:21:34 -07:00
Dirk Hohndel
085c65b0c4 mobile: remove logText property
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-09-13 11:21:34 -07:00
Dirk Hohndel
f33c90ba6b mobile: remove deleteGpsFix interface
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-09-13 11:21:34 -07:00
Dirk Hohndel
094a3b01c8 mobile: remove applyGpsData interface
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-09-13 11:21:34 -07:00
Dirk Hohndel
0b8c8599c1 mobile: remove copyGpsFixesToClipboard interface
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-09-13 11:21:34 -07:00
Dirk Hohndel
3065eddbe1 mobile: remove clearGpsData interface
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-09-13 11:21:34 -07:00
Dirk Hohndel
ea751928aa mobile: remove getCurrentPosition interface
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-09-13 11:21:34 -07:00
Dirk Hohndel
bea552bf0d mobile: remove GpsListModel
This is only needed to show the list of GPS fixes obtained with
the now removed location service.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-09-13 11:21:34 -07:00
Dirk Hohndel
f19e10209c mobile: fix broken cylinder name tracking in dive edit
Prior to this change, we had two different cylinder lists as models for
drop down boxes - one that prepends the "no default cylinder" entry
(which we need for setting up no default cylinder to be used in the
app), and another one that only includes actual cylinders.

The problem occured if a dive is created before the first time we edit
an existing dive: in this case we are applying indices across the two
models, but the indices are of course off by one; this results in
actually picking the wrong cylinder. So each time we try to edit a dive,
we end up with the previous cylinder in the list.

This commit simplifies the code by having only one place where we create
list of cylinder names (which is then used as the model for the combo
box). It also uses more logical names for the two 'flavors' of this list
to make it clear which one is supposed to be used (the regular list when
editing or adding dives, the one with the "no default cylinder" entry
prependet for the Settings page).

Reported-by: Brian Fransen
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-09-02 12:41:00 -07:00
Dirk Hohndel
9b669d91e0 mobile: add ability to edit tags
We already showed the tags, but we didn't allow the user to edit them.

This tries hard not to create inconsistent or illogical tags by trimming
white space and being careful with how the tags are added.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-08-18 19:09:59 -07:00
Dirk Hohndel
64dea827bd mobile/debugging: copy GPS fixes to clipboard
The goal is to enable a user experiencing crashes when applying GPS data
to their dive log to make all necessary data available to the
developers. Hopefully the clipboard is large enough to hold all the
data.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-23 13:19:11 -08:00
Dirk Hohndel
e1cb368437 mobile/UI: show notification with changes made after save
Since we save after every operation in the mobile app, this allows us to
tell the user what we actually saved - and we can remind the user that
they can undo/redo the last operation.

The code gets more complicated because in the case that the operation
that triggered this change was an undo, we need to show the redo text to
describe what we are saving, and must point the user to the redo
operation.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-19 12:42:47 -08:00
Dirk Hohndel
c6f134a9b1 mobile: replace locationProvider with calls to GpsLocation::instance()
This makes it more obvious what we are doing. And won't make any difference
from a performance perspective.

Also converted the last call to connect using the old syntax to the new syntax.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-02 12:47:15 -08:00
Berthold Stoeger
79f95b7f7d core: remove DiveObjectHelper
Since switching to the mobile-models and removing grantlee,
DiveObjectHelper was demoted to a thin wrapper around string
formatting functions. The last user was removed in a previous
commit.

It was never a good idea, given QML's strange memory-management.
Let's remove it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-17 13:03:56 -08:00
Berthold Stoeger
1037c15b98 mobile: remove DiveObjectHelper code
When editing a dive, a DiveObjectHelper of the unmodified dive
was created to compare the edited with the old values. Since
the DiveObjectHelper is used here only as a pointless wrapper
around the formatting functions, call these functions directly.

However, note that the code is in principle wrong since the
change to the mobile-models, which do not use the DiveObjectHelper.
The real fix would be to reload the data from the model to prevent
going out-of-sync with respect to the formatting routines!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-17 13:03:56 -08:00
Dirk Hohndel
1a0cf0bb44 cleanup: remove struct/class confusion
DiveSiteChange is defined as a struct, not as a class.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26 19:27:03 -07:00
Dirk Hohndel
3a409c51ea mobile: add status text for cloud sync state
This allows the mobile UI to reflect the three states that the dive list can be
in:
- changes that haven't been written to local storage
- there potentially are changes in local storage that were not synced with the cloud
- dive list is in sync with cloud storage

The last state could be misleading if the user access the cloud from a
different device and makes changes to the cloud storage from there, but from
the point of view of this device, the states are consistent.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-14 13:35:33 -07:00
Dirk Hohndel
01de67a5a6 mobile: track if we have changes that aren't synced to cloud
If we haven't connected at all to the cloud server we assume that there are
local changes. And whenever we save changes only locally, we also set that
flag.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-14 13:35:33 -07:00
Dirk Hohndel
208d46d58e mobile: add helper to import data from local cloud cache
If you pass in the repo name, it isn't treated as cloud storage, but simply as
local git storage and imported (i.e., added) to the current dive list.

This allows the user to work around failed no-cloud->cloud transitions, merge
different accounts, and most importantly deal with situations were conflicts on
the server caused us to move a cache out of the way and potentially make dives
that were on the mobile device inaccessible to the user.

Once a UI is added, this allows the user to recover those dives (realistically
this is not really all that potentially 'dangerous' to do, but it's definitely
something that would best be done after talking to someone who understands the
cloud storage and can guide the user...).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-07 19:47:52 -07:00
Dirk Hohndel
dd82149726 mobile: make list of local cloud cache directories available
This way QML can show those to the user.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-07 19:47:52 -07:00
Dirk Hohndel
8414f83926 mobile/cleanup: create helper function to hide verbose casts
The strange enum casts (that apparently we needed in order to have strongly typed
enums in QML) are really ugly and confusing in the code. Since we had this three
times it seemed worth to create a little helper that hides this nonsense.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 16:10:50 -07:00
Dirk Hohndel
e43362fdcf mobile/download-from-DC: ensure that changes get actually saved
Calling saveChangesLocal() seems like the right thing to do, but it
doesn't do anything useful if the dive list hasn't been marked as
changed. The correct helper function to call is changesNeedSaving()
which makes sure we save the changes and update all UI information.

[Berthold: since this removes the last QML caller of saveChangesLocal()
we can make that function private.]

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-04 12:00:25 -07:00
Dirk Hohndel
0e1b784afe mobile/core: remove locking for git access
We have convinced ourselves that only the main thread will ever trigger
a save operation, therefore the locking is not needed (and it has
recently started to cause user problems where local changes aren't saved
to storage and get lost).

Fixes #2718

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 12:00:25 -07:00
Dirk Hohndel
a37499bccd mobile: add indication if the app has finished initializing
This will help us to ensure that notifications are actually shown on the
UI during the startup phase.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 12:00:24 -07:00
Berthold Stoeger
d13f73001b cleanup: make QMLManager member functions private
The
	- mergeLocalRepo()
	- openLocalThenRemote()
functions were not invoked from outside QMLManager.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-31 08:56:45 -07:00
Berthold Stoeger
eef41a3403 cleanup: remove loadFromCloud() declaration from QMLManager.h
This getter functions was not defined anywhere.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-31 04:18:34 -07:00
Berthold Stoeger
45a3fff62c cleanup: fix initialization order in QMLProfile constructor
The compiler complains that members were initialized out-of-order.
Even though this is not an issue here it is correct to emit a
warning, since only then it is guaranteed that the objects are
destructed in reverse-order with respect to construction.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-30 13:58:10 -07:00
Berthold Stoeger
38d70ba854 cleanup: un-slotify QMLManager functions
Some slots in QMLManager were not called from the outside, some
only directly from C++-code. Make the former private and the latter
public member functions.

The idea here is to document which functions are actually called
from the outside and which are called from QML or connected to
signals.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-30 13:58:10 -07:00
Dirk Hohndel
2e07e9345f mobile/dive-list: add indicator that dive list is being processed
This should deal with the rather confusing 'No dive in dive list' shown
while loading and processing the dive list.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-30 09:16:55 -07:00
Dirk Hohndel
d12e86cb2b mobile/cleanup: use a mutex to protect storage access
Instead of the crude and error prone bool, let's just use the right tool
for this job.

In order to avoid issues with a goto across a mutex boundary, this
slightly restructures the code in one place - 'git show -w' makes it
clear that this is really rather simple in its changes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-29 12:36:57 -07:00
Dirk Hohndel
98966fdd8a mobile/save-changes: untangle the handling of alreadySaving
I'm suspicious that an issue that some people have seen around changes
not being saved is caused by our handling of alreadySaving.
When starting with Subsurface-mobile in no-autosync mode, we were able
to end in a scenario where alreadySaving was true, even though there
were no unsaved changes. And in that case no changes made during such a
session were saved unless the user forced a manual sync with the server.

This commit radically changes our approach to handling the flag. It
moves it right next to the actual calls into code that could modify git
storage, and ensures that the flag can never stay set.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-28 11:00:09 -07:00
Dirk Hohndel
66fd93c9cc mobile/dive-list: add ability to create trip
This adds a context menu entry for top level dives that allows the user
to create a trip for that dive.

Unfortunately this creates a new string to translate right before a
release...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-26 12:59:00 -07:00
Dirk Hohndel
30e6102886 mobile/divelist: add UI to toggle dive invalid flag
This reuses the corresponding undo command.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-21 14:31:37 -07:00
Berthold Stoeger
568a8d6254 mobile: remove QMLManager::updateSiteList()
The location information model is updated automatically by the
divelist-model and the undo commands. Therefore remove the
QMLManager::updateSiteList() function. We do have to keep
the locationListChanged() signal though, because the list
of dive sites is not exported via model/view but rather via
a Q_PROPERTY. We really should change that.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-18 13:27:16 -07:00
Dirk Hohndel
8e7711c054 mobile/cleanup: remove the second access to cloud data
While I remember some of the thinking that went into doing things this way,
the more I read the code, the less it makes sense to me.

This is a rather drastic step, but in reasonably extensive testing it seems
to work in every case that I tried.

That's rather embarrassing, actually.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-17 16:49:53 -07:00
Dirk Hohndel
0b72495413 android/usb: simply restart the download after receiving permission
If the user tries to download from a device that he hasn't given the app
permission to read from, Android will pop up a dialogue asking for that
permission. With this after giving the permission we continue (well,
technically, restart) the download which is likely the expected behavior.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
ff2f199eed mobile UI: rescan button on DC Download page rescans BT/BLE/USB
This way even if a USB device wasn't added through an Android intent, we
still have a way to scan for it and select it. This is especially
important in case a user has a cable that we haven't seen yet (i.e. with
a VID/PID that we haven't added to Subsurface-mobile), but that
nevertheless works with the android usb serial drivers.

This also makes the flow a little more logical / consistent when
deciding which connections to show.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
ec3a968df9 android/usb: pass in the UsbDevice when downloading
This finally allows us to download from not just the first device, but specifically
the device that the user picks.

Passing the object through a void pointer is not nice - but since this traverses
C code other solutions (like passing an index into the list) seemed even worse.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
4cd453dc92 android/usb: parse the usbDevice when responding to intent
This vastly simplifies our handling of devive information as we simply use
what is already in the descriptor. This way we do not duplicate information
about USB devices in the QMLManager.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00