5 Commits

Author SHA1 Message Date
505f8bf54b Downgraded LibVLC library to fix black screen bug on certain devices 2021-10-24 13:57:39 +02:00
3c37c50843 Added F-Droid badge 2021-10-24 12:49:46 +02:00
448ff4d2b3 v0.0.2 2021-10-14 16:57:17 +02:00
82810f06e1 Fixed navigation 2021-10-14 16:54:59 +02:00
d207b78065 Working zoom 2021-10-14 16:44:28 +02:00
9 changed files with 77 additions and 37 deletions

2
.idea/compiler.xml generated
View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="CompilerConfiguration"> <component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" /> <bytecodeTargetLevel target="1.8" />
</component> </component>
</project> </project>

2
.idea/misc.xml generated
View File

@ -10,7 +10,7 @@
</option> </option>
</component> </component>
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View File

@ -3,8 +3,7 @@
# Ojo: the FLOSS RTSP Surveillance camera viewer for Android # Ojo: the FLOSS RTSP Surveillance camera viewer for Android
[<img src="https://raw.githubusercontent.com/andOTP/andOTP/master/assets/badges/get-it-on-github.png" height="80">](https://github.com/penguin86/ojo/releases/latest) [<img src="https://raw.githubusercontent.com/andOTP/andOTP/master/assets/badges/get-it-on-github.png" height="80">](https://github.com/penguin86/ojo/releases/latest)
[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png" alt="Get it on F-Droid" height="80">](https://f-droid.org/it/packages/it.danieleverducci.ojo)
F-droid build **coming soon!**
(Always prefer [F-Droid](https://f-droid.org) build, when possible). (Always prefer [F-Droid](https://f-droid.org) build, when possible).

View File

@ -10,8 +10,8 @@ android {
applicationId "it.danieleverducci.ojo" applicationId "it.danieleverducci.ojo"
minSdkVersion 17 minSdkVersion 17
targetSdkVersion 30 targetSdkVersion 30
versionCode 1 versionCode 3
versionName "0.0.1" versionName "0.0.3"
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
@ -39,7 +39,8 @@ dependencies {
implementation 'com.google.android.material:material:1.4.0' implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.navigation:navigation-fragment:2.3.5' implementation 'androidx.navigation:navigation-fragment:2.3.5'
implementation 'androidx.navigation:navigation-ui:2.3.5' implementation 'androidx.navigation:navigation-ui:2.3.5'
implementation 'org.videolan.android:libvlc-all:3.4.1' //implementation 'org.videolan.android:libvlc-all:3.4.1'
implementation 'de.mrmaffen:libvlc-android:2.1.12@aar'
testImplementation 'junit:junit:4.+' testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

View File

@ -0,0 +1,18 @@
{
"version": 2,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "it.danieleverducci.ojo",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"versionCode": 1,
"versionName": "0.0.1",
"outputFile": "app-release.apk"
}
]
}

View File

@ -57,7 +57,7 @@ public class AddStreamFragment extends Fragment {
// Back to first fragment // Back to first fragment
NavHostFragment.findNavController(AddStreamFragment.this) NavHostFragment.findNavController(AddStreamFragment.this)
.navigate(R.id.action_SecondFragment_to_FirstFragment); .popBackStack();
} }
}); });
} }

View File

@ -18,7 +18,7 @@ import android.widget.LinearLayout;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import org.videolan.libvlc.interfaces.IVLCVout; import org.videolan.libvlc.IVLCVout;
import org.videolan.libvlc.LibVLC; import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.Media; import org.videolan.libvlc.Media;
import org.videolan.libvlc.MediaPlayer; import org.videolan.libvlc.MediaPlayer;
@ -52,14 +52,31 @@ public class SurveillanceFragment extends Fragment {
private FragmentSurveillanceBinding binding; private FragmentSurveillanceBinding binding;
private List<CameraView> cameraViews = new ArrayList<>(); private List<CameraView> cameraViews = new ArrayList<>();
int viewMargin; private boolean fullscreenCameraView = false;
private LinearLayout.LayoutParams cameraViewLayoutParams;
private LinearLayout.LayoutParams rowLayoutParams;
private LinearLayout.LayoutParams hiddenLayoutParams;
@Override @Override
public View onCreateView( public View onCreateView(
LayoutInflater inflater, ViewGroup container, LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState Bundle savedInstanceState
) { ) {
viewMargin = DpiUtils.DpToPixels(container.getContext(), 2); int viewMargin = DpiUtils.DpToPixels(container.getContext(), 2);
cameraViewLayoutParams = new LinearLayout.LayoutParams(
0,
LinearLayout.LayoutParams.MATCH_PARENT,
1.0f
);
cameraViewLayoutParams.setMargins(viewMargin,viewMargin,viewMargin,viewMargin);
rowLayoutParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT,
1.0f
);
hiddenLayoutParams = new LinearLayout.LayoutParams(0, 0);
binding = FragmentSurveillanceBinding.inflate(inflater, container, false); binding = FragmentSurveillanceBinding.inflate(inflater, container, false);
return binding.getRoot(); return binding.getRoot();
@ -114,29 +131,30 @@ public class SurveillanceFragment extends Fragment {
for (int r = 0; r < elemsPerSide; r++) { for (int r = 0; r < elemsPerSide; r++) {
// Create row and add to row container // Create row and add to row container
LinearLayout row = new LinearLayout(getContext()); LinearLayout row = new LinearLayout(getContext());
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( binding.gridRowContainer.addView(row, rowLayoutParams);
LinearLayout.LayoutParams.MATCH_PARENT,
0,
1.0f
);
binding.gridRowContainer.addView(row, params);
// Add camera viewers to the row // Add camera viewers to the row
for (int c = 0; c < elemsPerSide; c++) { for (int c = 0; c < elemsPerSide; c++) {
if ( camIdx < cc.size() ) { if ( camIdx < cc.size() ) {
Camera cam = cc.get(camIdx); Camera cam = cc.get(camIdx);
CameraView cv = addCameraView(cam, row); CameraView cv = addCameraView(cam, row);
cv.startPlayback(); cv.startPlayback();
cv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Toggle single/multi camera views
fullscreenCameraView = !fullscreenCameraView;
if (fullscreenCameraView) {
hideAllCameraViewsButNot(v);
} else {
showAllCameras();
}
}
});
} else { } else {
// Cameras are less than the maximum number of cells in grid: fill remaining cells with empty views // Cameras are less than the maximum number of cells in grid: fill remaining cells with empty views
View ev = new View(getContext()); View ev = new View(getContext());
ev.setBackgroundColor(getResources().getColor(R.color.purple_700)); ev.setBackgroundColor(getResources().getColor(R.color.purple_700));
LinearLayout.LayoutParams evParams = new LinearLayout.LayoutParams( row.addView(ev, cameraViewLayoutParams);
0,
LinearLayout.LayoutParams.MATCH_PARENT,
1.0f
);
evParams.setMargins(viewMargin,viewMargin,viewMargin,viewMargin);
row.addView(ev, evParams);
} }
camIdx++; camIdx++;
} }
@ -156,22 +174,26 @@ public class SurveillanceFragment extends Fragment {
protected void hideAllCameraViewsButNot(View cameraView) { protected void hideAllCameraViewsButNot(View cameraView) {
for (int i = 0; i < binding.gridRowContainer.getChildCount(); i++) { for (int i = 0; i < binding.gridRowContainer.getChildCount(); i++) {
LinearLayout row = (LinearLayout) binding.gridRowContainer.getChildAt(i); LinearLayout row = (LinearLayout) binding.gridRowContainer.getChildAt(i);
boolean emptyRow = true;
for (int j = 0; j < row.getChildCount(); j++) { for (int j = 0; j < row.getChildCount(); j++) {
View cam = row.getChildAt(j); View cam = row.getChildAt(j);
if (cameraView.getId() == cam.getId()) if (cameraView == cam)
cam.setVisibility(View.VISIBLE); emptyRow = false;
else else
cam.setVisibility(View.GONE); cam.setLayoutParams(hiddenLayoutParams);
} }
if (emptyRow)
row.setLayoutParams(hiddenLayoutParams);
} }
} }
protected void showAllCameras() { protected void showAllCameras() {
for (int i = 0; i < binding.gridRowContainer.getChildCount(); i++) { for (int i = 0; i < binding.gridRowContainer.getChildCount(); i++) {
LinearLayout row = (LinearLayout) binding.gridRowContainer.getChildAt(i); LinearLayout row = (LinearLayout) binding.gridRowContainer.getChildAt(i);
row.setLayoutParams(rowLayoutParams);
for (int j = 0; j < row.getChildCount(); j++) { for (int j = 0; j < row.getChildCount(); j++) {
View cam = row.getChildAt(j); View cam = row.getChildAt(j);
cam.setVisibility(View.VISIBLE); cam.setLayoutParams(cameraViewLayoutParams);
} }
} }
} }
@ -183,13 +205,7 @@ public class SurveillanceFragment extends Fragment {
); );
// Add to layout // Add to layout
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( rowContainer.addView(cv.surfaceView, cameraViewLayoutParams);
0,
LinearLayout.LayoutParams.MATCH_PARENT,
1.0f
);
params.setMargins(viewMargin,viewMargin,viewMargin,viewMargin);
rowContainer.addView(cv.surfaceView, params);
cameraViews.add(cv); cameraViews.add(cv);
return cv; return cv;
@ -223,7 +239,7 @@ public class SurveillanceFragment extends Fragment {
surfaceView.setOnClickListener(new View.OnClickListener() { surfaceView.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
SurveillanceFragment.this.hideAllCameraViewsButNot(v);
} }
}); });
SurfaceHolder holder = surfaceView.getHolder(); SurfaceHolder holder = surfaceView.getHolder();
@ -250,6 +266,10 @@ public class SurveillanceFragment extends Fragment {
}); });
} }
public void setOnClickListener(View.OnClickListener listener) {
surfaceView.setOnClickListener(listener);
}
/** /**
* Starts the playback. * Starts the playback.
*/ */

View File

@ -0,0 +1 @@
Downgraded LibVLC library to fix black screen bug on certain devices

View File

@ -0,0 +1 @@
Downgrade della libreria libVLC per risolvere il bug della schermata nera in determinati dispositivi