Pre-release

This commit is contained in:
Daniele 2021-09-15 20:26:29 +02:00
parent f21e5221ba
commit c7212fbeba
20 changed files with 224 additions and 79 deletions

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="SERIAL_NUMBER" />
<value value="830cb6b6" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2021-09-15T13:58:51.175333Z" />
</component>
</project>

View File

@ -6,6 +6,9 @@
<entry key="../../../../layout/custom_preview.xml" value="0.5661458333333333" />
<entry key="app/src/main/res/drawable/floating_semitransparent_button_background.xml" value="0.512962962962963" />
<entry key="app/src/main/res/drawable/ic_map_pin.xml" value="0.6425925925925926" />
<entry key="app/src/main/res/drawable/ic_more.xml" value="0.6166666666666667" />
<entry key="app/src/main/res/drawable/ic_nav.xml" value="0.6083333333333333" />
<entry key="app/src/main/res/drawable/ic_share.xml" value="0.8828125" />
<entry key="app/src/main/res/layout/activity_geofavorite_detail.xml" value="0.4" />
<entry key="app/src/main/res/layout/activity_list_view.xml" value="0.5307291666666667" />
<entry key="app/src/main/res/layout/activity_main.xml" value="0.5307291666666667" />

View File

@ -73,6 +73,9 @@ dependencies {
implementation "com.github.nextcloud:Android-SingleSignOn:0.5.6"
// OSMDroid
compile 'org.osmdroid:osmdroid-android:6.1.10'
implementation 'org.osmdroid:osmdroid-android:6.1.10'
//Threeten-Backport (ports Java 8 Date API on Java 6+)
implementation 'org.threeten:threetenbp:1.5.1'
}

View File

@ -19,6 +19,7 @@ package it.danieleverducci.nextcloudmaps.activity.detail;
import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.location.Location;
@ -43,13 +44,17 @@ import org.osmdroid.config.Configuration;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.CustomZoomButtonsController;
import org.osmdroid.views.overlay.Marker;
import org.threeten.bp.format.DateTimeFormatter;
import org.threeten.bp.format.FormatStyle;
import java.util.Date;
import it.danieleverducci.nextcloudmaps.R;
import it.danieleverducci.nextcloudmaps.activity.main.MainActivity;
import it.danieleverducci.nextcloudmaps.api.ApiProvider;
import it.danieleverducci.nextcloudmaps.databinding.ActivityGeofavoriteDetailBinding;
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
import it.danieleverducci.nextcloudmaps.utils.IntentGenerator;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@ -81,6 +86,21 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
finish();
}
@Override
public void onActionIconShareClicked() {
startActivity(Intent.createChooser(IntentGenerator.newShareIntent(GeofavoriteDetailActivity.this, mGeofavorite), getString(R.string.share_via)));
}
@Override
public void onActionIconNavClicked() {
startActivity(IntentGenerator.newGeoUriIntent(GeofavoriteDetailActivity.this, mGeofavorite));
}
@Override
public void onActionIconDeleteClicked() {
// TODO
}
@Override
public void onSubmit() {
saveGeofavorite();
@ -102,6 +122,8 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
mGeofavorite.setCategory(DEFAULT_CATEGORY);
mGeofavorite.setDateCreated(System.currentTimeMillis());
mGeofavorite.setDateModified(System.currentTimeMillis());
mViewHolder.hideActions();
// Precompile location
getLocation();
}
@ -255,6 +277,7 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
private class ViewHolder implements View.OnClickListener {
private final ActivityGeofavoriteDetailBinding binding;
private DateTimeFormatter dateFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG);
private OnSubmitListener listener;
private Marker mapMarker;
@ -263,6 +286,9 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
this.binding.submitBt.setOnClickListener(this);
this.binding.mapBt.setOnClickListener(this);
this.binding.backBt.setOnClickListener(this);
this.binding.actionIconShare.setOnClickListener(this);
this.binding.actionIconDelete.setOnClickListener(this);
this.binding.actionIconNav.setOnClickListener(this);
// Set map properties
this.binding.map.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.NEVER);
@ -283,8 +309,8 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
binding.collapsingToolbar.setTitle(item.getName() != null ? item.getName() : getString(R.string.new_geobookmark));
binding.nameEt.setText(item.getName());
binding.descriptionEt.setText(item.getComment());
binding.createdTv.setText(new Date(item.getDateCreated() * 1000).toString());
binding.modifiedTv.setText(new Date(item.getDateModified() * 1000).toString());
binding.createdTv.setText(item.getLocalDateCreated().format(dateFormatter));
binding.modifiedTv.setText(item.getLocalDateCreated().format(dateFormatter));
binding.categoryTv.setText(item.getCategory()); // TODO: Category spinner from existing categories
updateViewCoords(item);
}
@ -322,6 +348,10 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
binding.accuracyTv.setVisibility(View.GONE);
}
public void hideActions() {
binding.actionIcons.setVisibility(View.GONE);
}
public void setOnSubmitListener(OnSubmitListener listener) {
this.listener = listener;
}
@ -345,6 +375,17 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
if (v.getId() == R.id.back_bt && this.listener != null) {
this.listener.onBackPressed();
}
// Actions
if (v.getId() == R.id.action_icon_share && this.listener != null) {
this.listener.onActionIconShareClicked();
}
if (v.getId() == R.id.action_icon_nav && this.listener != null) {
this.listener.onActionIconNavClicked();
}
if (v.getId() == R.id.action_icon_delete && this.listener != null) {
this.listener.onActionIconDeleteClicked();
}
}
}
@ -352,5 +393,8 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
void onSubmit();
void onMapClicked();
void onBackPressed();
void onActionIconShareClicked();
void onActionIconNavClicked();
void onActionIconDeleteClicked();
}
}

View File

@ -21,13 +21,9 @@
package it.danieleverducci.nextcloudmaps.activity.main;
import android.content.Context;
import android.content.Intent;
import android.text.Html;
import android.util.Log;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
@ -40,6 +36,9 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import org.threeten.bp.format.DateTimeFormatter;
import org.threeten.bp.format.FormatStyle;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@ -57,6 +56,7 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
private Context context;
private ItemClickListener itemClickListener;
private DateTimeFormatter dateFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT);
private List<Geofavorite> geofavoriteList = new ArrayList<>();
private List<Geofavorite> geofavoriteListFiltered = new ArrayList<>();
@ -117,6 +117,7 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
holder.tv_title.setText(Html.fromHtml(geofavorite.getName()));
holder.tv_content.setText(geofavorite.getComment());
holder.tv_date.setText(geofavorite.getLocalDateCreated().format(dateFormatter));
}
@Override
@ -164,9 +165,9 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
};
class GeofavoriteViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
TextView tv_title, tv_content;
TextView tv_title, tv_content, tv_date;
ImageView bt_context_menu;
ImageView bt_share;
ImageView bt_nav;
ItemClickListener itemClickListener;
@ -176,14 +177,15 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
tv_title = itemView.findViewById(R.id.title);
tv_content = itemView.findViewById(R.id.content);
tv_date = itemView.findViewById(R.id.date);
bt_context_menu = itemView.findViewById(R.id.geofav_context_menu_bt);
bt_share = itemView.findViewById(R.id.geofav_share_bt);
bt_nav = itemView.findViewById(R.id.geofav_nav_bt);
this.itemClickListener = itemClickListener;
itemView.setOnClickListener(this);
bt_context_menu.setOnClickListener(this);
bt_share.setOnClickListener(this);
bt_nav.setOnClickListener(this);
}
@Override
@ -192,9 +194,9 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
case R.id.geofav_context_menu_bt:
onOverflowIconClicked(view, getAdapterPosition());
break;
case R.id.geofav_share_bt:
case R.id.geofav_nav_bt:
if (itemClickListener != null)
itemClickListener.onItemShareClick(get(getAdapterPosition()));
itemClickListener.onItemNavClick(get(getAdapterPosition()));
break;
default:
if (itemClickListener != null)
@ -229,9 +231,9 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
}
Geofavorite gf = get(overflowMenuSelectedPosition);
overflowMenuSelectedPosition = -1;
if (item.getItemId() == R.id.list_context_menu_detail && itemClickListener != null)
itemClickListener.onItemDetailsClick(gf);
if (item.getItemId() == R.id.list_context_menu_delete)
if (item.getItemId() == R.id.list_context_menu_share && itemClickListener != null)
itemClickListener.onItemShareClick(gf);
if (item.getItemId() == R.id.list_context_menu_delete && itemClickListener != null)
itemClickListener.onItemDeleteClick(gf);
return true;
}
@ -239,7 +241,7 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
public interface ItemClickListener {
void onItemClick(Geofavorite item);
void onItemShareClick(Geofavorite item);
void onItemDetailsClick(Geofavorite item);
void onItemNavClick(Geofavorite item);
void onItemDeleteClick(Geofavorite item);
}

View File

@ -54,6 +54,7 @@ import it.danieleverducci.nextcloudmaps.activity.login.LoginActivity;
import it.danieleverducci.nextcloudmaps.activity.main.NavigationAdapter.NavigationItem;
import it.danieleverducci.nextcloudmaps.activity.main.SortingOrderDialogFragment.OnSortingOrderListener;
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
import it.danieleverducci.nextcloudmaps.utils.IntentGenerator;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
@ -107,28 +108,18 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti
rvItemClickListener = new ItemClickListener() {
@Override
public void onItemClick(Geofavorite geofavorite) {
Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
i.setData(geofavorite.getGeoUri());
startActivity(i);
public void onItemClick(Geofavorite item) {
showGeofavoriteDetailActivity(item);
}
@Override
public void onItemShareClick(Geofavorite item) {
Intent i = new Intent();
i.setAction(Intent.ACTION_SEND);
i.setType("text/plain");
String shareMessage = getString(R.string.share_message)
.replace("{lat}", ""+item.getLat())
.replace("{lng}", ""+item.getLng());
i.putExtra(Intent.EXTRA_TEXT, shareMessage );
startActivity(Intent.createChooser(i, getString(R.string.share_via)));
startActivity(Intent.createChooser(IntentGenerator.newShareIntent(MainActivity.this, item), getString(R.string.share_via)));
}
@Override
public void onItemDetailsClick(Geofavorite item) {
showGeofavoriteDetailActivity(item);
public void onItemNavClick(Geofavorite item) {
startActivity(IntentGenerator.newGeoUriIntent(MainActivity.this, item));
}
@Override

View File

@ -32,6 +32,10 @@ import androidx.databinding.BindingAdapter;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import org.threeten.bp.Instant;
import org.threeten.bp.LocalDate;
import org.threeten.bp.ZoneId;
import java.io.Serializable;
import java.util.Comparator;
import java.util.Date;
@ -102,10 +106,17 @@ public class Geofavorite implements Serializable {
public void setDateModified(long dateModified) {
this.dateModified = dateModified;
}
public LocalDate getLocalDateModified() {
return Instant.ofEpochSecond(getDateCreated()).atZone(ZoneId.systemDefault()).toLocalDate();
}
public long getDateCreated() {
return dateCreated;
}
public LocalDate getLocalDateCreated() {
return Instant.ofEpochSecond(getDateCreated()).atZone(ZoneId.systemDefault()).toLocalDate();
}
public void setDateCreated(long dateCreated) {
this.dateCreated = dateCreated;
}

View File

@ -0,0 +1,27 @@
package it.danieleverducci.nextcloudmaps.utils;
import android.content.Context;
import android.content.Intent;
import it.danieleverducci.nextcloudmaps.R;
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
public class IntentGenerator {
public static Intent newShareIntent(Context context, Geofavorite item) {
Intent i = new Intent();
i.setAction(Intent.ACTION_SEND);
i.setType("text/plain");
String shareMessage = context.getString(R.string.share_message)
.replace("{lat}", ""+item.getLat())
.replace("{lng}", ""+item.getLng());
i.putExtra(Intent.EXTRA_TEXT, shareMessage );
return i;
}
public static Intent newGeoUriIntent(Context context, Geofavorite item) {
Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
i.setData(item.getGeoUri());
return i;
}
}

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#0082C9"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z"/>
</vector>

View 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="M20.5,3l-0.16,0.03L15,5.1 9,3 3.36,4.9c-0.21,0.07 -0.36,0.25 -0.36,0.48V20.5c0,0.28 0.22,0.5 0.5,0.5l0.16,-0.03L9,18.9l6,2.1 5.64,-1.9c0.21,-0.07 0.36,-0.25 0.36,-0.48V3.5c0,-0.28 -0.22,-0.5 -0.5,-0.5zM15,19l-6,-2.11V5l6,2.11V19z"/>
</vector>

View File

@ -87,6 +87,43 @@
android:textColor="@android:color/white"
android:background="@android:color/darker_gray"/>
<LinearLayout
android:id="@+id/action_icons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/action_icon_share"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="10dp"
android:src="@drawable/ic_share"
android:tint="@color/defaultBrand"/>
<ImageView
android:id="@+id/action_icon_nav"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="10dp"
android:src="@drawable/ic_nav"
android:tint="@color/defaultBrand"/>
<ImageView
android:id="@+id/action_icon_delete"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="10dp"
android:src="@drawable/ic_delete_grey"
android:tint="@color/defaultBrand"
android:visibility="gone"/> <!-- TODO Implement delete -->
</LinearLayout>
<EditText
android:id="@+id/name_et"
android:layout_width="match_parent"
@ -99,7 +136,9 @@
android:singleLine="true"
android:textColor="@color/defaultBrand"
android:textAppearance="@style/TextAppearance.AppCompat.Title"
android:background="@android:color/transparent"/>
android:background="@android:color/transparent"
android:drawableLeft="@drawable/ic_edit"
android:drawablePadding="5dp"/>
<EditText
android:id="@+id/description_et"
@ -111,6 +150,8 @@
android:inputType="textMultiLine"
android:maxLines="10"
android:background="@android:color/transparent"
android:drawableLeft="@drawable/ic_edit"
android:drawablePadding="5dp"
android:hint="@string/description"/>
<TextView

View File

@ -23,13 +23,14 @@
android:layout_width="match_parent"
android:layout_height="90dp"
android:gravity="center_vertical"
android:padding="12dp"
android:clickable="true"
android:focusable="true">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginStart="12dp"
android:contentDescription="@null"
android:layout_weight="0"
android:src="@mipmap/ic_launcher"/>
@ -37,51 +38,76 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="8dp"
android:layout_weight="1">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/note_font_size_item_title"
android:textStyle="bold"
android:singleLine="true"
android:maxLines="1"
android:lines="1"
android:ellipsize="end"
android:ellipsize="middle"
android:textColor="@color/text_color"
android:textSize="@dimen/two_line_primary_text_size"
tools:text="@tools:sample/lorem/random">
</TextView>
<TextView
android:id="@+id/content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:textSize="@dimen/note_font_size_item_content"
android:maxLines="2"
android:orientation="horizontal">
<TextView
android:id="@+id/content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="10dp"
android:textColor="@color/secondary_text_color"
android:textSize="@dimen/two_line_secondary_text_size"
android:maxLines="1"
android:lines="1"
android:ellipsize="end"
android:gravity="center_vertical"
tools:text="@tools:sample/lorem/random">
</TextView>
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:textColor="@color/secondary_text_color"
android:textSize="@dimen/two_line_secondary_text_size"
android:maxLines="1"
android:lines="1"
android:gravity="center_vertical"
tools:text="00/00/0000">
</TextView>
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/geofav_share_bt"
android:id="@+id/geofav_nav_bt"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0"
android:padding="10dp"
android:src="@drawable/ic_share"
android:tint="@color/list_text" /> <!-- TODO: app:tint is not working -->
android:padding="8dp"
android:src="@drawable/ic_nav"
android:tint="@color/secondary_text_color" /> <!-- TODO: app:tint is not working -->
<ImageView
android:id="@+id/geofav_context_menu_bt"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0"
android:padding="10dp"
android:padding="8dp"
android:src="@drawable/ic_more"
android:tint="@color/list_text" /> <!-- TODO: app:tint is not working -->
android:tint="@color/secondary_text_color" /> <!-- TODO: app:tint is not working -->
</LinearLayout>

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!-- Detail button -->
<!-- Share button -->
<item
android:id="@+id/list_context_menu_detail"
android:title="@string/list_context_menu_detail"/>
android:id="@+id/list_context_menu_share"
android:title="@string/list_context_menu_share"/>
<!-- Delete button -->
<item
android:id="@+id/list_context_menu_delete"

View File

@ -27,7 +27,8 @@
<color name="defaultTint">#202124</color>
<!-- List Colors -->
<color name="list_text">#aaa</color>
<color name="text_color">#333333</color>
<color name="secondary_text_color">#666666</color>
<!-- Generic Colors -->
<color name="white">#fff</color>

View File

@ -28,14 +28,12 @@
<dimen name="drawer_header_logo_size">42dp</dimen>
<!-- Font Sizes -->
<dimen name="note_font_size_item_title">18sp</dimen>
<dimen name="note_font_size_item_content">14sp</dimen>
<dimen name="zero">0dp</dimen>
<dimen name="standard_margin">16dp</dimen>
<dimen name="standard_half_margin">8dp</dimen>
<dimen name="standard_padding">16dp</dimen>
<dimen name="standard_half_padding">8dp</dimen>
<dimen name="two_line_primary_text_size">16sp</dimen>
<dimen name="two_line_secondary_text_size">12sp</dimen>
</resources>

View File

@ -31,7 +31,7 @@
<string name="search_in_all">Search by name</string>
<string name="share_via">Share via</string>
<string name="share_message">Check out this place: {lat}°N, {lng}°E https://www.openstreetmap.org/#map=17/{lat}/{lng}</string>
<string name="list_context_menu_detail">Details</string>
<string name="list_context_menu_share">Share</string>
<string name="list_context_menu_delete">Delete</string>
<string name="dialog_delete_title">Delete geobookmark</string>
<string name="dialog_delete_message">You are about to delete geobookmark {name}. Proceed?</string>

BIN
screenshots/full/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

BIN
screenshots/full/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB