Added back button in detail
This commit is contained in:
parent
2a62da3cf2
commit
b8541c994a
@ -42,12 +42,8 @@ import org.osmdroid.api.IMapController;
|
|||||||
import org.osmdroid.config.Configuration;
|
import org.osmdroid.config.Configuration;
|
||||||
import org.osmdroid.util.GeoPoint;
|
import org.osmdroid.util.GeoPoint;
|
||||||
import org.osmdroid.views.CustomZoomButtonsController;
|
import org.osmdroid.views.CustomZoomButtonsController;
|
||||||
import org.osmdroid.views.overlay.IconOverlay;
|
|
||||||
import org.osmdroid.views.overlay.Marker;
|
import org.osmdroid.views.overlay.Marker;
|
||||||
import org.osmdroid.views.overlay.Overlay;
|
|
||||||
import org.osmdroid.views.overlay.OverlayItem;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import it.danieleverducci.nextcloudmaps.R;
|
import it.danieleverducci.nextcloudmaps.R;
|
||||||
@ -78,7 +74,13 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
|
|||||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()));
|
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()));
|
||||||
|
|
||||||
mViewHolder = new ViewHolder(getLayoutInflater());
|
mViewHolder = new ViewHolder(getLayoutInflater());
|
||||||
|
setContentView(mViewHolder.getRootView());
|
||||||
mViewHolder.setOnSubmitListener(new OnSubmitListener() {
|
mViewHolder.setOnSubmitListener(new OnSubmitListener() {
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSubmit() {
|
public void onSubmit() {
|
||||||
saveGeofavorite();
|
saveGeofavorite();
|
||||||
@ -89,7 +91,6 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
|
|||||||
Toast.makeText(GeofavoriteDetailActivity.this, "TODO: Open map activity with pin", Toast.LENGTH_SHORT).show();
|
Toast.makeText(GeofavoriteDetailActivity.this, "TODO: Open map activity with pin", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setContentView(mViewHolder.getRootView());
|
|
||||||
|
|
||||||
if (getIntent().hasExtra(ARG_GEOFAVORITE)) {
|
if (getIntent().hasExtra(ARG_GEOFAVORITE)) {
|
||||||
// Opening geofavorite from list
|
// Opening geofavorite from list
|
||||||
@ -210,7 +211,7 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
|
|||||||
mGeofavorite.setLat(location.getLatitude());
|
mGeofavorite.setLat(location.getLatitude());
|
||||||
mGeofavorite.setLng(location.getLongitude());
|
mGeofavorite.setLng(location.getLongitude());
|
||||||
// Update view
|
// Update view
|
||||||
mViewHolder.updateViewCoords(mGeofavorite.getCoordinatesString());
|
mViewHolder.updateViewCoords(mGeofavorite);
|
||||||
mViewHolder.setAccuracy(location.getAccuracy());
|
mViewHolder.setAccuracy(location.getAccuracy());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,15 +256,23 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
|
|||||||
private class ViewHolder implements View.OnClickListener {
|
private class ViewHolder implements View.OnClickListener {
|
||||||
private final ActivityGeofavoriteDetailBinding binding;
|
private final ActivityGeofavoriteDetailBinding binding;
|
||||||
private OnSubmitListener listener;
|
private OnSubmitListener listener;
|
||||||
|
private Marker mapMarker;
|
||||||
|
|
||||||
public ViewHolder(LayoutInflater inflater) {
|
public ViewHolder(LayoutInflater inflater) {
|
||||||
this.binding = ActivityGeofavoriteDetailBinding.inflate(inflater);
|
this.binding = ActivityGeofavoriteDetailBinding.inflate(inflater);
|
||||||
this.binding.submitBt.setOnClickListener(this);
|
this.binding.submitBt.setOnClickListener(this);
|
||||||
this.binding.mapBt.setOnClickListener(this);
|
this.binding.mapBt.setOnClickListener(this);
|
||||||
|
this.binding.backBt.setOnClickListener(this);
|
||||||
|
|
||||||
// Set map properties
|
// Set map properties
|
||||||
this.binding.map.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.NEVER);
|
this.binding.map.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.NEVER);
|
||||||
this.binding.map.setMultiTouchControls(true);
|
this.binding.map.setMultiTouchControls(true);
|
||||||
|
|
||||||
|
// Create marker
|
||||||
|
mapMarker = new Marker(binding.map);
|
||||||
|
mapMarker.setIcon(AppCompatResources.getDrawable(GeofavoriteDetailActivity.this, R.drawable.ic_map_pin));
|
||||||
|
mapMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
|
||||||
|
binding.map.getOverlays().add(mapMarker);
|
||||||
}
|
}
|
||||||
|
|
||||||
public View getRootView() {
|
public View getRootView() {
|
||||||
@ -276,6 +285,10 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
|
|||||||
binding.createdTv.setText(new Date(item.getDateCreated() * 1000).toString());
|
binding.createdTv.setText(new Date(item.getDateCreated() * 1000).toString());
|
||||||
binding.modifiedTv.setText(new Date(item.getDateModified() * 1000).toString());
|
binding.modifiedTv.setText(new Date(item.getDateModified() * 1000).toString());
|
||||||
binding.categoryTv.setText(item.getCategory()); // TODO: Category spinner from existing categories
|
binding.categoryTv.setText(item.getCategory()); // TODO: Category spinner from existing categories
|
||||||
|
updateViewCoords(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateViewCoords(Geofavorite item) {
|
||||||
binding.coordsTv.setText(item.getCoordinatesString());
|
binding.coordsTv.setText(item.getCoordinatesString());
|
||||||
|
|
||||||
// Center map
|
// Center map
|
||||||
@ -285,15 +298,7 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
|
|||||||
mapController.setCenter(position);
|
mapController.setCenter(position);
|
||||||
|
|
||||||
// Set pin
|
// Set pin
|
||||||
Marker startMarker = new Marker(binding.map);
|
mapMarker.setPosition(position);
|
||||||
startMarker.setPosition(position);
|
|
||||||
startMarker.setIcon(AppCompatResources.getDrawable(GeofavoriteDetailActivity.this, R.drawable.ic_map_pin));
|
|
||||||
startMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
|
|
||||||
binding.map.getOverlays().add(startMarker);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateViewCoords(String coords) {
|
|
||||||
binding.coordsTv.setText(coords);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateModel(Geofavorite item) {
|
public void updateModel(Geofavorite item) {
|
||||||
@ -336,11 +341,15 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
|
|||||||
if (v.getId() == R.id.map_bt && this.listener != null) {
|
if (v.getId() == R.id.map_bt && this.listener != null) {
|
||||||
this.listener.onMapClicked();
|
this.listener.onMapClicked();
|
||||||
}
|
}
|
||||||
|
if (v.getId() == R.id.back_bt && this.listener != null) {
|
||||||
|
this.listener.onBackPressed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected interface OnSubmitListener {
|
protected interface OnSubmitListener {
|
||||||
void onSubmit();
|
void onSubmit();
|
||||||
void onMapClicked();
|
void onMapClicked();
|
||||||
|
void onBackPressed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,134 +2,150 @@
|
|||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<ScrollView
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:id="@+id/root">
|
android:id="@+id/root">
|
||||||
|
|
||||||
<LinearLayout
|
<ScrollView
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="200dp">
|
|
||||||
<org.osmdroid.views.MapView
|
|
||||||
android:id="@+id/map"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:focusable="false"
|
|
||||||
android:clickable="false"/>
|
|
||||||
<View
|
|
||||||
android:id="@+id/map_bt"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"/>
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="20dp">
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<EditText
|
<FrameLayout
|
||||||
android:id="@+id/name_et"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="200dp">
|
||||||
android:ems="10"
|
<org.osmdroid.views.MapView
|
||||||
android:hint="@string/name"
|
android:id="@+id/map"
|
||||||
android:lines="1"
|
android:layout_width="match_parent"
|
||||||
android:maxLines="1"
|
android:layout_height="match_parent"
|
||||||
android:singleLine="true"
|
android:focusable="false"
|
||||||
android:ellipsize="end"/>
|
android:clickable="false"/>
|
||||||
|
<View
|
||||||
|
android:id="@+id/map_bt"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
<EditText
|
<LinearLayout
|
||||||
android:id="@+id/description_et"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:ems="10"
|
android:orientation="vertical"
|
||||||
android:gravity="start|top"
|
android:padding="20dp">
|
||||||
android:inputType="textMultiLine"
|
|
||||||
android:lines="5"
|
|
||||||
android:maxLines="10"
|
|
||||||
android:hint="@string/description"
|
|
||||||
android:ellipsize="end" />
|
|
||||||
|
|
||||||
<TextView
|
<EditText
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/name_et"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_marginTop="20dp"
|
android:layout_height="wrap_content"
|
||||||
android:textStyle="bold"
|
android:ems="10"
|
||||||
android:text="@string/created" />
|
android:hint="@string/name"
|
||||||
|
android:lines="1"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="end"/>
|
||||||
|
|
||||||
<TextView
|
<EditText
|
||||||
android:id="@+id/created_tv"
|
android:id="@+id/description_et"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAlignment="textEnd" />
|
android:ems="10"
|
||||||
|
android:gravity="start|top"
|
||||||
|
android:inputType="textMultiLine"
|
||||||
|
android:lines="5"
|
||||||
|
android:maxLines="10"
|
||||||
|
android:hint="@string/description"
|
||||||
|
android:ellipsize="end" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="20dp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:text="@string/modified" />
|
android:text="@string/created" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/modified_tv"
|
android:id="@+id/created_tv"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAlignment="textEnd" />
|
android:textAlignment="textEnd" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="20dp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:text="@string/category" />
|
android:text="@string/modified" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/category_tv"
|
android:id="@+id/modified_tv"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAlignment="textEnd" />
|
android:textAlignment="textEnd" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="20dp"
|
||||||
android:text="@string/coords"
|
android:textStyle="bold"
|
||||||
android:textStyle="bold" />
|
android:text="@string/category" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/coords_tv"
|
android:id="@+id/category_tv"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAlignment="textEnd" />
|
android:textAlignment="textEnd" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/accuracy_tv"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_marginTop="20dp"
|
||||||
android:layout_marginTop="10dp"
|
android:text="@string/coords"
|
||||||
android:textAlignment="center"
|
android:textStyle="bold" />
|
||||||
android:text="@string/accuracy"
|
|
||||||
android:textColor="@android:color/white"
|
|
||||||
android:background="@android:color/darker_gray"/>
|
|
||||||
|
|
||||||
<Button
|
<TextView
|
||||||
android:id="@+id/submit_bt"
|
android:id="@+id/coords_tv"
|
||||||
style="@style/Widget.AppCompat.Button.Colored"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="60dp"
|
android:textAlignment="textEnd" />
|
||||||
android:layout_margin="50dp"
|
|
||||||
android:text="@string/confirm"
|
<TextView
|
||||||
app:backgroundTint="@color/defaultBrand"
|
android:id="@+id/accuracy_tv"
|
||||||
android:onClick="onSubmit"/>
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:text="@string/accuracy"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:background="@android:color/darker_gray"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/submit_bt"
|
||||||
|
style="@style/Widget.AppCompat.Button.Colored"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:layout_margin="50dp"
|
||||||
|
android:text="@string/confirm"
|
||||||
|
app:backgroundTint="@color/defaultBrand"
|
||||||
|
android:onClick="onSubmit"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
</LinearLayout>
|
<!-- Back button -->
|
||||||
</ScrollView>
|
<ImageView
|
||||||
|
android:id="@+id/back_bt"
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:padding="12dp"
|
||||||
|
android:src="@drawable/ic_back_grey"
|
||||||
|
app:tint="@color/white"
|
||||||
|
android:background="@color/defaultBrandAlpha"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
</layout>
|
</layout>
|
@ -22,9 +22,13 @@
|
|||||||
<color name="accent">#121212</color>
|
<color name="accent">#121212</color>
|
||||||
<color name="transparent">#00000000</color>
|
<color name="transparent">#00000000</color>
|
||||||
<color name="defaultBrand">#0082C9</color>
|
<color name="defaultBrand">#0082C9</color>
|
||||||
|
<color name="defaultBrandAlpha">#550082C9</color>
|
||||||
<color name="appbar">@android:color/white</color>
|
<color name="appbar">@android:color/white</color>
|
||||||
<color name="defaultTint">#202124</color>
|
<color name="defaultTint">#202124</color>
|
||||||
|
|
||||||
<!-- List Colors -->
|
<!-- List Colors -->
|
||||||
<color name="list_text">#aaa</color>
|
<color name="list_text">#aaa</color>
|
||||||
|
|
||||||
|
<!-- Generic Colors -->
|
||||||
|
<color name="white">#fff</color>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue
Block a user