Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canon Camera Integration #898

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,14 @@ dependencies {

implementation 'com.google.zxing:core:3.4.1'

implementation('com.github.phenoapps:phenolib:v0.9.50')
implementation('com.github.phenoapps:phenolib:v0.9.51-SNAPSHOT')

//implementation 'com.google.android.exoplayer:exoplayer:2.19.1'
implementation 'androidx.media3:media3-exoplayer:1.3.0'
implementation 'androidx.media3:media3-exoplayer-dash:1.3.0'
implementation 'androidx.media3:media3-ui:1.3.0'
implementation 'androidx.media3:media3-common:1.3.0'

implementation 'com.google.android.exoplayer:exoplayer:2.19.1'
implementation 'com.arthenica:ffmpeg-kit-min:5.1.LTS'
implementation 'com.squareup.okhttp3:okhttp:4.11.0'

Expand Down Expand Up @@ -203,6 +208,12 @@ dependencies {

kapt 'com.android.databinding:compiler:3.1.4'

// Retrofit
implementation "com.squareup.retrofit2:retrofit:2.9.0"
// Retrofit with Scalar Converter
implementation "com.squareup.retrofit2:converter-scalars:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0"

testImplementation 'androidx.test:core:1.5.0'
testImplementation 'org.robolectric:robolectric:4.3.1'
testImplementation 'junit:junit:4.13.2'
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
android:name="com.journeyapps.barcodescanner.CaptureActivity"
android:screenOrientation="portrait"
android:stateNotNeeded="true"
tools:replace="android:screenOrientation" />
tools:replace="android:screenOrientation" />

<!-- used to define SAF storage directory, required at start of app -->
<activity
Expand Down Expand Up @@ -221,6 +221,9 @@
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<uses-feature android:name="android.software.companion_device_setup" />
<uses-feature android:name="android.hardware.usb.host" android:required="false"/>

<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
Expand All @@ -244,6 +247,10 @@

<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />

<uses-permission android:name="android.permission.NEARBY_WIFI_DEVICES"/>

<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/>

<uses-sdk tools:overrideLibrary="com.google.zxing.client.android" />

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.documentfile.provider.DocumentFile;
import androidx.fragment.app.FragmentManager;
import androidx.media3.common.Player;
import androidx.media3.exoplayer.ExoPlayer;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
Expand All @@ -48,6 +50,9 @@
import com.fieldbook.tracker.database.DataHelper;
import com.fieldbook.tracker.database.models.ObservationModel;
import com.fieldbook.tracker.database.models.ObservationUnitModel;
import com.fieldbook.tracker.devices.camera.CanonApi;
import com.fieldbook.tracker.devices.camera.GoProApi;
import com.fieldbook.tracker.devices.camera.UsbCameraApi;
import com.fieldbook.tracker.dialogs.GeoNavCollectDialog;
import com.fieldbook.tracker.interfaces.FieldSwitcher;
import com.fieldbook.tracker.location.GPSTracker;
Expand All @@ -58,19 +63,20 @@
import com.fieldbook.tracker.preferences.GeneralKeys;
import com.fieldbook.tracker.traits.AudioTraitLayout;
import com.fieldbook.tracker.traits.BaseTraitLayout;
import com.fieldbook.tracker.traits.CanonTrait;
import com.fieldbook.tracker.traits.CategoricalTraitLayout;
import com.fieldbook.tracker.traits.GNSSTraitLayout;
import com.fieldbook.tracker.traits.GoProTraitLayout;
import com.fieldbook.tracker.traits.LayoutCollections;
import com.fieldbook.tracker.traits.PhotoTraitLayout;
import com.fieldbook.tracker.utilities.BluetoothHelper;
import com.fieldbook.tracker.utilities.CategoryJsonUtil;
import com.fieldbook.tracker.utilities.DocumentTreeUtil;
import com.fieldbook.tracker.utilities.FfmpegHelper;
import com.fieldbook.tracker.utilities.FieldAudioHelper;
import com.fieldbook.tracker.utilities.FieldSwitchImpl;
import com.fieldbook.tracker.utilities.GeoJsonUtil;
import com.fieldbook.tracker.utilities.GeoNavHelper;
import com.fieldbook.tracker.utilities.GnssThreadHelper;
import com.fieldbook.tracker.utilities.GoProWrapper;
import com.fieldbook.tracker.utilities.InfoBarHelper;
import com.fieldbook.tracker.utilities.JsonUtil;
import com.fieldbook.tracker.utilities.KeyboardListenerHelper;
Expand All @@ -81,13 +87,15 @@
import com.fieldbook.tracker.utilities.Utils;
import com.fieldbook.tracker.utilities.VerifyPersonHelper;
import com.fieldbook.tracker.utilities.VibrateUtil;
import com.fieldbook.tracker.utilities.WifiHelper;
import com.fieldbook.tracker.views.CollectInputView;
import com.fieldbook.tracker.views.RangeBoxView;
import com.fieldbook.tracker.views.TraitBoxView;
import com.getkeepsafe.taptargetview.TapTarget;
import com.getkeepsafe.taptargetview.TapTargetSequence;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
import com.serenegiant.widget.UVCCameraTextureView;

import org.brapi.v2.model.pheno.BrAPIScaleValidValuesCategories;
import org.phenoapps.interfaces.security.SecureBluetooth;
Expand Down Expand Up @@ -129,7 +137,6 @@ public class CollectActivity extends ThemedActivity
com.fieldbook.tracker.interfaces.CollectRangeController,
com.fieldbook.tracker.interfaces.CollectTraitController,
InfoBarAdapter.InfoBarController,
GoProTraitLayout.GoProCollector,
GPSTracker.GPSTrackerListener {

public static final int REQUEST_FILE_EXPLORER_CODE = 1;
Expand All @@ -140,6 +147,24 @@ public class CollectActivity extends ThemedActivity

private GeoNavHelper geoNavHelper;

@Inject
FfmpegHelper ffmpegHelper;

@Inject
GoProApi goProApi;

@Inject
UsbCameraApi usbCameraApi;

@Inject
CanonApi canonApi;

@Inject
WifiHelper wifiHelper;

@Inject
BluetoothHelper bluetoothHelper;

@Inject
KeyboardListenerHelper keyboardListenerHelper;

Expand Down Expand Up @@ -168,9 +193,6 @@ public class CollectActivity extends ThemedActivity
@Inject
SoundHelperImpl soundHelper;

@Inject
GoProWrapper goProWrapper;

private GPSTracker gps;

public static boolean searchReload;
Expand All @@ -182,6 +204,8 @@ public class CollectActivity extends ThemedActivity
public static String TAG = "Field Book";
public static String GEOTAG = "GeoNav";

UVCCameraTextureView uvcView;

ImageButton deleteValue;
ImageButton missingValue;
ImageButton barcodeInput;
Expand Down Expand Up @@ -306,15 +330,28 @@ public void handleMessage(Message msg) {

mUsbCameraHelper = new UsbCameraHelper(this);

goProWrapper.attach();

mlkitEnabled = mPrefs.getBoolean(GeneralKeys.MLKIT_PREFERENCE_KEY, false);

loadScreen();

checkForInitialBarcodeSearch();

verifyPersonHelper.checkLastOpened();

}

@Override
protected void onStart() {
super.onStart();
usbCameraApi.onStart();
bluetoothHelper.onStart();
}

@Override
protected void onStop() {
super.onStop();
usbCameraApi.onStop();
bluetoothHelper.onStop();
}

public void triggerTts(String text) {
Expand Down Expand Up @@ -501,6 +538,9 @@ private void loadScreen() {
});

refreshInfoBarAdapter();

uvcView = findViewById(R.id.collect_activity_uvc_tv);

}

//when softkeyboard is displayed, reset the snackbar to redisplay with a calculated bottom margin
Expand Down Expand Up @@ -922,6 +962,8 @@ public void onPause() {

ep.edit().putInt(GeneralKeys.DATA_LOCK_STATE, dataLocked).apply();

bluetoothHelper.onPause();

super.onPause();
}

Expand All @@ -945,12 +987,16 @@ public void onDestroy() {

mUsbCameraHelper.destroy();

goProWrapper.destroy();

traitLayoutRefresh();

gnssThreadHelper.stop();

usbCameraApi.onDestroy();

goProApi.onDestroy();

bluetoothHelper.onDestroy();

super.onDestroy();
}

Expand Down Expand Up @@ -2007,19 +2053,26 @@ public void onBackPressed() {
FragmentManager m = getSupportFragmentManager();
int count = getSupportFragmentManager().getBackStackEntryCount();

String format = traitBox.getCurrentFormat();

if (count == 0) {

if (isNavigatingFromSummary) {

isNavigatingFromSummary = false;

} else {
} else if (format.equals(CanonTrait.type)) {

canonApi.stopSession();

wifiHelper.disconnect();

}else {

finish();

}


} else {

getSupportFragmentManager().popBackStack();
Expand Down Expand Up @@ -2270,8 +2323,8 @@ public GnssThreadHelper getGnssThreadHelper() {

@NonNull
@Override
public GoProWrapper wrapper() {
return goProWrapper;
public GoProApi getGoProApi() {
return goProApi;
}

@NonNull
Expand Down Expand Up @@ -2527,4 +2580,33 @@ public void setUsbCameraConnected(boolean connected) {
usbCameraConnected = connected;
}

@NonNull
@Override
public CanonApi getCanonApi() {
return canonApi;
}

@NonNull
@Override
public WifiHelper getWifiHelper() { return wifiHelper; }

@NonNull
@Override
public BluetoothHelper getBluetoothHelper() { return bluetoothHelper; }

@NonNull
@Override
public UsbCameraApi getUsbApi() {
return usbCameraApi;
}

@NonNull
@Override
public UVCCameraTextureView getUvcView() { return uvcView; }

@NonNull
@Override
public FfmpegHelper getFfmpegHelper() {
return ffmpegHelper;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ import javax.inject.Inject
@AndroidEntryPoint
class DataGridActivity : ThemedActivity(), CoroutineScope by MainScope(), ITableViewListener {

companion object {
val TAG = DataGridActivity::class.simpleName
}

/***
* Polymorphism class structure to serve different cell types to the grid.
*/
Expand Down
Loading