WIP refactoring geofavorites list activity into fragment
This commit is contained in:
		
							
								
								
									
										2
									
								
								.idea/compiler.xml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.idea/compiler.xml
									
									
									
										generated
									
									
									
								
							| @@ -1,6 +1,6 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <project version="4"> | ||||
|   <component name="CompilerConfiguration"> | ||||
|     <bytecodeTargetLevel target="11" /> | ||||
|     <bytecodeTargetLevel target="1.8" /> | ||||
|   </component> | ||||
| </project> | ||||
							
								
								
									
										7
									
								
								.idea/misc.xml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										7
									
								
								.idea/misc.xml
									
									
									
										generated
									
									
									
								
							| @@ -4,15 +4,16 @@ | ||||
|     <option name="filePathToZoomLevelMap"> | ||||
|       <map> | ||||
|         <entry key="../../../../layout/custom_preview.xml" value="0.5661458333333333" /> | ||||
|         <entry key="app/src/main/res/drawable/ic_map_pin.xml" value="0.6425925925925926" /> | ||||
|         <entry key="app/src/main/res/layout/activity_geofavorite_detail.xml" value="0.4" /> | ||||
|         <entry key="app/src/main/res/layout/activity_list_view.xml" value="0.5307291666666667" /> | ||||
|         <entry key="app/src/main/res/layout/activity_main.xml" value="0.5307291666666667" /> | ||||
|         <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/menu/list_context_menu.xml" value="0.41944444444444445" /> | ||||
|       </map> | ||||
|     </option> | ||||
|   </component> | ||||
|   <component name="ExternalStorageConfigurationManager" enabled="true" /> | ||||
|   <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK" /> | ||||
|   <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="11" project-jdk-type="JavaSDK" /> | ||||
| </project> | ||||
| @@ -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' | ||||
|   | ||||
| @@ -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(); | ||||
|  | ||||
| } | ||||
| @@ -33,6 +33,7 @@ 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.preference.PreferenceManager; | ||||
| @@ -61,7 +62,7 @@ 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; | ||||
|  | ||||
| public class MainActivity extends AppCompatActivity implements MainView, OnSortingOrderListener { | ||||
| public class MainActivity extends AppCompatActivity implements MainView, GeofavoriteActivity { | ||||
|  | ||||
|     private static final int INTENT_ADD = 100; | ||||
|     private static final int INTENT_EDIT = 200; | ||||
| @@ -72,20 +73,13 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti | ||||
|     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 MainPresenter presenter; | ||||
|     private GeofavoriteAdapter geofavoriteAdapter; | ||||
|     private ItemClickListener rvItemClickListener; | ||||
|  | ||||
|     NavigationAdapter navigationCommonAdapter; | ||||
|  | ||||
| @@ -94,56 +88,8 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti | ||||
|         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); | ||||
|  | ||||
|         presenter = new MainPresenter(this); | ||||
|  | ||||
|         rvItemClickListener = new 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) { | ||||
|                 showGeofavoriteDetailActivity(item); | ||||
|             } | ||||
|  | ||||
|             @Override | ||||
|             public void onItemDeleteClick(Geofavorite item) { | ||||
|                 showGeofavoriteDeteleDialog(item); | ||||
|             } | ||||
|         }; | ||||
|  | ||||
|         geofavoriteAdapter = new GeofavoriteAdapter(getApplicationContext(), rvItemClickListener); | ||||
|         recyclerView.setAdapter(geofavoriteAdapter); | ||||
|         geofavoriteAdapter.setSortRule(sortRule); | ||||
|  | ||||
|         swipeRefresh = findViewById(R.id.swipe_refresh); | ||||
|         swipeRefresh.setOnRefreshListener(() -> presenter.getGeofavorites()); | ||||
|  | ||||
|         fab = findViewById(R.id.add); | ||||
|         fab.setOnClickListener(view -> addGeofavorite()); | ||||
|  | ||||
| @@ -184,14 +130,7 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti | ||||
|         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 | ||||
| @@ -271,24 +210,24 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti | ||||
|  | ||||
|     @Override | ||||
|     public void showLoading() { | ||||
|         swipeRefresh.setRefreshing(true); | ||||
|         //todo notify GeofavoriteListConsumer.geoFavoriteLoading(true) | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void hideLoading() { | ||||
|         swipeRefresh.setRefreshing(false); | ||||
|         //todo notify GeofavoriteListConsumer.geoFavoriteLoading(false) | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void onGetResult(List<Geofavorite> geofavorite_list) { | ||||
|         geofavoriteAdapter.setGeofavoriteList(geofavorite_list); | ||||
|         //todo notify GeofavoriteListConsumer | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void onGeofavoriteDeleted(int id) { | ||||
|         // Update list | ||||
|         // Notify fragment | ||||
|         runOnUiThread(() -> { | ||||
|             geofavoriteAdapter.removeById(id); | ||||
|             //todo notify GeofavoriteListConsumer | ||||
|             Toast.makeText(MainActivity.this, R.string.list_geofavorite_deleted, Toast.LENGTH_LONG).show(); | ||||
|         }); | ||||
|     } | ||||
| @@ -300,38 +239,7 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti | ||||
|     } | ||||
|  | ||||
|     @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) { | ||||
|         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; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public void onGridIconChosen(boolean gridEnabled) { | ||||
|         layoutManager.setSpanCount(gridEnabled ? 2 : 1); | ||||
|         updateGridIcon(gridEnabled); | ||||
|  | ||||
|         preferences.edit().putBoolean(getString(R.string.setting_grid_view_enabled), gridEnabled).apply(); | ||||
|     } | ||||
|  | ||||
|     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); | ||||
|     } | ||||
|  | ||||
|     private void showGeofavoriteDeteleDialog(Geofavorite item) { | ||||
|     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) | ||||
| @@ -351,10 +259,22 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti | ||||
|         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); | ||||
|         startActivity(i); | ||||
|     } | ||||
|  | ||||
|  | ||||
| } | ||||
| @@ -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 { | ||||
|  | ||||
| } | ||||
| @@ -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> | ||||
| @@ -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
									
								
							
							
						
						
									
										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
									
								
							
							
						
						
									
										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> | ||||
| @@ -81,6 +81,5 @@ | ||||
|  | ||||
|     <!-- Settings --> | ||||
|     <string name="setting_sort_by">SETTING_SORT_BY</string> | ||||
|     <string name="setting_grid_view_enabled">SETTING_GRID_VIEW_ENABLED</string> | ||||
|  | ||||
| </resources> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user