Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
0f13e23f09 | |||
02bac4671e | |||
9d6d97b10f | |||
5ec000d1c9 | |||
d3cb5abe27 | |||
66d0a1081a | |||
1647895a2a | |||
1ad6500882 | |||
dfb30bef9e | |||
2f9af2e1f1 | |||
333b44cba3 | |||
182a9a9b89 | |||
ff5b6b8101 |
17
.idea/deploymentTargetDropDown.xml
generated
Normal file
17
.idea/deploymentTargetDropDown.xml
generated
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="deploymentTargetDropDown">
|
||||||
|
<targetSelectedWithDropDown>
|
||||||
|
<Target>
|
||||||
|
<type value="QUICK_BOOT_TARGET" />
|
||||||
|
<deviceKey>
|
||||||
|
<Key>
|
||||||
|
<type value="VIRTUAL_DEVICE_PATH" />
|
||||||
|
<value value="$USER_HOME$/.android/avd/Pixel_XL_Android_12.avd" />
|
||||||
|
</Key>
|
||||||
|
</deviceKey>
|
||||||
|
</Target>
|
||||||
|
</targetSelectedWithDropDown>
|
||||||
|
<timeTargetWasSelectedWithDropDown value="2023-03-10T07:05:42.920194Z" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -16,3 +16,7 @@ This app was specifically developed for F-Droid, as I couldn't find any open sou
|
|||||||
|
|
||||||
  
|
  
|
||||||
|
|
||||||
|
## 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
|
||||||
|
|
||||||
|
@ -3,15 +3,14 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 30
|
compileSdkVersion 33
|
||||||
buildToolsVersion "30.0.2"
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "it.danieleverducci.ojo"
|
applicationId "it.danieleverducci.ojo"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 30
|
targetSdkVersion 33
|
||||||
versionCode 4
|
versionCode 7
|
||||||
versionName "0.1.0"
|
versionName "0.1.2"
|
||||||
|
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
|
|
||||||
@ -31,19 +30,19 @@ android {
|
|||||||
buildFeatures {
|
buildFeatures {
|
||||||
viewBinding true
|
viewBinding true
|
||||||
}
|
}
|
||||||
|
namespace 'it.danieleverducci.ojo'
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
||||||
implementation 'androidx.appcompat:appcompat:1.3.1'
|
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||||
implementation 'com.google.android.material:material:1.4.0'
|
implementation 'com.google.android.material:material:1.8.0'
|
||||||
implementation 'androidx.navigation:navigation-fragment:2.3.5'
|
implementation 'androidx.navigation:navigation-fragment:2.5.3'
|
||||||
implementation 'androidx.navigation:navigation-ui:2.3.5'
|
implementation 'androidx.navigation:navigation-ui:2.5.3'
|
||||||
//implementation 'org.videolan.android:libvlc-all:3.4.1'
|
|
||||||
implementation 'de.mrmaffen:libvlc-android:2.1.12@aar'
|
implementation 'de.mrmaffen:libvlc-android:2.1.12@aar'
|
||||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
||||||
testImplementation 'junit:junit:4.+'
|
testImplementation 'junit:junit:4.+'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||||
}
|
}
|
@ -1,18 +1,20 @@
|
|||||||
{
|
{
|
||||||
"version": 2,
|
"version": 3,
|
||||||
"artifactType": {
|
"artifactType": {
|
||||||
"type": "APK",
|
"type": "APK",
|
||||||
"kind": "Directory"
|
"kind": "Directory"
|
||||||
},
|
},
|
||||||
"applicationId": "it.danieleverducci.ojo",
|
"applicationId": "it.danieleverducci.ojo.googleplay",
|
||||||
"variantName": "release",
|
"variantName": "release",
|
||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"type": "SINGLE",
|
"type": "SINGLE",
|
||||||
"filters": [],
|
"filters": [],
|
||||||
"versionCode": 4,
|
"attributes": [],
|
||||||
"versionName": "0.1.0",
|
"versionCode": 6,
|
||||||
|
"versionName": "0.1.1",
|
||||||
"outputFile": "app-release.apk"
|
"outputFile": "app-release.apk"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"elementType": "File"
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
package="it.danieleverducci.ojo">
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
@ -12,10 +11,17 @@
|
|||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.Ojo">
|
android:theme="@style/Theme.Ojo">
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.MainActivity"
|
android:name=".ui.SettingsActivity"
|
||||||
|
android:exported="true"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/Theme.Ojo"
|
android:theme="@style/Theme.Ojo">
|
||||||
android:configChanges="orientation|screenSize">
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".ui.MainActivity"
|
||||||
|
android:configChanges="orientation|screenSize"
|
||||||
|
android:exported="true"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:theme="@style/Theme.Ojo">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
@ -15,4 +15,8 @@ public class SharedPreferencesManager {
|
|||||||
SharedPreferences sharedPref = ctx.getSharedPreferences(SP_ROTATION_ENABLED, Context.MODE_PRIVATE);
|
SharedPreferences sharedPref = ctx.getSharedPreferences(SP_ROTATION_ENABLED, Context.MODE_PRIVATE);
|
||||||
return sharedPref.getBoolean(SP_ROTATION_ENABLED, false);
|
return sharedPref.getBoolean(SP_ROTATION_ENABLED, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void toggleRotationEnabled(Context ctx) {
|
||||||
|
saveRotationEnabled(ctx, ! loadRotationEnabled(ctx));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,13 @@
|
|||||||
package it.danieleverducci.ojo.ui;
|
package it.danieleverducci.ojo.ui;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.navigation.NavController;
|
|
||||||
import androidx.navigation.Navigation;
|
|
||||||
|
|
||||||
import it.danieleverducci.ojo.R;
|
|
||||||
import it.danieleverducci.ojo.SharedPreferencesManager;
|
import it.danieleverducci.ojo.SharedPreferencesManager;
|
||||||
import it.danieleverducci.ojo.databinding.ActivityMainBinding;
|
import it.danieleverducci.ojo.databinding.ActivityMainBinding;
|
||||||
|
|
||||||
@ -20,35 +15,32 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
private static final String TAG = "MainActivity";
|
private static final String TAG = "MainActivity";
|
||||||
|
|
||||||
private ActivityMainBinding binding;
|
private ActivityMainBinding binding;
|
||||||
private NavController navController;
|
|
||||||
private boolean rotationEnabledSetting;
|
|
||||||
private OnBackButtonPressedListener onBackButtonPressedListener;
|
private OnBackButtonPressedListener onBackButtonPressedListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
rotationEnabledSetting = SharedPreferencesManager.loadRotationEnabled(this);
|
// Interface can go below notches
|
||||||
this.setRequestedOrientation(this.rotationEnabledSetting ? ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
if (Build.VERSION.SDK_INT >= 28) {
|
||||||
|
getWindow().setFlags(
|
||||||
|
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
|
||||||
|
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
binding = ActivityMainBinding.inflate(getLayoutInflater());
|
binding = ActivityMainBinding.inflate(getLayoutInflater());
|
||||||
setContentView(binding.getRoot());
|
setContentView(binding.getRoot());
|
||||||
|
|
||||||
// Show FAB only on first fragment
|
binding.fab.setOnClickListener(view -> openSettings());
|
||||||
navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_main);
|
}
|
||||||
navController.addOnDestinationChangedListener((controller, destination, arguments) -> {
|
|
||||||
if (destination.getId() == R.id.HomeFragment)
|
|
||||||
binding.fab.show();
|
|
||||||
else
|
|
||||||
binding.fab.hide();
|
|
||||||
});
|
|
||||||
|
|
||||||
binding.fab.setOnClickListener(new View.OnClickListener() {
|
@Override
|
||||||
@Override
|
protected void onStart() {
|
||||||
public void onClick(View view) {
|
boolean rotationEnabledSetting = SharedPreferencesManager.loadRotationEnabled(this);
|
||||||
navigateToFragment(R.id.action_homeToSettings);
|
this.setRequestedOrientation(rotationEnabledSetting ? ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||||
}
|
|
||||||
});
|
super.onStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOnBackButtonPressedListener(OnBackButtonPressedListener onBackButtonPressedListener) {
|
public void setOnBackButtonPressedListener(OnBackButtonPressedListener onBackButtonPressedListener) {
|
||||||
@ -62,28 +54,9 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void navigateToFragment(int actionId) {
|
private void openSettings() {
|
||||||
navigateToFragment(actionId, null);
|
Intent i = new Intent(this, SettingsActivity.class);
|
||||||
|
startActivity(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void navigateToFragment(int actionId, Bundle bundle) {
|
|
||||||
if (navController == null) {
|
|
||||||
Log.e(TAG, "Not initialized");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bundle != null)
|
|
||||||
navController.navigate(actionId, bundle);
|
|
||||||
else
|
|
||||||
navController.navigate(actionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getRotationEnabledSetting() {
|
|
||||||
return this.rotationEnabledSetting;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toggleRotationEnabledSetting() {
|
|
||||||
this.rotationEnabledSetting = !this.rotationEnabledSetting;
|
|
||||||
this.setRequestedOrientation(this.rotationEnabledSetting ? ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
package it.danieleverducci.ojo.ui;
|
||||||
|
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.navigation.NavController;
|
||||||
|
import androidx.navigation.Navigation;
|
||||||
|
|
||||||
|
import it.danieleverducci.ojo.R;
|
||||||
|
import it.danieleverducci.ojo.SharedPreferencesManager;
|
||||||
|
import it.danieleverducci.ojo.databinding.ActivitySettingsBinding;
|
||||||
|
|
||||||
|
public class SettingsActivity extends AppCompatActivity {
|
||||||
|
private static final String TAG = "SettingsActivity";
|
||||||
|
|
||||||
|
private ActivitySettingsBinding binding;
|
||||||
|
private NavController navController;
|
||||||
|
private OnBackButtonPressedListener onBackButtonPressedListener;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
binding = ActivitySettingsBinding.inflate(getLayoutInflater());
|
||||||
|
setContentView(binding.getRoot());
|
||||||
|
|
||||||
|
navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnBackButtonPressedListener(OnBackButtonPressedListener onBackButtonPressedListener) {
|
||||||
|
this.onBackButtonPressedListener = onBackButtonPressedListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
if (this.onBackButtonPressedListener != null && this.onBackButtonPressedListener.onBackPressed())
|
||||||
|
return;
|
||||||
|
super.onBackPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void navigateToFragment(int actionId) {
|
||||||
|
navigateToFragment(actionId, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void navigateToFragment(int actionId, Bundle bundle) {
|
||||||
|
if (navController == null) {
|
||||||
|
Log.e(TAG, "Not initialized");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (bundle != null)
|
||||||
|
navController.navigate(actionId, bundle);
|
||||||
|
else
|
||||||
|
navController.navigate(actionId);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Log.e(TAG, "Unable to navigate to fragment: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toggleRotationEnabledSetting() {
|
||||||
|
SharedPreferencesManager.toggleRotationEnabled(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getRotationEnabledSetting() {
|
||||||
|
return SharedPreferencesManager.loadRotationEnabled(this);
|
||||||
|
}
|
||||||
|
}
|
@ -48,7 +48,7 @@ public class SettingsFragment extends Fragment {
|
|||||||
binding.settingsToolbar.getOverflowIcon().setTint(Color.WHITE);
|
binding.settingsToolbar.getOverflowIcon().setTint(Color.WHITE);
|
||||||
binding.settingsToolbar.inflateMenu(R.menu.settings_menu);
|
binding.settingsToolbar.inflateMenu(R.menu.settings_menu);
|
||||||
MenuItem rotMenuItem = binding.settingsToolbar.getMenu().findItem(R.id.menuitem_allow_rotation);
|
MenuItem rotMenuItem = binding.settingsToolbar.getMenu().findItem(R.id.menuitem_allow_rotation);
|
||||||
rotMenuItem.setTitle(((MainActivity)getActivity()).getRotationEnabledSetting() ? R.string.menuitem_deny_rotation : R.string.menuitem_allow_rotation);
|
rotMenuItem.setTitle(((SettingsActivity)getActivity()).getRotationEnabledSetting() ? R.string.menuitem_deny_rotation : R.string.menuitem_allow_rotation);
|
||||||
|
|
||||||
// Register for item click
|
// Register for item click
|
||||||
binding.settingsToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
|
binding.settingsToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
|
||||||
@ -56,15 +56,15 @@ public class SettingsFragment extends Fragment {
|
|||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.menuitem_add_camera:
|
case R.id.menuitem_add_camera:
|
||||||
((MainActivity)getActivity()).navigateToFragment(R.id.action_settingsToCameraUrl);
|
((SettingsActivity)getActivity()).navigateToFragment(R.id.action_settingsToCameraUrl);
|
||||||
return true;
|
return true;
|
||||||
case R.id.menuitem_allow_rotation:
|
case R.id.menuitem_allow_rotation:
|
||||||
((MainActivity)getActivity()).toggleRotationEnabledSetting();
|
((SettingsActivity)getActivity()).toggleRotationEnabledSetting();
|
||||||
SharedPreferencesManager.saveRotationEnabled(getContext(), ((MainActivity)getActivity()).getRotationEnabledSetting());
|
SharedPreferencesManager.saveRotationEnabled(getContext(), ((SettingsActivity)getActivity()).getRotationEnabledSetting());
|
||||||
item.setTitle(((MainActivity)getActivity()).getRotationEnabledSetting() ? R.string.menuitem_deny_rotation : R.string.menuitem_allow_rotation);
|
item.setTitle(((SettingsActivity)getActivity()).getRotationEnabledSetting() ? R.string.menuitem_deny_rotation : R.string.menuitem_allow_rotation);
|
||||||
return true;
|
return true;
|
||||||
case R.id.menuitem_info:
|
case R.id.menuitem_info:
|
||||||
((MainActivity)getActivity()).navigateToFragment(R.id.action_SettingsToInfoFragment);
|
((SettingsActivity)getActivity()).navigateToFragment(R.id.action_SettingsToInfoFragment);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -96,7 +96,7 @@ public class SettingsFragment extends Fragment {
|
|||||||
public void onItemClick(int pos) {
|
public void onItemClick(int pos) {
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putInt(StreamUrlFragment.ARG_CAMERA, pos);
|
b.putInt(StreamUrlFragment.ARG_CAMERA, pos);
|
||||||
((MainActivity)getActivity()).navigateToFragment(R.id.action_settingsToCameraUrl, b);
|
((SettingsActivity)getActivity()).navigateToFragment(R.id.action_settingsToCameraUrl, b);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,12 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
import android.view.ViewTreeObserver;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowInsets;
|
import android.view.WindowManager;
|
||||||
import android.view.WindowInsetsController;
|
|
||||||
import android.widget.LinearLayout;
|
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 androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import org.videolan.libvlc.IVLCVout;
|
import org.videolan.libvlc.IVLCVout;
|
||||||
@ -26,6 +28,7 @@ import org.videolan.libvlc.MediaPlayer;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import it.danieleverducci.ojo.R;
|
import it.danieleverducci.ojo.R;
|
||||||
import it.danieleverducci.ojo.Settings;
|
import it.danieleverducci.ojo.Settings;
|
||||||
@ -76,7 +79,8 @@ public class SurveillanceFragment extends Fragment {
|
|||||||
1.0f
|
1.0f
|
||||||
);
|
);
|
||||||
|
|
||||||
hiddenLayoutParams = new LinearLayout.LayoutParams(0, 0);
|
// 1,1 instead of 0,0 because the latter doesn't work on android 13+
|
||||||
|
hiddenLayoutParams = new LinearLayout.LayoutParams(1, 1);
|
||||||
|
|
||||||
binding = FragmentSurveillanceBinding.inflate(inflater, container, false);
|
binding = FragmentSurveillanceBinding.inflate(inflater, container, false);
|
||||||
return binding.getRoot();
|
return binding.getRoot();
|
||||||
@ -86,24 +90,7 @@ public class SurveillanceFragment extends Fragment {
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
// Leanback mode (fullscreen)
|
leanbackMode(true);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fullscreenCameraView = false;
|
fullscreenCameraView = false;
|
||||||
addAllCameras();
|
addAllCameras();
|
||||||
@ -127,23 +114,35 @@ 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) {
|
||||||
|
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 {
|
||||||
|
// Show system bar
|
||||||
|
//WindowInsetsControllerCompat windowInsetsController = WindowCompat.getInsetsController(w, w.getDecorView());
|
||||||
|
//windowInsetsController.show(WindowInsetsCompat.Type.systemBars());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
// Disable Leanback mode (fullscreen)
|
leanbackMode(false);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
disposeAllCameras();
|
disposeAllCameras();
|
||||||
}
|
}
|
||||||
@ -153,14 +152,14 @@ public class SurveillanceFragment extends Fragment {
|
|||||||
Settings settings = Settings.fromDisk(getContext());
|
Settings settings = Settings.fromDisk(getContext());
|
||||||
List<Camera> cc = settings.getCameras();
|
List<Camera> cc = settings.getCameras();
|
||||||
|
|
||||||
int elemsPerSide = calcGridSideElements(cc.size());
|
int[] gridSize = calcGridDimensionsBasedOnNumberOfElements(cc.size());
|
||||||
int camIdx = 0;
|
int camIdx = 0;
|
||||||
for (int r = 0; r < elemsPerSide; r++) {
|
for (int r = 0; r < gridSize[0]; 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());
|
||||||
binding.gridRowContainer.addView(row, rowLayoutParams);
|
binding.gridRowContainer.addView(row, rowLayoutParams);
|
||||||
// Add camera viewers to the row
|
// Add camera viewers to the row
|
||||||
for (int c = 0; c < elemsPerSide; c++) {
|
for (int c = 0; c < gridSize[1]; 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);
|
||||||
@ -239,13 +238,22 @@ public class SurveillanceFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of elements per side needed to create a grid that can contain the provided elements number.
|
* Returns the dimensions of the grid based on the number of elements.
|
||||||
* Es: to display 3 elements is needed a 4-element grid, with 2 elements per side (a 2x2 grid)
|
* Es: to display 3 elements is needed a 4-element grid, with 2 elements per side (a 2x2 grid)
|
||||||
|
* Es: to display 6 elements is needed a 9-element grid, with 3 elements per side (a 2x3 grid)
|
||||||
* Es: to display 7 elements is needed a 9-element grid, with 3 elements per side (a 3x3 grid)
|
* Es: to display 7 elements is needed a 9-element grid, with 3 elements per side (a 3x3 grid)
|
||||||
* @param elements
|
* @param elements
|
||||||
*/
|
*/
|
||||||
private int calcGridSideElements(int elements) {
|
private int[] calcGridDimensionsBasedOnNumberOfElements(int elements) {
|
||||||
return (int)(Math.ceil(Math.sqrt(elements)));
|
int rows = 1;
|
||||||
|
int cols = 1;
|
||||||
|
while (rows * cols < elements) {
|
||||||
|
cols += 1;
|
||||||
|
if (rows * cols >= elements) break;
|
||||||
|
rows += 1;
|
||||||
|
}
|
||||||
|
int[] dimensions = {rows, cols};
|
||||||
|
return dimensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,7 +6,11 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".ui.MainActivity">
|
tools:context=".ui.MainActivity">
|
||||||
|
|
||||||
<include layout="@layout/content_main" />
|
<androidx.fragment.app.FragmentContainerView
|
||||||
|
android:id="@+id/fragment_surveillance"
|
||||||
|
android:name="it.danieleverducci.ojo.ui.SurveillanceFragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
android:id="@+id/fab"
|
android:id="@+id/fab"
|
||||||
@ -14,7 +18,12 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom|end"
|
android:layout_gravity="bottom|end"
|
||||||
android:layout_margin="@dimen/fab_margin"
|
android:layout_margin="@dimen/fab_margin"
|
||||||
|
android:src="@drawable/ic_settings"
|
||||||
app:srcCompat="@drawable/ic_settings"
|
app:srcCompat="@drawable/ic_settings"
|
||||||
app:tint="@color/purple_500"/>
|
app:tint="@color/fab_foreground"
|
||||||
|
android:tint="@color/fab_foreground"
|
||||||
|
android:backgroundTint="@color/fab_background"
|
||||||
|
android:hint="@string/fab_add_camera"
|
||||||
|
android:contentDescription="@string/fab_add_camera"/>
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
11
app/src/main/res/layout/activity_settings.xml
Normal file
11
app/src/main/res/layout/activity_settings.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout 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"
|
||||||
|
tools:context=".ui.SettingsActivity">
|
||||||
|
|
||||||
|
<include layout="@layout/content_settings" />
|
||||||
|
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
@ -6,7 +6,7 @@
|
|||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/nav_host_fragment_content_main"
|
android:id="@+id/nav_host_fragment_content_settings"
|
||||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
@ -17,7 +17,8 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="50dp"
|
android:layout_marginBottom="50dp"
|
||||||
android:src="@mipmap/ic_launcher_round"/>
|
android:background="@color/ic_launcher_background"
|
||||||
|
android:src="@drawable/ic_launcher_foreground"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:src="@mipmap/ic_launcher_round"/>
|
android:background="@color/ic_launcher_background"
|
||||||
|
android:src="@drawable/ic_launcher_foreground"/>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/settingsToolbar"
|
android:id="@+id/settingsToolbar"
|
||||||
app:title="@string/app_name"
|
app:title="@string/app_name"
|
||||||
style="@style/ToolBarStyle" />
|
style="@style/ToolBarStyle"
|
||||||
|
/>
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/list"
|
android:id="@+id/list"
|
||||||
|
@ -3,18 +3,8 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/nav_graph"
|
android:id="@+id/nav_graph"
|
||||||
app:startDestination="@id/HomeFragment">
|
app:startDestination="@id/SettingsFragment">
|
||||||
|
|
||||||
<fragment
|
|
||||||
android:id="@+id/HomeFragment"
|
|
||||||
android:name="it.danieleverducci.ojo.ui.SurveillanceFragment"
|
|
||||||
android:label="@string/first_fragment_label"
|
|
||||||
tools:layout="@layout/fragment_surveillance">
|
|
||||||
|
|
||||||
<action
|
|
||||||
android:id="@+id/action_homeToSettings"
|
|
||||||
app:destination="@id/SettingsFragment" />
|
|
||||||
</fragment>
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/CameraUrlFragment"
|
android:id="@+id/CameraUrlFragment"
|
||||||
android:name="it.danieleverducci.ojo.ui.StreamUrlFragment"
|
android:name="it.danieleverducci.ojo.ui.StreamUrlFragment"
|
||||||
@ -30,9 +20,6 @@
|
|||||||
android:label="fragment_settings_item_list"
|
android:label="fragment_settings_item_list"
|
||||||
tools:layout="@layout/fragment_settings_item_list" >
|
tools:layout="@layout/fragment_settings_item_list" >
|
||||||
|
|
||||||
<action
|
|
||||||
android:id="@+id/action_settingsToHome"
|
|
||||||
app:destination="@id/HomeFragment" />
|
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_settingsToCameraUrl"
|
android:id="@+id/action_settingsToCameraUrl"
|
||||||
app:destination="@id/CameraUrlFragment" />
|
app:destination="@id/CameraUrlFragment" />
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
<string name="first_fragment_label">First Fragment</string>
|
<string name="first_fragment_label">First Fragment</string>
|
||||||
<string name="second_fragment_label">Second Fragment</string>
|
<string name="second_fragment_label">Second Fragment</string>
|
||||||
|
|
||||||
|
<string name="fab_add_camera">Add</string>
|
||||||
|
|
||||||
<string name="stream_list_default_camera_name">Videocamera senza nome n°{camNo}</string>
|
<string name="stream_list_default_camera_name">Videocamera senza nome n°{camNo}</string>
|
||||||
|
|
||||||
<string name="add_stream_placeholder_url">rtsp://username:password@192.168.1.123:554</string>
|
<string name="add_stream_placeholder_url">rtsp://username:password@192.168.1.123:554</string>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
<style name="Theme.Ojo" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
<style name="Theme.Ojo" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||||
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
|
|
||||||
<item name="windowActionBar">false</item>
|
<item name="windowActionBar">false</item>
|
||||||
<item name="windowNoTitle">true</item>
|
<item name="windowNoTitle">true</item>
|
||||||
<!-- Primary brand color. -->
|
<!-- Primary brand color. -->
|
||||||
@ -13,7 +12,8 @@
|
|||||||
<item name="colorSecondaryVariant">@color/purple_700</item>
|
<item name="colorSecondaryVariant">@color/purple_700</item>
|
||||||
<item name="colorOnSecondary">@color/black</item>
|
<item name="colorOnSecondary">@color/black</item>
|
||||||
<!-- Status bar color. -->
|
<!-- Status bar color. -->
|
||||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||||
<!-- Customize your theme here. -->
|
<!-- Customize your theme here. -->
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
@ -5,4 +5,7 @@
|
|||||||
<color name="purple_700">#FF3700B3</color>
|
<color name="purple_700">#FF3700B3</color>
|
||||||
<color name="black">#FF000000</color>
|
<color name="black">#FF000000</color>
|
||||||
<color name="white">#FFFFFFFF</color>
|
<color name="white">#FFFFFFFF</color>
|
||||||
|
|
||||||
|
<color name="fab_foreground">@color/purple_500</color>
|
||||||
|
<color name="fab_background">@color/purple_200</color>
|
||||||
</resources>
|
</resources>
|
@ -4,6 +4,8 @@
|
|||||||
<string name="first_fragment_label">First Fragment</string>
|
<string name="first_fragment_label">First Fragment</string>
|
||||||
<string name="second_fragment_label">Second Fragment</string>
|
<string name="second_fragment_label">Second Fragment</string>
|
||||||
|
|
||||||
|
<string name="fab_add_camera">Add</string>
|
||||||
|
|
||||||
<string name="stream_list_default_camera_name">Unnamed camera {camNo}</string>
|
<string name="stream_list_default_camera_name">Unnamed camera {camNo}</string>
|
||||||
|
|
||||||
<string name="add_stream_placeholder_url">rtsp://username:password@192.168.1.123:554</string>
|
<string name="add_stream_placeholder_url">rtsp://username:password@192.168.1.123:554</string>
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
<style name="ToolBarStyle" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
|
<style name="ToolBarStyle" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
|
||||||
<item name="android:background">@color/purple_500</item>
|
<item name="android:background">@color/purple_500</item>
|
||||||
<item name="titleTextColor">@color/white</item>
|
<item name="titleTextColor">@color/white</item>
|
||||||
|
<item name="actionMenuTextColor">@color/white</item>
|
||||||
|
<item name="android:actionMenuTextColor">@color/white</item>
|
||||||
|
<item name="colorOnPrimary">@color/white</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -5,7 +5,7 @@ buildscript {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath "com.android.tools.build:gradle:4.2.2"
|
classpath 'com.android.tools.build:gradle:7.4.0'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
|||||||
#Fri Aug 13 07:42:34 CEST 2021
|
#Wed Feb 15 08:51:54 CET 2023
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
Reference in New Issue
Block a user