Merge pull request #4797 from osmandapp/improve_options_menu
Blur status bar with opened options menu
This commit is contained in:
commit
0d89116dd8
5 changed files with 252 additions and 200 deletions
|
@ -61,7 +61,7 @@
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/menu_container"
|
android:id="@+id/menu_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="bottom|center_horizontal"/>
|
android:layout_gravity="bottom|center_horizontal"/>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
|
@ -1,10 +1,17 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout
|
<FrameLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/status_bar_transparent_light">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/main_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|center_horizontal"
|
||||||
android:background="?attr/bg_color"
|
android:background="?attr/bg_color"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
@ -215,4 +222,6 @@
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
|
@ -138,6 +138,8 @@
|
||||||
<color name="status_bar_mapillary">#11ab51</color>
|
<color name="status_bar_mapillary">#11ab51</color>
|
||||||
<color name="status_bar_route_light">#d9d9d9</color>
|
<color name="status_bar_route_light">#d9d9d9</color>
|
||||||
<color name="status_bar_route_dark">#000000</color>
|
<color name="status_bar_route_dark">#000000</color>
|
||||||
|
<color name="status_bar_dim_light">#8a4e00</color>
|
||||||
|
<color name="status_bar_dim_dark">#13171a</color>
|
||||||
|
|
||||||
|
|
||||||
<color name="color_transparent">#0000</color>
|
<color name="color_transparent">#0000</color>
|
||||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.mapmarkers;
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
@ -17,6 +18,7 @@ import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.Window;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
@ -28,7 +30,6 @@ import net.osmand.plus.OsmandSettings.MapMarkersOrderByMode;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.TrackActivity;
|
import net.osmand.plus.activities.TrackActivity;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
|
||||||
import net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.OnMapMarkersSavedListener;
|
import net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.OnMapMarkersSavedListener;
|
||||||
import net.osmand.plus.mapmarkers.DirectionIndicationDialogFragment.DirectionIndicationFragmentListener;
|
import net.osmand.plus.mapmarkers.DirectionIndicationDialogFragment.DirectionIndicationFragmentListener;
|
||||||
import net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.MarkerOptionsFragmentListener;
|
import net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.MarkerOptionsFragmentListener;
|
||||||
|
@ -64,6 +65,8 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
private boolean lightTheme;
|
private boolean lightTheme;
|
||||||
private String groupIdToOpen;
|
private String groupIdToOpen;
|
||||||
|
|
||||||
|
private int statusBarColor = -1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -152,11 +155,6 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
final MapMarkersViewPagerAdapter adapter = new MapMarkersViewPagerAdapter(getChildFragmentManager());
|
final MapMarkersViewPagerAdapter adapter = new MapMarkersViewPagerAdapter(getChildFragmentManager());
|
||||||
viewPager.setAdapter(adapter);
|
viewPager.setAdapter(adapter);
|
||||||
|
|
||||||
if (!AndroidUiHelper.isOrientationPortrait(getActivity())) {
|
|
||||||
mainView.findViewById(R.id.menu_container).getLayoutParams().width =
|
|
||||||
getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
|
||||||
}
|
|
||||||
|
|
||||||
bottomNav = mainView.findViewById(R.id.map_markers_bottom_navigation);
|
bottomNav = mainView.findViewById(R.id.map_markers_bottom_navigation);
|
||||||
BottomNavigationViewHelper.disableShiftMode(bottomNav);
|
BottomNavigationViewHelper.disableShiftMode(bottomNav);
|
||||||
if (!lightTheme) {
|
if (!lightTheme) {
|
||||||
|
@ -265,6 +263,26 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void blurStatusBar() {
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
Window window = getDialog().getWindow();
|
||||||
|
if (window != null) {
|
||||||
|
statusBarColor = window.getStatusBarColor();
|
||||||
|
window.setStatusBarColor(ContextCompat.getColor(getActivity(),
|
||||||
|
lightTheme ? R.color.status_bar_dim_light : R.color.status_bar_dim_dark));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearStatusBar() {
|
||||||
|
if (Build.VERSION.SDK_INT >= 21 && statusBarColor != -1) {
|
||||||
|
Window window = getDialog().getWindow();
|
||||||
|
if (window != null) {
|
||||||
|
window.setStatusBarColor(statusBarColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void showOptionsMenuFragment() {
|
private void showOptionsMenuFragment() {
|
||||||
OptionsBottomSheetDialogFragment fragment = new OptionsBottomSheetDialogFragment();
|
OptionsBottomSheetDialogFragment fragment = new OptionsBottomSheetDialogFragment();
|
||||||
fragment.setListener(createOptionsFragmentListener());
|
fragment.setListener(createOptionsFragmentListener());
|
||||||
|
|
|
@ -47,7 +47,18 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
final int themeRes = getMyApplication().getSettings().isLightContent() ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
|
final int themeRes = getMyApplication().getSettings().isLightContent() ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
|
||||||
|
|
||||||
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_options_bottom_sheet_dialog, null);
|
View view = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_options_bottom_sheet_dialog, null);
|
||||||
|
view.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
final View mainView = view.findViewById(R.id.main_view);
|
||||||
|
if (!AndroidUiHelper.isOrientationPortrait(getActivity())) {
|
||||||
|
mainView.getLayoutParams().width = getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
||||||
|
}
|
||||||
|
|
||||||
((ImageView) mainView.findViewById(R.id.sort_by_icon)).setImageDrawable(getContentIcon(R.drawable.ic_sort_waypoint_dark));
|
((ImageView) mainView.findViewById(R.id.sort_by_icon)).setImageDrawable(getContentIcon(R.drawable.ic_sort_waypoint_dark));
|
||||||
OsmandSettings.MapMarkersMode mode = getMyApplication().getSettings().MAP_MARKERS_MODE.get();
|
OsmandSettings.MapMarkersMode mode = getMyApplication().getSettings().MAP_MARKERS_MODE.get();
|
||||||
|
@ -171,7 +182,19 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return mainView;
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
((MapMarkersDialogFragment) getParentFragment()).blurStatusBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
((MapMarkersDialogFragment) getParentFragment()).clearStatusBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue