WIP adding geofavorite map fragment
This commit is contained in:
		@@ -56,6 +56,7 @@ import it.danieleverducci.nextcloudmaps.activity.main.SortingOrderDialogFragment
 | 
				
			|||||||
import it.danieleverducci.nextcloudmaps.activity.mappicker.MapPickerActivity;
 | 
					import it.danieleverducci.nextcloudmaps.activity.mappicker.MapPickerActivity;
 | 
				
			||||||
import it.danieleverducci.nextcloudmaps.api.ApiProvider;
 | 
					import it.danieleverducci.nextcloudmaps.api.ApiProvider;
 | 
				
			||||||
import it.danieleverducci.nextcloudmaps.fragments.GeofavoriteListFragment;
 | 
					import it.danieleverducci.nextcloudmaps.fragments.GeofavoriteListFragment;
 | 
				
			||||||
 | 
					import it.danieleverducci.nextcloudmaps.fragments.GeofavoriteMapFragment;
 | 
				
			||||||
import it.danieleverducci.nextcloudmaps.fragments.GeofavoritesFragment;
 | 
					import it.danieleverducci.nextcloudmaps.fragments.GeofavoritesFragment;
 | 
				
			||||||
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
 | 
					import it.danieleverducci.nextcloudmaps.model.Geofavorite;
 | 
				
			||||||
import it.danieleverducci.nextcloudmaps.utils.SettingsManager;
 | 
					import it.danieleverducci.nextcloudmaps.utils.SettingsManager;
 | 
				
			||||||
@@ -87,6 +88,14 @@ public class MainActivity extends NextcloudMapsStyledActivity {
 | 
				
			|||||||
        drawerLayout.openDrawer(GravityCompat.START);
 | 
					        drawerLayout.openDrawer(GravityCompat.START);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void showMap() {
 | 
				
			||||||
 | 
					        replaceFragment(new GeofavoriteMapFragment());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void showList() {
 | 
				
			||||||
 | 
					        replaceFragment(new GeofavoriteListFragment());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void onCreate(Bundle savedInstanceState) {
 | 
					    protected void onCreate(Bundle savedInstanceState) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -94,15 +103,10 @@ public class MainActivity extends NextcloudMapsStyledActivity {
 | 
				
			|||||||
        setContentView(R.layout.activity_main);
 | 
					        setContentView(R.layout.activity_main);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        boolean showMap = SettingsManager.isGeofavoriteListShownAsMap(this);
 | 
					        boolean showMap = SettingsManager.isGeofavoriteListShownAsMap(this);
 | 
				
			||||||
        if (showMap) {
 | 
					        if (showMap)
 | 
				
			||||||
            // TODO: Map fragment
 | 
					            showMap();
 | 
				
			||||||
        } else {
 | 
					        else
 | 
				
			||||||
            Fragment fragment = new GeofavoriteListFragment();
 | 
					            showList();
 | 
				
			||||||
            FragmentManager manager = getSupportFragmentManager();
 | 
					 | 
				
			||||||
            FragmentTransaction transaction = manager.beginTransaction();
 | 
					 | 
				
			||||||
            transaction.replace(R.id.fragment_container, fragment);
 | 
					 | 
				
			||||||
            transaction.commit();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        FloatingActionButton fab = findViewById(R.id.open_fab);
 | 
					        FloatingActionButton fab = findViewById(R.id.open_fab);
 | 
				
			||||||
        fab.setOnClickListener(view -> openFab(!this.isFabOpen));
 | 
					        fab.setOnClickListener(view -> openFab(!this.isFabOpen));
 | 
				
			||||||
@@ -124,6 +128,13 @@ public class MainActivity extends NextcloudMapsStyledActivity {
 | 
				
			|||||||
        super.onPause();
 | 
					        super.onPause();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void replaceFragment(Fragment fragment) {
 | 
				
			||||||
 | 
					        FragmentManager manager = getSupportFragmentManager();
 | 
				
			||||||
 | 
					        FragmentTransaction transaction = manager.beginTransaction();
 | 
				
			||||||
 | 
					        transaction.replace(R.id.fragment_container, fragment);
 | 
				
			||||||
 | 
					        transaction.commit();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void setupNavigationMenu() {
 | 
					    private void setupNavigationMenu() {
 | 
				
			||||||
        ArrayList<NavigationItem> navItems = new ArrayList<>();
 | 
					        ArrayList<NavigationItem> navItems = new ArrayList<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -147,6 +147,9 @@ public class GeofavoriteListFragment extends GeofavoritesFragment implements Sor
 | 
				
			|||||||
        AppCompatImageView sortButton = v.findViewById(R.id.sort_mode);
 | 
					        AppCompatImageView sortButton = v.findViewById(R.id.sort_mode);
 | 
				
			||||||
        sortButton.setOnClickListener(view -> openSortingOrderDialogFragment(geofavoriteAdapter.getSortRule()));
 | 
					        sortButton.setOnClickListener(view -> openSortingOrderDialogFragment(geofavoriteAdapter.getSortRule()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        View showMapButton = v.findViewById(R.id.view_mode_map);
 | 
				
			||||||
 | 
					        showMapButton.setOnClickListener(View -> ((MainActivity)requireActivity()).showMap());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return v;
 | 
					        return v;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,33 @@
 | 
				
			|||||||
 | 
					package it.danieleverducci.nextcloudmaps.fragments;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.view.LayoutInflater;
 | 
				
			||||||
 | 
					import android.view.View;
 | 
				
			||||||
 | 
					import android.view.ViewGroup;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import androidx.annotation.NonNull;
 | 
				
			||||||
 | 
					import androidx.annotation.Nullable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import it.danieleverducci.nextcloudmaps.R;
 | 
				
			||||||
 | 
					import it.danieleverducci.nextcloudmaps.activity.main.MainActivity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class GeofavoriteMapFragment extends GeofavoritesFragment {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nullable
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
 | 
				
			||||||
 | 
					        View v = inflater.inflate(R.layout.fragment_geofavorite_map, container, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Setup view listeners
 | 
				
			||||||
 | 
					        View showListButton = v.findViewById(R.id.view_mode_list);
 | 
				
			||||||
 | 
					        showListButton.setOnClickListener(View -> ((MainActivity)requireActivity()).showMap());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return v;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onSearch(String query) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -15,7 +15,6 @@
 | 
				
			|||||||
        app:elevation="0dp">
 | 
					        app:elevation="0dp">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <com.google.android.material.appbar.CollapsingToolbarLayout
 | 
					        <com.google.android.material.appbar.CollapsingToolbarLayout
 | 
				
			||||||
            android:id="@+id/toolbar_layout"
 | 
					 | 
				
			||||||
            android:layout_width="match_parent"
 | 
					            android:layout_width="match_parent"
 | 
				
			||||||
            android:layout_height="wrap_content"
 | 
					            android:layout_height="wrap_content"
 | 
				
			||||||
            android:fitsSystemWindows="true"
 | 
					            android:fitsSystemWindows="true"
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										47
									
								
								app/src/main/res/layout/fragment_geofavorite_map.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								app/src/main/res/layout/fragment_geofavorite_map.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,47 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<FrameLayout
 | 
				
			||||||
 | 
					    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: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"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <androidx.appcompat.widget.LinearLayoutCompat
 | 
				
			||||||
 | 
					        android:id="@+id/appBar"
 | 
				
			||||||
 | 
					        android:layout_width="match_parent"
 | 
				
			||||||
 | 
					        android:layout_height="wrap_content"
 | 
				
			||||||
 | 
					        app:elevation="0dp"
 | 
				
			||||||
 | 
					        android:orientation="vertical">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <include layout="@layout/app_toolbar"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <RelativeLayout
 | 
				
			||||||
 | 
					            android:layout_width="match_parent"
 | 
				
			||||||
 | 
					            android:layout_height="wrap_content"
 | 
				
			||||||
 | 
					            android:orientation="horizontal"
 | 
				
			||||||
 | 
					            android:paddingTop="10dp">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <androidx.appcompat.widget.AppCompatImageView
 | 
				
			||||||
 | 
					                android:id="@+id/view_mode_list"
 | 
				
			||||||
 | 
					                android:layout_width="wrap_content"
 | 
				
			||||||
 | 
					                android:layout_height="@dimen/floating_bar_height"
 | 
				
			||||||
 | 
					                android:layout_alignParentRight="true"
 | 
				
			||||||
 | 
					                android:background="?android:attr/selectableItemBackgroundBorderless"
 | 
				
			||||||
 | 
					                android:contentDescription="@string/list_mode"
 | 
				
			||||||
 | 
					                android:paddingStart="@dimen/spacer_2x"
 | 
				
			||||||
 | 
					                android:paddingEnd="@dimen/spacer_2x"
 | 
				
			||||||
 | 
					                android:tint="@color/text_color"
 | 
				
			||||||
 | 
					                android:src="@drawable/ic_view_list" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        </RelativeLayout>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    </androidx.appcompat.widget.LinearLayoutCompat>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</FrameLayout>
 | 
				
			||||||
		Reference in New Issue
	
	Block a user