Compare commits
1 Commits
dark-theme
...
adding-map
Author | SHA1 | Date | |
---|---|---|---|
be910bcabe |
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_API_30.avd" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</targetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2021-09-14T16:48:49.750165Z" />
|
||||
</component>
|
||||
</project>
|
13
.idea/misc.xml
generated
@ -4,17 +4,12 @@
|
||||
<option name="filePathToZoomLevelMap">
|
||||
<map>
|
||||
<entry key="../../../../layout/custom_preview.xml" value="0.5661458333333333" />
|
||||
<entry key="app/src/main/res/drawable/category_listitem_background.xml" value="0.35104166666666664" />
|
||||
<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.4" />
|
||||
<entry key="app/src/main/res/layout/activity_main.xml" value="0.5307291666666667" />
|
||||
<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.5218150087260035" />
|
||||
<entry key="app/src/main/res/layout/fragment_geofavorite_list.xml" value="0.1734375" />
|
||||
<entry key="app/src/main/res/layout/fragment_map.xml" value="0.19010416666666666" />
|
||||
<entry key="app/src/main/res/layout/item_geofav.xml" value="0.5307291666666667" />
|
||||
<entry key="app/src/main/res/layout/sorting_order_fragment.xml" value="0.4740740740740741" />
|
||||
<entry key="app/src/main/res/menu/list_context_menu.xml" value="0.41944444444444445" />
|
||||
</map>
|
||||
</option>
|
||||
|
@ -2,12 +2,6 @@
|
||||
|
||||
# Nextcloud Maps Geobookmarks Android app
|
||||
|
||||
[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png" alt="Get it on F-Droid" height="80">](https://f-droid.org/it/packages/it.danieleverducci.nextcloudmaps)
|
||||
[<img src="https://cdn.rawgit.com/steverichey/google-play-badge-svg/master/img/en_get.svg" height="80">](https://play.google.com/store/apps/details?id=it.danieleverducci.nextcloudmaps)
|
||||
[<img src="https://raw.githubusercontent.com/andOTP/andOTP/master/assets/badges/get-it-on-github.png" height="80">](https://github.com/penguin86/nextcloud-maps-client/releases/latest)
|
||||
|
||||
(Always prefer [F-Droid](https://f-droid.org) build, when possible).
|
||||
|
||||
Android app to show your Nextcloud Maps geobookmarks list. Geobookmarks can be opened in all apps supporting geo links (i.e. Google Maps, Organic Maps etc...).
|
||||
A new geobookmark can be created on current location.
|
||||
|
||||
@ -17,3 +11,5 @@ This work is heavily based on [matiasdelellis's Nextcloud SSO example](https://g
|
||||
|
||||
 
|
||||
|
||||
Download it from [the releases page](https://github.com/penguin86/nextcloud-maps-client/releases)
|
||||
|
||||
|
@ -24,8 +24,8 @@ android {
|
||||
applicationId "it.danieleverducci.nextcloudmaps"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 30
|
||||
versionCode 5
|
||||
versionName "0.3.3"
|
||||
versionCode 2
|
||||
versionName "0.2"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
@ -60,6 +60,7 @@ dependencies {
|
||||
implementation "androidx.cardview:cardview:1.0.0"
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
|
||||
implementation "androidx.preference:preference:1.1.1"
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
@ -73,9 +74,6 @@ dependencies {
|
||||
implementation "com.github.nextcloud:Android-SingleSignOn:0.5.6"
|
||||
|
||||
// OSMDroid
|
||||
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'
|
||||
compile 'org.osmdroid:osmdroid-android:6.1.10'
|
||||
|
||||
}
|
||||
|
@ -10,8 +10,8 @@
|
||||
{
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"versionCode": 3,
|
||||
"versionName": "0.3.1",
|
||||
"versionCode": 2,
|
||||
"versionName": "0.2",
|
||||
"outputFile": "app-release.apk"
|
||||
}
|
||||
]
|
||||
|
@ -50,17 +50,7 @@
|
||||
|
||||
<activity
|
||||
android:name=".activity.detail.GeofavoriteDetailActivity"
|
||||
android:theme="@style/AppTheme">
|
||||
<!-- standard "geo" scheme -->
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
|
||||
<data android:scheme="geo"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
android:theme="@style/AppTheme"/>
|
||||
|
||||
<activity
|
||||
android:name=".activity.about.AboutActivity"
|
||||
|
@ -62,10 +62,6 @@ public class AboutActivity extends AppCompatActivity {
|
||||
TextView tvIssues = findViewById(R.id.about_issues);
|
||||
tvIssues.setText(Html.fromHtml(getString(R.string.about_issues, getString(R.string.url_issues))));
|
||||
tvIssues.setOnClickListener(view -> openUtl(getString(R.string.url_issues)));
|
||||
|
||||
TextView tvMaps = findViewById(R.id.about_maps);
|
||||
tvMaps.setText(Html.fromHtml(getString(R.string.about_maps)));
|
||||
tvMaps.setOnClickListener(view -> openUtl(getString(R.string.url_maps)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,24 +0,0 @@
|
||||
package it.danieleverducci.nextcloudmaps.activity.detail;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
public class CategoriesSpinnerAdapter extends ArrayAdapter<String> {
|
||||
|
||||
public CategoriesSpinnerAdapter(@NonNull Context context) {
|
||||
super(context, android.R.layout.simple_dropdown_item_1line);
|
||||
}
|
||||
|
||||
// TODO: implement colors
|
||||
|
||||
public void setCategoriesList(HashSet<String> categories) {
|
||||
clear();
|
||||
addAll(categories);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
}
|
@ -19,7 +19,6 @@ 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;
|
||||
@ -37,8 +36,6 @@ import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import org.osmdroid.api.IMapController;
|
||||
@ -46,21 +43,13 @@ 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 java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import it.danieleverducci.nextcloudmaps.R;
|
||||
import it.danieleverducci.nextcloudmaps.activity.main.MainActivity;
|
||||
import it.danieleverducci.nextcloudmaps.activity.main.MainActivityViewModel;
|
||||
import it.danieleverducci.nextcloudmaps.api.ApiProvider;
|
||||
import it.danieleverducci.nextcloudmaps.databinding.ActivityGeofavoriteDetailBinding;
|
||||
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||
import it.danieleverducci.nextcloudmaps.utils.GeoUriParser;
|
||||
import it.danieleverducci.nextcloudmaps.utils.IntentGenerator;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
@ -68,13 +57,13 @@ import retrofit2.Response;
|
||||
public class GeofavoriteDetailActivity extends AppCompatActivity implements LocationListener, ActivityCompat.OnRequestPermissionsResultCallback {
|
||||
|
||||
public static final String TAG = "GeofavDetail";
|
||||
public static final String DEFAULT_CATEGORY = "Personal";
|
||||
public static final int MINIMUM_ACCEPTABLE_ACCURACY = 50; // In meters
|
||||
public static final String ARG_GEOFAVORITE = "geofav";
|
||||
private static final int PERMISSION_REQUEST_CODE = 9999;
|
||||
|
||||
private ViewHolder mViewHolder;
|
||||
private Geofavorite mGeofavorite;
|
||||
private GeofavoriteDetailActivityViewModel mViewModel;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@ -92,21 +81,6 @@ 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();
|
||||
@ -114,66 +88,22 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
|
||||
|
||||
@Override
|
||||
public void onMapClicked() {
|
||||
// TODO: Open map activity with pin
|
||||
startActivity(IntentGenerator.newGeoUriIntent(GeofavoriteDetailActivity.this, mGeofavorite));
|
||||
Toast.makeText(GeofavoriteDetailActivity.this, "TODO: Open map activity with pin", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
mViewModel = new ViewModelProvider(this).get(GeofavoriteDetailActivityViewModel.class);
|
||||
mViewModel.init();
|
||||
mViewModel.getCategories().observe(this, new Observer<HashSet<String>>() {
|
||||
@Override
|
||||
public void onChanged(HashSet<String> categories) {
|
||||
mViewHolder.setCategories(categories);
|
||||
}
|
||||
});
|
||||
mViewModel.getIsUpdating().observe(this, new Observer<Boolean>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable Boolean updating) {
|
||||
mViewHolder.setUpdating(updating);
|
||||
}
|
||||
});
|
||||
mViewModel.getOnFinished().observe(this, new Observer<Boolean>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable Boolean success) {
|
||||
if(success){
|
||||
Toast.makeText(GeofavoriteDetailActivity.this, R.string.geofavorite_saved, Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
} else {
|
||||
Toast.makeText(GeofavoriteDetailActivity.this, R.string.error_saving_geofavorite, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (getIntent().hasExtra(ARG_GEOFAVORITE) && getIntent().getIntExtra(ARG_GEOFAVORITE, 0) != 0) {
|
||||
if (getIntent().hasExtra(ARG_GEOFAVORITE)) {
|
||||
// Opening geofavorite from list
|
||||
mGeofavorite = mViewModel.getGeofavorite(
|
||||
getIntent().getIntExtra(ARG_GEOFAVORITE, 0)
|
||||
);
|
||||
mGeofavorite = (Geofavorite) getIntent().getSerializableExtra(ARG_GEOFAVORITE);
|
||||
mViewHolder.hideAccuracy();
|
||||
} else {
|
||||
// New geofavorite
|
||||
mGeofavorite = new Geofavorite();
|
||||
mGeofavorite.setCategory(Geofavorite.DEFAULT_CATEGORY);
|
||||
mGeofavorite.setDateCreated(System.currentTimeMillis() / 1000);
|
||||
mGeofavorite.setDateModified(System.currentTimeMillis() / 1000);
|
||||
mViewHolder.hideActions();
|
||||
|
||||
if (getIntent().getData() != null) {
|
||||
// Opened by external generic intent: parse URI
|
||||
try {
|
||||
double[] coords = GeoUriParser.parseUri(getIntent().getData());
|
||||
mGeofavorite.setLat(coords[0]);
|
||||
mGeofavorite.setLng(coords[1]);
|
||||
mViewHolder.hideAccuracy();
|
||||
} catch (IllegalArgumentException e) {
|
||||
Toast.makeText(this, R.string.error_unsupported_uri, Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
}
|
||||
} else {
|
||||
// Precompile location with current one
|
||||
getLocation();
|
||||
}
|
||||
mGeofavorite.setCategory(DEFAULT_CATEGORY);
|
||||
mGeofavorite.setDateCreated(System.currentTimeMillis());
|
||||
mGeofavorite.setDateModified(System.currentTimeMillis());
|
||||
// Precompile location
|
||||
getLocation();
|
||||
}
|
||||
|
||||
mViewHolder.updateView(mGeofavorite);
|
||||
@ -217,7 +147,35 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
|
||||
return;
|
||||
}
|
||||
|
||||
mViewModel.saveGeofavorite(mGeofavorite);
|
||||
Call<Geofavorite> call;
|
||||
if (mGeofavorite.getId() == 0) {
|
||||
// New geofavorite
|
||||
call = ApiProvider.getAPI().createGeofavorite(mGeofavorite);
|
||||
} else {
|
||||
// Update existing geofavorite
|
||||
call = ApiProvider.getAPI().updateGeofavorite(mGeofavorite.getId(), mGeofavorite);
|
||||
}
|
||||
call.enqueue(new Callback<Geofavorite>() {
|
||||
@Override
|
||||
public void onResponse(Call<Geofavorite> call, Response<Geofavorite> response) {
|
||||
if (response.isSuccessful())
|
||||
finish();
|
||||
else
|
||||
onGeofavoriteSaveFailed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Geofavorite> call, Throwable t) {
|
||||
onGeofavoriteSaveFailed();
|
||||
Log.e(TAG, "Unable to update geofavorite: " + t.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void onGeofavoriteSaveFailed() {
|
||||
runOnUiThread(() ->
|
||||
Toast.makeText(GeofavoriteDetailActivity.this, R.string.error_saving_geofavorite, Toast.LENGTH_SHORT).show()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -297,30 +255,18 @@ 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;
|
||||
|
||||
|
||||
public ViewHolder(LayoutInflater inflater) {
|
||||
|
||||
this.binding = ActivityGeofavoriteDetailBinding.inflate(inflater);
|
||||
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 categories adapter
|
||||
CategoriesSpinnerAdapter categoriesAdapter = new CategoriesSpinnerAdapter(binding.root.getContext());
|
||||
this.binding.categoryAt.setAdapter(categoriesAdapter);
|
||||
this.binding.categoryAt.setText(Geofavorite.DEFAULT_CATEGORY);
|
||||
|
||||
// Set map properties
|
||||
this.binding.map.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.NEVER);
|
||||
this.binding.map.setMultiTouchControls(true);
|
||||
// this.binding.map.setTilesScaledToDpi(true);
|
||||
|
||||
// Create marker
|
||||
mapMarker = new Marker(binding.map);
|
||||
@ -334,12 +280,11 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
|
||||
}
|
||||
|
||||
public void updateView(Geofavorite item) {
|
||||
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(item.getLocalDateCreated().format(dateFormatter));
|
||||
binding.modifiedTv.setText(item.getLocalDateCreated().format(dateFormatter));
|
||||
binding.categoryAt.setText(item.getCategory());
|
||||
binding.createdTv.setText(new Date(item.getDateCreated() * 1000).toString());
|
||||
binding.modifiedTv.setText(new Date(item.getDateModified() * 1000).toString());
|
||||
binding.categoryTv.setText(item.getCategory()); // TODO: Category spinner from existing categories
|
||||
updateViewCoords(item);
|
||||
}
|
||||
|
||||
@ -359,14 +304,9 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
|
||||
public void updateModel(Geofavorite item) {
|
||||
item.setName(binding.nameEt.getText().toString());
|
||||
item.setComment(binding.descriptionEt.getText().toString());
|
||||
item.setCategory(binding.categoryAt.getText().toString());
|
||||
item.setDateModified(System.currentTimeMillis() / 1000);
|
||||
}
|
||||
|
||||
public void setUpdating(boolean updating) {
|
||||
binding.progress.setVisibility(updating ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
public void setAccuracy(float accuracy) {
|
||||
binding.accuracyTv.setText(getString(R.string.accuracy).replace("{accuracy}", ((int)accuracy) + ""));
|
||||
// Color the accuracy background with a scale from red (MINIMUM_ACCEPTABLE_ACCURACY) to green (0 meters)
|
||||
@ -377,18 +317,10 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
|
||||
binding.accuracyTv.setBackgroundColor(Color.rgb(red, green, 0.0f));
|
||||
}
|
||||
|
||||
public void setCategories(HashSet<String> categories) {
|
||||
((CategoriesSpinnerAdapter)binding.categoryAt.getAdapter()).setCategoriesList(categories);
|
||||
}
|
||||
|
||||
public void hideAccuracy() {
|
||||
binding.accuracyTv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void hideActions() {
|
||||
binding.actionIcons.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void setOnSubmitListener(OnSubmitListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
@ -412,17 +344,6 @@ 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -430,8 +351,5 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
|
||||
void onSubmit();
|
||||
void onMapClicked();
|
||||
void onBackPressed();
|
||||
void onActionIconShareClicked();
|
||||
void onActionIconNavClicked();
|
||||
void onActionIconDeleteClicked();
|
||||
}
|
||||
}
|
||||
|
@ -1,41 +0,0 @@
|
||||
package it.danieleverducci.nextcloudmaps.activity.detail;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||
import it.danieleverducci.nextcloudmaps.repository.GeofavoriteRepository;
|
||||
|
||||
public class GeofavoriteDetailActivityViewModel extends ViewModel {
|
||||
private GeofavoriteRepository mRepo;
|
||||
|
||||
public void init() {
|
||||
mRepo = GeofavoriteRepository.getInstance();
|
||||
}
|
||||
|
||||
public Geofavorite getGeofavorite(int id) {
|
||||
return mRepo.getGeofavorite(id);
|
||||
}
|
||||
|
||||
public void saveGeofavorite(Geofavorite geofav) {
|
||||
mRepo.saveGeofavorite(geofav);
|
||||
}
|
||||
|
||||
public LiveData<HashSet<String>> getCategories(){
|
||||
return mRepo.getCategories();
|
||||
}
|
||||
|
||||
public LiveData<Boolean> getIsUpdating(){
|
||||
return mRepo.isUpdating();
|
||||
}
|
||||
|
||||
public LiveData<Boolean> getOnFinished(){
|
||||
return mRepo.onFinished();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package it.danieleverducci.nextcloudmaps.activity.main;
|
||||
|
||||
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||
|
||||
public interface GeofavoriteActivity {
|
||||
void showGeofavoriteDetailActivity(Geofavorite item);
|
||||
void showGeofavoriteDeteleDialog(Geofavorite item);
|
||||
void updateGeofavorites();
|
||||
void getGeofavorites();
|
||||
|
||||
}
|
@ -21,10 +21,13 @@
|
||||
package it.danieleverducci.nextcloudmaps.activity.main;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
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;
|
||||
@ -35,12 +38,8 @@ import android.widget.PopupMenu;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
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;
|
||||
@ -55,12 +54,9 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
|
||||
|
||||
public static final int SORT_BY_TITLE = 0;
|
||||
public static final int SORT_BY_CREATED = 1;
|
||||
public static final int SORT_BY_CATEGORY = 2;
|
||||
public static final int SORT_BY_DISTANCE = 3;
|
||||
|
||||
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<>();
|
||||
@ -86,6 +82,17 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
|
||||
return geofavoriteListFiltered.get(position);
|
||||
}
|
||||
|
||||
public void removeById(int id) {
|
||||
for (Geofavorite g : geofavoriteList) {
|
||||
if (g.getId() == id) {
|
||||
geofavoriteList.remove(g);
|
||||
geofavoriteListFiltered.remove(g);
|
||||
break;
|
||||
}
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public int getSortRule() {
|
||||
return sortRule;
|
||||
}
|
||||
@ -108,12 +115,8 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
|
||||
public void onBindViewHolder(@NonNull GeofavoriteViewHolder holder, int position) {
|
||||
Geofavorite geofavorite = geofavoriteListFiltered.get(position);
|
||||
|
||||
holder.tv_category.setText(geofavorite.categoryLetter());
|
||||
holder.tv_category_background.setTint(
|
||||
geofavorite.categoryColor() == 0 ? context.getColor(R.color.defaultBrand) : geofavorite.categoryColor());
|
||||
holder.tv_title.setText(Html.fromHtml(geofavorite.getName()));
|
||||
holder.tv_content.setText(geofavorite.getComment());
|
||||
holder.tv_date.setText(geofavorite.getLocalDateCreated().format(dateFormatter));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -161,10 +164,9 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
|
||||
};
|
||||
|
||||
class GeofavoriteViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
TextView tv_category, tv_title, tv_content, tv_date;
|
||||
TextView tv_title, tv_content;
|
||||
ImageView bt_context_menu;
|
||||
ImageView bt_nav;
|
||||
Drawable tv_category_background;
|
||||
ImageView bt_share;
|
||||
|
||||
ItemClickListener itemClickListener;
|
||||
|
||||
@ -172,19 +174,16 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
|
||||
GeofavoriteViewHolder(@NonNull View itemView, ItemClickListener itemClickListener) {
|
||||
super(itemView);
|
||||
|
||||
tv_category = itemView.findViewById(R.id.tv_category);
|
||||
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_nav = itemView.findViewById(R.id.geofav_nav_bt);
|
||||
tv_category_background = DrawableCompat.wrap(tv_category.getBackground());
|
||||
bt_share = itemView.findViewById(R.id.geofav_share_bt);
|
||||
|
||||
this.itemClickListener = itemClickListener;
|
||||
itemView.setOnClickListener(this);
|
||||
|
||||
bt_context_menu.setOnClickListener(this);
|
||||
bt_nav.setOnClickListener(this);
|
||||
bt_share.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -193,9 +192,9 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
|
||||
case R.id.geofav_context_menu_bt:
|
||||
onOverflowIconClicked(view, getAdapterPosition());
|
||||
break;
|
||||
case R.id.geofav_nav_bt:
|
||||
case R.id.geofav_share_bt:
|
||||
if (itemClickListener != null)
|
||||
itemClickListener.onItemNavClick(get(getAdapterPosition()));
|
||||
itemClickListener.onItemShareClick(get(getAdapterPosition()));
|
||||
break;
|
||||
default:
|
||||
if (itemClickListener != null)
|
||||
@ -209,10 +208,6 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
|
||||
Collections.sort(geofavoriteListFiltered, Geofavorite.ByTitleAZ);
|
||||
} else if (sortRule == SORT_BY_CREATED) {
|
||||
Collections.sort(geofavoriteListFiltered, Geofavorite.ByLastCreated);
|
||||
} else if (sortRule == SORT_BY_CATEGORY) {
|
||||
Collections.sort(geofavoriteListFiltered, Geofavorite.ByCategory);
|
||||
} else if (sortRule == SORT_BY_DISTANCE) {
|
||||
Collections.sort(geofavoriteListFiltered, Geofavorite.ByDistance);
|
||||
}
|
||||
}
|
||||
|
||||
@ -234,9 +229,9 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
|
||||
}
|
||||
Geofavorite gf = get(overflowMenuSelectedPosition);
|
||||
overflowMenuSelectedPosition = -1;
|
||||
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)
|
||||
if (item.getItemId() == R.id.list_context_menu_detail && itemClickListener != null)
|
||||
itemClickListener.onItemDetailsClick(gf);
|
||||
if (item.getItemId() == R.id.list_context_menu_delete)
|
||||
itemClickListener.onItemDeleteClick(gf);
|
||||
return true;
|
||||
}
|
||||
@ -244,7 +239,7 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
|
||||
public interface ItemClickListener {
|
||||
void onItemClick(Geofavorite item);
|
||||
void onItemShareClick(Geofavorite item);
|
||||
void onItemNavClick(Geofavorite item);
|
||||
void onItemDetailsClick(Geofavorite item);
|
||||
void onItemDeleteClick(Geofavorite item);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,6 @@ import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.AppCompatImageButton;
|
||||
@ -34,9 +33,9 @@ import androidx.appcompat.widget.SearchView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
||||
@ -56,17 +55,17 @@ 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.GeoUriParser;
|
||||
import it.danieleverducci.nextcloudmaps.utils.IntentGenerator;
|
||||
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter.*;
|
||||
import static it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter.SORT_BY_CREATED;
|
||||
import static it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter.SORT_BY_TITLE;
|
||||
import androidx.lifecycle.Observer;
|
||||
|
||||
public class MainActivity extends AppCompatActivity implements OnSortingOrderListener {
|
||||
public class MainActivity extends AppCompatActivity implements MainView, GeofavoriteActivity {
|
||||
|
||||
private static final int INTENT_ADD = 100;
|
||||
private static final int INTENT_EDIT = 200;
|
||||
|
||||
private static final String TAG = "MainActivity";
|
||||
|
||||
@ -74,20 +73,13 @@ public class MainActivity extends AppCompatActivity implements OnSortingOrderLis
|
||||
private static final String NAVIGATION_KEY_SHOW_ABOUT = "about";
|
||||
private static final String NAVIGATION_KEY_SWITCH_ACCOUNT = "switch_account";
|
||||
|
||||
private SharedPreferences preferences;
|
||||
|
||||
private DrawerLayout drawerLayout;
|
||||
private Toolbar toolbar;
|
||||
private MaterialCardView homeToolbar;
|
||||
private SearchView searchView;
|
||||
private SwipeRefreshLayout swipeRefresh;
|
||||
private RecyclerView recyclerView;
|
||||
private StaggeredGridLayoutManager layoutManager;
|
||||
private FloatingActionButton fab;
|
||||
|
||||
private GeofavoriteAdapter geofavoriteAdapter;
|
||||
private ItemClickListener rvItemClickListener;
|
||||
private MainActivityViewModel mMainActivityViewModel;
|
||||
private MainPresenter presenter;
|
||||
|
||||
NavigationAdapter navigationCommonAdapter;
|
||||
|
||||
@ -96,74 +88,7 @@ public class MainActivity extends AppCompatActivity implements OnSortingOrderLis
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
|
||||
int sortRule = preferences.getInt(getString(R.string.setting_sort_by), SORT_BY_CREATED);
|
||||
boolean gridViewEnabled = preferences.getBoolean(getString(R.string.setting_grid_view_enabled), false);
|
||||
|
||||
recyclerView = findViewById(R.id.recycler_view);
|
||||
layoutManager = new StaggeredGridLayoutManager(gridViewEnabled ? 2 : 1, StaggeredGridLayoutManager.VERTICAL);
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
|
||||
rvItemClickListener = new ItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(Geofavorite item) {
|
||||
showGeofavoriteDetailActivity(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemShareClick(Geofavorite item) {
|
||||
startActivity(Intent.createChooser(IntentGenerator.newShareIntent(MainActivity.this, item), getString(R.string.share_via)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemNavClick(Geofavorite item) {
|
||||
startActivity(IntentGenerator.newGeoUriIntent(MainActivity.this, item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemDeleteClick(Geofavorite item) {
|
||||
showGeofavoriteDeteleDialog(item);
|
||||
}
|
||||
};
|
||||
|
||||
geofavoriteAdapter = new GeofavoriteAdapter(getApplicationContext(), rvItemClickListener);
|
||||
recyclerView.setAdapter(geofavoriteAdapter);
|
||||
geofavoriteAdapter.setSortRule(sortRule);
|
||||
|
||||
|
||||
mMainActivityViewModel = new ViewModelProvider(this).get(MainActivityViewModel.class);
|
||||
mMainActivityViewModel.init();
|
||||
mMainActivityViewModel.getIsUpdating().observe(this, new Observer<Boolean>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable Boolean aBoolean) {
|
||||
if(aBoolean){
|
||||
swipeRefresh.setRefreshing(true);
|
||||
}
|
||||
else{
|
||||
swipeRefresh.setRefreshing(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
mMainActivityViewModel.getOnFinished().observe(this, new Observer<Boolean>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable Boolean success) {
|
||||
if(!success){
|
||||
Toast.makeText(MainActivity.this, R.string.list_geofavorite_connection_error, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
mMainActivityViewModel.getGeofavorites().observe(this, new Observer<List<Geofavorite>>() {
|
||||
@Override
|
||||
public void onChanged(List<Geofavorite> geofavorites) {
|
||||
geofavoriteAdapter.setGeofavoriteList(geofavorites);
|
||||
}
|
||||
});
|
||||
mMainActivityViewModel.updateGeofavorites();
|
||||
|
||||
swipeRefresh = findViewById(R.id.swipe_refresh);
|
||||
swipeRefresh.setOnRefreshListener(() ->
|
||||
mMainActivityViewModel.updateGeofavorites());
|
||||
presenter = new MainPresenter(this);
|
||||
|
||||
fab = findViewById(R.id.add);
|
||||
fab.setOnClickListener(view -> addGeofavorite());
|
||||
@ -205,14 +130,15 @@ public class MainActivity extends AppCompatActivity implements OnSortingOrderLis
|
||||
AppCompatImageButton menuButton = findViewById(R.id.menu_button);
|
||||
menuButton.setOnClickListener(view -> drawerLayout.openDrawer(GravityCompat.START));
|
||||
|
||||
AppCompatImageView viewButton = findViewById(R.id.view_mode);
|
||||
viewButton.setOnClickListener(view -> {
|
||||
boolean gridEnabled = layoutManager.getSpanCount() == 1;
|
||||
onGridIconChosen(gridEnabled);
|
||||
});
|
||||
|
||||
updateSortingIcon(sortRule);
|
||||
updateGridIcon(gridViewEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
||||
// Update list
|
||||
presenter.getGeofavorites();
|
||||
}
|
||||
|
||||
private void setupNavigationMenu() {
|
||||
@ -257,10 +183,19 @@ public class MainActivity extends AppCompatActivity implements OnSortingOrderLis
|
||||
SortingOrderDialogFragment.newInstance(sortOrder).show(fragmentTransaction, SortingOrderDialogFragment.SORTING_ORDER_FRAGMENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == INTENT_ADD && resultCode == RESULT_OK) {
|
||||
presenter.getGeofavorites();
|
||||
} else if (requestCode == INTENT_EDIT && resultCode == RESULT_OK) {
|
||||
presenter.getGeofavorites();
|
||||
}
|
||||
}
|
||||
|
||||
private void addGeofavorite() {
|
||||
startActivity(
|
||||
new Intent(this, GeofavoriteDetailActivity.class)
|
||||
);
|
||||
startActivityForResult(
|
||||
new Intent(this, GeofavoriteDetailActivity.class), INTENT_ADD);
|
||||
}
|
||||
|
||||
private void show_about() {
|
||||
@ -274,51 +209,45 @@ public class MainActivity extends AppCompatActivity implements OnSortingOrderLis
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSortingOrderChosen(int sortSelection) {
|
||||
geofavoriteAdapter.setSortRule(sortSelection);
|
||||
updateSortingIcon(sortSelection);
|
||||
|
||||
preferences.edit().putInt(getString(R.string.setting_sort_by), sortSelection).apply();
|
||||
public void showLoading() {
|
||||
//todo notify GeofavoriteListConsumer.geoFavoriteLoading(true)
|
||||
}
|
||||
|
||||
public void updateSortingIcon(int sortSelection) {
|
||||
AppCompatImageView sortButton = findViewById(R.id.sort_mode);
|
||||
switch (sortSelection) {
|
||||
case SORT_BY_TITLE:
|
||||
sortButton.setImageResource(R.drawable.ic_alphabetical_asc);
|
||||
break;
|
||||
case SORT_BY_CREATED:
|
||||
sortButton.setImageResource(R.drawable.ic_modification_asc);
|
||||
break;
|
||||
case SORT_BY_CATEGORY:
|
||||
sortButton.setImageResource(R.drawable.ic_category_asc);
|
||||
break;
|
||||
case SORT_BY_DISTANCE:
|
||||
sortButton.setImageResource(R.drawable.ic_distance_asc);
|
||||
break;
|
||||
}
|
||||
@Override
|
||||
public void hideLoading() {
|
||||
//todo notify GeofavoriteListConsumer.geoFavoriteLoading(false)
|
||||
}
|
||||
|
||||
public void onGridIconChosen(boolean gridEnabled) {
|
||||
layoutManager.setSpanCount(gridEnabled ? 2 : 1);
|
||||
updateGridIcon(gridEnabled);
|
||||
|
||||
preferences.edit().putBoolean(getString(R.string.setting_grid_view_enabled), gridEnabled).apply();
|
||||
@Override
|
||||
public void onGetResult(List<Geofavorite> geofavorite_list) {
|
||||
//todo notify GeofavoriteListConsumer
|
||||
}
|
||||
|
||||
public void updateGridIcon(boolean gridEnabled) {
|
||||
AppCompatImageView viewButton = findViewById(R.id.view_mode);
|
||||
viewButton.setImageResource(gridEnabled ? R.drawable.ic_view_list : R.drawable.ic_view_module);
|
||||
@Override
|
||||
public void onGeofavoriteDeleted(int id) {
|
||||
// Notify fragment
|
||||
runOnUiThread(() -> {
|
||||
//todo notify GeofavoriteListConsumer
|
||||
Toast.makeText(MainActivity.this, R.string.list_geofavorite_deleted, Toast.LENGTH_LONG).show();
|
||||
});
|
||||
}
|
||||
|
||||
private void showGeofavoriteDeteleDialog(Geofavorite item) {
|
||||
@Override
|
||||
public void onErrorLoading(String message) {
|
||||
Toast.makeText(MainActivity.this, R.string.list_geofavorite_connection_error, Toast.LENGTH_LONG).show();
|
||||
Log.e(TAG, "Unable to obtain geofavorites list: " + message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showGeofavoriteDeteleDialog(Geofavorite item) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
||||
builder.setMessage(getString(R.string.dialog_delete_message).replace("{name}", item.getName()))
|
||||
.setTitle(R.string.dialog_delete_title)
|
||||
.setPositiveButton(R.string.dialog_delete_delete, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
mMainActivityViewModel.deleteGeofavorite(item);
|
||||
presenter.deleteGeofavorite(item.getId());
|
||||
dialog.dismiss();
|
||||
// Callback is onGeofavoriteDeleted
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.dialog_delete_cancel, new DialogInterface.OnClickListener() {
|
||||
@ -330,10 +259,22 @@ public class MainActivity extends AppCompatActivity implements OnSortingOrderLis
|
||||
ad.show();
|
||||
}
|
||||
|
||||
private void showGeofavoriteDetailActivity(Geofavorite item) {
|
||||
@Override
|
||||
public void updateGeofavorites() {
|
||||
presenter.getGeofavorites();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGeofavorites() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showGeofavoriteDetailActivity(Geofavorite item) {
|
||||
Intent i = new Intent(this, GeofavoriteDetailActivity.class);
|
||||
i.putExtra(GeofavoriteDetailActivity.ARG_GEOFAVORITE, item.getId());
|
||||
i.putExtra(GeofavoriteDetailActivity.ARG_GEOFAVORITE, item);
|
||||
startActivity(i);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package it.danieleverducci.nextcloudmaps.activity.main;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||
import it.danieleverducci.nextcloudmaps.repository.GeofavoriteRepository;
|
||||
|
||||
public class MainActivityViewModel extends ViewModel {
|
||||
private GeofavoriteRepository mRepo;
|
||||
|
||||
public void init() {
|
||||
mRepo = GeofavoriteRepository.getInstance();
|
||||
}
|
||||
|
||||
public LiveData<List<Geofavorite>> getGeofavorites(){
|
||||
mRepo.updateGeofavorites();
|
||||
return mRepo.getGeofavorites();
|
||||
}
|
||||
|
||||
public void updateGeofavorites() {
|
||||
mRepo.updateGeofavorites();
|
||||
}
|
||||
|
||||
public void deleteGeofavorite(Geofavorite geofav) {
|
||||
mRepo.deleteGeofavorite(geofav);
|
||||
}
|
||||
|
||||
public LiveData<Boolean> getIsUpdating(){
|
||||
return mRepo.isUpdating();
|
||||
}
|
||||
|
||||
public LiveData<Boolean> getOnFinished(){
|
||||
return mRepo.onFinished();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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.activity.main;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import it.danieleverducci.nextcloudmaps.api.ApiProvider;
|
||||
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class MainPresenter {
|
||||
private MainView view;
|
||||
|
||||
public MainPresenter(MainView view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
public void getGeofavorites() {
|
||||
view.showLoading();
|
||||
Call<List<Geofavorite>> call = ApiProvider.getAPI().getGeofavorites();
|
||||
call.enqueue(new Callback<List<Geofavorite>>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Geofavorite>> call, @NonNull Response<List<Geofavorite>> response) {
|
||||
((AppCompatActivity) view).runOnUiThread(() -> {
|
||||
view.hideLoading();
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
view.onGetResult(response.body());
|
||||
} else {
|
||||
((AppCompatActivity) view).runOnUiThread(() -> {
|
||||
view.hideLoading();
|
||||
view.onErrorLoading(response.raw().message());
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Geofavorite>> call, @NonNull Throwable t) {
|
||||
((AppCompatActivity) view).runOnUiThread(() -> {
|
||||
view.hideLoading();
|
||||
view.onErrorLoading(t.getLocalizedMessage());
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteGeofavorite(int id) {
|
||||
view.showLoading();
|
||||
Call<Geofavorite> call = ApiProvider.getAPI().deleteGeofavorite(id);
|
||||
call.enqueue(new Callback<Geofavorite>() {
|
||||
@Override
|
||||
public void onResponse(Call<Geofavorite> call, Response<Geofavorite> response) {
|
||||
view.hideLoading();
|
||||
view.onGeofavoriteDeleted(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Geofavorite> call, Throwable t) {
|
||||
view.hideLoading();
|
||||
view.onErrorLoading(t.getLocalizedMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.activity.main;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||
|
||||
public interface MainView {
|
||||
void showLoading();
|
||||
void hideLoading();
|
||||
void onGetResult(List<Geofavorite> geofavorites);
|
||||
void onGeofavoriteDeleted(int id);
|
||||
void onErrorLoading(String message);
|
||||
}
|
@ -91,14 +91,13 @@ public class SortingOrderDialogFragment extends DialogFragment {
|
||||
|
||||
/**
|
||||
* find all relevant UI elements and set their values.
|
||||
* TODO: this is REALLY ugly.
|
||||
*
|
||||
* @param view the parent view
|
||||
*/
|
||||
private void setupDialogElements(View view) {
|
||||
mCancel = view.findViewById(R.id.cancel);
|
||||
|
||||
mTaggedViews = new View[8];
|
||||
mTaggedViews = new View[4];
|
||||
mTaggedViews[0] = view.findViewById(R.id.sortByTitleAscending);
|
||||
mTaggedViews[0].setTag(GeofavoriteAdapter.SORT_BY_TITLE);
|
||||
mTaggedViews[1] = view.findViewById(R.id.sortByTitleAscendingText);
|
||||
@ -107,14 +106,6 @@ public class SortingOrderDialogFragment extends DialogFragment {
|
||||
mTaggedViews[2].setTag(GeofavoriteAdapter.SORT_BY_CREATED);
|
||||
mTaggedViews[3] = view.findViewById(R.id.sortByCreationDateDescendingText);
|
||||
mTaggedViews[3].setTag(GeofavoriteAdapter.SORT_BY_CREATED);
|
||||
mTaggedViews[4] = view.findViewById(R.id.sortByCategoryAscending);
|
||||
mTaggedViews[4].setTag(GeofavoriteAdapter.SORT_BY_CATEGORY);
|
||||
mTaggedViews[5] = view.findViewById(R.id.sortByCategoryAscendingText);
|
||||
mTaggedViews[5].setTag(GeofavoriteAdapter.SORT_BY_CATEGORY);
|
||||
mTaggedViews[6] = view.findViewById(R.id.sortByDistanceAscending);
|
||||
mTaggedViews[6].setTag(GeofavoriteAdapter.SORT_BY_DISTANCE);
|
||||
mTaggedViews[7] = view.findViewById(R.id.sortByDistanceAscendingText);
|
||||
mTaggedViews[7].setTag(GeofavoriteAdapter.SORT_BY_DISTANCE);
|
||||
|
||||
setupActiveOrderSelection();
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
package it.danieleverducci.nextcloudmaps.fragments;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||
|
||||
public interface GeofavoriteListConsumer {
|
||||
void onGeofavoritesUpdated(List<Geofavorite> geofavorites);
|
||||
void onGeofavoriteRemoved(Geofavorite geofavorite);
|
||||
void onGeofavoriteAdded(Geofavorite geofavorite);
|
||||
void onGeofavoriteLoading(boolean isLoading);
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
package it.danieleverducci.nextcloudmaps.fragments;
|
||||
|
||||
import static it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter.SORT_BY_CREATED;
|
||||
import static it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter.SORT_BY_TITLE;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import it.danieleverducci.nextcloudmaps.R;
|
||||
import it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteActivity;
|
||||
import it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter;
|
||||
import it.danieleverducci.nextcloudmaps.activity.main.MainActivity;
|
||||
import it.danieleverducci.nextcloudmaps.activity.main.SortingOrderDialogFragment;
|
||||
import it.danieleverducci.nextcloudmaps.databinding.FragmentGeofavoriteListBinding;
|
||||
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||
|
||||
/**
|
||||
* Geofavorites list
|
||||
*/
|
||||
public class GeofavoriteListFragment extends Fragment implements GeofavoriteListConsumer, SortingOrderDialogFragment.OnSortingOrderListener {
|
||||
private FragmentGeofavoriteListBinding binding;
|
||||
private GeofavoriteAdapter geofavoriteAdapter;
|
||||
private SharedPreferences preferences;
|
||||
|
||||
public GeofavoriteListFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
if (binding == null) {
|
||||
binding = FragmentGeofavoriteListBinding.inflate(
|
||||
LayoutInflater.from(container.getContext()),
|
||||
container,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
|
||||
StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL);
|
||||
binding.recyclerView.setLayoutManager(layoutManager);
|
||||
|
||||
int sortRule = preferences.getInt(getString(R.string.setting_sort_by), SORT_BY_CREATED);
|
||||
GeofavoriteAdapter.ItemClickListener rvItemClickListener = new GeofavoriteAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(Geofavorite geofavorite) {
|
||||
Intent i = new Intent();
|
||||
i.setAction(Intent.ACTION_VIEW);
|
||||
i.setData(geofavorite.getGeoUri());
|
||||
startActivity(i);
|
||||
}
|
||||
|
||||
@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)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemDetailsClick(Geofavorite item) {
|
||||
if (getActivity() instanceof GeofavoriteActivity)
|
||||
((GeofavoriteActivity)getActivity()).showGeofavoriteDetailActivity(item);
|
||||
else
|
||||
throw new IllegalStateException("Expected activity implementing GeofavoriteAcivity");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemDeleteClick(Geofavorite item) {
|
||||
if (getActivity() instanceof GeofavoriteActivity)
|
||||
((GeofavoriteActivity)getActivity()).showGeofavoriteDeteleDialog(item);
|
||||
else
|
||||
throw new IllegalStateException("Expected activity implementing GeofavoriteAcivity");
|
||||
}
|
||||
};
|
||||
geofavoriteAdapter = new GeofavoriteAdapter(getContext(), rvItemClickListener);
|
||||
binding.recyclerView.setAdapter(geofavoriteAdapter);
|
||||
geofavoriteAdapter.setSortRule(sortRule);
|
||||
|
||||
binding.swipeRefresh.setOnRefreshListener(() ->
|
||||
((GeofavoriteActivity)getActivity()).updateGeofavorites());
|
||||
|
||||
return binding.root;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onGeofavoritesUpdated(List<Geofavorite> geofavorites) {
|
||||
if (geofavoriteAdapter != null)
|
||||
geofavoriteAdapter.setGeofavoriteList(geofavorites);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGeofavoriteRemoved(Geofavorite geofavorite) {
|
||||
// Update list
|
||||
geofavoriteAdapter.removeById(geofavorite.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGeofavoriteAdded(Geofavorite geofavorite) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGeofavoriteLoading(boolean isLoading) {
|
||||
binding.swipeRefresh.setRefreshing(isLoading);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onSortingOrderChosen(int sortSelection) {
|
||||
geofavoriteAdapter.setSortRule(sortSelection);
|
||||
updateSortingIcon(sortSelection);
|
||||
|
||||
preferences.edit().putInt(getString(R.string.setting_sort_by), sortSelection).apply();
|
||||
}
|
||||
|
||||
public void updateSortingIcon(int sortSelection) {
|
||||
// TODO: Gestire il bottone come bottone generico da aggiungere all'activity
|
||||
AppCompatImageView sortButton = findViewById(R.id.sort_mode);
|
||||
switch (sortSelection) {
|
||||
case SORT_BY_TITLE:
|
||||
sortButton.setImageResource(R.drawable.ic_alphabetical_asc);
|
||||
break;
|
||||
case SORT_BY_CREATED:
|
||||
sortButton.setImageResource(R.drawable.ic_modification_asc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package it.danieleverducci.nextcloudmaps.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import it.danieleverducci.nextcloudmaps.R;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link MapFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class MapFragment extends Fragment {
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
|
||||
// TODO: Rename and change types of parameters
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
|
||||
public MapFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this factory method to create a new instance of
|
||||
* this fragment using the provided parameters.
|
||||
*
|
||||
* @param param1 Parameter 1.
|
||||
* @param param2 Parameter 2.
|
||||
* @return A new instance of fragment MapFragment.
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static MapFragment newInstance(String param1, String param2) {
|
||||
MapFragment fragment = new MapFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_map, container, false);
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package it.danieleverducci.nextcloudmaps.fragments;
|
||||
|
||||
public interface SortableListFragment {
|
||||
|
||||
}
|
@ -20,26 +20,23 @@
|
||||
|
||||
package it.danieleverducci.nextcloudmaps.model;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.databinding.BaseObservable;
|
||||
import androidx.databinding.Bindable;
|
||||
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;
|
||||
|
||||
public class Geofavorite implements Serializable {
|
||||
public static final String DEFAULT_CATEGORY = "Personal";
|
||||
private static final double EARTH_RADIUS = 6371; // https://en.wikipedia.org/wiki/Earth_radius
|
||||
|
||||
/**
|
||||
* JSON Definition:
|
||||
* {
|
||||
@ -105,17 +102,10 @@ 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;
|
||||
}
|
||||
@ -149,72 +139,18 @@ public class Geofavorite implements Serializable {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparators for list order
|
||||
*/
|
||||
public static Comparator<Geofavorite> ByTitleAZ = (gf0, gf1) -> gf0.name.compareTo(gf1.name);
|
||||
public static Comparator<Geofavorite> ByLastCreated = (gf0, gf1) -> (int) (gf1.dateCreated - gf0.dateCreated);
|
||||
public static Comparator<Geofavorite> ByCategory = (gf0, gf1) -> (gf0.category + gf0.name).compareTo(gf1.category + gf1.name);
|
||||
public static Comparator<Geofavorite> ByDistance = (gf0, gf1) -> 0; // (int) ((gf1.getDistanceFrom(userPosition) - gf0.getDistanceFrom(userPosition)) * 1000);
|
||||
public static Comparator<Geofavorite> ByTitleAZ = (note, t1) -> note.name.compareTo(t1.name);
|
||||
public static Comparator<Geofavorite> ByLastCreated = (note, t1) -> t1.id - note.id;
|
||||
|
||||
public String getCoordinatesString() {
|
||||
return this.lat + " N, " + this.lng + " E";
|
||||
}
|
||||
|
||||
public Uri getGeoUri() {
|
||||
return Uri.parse("geo:" + this.lat + "," + this.lng + "(" + this.name + ")");
|
||||
}
|
||||
|
||||
public boolean valid() {
|
||||
return
|
||||
getLat() != 0 && getLng() != 0 &&
|
||||
getName() != null && getName().length() > 0 &&
|
||||
getCategory() != null && getCategory().length() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the distance between the current Geofavorite and the provided one, in kilometers.
|
||||
* @param other Geovavorite
|
||||
* @return the distance in kilometers
|
||||
*/
|
||||
public double getDistanceFrom(Geofavorite other) {
|
||||
double latDistance = (other.lat-lat) * Math.PI / 180;
|
||||
double lonDistance = (other.lng-lng) * Math.PI / 180;
|
||||
double a =
|
||||
Math.sin(latDistance / 2) * Math.sin(latDistance / 2) +
|
||||
Math.cos(lat * Math.PI / 180) * Math.cos(other.lat * Math.PI / 180) *
|
||||
Math.sin(lonDistance / 2) * Math.sin(lonDistance / 2);
|
||||
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
|
||||
return EARTH_RADIUS * c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on Nextcloud Maps's getLetterColor util.
|
||||
* Assigns a color to a category based on its two first letters.
|
||||
*
|
||||
* @see "https://github.com/nextcloud/maps/blob/master/src/utils.js"
|
||||
* @return the generated color or null for the default category
|
||||
*/
|
||||
public int categoryColor() {
|
||||
// If category is default, return null: will be used Nextcloud's accent
|
||||
if (this.category.equals(DEFAULT_CATEGORY))
|
||||
return 0;
|
||||
|
||||
float letter1Index = this.category.toLowerCase().charAt(0);
|
||||
float letter2Index = this.category.toLowerCase().charAt(1);
|
||||
float letterCoef = ((letter1Index * letter2Index) % 100) / 100;
|
||||
float h = letterCoef * 360;
|
||||
float s = 75 + letterCoef * 10;
|
||||
float l = 50 + letterCoef * 10;
|
||||
return Color.HSVToColor( new float[]{ Math.round(h), Math.round(s), Math.round(l) });
|
||||
}
|
||||
|
||||
public String categoryLetter() {
|
||||
if (category == null || category.length() == 0)
|
||||
return "";
|
||||
if (category.equals(DEFAULT_CATEGORY))
|
||||
return "\u2022";
|
||||
return category.substring(0,1);
|
||||
return getLat() != 0 && getLng() != 0 && getName() != null && getName().length() > 0;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@ -222,5 +158,4 @@ public class Geofavorite implements Serializable {
|
||||
public String toString() {
|
||||
return "[" + getName() + " (" + getLat() + "," + getLng() + ")]";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,164 +0,0 @@
|
||||
package it.danieleverducci.nextcloudmaps.repository;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import it.danieleverducci.nextcloudmaps.api.ApiProvider;
|
||||
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||
import it.danieleverducci.nextcloudmaps.utils.SingleLiveEvent;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Singleton pattern
|
||||
*/
|
||||
public class GeofavoriteRepository {
|
||||
|
||||
private static final String TAG = "GeofavoriteRepository";
|
||||
private static GeofavoriteRepository instance;
|
||||
private MutableLiveData<List<Geofavorite>> mGeofavorites;
|
||||
private MutableLiveData<HashSet<String>> mCategories = new MutableLiveData<HashSet<String>>();
|
||||
private MutableLiveData<Boolean> mIsUpdating = new MutableLiveData<>(false);
|
||||
private SingleLiveEvent<Boolean> mOnFinished = new SingleLiveEvent<>();
|
||||
|
||||
public static GeofavoriteRepository getInstance() {
|
||||
if(instance == null){
|
||||
instance = new GeofavoriteRepository();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public MutableLiveData<List<Geofavorite>> getGeofavorites(){
|
||||
if (mGeofavorites == null) {
|
||||
mGeofavorites = new MutableLiveData<>();
|
||||
mGeofavorites.setValue(new ArrayList<>());
|
||||
}
|
||||
return mGeofavorites;
|
||||
}
|
||||
|
||||
public MutableLiveData<HashSet<String>> getCategories() {
|
||||
return mCategories;
|
||||
}
|
||||
|
||||
public MutableLiveData<Boolean> isUpdating() {
|
||||
return mIsUpdating;
|
||||
}
|
||||
|
||||
public SingleLiveEvent<Boolean> onFinished() {
|
||||
return mOnFinished;
|
||||
}
|
||||
|
||||
public void updateGeofavorites() {
|
||||
mIsUpdating.postValue(true);
|
||||
// Obtain geofavorites
|
||||
Call<List<Geofavorite>> call = ApiProvider.getAPI().getGeofavorites();
|
||||
call.enqueue(new Callback<List<Geofavorite>>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Geofavorite>> call, @NonNull Response<List<Geofavorite>> response) {
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
mGeofavorites.postValue(response.body());
|
||||
updateCategories(response.body());
|
||||
mIsUpdating.postValue(false);
|
||||
mOnFinished.postValue(true);
|
||||
} else {
|
||||
onFailure(call, new Throwable("Dataset is empty"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Geofavorite>> call, @NonNull Throwable t) {
|
||||
mIsUpdating.postValue(false);
|
||||
mOnFinished.postValue(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Geofavorite getGeofavorite(int id) {
|
||||
for (Geofavorite g : mGeofavorites.getValue()) {
|
||||
if (g.getId() == id)
|
||||
return g;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void saveGeofavorite(Geofavorite geofav) {
|
||||
mIsUpdating.postValue(true);
|
||||
Call<Geofavorite> call;
|
||||
if (geofav.getId() == 0) {
|
||||
// New geofavorite
|
||||
call = ApiProvider.getAPI().createGeofavorite(geofav);
|
||||
} else {
|
||||
// Update existing geofavorite
|
||||
call = ApiProvider.getAPI().updateGeofavorite(geofav.getId(), geofav);
|
||||
}
|
||||
call.enqueue(new Callback<Geofavorite>() {
|
||||
@Override
|
||||
public void onResponse(Call<Geofavorite> call, Response<Geofavorite> response) {
|
||||
if (response.isSuccessful()) {
|
||||
List<Geofavorite> geofavs = mGeofavorites.getValue();
|
||||
if (geofav.getId() != 0) {
|
||||
geofavs.remove(geofav);
|
||||
}
|
||||
geofavs.add(response.body());
|
||||
mGeofavorites.postValue(geofavs);
|
||||
mIsUpdating.postValue(false);
|
||||
mOnFinished.postValue(true);
|
||||
} else {
|
||||
mIsUpdating.postValue(false);
|
||||
mOnFinished.postValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Geofavorite> call, Throwable t) {
|
||||
Log.e(TAG, t.getMessage());
|
||||
mIsUpdating.postValue(false);
|
||||
mOnFinished.postValue(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteGeofavorite(Geofavorite geofav) {
|
||||
mIsUpdating.postValue(true);
|
||||
// Delete Geofavorite
|
||||
Call<Geofavorite> call = ApiProvider.getAPI().deleteGeofavorite(geofav.getId());
|
||||
call.enqueue(new Callback<Geofavorite>() {
|
||||
@Override
|
||||
public void onResponse(Call<Geofavorite> call, Response<Geofavorite> response) {
|
||||
List<Geofavorite> geofavs = mGeofavorites.getValue();
|
||||
if (geofavs.remove(geofav)) {
|
||||
mGeofavorites.postValue(geofavs);
|
||||
mIsUpdating.postValue(false);
|
||||
mOnFinished.postValue(true);
|
||||
} else {
|
||||
// Should never happen
|
||||
mIsUpdating.postValue(false);
|
||||
mOnFinished.postValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Geofavorite> call, Throwable t) {
|
||||
mIsUpdating.postValue(false);
|
||||
mOnFinished.postValue(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateCategories(List<Geofavorite> geofavs) {
|
||||
HashSet<String> categories = new HashSet<>();
|
||||
for (Geofavorite g : geofavs) {
|
||||
categories.add(g.getCategory());
|
||||
}
|
||||
mCategories.postValue(categories);
|
||||
}
|
||||
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package it.danieleverducci.nextcloudmaps.utils;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||
|
||||
public class GeoUriParser {
|
||||
private static final Pattern PATTERN_GEO = Pattern.compile("geo:(-?[\\d.]+),(-?[\\d.]+)");
|
||||
|
||||
public static double[] parseUri(Uri uri) throws IllegalArgumentException {
|
||||
if (uri == null)
|
||||
throw new IllegalArgumentException("no uri");
|
||||
|
||||
Matcher m = PATTERN_GEO.matcher(uri.toString());
|
||||
if (m.find() && m.groupCount() == 2) {
|
||||
String sLat = m.group(1);
|
||||
String sLon = m.group(2);
|
||||
try {
|
||||
return new double[]{Double.parseDouble(sLat), Double.parseDouble(sLon)};
|
||||
} catch (NumberFormatException e) {
|
||||
throw new IllegalArgumentException("unable to parse uri");
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("unable to parse uri");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package it.danieleverducci.nextcloudmaps.utils;
|
||||
|
||||
import androidx.annotation.MainThread;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.Observer;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* Events implementation in LiveData
|
||||
* From: https://gist.github.com/teegarcs/319a3e7e4736a0cce8eba2216c52b0ca#file-singleliveevent
|
||||
* @param <T>
|
||||
*/
|
||||
public class SingleLiveEvent<T> extends MutableLiveData<T> {
|
||||
AtomicBoolean mPending = new AtomicBoolean(false);
|
||||
|
||||
@MainThread
|
||||
@Override
|
||||
public void setValue(T value) {
|
||||
mPending.set(true);
|
||||
super.setValue(value);
|
||||
}
|
||||
|
||||
@MainThread
|
||||
@Override
|
||||
public void observe(@NonNull LifecycleOwner owner, @NonNull Observer<? super T> observer) {
|
||||
super.observe(owner, new Observer<T>() {
|
||||
@Override
|
||||
public void onChanged(T t) {
|
||||
if (mPending.compareAndSet(true, false)) {
|
||||
observer.onChanged(t);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Util function for Void implementations.
|
||||
*/
|
||||
public void call() {
|
||||
setValue(null);
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:left="8dp"
|
||||
android:right="8dp"
|
||||
android:top="8dp"
|
||||
android:bottom="8dp">
|
||||
<shape
|
||||
android:shape="oval">
|
||||
<solid android:color="@color/defaultBrand"/>
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:left="8dp"
|
||||
android:right="8dp"
|
||||
android:top="8dp"
|
||||
android:bottom="8dp">
|
||||
<shape
|
||||
android:shape="oval">
|
||||
<solid android:color="@color/defaultBrandAlpha"/>
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
@ -1,16 +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="M12,2l-5.5,9h11z"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M17.5,17.5m-4.5,0a4.5,4.5 0,1 1,9 0a4.5,4.5 0,1 1,-9 0"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M3,13.5h8v8H3z"/>
|
||||
</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="M21,3L3,10.53v0.98l6.84,2.65L12.48,21h0.98L21,3z"/>
|
||||
</vector>
|
@ -1,5 +0,0 @@
|
||||
<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>
|
@ -1,5 +0,0 @@
|
||||
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||
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="M17,1.01L7,1c-1.1,0 -1.99,0.9 -1.99,2v18c0,1.1 0.89,2 1.99,2h10c1.1,0 2,-0.9 2,-2L19,3c0,-1.1 -0.9,-1.99 -2,-1.99zM17,19L7,19L7,5h10v14zM12.8,13.22v1.75l3.2,-2.99L12.8,9v1.7c-3.11,0.43 -4.35,2.56 -4.8,4.7 1.11,-1.5 2.58,-2.18 4.8,-2.18z"/>
|
||||
</vector>
|
@ -1,23 +0,0 @@
|
||||
<!--
|
||||
~ Nextcloud Maps Geofavorites for Android
|
||||
~
|
||||
~ 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/>.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path android:fillColor="#FFFFFF" android:pathData="M9,5V9H21V5M9,19H21V15H9M9,14H21V10H9M4,9H8V5H4M4,19H8V15H4M4,14H8V10H4V14Z" />
|
||||
</vector>
|
@ -1,25 +0,0 @@
|
||||
<!--
|
||||
~ Nextcloud Maps Geofavorites for Android
|
||||
~
|
||||
~ 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/>.
|
||||
-->
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path android:fillColor="#FFFFFF"
|
||||
android:pathData="M16,5V11H21V5M10,11H15V5H10M16,18H21V12H16M10,18H15V12H10M4,18H9V12H4M4,11H9V5H4V11Z" />
|
||||
</vector>
|
@ -115,20 +115,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="@string/about_issues" />
|
||||
|
||||
<TextView
|
||||
style="?android:attr/listSeparatorTextViewStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/about_maps_title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/about_maps"
|
||||
style="?android:attr/editTextPreferenceStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="@string/about_maps" />
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
@ -2,32 +2,23 @@
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/root">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="250dp"
|
||||
android:fitsSystemWindows="true">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:id="@+id/collapsing_toolbar"
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
app:contentScrim="@color/defaultBrand"
|
||||
app:layout_scrollFlags="scroll|snap|exitUntilCollapsed"
|
||||
app:title="@string/new_geobookmark"
|
||||
app:expandedTitleTextAppearance="@style/TextAppearance.GeofavoriteDetail.Header.Expanded"
|
||||
app:collapsedTitleTextAppearance="@style/TextAppearance.GeofavoriteDetail.Header.Collapsed">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_collapseMode="parallax">
|
||||
android:layout_height="200dp">
|
||||
<org.osmdroid.views.MapView
|
||||
android:id="@+id/map"
|
||||
android:layout_width="match_parent"
|
||||
@ -40,196 +31,121 @@
|
||||
android:layout_height="match_parent"/>
|
||||
</FrameLayout>
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:contentInsetStart="0dp"
|
||||
app:layout_collapseMode="pin"
|
||||
android:background="@android:color/transparent">
|
||||
|
||||
<!-- Back button -->
|
||||
<ImageView
|
||||
android:id="@+id/back_bt"
|
||||
android:layout_width="?attr/actionBarSize"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:padding="16dp"
|
||||
android:src="@drawable/ic_back_grey"
|
||||
app:tint="@color/white"
|
||||
android:background="@drawable/floating_semitransparent_button_background"/>
|
||||
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
|
||||
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="20dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/accuracy_tv"
|
||||
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"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/action_icons"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="20dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/action_icon_share"
|
||||
android:layout_width="0dp"
|
||||
<EditText
|
||||
android:id="@+id/name_et"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:padding="10dp"
|
||||
android:src="@drawable/ic_share"
|
||||
android:tint="@color/defaultBrand"/>
|
||||
android:ems="10"
|
||||
android:hint="@string/name"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="end"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/action_icon_nav"
|
||||
android:layout_width="0dp"
|
||||
<EditText
|
||||
android:id="@+id/description_et"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:padding="10dp"
|
||||
android:src="@drawable/ic_nav"
|
||||
android:tint="@color/defaultBrand"/>
|
||||
android:ems="10"
|
||||
android:gravity="start|top"
|
||||
android:inputType="textMultiLine"
|
||||
android:lines="5"
|
||||
android:maxLines="10"
|
||||
android:hint="@string/description"
|
||||
android:ellipsize="end" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/action_icon_delete"
|
||||
android:layout_width="0dp"
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
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 -->
|
||||
android:layout_marginTop="20dp"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/created" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/created_tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="textEnd" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/modified" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/modified_tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="textEnd" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/category" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/category_tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="textEnd" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="@string/coords"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/coords_tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="textEnd" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/accuracy_tv"
|
||||
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>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/name_et"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="40dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/name"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/defaultBrand"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Title"
|
||||
android:background="@android:color/transparent"
|
||||
android:drawableLeft="@drawable/ic_edit"
|
||||
android:drawablePadding="5dp"
|
||||
android:drawableTint="@color/defaultBrand"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/description_et"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:ems="10"
|
||||
android:gravity="start|top"
|
||||
android:inputType="textMultiLine"
|
||||
android:maxLines="10"
|
||||
android:background="@android:color/transparent"
|
||||
android:drawableLeft="@drawable/ic_edit"
|
||||
android:drawablePadding="5dp"
|
||||
android:drawableTint="@color/defaultBrand"
|
||||
android:hint="@string/description"/>
|
||||
|
||||
<AutoCompleteTextView
|
||||
android:id="@+id/category_at"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:ems="10"
|
||||
android:gravity="start|top"
|
||||
android:inputType="textMultiLine"
|
||||
android:maxLines="10"
|
||||
android:background="@android:color/transparent"
|
||||
android:drawableLeft="@drawable/ic_category_asc"
|
||||
android:drawablePadding="5dp"
|
||||
android:drawableTint="@color/defaultBrand"
|
||||
android:hint="@string/category"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="40dp"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/created" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/created_tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="textEnd" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/modified" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/modified_tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="textEnd" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="@string/coords"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/coords_tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="textEnd" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<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>
|
||||
</ScrollView>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
<!-- Back button -->
|
||||
<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"/>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
</FrameLayout>
|
||||
</layout>
|
@ -1,166 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Nextcloud Maps Geofavorites for Android
|
||||
~
|
||||
~ 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/>.
|
||||
-->
|
||||
|
||||
<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:id="@+id/activity_list_view"
|
||||
android:background="@color/primary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:elevation="0dp">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:id="@+id/toolbar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="true"
|
||||
app:contentScrim="?attr/colorPrimary"
|
||||
app:layout_scrollFlags="scroll|enterAlways"
|
||||
app:toolbarId="@+id/toolbar" >
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="visible"
|
||||
app:contentInsetStartWithNavigation="0dp"
|
||||
app:titleMarginStart="0dp"
|
||||
tools:title="@string/app_name">
|
||||
|
||||
<androidx.appcompat.widget.SearchView
|
||||
android:id="@+id/search_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
</androidx.appcompat.widget.SearchView>
|
||||
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/home_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/spacer_2x"
|
||||
android:layout_marginTop="@dimen/spacer_1hx"
|
||||
android:layout_marginEnd="@dimen/spacer_2x"
|
||||
android:layout_marginBottom="@dimen/spacer_1hx"
|
||||
app:cardBackgroundColor="@color/appbar"
|
||||
app:cardCornerRadius="@dimen/spacer_1x"
|
||||
app:cardElevation="2dp"
|
||||
app:strokeWidth="0dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
android:id="@+id/menu_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:paddingStart="@dimen/spacer_1x"
|
||||
android:paddingTop="@dimen/spacer_2x"
|
||||
android:paddingEnd="@dimen/spacer_1x"
|
||||
android:paddingBottom="@dimen/spacer_2x"
|
||||
android:tint="?attr/colorAccent"
|
||||
android:src="@drawable/ic_menu_grey"/>
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/search_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="@dimen/spacer_1x"
|
||||
android:layout_marginEnd="@dimen/spacer_1x"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:gravity="start"
|
||||
android:lines="1"
|
||||
android:textSize="16sp"
|
||||
android:text="@string/search_in_all"/>
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/sort_mode"
|
||||
android:layout_width="?attr/actionBarSize"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/list_mode"
|
||||
android:padding="@dimen/spacer_2x"
|
||||
android:tint="?attr/colorAccent"
|
||||
android:translationX="@dimen/spacer_1x"
|
||||
android:src="@drawable/ic_alphabetical_asc" />
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/view_mode"
|
||||
android:layout_width="?attr/actionBarSize"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/list_mode"
|
||||
android:padding="@dimen/spacer_2x"
|
||||
android:tint="?attr/colorAccent"
|
||||
android:translationX="@dimen/spacer_1x"
|
||||
android:src="@drawable/ic_view_module" />
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipe_refresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="@dimen/spacer_1hx"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layoutManager="androidx.recyclerview.widget.StaggeredGridLayoutManager"
|
||||
app:spanCount="1"
|
||||
tools:itemCount="3"
|
||||
tools:listitem="@layout/item_geofav">
|
||||
</androidx.recyclerview.widget.RecyclerView>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/add"
|
||||
android:layout_margin="16dp"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_add"
|
||||
app:backgroundTint="@color/defaultBrand"/>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
@ -26,12 +26,126 @@
|
||||
tools:openDrawer="start"
|
||||
tools:context=".activity.main.MainActivity">
|
||||
|
||||
<include layout="@layout/activity_list_view"
|
||||
android:id="@+id/activity_list_view"
|
||||
<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:background="@color/primary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/root">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:elevation="0dp">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:id="@+id/toolbar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="true"
|
||||
app:contentScrim="?attr/colorPrimary"
|
||||
app:layout_scrollFlags="scroll|enterAlways"
|
||||
app:toolbarId="@+id/toolbar" >
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="visible"
|
||||
app:contentInsetStartWithNavigation="0dp"
|
||||
app:titleMarginStart="0dp"
|
||||
tools:title="@string/app_name">
|
||||
|
||||
<androidx.appcompat.widget.SearchView
|
||||
android:id="@+id/search_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
</androidx.appcompat.widget.SearchView>
|
||||
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/home_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/spacer_2x"
|
||||
android:layout_marginTop="@dimen/spacer_1hx"
|
||||
android:layout_marginEnd="@dimen/spacer_2x"
|
||||
android:layout_marginBottom="@dimen/spacer_1hx"
|
||||
app:cardBackgroundColor="@color/appbar"
|
||||
app:cardCornerRadius="@dimen/spacer_1x"
|
||||
app:cardElevation="2dp"
|
||||
app:strokeWidth="0dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
android:id="@+id/menu_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:paddingStart="@dimen/spacer_1x"
|
||||
android:paddingTop="@dimen/spacer_2x"
|
||||
android:paddingEnd="@dimen/spacer_1x"
|
||||
android:paddingBottom="@dimen/spacer_2x"
|
||||
android:tint="?attr/colorAccent"
|
||||
android:src="@drawable/ic_menu_grey"/>
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/search_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="@dimen/spacer_1x"
|
||||
android:layout_marginEnd="@dimen/spacer_1x"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:gravity="start"
|
||||
android:lines="1"
|
||||
android:textSize="16sp"
|
||||
android:text="@string/search_in_all"/>
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/sort_mode"
|
||||
android:layout_width="?attr/actionBarSize"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/list_mode"
|
||||
android:padding="@dimen/spacer_2x"
|
||||
android:tint="?attr/colorAccent"
|
||||
android:translationX="@dimen/spacer_1x"
|
||||
android:src="@drawable/ic_alphabetical_asc" />
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/fragment_container"
|
||||
android:name="it.danieleverducci.nextcloudmaps.fragments.GeofavoriteListFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
</androidx.fragment.app.FragmentContainerView>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/add"
|
||||
android:layout_margin="16dp"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_add"
|
||||
app:backgroundTint="@color/defaultBrand"/>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
<!-- TODO: Is use another layout for that is fill screen. -->
|
||||
<com.google.android.material.navigation.NavigationView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
|
55
app/src/main/res/layout/fragment_geofavorite_list.xml
Normal file
@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Nextcloud Maps Geofavorites for Android
|
||||
~
|
||||
~ 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/>.
|
||||
-->
|
||||
|
||||
<layout 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">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipe_refresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="@dimen/spacer_1hx"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layoutManager="androidx.recyclerview.widget.StaggeredGridLayoutManager"
|
||||
app:spanCount="1"
|
||||
tools:itemCount="3"
|
||||
tools:listitem="@layout/item_geofav">
|
||||
</androidx.recyclerview.widget.RecyclerView>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</layout>
|
14
app/src/main/res/layout/fragment_map.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".fragments.MapFragment">
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="Map fragment" />
|
||||
|
||||
</FrameLayout>
|
@ -23,95 +23,65 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="90dp"
|
||||
android:gravity="center_vertical"
|
||||
android:padding="12dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_category"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="4dp"
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
android:background="@drawable/category_listitem_background"
|
||||
android:gravity="center"
|
||||
android:textSize="28dp"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="@color/white"/>
|
||||
android:src="@mipmap/ic_launcher"/>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="10dp"
|
||||
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="middle"
|
||||
android:textColor="@color/text_color"
|
||||
android:textSize="@dimen/two_line_primary_text_size"
|
||||
android:ellipsize="end"
|
||||
tools:text="@tools:sample/lorem/random">
|
||||
</TextView>
|
||||
|
||||
<LinearLayout
|
||||
<TextView
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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>
|
||||
android:layout_marginTop="5dp"
|
||||
android:textSize="@dimen/note_font_size_item_content"
|
||||
android:maxLines="2"
|
||||
android:gravity="center_vertical"
|
||||
tools:text="@tools:sample/lorem/random">
|
||||
</TextView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/geofav_nav_bt"
|
||||
android:id="@+id/geofav_share_bt"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
android:padding="8dp"
|
||||
android:src="@drawable/ic_nav"
|
||||
android:tint="@color/secondary_text_color" /> <!-- TODO: app:tint is not working -->
|
||||
android:padding="10dp"
|
||||
android:src="@drawable/ic_share"
|
||||
android:tint="@color/list_text" /> <!-- 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="8dp"
|
||||
android:padding="10dp"
|
||||
android:src="@drawable/ic_more"
|
||||
android:tint="@color/secondary_text_color" /> <!-- TODO: app:tint is not working -->
|
||||
android:tint="@color/list_text" /> <!-- TODO: app:tint is not working -->
|
||||
|
||||
</LinearLayout>
|
@ -111,77 +111,6 @@
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/standard_half_margin">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/sortByCategoryAscending"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@color/transparent"
|
||||
android:paddingStart="@dimen/standard_padding"
|
||||
android:paddingTop="@dimen/standard_half_padding"
|
||||
android:paddingEnd="@dimen/standard_half_padding"
|
||||
android:paddingBottom="@dimen/standard_half_padding"
|
||||
android:contentDescription="@string/menu_item_sort_by_category_a_z"
|
||||
android:src="@drawable/ic_category_asc"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sortByCategoryAscendingText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="middle"
|
||||
android:paddingStart="@dimen/zero"
|
||||
android:paddingTop="@dimen/standard_half_padding"
|
||||
android:paddingEnd="@dimen/standard_half_padding"
|
||||
android:paddingBottom="@dimen/standard_half_padding"
|
||||
android:singleLine="true"
|
||||
android:text="@string/menu_item_sort_by_category_a_z"
|
||||
android:textSize="@dimen/two_line_primary_text_size" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/standard_half_margin"
|
||||
android:visibility="gone"> <!-- TODO: complete sorting by distance -->
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/sortByDistanceAscending"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@color/transparent"
|
||||
android:paddingStart="@dimen/standard_padding"
|
||||
android:paddingTop="@dimen/standard_half_padding"
|
||||
android:paddingEnd="@dimen/standard_half_padding"
|
||||
android:paddingBottom="@dimen/standard_half_padding"
|
||||
android:contentDescription="@string/menu_item_sort_by_distance_nearest_first"
|
||||
android:src="@drawable/ic_distance_asc"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sortByDistanceAscendingText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="middle"
|
||||
android:paddingStart="@dimen/zero"
|
||||
android:paddingTop="@dimen/standard_half_padding"
|
||||
android:paddingEnd="@dimen/standard_half_padding"
|
||||
android:paddingBottom="@dimen/standard_half_padding"
|
||||
android:singleLine="true"
|
||||
android:text="@string/menu_item_sort_by_distance_nearest_first"
|
||||
android:textSize="@dimen/two_line_primary_text_size" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
@ -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">
|
||||
<!-- Share button -->
|
||||
<!-- Detail button -->
|
||||
<item
|
||||
android:id="@+id/list_context_menu_share"
|
||||
android:title="@string/list_context_menu_share"/>
|
||||
android:id="@+id/list_context_menu_detail"
|
||||
android:title="@string/list_context_menu_detail"/>
|
||||
<!-- Delete button -->
|
||||
<item
|
||||
android:id="@+id/list_context_menu_delete"
|
||||
|
@ -27,8 +27,7 @@
|
||||
<color name="defaultTint">#202124</color>
|
||||
|
||||
<!-- List Colors -->
|
||||
<color name="text_color">#333333</color>
|
||||
<color name="secondary_text_color">#666666</color>
|
||||
<color name="list_text">#aaa</color>
|
||||
|
||||
<!-- Generic Colors -->
|
||||
<color name="white">#fff</color>
|
||||
|
@ -28,12 +28,14 @@
|
||||
<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>
|
||||
|
@ -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_share">Share</string>
|
||||
<string name="list_context_menu_detail">Details</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>
|
||||
@ -44,8 +44,7 @@
|
||||
<string name="sort_by">Sort by</string>
|
||||
<string name="menu_item_sort_by_title_a_z">A - Z</string>
|
||||
<string name="menu_item_sort_by_date_newest_first">Newest first</string>
|
||||
<string name="menu_item_sort_by_category_a_z">Category</string>
|
||||
<string name="menu_item_sort_by_distance_nearest_first">Distance</string>
|
||||
<string name="menu_item_sort_by_distance">Distance</string>
|
||||
|
||||
<!-- Geobookmarks detail -->
|
||||
<string name="name">Name</string>
|
||||
@ -58,9 +57,7 @@
|
||||
<string name="location_permission_required">Location permission is required to create a geofavorite.</string>
|
||||
<string name="confirm">Save</string>
|
||||
<string name="error_saving_geofavorite">Unable to save geofavorite</string>
|
||||
<string name="error_unsupported_uri">Unable to obtain coordinates from shared data</string>
|
||||
<string name="geofavorite_saved">Geofavorite saved</string>
|
||||
<string name="incomplete_geofavorite">Incomplete geofavorite: Name and category are mandatory</string>
|
||||
<string name="incomplete_geofavorite">Incomplete geofavorite: Name and GPS coordinates are mandatory</string>
|
||||
|
||||
<!-- About -->
|
||||
<string name="about_version_title">Version</string>
|
||||
@ -69,8 +66,6 @@
|
||||
<string name="about_source">This project is hosted on GitHub: <a href="%1$s">%1$s</a></string>
|
||||
<string name="about_issues_title">Issues</string>
|
||||
<string name="about_issues">You can report bugs, enhancement proposals and feature requests at the GitHub issue tracker: <a href="%1$s">%1$s</a></string>
|
||||
<string name="about_maps_title">Maps</string>
|
||||
<string name="about_maps">This app uses Open Street Maps tiles and servers to display the map. I do not accept any donation for this app, but strongly encourage to make any donation to <a href="%1$s">OpenStreetMap</a>, as this application could not exist without them.</string>
|
||||
<string name="about_app_license_title">App license</string>
|
||||
<string name="about_app_license">This application is licensed under the GNU GENERAL PUBLIC LICENSE v3+.</string>
|
||||
<string name="about_app_license_button">View license</string>
|
||||
@ -81,12 +76,10 @@
|
||||
|
||||
<!-- URLs -->
|
||||
<string name="url_source" translatable="false">https://github.com/penguin86/nextcloud-maps-client</string>
|
||||
<string name="url_issues" translatable="false">https://github.com/penguin86/nextcloud-maps-client/issues</string>
|
||||
<string name="url_issues" translatable="false">https://github.com/penguin86/nextcloud-maps-client/issues/new/choose</string>
|
||||
<string name="url_license" translatable="false">https://raw.githubusercontent.com/penguin86/nextcloud-maps-client/master/LICENSE</string>
|
||||
<string name="url_maps" translatable="false">https://donate.openstreetmap.org</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="setting_sort_by">SETTING_SORT_BY</string>
|
||||
<string name="setting_grid_view_enabled">SETTING_GRID_VIEW_ENABLED</string>
|
||||
|
||||
</resources>
|
||||
|
@ -20,7 +20,6 @@
|
||||
<style name="BaseTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/primary</item>
|
||||
<!-- <item name="android:textColorPrimary">@color/white</item>-->
|
||||
<item name="colorPrimaryDark">@color/primary</item>
|
||||
<item name="colorAccent">@color/accent</item>
|
||||
<item name="android:actionModeBackground">?attr/colorPrimary</item>
|
||||
@ -49,15 +48,4 @@
|
||||
<item name="android:background">?attr/colorPrimary</item>
|
||||
</style>
|
||||
|
||||
<!-- Geofavorite detail text appearances -->
|
||||
|
||||
<style name="TextAppearance.GeofavoriteDetail.Header.Expanded" parent="TextAppearance.Design.CollapsingToolbar.Expanded">
|
||||
<item name="android:textSize">36sp</item>
|
||||
<item name="android:textColor">@color/defaultBrand</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.GeofavoriteDetail.Header.Collapsed" parent="TextAppearance.AppCompat.Title">
|
||||
<item name="android:textColor">@color/white</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
@ -1 +0,0 @@
|
||||
Added geofavorite detail and deletion
|
@ -1 +0,0 @@
|
||||
Added map in geofavorite detail
|
@ -1 +0,0 @@
|
||||
First categories implementation
|
@ -1 +0,0 @@
|
||||
Fixed bug when opening newly-created element
|
@ -1,9 +1,3 @@
|
||||
UNOFFICIAL and FOSS Nextcloud Maps client at its earliest stages of developement. Shows your Nextcloud Maps geobookmarks list.
|
||||
Geobookmarks can be opened in all apps supporting geo links (i.e. Google Maps, Organic Maps etc...).
|
||||
A new geobookmark can be created on current location or by sharing a geo: uri from another app.
|
||||
|
||||
Shows your Nextcloud Maps geobookmarks list. Geobookmarks can be opened in all apps supporting geo links (i.e. Google Maps, Organic Maps etc...).
|
||||
A new geobookmark can be created on current location.
|
||||
Requires Maps app to be installed on the Nextcloud instance.
|
||||
As per Nextcloud's guidelines, the login is implemented using Nextcloud's Single Sign On module and thus requires Nextcloud app installed.
|
||||
|
||||
Promo banner by Gasteaud, Public domain, via Wikimedia Commons.
|
||||
|
||||
|
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 57 KiB |
@ -1 +1 @@
|
||||
Manage Nextcloud Maps Geobookmarks on your phone
|
||||
Manage Nextcloud Maps Geobookmarks on your Android phone
|
||||
|
Before Width: | Height: | Size: 132 KiB |
Before Width: | Height: | Size: 113 KiB |
Before Width: | Height: | Size: 132 KiB |
Before Width: | Height: | Size: 119 KiB |