diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index c9378d8..1bfc8b9 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -6,12 +6,12 @@ - - + + - + \ No newline at end of file diff --git a/README.md b/README.md index 72221a4..6bcd197 100644 --- a/README.md +++ b/README.md @@ -16,3 +16,7 @@ This app was specifically developed for F-Droid, as I couldn't find any open sou ![Screenshot 1](media/screenshots/1.png) ![Screenshot 2](media/screenshots/2.png) ![Screenshot 3](media/screenshots/3.png) +## Contributors +Thanks to [brenard](https://github.com/brenard) for the new grid sizing method +Thanks to [davquar](https://github.com/davquar) for the fullscreen compatibility fix on Android 11 + diff --git a/app/build.gradle b/app/build.gradle index 2a49c9e..6037793 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,7 +6,7 @@ android { compileSdkVersion 33 defaultConfig { - applicationId "it.danieleverducci.ojo.googleplay" + applicationId "it.danieleverducci.ojo" minSdkVersion 21 targetSdkVersion 33 versionCode 6 diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json index 9d79c34..3a6eae8 100644 --- a/app/release/output-metadata.json +++ b/app/release/output-metadata.json @@ -1,18 +1,20 @@ { - "version": 2, + "version": 3, "artifactType": { "type": "APK", "kind": "Directory" }, - "applicationId": "it.danieleverducci.ojo", + "applicationId": "it.danieleverducci.ojo.googleplay", "variantName": "release", "elements": [ { "type": "SINGLE", "filters": [], - "versionCode": 4, - "versionName": "0.1.0", + "attributes": [], + "versionCode": 6, + "versionName": "0.1.1", "outputFile": "app-release.apk" } - ] + ], + "elementType": "File" } \ No newline at end of file diff --git a/app/src/main/java/it/danieleverducci/ojo/ui/MainActivity.java b/app/src/main/java/it/danieleverducci/ojo/ui/MainActivity.java index b24d01c..aa75cb1 100644 --- a/app/src/main/java/it/danieleverducci/ojo/ui/MainActivity.java +++ b/app/src/main/java/it/danieleverducci/ojo/ui/MainActivity.java @@ -1,11 +1,13 @@ package it.danieleverducci.ojo.ui; import android.content.pm.ActivityInfo; +import android.os.Build; import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; import android.util.Log; +import android.view.WindowManager; import androidx.navigation.NavController; import androidx.navigation.Navigation; @@ -26,6 +28,14 @@ public class MainActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + // Interface can go below notches + if (Build.VERSION.SDK_INT >= 28) { + getWindow().setFlags( + WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, + WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS + ); + } + rotationEnabledSetting = SharedPreferencesManager.loadRotationEnabled(this); this.setRequestedOrientation(this.rotationEnabledSetting ? ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 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 3b52164..91e9225 100644 --- a/app/src/main/java/it/danieleverducci/ojo/ui/SurveillanceFragment.java +++ b/app/src/main/java/it/danieleverducci/ojo/ui/SurveillanceFragment.java @@ -12,10 +12,12 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.view.Window; -import android.view.WindowInsets; -import android.view.WindowInsetsController; +import android.view.WindowManager; import android.widget.LinearLayout; +import androidx.core.view.WindowCompat; +import androidx.core.view.WindowInsetsCompat; +import androidx.core.view.WindowInsetsControllerCompat; import androidx.fragment.app.Fragment; import org.videolan.libvlc.IVLCVout; @@ -26,6 +28,7 @@ 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; @@ -87,24 +90,7 @@ public class SurveillanceFragment extends Fragment { public void onResume() { super.onResume(); - // Leanback mode (fullscreen) - Window window = getActivity().getWindow(); - if (window != null) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - final WindowInsetsController controller = window.getInsetsController(); - - if (controller != null) - controller.hide(WindowInsets.Type.statusBars()); - } else { - window.getDecorView().setSystemUiVisibility( - View.SYSTEM_UI_FLAG_FULLSCREEN - | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_IMMERSIVE - | View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); - } - } + leanbackMode(true); fullscreenCameraView = false; addAllCameras(); @@ -128,23 +114,46 @@ public class SurveillanceFragment extends Fragment { }); } + /** + * Goes fullscreen igoring the device screen insets (camera etc) + */ + private void leanbackMode(boolean leanback) { + Window w = requireActivity().getWindow(); + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) + return; + + if (leanback) { + // Iterface can go below notch + /*w.setFlags( + WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, + WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS + );*/ + w.getAttributes().layoutInDisplayCutoutMode = + WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; + + // Hide system bar + WindowInsetsControllerCompat windowInsetsController = WindowCompat.getInsetsController(w, w.getDecorView()); + windowInsetsController.hide(WindowInsetsCompat.Type.systemBars()); + // System bar is hidden when not touched for a while + windowInsetsController.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); + } else { + // Interface cannot go below notch + /*w.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); + w.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); + w.getAttributes().layoutInDisplayCutoutMode = + WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;*/ + + // Show system bar + WindowInsetsControllerCompat windowInsetsController = WindowCompat.getInsetsController(w, w.getDecorView()); + windowInsetsController.show(WindowInsetsCompat.Type.systemBars()); + } + } + @Override public void onPause() { super.onPause(); - // Disable Leanback mode (fullscreen) - Window window = getActivity().getWindow(); - if (window != null) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - final WindowInsetsController controller = window.getInsetsController(); - - if (controller != null) - controller.show(WindowInsets.Type.statusBars()); - } else { - window.getDecorView().setSystemUiVisibility( - View.SYSTEM_UI_FLAG_VISIBLE); - } - } + leanbackMode(false); disposeAllCameras(); } diff --git a/app/src/main/res/values-v27/themes.xml b/app/src/main/res/values-v27/themes.xml index 2639df9..1ed4139 100644 --- a/app/src/main/res/values-v27/themes.xml +++ b/app/src/main/res/values-v27/themes.xml @@ -1,7 +1,6 @@ \ No newline at end of file