OpenCPN Partial API docs
Loading...
Searching...
No Matches
androidUTIL.h
1/***************************************************************************
2 *
3 * Project: OpenCPN
4 * Purpose: OpenCPN Android support utilities
5 * Author: David Register
6 *
7 ***************************************************************************
8 * Copyright (C) 2015 by David S. Register *
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
24 **************************************************************************/
25
26#ifndef ANDROIDUTIL_H
27#define ANDROIDUTIL_H
28
29#include "wx/wxprec.h"
30
31#ifndef WX_PRECOMP
32#include "wx/wx.h"
33#endif // precompiled headers
34
35#include "OCPN_Sound.h"
36
37class ArrayOfCDI;
38
39#include <QString>
40
41// Enumerators for OCPN menu actions requested by Android UI
42#define OCPN_ACTION_FOLLOW 0x1000
43#define OCPN_ACTION_ROUTE 0x1001
44#define OCPN_ACTION_RMD 0x1002
45#define OCPN_ACTION_SETTINGS_BASIC 0x1003
46#define OCPN_ACTION_SETTINGS_EXPERT 0x1004
47#define OCPN_ACTION_TRACK_TOGGLE 0x1005
48#define OCPN_ACTION_MOB 0x1006
49#define OCPN_ACTION_TIDES_TOGGLE 0x1007
50#define OCPN_ACTION_CURRENTS_TOGGLE 0x1008
51#define OCPN_ACTION_ENCTEXT_TOGGLE 0x1009
52#define OCPN_ACTION_TRACK_ON 0x100a
53#define OCPN_ACTION_TRACK_OFF 0x100b
54#define OCPN_ACTION_ENCSOUNDINGS_TOGGLE 0x100c
55#define OCPN_ACTION_ENCLIGHTS_TOGGLE 0x100d
56#define OCPN_ACTION_DOWNLOAD_VALID 0x100e
57
58#define GPS_OFF 0
59#define GPS_ON 1
60#define GPS_PROVIDER_AVAILABLE 2
61#define GPS_SHOWPREFERENCES 3
62
63extern bool androidUtilInit(void);
64
65extern wxString androidGetDeviceInfo();
66extern void CheckMigrateCharts();
67
68extern bool androidGetMemoryStatus(int *mem_total, int *mem_used);
69
70extern double GetAndroidDisplaySize();
71extern double getAndroidDPmm();
72extern wxSize getAndroidDisplayDimensions(void);
73extern double getAndroidDisplayDensity();
74extern int getAndroidActionBarHeight();
75extern void androidConfirmSizeCorrection();
76extern void androidForceFullRepaint(bool bskipConfirm = false);
77extern int androidGetVersionCode();
78extern wxString androidGetVersionName();
79
80extern bool LoadQtStyleSheet(wxString &sheet_file);
81extern QString getQtStyleSheet(void);
82
83extern void androidShowBusyIcon();
84extern void androidHideBusyIcon();
85extern void androidEnableBackButton(bool benable);
86extern void androidEnableBackButtonCheck(bool benable);
87extern void androidEnableOptionItems(bool benable);
88
89extern wxString androidGetSupplementalLicense(void);
90
91extern bool androidStartNMEA(wxEvtHandler *consumer);
92extern bool androidStopNMEA();
93extern wxString androidGPSService(int parm);
94extern bool androidDeviceHasGPS();
95
96extern bool androidDeviceHasBlueTooth();
97extern bool androidStartBluetoothScan();
98extern bool androidStopBluetoothScan();
99extern wxArrayString androidGetBluetoothScanResults();
100extern bool androidStartBT(wxEvtHandler *consumer, wxString mac_address);
101extern bool androidStopBT();
102extern bool androidSendBTMessage(wxString &payload);
103
104extern wxArrayString *androidGetSerialPortsArray(void);
105extern bool androidStartUSBSerial(wxString &portname, wxString baudRate,
106 wxEvtHandler *consumer);
107extern bool androidStopUSBSerial(wxString &portname);
108extern bool androidWriteSerial(wxString &portname, wxString &message);
109
110extern bool DoAndroidPreferences(void);
111extern int androidFileChooser(wxString *result, const wxString &initDir,
112 const wxString &title, const wxString &suggestion,
113 const wxString &wildcard, bool dirOnly = false,
114 bool addFiles = false);
115
116extern void androidSetChartTypeMaskSel(int mask, wxString &indicator);
117extern void androidSetRouteAnnunciator(bool viz);
118extern void androidSetFollowTool(int state, bool forceUpdate = false);
119extern void androidSetTrackTool(bool bactive);
120
121extern wxString androidGetHomeDir();
122extern wxString
123androidGetPrivateDir(); // Used for logfile, config file, and the like
124extern wxString
125androidGetSharedDir(); // Used for assets like uidata, s57data, etc
126extern wxString
127androidGetCacheDir(); // Used for raster_texture_cache, mmsitoname.csv, etc
128extern wxString androidGetExtStorageDir(); // Used for Chart storage, typically
129extern wxString androidGetDownloadDirectory();
130
131extern int startAndroidFileDownload(const wxString &url,
132 const wxString &destination,
133 wxEvtHandler *evh, long *dl_ID);
134extern int queryAndroidFileDownload(long dl_ID, wxString *result);
135extern void finishAndroidFileDownload();
136extern void cancelAndroidFileDownload(long dl_ID);
137extern int validateAndroidWriteLocation(const wxString &destination);
138
139extern wxString doAndroidPOST(const wxString &url, wxString &parms,
140 int timeoutMsec);
141
142extern wxString getFontQtStylesheet(wxFont *font);
143extern wxSize getAndroidConfigSize();
144void resizeAndroidPersistents();
145bool AndroidSecureCopyFile(wxString in, wxString out);
146
147class AndroidSound;
148bool androidPlaySound(const wxString soundfile, AndroidSound* sound);
149
150bool androidGetFullscreen();
151bool androidSetFullscreen(bool bFull);
152void androidDisableFullScreen();
153void androidRestoreFullScreen();
154
155void androidLaunchHelpView();
156void androidTerminate();
157
158void androidTestCPP();
159int androidGetTZOffsetMins();
160
161int androidApplySettingsString(wxString settings, ArrayOfCDI *pACDI);
162
163bool androidShowDisclaimer(wxString title, wxString msg);
164bool androidShowSimpleOKDialog(wxString title, wxString msg);
165bool androidShowSimpleYesNoDialog(wxString title, wxString msg);
166bool androidInstallPlaystoreHelp();
167
168void androidLaunchBrowser(wxString URL);
169bool androidCheckOnline();
170
171unsigned int androidColorPicker(unsigned int initialColor);
172
173wxArrayString androidTraverseDir(wxString dir, wxString filespec);
174void androidEnableOptionsMenu(bool bEnable);
175
176void prepareAndroidStyleSheets();
177QString getAdjustedDialogStyleSheet();
178QString getListBookStyleSheet();
179QString getScrollBarsStyleSheet();
180void setChoiceStyleSheet(wxChoice *win, int refDim);
181void setMenuStyleSheet(wxMenu *win, const wxFont &font);
182QString prepareAndroidSliderStyleSheet(int sliderWidth);
183
184void androidDisplayTimedToast(wxString message, int timeMillisec);
185void androidCancelTimedToast();
186void androidDisplayToast(wxString message);
187
188void androidEnableRotation(void);
189void androidDisableRotation(void);
190int androidGetScreenOrientation();
191
192void androidEnableMulticast(bool benable);
193void androidLastCall();
194
195// SVG Support
196wxBitmap loadAndroidSVG(const wxString filename, unsigned int width,
197 unsigned int height);
198
199wxString androidGetAndroidSystemLocale();
200bool androidIsDirWritable( wxString dir );
201wxArrayString GetConfigChartDirectories();
202
203class InProgressIndicator: public wxGauge
204{
205 DECLARE_EVENT_TABLE()
206
207public:
209 InProgressIndicator(wxWindow* parent, wxWindowID id, int range,
210 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
211 long style = wxGA_HORIZONTAL, const wxValidator& validator = wxDefaultValidator, const wxString& name = "inprogress");
212
214
215 void OnTimer(wxTimerEvent &evt);
216 void Start();
217 void Stop();
218
219
220 wxTimer m_timer;
221 int msec;
222 bool m_bAlive;
223};
224
225
229#define ID_MIGRATE_OK 8791
230#define ID_MIGRATE_CANCEL 8792
231#define ID_MIGRATE_START 8793
232#define ID_MIGRATE_CONTINUE 8794
233#define MIGRATION_STATUS_TIMER 8795
234
235class MigrateAssistantDialog : public wxDialog {
236public:
237 explicit MigrateAssistantDialog(wxWindow *parent,
238 bool bskipScan,
239 wxWindowID id = wxID_ANY,
240 const wxString &caption = wxEmptyString,
241 const wxPoint &pos = wxDefaultPosition,
242 const wxSize &size = wxDefaultSize, long style = 0);
244
245 void CreateControls(void);
246 void OnMigrateCancelClick(wxCommandEvent &event);
247 void OnMigrateOKClick(wxCommandEvent &event);
248 void OnMigrateClick(wxCommandEvent &event);
249 void OnMigrate1Click(wxCommandEvent &event);
250 void OnCtlUpdated(wxCommandEvent &event);
251 void onPermissionGranted(wxString);
252 void setStatus( wxString s ){ m_statusText->SetLabel(s); }
253 void onTimerEvent(wxTimerEvent &event);
254 void FinishMigration();
255
256 wxButton *m_CancelButton, *m_OKButton;
257 wxButton *m_migrateButton, *m_migrateButton1;
258 wxStaticText *m_infoText, *m_infoDirs, *m_migrateStep1, *m_statusText;;
259 wxRadioButton *m_radioSDCard, *m_radioInternal;
260 InProgressIndicator *m_ipGauge;
261 wxStaticBoxSizer *statusSizer;
262
263 wxArrayString m_migrateDirs;
264 wxString m_Status;
265 wxString m_permissionResult;
266 wxTimer m_statusTimer;
267 wxString m_migrateSourceFolder;
268 wxString m_migrateDestinationFolder; // something like "/storage/emulated/0/Android/data/org.opencpn.opencpn/files/Charts
269 // or "/storage/xxx-yyyy/Android/data/org.opencpn.opencpn/files/Charts
270 bool m_bsdcard;
271 bool m_bskipScan;
272
273private:
274
275 DECLARE_EVENT_TABLE()
276};
277
278
279#endif // guard