Skip to content

Commit

Permalink
Merge branch 'master' into dev-2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasMizera committed Aug 22, 2023
2 parents 4788ba4 + 2514b9c commit 2ea2550
Show file tree
Hide file tree
Showing 120 changed files with 9,805 additions and 2,636 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Mergin Maps Input app features touch optimised GUI components based on Qt Quick
* Support for capturing of new geometries
* Display and editing of feature forms
* Built-in service for storing and synchronising data ([Mergin Maps](https://merginmaps.com/))
* Translated to several [languages](https://www.transifex.com/lutra-consulting/input)
* Translated to several [languages](https://explore.transifex.com/lutra-consulting/mergin-maps-input/)

<p float="left">
<img align="centre" src="https://github.com/MerginMaps/input/blob/master/images/screen1.jpg" width="20%">
Expand Down
55 changes: 44 additions & 11 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,18 @@ set(MM_SRCS
maptools/splittingmaptool.cpp
ios/iosimagepicker.cpp
ios/iosutils.cpp
position/abstractpositionprovider.cpp
position/internalpositionprovider.cpp
position/providers/abstractpositionprovider.cpp
position/providers/internalpositionprovider.cpp
position/providers/positionprovidersmodel.cpp
position/providers/simulatedpositionprovider.cpp
position/tracking/abstracttrackingbackend.cpp
position/tracking/internaltrackingbackend.cpp
position/tracking/positiontrackinghighlight.cpp
position/tracking/positiontrackingmanager.cpp
position/geoposition.cpp
position/mapposition.cpp
position/positiondirection.cpp
position/positionkit.cpp
position/positionprovidersmodel.cpp
position/simulatedpositionprovider.cpp
activelayer.cpp
activeproject.cpp
androidutils.cpp
Expand Down Expand Up @@ -105,13 +110,18 @@ set(MM_HDRS
maptools/splittingmaptool.h
ios/iosimagepicker.h
ios/iosutils.h
position/abstractpositionprovider.h
position/internalpositionprovider.h
position/providers/abstractpositionprovider.h
position/providers/internalpositionprovider.h
position/providers/positionprovidersmodel.h
position/providers/simulatedpositionprovider.h
position/tracking/abstracttrackingbackend.h
position/tracking/internaltrackingbackend.h
position/tracking/positiontrackinghighlight.h
position/tracking/positiontrackingmanager.h
position/geoposition.h
position/mapposition.h
position/positiondirection.h
position/positionkit.h
position/positionprovidersmodel.h
position/simulatedpositionprovider.h
activelayer.h
activeproject.h
androidutils.h
Expand Down Expand Up @@ -155,9 +165,9 @@ set(MM_HDRS
)

if (HAVE_BLUETOOTH)
set(MM_SRCS ${MM_SRCS} position/bluetoothpositionprovider.cpp)
set(MM_SRCS ${MM_SRCS} position/providers/bluetoothpositionprovider.cpp)

set(MM_HDRS ${MM_HDRS} position/bluetoothpositionprovider.h)
set(MM_HDRS ${MM_HDRS} position/providers/bluetoothpositionprovider.h)
endif ()

if (ENABLE_TESTS)
Expand Down Expand Up @@ -213,14 +223,23 @@ if (ENABLE_TESTS)
endif ()

if (IOS)
set(MM_HDRS ${MM_HDRS} ios/iosinterface.h ios/iosviewdelegate.h)
set(MM_HDRS
${MM_HDRS}
ios/iosinterface.h
ios/iosviewdelegate.h
position/tracking/iostrackingbackend.h
position/tracking/iostrackingbackendimpl.h
)

set(MM_SRCS
${MM_SRCS}
ios/iosinterface.mm
ios/iosviewdelegate.mm
ios/iosimagepicker.mm
ios/iosutils.mm
position/tracking/iostrackingbackend.cpp
position/tracking/iostrackingbackend.mm
position/tracking/iostrackingbackendimpl.mm
)
endif ()

Expand All @@ -230,6 +249,16 @@ if (HAVE_APPLE_PURCHASING)
set(MM_SRCS ${MM_SRCS} ios/iospurchasing.mm)
endif ()

if (ANDROID)
set(MM_HDRS ${MM_HDRS} position/tracking/androidtrackingbackend.h
position/tracking/androidtrackingbroadcast.h
)

set(MM_SRCS ${MM_SRCS} position/tracking/androidtrackingbackend.cpp
position/tracking/androidtrackingbroadcast.cpp
)
endif ()

qt_add_resources(
MM_SRCS
img/pics.qrc
Expand Down Expand Up @@ -476,6 +505,10 @@ endif ()

if (LNX)
target_link_libraries(Input PUBLIC Glib2::Glib2)
endif()

if (IOS)
target_link_libraries(Input PUBLIC AppleFrameworks::CoreLocation)
endif ()

if (HAVE_APPLE_PURCHASING)
Expand Down
50 changes: 50 additions & 0 deletions app/activeproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#include "activeproject.h"
#include "coreutils.h"

#ifdef ANDROID
#include "position/tracking/androidtrackingbroadcast.h"
#endif

const QString ActiveProject::LOADING_FLAG_FILE_PATH = QString( "%1/.input_loading_project" ).arg( QStandardPaths::standardLocations( QStandardPaths::TempLocation ).first() );

ActiveProject::ActiveProject( AppSettings &appSettings
Expand Down Expand Up @@ -101,6 +105,12 @@ bool ActiveProject::forceLoad( const QString &filePath, bool force )
// clear autosync
setAutosyncEnabled( false );

// clear position tracking broadcast listeners
#ifdef ANDROID
disconnect( &AndroidTrackingBroadcast::getInstance() );
AndroidTrackingBroadcast::unregisterBroadcast();
#endif

// Just clear project if empty
if ( filePath.isEmpty() )
{
Expand Down Expand Up @@ -181,6 +191,7 @@ bool ActiveProject::forceLoad( const QString &filePath, bool force )

emit localProjectChanged( mLocalProject );
emit projectReloaded( mQgsProject );
emit positionTrackingSupportedChanged();
}

bool foundInvalidLayer = false;
Expand Down Expand Up @@ -225,6 +236,30 @@ bool ActiveProject::forceLoad( const QString &filePath, bool force )
setAutosyncEnabled( true );
}

// in case tracking is running, we want to show the UI
#ifdef ANDROID
if ( positionTrackingSupported() )
{
connect(
&AndroidTrackingBroadcast::getInstance(),
&AndroidTrackingBroadcast::aliveResponse,
this,
[this]( bool isAlive )
{
if ( isAlive )
{
emit startPositionTracking();
}
},
Qt::SingleShotConnection
);

// note: order matters in the following calls
AndroidTrackingBroadcast::registerBroadcast();
AndroidTrackingBroadcast::sendAliveRequestAsync();
}
#endif

return res;
}

Expand Down Expand Up @@ -447,6 +482,11 @@ void ActiveProject::updateRecordingLayers()
mRecordingLayerPM.refreshData();
}

bool ActiveProject::isProjectLoaded() const
{
return mQgsProject && !mQgsProject->fileName().isEmpty();
}

void ActiveProject::setActiveLayer( QgsMapLayer *layer ) const
{
if ( !layer || !layer->isValid() )
Expand Down Expand Up @@ -477,3 +517,13 @@ const QString &ActiveProject::mapTheme() const
{
return mMapTheme;
}

bool ActiveProject::positionTrackingSupported() const
{
if ( !isProjectLoaded() )
{
return false;
}

return mQgsProject->readBoolEntry( QStringLiteral( "Mergin" ), QStringLiteral( "PositionTracking/Enabled" ), false );
}
14 changes: 12 additions & 2 deletions app/activeproject.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/***************************************************************************
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
Expand All @@ -23,7 +23,6 @@
#include "autosynccontroller.h"
#include "inputmapsettings.h"


/**
* \brief The ActiveProject class can load a QGIS project and holds its data.
*/
Expand All @@ -36,6 +35,7 @@ class ActiveProject: public QObject
Q_PROPERTY( InputMapSettings *mapSettings READ mapSettings WRITE setMapSettings NOTIFY mapSettingsChanged )

Q_PROPERTY( QString mapTheme READ mapTheme WRITE setMapTheme NOTIFY mapThemeChanged )
Q_PROPERTY( bool positionTrackingSupported READ positionTrackingSupported NOTIFY positionTrackingSupportedChanged )

public:
explicit ActiveProject(
Expand Down Expand Up @@ -79,6 +79,9 @@ class ActiveProject: public QObject
*/
Q_INVOKABLE void switchLayerTreeNodeVisibility( QgsLayerTreeNode *node );

//! Returns boolean if any project is currently loaded
Q_INVOKABLE bool isProjectLoaded() const;

/**
* mapSettings method returns mapsettings pointer
*/
Expand Down Expand Up @@ -113,6 +116,8 @@ class ActiveProject: public QObject

const QString &mapTheme() const;

bool positionTrackingSupported() const;

signals:
void qgsProjectChanged();
void localProjectChanged( LocalProject project );
Expand All @@ -135,6 +140,11 @@ class ActiveProject: public QObject

void mapThemeChanged( const QString &mapTheme );

void positionTrackingSupportedChanged();

// Emited when the app (UI) should show tracking because there is a running tracking service
void startPositionTracking();

public slots:
// Reloads project if current project path matches given path (its the same project)
bool reloadProject( QString projectDir );
Expand Down
1 change: 1 addition & 0 deletions app/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies {
implementation "androidx.appcompat:appcompat:1.4.1"
implementation "androidx.core:core:1.8.0"
implementation "androidx.exifinterface:exifinterface:1.3.3"
implementation 'com.android.support:appcompat-v7:28.0.0'
}

android {
Expand Down
1 change: 1 addition & 0 deletions app/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
android.useAndroidX=true
android.enableJetifier=true
org.gradle.jvmargs=-Xmx4608m
6 changes: 6 additions & 0 deletions app/android/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<resources>
<string name="notification_title">Mergin Maps is tracking position</string>
<string name="notification_message">Your position is being recorded</string>
<string name="ticker_text">Position tracking</string>
</resources>
9 changes: 9 additions & 0 deletions app/android/src/uk/co/lutraconsulting/CameraActivity.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

package uk.co.lutraconsulting;

import java.text.SimpleDateFormat;
Expand Down
9 changes: 9 additions & 0 deletions app/android/src/uk/co/lutraconsulting/EXIFUtils.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

package uk.co.lutraconsulting;

import android.os.Bundle;
Expand Down
14 changes: 14 additions & 0 deletions app/android/src/uk/co/lutraconsulting/InputActivity.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

package uk.co.lutraconsulting;
import android.os.Bundle;
import android.view.WindowManager;
Expand All @@ -20,6 +29,11 @@ public void onCreate(Bundle savedInstanceState)
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}

public String homePath()
{
return getFilesDir().getAbsolutePath();
}

public void quitGracefully()
{
String man = android.os.Build.MANUFACTURER.toUpperCase();
Expand Down
9 changes: 9 additions & 0 deletions app/android/src/uk/co/lutraconsulting/OrientationSensor.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

package uk.co.lutraconsulting;

import android.app.Activity;
Expand Down
Loading

0 comments on commit 2ea2550

Please sign in to comment.