Skip to content

Commit

Permalink
Merge branch 'OpenCPN:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Hakansv authored Oct 25, 2024
2 parents caaa4f8 + f3daceb commit 1aed7b2
Show file tree
Hide file tree
Showing 158 changed files with 2,685 additions and 2,193 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: test-clang-format
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: DoozyX/[email protected]
with:
source: './model ./gui'
extensions: 'h,cpp'
clangFormatVersion: 18
style: file
...
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ repos:
rev: v18.1.8
hooks:
- id: clang-format
exclude: (?x)^( libs.*| data.*)$
exclude: (?x)^( libs.*| data.*| .*java| .*json)$
13 changes: 10 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ set(OpenGL_GL_PREFERENCE "LEGACY")

if ("${OCPN_TARGET_TUPLE}" MATCHES "Android")
message(STATUS "Building for wxQt-Android")

# Specific NDK setting, avoiding "Unwind" linkage problems with
# managed plugins found in later NDK versions.
#set( tool_base /home/dsr/Android/Sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64)
#cmake -DOCPN_TARGET_TUPLE:STRING="Android-arm64;16;arm64" -Dtool_base="$HOME/Android/Sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64" ..
#cmake -DOCPN_TARGET_TUPLE:STRING="Android-armhf;16;armhf" -Dtool_base="$HOME/Android/Sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64" ..

set(CMAKE_TOOLCHAIN_FILE buildandroid/build_android.cmake)
set(QT_ANDROID "ON")
if ("${OCPN_TARGET_TUPLE}" MATCHES "Android-arm64")
Expand Down Expand Up @@ -433,13 +440,13 @@ if (MSVC)
endif ()

if (QT_ANDROID)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
add_definitions(-D__WXQT__)
add_definitions(-D__OCPN__ANDROID__)
add_definitions(-DANDROID)
add_definitions(-DNOASSERT)
set(CMAKE_CXX_FLAGS "-pthread -fPIC -g")
set(CMAKE_C_FLAGS "-pthread -fPIC -g")
set(CMAKE_CXX_FLAGS "-pthread -fPIC -g -O2")
set(CMAKE_C_FLAGS "-pthread -fPIC -g -O2")

add_compile_options(
"-Wno-inconsistent-missing-override"
Expand Down
2 changes: 1 addition & 1 deletion VERSION.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SET(VERSION_MAJOR "5")
SET(VERSION_MINOR "10")
SET(VERSION_MINOR "11")
SET(VERSION_PATCH "0")
SET(VERSION_DATE "2024-08-09")
31 changes: 12 additions & 19 deletions android/androidUTIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ extern MyFrame *gFrame;
extern const wxEventType wxEVT_OCPN_DATASTREAM;
// extern const wxEventType wxEVT_DOWNLOAD_EVENT;

wxEvtHandler *s_pAndroidNMEAMessageConsumer;
static SendMsgFunc s_send_msg_func;
wxEvtHandler *s_pAndroidGPSIntMessageConsumer;
wxEvtHandler *s_pAndroidBTNMEAMessageConsumer;

Expand Down Expand Up @@ -1104,8 +1104,9 @@ JNIEXPORT jint JNICALL Java_org_opencpn_OCPNNativeLib_processSailTimer(
// Java app, even without a definite connection, and we want to process these
// messages too. So assume that the global MUX, if present, will handle these
// synthesized messages.
if (!s_pAndroidNMEAMessageConsumer && g_pMUX)
s_pAndroidNMEAMessageConsumer = g_pMUX;

////if (!s_pAndroidNMEAMessageConsumer && g_pMUX)
//// s_pAndroidNMEAMessageConsumer = g_pMUX;

double wind_angle_mag = 0;
double apparent_wind_angle = 0;
Expand Down Expand Up @@ -1184,7 +1185,7 @@ JNIEXPORT jint JNICALL Java_org_opencpn_OCPNNativeLib_processSailTimer(
// qDebug() << wind_angle_mag << app_windSpeed << apparent_wind_angle <<
// true_windSpeed << true_windDirection;

if (s_pAndroidNMEAMessageConsumer) {
if (g_androidUtilHandler) {
NMEA0183 parser(NmeaCtxFactory());

// Now make some NMEA messages
Expand Down Expand Up @@ -1244,21 +1245,14 @@ JNIEXPORT jint JNICALL Java_org_opencpn_OCPNNativeLib_processNMEA(
// The NMEA message target handler may not be setup yet, if no connections
// are defined or enabled. But we may get synthesized messages from the Java
// app, even without a definite connection. We ignore these messages.
wxEvtHandler *consumer = s_pAndroidNMEAMessageConsumer;

const char *string = env->GetStringUTFChars(nmea_string, NULL);

// qDebug() << "ProcessNMEA: " << string;

if (consumer) {
auto buffer = std::make_shared<std::vector<unsigned char>>();
std::vector<unsigned char> *vec = buffer.get();

for (int i = 0; i < strlen(string); i++) vec->push_back(string[i]);

CommDriverN0183SerialEvent Nevent(wxEVT_COMMDRIVER_N0183_SERIAL, 0);
Nevent.SetPayload(buffer);
consumer->AddPendingEvent(Nevent);
if (s_send_msg_func) {
std::string s(string);
s_send_msg_func(std::vector<unsigned char>(s.begin(), s.end()));
}

return 66;
Expand Down Expand Up @@ -1710,8 +1704,7 @@ JNIEXPORT int JNICALL Java_org_opencpn_OCPNNativeLib_getTLWCount(JNIEnv *env,
wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst();
while (node) {
wxWindow *win = node->GetData();
if (win->IsShown() && !win->IsKindOf(CLASSINFO(CanvasOptions))) ret++;

if (win->IsShown() && !dynamic_cast<CanvasOptions *>(win)) ret++;
node = node->GetNext();
}
return ret;
Expand Down Expand Up @@ -2871,17 +2864,17 @@ wxArrayString *androidGetSerialPortsArray(void) {
}

bool androidStartUSBSerial(wxString &portname, wxString baudRate,
wxEvtHandler *consumer) {
SendMsgFunc send_msg_func) {
wxString result =
callActivityMethod_s2s("startSerialPort", portname, baudRate);

s_pAndroidNMEAMessageConsumer = consumer;
s_send_msg_func = send_msg_func;

return true;
}

bool androidStopUSBSerial(wxString &portname) {
s_pAndroidNMEAMessageConsumer = NULL;
s_send_msg_func = nullptr;

// If app is closing down, the USB serial ports will go away automatically.
// So no need here.
Expand Down
75 changes: 39 additions & 36 deletions android/androidUTIL.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

class ArrayOfCDI;


// Enumerators for OCPN menu actions requested by Android UI
#define OCPN_ACTION_FOLLOW 0x1000
#define OCPN_ACTION_ROUTE 0x1001
Expand Down Expand Up @@ -105,8 +104,10 @@ extern bool androidStopBT();
extern bool androidSendBTMessage(wxString &payload);

extern wxArrayString *androidGetSerialPortsArray(void);

using SendMsgFunc = std::function<void(const std::vector<unsigned char> &)>;
extern bool androidStartUSBSerial(wxString &portname, wxString baudRate,
wxEvtHandler *consumer);
SendMsgFunc send_msg_func);
extern bool androidStopUSBSerial(wxString &portname);
extern bool androidWriteSerial(wxString &portname, wxString &message);

Expand Down Expand Up @@ -148,7 +149,7 @@ void resizeAndroidPersistents();
bool AndroidSecureCopyFile(wxString in, wxString out);

class AndroidSound;
bool androidPlaySound(const wxString soundfile, AndroidSound* sound);
bool androidPlaySound(const wxString soundfile, AndroidSound *sound);

bool androidGetFullscreen();
bool androidSetFullscreen(bool bFull);
Expand Down Expand Up @@ -202,32 +203,32 @@ wxBitmap loadAndroidSVG(const wxString filename, unsigned int width,
unsigned int height);

wxString androidGetAndroidSystemLocale();
bool androidIsDirWritable( wxString dir );
bool androidIsDirWritable(wxString dir);
wxArrayString GetConfigChartDirectories();

class InProgressIndicator: public wxGauge
{
DECLARE_EVENT_TABLE()
class InProgressIndicator : public wxGauge {
DECLARE_EVENT_TABLE()

public:
InProgressIndicator();
InProgressIndicator(wxWindow* parent, wxWindowID id, int range,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxGA_HORIZONTAL, const wxValidator& validator = wxDefaultValidator, const wxString& name = "inprogress");

~InProgressIndicator();

void OnTimer(wxTimerEvent &evt);
void Start();
void Stop();


wxTimer m_timer;
int msec;
bool m_bAlive;
InProgressIndicator();
InProgressIndicator(wxWindow *parent, wxWindowID id, int range,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = wxGA_HORIZONTAL,
const wxValidator &validator = wxDefaultValidator,
const wxString &name = "inprogress");

~InProgressIndicator();

void OnTimer(wxTimerEvent &evt);
void Start();
void Stop();

wxTimer m_timer;
int msec;
bool m_bAlive;
};


///////////////////////////////////////////////////////////////////////////////
/// Class MigrateAssistantDialog
///////////////////////////////////////////////////////////////////////////////
Expand All @@ -239,12 +240,12 @@ class InProgressIndicator: public wxGauge

class MigrateAssistantDialog : public wxDialog {
public:
explicit MigrateAssistantDialog(wxWindow *parent,
bool bskipScan,
wxWindowID id = wxID_ANY,
const wxString &caption = wxEmptyString,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize, long style = 0);
explicit MigrateAssistantDialog(wxWindow *parent, bool bskipScan,
wxWindowID id = wxID_ANY,
const wxString &caption = wxEmptyString,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = 0);
~MigrateAssistantDialog(void);

void CreateControls(void);
Expand All @@ -254,14 +255,15 @@ class MigrateAssistantDialog : public wxDialog {
void OnMigrate1Click(wxCommandEvent &event);
void OnCtlUpdated(wxCommandEvent &event);
void onPermissionGranted(wxString);
void setStatus( wxString s ){ m_statusText->SetLabel(s); }
void setStatus(wxString s) { m_statusText->SetLabel(s); }
void onTimerEvent(wxTimerEvent &event);
void FinishMigration();

wxButton *m_CancelButton, *m_OKButton;
wxButton *m_migrateButton, *m_migrateButton1;
wxStaticText *m_infoText, *m_infoDirs, *m_migrateStep1, *m_statusText;;
wxRadioButton *m_radioSDCard, *m_radioInternal;
wxStaticText *m_infoText, *m_infoDirs, *m_migrateStep1, *m_statusText;
;
wxRadioButton *m_radioSDCard, *m_radioInternal;
InProgressIndicator *m_ipGauge;
wxStaticBoxSizer *statusSizer;

Expand All @@ -270,15 +272,16 @@ class MigrateAssistantDialog : public wxDialog {
wxString m_permissionResult;
wxTimer m_statusTimer;
wxString m_migrateSourceFolder;
wxString m_migrateDestinationFolder; // something like "/storage/emulated/0/Android/data/org.opencpn.opencpn/files/Charts
// or "/storage/xxx-yyyy/Android/data/org.opencpn.opencpn/files/Charts
wxString
m_migrateDestinationFolder; // something like
// "/storage/emulated/0/Android/data/org.opencpn.opencpn/files/Charts
// or
// "/storage/xxx-yyyy/Android/data/org.opencpn.opencpn/files/Charts
bool m_bsdcard;
bool m_bskipScan;

private:

DECLARE_EVENT_TABLE()
};


#endif // guard
Loading

0 comments on commit 1aed7b2

Please sign in to comment.