7171import com .google .android .gms .maps .GoogleMap .OnMapLongClickListener ;
7272import com .google .android .gms .maps .GoogleMap .OnMarkerClickListener ;
7373import com .google .android .gms .maps .GoogleMap .OnMarkerDragListener ;
74+ import com .google .android .gms .maps .MapView ;
75+ import com .google .android .gms .maps .MapsInitializer ;
7476import com .google .android .gms .maps .OnMapReadyCallback ;
7577import com .google .android .gms .maps .Projection ;
7678import com .google .android .gms .maps .SupportMapFragment ;
@@ -726,7 +728,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
726728 view = inflater .inflate (R .layout .fragment_map , container , false );
727729 getMapFragment ().getMapAsync (this );
728730
729-
730731 touch = new TouchableMap (getActivity ());
731732 touch .addView (view );
732733
@@ -756,6 +757,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
756757 // Show disclaimer
757758 showDisclaimer ();
758759
760+ // Draw a transparent box. used for downloading a new tile layer
761+ // NOTE: This view is invisible by default
762+ transBox = getLayoutInflater ().inflate (R .layout .transparent_box_view , null );
763+
759764 return touch ;
760765 }
761766
@@ -2055,60 +2060,47 @@ public void onClick(View v) {
20552060 * @param url url to get the tiles from
20562061 */
20572062 private void drawTileBoundingBox (String geopackageName , String layerName , String url ){
2058- layerFab .hide ();
2059- setZoomLevelVisible (true );
2060- // shrink bottom sheet
2063+ // prepare the screen by shrinking bottom sheet, hide fab, show zoom level
20612064 BottomSheetBehavior behavior = BottomSheetBehavior .from (geoPackageRecycler );
20622065 behavior .setState (BottomSheetBehavior .STATE_COLLAPSED );
2066+ layerFab .hide ();
2067+ setZoomLevelVisible (true );
20632068
2064- // Draw a default bounding box (make sure start and end corner are currently set
2065- transBox = getLayoutInflater (). inflate ( R . layout . transparent_box_view , null );
2069+ // Make sure the transparent box is visible, and add it to the mapview
2070+ transBox . setVisibility ( View . VISIBLE );
20662071 touch .addView (transBox );
20672072
2068- // show message for how to draw the box
2069- final Snackbar snackBar = Snackbar .make (transBox , R .string .draw_layer_instruction , Snackbar .LENGTH_INDEFINITE );
2070- View view = snackBar .getView ();
2071-
2072- // Snackbar click listeners close by default every time. Instead, give an empty click listener
2073- // and use a callback to determine if they've drawn a bounding box first
2074- snackBar .setAction ("Continue" , new View .OnClickListener () {
2073+ // Cancel
2074+ Button cancelTile = (Button )transBox .findViewById (R .id .tile_area_select_cancel );
2075+ cancelTile .setOnClickListener (new View .OnClickListener () {
20752076 @ Override
2076- public void onClick (View v ) {}
2077+ public void onClick (View view ) {
2078+ // Remove transparent box and show the floating action button again
2079+ touch .removeView (transBox );
2080+ layerFab .show ();
2081+ }
20772082 });
2078- snackBar .addCallback (new BaseTransientBottomBar .BaseCallback <Snackbar >() {
2079- @ Override
2080- public void onShown (Snackbar transientBottomBar ) {
2081- super .onShown (transientBottomBar );
2082- transientBottomBar .getView ().findViewById (R .id .snackbar_action ).setOnClickListener (new View .OnClickListener () {
2083- @ Override
2084- public void onClick (View v ) {
2085- View transBoxView = (View ) transBox .findViewById (R .id .transparent_measurement );
2086- Point point = new Point (transBoxView .getLeft (), transBoxView .getTop ());
2087- boundingBoxStartCorner = map .getProjection ().fromScreenLocation (point );
20882083
2089- Point endPoint = new Point (transBoxView .getRight (), transBoxView .getBottom ());
2090- boundingBoxEndCorner = map .getProjection ().fromScreenLocation (endPoint );
2091-
2092- boolean drawBoundingBox = drawBoundingBox ();
2093-
2094- if (!isZoomLevelVisible ()) {
2095- setZoomLevelVisible (false );
2096- }
2097- snackBar .dismiss ();
2098- layerFab .show ();
2099- touch .removeView (transBox );
2100- // continue to create layer
2101- createTileFinal (geopackageName , layerName , url );
2102- }
2103- });
2084+ // Next
2085+ Button tileDrawNext = (Button )transBox .findViewById (R .id .tile_area_select_next );
2086+ tileDrawNext .setOnClickListener (new View .OnClickListener () {
2087+ @ Override
2088+ public void onClick (View view ) {
2089+ View transBoxView = (View ) transBox .findViewById (R .id .transparent_measurement );
2090+ Point point = new Point (transBoxView .getLeft (), transBoxView .getTop ());
2091+ boundingBoxStartCorner = map .getProjection ().fromScreenLocation (point );
2092+ Point endPoint = new Point (transBoxView .getRight (), transBoxView .getBottom ());
2093+ boundingBoxEndCorner = map .getProjection ().fromScreenLocation (endPoint );
2094+ boolean drawBoundingBox = drawBoundingBox ();
2095+ if (!isZoomLevelVisible ()) {
2096+ setZoomLevelVisible (false );
2097+ }
2098+ layerFab .show ();
2099+ touch .removeView (transBox );
2100+ // continue to create layer
2101+ createTileFinal (geopackageName , layerName , url );
21042102 }
21052103 });
2106-
2107- Snackbar .SnackbarLayout layout = (Snackbar .SnackbarLayout )snackBar .getView ();
2108- layout .setMinimumHeight (300 );
2109- snackBar .show ();
2110- behavior .setState (BottomSheetBehavior .STATE_COLLAPSED );
2111-
21122104 }
21132105
21142106
@@ -2138,8 +2130,6 @@ private void createTileFinal(String geopackageName, String layerName, String url
21382130 maxSpinner .setSelection (maxAdapter .getPosition ("5" ));
21392131
21402132 // Name and url
2141- // TextView finalGeoName = (TextView) tileView.findViewById(R.id.final_geo_name);
2142- // finalGeoName.setText(geopackageName);
21432133 TextView finalName = (TextView ) tileView .findViewById (R .id .final_tile_name );
21442134 finalName .setText (layerName );
21452135 TextView finalUrl = (TextView ) tileView .findViewById (R .id .final_tile_url );
@@ -2157,13 +2147,12 @@ private void createTileFinal(String geopackageName, String layerName, String url
21572147 RadioGroup srsGroup = (RadioGroup ) tileView .findViewById (R .id .srsGroup );
21582148 RadioGroup tileFormatGroup = (RadioGroup ) tileView .findViewById (R .id .tileFormatGroup );
21592149
2160-
21612150 // Open the dialog
21622151 AlertDialog .Builder dialog = new AlertDialog .Builder (getActivity (), R .style .AppCompatAlertDialogStyle )
21632152 .setView (tileView );
21642153 final AlertDialog alertDialog = dialog .create ();
21652154
2166- // Click listener for close button
2155+ // close button
21672156 closeLogo .setOnClickListener (new View .OnClickListener (){
21682157 @ Override
21692158 public void onClick (View v ) {
@@ -2173,7 +2162,7 @@ public void onClick(View v) {
21732162 }
21742163 });
21752164
2176- // Click listener for finish button
2165+ // finish button
21772166 drawButton .setOnClickListener (new View .OnClickListener (){
21782167 @ Override
21792168 public void onClick (View v ) {
@@ -2793,8 +2782,6 @@ public void onMapLoaded() {
27932782 }
27942783 });
27952784
2796- // For some reason on start, the map has zoom level set to 2. But it's actually at 3.
2797- // Just set it to 3 off the bat
27982785 map .moveCamera (CameraUpdateFactory .zoomTo (3 ));
27992786
28002787 // Keep track of the current zoom level
0 commit comments