Full screen mode, added license, a little theming
This commit is contained in:
parent
35c1355de2
commit
254a685387
@ -3,6 +3,7 @@ package it.danieleverducci.ojo.ui;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
@ -12,9 +13,15 @@ import android.view.SurfaceView;
|
||||
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.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.core.view.WindowInsetsControllerCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
|
||||
@ -31,6 +38,7 @@ import it.danieleverducci.ojo.R;
|
||||
import it.danieleverducci.ojo.Settings;
|
||||
import it.danieleverducci.ojo.databinding.FragmentSurveillanceBinding;
|
||||
import it.danieleverducci.ojo.entities.Camera;
|
||||
import it.danieleverducci.ojo.utils.DpiUtils;
|
||||
|
||||
/**
|
||||
* Some streams to test:
|
||||
@ -98,18 +106,32 @@ public class SurveillanceFragment extends Fragment implements MediaPlayer.EventL
|
||||
camIdx++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
// Start playback for all streams
|
||||
for (CameraView cv : cameraViews) {
|
||||
cv.startPlayback();
|
||||
}
|
||||
@ -174,6 +196,8 @@ public class SurveillanceFragment extends Fragment implements MediaPlayer.EventL
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
1.0f
|
||||
);
|
||||
int viewMargin = DpiUtils.DpToPixels(rowContainer.getContext(), 2);
|
||||
params.setMargins(viewMargin,viewMargin,viewMargin,viewMargin);
|
||||
rowContainer.addView(cv.surfaceView, params);
|
||||
|
||||
cameraViews.add(cv);
|
||||
|
16
app/src/main/java/it/danieleverducci/ojo/utils/DpiUtils.java
Normal file
16
app/src/main/java/it/danieleverducci/ojo/utils/DpiUtils.java
Normal file
@ -0,0 +1,16 @@
|
||||
package it.danieleverducci.ojo.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.util.TypedValue;
|
||||
|
||||
public class DpiUtils {
|
||||
public static int DpToPixels(Context context, int dp) {
|
||||
Resources r = context.getResources();
|
||||
return (int) TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_DIP,
|
||||
dp,
|
||||
r.getDisplayMetrics()
|
||||
);
|
||||
}
|
||||
}
|
@ -1,26 +1,81 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="50dp"
|
||||
android:orientation="vertical"
|
||||
tools:context=".ui.SurveillanceFragment">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/stream_url"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/add_stream_placeholder_url"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
android:inputType="textUri"/>
|
||||
<Button
|
||||
android:id="@+id/save"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="50dp"
|
||||
android:text="@string/add_stream_save"/>
|
||||
android:padding="50dp"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="50dp"
|
||||
android:src="@mipmap/ic_launcher_round"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/add_stream"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/stream_url"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:hint="@string/add_stream_placeholder_url"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
android:inputType="textUri"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/save"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="30dp"
|
||||
android:text="@string/add_stream_save"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="50dp"
|
||||
android:background="@color/purple_200"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Title"
|
||||
android:textColor="@color/purple_500"
|
||||
android:text="@string/app_info_title"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="@string/app_info_creator_desc"
|
||||
android:autoLink="web"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="@string/app_info_license_desc"
|
||||
android:autoLink="web"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="@string/app_info_repo_desc"
|
||||
android:autoLink="web"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
19
app/src/main/res/values-v27/themes.xml
Normal file
19
app/src/main/res/values-v27/themes.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<style name="Theme.Ojo" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_500</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
<item name="colorOnPrimary">@color/white</item>
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/teal_200</item>
|
||||
<item name="colorSecondaryVariant">@color/teal_700</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
</resources>
|
@ -8,8 +8,14 @@
|
||||
<string name="previous">Previous</string>
|
||||
|
||||
<string name="add_stream_placeholder_url">rtsp://username:password@192.168.1.123:554</string>
|
||||
<string name="add_stream">Please insert your camera\'s RTSP stream. Note that the URL differs from camera to camera: you can find the complete URL in your camera\'s settings or user manual.</string>
|
||||
<string name="add_stream_save">Save</string>
|
||||
<string name="add_stream_invalid_url">Invalid RTSP url</string>
|
||||
<string name="add_stream_invalid_url_dismiss">Dismiss</string>
|
||||
<string name="add_stream_error_saving">An error has occurred while saving configuration</string>
|
||||
|
||||
<string name="app_info_title">About Ojo</string>
|
||||
<string name="app_info_creator_desc">Created by Daniele Verducci.</string>
|
||||
<string name="app_info_license_desc">This application is licensed under the GNU GENERAL PUBLIC LICENSE v3+. You can obtain a copy here: https://raw.githubusercontent.com/penguin86/ojo/master/LICENSE</string>
|
||||
<string name="app_info_repo_desc">The source code can be obtained at the github repository: https://github.com/penguin86/ojo</string>
|
||||
</resources>
|
@ -1,3 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.Ojo" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||
|
Loading…
Reference in New Issue
Block a user