Created empty map pick activity, added FAB actions
This commit is contained in:
parent
8f054dd324
commit
90c4b998e7
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="1.8" />
|
||||
<bytecodeTargetLevel target="11" />
|
||||
</component>
|
||||
</project>
|
@ -13,6 +13,7 @@
|
||||
<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_map_picker.xml" value="0.3453125" />
|
||||
<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" />
|
||||
@ -20,5 +21,5 @@
|
||||
</option>
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="11" project-jdk-type="JavaSDK" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK" />
|
||||
</project>
|
@ -60,6 +60,40 @@
|
||||
|
||||
<data android:scheme="geo"/>
|
||||
</intent-filter>
|
||||
|
||||
<!-- Google Maps -->
|
||||
<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="google.navigation"/>
|
||||
</intent-filter>
|
||||
|
||||
<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:host="maps.google.com"
|
||||
android:scheme="https"/>
|
||||
</intent-filter>
|
||||
|
||||
<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:host="maps.google.com"
|
||||
android:scheme="http"/>
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
|
||||
<activity android:name=".activity.mappicker.MapPickerActivity"
|
||||
android:theme="@style/AppTheme">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
|
@ -27,7 +27,6 @@ import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
@ -50,22 +49,14 @@ 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.BuildConfig;
|
||||
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;
|
||||
|
||||
public class GeofavoriteDetailActivity extends AppCompatActivity implements LocationListener, ActivityCompat.OnRequestPermissionsResultCallback {
|
||||
|
||||
|
@ -23,6 +23,7 @@ import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@ -55,6 +56,7 @@ import it.danieleverducci.nextcloudmaps.activity.detail.GeofavoriteDetailActivit
|
||||
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.activity.mappicker.MapPickerActivity;
|
||||
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||
import it.danieleverducci.nextcloudmaps.utils.GeoUriParser;
|
||||
import it.danieleverducci.nextcloudmaps.utils.IntentGenerator;
|
||||
@ -70,7 +72,8 @@ public class MainActivity extends AppCompatActivity implements OnSortingOrderLis
|
||||
|
||||
private static final String TAG = "MainActivity";
|
||||
|
||||
private static final String NAVIGATION_KEY_ADD_GEOFAVORITE = "add";
|
||||
private static final String NAVIGATION_KEY_ADD_GEOFAVORITE_FROM_GPS = "add_from_gps";
|
||||
private static final String NAVIGATION_KEY_ADD_GEOFAVORITE_FROM_MAP = "add_from_map";
|
||||
private static final String NAVIGATION_KEY_SHOW_ABOUT = "about";
|
||||
private static final String NAVIGATION_KEY_SWITCH_ACCOUNT = "switch_account";
|
||||
|
||||
@ -89,6 +92,8 @@ public class MainActivity extends AppCompatActivity implements OnSortingOrderLis
|
||||
private ItemClickListener rvItemClickListener;
|
||||
private MainActivityViewModel mMainActivityViewModel;
|
||||
|
||||
private boolean isFabOpen = false;
|
||||
|
||||
NavigationAdapter navigationCommonAdapter;
|
||||
|
||||
@Override
|
||||
@ -165,8 +170,14 @@ public class MainActivity extends AppCompatActivity implements OnSortingOrderLis
|
||||
swipeRefresh.setOnRefreshListener(() ->
|
||||
mMainActivityViewModel.updateGeofavorites());
|
||||
|
||||
fab = findViewById(R.id.add);
|
||||
fab.setOnClickListener(view -> addGeofavorite());
|
||||
fab = findViewById(R.id.open_fab);
|
||||
fab.setOnClickListener(view -> openFab(!this.isFabOpen));
|
||||
|
||||
fab = findViewById(R.id.add_from_gps);
|
||||
fab.setOnClickListener(view -> addGeofavoriteFromGps());
|
||||
|
||||
fab = findViewById(R.id.add_from_map);
|
||||
fab.setOnClickListener(view -> addGeofavoriteFromMap());
|
||||
|
||||
toolbar = findViewById(R.id.toolbar);
|
||||
homeToolbar = findViewById(R.id.home_toolbar);
|
||||
@ -215,13 +226,22 @@ public class MainActivity extends AppCompatActivity implements OnSortingOrderLis
|
||||
updateGridIcon(gridViewEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
openFab(false);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
private void setupNavigationMenu() {
|
||||
ArrayList<NavigationItem> navItems = new ArrayList<>();
|
||||
|
||||
navigationCommonAdapter = new NavigationAdapter(this, item -> {
|
||||
switch (item.id) {
|
||||
case NAVIGATION_KEY_ADD_GEOFAVORITE:
|
||||
addGeofavorite();
|
||||
case NAVIGATION_KEY_ADD_GEOFAVORITE_FROM_GPS:
|
||||
addGeofavoriteFromGps();
|
||||
break;
|
||||
case NAVIGATION_KEY_ADD_GEOFAVORITE_FROM_MAP:
|
||||
addGeofavoriteFromMap();
|
||||
break;
|
||||
case NAVIGATION_KEY_SHOW_ABOUT:
|
||||
show_about();
|
||||
@ -232,7 +252,8 @@ public class MainActivity extends AppCompatActivity implements OnSortingOrderLis
|
||||
}
|
||||
});
|
||||
|
||||
navItems.add(new NavigationItem(NAVIGATION_KEY_ADD_GEOFAVORITE, getString(R.string.new_geobookmark), R.drawable.ic_add));
|
||||
navItems.add(new NavigationItem(NAVIGATION_KEY_ADD_GEOFAVORITE_FROM_GPS, getString(R.string.new_geobookmark_gps), R.drawable.ic_add_gps));
|
||||
navItems.add(new NavigationItem(NAVIGATION_KEY_ADD_GEOFAVORITE_FROM_MAP, getString(R.string.new_geobookmark_map), R.drawable.ic_add_map));
|
||||
navItems.add(new NavigationItem(NAVIGATION_KEY_SHOW_ABOUT, getString(R.string.about), R.drawable.ic_info_grey));
|
||||
navItems.add(new NavigationItem(NAVIGATION_KEY_SWITCH_ACCOUNT, getString(R.string.switch_account), R.drawable.ic_logout_grey));
|
||||
navigationCommonAdapter.setItems(navItems);
|
||||
@ -257,12 +278,18 @@ public class MainActivity extends AppCompatActivity implements OnSortingOrderLis
|
||||
SortingOrderDialogFragment.newInstance(sortOrder).show(fragmentTransaction, SortingOrderDialogFragment.SORTING_ORDER_FRAGMENT);
|
||||
}
|
||||
|
||||
private void addGeofavorite() {
|
||||
private void addGeofavoriteFromGps() {
|
||||
startActivity(
|
||||
new Intent(this, GeofavoriteDetailActivity.class)
|
||||
);
|
||||
}
|
||||
|
||||
private void addGeofavoriteFromMap() {
|
||||
startActivity(
|
||||
new Intent(this, MapPickerActivity.class)
|
||||
);
|
||||
}
|
||||
|
||||
private void show_about() {
|
||||
startActivity(new Intent(this, AboutActivity.class));
|
||||
}
|
||||
@ -336,4 +363,23 @@ public class MainActivity extends AppCompatActivity implements OnSortingOrderLis
|
||||
startActivity(i);
|
||||
}
|
||||
|
||||
private void openFab(boolean open) {
|
||||
View fab = findViewById(R.id.open_fab);
|
||||
View addFromGpsFab = findViewById(R.id.add_from_gps);
|
||||
View addFromMapFab = findViewById(R.id.add_from_map);
|
||||
|
||||
if (open) {
|
||||
this.isFabOpen = true;
|
||||
fab.animate().rotation(45.0f);
|
||||
addFromGpsFab.animate().translationY(-getResources().getDimension(R.dimen.fab_vertical_offset));
|
||||
addFromMapFab.animate().translationY(-getResources().getDimension(R.dimen.fab_vertical_offset) * 2);
|
||||
} else {
|
||||
this.isFabOpen = false;
|
||||
fab.animate().rotation(0f);
|
||||
addFromGpsFab.animate().translationY(0);
|
||||
addFromMapFab.animate().translationY(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package it.danieleverducci.nextcloudmaps.activity.mappicker;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import org.osmdroid.config.Configuration;
|
||||
import org.osmdroid.config.IConfigurationProvider;
|
||||
|
||||
import it.danieleverducci.nextcloudmaps.BuildConfig;
|
||||
import it.danieleverducci.nextcloudmaps.databinding.ActivityMapPickerBinding;
|
||||
|
||||
public class MapPickerActivity extends AppCompatActivity {
|
||||
public static final String TAG = "MapPickerActivity";
|
||||
private ViewHolder mViewHolder;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// OSMDroid config
|
||||
IConfigurationProvider osmdroidConfig = Configuration.getInstance();
|
||||
osmdroidConfig.load(getApplicationContext(),
|
||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()));
|
||||
osmdroidConfig.setUserAgentValue(BuildConfig.APPLICATION_ID);
|
||||
|
||||
mViewHolder = new MapPickerActivity.ViewHolder(getLayoutInflater());
|
||||
setContentView(mViewHolder.getRootView());
|
||||
}
|
||||
|
||||
private class ViewHolder implements View.OnClickListener {
|
||||
private final ActivityMapPickerBinding binding;
|
||||
|
||||
public ViewHolder(LayoutInflater inflater) {
|
||||
this.binding = ActivityMapPickerBinding.inflate(inflater);
|
||||
}
|
||||
|
||||
public View getRootView() {
|
||||
return this.binding.root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -2,6 +2,7 @@ package it.danieleverducci.nextcloudmaps.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import it.danieleverducci.nextcloudmaps.R;
|
||||
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||
|
16
app/src/main/res/drawable/ic_manual_pos.xml
Normal file
16
app/src/main/res/drawable/ic_manual_pos.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<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="M13.95,13H9V8.05l5.61,-5.61C13.78,2.16 12.9,2 12,2c-4.2,0 -8,3.22 -8,8.2c0,3.32 2.67,7.25 8,11.8c5.33,-4.55 8,-8.48 8,-11.8c0,-1.01 -0.16,-1.94 -0.45,-2.8L13.95,13z"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M11,11l2.12,0l6.16,-6.16l-2.12,-2.12l-6.16,6.16z"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M20.71,2L20,1.29C19.8,1.1 19.55,1 19.29,1c-0.13,0 -0.48,0.07 -0.71,0.29l-0.72,0.72l2.12,2.12l0.72,-0.72C21.1,3.02 21.1,2.39 20.71,2z"/>
|
||||
</vector>
|
10
app/src/main/res/drawable/ic_ok.xml
Normal file
10
app/src/main/res/drawable/ic_ok.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/>
|
||||
</vector>
|
@ -53,11 +53,23 @@
|
||||
android:id="@+id/back_bt"
|
||||
android:layout_width="?attr/actionBarSize"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:layout_gravity="start"
|
||||
android:padding="16dp"
|
||||
android:src="@drawable/ic_back_grey"
|
||||
app:tint="@color/white"
|
||||
android:background="@drawable/floating_semitransparent_button_background"/>
|
||||
|
||||
<!-- Manual position button -->
|
||||
<ImageView
|
||||
android:id="@+id/manual_pos_bt"
|
||||
android:layout_width="?attr/actionBarSize"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:layout_gravity="end"
|
||||
android:padding="16dp"
|
||||
android:src="@drawable/ic_manual_pos"
|
||||
app:tint="@color/white"
|
||||
android:background="@drawable/floating_semitransparent_button_background"/>
|
||||
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
|
||||
|
@ -154,8 +154,31 @@
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
<!-- Add from map FAB -->
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/add"
|
||||
android:id="@+id/add_from_map"
|
||||
android:layout_margin="24dp"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:fabSize="mini"
|
||||
android:src="@drawable/ic_add_map"
|
||||
app:backgroundTint="@color/defaultBrand"/>
|
||||
|
||||
<!-- Add from current position FAB -->
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/add_from_gps"
|
||||
android:layout_margin="24dp"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:fabSize="mini"
|
||||
android:src="@drawable/ic_add_gps"
|
||||
app:backgroundTint="@color/defaultBrand"/>
|
||||
|
||||
<!-- Main FAB -->
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/open_fab"
|
||||
android:layout_margin="16dp"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_width="wrap_content"
|
||||
|
60
app/src/main/res/layout/activity_map_picker.xml
Normal file
60
app/src/main/res/layout/activity_map_picker.xml
Normal file
@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto" >
|
||||
<FrameLayout
|
||||
android:id="@+id/root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<org.osmdroid.views.MapView
|
||||
android:id="@+id/map"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back_bt"
|
||||
android:layout_width="?attr/actionBarSize"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:layout_gravity="start"
|
||||
android:padding="16dp"
|
||||
android:src="@drawable/ic_back_grey"
|
||||
app:tint="@color/white"
|
||||
android:background="@drawable/floating_semitransparent_button_background"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ok_bt"
|
||||
android:layout_width="?attr/actionBarSize"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:layout_gravity="end"
|
||||
android:padding="16dp"
|
||||
android:src="@drawable/ic_ok"
|
||||
app:tint="@color/white"
|
||||
android:background="@drawable/floating_semitransparent_button_background"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:padding="20dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/lat_et"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:background="@color/whiteAlpha"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/lon_et"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@color/whiteAlpha"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</FrameLayout>
|
||||
</layout>
|
@ -32,4 +32,5 @@
|
||||
|
||||
<!-- Generic Colors -->
|
||||
<color name="white">#fff</color>
|
||||
<color name="whiteAlpha">#cfff</color>
|
||||
</resources>
|
@ -36,4 +36,7 @@
|
||||
<dimen name="two_line_primary_text_size">16sp</dimen>
|
||||
<dimen name="two_line_secondary_text_size">12sp</dimen>
|
||||
|
||||
<!-- FAB dimensions -->
|
||||
<dimen name="fab_vertical_offset">55dp</dimen>
|
||||
|
||||
</resources>
|
||||
|
@ -89,4 +89,8 @@
|
||||
<string name="setting_sort_by">SETTING_SORT_BY</string>
|
||||
<string name="setting_grid_view_enabled">SETTING_GRID_VIEW_ENABLED</string>
|
||||
|
||||
<!-- Menu -->
|
||||
<string name="new_geobookmark_gps">New from current position</string>
|
||||
<string name="new_geobookmark_map">New from map</string>
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user