diff --git a/MapboxAndroidDemo/src/global/java/com/mapbox/mapboxandroiddemo/MainActivity.java b/MapboxAndroidDemo/src/global/java/com/mapbox/mapboxandroiddemo/MainActivity.java
index 04122e47f..a66015fab 100644
--- a/MapboxAndroidDemo/src/global/java/com/mapbox/mapboxandroiddemo/MainActivity.java
+++ b/MapboxAndroidDemo/src/global/java/com/mapbox/mapboxandroiddemo/MainActivity.java
@@ -92,6 +92,7 @@
import com.mapbox.mapboxandroiddemo.examples.labs.CalendarIntegrationActivity;
import com.mapbox.mapboxandroiddemo.examples.labs.ChangeAttributionColorActivity;
import com.mapbox.mapboxandroiddemo.examples.labs.DashedLineDirectionsPickerActivity;
+import com.mapbox.mapboxandroiddemo.examples.labs.FullScreenToggleActivity;
import com.mapbox.mapboxandroiddemo.examples.labs.HomeScreenWidgetActivity;
import com.mapbox.mapboxandroiddemo.examples.labs.IndoorMapActivity;
import com.mapbox.mapboxandroiddemo.examples.labs.InsetMapActivity;
@@ -1388,6 +1389,14 @@ private void initializeModels() {
null,
R.string.activity_lab_baseball_spray_chart_url, true, BuildConfig.MIN_SDK_VERSION));
+ exampleItemModels.add(new ExampleItemModel(
+ R.id.nav_lab,
+ R.string.activity_lab_full_screen_toggle_title,
+ R.string.activity_lab_full_screen_toggle_description,
+ new Intent(MainActivity.this, FullScreenToggleActivity.class),
+ null,
+ R.string.activity_lab_full_screen_toggle_url, true, BuildConfig.MIN_SDK_VERSION));
+
exampleItemModels.add(new ExampleItemModel(
R.id.nav_dds,
R.string.activity_dds_geojson_line_title,
diff --git a/MapboxAndroidDemo/src/main/AndroidManifest.xml b/MapboxAndroidDemo/src/main/AndroidManifest.xml
index f80ecff95..e907c67c5 100644
--- a/MapboxAndroidDemo/src/main/AndroidManifest.xml
+++ b/MapboxAndroidDemo/src/main/AndroidManifest.xml
@@ -300,6 +300,13 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="com.mapbox.mapboxandroiddemo.MainActivity" />
+
+
+
diff --git a/MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/labs/FullScreenToggleActivity.java b/MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/labs/FullScreenToggleActivity.java
new file mode 100644
index 000000000..5dc7edc99
--- /dev/null
+++ b/MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/labs/FullScreenToggleActivity.java
@@ -0,0 +1,144 @@
+package com.mapbox.mapboxandroiddemo.examples.labs;
+
+import android.os.Bundle;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.Toast;
+
+import com.google.android.material.floatingactionbutton.FloatingActionButton;
+import com.mapbox.mapboxandroiddemo.R;
+import com.mapbox.mapboxsdk.Mapbox;
+import com.mapbox.mapboxsdk.geometry.LatLng;
+import com.mapbox.mapboxsdk.maps.MapView;
+import com.mapbox.mapboxsdk.maps.MapboxMap;
+import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
+import com.mapbox.mapboxsdk.maps.Style;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+
+public class FullScreenToggleActivity extends AppCompatActivity implements MapboxMap.OnMapLongClickListener {
+
+ private MapView mapView;
+ private MapboxMap mapboxMap;
+ private boolean hasBeenGivenFullScreenToggleInstruction = false;
+ private boolean isFullScreen = false;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // Mapbox access token is configured here. This needs to be called either in your application
+ // object or in the same activity which contains the mapview.
+ Mapbox.getInstance(this, getString(R.string.access_token));
+
+ // This contains the MapView in XML and needs to be called after the access token is configured.
+ setContentView(R.layout.activity_lab_full_screen_toggle);
+
+ mapView = findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(@NonNull MapboxMap mapboxMap) {
+ mapboxMap.setStyle(Style.MAPBOX_STREETS, new Style.OnStyleLoaded() {
+ @Override
+ public void onStyleLoaded(@NonNull Style style) {
+ FullScreenToggleActivity.this.mapboxMap = mapboxMap;
+ mapboxMap.addOnMapLongClickListener(FullScreenToggleActivity.this);
+ FloatingActionButton fullScreenToggleFab = findViewById(R.id.full_screen_toggle_fab);
+ fullScreenToggleFab.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ fullScreenToggleFab.hide();
+ adjustToolbars(isFullScreen);
+ if (!hasBeenGivenFullScreenToggleInstruction) {
+ Toast.makeText(FullScreenToggleActivity.this,
+ R.string.full_screen_toggle_instruction, Toast.LENGTH_SHORT).show();
+ hasBeenGivenFullScreenToggleInstruction = true;
+ }
+ }
+ });
+ }
+ });
+ }
+ });
+ }
+
+ @Override
+ public boolean onMapLongClick(@NonNull LatLng point) {
+ if (hasBeenGivenFullScreenToggleInstruction) {
+ adjustToolbars(isFullScreen);
+ }
+ return true;
+ }
+
+
+ /**
+ * Adjusts the visibility of the SupportActionBar and notification bars for the map to be full screen or not.
+ * ActionBar isn't checked for because the current minimum SDK level for this app is 16, which is when the
+ * SupportActionBar was introduced.
+ *
+ * @param showToolbars whether or not the toolbars should be displayed in order for the map to be full screen
+ * or not.
+ */
+ private void adjustToolbars(boolean showToolbars) {
+ if (getSupportActionBar() != null) {
+ if (showToolbars) {
+ getSupportActionBar().show();
+ } else {
+ getSupportActionBar().hide();
+ }
+ }
+ getWindow().clearFlags(showToolbars ? WindowManager.LayoutParams.FLAG_FULLSCREEN :
+ WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
+ getWindow().addFlags(showToolbars ? WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN :
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ isFullScreen = !showToolbars;
+ }
+
+ // Add the mapView lifecycle to the activity's lifecycle methods
+ @Override
+ public void onResume() {
+ super.onResume();
+ mapView.onResume();
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ mapView.onStart();
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ mapView.onStop();
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ mapView.onPause();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ if (mapboxMap != null) {
+ mapboxMap.removeOnMapLongClickListener(this);
+ }
+ mapView.onDestroy();
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+}
\ No newline at end of file
diff --git a/MapboxAndroidDemo/src/main/res/layout/activity_inset_map.xml b/MapboxAndroidDemo/src/main/res/layout/activity_inset_map.xml
index baf730a43..2e95462f3 100644
--- a/MapboxAndroidDemo/src/main/res/layout/activity_inset_map.xml
+++ b/MapboxAndroidDemo/src/main/res/layout/activity_inset_map.xml
@@ -4,8 +4,7 @@
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
xmlns:maps="http://schemas.android.com/tools"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
+ android:layout_height="match_parent">
@@ -38,11 +37,11 @@
+ android:layout_marginBottom="16dp"
+ app:srcCompat="@drawable/ic_swap_horiz_white_24dp" />
\ No newline at end of file
diff --git a/MapboxAndroidDemo/src/main/res/layout/activity_lab_full_screen_toggle.xml b/MapboxAndroidDemo/src/main/res/layout/activity_lab_full_screen_toggle.xml
new file mode 100644
index 000000000..7164f18ee
--- /dev/null
+++ b/MapboxAndroidDemo/src/main/res/layout/activity_lab_full_screen_toggle.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MapboxAndroidDemo/src/main/res/values/activity_strings.xml b/MapboxAndroidDemo/src/main/res/values/activity_strings.xml
index b2b595ca6..c08e98b0f 100644
--- a/MapboxAndroidDemo/src/main/res/values/activity_strings.xml
+++ b/MapboxAndroidDemo/src/main/res/values/activity_strings.xml
@@ -475,4 +475,7 @@
Tap on a circle and then marker to toggle. Tap elsewhere to reset to circles.
+
+ Long press on the map to condense the map.
+
diff --git a/MapboxAndroidDemo/src/main/res/values/descriptions_strings.xml b/MapboxAndroidDemo/src/main/res/values/descriptions_strings.xml
index 43a2759f4..363d99a1c 100644
--- a/MapboxAndroidDemo/src/main/res/values/descriptions_strings.xml
+++ b/MapboxAndroidDemo/src/main/res/values/descriptions_strings.xml
@@ -145,6 +145,7 @@
Use the Android system\'s SharedPreferences to save and retrieve information such as coordinates.
Use the Android system\'s fingerprint unlock to reveal "personal" data on a map.
Use the Maps SDK and filters to explore baseball data.
+ Toggle between showing a smaller map and a full screen map.
Show an accurate and government-approved China map in your app using the Mapbox Maps SDK.
Use the China plugin to determine whether or not the device is inside of China.
Load a China style if the device is in China. Load a global/.com style if not.
diff --git a/MapboxAndroidDemo/src/main/res/values/titles_strings.xml b/MapboxAndroidDemo/src/main/res/values/titles_strings.xml
index 2a69a83ce..5bf8663c2 100644
--- a/MapboxAndroidDemo/src/main/res/values/titles_strings.xml
+++ b/MapboxAndroidDemo/src/main/res/values/titles_strings.xml
@@ -148,4 +148,5 @@
Style attribution
Saving to SharedPreferences
Biometric fingerprint
+ Fullscreen toggle
diff --git a/MapboxAndroidDemo/src/main/res/values/urls_strings.xml b/MapboxAndroidDemo/src/main/res/values/urls_strings.xml
index 418a062f8..fb8f7c56a 100644
--- a/MapboxAndroidDemo/src/main/res/values/urls_strings.xml
+++ b/MapboxAndroidDemo/src/main/res/values/urls_strings.xml
@@ -143,6 +143,7 @@
https://i.imgur.com/znxAhDG.png
https://i.imgur.com/iQZzMIR.png
https://i.imgur.com/1j7WVoO.png
+ https://i.imgur.com/I5iR4Vr.png
https://i.imgur.com/KwoEynZ.png
https://i.imgur.com/fIFWqJu.png
https://i.imgur.com/XBS1WAn.png