Working list with item click

This commit is contained in:
Daniele Verducci (ZenPenguin) 2021-08-27 15:31:13 +02:00
parent cf7221eddc
commit f1d7acb71c
16 changed files with 249 additions and 217 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Nextcloud Notes Tutorial for Android * Nextcloud Maps Geofavorites for Android
* *
* @copyright Copyright (c) 2020 John Doe <john@doe.com> * @copyright Copyright (c) 2020 John Doe <john@doe.com>
* @author John Doe <john@doe.com> * @author John Doe <john@doe.com>
@ -39,9 +39,9 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import it.danieleverducci.nextcloudmaps.R; import it.danieleverducci.nextcloudmaps.R;
import it.danieleverducci.nextcloudmaps.model.Note; import it.danieleverducci.nextcloudmaps.model.Geofavorite;
public class NoteAdapter extends RecyclerView.Adapter<NoteAdapter.RecyclerViewAdapter> implements Filterable { public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.RecyclerViewAdapter> implements Filterable {
public static final int SORT_BY_TITLE = 0; public static final int SORT_BY_TITLE = 0;
public static final int SORT_BY_CREATED = 1; public static final int SORT_BY_CREATED = 1;
@ -49,25 +49,25 @@ public class NoteAdapter extends RecyclerView.Adapter<NoteAdapter.RecyclerViewAd
private Context context; private Context context;
private ItemClickListener itemClickListener; private ItemClickListener itemClickListener;
private List<Note> noteList = new ArrayList<>(); private List<Geofavorite> geofavoriteList = new ArrayList<>();
private List<Note> noteListFiltered = new ArrayList<>(); private List<Geofavorite> geofavoriteListFiltered = new ArrayList<>();
private int sortRule = SORT_BY_CREATED; private int sortRule = SORT_BY_CREATED;
public NoteAdapter(Context context, ItemClickListener itemClickListener) { public GeofavoriteAdapter(Context context, ItemClickListener itemClickListener) {
this.context = context; this.context = context;
this.itemClickListener = itemClickListener; this.itemClickListener = itemClickListener;
} }
public void setNoteList(@NonNull List<Note> noteList) { public void setGeofavoriteList(@NonNull List<Geofavorite> geofavoriteList) {
this.noteList = noteList; this.geofavoriteList = geofavoriteList;
this.noteListFiltered = new ArrayList<>(noteList); this.geofavoriteListFiltered = new ArrayList<>(geofavoriteList);
performSort(); performSort();
notifyDataSetChanged(); notifyDataSetChanged();
} }
public Note get(int position) { public Geofavorite get(int position) {
return noteListFiltered.get(position); return geofavoriteListFiltered.get(position);
} }
public int getSortRule() { public int getSortRule() {
@ -90,16 +90,15 @@ public class NoteAdapter extends RecyclerView.Adapter<NoteAdapter.RecyclerViewAd
@Override @Override
public void onBindViewHolder(@NonNull RecyclerViewAdapter holder, int position) { public void onBindViewHolder(@NonNull RecyclerViewAdapter holder, int position) {
Note note = noteListFiltered.get(position); Geofavorite geofavorite = geofavoriteListFiltered.get(position);
holder.tv_title.setText(Html.fromHtml(note.getTitle().trim())); holder.tv_title.setText(Html.fromHtml(geofavorite.getName().trim()));
holder.tv_content.setText(note.getContent().trim()); holder.tv_content.setText(geofavorite.getComment().trim());
holder.card_item.setCardBackgroundColor(context.getResources().getColor(R.color.defaultNoteColor));
} }
@Override @Override
public int getItemCount() { public int getItemCount() {
return noteListFiltered.size(); return geofavoriteListFiltered.size();
} }
@Override @Override
@ -112,29 +111,29 @@ public class NoteAdapter extends RecyclerView.Adapter<NoteAdapter.RecyclerViewAd
// Run on Background thread. // Run on Background thread.
protected FilterResults performFiltering(CharSequence charSequence) { protected FilterResults performFiltering(CharSequence charSequence) {
FilterResults filterResults = new FilterResults(); FilterResults filterResults = new FilterResults();
List <Note> filteredNotes = new ArrayList<>(); List <Geofavorite> filteredGeofavorites = new ArrayList<>();
if (charSequence.toString().isEmpty()) { if (charSequence.toString().isEmpty()) {
filteredNotes.addAll(noteList); filteredGeofavorites.addAll(geofavoriteList);
} else { } else {
for (Note note: noteList) { for (Geofavorite geofavorite : geofavoriteList) {
String query = charSequence.toString().toLowerCase(); String query = charSequence.toString().toLowerCase();
if (note.getTitle().toLowerCase().contains(query)) { if (geofavorite.getName().toLowerCase().contains(query)) {
filteredNotes.add(note); filteredGeofavorites.add(geofavorite);
} else if (note.getContent().toLowerCase().contains(query)) { } else if (geofavorite.getComment().toLowerCase().contains(query)) {
filteredNotes.add(note); filteredGeofavorites.add(geofavorite);
} }
} }
} }
filterResults.values = filteredNotes; filterResults.values = filteredGeofavorites;
return filterResults; return filterResults;
} }
//Run on ui thread //Run on ui thread
@Override @Override
protected void publishResults(CharSequence charSequence, FilterResults filterResults) { protected void publishResults(CharSequence charSequence, FilterResults filterResults) {
noteListFiltered.clear(); geofavoriteListFiltered.clear();
noteListFiltered.addAll((Collection<? extends Note>) filterResults.values); geofavoriteListFiltered.addAll((Collection<? extends Geofavorite>) filterResults.values);
performSort(); performSort();
notifyDataSetChanged(); notifyDataSetChanged();
@ -142,7 +141,6 @@ public class NoteAdapter extends RecyclerView.Adapter<NoteAdapter.RecyclerViewAd
}; };
class RecyclerViewAdapter extends RecyclerView.ViewHolder implements View.OnClickListener { class RecyclerViewAdapter extends RecyclerView.ViewHolder implements View.OnClickListener {
CardView card_item;
TextView tv_title, tv_content; TextView tv_title, tv_content;
ItemClickListener itemClickListener; ItemClickListener itemClickListener;
@ -150,12 +148,11 @@ public class NoteAdapter extends RecyclerView.Adapter<NoteAdapter.RecyclerViewAd
RecyclerViewAdapter(@NonNull View itemView, ItemClickListener itemClickListener) { RecyclerViewAdapter(@NonNull View itemView, ItemClickListener itemClickListener) {
super(itemView); super(itemView);
card_item = itemView.findViewById(R.id.card_item);
tv_title = itemView.findViewById(R.id.title); tv_title = itemView.findViewById(R.id.title);
tv_content = itemView.findViewById(R.id.content); tv_content = itemView.findViewById(R.id.content);
this.itemClickListener = itemClickListener; this.itemClickListener = itemClickListener;
card_item.setOnClickListener(this); itemView.setOnClickListener(this);
tv_content.setOnClickListener(this); tv_content.setOnClickListener(this);
} }
@ -168,9 +165,9 @@ public class NoteAdapter extends RecyclerView.Adapter<NoteAdapter.RecyclerViewAd
private void performSort() { private void performSort() {
if (sortRule == SORT_BY_TITLE) { if (sortRule == SORT_BY_TITLE) {
Collections.sort(noteListFiltered, Note.ByTitleAZ); Collections.sort(geofavoriteListFiltered, Geofavorite.ByTitleAZ);
} else if (sortRule == SORT_BY_CREATED) { } else if (sortRule == SORT_BY_CREATED) {
Collections.sort(noteListFiltered, Note.ByLastCreated); Collections.sort(geofavoriteListFiltered, Geofavorite.ByLastCreated);
} }
} }

View File

@ -19,6 +19,7 @@ package it.danieleverducci.nextcloudmaps.activity.main;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
import android.widget.Toast; import android.widget.Toast;
@ -50,13 +51,13 @@ import it.danieleverducci.nextcloudmaps.activity.login.LoginActivity;
import it.danieleverducci.nextcloudmaps.activity.main.NavigationAdapter.NavigationItem; import it.danieleverducci.nextcloudmaps.activity.main.NavigationAdapter.NavigationItem;
import it.danieleverducci.nextcloudmaps.activity.main.SortingOrderDialogFragment.OnSortingOrderListener; import it.danieleverducci.nextcloudmaps.activity.main.SortingOrderDialogFragment.OnSortingOrderListener;
import it.danieleverducci.nextcloudmaps.api.ApiProvider; import it.danieleverducci.nextcloudmaps.api.ApiProvider;
import it.danieleverducci.nextcloudmaps.model.Note; import it.danieleverducci.nextcloudmaps.model.Geofavorite;
import static android.view.View.GONE; import static android.view.View.GONE;
import static android.view.View.VISIBLE; import static android.view.View.VISIBLE;
import static it.danieleverducci.nextcloudmaps.activity.main.NoteAdapter.*; import static it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter.*;
import static it.danieleverducci.nextcloudmaps.activity.main.NoteAdapter.SORT_BY_CREATED; import static it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter.SORT_BY_CREATED;
import static it.danieleverducci.nextcloudmaps.activity.main.NoteAdapter.SORT_BY_TITLE; import static it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter.SORT_BY_TITLE;
public class MainActivity extends AppCompatActivity implements MainView, OnSortingOrderListener { public class MainActivity extends AppCompatActivity implements MainView, OnSortingOrderListener {
@ -79,7 +80,7 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti
private FloatingActionButton fab; private FloatingActionButton fab;
private MainPresenter presenter; private MainPresenter presenter;
private NoteAdapter noteAdapter; private GeofavoriteAdapter geofavoriteAdapter;
private ItemClickListener itemClickListener; private ItemClickListener itemClickListener;
NavigationAdapter navigationCommonAdapter; NavigationAdapter navigationCommonAdapter;
@ -103,21 +104,20 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti
presenter = new MainPresenter(this); presenter = new MainPresenter(this);
itemClickListener = ((view, position) -> { itemClickListener = ((view, position) -> {
Note note = noteAdapter.get(position); Geofavorite geofavorite = geofavoriteAdapter.get(position);
Intent i = new Intent();
/*Intent intent = new Intent(this, EditorActivity.class); i.setAction(Intent.ACTION_VIEW);
intent.putExtra("note", note); i.setData(geofavorite.getGeoUri());
startActivity(i);
startActivityForResult(intent, INTENT_EDIT);*/
}); });
noteAdapter = new NoteAdapter(getApplicationContext(), itemClickListener); geofavoriteAdapter = new GeofavoriteAdapter(getApplicationContext(), itemClickListener);
recyclerView.setAdapter(noteAdapter); recyclerView.setAdapter(geofavoriteAdapter);
noteAdapter.setSortRule(sortRule); geofavoriteAdapter.setSortRule(sortRule);
swipeRefresh = findViewById(R.id.swipe_refresh); swipeRefresh = findViewById(R.id.swipe_refresh);
swipeRefresh.setOnRefreshListener(() -> presenter.getNotes()); swipeRefresh.setOnRefreshListener(() -> presenter.getGeofavorites());
fab = findViewById(R.id.add); fab = findViewById(R.id.add);
fab.setOnClickListener(view -> add_note()); fab.setOnClickListener(view -> add_note());
@ -134,7 +134,7 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti
@Override @Override
public boolean onQueryTextChange(String query) { public boolean onQueryTextChange(String query) {
noteAdapter.getFilter().filter(query); geofavoriteAdapter.getFilter().filter(query);
return false; return false;
} }
}); });
@ -153,7 +153,7 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti
homeToolbar.setOnClickListener(view -> updateToolbars(false)); homeToolbar.setOnClickListener(view -> updateToolbars(false));
AppCompatImageView sortButton = findViewById(R.id.sort_mode); AppCompatImageView sortButton = findViewById(R.id.sort_mode);
sortButton.setOnClickListener(view -> openSortingOrderDialogFragment(getSupportFragmentManager(), noteAdapter.getSortRule())); sortButton.setOnClickListener(view -> openSortingOrderDialogFragment(getSupportFragmentManager(), geofavoriteAdapter.getSortRule()));
drawerLayout = findViewById(R.id.drawerLayout); drawerLayout = findViewById(R.id.drawerLayout);
AppCompatImageButton menuButton = findViewById(R.id.menu_button); AppCompatImageButton menuButton = findViewById(R.id.menu_button);
@ -169,7 +169,7 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti
updateGridIcon(gridViewEnabled); updateGridIcon(gridViewEnabled);
mApi = new ApiProvider(getApplicationContext()); mApi = new ApiProvider(getApplicationContext());
presenter.getNotes(); presenter.getGeofavorites();
} }
private void setupNavigationMenu() { private void setupNavigationMenu() {
@ -218,9 +218,9 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (requestCode == INTENT_ADD && resultCode == RESULT_OK) { if (requestCode == INTENT_ADD && resultCode == RESULT_OK) {
presenter.getNotes(); presenter.getGeofavorites();
} else if (requestCode == INTENT_EDIT && resultCode == RESULT_OK) { } else if (requestCode == INTENT_EDIT && resultCode == RESULT_OK) {
presenter.getNotes(); presenter.getGeofavorites();
} }
} }
@ -252,8 +252,8 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti
} }
@Override @Override
public void onGetResult(List<Note> note_list) { public void onGetResult(List<Geofavorite> geofavorite_list) {
noteAdapter.setNoteList(note_list); geofavoriteAdapter.setGeofavoriteList(geofavorite_list);
} }
@Override @Override
@ -263,7 +263,7 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti
@Override @Override
public void onSortingOrderChosen(int sortSelection) { public void onSortingOrderChosen(int sortSelection) {
noteAdapter.setSortRule(sortSelection); geofavoriteAdapter.setSortRule(sortSelection);
updateSortingIcon(sortSelection); updateSortingIcon(sortSelection);
preferences.edit().putInt(getString(R.string.setting_sort_by), sortSelection).apply(); preferences.edit().putInt(getString(R.string.setting_sort_by), sortSelection).apply();

View File

@ -1,5 +1,5 @@
/* /*
* Nextcloud Notes Tutorial for Android * Nextcloud Maps Geofavorites for Android
* *
* @copyright Copyright (c) 2020 John Doe <john@doe.com> * @copyright Copyright (c) 2020 John Doe <john@doe.com>
* @author John Doe <john@doe.com> * @author John Doe <john@doe.com>
@ -20,13 +20,15 @@
package it.danieleverducci.nextcloudmaps.activity.main; package it.danieleverducci.nextcloudmaps.activity.main;
import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import java.util.List; import java.util.List;
import it.danieleverducci.nextcloudmaps.api.ApiProvider; import it.danieleverducci.nextcloudmaps.api.ApiProvider;
import it.danieleverducci.nextcloudmaps.model.Note; import it.danieleverducci.nextcloudmaps.model.Geofavorite;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@ -38,12 +40,12 @@ public class MainPresenter {
this.view = view; this.view = view;
} }
public void getNotes() { public void getGeofavorites() {
view.showLoading(); view.showLoading();
Call<List<Note>> call = ApiProvider.getAPI().getNotes(); Call<List<Geofavorite>> call = ApiProvider.getAPI().getGeofavorites();
call.enqueue(new Callback<List<Note>>() { call.enqueue(new Callback<List<Geofavorite>>() {
@Override @Override
public void onResponse(@NonNull Call<List<Note>> call, @NonNull Response<List<Note>> response) { public void onResponse(@NonNull Call<List<Geofavorite>> call, @NonNull Response<List<Geofavorite>> response) {
((AppCompatActivity) view).runOnUiThread(() -> { ((AppCompatActivity) view).runOnUiThread(() -> {
view.hideLoading(); view.hideLoading();
if (response.isSuccessful() && response.body() != null) { if (response.isSuccessful() && response.body() != null) {
@ -53,7 +55,7 @@ public class MainPresenter {
} }
@Override @Override
public void onFailure(@NonNull Call<List<Note>> call, @NonNull Throwable t) { public void onFailure(@NonNull Call<List<Geofavorite>> call, @NonNull Throwable t) {
((AppCompatActivity) view).runOnUiThread(() -> { ((AppCompatActivity) view).runOnUiThread(() -> {
view.hideLoading(); view.hideLoading();
view.onErrorLoading(t.getLocalizedMessage()); view.onErrorLoading(t.getLocalizedMessage());

View File

@ -1,5 +1,5 @@
/* /*
* Nextcloud Notes Tutorial for Android * Nextcloud Maps Geofavorites for Android
* *
* @copyright Copyright (c) 2020 John Doe <john@doe.com> * @copyright Copyright (c) 2020 John Doe <john@doe.com>
* @author John Doe <john@doe.com> * @author John Doe <john@doe.com>
@ -22,11 +22,11 @@ package it.danieleverducci.nextcloudmaps.activity.main;
import java.util.List; import java.util.List;
import it.danieleverducci.nextcloudmaps.model.Note; import it.danieleverducci.nextcloudmaps.model.Geofavorite;
public interface MainView { public interface MainView {
void showLoading(); void showLoading();
void hideLoading(); void hideLoading();
void onGetResult(List<Note> notes); void onGetResult(List<Geofavorite> geofavorites);
void onErrorLoading(String message); void onErrorLoading(String message);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Nextcloud Notes Tutorial for Android * Nextcloud Maps Geofavorites for Android
* *
* @copyright Copyright (c) 2020 John Doe <john@doe.com> * @copyright Copyright (c) 2020 John Doe <john@doe.com>
* @author John Doe <john@doe.com> * @author John Doe <john@doe.com>

View File

@ -1,5 +1,5 @@
/* /*
* Nextcloud Notes Tutorial for Android * Nextcloud Maps Geofavorites for Android
* *
* @copyright Copyright (c) 2020 John Doe <john@doe.com> * @copyright Copyright (c) 2020 John Doe <john@doe.com>
* @author John Doe <john@doe.com> * @author John Doe <john@doe.com>
@ -76,7 +76,7 @@ public class SortingOrderDialogFragment extends DialogFragment {
if (arguments == null) { if (arguments == null) {
throw new IllegalArgumentException("Arguments may not be null"); throw new IllegalArgumentException("Arguments may not be null");
} }
mCurrentSortOrder = arguments.getInt(KEY_SORT_ORDER, NoteAdapter.SORT_BY_TITLE); mCurrentSortOrder = arguments.getInt(KEY_SORT_ORDER, GeofavoriteAdapter.SORT_BY_TITLE);
} }
@Override @Override
@ -99,13 +99,13 @@ public class SortingOrderDialogFragment extends DialogFragment {
mTaggedViews = new View[4]; mTaggedViews = new View[4];
mTaggedViews[0] = view.findViewById(R.id.sortByTitleAscending); mTaggedViews[0] = view.findViewById(R.id.sortByTitleAscending);
mTaggedViews[0].setTag(NoteAdapter.SORT_BY_TITLE); mTaggedViews[0].setTag(GeofavoriteAdapter.SORT_BY_TITLE);
mTaggedViews[1] = view.findViewById(R.id.sortByTitleAscendingText); mTaggedViews[1] = view.findViewById(R.id.sortByTitleAscendingText);
mTaggedViews[1].setTag(NoteAdapter.SORT_BY_TITLE); mTaggedViews[1].setTag(GeofavoriteAdapter.SORT_BY_TITLE);
mTaggedViews[2] = view.findViewById(R.id.sortByCreationDateDescending); mTaggedViews[2] = view.findViewById(R.id.sortByCreationDateDescending);
mTaggedViews[2].setTag(NoteAdapter.SORT_BY_CREATED); mTaggedViews[2].setTag(GeofavoriteAdapter.SORT_BY_CREATED);
mTaggedViews[3] = view.findViewById(R.id.sortByCreationDateDescendingText); mTaggedViews[3] = view.findViewById(R.id.sortByCreationDateDescendingText);
mTaggedViews[3].setTag(NoteAdapter.SORT_BY_CREATED); mTaggedViews[3].setTag(GeofavoriteAdapter.SORT_BY_CREATED);
setupActiveOrderSelection(); setupActiveOrderSelection();
} }
@ -121,10 +121,10 @@ public class SortingOrderDialogFragment extends DialogFragment {
if (view instanceof ImageButton) { if (view instanceof ImageButton) {
Drawable normalDrawable = ((ImageButton) view).getDrawable(); Drawable normalDrawable = ((ImageButton) view).getDrawable();
Drawable wrapDrawable = DrawableCompat.wrap(normalDrawable); Drawable wrapDrawable = DrawableCompat.wrap(normalDrawable);
DrawableCompat.setTint(wrapDrawable, this.getResources().getColor(R.color.defaultNoteTint)); DrawableCompat.setTint(wrapDrawable, this.getResources().getColor(R.color.defaultTint));
} }
if (view instanceof TextView) { if (view instanceof TextView) {
((TextView)view).setTextColor(this.getResources().getColor(R.color.defaultNoteTint)); ((TextView)view).setTextColor(this.getResources().getColor(R.color.defaultTint));
((TextView)view).setTypeface(Typeface.DEFAULT_BOLD); ((TextView)view).setTypeface(Typeface.DEFAULT_BOLD);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Nextcloud Notes Tutorial for Android * Nextcloud Maps Geofavorites for Android
* *
* @copyright Copyright (c) 2020 John Doe <john@doe.com> * @copyright Copyright (c) 2020 John Doe <john@doe.com>
* @author John Doe <john@doe.com> * @author John Doe <john@doe.com>
@ -22,7 +22,7 @@ package it.danieleverducci.nextcloudmaps.api;
import java.util.List; import java.util.List;
import it.danieleverducci.nextcloudmaps.model.Note; import it.danieleverducci.nextcloudmaps.model.Geofavorite;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.http.Body; import retrofit2.http.Body;
import retrofit2.http.DELETE; import retrofit2.http.DELETE;
@ -32,24 +32,24 @@ import retrofit2.http.PUT;
import retrofit2.http.Path; import retrofit2.http.Path;
public interface API { public interface API {
String mApiEndpoint = "/index.php/apps/notestutorial/api/0.1"; String mApiEndpoint = "/index.php/apps/maps/api/1.0";
@GET("/notes") @GET("/favorites")
Call<List<Note>> getNotes(); Call<List<Geofavorite>> getGeofavorites();
@POST("/notes") @POST("/favorites")
Call<Note> create( Call<Geofavorite> createGeofavorite (
@Body Note note @Body Geofavorite geofavorite
); );
@PUT("/notes/{id}") @PUT("/favorites/{id}")
Call<Note> updateNote( Call<Geofavorite> updateGeofavorite (
@Path("id") int id, @Path("id") int id,
@Body Note note @Body Geofavorite geofavorite
); );
@DELETE("/notes/{id}") @DELETE("/favorites/{id}")
Call<Note> deleteNote( Call<Geofavorite> deleteGeofavorite (
@Path("id") int id @Path("id") int id
); );
} }

View File

@ -1,5 +1,5 @@
/* /*
* Nextcloud Notes Tutorial for Android * Nextcloud Maps Geofavorites for Android
* *
* @copyright Copyright (c) 2020 John Doe <john@doe.com> * @copyright Copyright (c) 2020 John Doe <john@doe.com>
* @author John Doe <john@doe.com> * @author John Doe <john@doe.com>

View File

@ -0,0 +1,143 @@
/*
* Nextcloud Maps Geofavorites for Android
*
* @copyright Copyright (c) 2020 John Doe <john@doe.com>
* @author John Doe <john@doe.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package it.danieleverducci.nextcloudmaps.model;
import android.net.Uri;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.Comparator;
public class Geofavorite implements Serializable {
/**
* JSON Definition:
* {
* "id": 20,
* "name": "Ipermercato Collestrada",
* "date_modified": 1626798839,
* "date_created": 1626798825,
* "lat": 43.08620320282127,
* "lng": 12.481070617773184,
* "category": "Personal",
* "comment": "Strada Centrale Umbra 06135 Collestrada Umbria Italia",
* "extensions": ""
* }
*/
@Expose
@SerializedName("id") private int id;
@Expose
@SerializedName("name") private String name;
@Expose
@SerializedName("date_modified") private long dateModified;
@Expose
@SerializedName("date_created") private long dateCreated;
@Expose
@SerializedName("lat") private float lat;
@Expose
@SerializedName("lng") private float lng;
@Expose
@SerializedName("category") private String category;
@Expose
@SerializedName("comment") private String comment;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public long getDateModified() {
return dateModified;
}
public void setDateModified(long dateModified) {
this.dateModified = dateModified;
}
public long getDateCreated() {
return dateCreated;
}
public void setDateCreated(long dateCreated) {
this.dateCreated = dateCreated;
}
public float getLat() {
return lat;
}
public void setLat(float lat) {
this.lat = lat;
}
public float getLng() {
return lng;
}
public void setLng(float lng) {
this.lng = lng;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public static Comparator<Geofavorite> ByTitleAZ = (note, t1) -> note.name.compareTo(t1.name);
public static Comparator<Geofavorite> ByLastCreated = (note, t1) -> t1.id - note.id;
public Uri getGeoUri() {
return Uri.parse("geo:" + this.lat + "," + this.lng + "(" + this.name + ")");
}
}

View File

@ -1,67 +0,0 @@
/*
* Nextcloud Notes Tutorial for Android
*
* @copyright Copyright (c) 2020 John Doe <john@doe.com>
* @author John Doe <john@doe.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package it.danieleverducci.nextcloudmaps.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.Comparator;
public class Note implements Serializable {
@Expose
@SerializedName("id") private int id;
@Expose
@SerializedName("title") private String title;
@Expose
@SerializedName("content") private String content;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public static Comparator<Note> ByTitleAZ = (note, t1) -> note.title.compareTo(t1.title);
public static Comparator<Note> ByLastCreated = (note, t1) -> t1.id - note.id;
}

View File

@ -1,38 +0,0 @@
/*
* Nextcloud Notes Tutorial for Android
*
* @copyright Copyright (c) 2020 John Doe <john@doe.com>
* @author John Doe <john@doe.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package it.danieleverducci.nextcloudmaps.util;
import android.graphics.drawable.Drawable;
import android.view.MenuItem;
import androidx.annotation.ColorInt;
import androidx.core.graphics.drawable.DrawableCompat;
public class ColorUtil {
public static void menuItemTintColor(MenuItem item, @ColorInt int color) {
Drawable normalDrawable = item.getIcon();
Drawable wrapDrawable = DrawableCompat.wrap(normalDrawable);
DrawableCompat.setTint(wrapDrawable, color);
item.setIcon(wrapDrawable);
}
}

View File

@ -16,29 +16,28 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>. ~ along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<androidx.cardview.widget.CardView <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" 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"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/card_item" android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="4dp" android:padding="12dp"
android:layout_marginRight="4dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
app:cardCornerRadius="10dp"
app:cardElevation="1dp"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true">
android:foreground="?android:attr/selectableItemBackground"
tools:backgroundTint="@color/defaultNoteColor"> <ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0"
android:layout_marginRight="10dp"
android:src="@mipmap/ic_launcher"/>
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:padding="12dp">
<TextView <TextView
android:id="@+id/title" android:id="@+id/title"
@ -46,10 +45,10 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:textSize="@dimen/note_font_size_item_title" android:textSize="@dimen/note_font_size_item_title"
android:textColor="@color/note_font_color_default"
android:textStyle="bold" android:textStyle="bold"
android:singleLine="true" android:singleLine="true"
android:maxLines="1" android:maxLines="1"
android:lines="1"
android:ellipsize="end" android:ellipsize="end"
tools:text="@tools:sample/lorem/random"> tools:text="@tools:sample/lorem/random">
</TextView> </TextView>
@ -60,11 +59,12 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:textSize="@dimen/note_font_size_item_content" android:textSize="@dimen/note_font_size_item_content"
android:textColor="@color/note_font_color_default" android:maxLines="2"
android:lines="2"
tools:text="@tools:sample/lorem/random"> tools:text="@tools:sample/lorem/random">
</TextView> </TextView>
</LinearLayout> </LinearLayout>
</androidx.cardview.widget.CardView> </LinearLayout>

View File

@ -25,12 +25,7 @@
<color name="defaultBrand">#0082C9</color> <color name="defaultBrand">#0082C9</color>
<color name="note_font_color_default">#202124</color>
<color name="appbar">@android:color/white</color> <color name="appbar">@android:color/white</color>
<color name="defaultNoteColor">#F7EB96</color> <color name="defaultTint">#202124</color>
<color name="defaultNoteTint">#202124</color>
<color name="defaultNoteHintTint">#1A202124</color>
</resources> </resources>

View File

@ -1,5 +1,5 @@
/* /*
* Nextcloud Notes Tutorial for Android * Nextcloud Maps Geofavorites for Android
* *
* @copyright Copyright (c) 2020 John Doe <john@doe.com> * @copyright Copyright (c) 2020 John Doe <john@doe.com>
* @author John Doe <john@doe.com> * @author John Doe <john@doe.com>

View File

@ -1,5 +1,5 @@
# #
# Nextcloud Notes Tutorial for Android # Nextcloud Maps Geofavorites for Android
# #
# @copyright Copyright (c) 2020 John Doe <john@doe.com> # @copyright Copyright (c) 2020 John Doe <john@doe.com>
# @author John Doe <john@doe.com> # @author John Doe <john@doe.com>

View File

@ -1,5 +1,5 @@
/* /*
* Nextcloud Notes Tutorial for Android * Nextcloud Maps Geofavorites for Android
* *
* @copyright Copyright (c) 2020 John Doe <john@doe.com> * @copyright Copyright (c) 2020 John Doe <john@doe.com>
* @author John Doe <john@doe.com> * @author John Doe <john@doe.com>