Skip to content

Commit 96a91a6

Browse files
authored
Merge pull request #32 from free-bots/feature/intent
added intent for direct camera access and leanback support
2 parents 4aa17ec + 7a52c24 commit 96a91a6

File tree

4 files changed

+69
-2
lines changed

4 files changed

+69
-2
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ The maximum number of cameras is determined by the device's capabilities.
1414
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.
1515
This app was specifically developed for F-Droid, as I couldn't find any open source RTSP vievers in the main repository.
1616

17+
The app can be opened deeplinking to url ojo://view.
18+
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.
19+
The extra argument it.danieleverducci.ojo.CAMERA_NAME will open the app with the camera with the name you specified while adding the camera.
20+
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.
21+
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.
22+
```shell
23+
adb -s <YOUR_DEVICE> shell am start -a it.danieleverducci.ojo.OPEN_CAMERA -f 268468224 --es it.danieleverducci.ojo.CAMERA_NAME <YOUR_CAMERA_NAME>
24+
adb -s <YOUR_DEVICE> shell am start -a it.danieleverducci.ojo.OPEN_CAMERA -f 268468224 --es it.danieleverducci.ojo.CAMERA_NUMBER <YOUR_CAMERA_NUMBER>
25+
```
26+
27+
1728
![Screenshot 1](media/screenshots/1.png) ![Screenshot 2](media/screenshots/2.png) ![Screenshot 3](media/screenshots/3.png)
1829

1930
## Contributors

app/src/main/AndroidManifest.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
<manifest xmlns:tools="http://schemas.android.com/tools"
3+
xmlns:android="http://schemas.android.com/apk/res/android">
34

45
<uses-permission android:name="android.permission.INTERNET" />
6+
<uses-feature
7+
android:name="android.software.leanback"
8+
android:required="false" />
59

610
<application
711
android:allowBackup="true"
@@ -12,6 +16,7 @@
1216
android:theme="@style/Theme.Ojo">
1317
<activity
1418
android:name=".ui.SettingsActivity"
19+
android:banner="@mipmap/ic_launcher"
1520
android:exported="true"
1621
android:label="@string/app_name"
1722
android:theme="@style/Theme.Ojo">
@@ -25,12 +30,17 @@
2530
<intent-filter>
2631
<action android:name="android.intent.action.MAIN" />
2732
<category android:name="android.intent.category.LAUNCHER" />
33+
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
2834
</intent-filter>
2935
<intent-filter>
3036
<action android:name="android.intent.action.VIEW"/>
3137
<category android:name="android.intent.category.DEFAULT"/>
3238
<data android:scheme="ojo" android:host="view"/>
3339
</intent-filter>
40+
<intent-filter>
41+
<action android:name="it.danieleverducci.ojo.OPEN_CAMERA"/>
42+
<category android:name="android.intent.category.DEFAULT"/>
43+
</intent-filter>
3444
</activity>
3545
</application>
3646

app/src/main/java/it/danieleverducci/ojo/ui/SurveillanceFragment.java

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package it.danieleverducci.ojo.ui;
22

33
import android.content.Context;
4+
import android.content.Intent;
45
import android.net.Uri;
56
import android.os.Build;
67
import android.os.Bundle;
@@ -28,7 +29,6 @@
2829
import java.util.ArrayList;
2930
import java.util.Arrays;
3031
import java.util.List;
31-
import java.util.Objects;
3232

3333
import it.danieleverducci.ojo.R;
3434
import it.danieleverducci.ojo.Settings;
@@ -100,6 +100,8 @@ public void onResume() {
100100
cv.startPlayback();
101101
}
102102

103+
expandToCameraViewIfRequired();
104+
103105
// Register for back pressed events
104106
((MainActivity)getActivity()).setOnBackButtonPressedListener(new OnBackButtonPressedListener() {
105107
@Override
@@ -256,6 +258,44 @@ private int[] calcGridDimensionsBasedOnNumberOfElements(int elements) {
256258
return dimensions;
257259
}
258260

261+
private void expandToCameraViewIfRequired() {
262+
final String EXTRA_CAMERA_NUMBER = "it.danieleverducci.ojo.CAMERA_NUMBER";
263+
final String EXTRA_CAMERA_NAME = "it.danieleverducci.ojo.CAMERA_NAME";
264+
final String OPEN_CAMERA = "it.danieleverducci.ojo.OPEN_CAMERA";
265+
266+
if (this.getActivity() == null) {
267+
return;
268+
}
269+
270+
Intent intent = this.getActivity().getIntent();
271+
272+
if (OPEN_CAMERA.equals(intent.getAction())) {
273+
String cameraName = intent.getStringExtra(EXTRA_CAMERA_NAME);
274+
if (cameraName == null) {
275+
int cameraNumber = intent.getIntExtra(EXTRA_CAMERA_NUMBER, 0) - 1;
276+
expandByIndex(cameraNumber);
277+
return;
278+
}
279+
expandByName(cameraName);
280+
}
281+
}
282+
283+
private void expandByIndex(int index) {
284+
if (index < 0 || cameraViews.size() <= index) {
285+
return;
286+
}
287+
hideAllCameraViewsButNot(cameraViews.get(index).surfaceView);
288+
}
289+
290+
private void expandByName(String name) {
291+
for(CameraView cameraView: cameraViews) {
292+
if (cameraView.camera.getName().equals(name)) {
293+
hideAllCameraViewsButNot(cameraView.surfaceView);
294+
break;
295+
}
296+
}
297+
}
298+
259299
/**
260300
* Contains all entities (views and java entities) related to a camera stream viewer
261301
*/

fastlane/metadata/android/en-US/full_description.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@ The stream decoding and rendering is demanded to VLC's library: without their ef
66
This app was specifically developed for F-Droid, as I couldn't find any open source RTSP vievers in the main repository.
77

88
The app can be opened deeplinking to url ojo://view
9+
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.
10+
The extra argument it.danieleverducci.ojo.CAMERA_NAME will open the app with the camera with the name you specified while adding the camera.
11+
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.
12+
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.
13+
adb -s <YOUR_DEVICE> shell am start -a it.danieleverducci.ojo.OPEN_CAMERA -f 268468224 --es it.danieleverducci.ojo.CAMERA_NAME <YOUR_CAMERA_NAME>
14+
adb -s <YOUR_DEVICE> shell am start -a it.danieleverducci.ojo.OPEN_CAMERA -f 268468224 --es it.danieleverducci.ojo.CAMERA_NUMBER <YOUR_CAMERA_NUMBER>

0 commit comments

Comments
 (0)