Add and reorder cams is working
This commit is contained in:
parent
b1fa8713e2
commit
85be9af409
@ -3,6 +3,9 @@
|
||||
<component name="DesignSurface">
|
||||
<option name="filePathToZoomLevelMap">
|
||||
<map>
|
||||
<entry key="../../../../layout/custom_preview.xml" value="0.36974358974358973" />
|
||||
<entry key="app/src/main/res/drawable/ic_add.xml" value="0.1565" />
|
||||
<entry key="app/src/main/res/drawable/ic_add_camera.xml" value="0.1565" />
|
||||
<entry key="app/src/main/res/layout/activity_main.xml" value="0.45" />
|
||||
<entry key="app/src/main/res/layout/fragment_add_stream.xml" value="0.524901185770751" />
|
||||
<entry key="app/src/main/res/layout/fragment_settings_item.xml" value="0.536" />
|
||||
|
@ -5,6 +5,7 @@ import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||
@ -31,14 +32,38 @@ import it.danieleverducci.ojo.utils.ItemMoveCallback;
|
||||
public class SettingsFragment extends Fragment {
|
||||
|
||||
private FragmentSettingsItemListBinding binding;
|
||||
private Settings settings;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
binding = FragmentSettingsItemListBinding.inflate(inflater, container, false);
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
// Setup toolbar and register for item click
|
||||
binding.settingsToolbar.inflateMenu(R.menu.settings_menu);
|
||||
binding.settingsToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
if (item.getItemId() == R.id.menuitem_add_camera) {
|
||||
((MainActivity)getActivity()).navigateToFragment(R.id.action_settingsToCameraUrl);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
// Load cameras
|
||||
Settings settings = Settings.fromDisk(getContext());
|
||||
settings = Settings.fromDisk(getContext());
|
||||
List<Camera> cams = settings.getCameras();
|
||||
|
||||
// Set the adapter
|
||||
@ -60,21 +85,15 @@ public class SettingsFragment extends Fragment {
|
||||
((MainActivity)getActivity()).navigateToFragment(R.id.action_settingsToCameraUrl, b);
|
||||
}
|
||||
});
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
binding.settingsToolbar.inflateMenu(R.menu.settings_menu);
|
||||
}
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
if (item.getItemId() == R.id.menuitem_add_camera) {
|
||||
((MainActivity)getActivity()).navigateToFragment(R.id.action_settingsToCameraUrl);
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
// Save cameras
|
||||
List<Camera> cams = ((SettingsRecyclerViewAdapter)binding.list.getAdapter()).getItems();
|
||||
this.settings.setCameras(cams);
|
||||
this.settings.save();
|
||||
}
|
||||
}
|
@ -97,6 +97,10 @@ public class SettingsRecyclerViewAdapter extends RecyclerView.Adapter<SettingsRe
|
||||
this.clickListener = clickListener;
|
||||
}
|
||||
|
||||
public List<Camera> getItems() {
|
||||
return mValues;
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
public View root;
|
||||
public TextView name;
|
||||
|
9
app/src/main/res/drawable/ic_add.xml
Normal file
9
app/src/main/res/drawable/ic_add.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
|
||||
</vector>
|
@ -1,10 +0,0 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M3,4V1h2v3h3v2H5v3H3V6H0V4H3zM6,10V7h3V4h7l1.83,2H21c1.1,0 2,0.9 2,2v12c0,1.1 -0.9,2 -2,2H5c-1.1,0 -2,-0.9 -2,-2V10H6zM13,19c2.76,0 5,-2.24 5,-5s-2.24,-5 -5,-5s-5,2.24 -5,5S10.24,19 13,19zM9.8,14c0,1.77 1.43,3.2 3.2,3.2s3.2,-1.43 3.2,-3.2s-1.43,-3.2 -3.2,-3.2S9.8,12.23 9.8,14z"/>
|
||||
</vector>
|
10
app/src/main/res/drawable/ic_settings.xml
Normal file
10
app/src/main/res/drawable/ic_settings.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M19.14,12.94c0.04,-0.3 0.06,-0.61 0.06,-0.94c0,-0.32 -0.02,-0.64 -0.07,-0.94l2.03,-1.58c0.18,-0.14 0.23,-0.41 0.12,-0.61l-1.92,-3.32c-0.12,-0.22 -0.37,-0.29 -0.59,-0.22l-2.39,0.96c-0.5,-0.38 -1.03,-0.7 -1.62,-0.94L14.4,2.81c-0.04,-0.24 -0.24,-0.41 -0.48,-0.41h-3.84c-0.24,0 -0.43,0.17 -0.47,0.41L9.25,5.35C8.66,5.59 8.12,5.92 7.63,6.29L5.24,5.33c-0.22,-0.08 -0.47,0 -0.59,0.22L2.74,8.87C2.62,9.08 2.66,9.34 2.86,9.48l2.03,1.58C4.84,11.36 4.8,11.69 4.8,12s0.02,0.64 0.07,0.94l-2.03,1.58c-0.18,0.14 -0.23,0.41 -0.12,0.61l1.92,3.32c0.12,0.22 0.37,0.29 0.59,0.22l2.39,-0.96c0.5,0.38 1.03,0.7 1.62,0.94l0.36,2.54c0.05,0.24 0.24,0.41 0.48,0.41h3.84c0.24,0 0.44,-0.17 0.47,-0.41l0.36,-2.54c0.59,-0.24 1.13,-0.56 1.62,-0.94l2.39,0.96c0.22,0.08 0.47,0 0.59,-0.22l1.92,-3.32c0.12,-0.22 0.07,-0.47 -0.12,-0.61L19.14,12.94zM12,15.6c-1.98,0 -3.6,-1.62 -3.6,-3.6s1.62,-3.6 3.6,-3.6s3.6,1.62 3.6,3.6S13.98,15.6 12,15.6z"/>
|
||||
</vector>
|
@ -14,7 +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_settings"
|
||||
app:tint="@color/purple_500"/>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
@ -29,7 +29,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:hint="@string/add_stream_placeholder_url"
|
||||
android:hint="@string/add_stream_placeholder_name"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
android:inputType="textUri"/>
|
||||
|
@ -10,7 +10,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/settingsToolbar"
|
||||
app:title="@string/app_name" />
|
||||
app:title="@string/app_name"
|
||||
style="@style/ToolBarStyle"/>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/list"
|
||||
|
@ -2,7 +2,7 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item android:id="@+id/menuitem_add_camera"
|
||||
android:icon="@drawable/ic_add_camera"
|
||||
android:icon="@drawable/ic_add"
|
||||
android:title="@string/add_stream"
|
||||
app:showAsAction="always"/>
|
||||
</menu>
|
@ -8,6 +8,7 @@
|
||||
<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_name">Nome della IP Camera</string>
|
||||
<string name="add_stream_name">Nome della IP Camera</string>
|
||||
<string name="add_stream">Inserisci l\'url dello stream RTSP della tua IP Camera. Nota che questo differisce tra un modello e l\'altro. Consulta il pannello di configurazione o il manuale della tua IP Camera.</string>
|
||||
<string name="add_stream_save">Salva</string>
|
||||
|
@ -7,6 +7,7 @@
|
||||
<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_name">Camera name</string>
|
||||
<string name="add_stream_name">Camera name</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>
|
||||
|
@ -14,6 +14,9 @@
|
||||
<item name="colorOnSecondary">@color/white</item>
|
||||
</style>
|
||||
|
||||
|
||||
<style name="ToolBarStyle" parent="">
|
||||
<item name="android:background">@color/purple_500</item>
|
||||
<item name="titleTextColor">@color/white</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user