From 390847ab95597a2ef4107c92128f502c43bb386c Mon Sep 17 00:00:00 2001 From: Daniele Date: Wed, 13 Oct 2021 17:20:53 +0200 Subject: [PATCH] Colors --- .../ojo/ui/SurveillanceFragment.java | 36 +++++++++++++++++-- app/src/main/res/layout/activity_main.xml | 3 +- app/src/main/res/values-night/themes.xml | 11 +++--- app/src/main/res/values-v27/themes.xml | 4 +-- app/src/main/res/values/colors.xml | 2 -- app/src/main/res/values/themes.xml | 9 ++--- 6 files changed, 45 insertions(+), 20 deletions(-) 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 457822b..e57585f 100644 --- a/app/src/main/java/it/danieleverducci/ojo/ui/SurveillanceFragment.java +++ b/app/src/main/java/it/danieleverducci/ojo/ui/SurveillanceFragment.java @@ -16,7 +16,6 @@ import android.view.WindowInsets; import android.view.WindowInsetsController; import android.widget.LinearLayout; -import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import org.videolan.libvlc.interfaces.IVLCVout; @@ -53,12 +52,14 @@ public class SurveillanceFragment extends Fragment { private FragmentSurveillanceBinding binding; private List cameraViews = new ArrayList<>(); + int viewMargin; @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState ) { + viewMargin = DpiUtils.DpToPixels(container.getContext(), 2); binding = FragmentSurveillanceBinding.inflate(inflater, container, false); return binding.getRoot(); @@ -128,12 +129,13 @@ public class SurveillanceFragment extends Fragment { } else { // Cameras are less than the maximum number of cells in grid: fill remaining cells with empty views View ev = new View(getContext()); - ev.setBackgroundColor(getResources().getColor(R.color.purple_500)); + ev.setBackgroundColor(getResources().getColor(R.color.purple_700)); LinearLayout.LayoutParams evParams = new LinearLayout.LayoutParams( 0, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f ); + evParams.setMargins(viewMargin,viewMargin,viewMargin,viewMargin); row.addView(ev, evParams); } camIdx++; @@ -151,6 +153,29 @@ public class SurveillanceFragment extends Fragment { binding.gridRowContainer.removeAllViews(); } + protected void hideAllCameraViewsButNot(View cameraView) { + for (int i = 0; i < binding.gridRowContainer.getChildCount(); i++) { + LinearLayout row = (LinearLayout) binding.gridRowContainer.getChildAt(i); + for (int j = 0; j < row.getChildCount(); j++) { + View cam = row.getChildAt(j); + if (cameraView.getId() == cam.getId()) + cam.setVisibility(View.VISIBLE); + else + cam.setVisibility(View.GONE); + } + } + } + + protected void showAllCameras() { + for (int i = 0; i < binding.gridRowContainer.getChildCount(); i++) { + LinearLayout row = (LinearLayout) binding.gridRowContainer.getChildAt(i); + for (int j = 0; j < row.getChildCount(); j++) { + View cam = row.getChildAt(j); + cam.setVisibility(View.VISIBLE); + } + } + } + private CameraView addCameraView(Camera camera, LinearLayout rowContainer) { CameraView cv = new CameraView( getContext(), @@ -163,7 +188,6 @@ public class SurveillanceFragment extends Fragment { LinearLayout.LayoutParams.MATCH_PARENT, 1.0f ); - int viewMargin = DpiUtils.DpToPixels(rowContainer.getContext(), 2); params.setMargins(viewMargin,viewMargin,viewMargin,viewMargin); rowContainer.addView(cv.surfaceView, params); @@ -196,6 +220,12 @@ public class SurveillanceFragment extends Fragment { this.libvlc = new LibVLC(context, new ArrayList<>(Arrays.asList(VLC_OPTIONS))); surfaceView = new SurfaceView(context); + surfaceView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + SurveillanceFragment.this.hideAllCameraViewsButNot(v); + } + }); SurfaceHolder holder = surfaceView.getHolder(); holder.setKeepScreenOn(true); diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index cdcd3af..ba4c96f 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -14,6 +14,7 @@ android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin" - app:srcCompat="@drawable/ic_add_camera" /> + app:srcCompat="@drawable/ic_add_camera" + app:tint="@color/purple_500"/> \ No newline at end of file diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml index 29c7123..fa08e79 100644 --- a/app/src/main/res/values-night/themes.xml +++ b/app/src/main/res/values-night/themes.xml @@ -1,16 +1,15 @@ - \ No newline at end of file diff --git a/app/src/main/res/values-v27/themes.xml b/app/src/main/res/values-v27/themes.xml index fbc2c4e..2639df9 100644 --- a/app/src/main/res/values-v27/themes.xml +++ b/app/src/main/res/values-v27/themes.xml @@ -9,8 +9,8 @@ @color/purple_700 @color/white - @color/teal_200 - @color/teal_700 + @color/purple_200 + @color/purple_700 @color/black ?attr/colorPrimaryVariant diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index f8c6127..e487941 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -3,8 +3,6 @@ #FFBB86FC #FF6200EE #FF3700B3 - #FF03DAC5 - #FF018786 #FF000000 #FFFFFFFF \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 267b5dc..7ce18d5 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -9,12 +9,9 @@ @color/purple_700 @color/white - @color/teal_200 - @color/teal_700 - @color/black - - ?attr/colorPrimaryVariant - + @color/purple_500 + @color/purple_700 + @color/white \ No newline at end of file