diff options
author | Tobrun Van Nuland <tobrun.van.nuland@gmail.com> | 2016-07-26 16:59:04 +0200 |
---|---|---|
committer | Tobrun <tobrun.van.nuland@gmail.com> | 2016-08-03 14:53:23 -0400 |
commit | 9b871a9a0fcbbeb40cec07fc976cbdbaebf00856 (patch) | |
tree | a82b550f355320997e510a3bb07a0b7358dfe28a /platform/android | |
parent | 75a1a9697b7a6afd8bc76b07ec98c083893bf0a3 (diff) | |
download | qtlocation-mapboxgl-9b871a9a0fcbbeb40cec07fc976cbdbaebf00856.tar.gz |
[android] #5378 - NavDrawer rendering issues, added snackbar example
Diffstat (limited to 'platform/android')
3 files changed, 24 insertions, 52 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapview_internal.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapview_internal.xml index 38f6db22a3..2616724865 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapview_internal.xml +++ b/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapview_internal.xml @@ -9,7 +9,8 @@ <FrameLayout android:id="@+id/markerViewContainer" android:layout_width="match_parent" - android:layout_height="match_parent" /> + android:layout_height="match_parent" + android:background="@android:color/transparent"/> <com.mapbox.mapboxsdk.maps.widgets.CompassView android:id="@+id/compassView" diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/NavigationDrawerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/NavigationDrawerActivity.java index b7f6565cbe..baa4142489 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/NavigationDrawerActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/NavigationDrawerActivity.java @@ -8,6 +8,7 @@ import android.content.res.Configuration; import android.graphics.Color; import android.os.Bundle; import android.preference.PreferenceManager; +import android.support.design.widget.Snackbar; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarDrawerToggle; @@ -30,6 +31,8 @@ import com.mapbox.mapboxsdk.testapp.R; public class NavigationDrawerActivity extends AppCompatActivity { + private boolean firstStyle = true; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -53,35 +56,29 @@ public class NavigationDrawerActivity extends AppCompatActivity { public void onNavigationDrawerItemSelected(int position) { // update the main content by replacing fragments - MapboxMapOptions options = new MapboxMapOptions(); switch (position) { case 0: - options.styleUrl(Style.DARK); + MapboxMapOptions options = new MapboxMapOptions(); + options.styleUrl(firstStyle ? Style.LIGHT : Style.SATELLITE); options.camera(new CameraPosition.Builder() .target(new LatLng(39.913271, 116.413891)) .zoom(12) .build()); + FragmentManager fragmentManager = getFragmentManager(); + fragmentManager.beginTransaction() + .replace(R.id.container, MapFragment.newInstance(options)) + .commit(); + + firstStyle = !firstStyle; break; case 1: - options.styleUrl(Style.LIGHT); - options.camera(new CameraPosition.Builder() - .target(new LatLng(31.227831, 121.449076)) - .zoom(6) - .build()); - break; - case 2: - options.styleUrl(Style.SATELLITE); - options.camera(new CameraPosition.Builder() - .target(new LatLng(22.294297, 114.177891)) - .zoom(8) - .build()); + Snackbar.make( + findViewById(android.R.id.content), + "Hello from snackbar", + Snackbar.LENGTH_LONG) + .show(); break; } - - FragmentManager fragmentManager = getFragmentManager(); - fragmentManager.beginTransaction() - .replace(R.id.container, MapFragment.newInstance(options)) - .commit(); } public static class NavigationDrawerFragment extends Fragment { @@ -112,30 +109,6 @@ public class NavigationDrawerActivity extends AppCompatActivity { mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION); mFromSavedInstanceState = true; } - - mDrawerLayout.addDrawerListener(new DrawerLayout.DrawerListener() { - @Override - public void onDrawerSlide(View drawerView, float slideOffset) { - mDrawerLayout.bringChildToFront(drawerView); - mDrawerLayout.requestLayout(); - } - - @Override - public void onDrawerOpened(View drawerView) { - - } - - @Override - public void onDrawerClosed(View drawerView) { - - } - - @Override - public void onDrawerStateChanged(int newState) { - - } - }); - selectItem(mCurrentSelectedPosition); } @@ -162,8 +135,7 @@ public class NavigationDrawerActivity extends AppCompatActivity { android.R.id.text1, new String[]{ getString(R.string.title_section1), - getString(R.string.title_section2), - getString(R.string.title_section3), + getString(R.string.title_section2) })); mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return mDrawerListView; @@ -178,7 +150,7 @@ public class NavigationDrawerActivity extends AppCompatActivity { public void setUp(Activity activity, int fragmentId, DrawerLayout drawerLayout, ActionBar actionBar) { mFragmentContainerView = activity.findViewById(fragmentId); mDrawerLayout = drawerLayout; - mDrawerLayout.setScrimColor(Color.TRANSPARENT); +// mDrawerLayout.setScrimColor(Color.TRANSPARENT); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml index c6738869a3..eb6129900d 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml @@ -53,9 +53,9 @@ <string name="activity_offline">Offline Map</string> <string name="activity_minmax_zoom">Min/Max Zoom</string> <string name="activity_viewpager">ViewPager</string> - <string name="title_activity_navigation_drawer">Navigation Drawer</string> <string name="activity_runtime_style">Runtime Style</string> <string name="activity_print">Print a map</string> + <string name="title_activity_navigation_drawer">Android SDK View integration</string> <!-- Description --> <string name="description_user_location_tracking">Tracks the location of the user</string> @@ -93,9 +93,9 @@ <string name="description_dynamic_info_window_adapter">Learn how to create a dynamic custom InfoWindow</string> <string name="description_location_picker">Use a fixed Marker to select your location</string> <string name="description_viewpager">Use SupportMapFragments in a ViewPager</string> - <string name="description_navigation_drawer">Test for Navigation Drawer support</string> <string name="description_runtime_style">Adopt the map style on the fly</string> <string name="description_print">Shows how to print a map</string> + <string name="description_navigation_drawer">Test animation of Android SDK View components</string> <string name="menuitem_title_concurrent_infowindow">Concurrent Open InfoWindows</string> <string name="menuitem_title_deselect_markers_on_tap">Deselect Markers On Tap</string> @@ -186,9 +186,8 @@ <string name="navigation_select_location_button_text">Select Location!</string> - <string name="title_section1">Section 1</string> - <string name="title_section2">Section 2</string> - <string name="title_section3">Section 3</string> + <string name="title_section1">Different style</string> + <string name="title_section2">Show Snackbar</string> <string name="navigation_drawer_open">Open navigation drawer</string> <string name="navigation_drawer_close">Close navigation drawer</string> |