summaryrefslogtreecommitdiffstats
path: root/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java
diff options
context:
space:
mode:
authorGravatar Christof Arnosti <charno@charno.ch>2020-03-05 22:38:33 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-03-07 12:34:43 -0800
commit6e38f85ba7365efd2f27b407cf001b1e10dff1c8 (patch)
tree6504a8634b78523c02c72cf07280a01177785485 /android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java
parent6ffb1e3129a95ad30c2a1951373b1001db930ed6 (diff)
downloadsubsurface-6e38f85ba7365efd2f27b407cf001b1e10dff1c8.tar.gz
usb-serial-for-android: Implementation
Implement the libdivecomputer API in Java and create C/JNI translation layer. [Dirk Hohndel: whitespace harmonization - yes, some of this is Java, this still makes it much easier to read for me; also changed the FTDI conditional compilation to make sure we can still use that for mobile-on-desktop if necessary] Signed-off-by: Christof Arnosti <charno@charno.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java')
-rw-r--r--android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java21
1 files changed, 17 insertions, 4 deletions
diff --git a/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java b/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java
index 4c5bc576b..c909210f2 100644
--- a/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java
+++ b/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java
@@ -28,15 +28,19 @@ public class SubsurfaceMobileActivity extends QtActivity
public static boolean isInitialized;
private static final String TAG = "subsurfacedivelog.mobile";
public static native void setDeviceString(String deviceString);
+ private static Context appContext;
// we need to provide two endpoints:
// onNewIntent if we receive an Intent while running
// onCreate if we were started by an Intent
@Override
- public void onCreate(Bundle savedInstanceState) {
+ public void onCreate(Bundle savedInstanceState)
+ {
Log.i(TAG + " onCreate", "onCreate SubsurfaceMobileActivity");
super.onCreate(savedInstanceState);
+ appContext = getApplicationContext();
+
// now we're checking if the App was started from another Android App via Intent
Intent theIntent = getIntent();
if (theIntent != null) {
@@ -50,7 +54,8 @@ public class SubsurfaceMobileActivity extends QtActivity
// if we are opened from other apps:
@Override
- public void onNewIntent(Intent intent) {
+ public void onNewIntent(Intent intent)
+ {
Log.i(TAG + " onNewIntent", intent.getAction());
UsbDevice device = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
if (device == null) {
@@ -68,7 +73,8 @@ public class SubsurfaceMobileActivity extends QtActivity
}
} // onNewIntent
- public void checkPendingIntents() {
+ public void checkPendingIntents()
+ {
isInitialized = true;
if (isIntentPending) {
isIntentPending = false;
@@ -80,7 +86,8 @@ public class SubsurfaceMobileActivity extends QtActivity
} // checkPendingIntents
- private void processIntent() {
+ private void processIntent()
+ {
Intent intent = getIntent();
if (intent == null) {
Log.i(TAG + " processIntent", "intent is null");
@@ -95,4 +102,10 @@ public class SubsurfaceMobileActivity extends QtActivity
Log.i(TAG + " processIntent device name", device.getDeviceName());
setDeviceString(device.toString());
} // processIntent
+
+
+ public static Context getAppContext()
+ {
+ return appContext;
+ }
}