diff --git a/android/res/layout-h400dp/map_buttons_layout_regular.xml b/android/res/layout-h400dp/map_buttons_layout_regular.xml
index 3e88cef6ba..3b42e5683f 100644
--- a/android/res/layout-h400dp/map_buttons_layout_regular.xml
+++ b/android/res/layout-h400dp/map_buttons_layout_regular.xml
@@ -13,7 +13,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
- android:layout_marginTop="@dimen/margin_double"
android:clipChildren="false"
android:clipToPadding="false"
android:layoutDirection="ltr"
diff --git a/android/res/layout/activity_map.xml b/android/res/layout/activity_map.xml
index b320619f14..ab1fa915a3 100644
--- a/android/res/layout/activity_map.xml
+++ b/android/res/layout/activity_map.xml
@@ -6,72 +6,58 @@
android:id="@+id/coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
-
-
-
-
-
+ android:layout_height="match_parent">
+
-
-
-
+ android:layout_centerInParent="true" />
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+ app:layout_behavior="@string/placepage_behavior" />
-
+ android:orientation="horizontal" />
+
diff --git a/android/res/layout/layout_nav.xml b/android/res/layout/layout_nav.xml
index 7df440c132..03a190f63e 100644
--- a/android/res/layout/layout_nav.xml
+++ b/android/res/layout/layout_nav.xml
@@ -37,7 +37,7 @@
diff --git a/android/res/layout/layout_nav_top.xml b/android/res/layout/layout_nav_top.xml
index ef15d3968a..69651da8f0 100644
--- a/android/res/layout/layout_nav_top.xml
+++ b/android/res/layout/layout_nav_top.xml
@@ -1,11 +1,11 @@
-
@@ -14,6 +14,7 @@
android:layout_width="match_parent"
android:layout_height="@dimen/nav_street_height"
android:elevation="@dimen/nav_elevation"
+ app:layout_constraintTop_toTopOf="parent"
android:background="?cardBackground">
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/android/res/layout/map_buttons_layout_regular.xml b/android/res/layout/map_buttons_layout_regular.xml
index eaa34fb11a..6d353aedcc 100644
--- a/android/res/layout/map_buttons_layout_regular.xml
+++ b/android/res/layout/map_buttons_layout_regular.xml
@@ -13,7 +13,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
- android:layout_marginTop="@dimen/margin_double"
android:clipChildren="false"
android:clipToPadding="false"
android:layoutDirection="ltr"
diff --git a/android/res/values/colors.xml b/android/res/values/colors.xml
index 37395a7177..362212dee8 100644
--- a/android/res/values/colors.xml
+++ b/android/res/values/colors.xml
@@ -81,6 +81,7 @@
#CC2D3237
#004120
+ #66000000
#121417
diff --git a/android/res/values/themes.xml b/android/res/values/themes.xml
index 908f86d85d..7ccc4e8c9e 100644
--- a/android/res/values/themes.xml
+++ b/android/res/values/themes.xml
@@ -20,14 +20,12 @@
diff --git a/android/src/com/mapswithme/maps/MapFragment.java b/android/src/com/mapswithme/maps/MapFragment.java
index 8bb5b120ad..d426b51b26 100644
--- a/android/src/com/mapswithme/maps/MapFragment.java
+++ b/android/src/com/mapswithme/maps/MapFragment.java
@@ -90,8 +90,6 @@ public class MapFragment extends BaseMwmFragment
UiUtils.dimen(context, R.dimen.margin_base),
ANCHOR_LEFT_TOP);
- mCurrentCompassOffsetX = 0;
- mCurrentCompassOffsetY = UiUtils.getCompassYOffset(requireContext());
setupCompass(mCurrentCompassOffsetY, mCurrentCompassOffsetX, false);
}
@@ -287,6 +285,10 @@ public class MapFragment extends BaseMwmFragment
public void onCreate(Bundle b)
{
super.onCreate(b);
+ mCurrentCompassOffsetX = 0;
+ mCurrentCompassOffsetY = 0;
+ mBottomWidgetOffsetX = 0;
+ mBottomWidgetOffsetY = 0;
setRetainInstance(true);
Bundle args = getArguments();
if (args != null)
diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java
index beff607c2d..6be11490a8 100644
--- a/android/src/com/mapswithme/maps/MwmActivity.java
+++ b/android/src/com/mapswithme/maps/MwmActivity.java
@@ -1,7 +1,5 @@
package com.mapswithme.maps;
-import static com.mapswithme.maps.widget.placepage.PlacePageButtons.PLACEPAGE_MORE_MENU_ID;
-
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
@@ -13,7 +11,6 @@ import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewTreeObserver;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.widget.TextView;
@@ -29,7 +26,6 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentFactory;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
-
import com.mapswithme.maps.Framework.PlacePageActivationListener;
import com.mapswithme.maps.api.Const;
import com.mapswithme.maps.background.AppBackgroundTracker;
@@ -101,6 +97,8 @@ import java.util.ArrayList;
import java.util.Objects;
import java.util.Stack;
+import static com.mapswithme.maps.widget.placepage.PlacePageButtons.PLACEPAGE_MORE_MENU_ID;
+
public class MwmActivity extends BaseMwmFragmentActivity
implements PlacePageActivationListener,
View.OnTouchListener,
@@ -149,6 +147,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
private MapFragment mMapFragment;
private View mPointChooser;
+ private Toolbar mPointChooserToolbar;
enum PointChooserMode
{
NONE,
@@ -189,6 +188,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
private int navBarHeight;
+ private WindowInsets mCurrentWindowInsets;
+
public interface LeftAnimationTrackListener
{
void onTrackStarted(boolean collapsed);
@@ -378,6 +379,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
setContentView(R.layout.activity_map);
+ UiUtils.setupTransparentStatusBar(this);
mPlacePageController = PlacePageFactory.createCompositePlacePageController(
this, this);
@@ -386,8 +388,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
mSearchController = new FloatingSearchToolbarController(this, this);
mSearchController.getToolbar()
- .getViewTreeObserver()
- .addOnGlobalLayoutListener(new ToolbarLayoutChangeListener());
+ .getViewTreeObserver();
boolean isLaunchByDeepLink = getIntent().getBooleanExtra(EXTRA_LAUNCH_BY_DEEP_LINK, false);
initViews(isLaunchByDeepLink);
@@ -405,33 +406,34 @@ public class MwmActivity extends BaseMwmFragmentActivity
addTask(new Factory.RestoreRouteTask());
}
+ private void refreshLightStatusBar()
+ {
+ UiUtils.setLightStatusBar(this, !(
+ ThemeUtils.isNightTheme(this)
+ || RoutingController.get().isPlanning()
+ || Framework.nativeIsInChoosePositionMode()
+ ));
+ }
+
private void updateViewsInsets()
{
- findViewById(R.id.map_ui_container).setOnApplyWindowInsetsListener((view, windowInsets) -> {
- setViewInsets(findViewById(R.id.map_ui_container), windowInsets);
- setViewInsets(findViewById(R.id.pp_buttons_layout), windowInsets);
- setViewInsets(findViewById(R.id.toolbar), windowInsets);
- setViewInsets(findViewById(R.id.menu_frame), windowInsets);
- setViewInsetsSides(findViewById(R.id.routing_plan_frame).findViewById(R.id.toolbar), windowInsets);
+ mPointChooser.setOnApplyWindowInsetsListener((view, windowInsets) -> {
+ UiUtils.setViewInsetsPaddingBottom(mPointChooser, windowInsets);
+ UiUtils.extendViewWithStatusBar(mPointChooserToolbar, windowInsets);
+
navBarHeight = windowInsets.getSystemWindowInsetBottom();
- adjustCompass(-1, windowInsets.getSystemWindowInsetRight());
+ // For the first loading, set compass top margin to status bar size
+ if (mCurrentWindowInsets == null)
+ adjustCompass(windowInsets.getSystemWindowInsetTop(), windowInsets.getSystemWindowInsetRight());
+ else
+ adjustCompass(-1, windowInsets.getSystemWindowInsetRight());
+ refreshLightStatusBar();
adjustBottomWidgets(windowInsets.getSystemWindowInsetLeft());
+ mCurrentWindowInsets = windowInsets;
return windowInsets;
});
}
- private void setViewInsets(View view, WindowInsets windowInsets)
- {
- view.setPadding(windowInsets.getSystemWindowInsetLeft(), view.getPaddingTop(),
- windowInsets.getSystemWindowInsetRight(), windowInsets.getSystemWindowInsetBottom());
- }
-
- private void setViewInsetsSides(View view, WindowInsets windowInsets)
- {
- view.setPadding(windowInsets.getSystemWindowInsetLeft(), view.getPaddingTop(),
- windowInsets.getSystemWindowInsetRight(), view.getPaddingBottom());
- }
-
private int getDownloadMapsCounter()
{
UpdateInfo info = MapManager.nativeGetUpdateInfo(null);
@@ -473,10 +475,9 @@ public class MwmActivity extends BaseMwmFragmentActivity
if (mPointChooser == null)
return;
- final Toolbar toolbar = mPointChooser.findViewById(R.id.toolbar_point_chooser);
- UiUtils.extendViewWithStatusBar(toolbar);
- UiUtils.showHomeUpButton(toolbar);
- toolbar.setNavigationOnClickListener(v -> {
+ mPointChooserToolbar = mPointChooser.findViewById(R.id.toolbar_point_chooser);
+ UiUtils.showHomeUpButton(mPointChooserToolbar);
+ mPointChooserToolbar.setNavigationOnClickListener(v -> {
closePositionChooser();
if (mPointChooserMode == PointChooserMode.API)
finish();
@@ -562,6 +563,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
UiUtils.show(mPointChooser);
setFullscreen(true);
Framework.nativeTurnOnChoosePositionMode(isBusiness, applyPosition);
+ refreshLightStatusBar();
}
private void hidePositionChooser()
@@ -572,6 +574,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
if (mPointChooserMode == PointChooserMode.API)
finish();
mPointChooserMode = PointChooserMode.NONE;
+ refreshLightStatusBar();
}
private void initMap(boolean isLaunchByDeepLink)
@@ -1003,6 +1006,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
mNavigationController.onActivityResumed(this);
mMapButtonsController.onResume();
mPlacePageController.onActivityResumed(this);
+ refreshLightStatusBar();
}
@Override
@@ -1390,9 +1394,14 @@ public class MwmActivity extends BaseMwmFragmentActivity
@Override
public void onRoutingPlanStartAnimate(boolean show)
{
- int totalHeight = calcFloatingViewsOffset();
- adjustCompassAndTraffic(!show ? UiUtils.getStatusBarHeight(getApplicationContext())
- : totalHeight);
+ int offset = mCurrentWindowInsets.getSystemWindowInsetTop();
+ if (show && mRoutingPlanInplaceController != null)
+ {
+ final int height = mRoutingPlanInplaceController.calcHeight();
+ if (height != 0)
+ offset = height;
+ }
+ adjustCompassAndTraffic(offset);
}
@Override
@@ -1422,7 +1431,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
{
if (mIsTabletLayout)
{
- adjustCompassAndTraffic(UiUtils.getStatusBarHeight(getApplicationContext()));
+ adjustCompassAndTraffic(mCurrentWindowInsets.getSystemWindowInsetTop());
}
else
{
@@ -1451,16 +1460,6 @@ public class MwmActivity extends BaseMwmFragmentActivity
});
}
- private int calcFloatingViewsOffset()
- {
- int offset;
- if (mRoutingPlanInplaceController == null
- || (offset = mRoutingPlanInplaceController.calcHeight()) == 0)
- return UiUtils.getStatusBarHeight(this);
-
- return offset;
- }
-
@Override
public void showNavigation(boolean show)
{
@@ -1506,6 +1505,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
mRoutingPlanInplaceController.hideDrivingOptionsView();
mNavigationController.stop(this);
initNavigationButtons(MapButtonsController.LayoutMode.regular);
+ refreshLightStatusBar();
}
@Override
@@ -1515,6 +1515,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
ThemeSwitcher.INSTANCE.restart(isMapRendererActive());
mNavigationController.start(this);
initNavigationButtons(MapButtonsController.LayoutMode.navigation);
+ refreshLightStatusBar();
}
@Override
@@ -1522,6 +1523,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
{
closeFloatingToolbarsAndPanels(true);
initNavigationButtons(MapButtonsController.LayoutMode.regular);
+ refreshLightStatusBar();
}
@Override
@@ -1529,6 +1531,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
{
closeFloatingToolbarsAndPanels(true);
initNavigationButtons(MapButtonsController.LayoutMode.planning);
+ refreshLightStatusBar();
}
@Override
@@ -1538,6 +1541,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
ThemeSwitcher.INSTANCE.restart(isMapRendererActive());
mNavigationController.stop(this);
initNavigationButtons(MapButtonsController.LayoutMode.planning);
+ refreshLightStatusBar();
}
@Override
@@ -1750,20 +1754,6 @@ public class MwmActivity extends BaseMwmFragmentActivity
BookmarkManager.INSTANCE.showBookmarkCategoryOnMap(categoryId);
}
- private class ToolbarLayoutChangeListener implements ViewTreeObserver.OnGlobalLayoutListener
- {
- @Override
- public void onGlobalLayout()
- {
- mSearchController.getToolbar().getViewTreeObserver()
- .removeOnGlobalLayoutListener(this);
-
- adjustCompassAndTraffic(UiUtils.isVisible(mSearchController.getToolbar())
- ? calcFloatingViewsOffset()
- : UiUtils.getStatusBarHeight(getApplicationContext()));
- }
- }
-
public void onAddPlaceOptionSelected()
{
closeFloatingPanels();
diff --git a/android/src/com/mapswithme/maps/PanelAnimator.java b/android/src/com/mapswithme/maps/PanelAnimator.java
index a2fa494632..22097bc53c 100644
--- a/android/src/com/mapswithme/maps/PanelAnimator.java
+++ b/android/src/com/mapswithme/maps/PanelAnimator.java
@@ -84,8 +84,6 @@ class PanelAnimator
for (MwmActivity.LeftAnimationTrackListener listener: mAnimationTrackListeners)
listener.onTrackStarted(true);
mAnimationTrackListeners.finishIterate();
-
- mActivity.adjustCompass(UiUtils.getCompassYOffset(mActivity));
}
});
@@ -120,8 +118,6 @@ class PanelAnimator
listener.onTrackStarted(false);
mAnimationTrackListeners.finishIterate();
- mActivity.adjustCompass(UiUtils.getCompassYOffset(mActivity));
-
if (completionListener != null)
completionListener.run();
}
diff --git a/android/src/com/mapswithme/maps/downloader/OnmapDownloader.java b/android/src/com/mapswithme/maps/downloader/OnmapDownloader.java
index 2861f8f8dd..9c89e3855b 100644
--- a/android/src/com/mapswithme/maps/downloader/OnmapDownloader.java
+++ b/android/src/com/mapswithme/maps/downloader/OnmapDownloader.java
@@ -222,6 +222,11 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener
else
MapManager.nativeDownload(mCurrentCountry.id);
}));
+
+ mFrame.setOnApplyWindowInsetsListener((view, windowInsets) -> {
+ UiUtils.setViewInsetsPadding(view, windowInsets);
+ return windowInsets;
+ });
}
@Override
diff --git a/android/src/com/mapswithme/maps/maplayer/MapButtonsController.java b/android/src/com/mapswithme/maps/maplayer/MapButtonsController.java
index ceb6a505cb..e83d0e2f18 100644
--- a/android/src/com/mapswithme/maps/maplayer/MapButtonsController.java
+++ b/android/src/com/mapswithme/maps/maplayer/MapButtonsController.java
@@ -120,6 +120,12 @@ public class MapButtonsController extends Fragment
mButtonsMap.put(MapButtons.menu, menuButton);
if (helpButton != null)
mButtonsMap.put(MapButtons.help, helpButton);
+
+ mFrame.setOnApplyWindowInsetsListener((view, windowInsets) -> {
+ UiUtils.setViewInsetsPadding(view, windowInsets);
+ return windowInsets;
+ });
+
return mFrame;
}
diff --git a/android/src/com/mapswithme/maps/maplayer/traffic/widget/TrafficButton.java b/android/src/com/mapswithme/maps/maplayer/traffic/widget/TrafficButton.java
index f3ea2ca1de..9f0e353d9a 100644
--- a/android/src/com/mapswithme/maps/maplayer/traffic/widget/TrafficButton.java
+++ b/android/src/com/mapswithme/maps/maplayer/traffic/widget/TrafficButton.java
@@ -26,8 +26,8 @@ public class TrafficButton
mButton = trafficBtn;
mLoadingAnim = getLoadingAnim(trafficBtn);
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) trafficBtn.getLayoutParams();
- params.setMargins(0, UiUtils.getStatusBarHeight(trafficBtn.getContext()), 0, 0);
+ // RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) trafficBtn.getLayoutParams();
+ // params.setMargins(0, UiUtils.getStatusBarHeight(trafficBtn.getContext()), 0, 0);
}
@NonNull
diff --git a/android/src/com/mapswithme/maps/routing/NavigationController.java b/android/src/com/mapswithme/maps/routing/NavigationController.java
index 390b95552c..2692dadd65 100644
--- a/android/src/com/mapswithme/maps/routing/NavigationController.java
+++ b/android/src/com/mapswithme/maps/routing/NavigationController.java
@@ -12,7 +12,6 @@ import android.os.IBinder;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
@@ -87,13 +86,6 @@ public class NavigationController implements Application.ActivityLifecycleCallba
mOnSettingsClickListener = onSettingsClickListener;
mMapButtonsController = mapButtonsController;
- // Show a blank view below the navbar to hide the menu content
- mFrame.findViewById(R.id.nav_bottom_sheet_nav_bar).setOnApplyWindowInsetsListener((view, windowInsets) -> {
- view.getLayoutParams().height = windowInsets.getSystemWindowInsetBottom();
- view.getLayoutParams().width = mFrame.findViewById(R.id.nav_bottom_sheet).getWidth();
- return windowInsets;
- });
-
// Top frame
View topFrame = mFrame.findViewById(R.id.nav_top_frame);
View turnFrame = topFrame.findViewById(R.id.nav_next_turn_frame);
@@ -112,11 +104,20 @@ public class NavigationController implements Application.ActivityLifecycleCallba
mStreetFrame = topFrame.findViewById(R.id.street_frame);
mNextStreet = mStreetFrame.findViewById(R.id.street);
- View shadow = topFrame.findViewById(R.id.shadow_top);
- UiUtils.hide(shadow);
- UiUtils.extendViewWithStatusBar(mStreetFrame);
- UiUtils.extendViewMarginWithStatusBar(turnFrame);
+ // Show a blank view below the navbar to hide the menu content
+ final View navigationBarBackground = mFrame.findViewById(R.id.nav_bottom_sheet_nav_bar);
+ final View nextTurnContainer = mFrame.findViewById(R.id.nav_next_turn_container);
+ mStreetFrame.setOnApplyWindowInsetsListener((v, windowInsets) -> {
+ UiUtils.extendViewWithStatusBar(v, windowInsets);
+ nextTurnContainer.setPadding(windowInsets.getSystemWindowInsetLeft(), nextTurnContainer.getPaddingTop(),
+ nextTurnContainer.getPaddingRight(), nextTurnContainer.getPaddingBottom());
+ navigationBarBackground.getLayoutParams().height = windowInsets.getSystemWindowInsetBottom();
+ // The gesture navigation bar stays at the bottom in landscape
+ // We need to add a background only above the nav menu
+ navigationBarBackground.getLayoutParams().width = mFrame.findViewById(R.id.nav_bottom_sheet).getWidth();
+ return windowInsets;
+ });
final Application app = (Application) mFrame.getContext().getApplicationContext();
mSpeedCamSignalCompletionListener = new CameraWarningSignalCompletionListener(app);
diff --git a/android/src/com/mapswithme/maps/routing/RoutingPlanController.java b/android/src/com/mapswithme/maps/routing/RoutingPlanController.java
index a756ca8ab8..af40def807 100644
--- a/android/src/com/mapswithme/maps/routing/RoutingPlanController.java
+++ b/android/src/com/mapswithme/maps/routing/RoutingPlanController.java
@@ -104,6 +104,11 @@ public class RoutingPlanController extends ToolbarController
mDriverOptionsLayoutListener = new SelfTerminatedDrivingOptionsLayoutListener();
mAnimToggle = MwmApplication.from(activity.getApplicationContext())
.getResources().getInteger(R.integer.anim_default);
+
+ mFrame.setOnApplyWindowInsetsListener((view, windowInsets) -> {
+ UiUtils.setViewInsetsPaddingNoTop(activity.findViewById(R.id.menu_frame), windowInsets);
+ return windowInsets;
+ });
}
@NonNull
diff --git a/android/src/com/mapswithme/maps/search/FloatingSearchToolbarController.java b/android/src/com/mapswithme/maps/search/FloatingSearchToolbarController.java
index f476a18bb9..c90cc7c522 100644
--- a/android/src/com/mapswithme/maps/search/FloatingSearchToolbarController.java
+++ b/android/src/com/mapswithme/maps/search/FloatingSearchToolbarController.java
@@ -27,6 +27,10 @@ public class FloatingSearchToolbarController extends SearchToolbarController
mListener = listener;
// We only want to detect a click on the input and not allow editing.
disableQueryEditing();
+ getToolbar().setOnApplyWindowInsetsListener((view, windowInsets) -> {
+ UiUtils.setViewInsetsPaddingNoTop(view, windowInsets);
+ return windowInsets;
+ });
}
@Override
diff --git a/android/src/com/mapswithme/maps/widget/ToolbarController.java b/android/src/com/mapswithme/maps/widget/ToolbarController.java
index 928b922104..48c836821b 100644
--- a/android/src/com/mapswithme/maps/widget/ToolbarController.java
+++ b/android/src/com/mapswithme/maps/widget/ToolbarController.java
@@ -31,7 +31,12 @@ public class ToolbarController implements Detachable
mToolbar = root.findViewById(getToolbarId());
if (useExtendedToolbar())
- UiUtils.extendViewWithStatusBar(getToolbar());
+ {
+ getToolbar().setOnApplyWindowInsetsListener((view, windowInsets) -> {
+ UiUtils.extendViewWithStatusBar(getToolbar(), windowInsets);
+ return windowInsets;
+ });
+ }
UiUtils.setupNavigationIcon(mToolbar, mNavigationClickListener);
setSupportActionBar(activity, mToolbar);
}
diff --git a/android/src/com/mapswithme/maps/widget/menu/NavMenu.java b/android/src/com/mapswithme/maps/widget/menu/NavMenu.java
index b29ffad2ee..06438ecc25 100644
--- a/android/src/com/mapswithme/maps/widget/menu/NavMenu.java
+++ b/android/src/com/mapswithme/maps/widget/menu/NavMenu.java
@@ -9,7 +9,6 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
-
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.mapswithme.maps.R;
import com.mapswithme.maps.location.LocationHelper;
@@ -54,8 +53,8 @@ public class NavMenu
{
mActivity = activity;
mNavMenuListener = navMenuListener;
- View mBottomFrame = mActivity.findViewById(R.id.nav_bottom_frame);
- mHeaderFrame = mBottomFrame.findViewById(R.id.line_frame);
+ final View bottomFrame = mActivity.findViewById(R.id.nav_bottom_frame);
+ mHeaderFrame = bottomFrame.findViewById(R.id.line_frame);
mHeaderFrame.setOnClickListener(v -> toggleNavMenu());
mHeaderFrame.addOnLayoutChangeListener((view, i, i1, i2, i3, i4, i5, i6, i7) -> setPeekHeight());
mNavBottomSheetBehavior = BottomSheetBehavior.from(mActivity.findViewById(R.id.nav_bottom_sheet));
@@ -86,24 +85,24 @@ public class NavMenu
});
// Bottom frame
- mSpeedViewContainer = mBottomFrame.findViewById(R.id.speed_view_container);
- mSpeedValue = mBottomFrame.findViewById(R.id.speed_value);
- mSpeedUnits = mBottomFrame.findViewById(R.id.speed_dimen);
- mTimeHourValue = mBottomFrame.findViewById(R.id.time_hour_value);
- mTimeHourUnits = mBottomFrame.findViewById(R.id.time_hour_dimen);
- mTimeMinuteValue = mBottomFrame.findViewById(R.id.time_minute_value);
- mTimeMinuteUnits = mBottomFrame.findViewById(R.id.time_minute_dimen);
- mTimeEstimate = mBottomFrame.findViewById(R.id.time_estimate);
- mDistanceValue = mBottomFrame.findViewById(R.id.distance_value);
- mDistanceUnits = mBottomFrame.findViewById(R.id.distance_dimen);
- mRouteProgress = mBottomFrame.findViewById(R.id.navigation_progress);
+ mSpeedViewContainer = bottomFrame.findViewById(R.id.speed_view_container);
+ mSpeedValue = bottomFrame.findViewById(R.id.speed_value);
+ mSpeedUnits = bottomFrame.findViewById(R.id.speed_dimen);
+ mTimeHourValue = bottomFrame.findViewById(R.id.time_hour_value);
+ mTimeHourUnits = bottomFrame.findViewById(R.id.time_hour_dimen);
+ mTimeMinuteValue = bottomFrame.findViewById(R.id.time_minute_value);
+ mTimeMinuteUnits = bottomFrame.findViewById(R.id.time_minute_dimen);
+ mTimeEstimate = bottomFrame.findViewById(R.id.time_estimate);
+ mDistanceValue = bottomFrame.findViewById(R.id.distance_value);
+ mDistanceUnits = bottomFrame.findViewById(R.id.distance_dimen);
+ mRouteProgress = bottomFrame.findViewById(R.id.navigation_progress);
// Bottom frame buttons
- ImageView mSettings = mBottomFrame.findViewById(R.id.settings);
+ ImageView mSettings = bottomFrame.findViewById(R.id.settings);
mSettings.setOnClickListener(v -> onSettingsClicked());
- mTts = mBottomFrame.findViewById(R.id.tts_volume);
+ mTts = bottomFrame.findViewById(R.id.tts_volume);
mTts.setOnClickListener(v -> onTtsClicked());
- Button stop = mBottomFrame.findViewById(R.id.stop);
+ Button stop = bottomFrame.findViewById(R.id.stop);
stop.setOnClickListener(v -> onStopClicked());
UiUtils.updateRedButton(stop);
diff --git a/android/src/com/mapswithme/maps/widget/placepage/EditBookmarkFragment.java b/android/src/com/mapswithme/maps/widget/placepage/EditBookmarkFragment.java
index 5a95d62122..02bd165c98 100644
--- a/android/src/com/mapswithme/maps/widget/placepage/EditBookmarkFragment.java
+++ b/android/src/com/mapswithme/maps/widget/placepage/EditBookmarkFragment.java
@@ -104,7 +104,10 @@ public class EditBookmarkFragment extends BaseMwmDialogFragment implements View.
private void initToolbar(View view)
{
Toolbar toolbar = view.findViewById(R.id.toolbar);
- UiUtils.extendViewWithStatusBar(toolbar);
+ toolbar.setOnApplyWindowInsetsListener((v, windowInsets) -> {
+ UiUtils.extendViewWithStatusBar(v, windowInsets);
+ return windowInsets;
+ });
final TextView textView = toolbar.findViewById(R.id.tv__save);
textView.setOnClickListener(new View.OnClickListener()
{
diff --git a/android/src/com/mapswithme/maps/widget/placepage/EditDescriptionFragment.java b/android/src/com/mapswithme/maps/widget/placepage/EditDescriptionFragment.java
deleted file mode 100644
index c09361a889..0000000000
--- a/android/src/com/mapswithme/maps/widget/placepage/EditDescriptionFragment.java
+++ /dev/null
@@ -1,131 +0,0 @@
-package com.mapswithme.maps.widget.placepage;
-
-import android.os.Build;
-import android.os.Bundle;
-import android.text.Html;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.WindowManager;
-import android.widget.EditText;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.appcompat.widget.Toolbar;
-
-import com.mapswithme.maps.R;
-import com.mapswithme.maps.base.BaseMwmDialogFragment;
-import com.mapswithme.maps.bookmarks.data.Bookmark;
-import com.mapswithme.util.StringUtils;
-import com.mapswithme.util.UiUtils;
-
-import java.lang.ref.WeakReference;
-
-public class EditDescriptionFragment extends BaseMwmDialogFragment
-{
- public static final String EXTRA_BOOKMARK = "bookmark";
-
- private EditText mEtDescription;
- private Bookmark mBookmark;
-
- public interface OnDescriptionSavedListener
- {
- void onSaved(Bookmark bookmark);
- }
-
- private WeakReference mListener;
-
- public EditDescriptionFragment() {}
-
- @Override
- protected int getCustomTheme()
- {
- return getFullscreenTheme();
- }
-
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
- {
- return inflater.inflate(R.layout.fragment_edit_description, container, false);
- }
-
- @Override
- public void onViewCreated(@NonNull View view, Bundle savedInstanceState)
- {
- mBookmark = getArguments().getParcelable(EXTRA_BOOKMARK);
- String description = null;
- if (mBookmark != null)
- description = mBookmark.getBookmarkDescription();
-
- if (description != null && StringUtils.nativeIsHtml(description))
- {
- final String descriptionNoSimpleTags = StringUtils.removeEditTextHtmlTags(description);
- if (!StringUtils.nativeIsHtml(descriptionNoSimpleTags))
- {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- description = Html.fromHtml(description, Html.FROM_HTML_MODE_LEGACY).toString();
- else
- description = Html.fromHtml(description).toString();
- }
- }
-
- mEtDescription = view.findViewById(R.id.et__description);
- mEtDescription.setText(description);
- initToolbar(view);
-
- mEtDescription.requestFocus();
- getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
- }
-
- public void setSaveDescriptionListener(OnDescriptionSavedListener listener)
- {
- mListener = new WeakReference<>(listener);
- }
-
- private void initToolbar(View view)
- {
- Toolbar toolbar = view.findViewById(R.id.toolbar);
- UiUtils.extendViewWithStatusBar(toolbar);
- final TextView textView = toolbar.findViewById(R.id.tv__save);
- textView.setOnClickListener(new View.OnClickListener()
- {
- @Override
- public void onClick(View v)
- {
- saveDescription();
- }
- });
- UiUtils.showHomeUpButton(toolbar);
- toolbar.setTitle(R.string.description);
- toolbar.setNavigationOnClickListener(new View.OnClickListener()
- {
- @Override
- public void onClick(View v)
- {
- dismiss();
- }
- });
- }
-
- private void saveDescription()
- {
- mBookmark.setParams(mBookmark.getTitle(), null, mEtDescription.getText().toString());
-
- if (mListener != null)
- {
- OnDescriptionSavedListener listener = mListener.get();
- if (listener != null)
- listener.onSaved(mBookmark);
- }
- dismiss();
- }
-
- @Override
- public void onDetach()
- {
- super.onDetach();
- mListener = null;
- }
-}
diff --git a/android/src/com/mapswithme/maps/widget/placepage/RichPlacePageController.java b/android/src/com/mapswithme/maps/widget/placepage/RichPlacePageController.java
index f0840d2ae7..103e1aaca8 100644
--- a/android/src/com/mapswithme/maps/widget/placepage/RichPlacePageController.java
+++ b/android/src/com/mapswithme/maps/widget/placepage/RichPlacePageController.java
@@ -7,6 +7,7 @@ import android.location.Location;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
+import android.view.WindowInsets;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -132,6 +133,12 @@ public class RichPlacePageController implements PlacePageController, LocationLis
mPlacePage.initButtons(buttons);
UiUtils.bringViewToFrontOf(mButtonsLayout, mPlacePage);
LocationHelper.INSTANCE.addListener(this);
+
+ mButtonsLayout.setOnApplyWindowInsetsListener((view, windowInsets) -> {
+ UiUtils.setViewInsetsPaddingNoTop(mButtonsLayout, windowInsets);
+ return windowInsets;
+ });
+ mPlacePage.requestApplyInsets();
}
public int getPlacePageWidth()
diff --git a/android/src/com/mapswithme/util/UiUtils.java b/android/src/com/mapswithme/util/UiUtils.java
index e8d790a578..0408201a0c 100644
--- a/android/src/com/mapswithme/util/UiUtils.java
+++ b/android/src/com/mapswithme/util/UiUtils.java
@@ -11,6 +11,7 @@ import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.Rect;
import android.net.Uri;
+import android.os.Build;
import android.text.Html;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
@@ -22,28 +23,29 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
-import android.view.WindowManager;
+import android.view.WindowInsets;
import android.widget.Button;
-import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.AnyRes;
import androidx.annotation.AttrRes;
import androidx.annotation.ColorInt;
-import androidx.annotation.ColorRes;
import androidx.annotation.DimenRes;
import androidx.annotation.IdRes;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import androidx.appcompat.widget.Toolbar;
-import androidx.core.content.ContextCompat;
+import androidx.core.content.res.ResourcesCompat;
+import androidx.core.view.WindowCompat;
+import androidx.core.view.WindowInsetsControllerCompat;
import androidx.recyclerview.widget.RecyclerView;
-
import com.google.android.material.textfield.TextInputLayout;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
+import java.util.Objects;
+
public final class UiUtils
{
private static final int DEFAULT_TINT_COLOR = Color.parseColor("#20000000");
@@ -53,12 +55,6 @@ public final class UiUtils
public static final String WIDE_PHRASE_SEPARATOR = " • ";
public static final String APPROXIMATE_SYMBOL = "~";
- public static void addStatusBarOffset(@NonNull View view)
- {
- ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
- params.setMargins(0, UiUtils.getStatusBarHeight(view.getContext()), 0, 0);
- }
-
public static void bringViewToFrontOf(@NonNull View frontView, @NonNull View backView)
{
frontView.setZ(backView.getZ() + 1);
@@ -364,75 +360,73 @@ public final class UiUtils
return viewRect.contains(x, y);
}
- public static int getStatusBarHeight(@NonNull Context context)
+ public static void setupTransparentStatusBar(@NonNull Activity activity)
{
- int result = 0;
- Resources res = context.getResources();
- // TODO: find a better way of getting system status bar height
- // https://github.com/organicmaps/organicmaps/issues/3611
- @SuppressLint({"DiscouragedApi", "InternalInsetResource"})
- int resourceId = res.getIdentifier("status_bar_height", "dimen", "android");
- if (resourceId > 0)
- result = res.getDimensionPixelSize(resourceId);
-
- return result;
+ final Window window = activity.getWindow();
+ window.getDecorView().setFitsSystemWindows(false);
+ window.setStatusBarColor(Color.TRANSPARENT);
}
- public static void extendViewWithStatusBar(@NonNull View view)
+ public static void setLightStatusBar(@NonNull Activity activity, boolean isLight)
{
- int statusBarHeight = getStatusBarHeight(view.getContext());
- ViewGroup.LayoutParams lp = view.getLayoutParams();
- if (lp.height == ViewGroup.LayoutParams.WRAP_CONTENT)
+ final Window window = activity.getWindow();
+ final View decorView = window.getDecorView();
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
{
- extendViewPaddingTop(view, statusBarHeight);
- return;
+ WindowInsetsControllerCompat wic = WindowCompat.getInsetsController(window, decorView);
+ // It should not be possible for Window insets controller to be null
+ Objects.requireNonNull(wic).setAppearanceLightStatusBars(isLight);
+ }
+ else
+ {
+ @ColorInt final int color = isLight
+ ? ResourcesCompat.getColor(activity.getResources(), R.color.bg_statusbar_translucent, null)
+ : Color.TRANSPARENT;
+ window.setStatusBarColor(color);
}
-
- lp.height += statusBarHeight;
- view.setLayoutParams(lp);
- extendViewPaddingTop(view, statusBarHeight);
}
- public static void extendViewPaddingWithStatusBar(@NonNull View view)
+ public static void extendViewWithStatusBar(@NonNull View view, WindowInsets windowInsets)
{
- int statusBarHeight = getStatusBarHeight(view.getContext());
- extendViewPaddingTop(view, statusBarHeight);
+ final int height = windowInsets.getSystemWindowInsetTop();
+ final ViewGroup.LayoutParams lp = view.getLayoutParams();
+ // Extend the height only when necessary
+ if (lp.height != ViewGroup.LayoutParams.WRAP_CONTENT && view.getPaddingTop() < height)
+ {
+ lp.height += height;
+ view.setLayoutParams(lp);
+ }
+ setViewInsetsPaddingNoBottom(view, windowInsets);
}
- private static void extendViewPaddingTop(@NonNull View view, int statusBarHeight)
+ public static void setViewInsetsPadding(View view, WindowInsets windowInsets)
{
- view.setPadding(view.getPaddingLeft(), view.getPaddingTop() + statusBarHeight,
- view.getPaddingRight(), view.getPaddingBottom());
+ view.setPadding(windowInsets.getSystemWindowInsetLeft(), windowInsets.getSystemWindowInsetTop(),
+ windowInsets.getSystemWindowInsetRight(), windowInsets.getSystemWindowInsetBottom());
}
- public static void extendViewMarginWithStatusBar(@NonNull View view)
+ public static void setViewInsetsPaddingNoTop(View view, WindowInsets windowInsets)
{
- int statusBarHeight = getStatusBarHeight(view.getContext());
- ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
- int margin = lp.getMarginStart();
- lp.setMargins(margin, margin + statusBarHeight, margin, margin);
- view.setLayoutParams(lp);
+ view.setPadding(windowInsets.getSystemWindowInsetLeft(), view.getPaddingTop(),
+ windowInsets.getSystemWindowInsetRight(), windowInsets.getSystemWindowInsetBottom());
}
- public static void setupStatusBar(@NonNull Activity activity)
+ public static void setViewInsetsPaddingSides(View view, WindowInsets windowInsets)
{
- activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
-
- View statusBarTintView = new View(activity);
- FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, getStatusBarHeight(activity));
- params.gravity = Gravity.TOP;
- statusBarTintView.setLayoutParams(params);
- statusBarTintView.setBackgroundColor(DEFAULT_TINT_COLOR);
- statusBarTintView.setVisibility(View.VISIBLE);
- ViewGroup decorViewGroup = (ViewGroup) activity.getWindow().getDecorView();
- decorViewGroup.addView(statusBarTintView);
+ view.setPadding(windowInsets.getSystemWindowInsetLeft(), view.getPaddingTop(),
+ windowInsets.getSystemWindowInsetRight(), view.getPaddingBottom());
}
- public static void setupColorStatusBar(@NonNull Activity activity, @ColorRes int statusBarColor)
+ public static void setViewInsetsPaddingBottom(View view, WindowInsets windowInsets)
{
- Window window = activity.getWindow();
- window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
- window.setStatusBarColor(ContextCompat.getColor(activity, statusBarColor));
+ view.setPadding(view.getPaddingLeft(), view.getPaddingTop(),
+ view.getPaddingRight(), windowInsets.getSystemWindowInsetBottom());
+ }
+
+ public static void setViewInsetsPaddingNoBottom(View view, WindowInsets windowInsets)
+ {
+ view.setPadding(windowInsets.getSystemWindowInsetLeft(), windowInsets.getSystemWindowInsetTop(),
+ windowInsets.getSystemWindowInsetRight(), view.getPaddingBottom());
}
public static void setupNavigationIcon(@NonNull Toolbar toolbar,
@@ -462,11 +456,6 @@ public final class UiUtils
toolbar.setNavigationOnClickListener(null);
}
- public static int getCompassYOffset(@NonNull Context context)
- {
- return getStatusBarHeight(context);
- }
-
@AnyRes
public static int getStyledResourceId(@NonNull Context context, @AttrRes int res)
{