From 23535448a55beb2dacd423cc197105a58424e13c Mon Sep 17 00:00:00 2001 From: free-bots Date: Thu, 8 Feb 2024 17:21:11 +0100 Subject: [PATCH 1/2] added intent for direct camera access and leanback support --- app/src/main/AndroidManifest.xml | 12 +++++- .../ojo/ui/SurveillanceFragment.java | 42 ++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 09aae44..ec00221 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,7 +1,11 @@ - + + @@ -25,12 +30,17 @@ + + + + + diff --git a/app/src/main/java/it/danieleverducci/ojo/ui/SurveillanceFragment.java b/app/src/main/java/it/danieleverducci/ojo/ui/SurveillanceFragment.java index ba5fa14..d072be9 100644 --- a/app/src/main/java/it/danieleverducci/ojo/ui/SurveillanceFragment.java +++ b/app/src/main/java/it/danieleverducci/ojo/ui/SurveillanceFragment.java @@ -1,6 +1,7 @@ package it.danieleverducci.ojo.ui; import android.content.Context; +import android.content.Intent; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -28,7 +29,6 @@ import org.videolan.libvlc.MediaPlayer; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Objects; import it.danieleverducci.ojo.R; import it.danieleverducci.ojo.Settings; @@ -100,6 +100,8 @@ public class SurveillanceFragment extends Fragment { cv.startPlayback(); } + expandToCameraViewIfRequired(); + // Register for back pressed events ((MainActivity)getActivity()).setOnBackButtonPressedListener(new OnBackButtonPressedListener() { @Override @@ -256,6 +258,44 @@ public class SurveillanceFragment extends Fragment { return dimensions; } + private void expandToCameraViewIfRequired() { + final String EXTRA_CAMERA_NUMBER = "it.danieleverducci.ojo.CAMERA_NUMBER"; + final String EXTRA_CAMERA_NAME = "it.danieleverducci.ojo.CAMERA_NAME"; + final String OPEN_CAMERA = "it.danieleverducci.ojo.OPEN_CAMERA"; + + if (this.getActivity() == null) { + return; + } + + Intent intent = this.getActivity().getIntent(); + + if (OPEN_CAMERA.equals(intent.getAction())) { + String cameraName = intent.getStringExtra(EXTRA_CAMERA_NAME); + if (cameraName == null) { + int cameraNumber = intent.getIntExtra(EXTRA_CAMERA_NUMBER, 0) - 1; + expandByIndex(cameraNumber); + return; + } + expandByName(cameraName); + } + } + + private void expandByIndex(int index) { + if (index < 0 || cameraViews.size() <= index) { + return; + } + hideAllCameraViewsButNot(cameraViews.get(index).surfaceView); + } + + private void expandByName(String name) { + for(CameraView cameraView: cameraViews) { + if (cameraView.camera.getName().equals(name)) { + hideAllCameraViewsButNot(cameraView.surfaceView); + break; + } + } + } + /** * Contains all entities (views and java entities) related to a camera stream viewer */ From 7a52c24fea46872e5c9eedb1bc759b1b99b9dcd6 Mon Sep 17 00:00:00 2001 From: free-bots Date: Sat, 10 Feb 2024 09:07:13 +0100 Subject: [PATCH 2/2] added description for intent usage --- README.md | 11 +++++++++++ fastlane/metadata/android/en-US/full_description.txt | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/README.md b/README.md index 6bcd197..fe9c968 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,17 @@ The maximum number of cameras is determined by the device's capabilities. The stream decoding and rendering is demanded to [VLC's library](https://code.videolan.org/videolan/vlc-android): without their effort this app wouldn't be possible. This app was specifically developed for F-Droid, as I couldn't find any open source RTSP vievers in the main repository. +The app can be opened deeplinking to url ojo://view. +To open the app with focus on a specific camera, you can use an intent (it.danieleverducci.ojo.OPEN_CAMERA) to specify which camera you want to view. +The extra argument it.danieleverducci.ojo.CAMERA_NAME will open the app with the camera with the name you specified while adding the camera. +The extra argument it.danieleverducci.ojo.CAMERA_NUMBER starting at 1 could be used as well, if you have multiple cameras with the same name. +See belows example how to use the intent. The flag (-f 268468224) could be useful if you want to switch to an other camera while the app is running. +```shell +adb -s shell am start -a it.danieleverducci.ojo.OPEN_CAMERA -f 268468224 --es it.danieleverducci.ojo.CAMERA_NAME +adb -s shell am start -a it.danieleverducci.ojo.OPEN_CAMERA -f 268468224 --es it.danieleverducci.ojo.CAMERA_NUMBER +``` + + ![Screenshot 1](media/screenshots/1.png) ![Screenshot 2](media/screenshots/2.png) ![Screenshot 3](media/screenshots/3.png) ## Contributors diff --git a/fastlane/metadata/android/en-US/full_description.txt b/fastlane/metadata/android/en-US/full_description.txt index d20c8cd..805a141 100644 --- a/fastlane/metadata/android/en-US/full_description.txt +++ b/fastlane/metadata/android/en-US/full_description.txt @@ -6,3 +6,9 @@ The stream decoding and rendering is demanded to VLC's library: without their ef This app was specifically developed for F-Droid, as I couldn't find any open source RTSP vievers in the main repository. The app can be opened deeplinking to url ojo://view +To open the app with focus on a specific camera, you can use an intent (it.danieleverducci.ojo.OPEN_CAMERA) to specify which camera you want to view. +The extra argument it.danieleverducci.ojo.CAMERA_NAME will open the app with the camera with the name you specified while adding the camera. +The extra argument it.danieleverducci.ojo.CAMERA_NUMBER starting at 1 could be used as well, if you have multiple cameras with the same name. +See belows example how to use the intent. The flag (-f 268468224) could be useful if you want to switch to an other camera while the app is running. +adb -s shell am start -a it.danieleverducci.ojo.OPEN_CAMERA -f 268468224 --es it.danieleverducci.ojo.CAMERA_NAME +adb -s shell am start -a it.danieleverducci.ojo.OPEN_CAMERA -f 268468224 --es it.danieleverducci.ojo.CAMERA_NUMBER