Commit graph

489 commits

Author SHA1 Message Date
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
Michael Keller
df1974a244 Mobile: Fix Configuration of Ceiling Display.
Fix the configuration of the deco ceilings in the mobile version:
- make the settings work;
- remove reading of the dive computer ceiling from git;
- hide the gradient factor in the profile when the calculated ceiling is
  not shown;
- when the calculated ceiling is disabled in the settings, disable
  editing of the gradient factor.

Signed-off-by: Michael Keller <github@ike.ch>
2024-02-06 11:58:49 +13:00
Berthold Stoeger
c5d6e0f44f core: make owning pointers a top-level features
The undo-code uses owning pointers based on std::unique_ptr to
manage lifetime of C-objects. Since these are generally useful,
move them from the undo-code to the core-code. In fact, this
eliminates one instance of code duplication.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
b61732da42 core: remove autogroup global
Use the flag in the divelog structure, since this will be saved
in the dive log.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2023-04-14 21:20:23 +02:00
Berthold Stoeger
9c253ee6c5 core: introduce divelog structure
The parser API was very annoying, as a number of tables
to-be-filled were passed in as pointers. The goal of this
commit is to collect all these tables in a single struct.
This should make it (more or less) clear what is actually
written into the divelog files.

Moreover, it should now be rather easy to search for
instances, where the global logfile is accessed (and it
turns out that there are many!).

The divelog struct does not contain the tables as substructs,
but only collects pointers. The idea is that the "divelog.h"
file can be included without all the other files describing
the numerous tables.

To make it easier to use from C++ parts of the code, the
struct implements a constructor and a destructor. Sadly,
we can't use smart pointers, since the pointers are accessed
from C code. Therfore the constructor and destructor are
quite complex.

The whole commit is large, but was mostly an automatic
conversion.

One oddity of note: the divelog structure also contains
the "autogroup" flag, since that is saved in the divelog.
This actually fixes a bug: Before, when importing dives
from a different log, the autogroup flag was overwritten.
This was probably not intended and does not happen anymore.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2023-04-14 21:20:23 +02:00
Berthold Stoeger
261f07dfa4 core: add make_manually_added_dc() function
For reasons of symmetry (there is a is_manually_added_dc()
function), create a make_manually_added_dc() function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-21 16:51:57 -07:00
Berthold Stoeger
f687e51d4b core: don't consider dives with many samples as manually added
This causes UI confusion. Notably we go into edit mode and
reduce the number of samples, leading to loss of information.

If someone really manually adds a dive with more than 50
samples, they should still be able to explicitly open the
dive in the planner.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-21 16:51:57 -07: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
2ae7f3cf6c Android: make support email API consistent with iOS
We have two different API endpoints. supportEmail() which adds the
default subject, recipient, and message body, and the generic
shareViaEmail() which takes all of these as arguments.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-08-30 11:55:54 -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
8c644547fb mobile: fix reading of cache dir
For some reason the flag to exclude . and .. breaks this functionality.
It works just fine without that flag, so let's just remove it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-08-28 19:51:03 -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
Linus Torvalds
e33680c336 git access: add proper cleanup function for git_info
We had various random "free parts of the git info" left-overs from when
we passed down the git repo data ad-hoc.  Get rid of it, and replace it
with just doing a 'cleanup_git_info()' that does the final cleanup of it
all.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-04-22 08:28:17 -07:00
Linus Torvalds
96337dbbcf git access: rename 'check_git_sha()' function
That function name was incomprehensible.  What did it check? And what
did the return value mean?

So let's rename it to something that actually describes what it does,
and reverse the meaning of the return value while at it.

So now it's called 'remote_repo_uptodate()', and it returns true if the
remote repository branch has the same value as our 'saved_git_id'.

It's still a bit obscure, but at least within the context of the only
user, the code now makes _more_ sense than it used to:

        if (remote_repo_uptodate(fileNamePrt.data(), &info)) {
                appendTextToLog("Cloud sync shows local cache was current");

but maybe we could come up with even better semantics and naming, and
make it even clearer.

Requested-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-04-22 08:28:17 -07:00
Linus Torvalds
7e632173e0 Collect and convert git repo data to 'struct git_info'
We have this nasty habit of randomly passing down all the different
things that we use to look up the local and remote git repository, and
the information associated with it.

Start collecting the data into a 'struct git_info' instead, so that it
is easier to manage, and easier and more logical to just look up
different parts of the puzzle.

This is a fairly mechanical conversion, but has moved all the basic
information collection to the 'is_git_repository()' function.  That
function no longer actually opens the repository (so the 'dry_run'
argument is gone, and instead a successful 'is_git_repository()' is
followed by 'opn_git_repository()' if you actually want the old
non-dry_run semantics.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-04-17 22:14:34 -07:00
Dirk Hohndel
2886104b1d mobile: allow date only when adding/editing dives
Apparently some people try to manually enter older dives where they don't
have data about the dive time and therefore want to only capture the dive
date.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-03-18 08:57:55 -07:00
Dirk Hohndel
ccda4f557c mobile: fix broken undo stack initialization
We would dereference the undoAction before the command infrastructure
was initialized which led to a crash in the mobile app.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-03-18 08:57:55 -07:00
Dirk Hohndel
83d6143f97 Android: use shareFile for support email
This way we can have attachment of fairly arbitrary size (which should
be extremely useful for long libdivecomputer logs). This isn't quite as
intuitive as what we did before - the user needs to pick an email app to
share with), but that doesn't seem too bad - and also... this way they
can share logfiles via Dropbox or analyze them in other apps).

If the file share fails for some reason, we fall back to the old method
with passing the combined logs as body to the support message.

As an implementation detail this keeps the correct path for the app log file around
(this was stupidly overwritten before).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-03-01 14:16:25 -08:00
Dirk Hohndel
43ed2e1224 Android: use a sharable location for our files
The first location we should try is one that allows us to share files.
In theory this should work on every device, but we do have a few
fall-backs, just in case.

This also moves the Android specific include to the top which seems much
more standard.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-03-01 14:16:25 -08: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
Berthold Stoeger
c893d19ea4 cleanup: pass all parameters to weightsystem_t
With -Wextra, gcc/g++ complains that compound initialization
of weightsystem_t misses the auto_filled parameter. Add it.
For C++ code we might think about writing a constructor. However,
we use two versions: with and without copied string.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-01-02 13:51:07 -08:00
Dirk Hohndel
1e527fb9f0 mobile: correctly store manually entered GPS
If there was no pre-existing dive site for a dive, manually entered GPS
information didn't get saved.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-11-24 11:13:46 -08:00
Dirk Hohndel
cfd6a1634f cleanup: fix SkipEmptyParts warning for mobile
And while doing that, have all the cases where we already include
qthelper.h simply use a define in that header file - but keep the two
other instances of the define where the C++ source don't need qthelper.h
otherwise.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-11-24 10:53:26 -08:00
Dirk Hohndel
ee87d28d7b cleanup: replace QRegExp with QRegularExpression
Qt 6 will drop support for QRegExp.
Use QRegularExpression instead.

The exactMatch in getVersion() was rather bogus, given the pattern.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-10-27 12:38:11 -07:00
Dirk Hohndel
5e9ee9febb mobile: restore dev_info display
In commit 105b60389c ("mobile: remove GpsLocation reference from qmlmanager") I
was a bit careless with the code removal and unintentionally also removed the
initialization of the progress callback.  With this change the updates from the
download process are once again shown on screen in the mobile app.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-09-27 08:42:50 -07: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
2a0d14b100 core: remove location service preferences
Including the related tests.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-09-13 11:21:34 -07:00
Dirk Hohndel
105b60389c mobile: remove GpsLocation reference from qmlmanager
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
454207cd80 mobile: make cloud timeouts more consistent
In the mobile version we should always allow a little more wait time for
the cloud server - there just seem to be more issues with response times
on mobile devices, especially when in places with poor data reception
(which isn't uncommon for dive sites).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-08-18 19:09:59 -07:00
Berthold Stoeger
16b31985c3 cleanup: replace membuffer by membufferpp in C-code
Thus, the membuffer data is automatically freed when going
out of scope - one thing less to worry about.

This fixes one use-after-free bug in uploadDiveLogsDE.cpp
and one extremely questionable practice in divetooltipitem.cpp:
The membuffer was a shared instance across all instances
of the DiveToolTipItem.

Remves unnecessary #include directives in files that didn't
even use membuffer.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-07-23 11:22:43 -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
126329ab7c mobile/UI: add button to change notification
This is fun... with just a tiny bit of 'magic text parsing' we can allow
the backend code to add a button to the notification that will open the
context menu that will make it super obvious to the user how they can
undo an operation.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-19 12:42:47 -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
fa8ac5ceeb mobile/UI: normally don't show git progress info to user
This isn't really useful for normal users and with the new 'multiple
notifications stay visible' feature in Kirigami it creates a really
weird and distracting user experience.
We should show the user a summart of what we did instead.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-19 12:42:47 -08:00
Dirk Hohndel
274b3c786b mobile/git-storage: ensure correct commit messages get saved
In order to get the undo stack information into the commit message, we
need to actually call Command::init() to set up the callback.

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
Dirk Hohndel
5048a695aa mobile: turn GpsLocation into a regular singleton construct
Simply move the initialization of the logging function into its own method and
call that in the QMLManager constructor.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-02 12:47:15 -08:00
Dirk Hohndel
53b572f987 mobile: don't connect to applicationStateChanged signal early
We don't want to connect to this until all parts of the QMLManager object are set up.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-02 12:47:15 -08:00