Merge pull request #4665 from osmandapp/create_base_class_for_menus
Create base class for menus
This commit is contained in:
commit
ee786cde86
17 changed files with 181 additions and 722 deletions
|
@ -0,0 +1,110 @@
|
||||||
|
package net.osmand.plus.base;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.DrawableRes;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewTreeObserver;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
|
||||||
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
|
|
||||||
|
public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
||||||
|
|
||||||
|
private static final String USED_ON_MAP_KEY = "used_on_map";
|
||||||
|
|
||||||
|
protected boolean usedOnMap = true;
|
||||||
|
protected boolean nightMode;
|
||||||
|
|
||||||
|
public void setUsedOnMap(boolean usedOnMap) {
|
||||||
|
this.usedOnMap = usedOnMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
usedOnMap = savedInstanceState.getBoolean(USED_ON_MAP_KEY);
|
||||||
|
}
|
||||||
|
nightMode = isNightMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
if (!AndroidUiHelper.isOrientationPortrait(getActivity())) {
|
||||||
|
final Window window = getDialog().getWindow();
|
||||||
|
WindowManager.LayoutParams params = window.getAttributes();
|
||||||
|
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
||||||
|
window.setAttributes(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putBoolean(USED_ON_MAP_KEY, usedOnMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Drawable getContentIcon(@DrawableRes int id) {
|
||||||
|
return getIcon(id, nightMode ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Drawable getActiveIcon(@DrawableRes int id) {
|
||||||
|
return getIcon(id, nightMode ? R.color.osmand_orange : R.color.color_myloc_distance);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setupHeightAndBackground(final View mainView, final int scrollViewId) {
|
||||||
|
final Activity activity = getActivity();
|
||||||
|
final int screenHeight = AndroidUtils.getScreenHeight(activity);
|
||||||
|
final int statusBarHeight = AndroidUtils.getStatusBarHeight(activity);
|
||||||
|
final int navBarHeight = AndroidUtils.getNavBarHeight(activity);
|
||||||
|
|
||||||
|
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
|
@Override
|
||||||
|
public void onGlobalLayout() {
|
||||||
|
final View scrollView = mainView.findViewById(scrollViewId);
|
||||||
|
int scrollViewHeight = scrollView.getHeight();
|
||||||
|
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
|
||||||
|
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
|
||||||
|
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
|
||||||
|
if (scrollViewHeight > spaceForScrollView) {
|
||||||
|
scrollView.getLayoutParams().height = spaceForScrollView;
|
||||||
|
scrollView.requestLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AndroidUiHelper.isOrientationPortrait(activity)) {
|
||||||
|
AndroidUtils.setBackground(activity, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
||||||
|
} else {
|
||||||
|
if (screenHeight - statusBarHeight - mainView.getHeight() >= getResources().getDimension(R.dimen.bottom_sheet_content_padding_small)) {
|
||||||
|
AndroidUtils.setBackground(activity, mainView, nightMode,
|
||||||
|
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
||||||
|
} else {
|
||||||
|
AndroidUtils.setBackground(activity, mainView, nightMode,
|
||||||
|
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewTreeObserver obs = mainView.getViewTreeObserver();
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
|
obs.removeOnGlobalLayoutListener(this);
|
||||||
|
} else {
|
||||||
|
obs.removeGlobalOnLayoutListener(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isNightMode() {
|
||||||
|
if (usedOnMap) {
|
||||||
|
return getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||||
|
}
|
||||||
|
return !getMyApplication().getSettings().isLightContent();
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,15 +4,12 @@ import android.app.ProgressDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.provider.OpenableColumns;
|
import android.provider.OpenableColumns;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.annotation.DrawableRes;
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
@ -24,14 +21,10 @@ import android.view.ContextThemeWrapper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
import net.osmand.plus.FavouritesDbHelper;
|
import net.osmand.plus.FavouritesDbHelper;
|
||||||
|
@ -40,7 +33,7 @@ import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
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.base.BottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.myplaces.FavoritesActivity;
|
import net.osmand.plus.myplaces.FavoritesActivity;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
|
||||||
|
@ -545,6 +538,7 @@ public class GpxImportHelper {
|
||||||
importFavoritesImpl(gpxFile, fileName, true);
|
importFavoritesImpl(gpxFile, fileName, true);
|
||||||
} else {
|
} else {
|
||||||
ImportGpxBottomSheetDialogFragment fragment = new ImportGpxBottomSheetDialogFragment();
|
ImportGpxBottomSheetDialogFragment fragment = new ImportGpxBottomSheetDialogFragment();
|
||||||
|
fragment.setUsedOnMap(true);
|
||||||
fragment.setGpxImportHelper(this);
|
fragment.setGpxImportHelper(this);
|
||||||
fragment.setGpxFile(gpxFile);
|
fragment.setGpxFile(gpxFile);
|
||||||
fragment.setFileName(fileName);
|
fragment.setFileName(fileName);
|
||||||
|
@ -605,13 +599,11 @@ public class GpxImportHelper {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ImportGpxBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
public static class ImportGpxBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
public static final String TAG = "ImportGpxBottomSheetDialogFragment";
|
public static final String TAG = "ImportGpxBottomSheetDialogFragment";
|
||||||
|
|
||||||
private GpxImportHelper gpxImportHelper;
|
private GpxImportHelper gpxImportHelper;
|
||||||
private boolean portrait;
|
|
||||||
private boolean night;
|
|
||||||
|
|
||||||
private GPXFile gpxFile;
|
private GPXFile gpxFile;
|
||||||
private String fileName;
|
private String fileName;
|
||||||
|
@ -641,24 +633,19 @@ public class GpxImportHelper {
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
night = getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
|
||||||
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
|
||||||
|
|
||||||
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_import_gpx_bottom_sheet_dialog, container);
|
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_import_gpx_bottom_sheet_dialog, container);
|
||||||
if (portrait) {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, night, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (night) {
|
if (nightMode) {
|
||||||
((TextView) mainView.findViewById(R.id.import_gpx_title)).setTextColor(ContextCompat.getColor(getActivity(), R.color.ctx_menu_info_text_dark));
|
((TextView) mainView.findViewById(R.id.import_gpx_title)).setTextColor(ContextCompat.getColor(getActivity(), R.color.ctx_menu_info_text_dark));
|
||||||
}
|
}
|
||||||
|
|
||||||
((ImageView) mainView.findViewById(R.id.import_as_favorites_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_fav_dark));
|
((ImageView) mainView.findViewById(R.id.import_as_favorites_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_fav_dark));
|
||||||
((ImageView) mainView.findViewById(R.id.import_as_gpx_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_polygom_dark));
|
((ImageView) mainView.findViewById(R.id.import_as_gpx_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_polygom_dark));
|
||||||
|
|
||||||
int nameColor = ContextCompat.getColor(getContext(), night ? R.color.osmand_orange : R.color.dashboard_blue);
|
int nameColor = ContextCompat.getColor(getContext(), nightMode ? R.color.osmand_orange : R.color.dashboard_blue);
|
||||||
int descrColor = ContextCompat.getColor(getContext(), night ? R.color.dashboard_subheader_text_dark : R.color.dashboard_subheader_text_light);
|
int descrColor = ContextCompat.getColor(getContext(), nightMode ? R.color.dashboard_subheader_text_dark : R.color.dashboard_subheader_text_light);
|
||||||
String descr = getString(R.string.import_gpx_file_description);
|
String descr = getString(R.string.import_gpx_file_description);
|
||||||
SpannableStringBuilder text = new SpannableStringBuilder(fileName).append(" ").append(descr);
|
SpannableStringBuilder text = new SpannableStringBuilder(fileName).append(" ").append(descr);
|
||||||
text.setSpan(new ForegroundColorSpan(nameColor), 0, fileName.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
text.setSpan(new ForegroundColorSpan(nameColor), 0, fileName.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
|
@ -687,59 +674,9 @@ public class GpxImportHelper {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final int screenHeight = AndroidUtils.getScreenHeight(getActivity());
|
setupHeightAndBackground(mainView, R.id.import_gpx_scroll_view);
|
||||||
final int statusBarHeight = AndroidUtils.getStatusBarHeight(getActivity());
|
|
||||||
final int navBarHeight = AndroidUtils.getNavBarHeight(getActivity());
|
|
||||||
|
|
||||||
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
||||||
@Override
|
|
||||||
public void onGlobalLayout() {
|
|
||||||
final View scrollView = mainView.findViewById(R.id.import_gpx_scroll_view);
|
|
||||||
int scrollViewHeight = scrollView.getHeight();
|
|
||||||
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
|
|
||||||
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
|
|
||||||
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
|
|
||||||
if (scrollViewHeight > spaceForScrollView) {
|
|
||||||
scrollView.getLayoutParams().height = spaceForScrollView;
|
|
||||||
scrollView.requestLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!portrait) {
|
|
||||||
if (screenHeight - statusBarHeight - mainView.getHeight() >= getResources().getDimension(R.dimen.bottom_sheet_content_padding_small)) {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, night,
|
|
||||||
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
|
||||||
} else {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, night,
|
|
||||||
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewTreeObserver obs = mainView.getViewTreeObserver();
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
|
||||||
obs.removeOnGlobalLayoutListener(this);
|
|
||||||
} else {
|
|
||||||
obs.removeGlobalOnLayoutListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
if (!portrait) {
|
|
||||||
final Window window = getDialog().getWindow();
|
|
||||||
WindowManager.LayoutParams params = window.getAttributes();
|
|
||||||
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
|
||||||
window.setAttributes(params);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Drawable getContentIcon(@DrawableRes int id) {
|
|
||||||
return getIcon(id, night ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +1,28 @@
|
||||||
package net.osmand.plus.mapmarkers;
|
package net.osmand.plus.mapmarkers;
|
||||||
|
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.DrawableRes;
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
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.base.BottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
|
||||||
|
|
||||||
public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
public final static String TAG = "CoordinateInputBottomSheetDialogFragment";
|
public final static String TAG = "CoordinateInputBottomSheetDialogFragment";
|
||||||
|
|
||||||
private boolean portrait;
|
|
||||||
private View mainView;
|
private View mainView;
|
||||||
private boolean night;
|
|
||||||
private int coordinateFormat = -1;
|
private int coordinateFormat = -1;
|
||||||
private boolean useOsmandKeyboard = true;
|
private boolean useOsmandKeyboard = true;
|
||||||
private CoordinateInputFormatChangeListener listener;
|
private CoordinateInputFormatChangeListener listener;
|
||||||
|
@ -58,17 +48,12 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
final MapActivity mapActivity = (MapActivity) getActivity();
|
final MapActivity mapActivity = (MapActivity) getActivity();
|
||||||
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
night = !mapActivity.getMyApplication().getSettings().isLightContent();
|
|
||||||
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
|
||||||
|
|
||||||
mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), coordinateFormat == -1 ?
|
mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), coordinateFormat == -1 ?
|
||||||
R.layout.fragment_marker_coordinate_input_bottom_sheet_dialog : R.layout.fragment_marker_coordinate_input_options_bottom_sheet_helper, container);
|
R.layout.fragment_marker_coordinate_input_bottom_sheet_dialog : R.layout.fragment_marker_coordinate_input_options_bottom_sheet_helper, container);
|
||||||
if (portrait) {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, night, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (night) {
|
if (nightMode) {
|
||||||
((TextView) mainView.findViewById(R.id.coordinate_input_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
|
((TextView) mainView.findViewById(R.id.coordinate_input_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,57 +147,11 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final int screenHeight = AndroidUtils.getScreenHeight(getActivity());
|
setupHeightAndBackground(mainView, R.id.marker_coordinate_input_scroll_view);
|
||||||
final int statusBarHeight = AndroidUtils.getStatusBarHeight(getActivity());
|
|
||||||
final int navBarHeight = AndroidUtils.getNavBarHeight(getActivity());
|
|
||||||
|
|
||||||
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
||||||
@Override
|
|
||||||
public void onGlobalLayout() {
|
|
||||||
final View scrollView = mainView.findViewById(R.id.marker_coordinate_input_scroll_view);
|
|
||||||
int scrollViewHeight = scrollView.getHeight();
|
|
||||||
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
|
|
||||||
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
|
|
||||||
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
|
|
||||||
if (scrollViewHeight > spaceForScrollView) {
|
|
||||||
scrollView.getLayoutParams().height = spaceForScrollView;
|
|
||||||
scrollView.requestLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!portrait) {
|
|
||||||
if (screenHeight - statusBarHeight - mainView.getHeight()
|
|
||||||
>= AndroidUtils.dpToPx(getActivity(), 8)) {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, night,
|
|
||||||
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
|
||||||
} else {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, night,
|
|
||||||
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewTreeObserver obs = mainView.getViewTreeObserver();
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
|
||||||
obs.removeOnGlobalLayoutListener(this);
|
|
||||||
} else {
|
|
||||||
obs.removeGlobalOnLayoutListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
if (!portrait) {
|
|
||||||
final Window window = getDialog().getWindow();
|
|
||||||
WindowManager.LayoutParams params = window.getAttributes();
|
|
||||||
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
|
||||||
window.setAttributes(params);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCancel(DialogInterface dialog) {
|
public void onCancel(DialogInterface dialog) {
|
||||||
super.onCancel(dialog);
|
super.onCancel(dialog);
|
||||||
|
@ -221,14 +160,9 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Drawable getContentIcon(@DrawableRes int id) {
|
|
||||||
return getIcon(id, night ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void highlightSelectedItem(boolean check) {
|
private void highlightSelectedItem(boolean check) {
|
||||||
int iconColor = check ? R.color.dashboard_blue : night ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color;
|
int iconColor = check ? R.color.dashboard_blue : nightMode ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color;
|
||||||
int textColor = ContextCompat.getColor(getContext(), check ? (night ? R.color.color_dialog_buttons_dark : R.color.dashboard_blue) : night ? R.color.color_white : R.color.color_black);
|
int textColor = ContextCompat.getColor(getContext(), check ? (nightMode ? R.color.color_dialog_buttons_dark : R.color.dashboard_blue) : nightMode ? R.color.color_white : R.color.color_black);
|
||||||
switch (coordinateFormat) {
|
switch (coordinateFormat) {
|
||||||
case PointDescription.FORMAT_DEGREES:
|
case PointDescription.FORMAT_DEGREES:
|
||||||
((TextView) mainView.findViewById(R.id.degrees_text)).setTextColor(textColor);
|
((TextView) mainView.findViewById(R.id.degrees_text)).setTextColor(textColor);
|
||||||
|
@ -255,6 +189,5 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
|
||||||
void onKeyboardChanged(boolean useOsmandKeyboard);
|
void onKeyboardChanged(boolean useOsmandKeyboard);
|
||||||
|
|
||||||
void onCancel();
|
void onCancel();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,7 @@ public class CoordinateInputDialogFragment extends DialogFragment {
|
||||||
setStyle(STYLE_NO_FRAME, themeId);
|
setStyle(STYLE_NO_FRAME, themeId);
|
||||||
|
|
||||||
CoordinateInputBottomSheetDialogFragment fragment = new CoordinateInputBottomSheetDialogFragment();
|
CoordinateInputBottomSheetDialogFragment fragment = new CoordinateInputBottomSheetDialogFragment();
|
||||||
|
fragment.setUsedOnMap(false);
|
||||||
fragment.setListener(createCoordinateInputFormatChangeListener());
|
fragment.setListener(createCoordinateInputFormatChangeListener());
|
||||||
fragment.show(getMapActivity().getSupportFragmentManager(), CoordinateInputBottomSheetDialogFragment.TAG);
|
fragment.show(getMapActivity().getSupportFragmentManager(), CoordinateInputBottomSheetDialogFragment.TAG);
|
||||||
}
|
}
|
||||||
|
@ -95,6 +96,7 @@ public class CoordinateInputDialogFragment extends DialogFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
CoordinateInputBottomSheetDialogFragment fragment = new CoordinateInputBottomSheetDialogFragment();
|
CoordinateInputBottomSheetDialogFragment fragment = new CoordinateInputBottomSheetDialogFragment();
|
||||||
|
fragment.setUsedOnMap(false);
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt(COORDINATE_FORMAT, coordinateFormat);
|
args.putInt(COORDINATE_FORMAT, coordinateFormat);
|
||||||
args.putBoolean(USE_OSMAND_KEYBOARD, useOsmandKeyboard);
|
args.putBoolean(USE_OSMAND_KEYBOARD, useOsmandKeyboard);
|
||||||
|
|
|
@ -1,29 +1,23 @@
|
||||||
package net.osmand.plus.mapmarkers;
|
package net.osmand.plus.mapmarkers;
|
||||||
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
|
||||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.base.BottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class HistoryMarkerMenuBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
public class HistoryMarkerMenuBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
public final static String TAG = "HistoryMarkerMenuBottomSheetDialogFragment";
|
public final static String TAG = "HistoryMarkerMenuBottomSheetDialogFragment";
|
||||||
|
|
||||||
|
@ -33,7 +27,6 @@ public class HistoryMarkerMenuBottomSheetDialogFragment extends BottomSheetDialo
|
||||||
public static final String MARKER_VISITED_DATE = "marker_visited_date";
|
public static final String MARKER_VISITED_DATE = "marker_visited_date";
|
||||||
|
|
||||||
private HistoryMarkerMenuFragmentListener listener;
|
private HistoryMarkerMenuFragmentListener listener;
|
||||||
private boolean portrait;
|
|
||||||
|
|
||||||
public void setListener(HistoryMarkerMenuFragmentListener listener) {
|
public void setListener(HistoryMarkerMenuFragmentListener listener) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
|
@ -42,14 +35,9 @@ public class HistoryMarkerMenuBottomSheetDialogFragment extends BottomSheetDialo
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
|
||||||
final boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
|
||||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
|
|
||||||
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_history_bottom_sheet_dialog, container);
|
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_history_bottom_sheet_dialog, container);
|
||||||
if (portrait) {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
|
||||||
}
|
|
||||||
|
|
||||||
Bundle arguments = getArguments();
|
Bundle arguments = getArguments();
|
||||||
if (arguments != null) {
|
if (arguments != null) {
|
||||||
|
@ -98,59 +86,15 @@ public class HistoryMarkerMenuBottomSheetDialogFragment extends BottomSheetDialo
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final int screenHeight = AndroidUtils.getScreenHeight(getActivity());
|
setupHeightAndBackground(mainView, R.id.history_marker_scroll_view);
|
||||||
final int statusBarHeight = AndroidUtils.getStatusBarHeight(getActivity());
|
|
||||||
final int navBarHeight = AndroidUtils.getNavBarHeight(getActivity());
|
|
||||||
|
|
||||||
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
||||||
@Override
|
|
||||||
public void onGlobalLayout() {
|
|
||||||
final View scrollView = mainView.findViewById(R.id.history_marker_scroll_view);
|
|
||||||
int scrollViewHeight = scrollView.getHeight();
|
|
||||||
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
|
|
||||||
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
|
|
||||||
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
|
|
||||||
if (scrollViewHeight > spaceForScrollView) {
|
|
||||||
scrollView.getLayoutParams().height = spaceForScrollView;
|
|
||||||
scrollView.requestLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!portrait) {
|
|
||||||
if (screenHeight - statusBarHeight - mainView.getHeight()
|
|
||||||
>= getResources().getDimension(R.dimen.bottom_sheet_content_padding_small)) {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode,
|
|
||||||
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
|
||||||
} else {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode,
|
|
||||||
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewTreeObserver obs = mainView.getViewTreeObserver();
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
|
||||||
obs.removeOnGlobalLayoutListener(this);
|
|
||||||
} else {
|
|
||||||
obs.removeGlobalOnLayoutListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
if (!portrait) {
|
|
||||||
final Window window = getDialog().getWindow();
|
|
||||||
WindowManager.LayoutParams params = window.getAttributes();
|
|
||||||
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
|
||||||
window.setAttributes(params);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface HistoryMarkerMenuFragmentListener {
|
interface HistoryMarkerMenuFragmentListener {
|
||||||
|
|
||||||
void onMakeMarkerActive(int pos);
|
void onMakeMarkerActive(int pos);
|
||||||
|
|
||||||
void onDeleteMarker(int pos);
|
void onDeleteMarker(int pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,6 +131,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
OptionsBottomSheetDialogFragment fragment = new OptionsBottomSheetDialogFragment();
|
OptionsBottomSheetDialogFragment fragment = new OptionsBottomSheetDialogFragment();
|
||||||
|
fragment.setUsedOnMap(false);
|
||||||
fragment.setListener(createOptionsFragmentListener());
|
fragment.setListener(createOptionsFragmentListener());
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
int pos = viewPager.getCurrentItem();
|
int pos = viewPager.getCurrentItem();
|
||||||
|
@ -215,6 +216,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
public void sortByOnClick() {
|
public void sortByOnClick() {
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
OrderByBottomSheetDialogFragment fragment = new OrderByBottomSheetDialogFragment();
|
OrderByBottomSheetDialogFragment fragment = new OrderByBottomSheetDialogFragment();
|
||||||
|
fragment.setUsedOnMap(false);
|
||||||
fragment.setListener(createOrderByFragmentListener());
|
fragment.setListener(createOrderByFragmentListener());
|
||||||
fragment.show(mapActivity.getSupportFragmentManager(), OrderByBottomSheetDialogFragment.TAG);
|
fragment.show(mapActivity.getSupportFragmentManager(), OrderByBottomSheetDialogFragment.TAG);
|
||||||
}
|
}
|
||||||
|
@ -224,6 +226,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
public void showDirectionOnClick() {
|
public void showDirectionOnClick() {
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
ShowDirectionBottomSheetDialogFragment fragment = new ShowDirectionBottomSheetDialogFragment();
|
ShowDirectionBottomSheetDialogFragment fragment = new ShowDirectionBottomSheetDialogFragment();
|
||||||
|
fragment.setUsedOnMap(false);
|
||||||
fragment.setListener(createShowDirectionFragmentListener());
|
fragment.setListener(createShowDirectionFragmentListener());
|
||||||
fragment.show(mapActivity.getSupportFragmentManager(), ShowDirectionBottomSheetDialogFragment.TAG);
|
fragment.show(mapActivity.getSupportFragmentManager(), ShowDirectionBottomSheetDialogFragment.TAG);
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,6 +191,7 @@ public class MapMarkersHistoryFragment extends Fragment implements MapMarkersHel
|
||||||
if (item instanceof MapMarker) {
|
if (item instanceof MapMarker) {
|
||||||
MapMarker marker = (MapMarker) item;
|
MapMarker marker = (MapMarker) item;
|
||||||
HistoryMarkerMenuBottomSheetDialogFragment fragment = new HistoryMarkerMenuBottomSheetDialogFragment();
|
HistoryMarkerMenuBottomSheetDialogFragment fragment = new HistoryMarkerMenuBottomSheetDialogFragment();
|
||||||
|
fragment.setUsedOnMap(false);
|
||||||
Bundle arguments = new Bundle();
|
Bundle arguments = new Bundle();
|
||||||
arguments.putInt(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_POSITION, pos);
|
arguments.putInt(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_POSITION, pos);
|
||||||
arguments.putString(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_NAME, marker.getName(mapActivity));
|
arguments.putString(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_NAME, marker.getName(mapActivity));
|
||||||
|
|
|
@ -1,36 +1,27 @@
|
||||||
package net.osmand.plus.mapmarkers;
|
package net.osmand.plus.mapmarkers;
|
||||||
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.DrawableRes;
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
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.base.BottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
|
||||||
|
|
||||||
public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
public final static String TAG = "OptionsBottomSheetDialogFragment";
|
public final static String TAG = "OptionsBottomSheetDialogFragment";
|
||||||
public final static String SHOW_SORT_BY_ROW = "show_sort_by_row";
|
public final static String SHOW_SORT_BY_ROW = "show_sort_by_row";
|
||||||
public final static String SHOW_MOVE_ALL_TO_HISTORY_ROW = "show_move_to_history_row";
|
public final static String SHOW_MOVE_ALL_TO_HISTORY_ROW = "show_move_to_history_row";
|
||||||
|
|
||||||
private MarkerOptionsFragmentListener listener;
|
private MarkerOptionsFragmentListener listener;
|
||||||
private boolean portrait;
|
|
||||||
private boolean showSortBy;
|
private boolean showSortBy;
|
||||||
private boolean showMoveAllToHistory;
|
private boolean showMoveAllToHistory;
|
||||||
|
|
||||||
|
@ -50,17 +41,11 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
MapActivity mapActivity = (MapActivity) getActivity();
|
MapActivity mapActivity = (MapActivity) getActivity();
|
||||||
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
|
||||||
final boolean nightMode = !getMyApplication().getSettings().isLightContent();
|
|
||||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
|
|
||||||
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_options_bottom_sheet_dialog, container);
|
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_options_bottom_sheet_dialog, container);
|
||||||
if (portrait) {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
|
||||||
}
|
|
||||||
|
|
||||||
((ImageView) mainView.findViewById(R.id.sort_by_icon))
|
((ImageView) mainView.findViewById(R.id.sort_by_icon)).setImageDrawable(getContentIcon(R.drawable.ic_sort_waypoint_dark));
|
||||||
.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();
|
||||||
ImageView showDirectionIcon = (ImageView) mainView.findViewById(R.id.show_direction_icon);
|
ImageView showDirectionIcon = (ImageView) mainView.findViewById(R.id.show_direction_icon);
|
||||||
int imageResId = 0;
|
int imageResId = 0;
|
||||||
|
@ -76,14 +61,10 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
|
||||||
if (imageResId != 0) {
|
if (imageResId != 0) {
|
||||||
showDirectionIcon.setImageDrawable(getIcon(imageResId, R.color.dashboard_blue));
|
showDirectionIcon.setImageDrawable(getIcon(imageResId, R.color.dashboard_blue));
|
||||||
}
|
}
|
||||||
((ImageView) mainView.findViewById(R.id.coordinate_input_icon))
|
((ImageView) mainView.findViewById(R.id.coordinate_input_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_longitude));
|
||||||
.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_longitude));
|
((ImageView) mainView.findViewById(R.id.build_route_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_gdirections_dark));
|
||||||
((ImageView) mainView.findViewById(R.id.build_route_icon))
|
((ImageView) mainView.findViewById(R.id.save_as_new_track_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_polygom_dark));
|
||||||
.setImageDrawable(getContentIcon(R.drawable.ic_action_gdirections_dark));
|
((ImageView) mainView.findViewById(R.id.move_all_to_history_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_history2));
|
||||||
((ImageView) mainView.findViewById(R.id.save_as_new_track_icon))
|
|
||||||
.setImageDrawable(getContentIcon(R.drawable.ic_action_polygom_dark));
|
|
||||||
((ImageView) mainView.findViewById(R.id.move_all_to_history_icon))
|
|
||||||
.setImageDrawable(getContentIcon(R.drawable.ic_action_history2));
|
|
||||||
|
|
||||||
((TextView) mainView.findViewById(R.id.show_direction_text_view)).setTextColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.color_dialog_buttons_dark : R.color.map_widget_blue_pressed));
|
((TextView) mainView.findViewById(R.id.show_direction_text_view)).setTextColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.color_dialog_buttons_dark : R.color.map_widget_blue_pressed));
|
||||||
((TextView) mainView.findViewById(R.id.show_direction_text_view)).setText(getMyApplication().getSettings().MAP_MARKERS_MODE.get().toHumanString(getActivity()));
|
((TextView) mainView.findViewById(R.id.show_direction_text_view)).setText(getMyApplication().getSettings().MAP_MARKERS_MODE.get().toHumanString(getActivity()));
|
||||||
|
@ -160,62 +141,11 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final int screenHeight = AndroidUtils.getScreenHeight(getActivity());
|
setupHeightAndBackground(mainView, R.id.marker_options_scroll_view);
|
||||||
final int statusBarHeight = AndroidUtils.getStatusBarHeight(getActivity());
|
|
||||||
final int navBarHeight = AndroidUtils.getNavBarHeight(getActivity());
|
|
||||||
|
|
||||||
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
||||||
@Override
|
|
||||||
public void onGlobalLayout() {
|
|
||||||
final View scrollView = mainView.findViewById(R.id.marker_options_scroll_view);
|
|
||||||
int scrollViewHeight = scrollView.getHeight();
|
|
||||||
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
|
|
||||||
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
|
|
||||||
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
|
|
||||||
if (scrollViewHeight > spaceForScrollView) {
|
|
||||||
scrollView.getLayoutParams().height = spaceForScrollView;
|
|
||||||
scrollView.requestLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!portrait) {
|
|
||||||
if (screenHeight - statusBarHeight - mainView.getHeight()
|
|
||||||
>= getResources().getDimension(R.dimen.bottom_sheet_content_padding_small)) {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode,
|
|
||||||
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
|
||||||
} else {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode,
|
|
||||||
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewTreeObserver obs = mainView.getViewTreeObserver();
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
|
||||||
obs.removeOnGlobalLayoutListener(this);
|
|
||||||
} else {
|
|
||||||
obs.removeGlobalOnLayoutListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
if (!portrait) {
|
|
||||||
final Window window = getDialog().getWindow();
|
|
||||||
WindowManager.LayoutParams params = window.getAttributes();
|
|
||||||
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
|
||||||
window.setAttributes(params);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Drawable getContentIcon(@DrawableRes int id) {
|
|
||||||
return getIcon(id, getMyApplication().getSettings().isLightContent() ? R.color.on_map_icon_color : R.color.ctx_menu_info_text_dark);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MarkerOptionsFragmentListener {
|
interface MarkerOptionsFragmentListener {
|
||||||
|
|
||||||
void sortByOnClick();
|
void sortByOnClick();
|
||||||
|
|
|
@ -1,32 +1,23 @@
|
||||||
package net.osmand.plus.mapmarkers;
|
package net.osmand.plus.mapmarkers;
|
||||||
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.DrawableRes;
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandSettings.MapMarkersOrderByMode;
|
import net.osmand.plus.OsmandSettings.MapMarkersOrderByMode;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.base.BottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
|
||||||
|
|
||||||
public class OrderByBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
public class OrderByBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
public final static String TAG = "OrderByBottomSheetDialogFragment";
|
public final static String TAG = "OrderByBottomSheetDialogFragment";
|
||||||
|
|
||||||
private boolean portrait;
|
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
private OrderByFragmentListener listener;
|
private OrderByFragmentListener listener;
|
||||||
|
|
||||||
|
@ -37,32 +28,20 @@ public class OrderByBottomSheetDialogFragment extends BottomSheetDialogFragment
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
|
||||||
settings = getMyApplication().getSettings();
|
settings = getMyApplication().getSettings();
|
||||||
final boolean night = !settings.isLightContent();
|
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
|
||||||
|
|
||||||
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_order_by_bottom_sheet_dialog, container);
|
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_order_by_bottom_sheet_dialog, container);
|
||||||
if (portrait) {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, night, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (night) {
|
if (nightMode) {
|
||||||
((TextView) mainView.findViewById(R.id.order_by_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
|
((TextView) mainView.findViewById(R.id.order_by_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
|
||||||
}
|
}
|
||||||
((TextView) mainView.findViewById(R.id.order_by_title)).setText(getString(R.string.order_by));
|
((TextView) mainView.findViewById(R.id.order_by_title)).setText(getString(R.string.order_by));
|
||||||
|
|
||||||
ImageView distanceIcon = (ImageView) mainView.findViewById(R.id.distance_icon);
|
((ImageView) mainView.findViewById(R.id.distance_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_markers_dark));
|
||||||
distanceIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_markers_dark));
|
((ImageView) mainView.findViewById(R.id.name_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_by_name));
|
||||||
|
((ImageView) mainView.findViewById(R.id.date_added_asc_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_by_date));
|
||||||
ImageView nameIcon = (ImageView) mainView.findViewById(R.id.name_icon);
|
((ImageView) mainView.findViewById(R.id.date_added_desc_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_by_date));
|
||||||
nameIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_sort_by_name));
|
|
||||||
|
|
||||||
ImageView dateAddedAscIcon = (ImageView) mainView.findViewById(R.id.date_added_asc_icon);
|
|
||||||
dateAddedAscIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_sort_by_date));
|
|
||||||
|
|
||||||
ImageView dateAddedDescIcon = (ImageView) mainView.findViewById(R.id.date_added_desc_icon);
|
|
||||||
dateAddedDescIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_sort_by_date));
|
|
||||||
|
|
||||||
((TextView) mainView.findViewById(R.id.date_added_asc_text)).setText(getString(R.string.date_added) + " (" + getString(R.string.ascendingly) + ")");
|
((TextView) mainView.findViewById(R.id.date_added_asc_text)).setText(getString(R.string.date_added) + " (" + getString(R.string.ascendingly) + ")");
|
||||||
((TextView) mainView.findViewById(R.id.date_added_desc_text)).setText(getString(R.string.date_added) + " (" + getString(R.string.descendingly) + ")");
|
((TextView) mainView.findViewById(R.id.date_added_desc_text)).setText(getString(R.string.date_added) + " (" + getString(R.string.descendingly) + ")");
|
||||||
|
@ -79,62 +58,11 @@ public class OrderByBottomSheetDialogFragment extends BottomSheetDialogFragment
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final int screenHeight = AndroidUtils.getScreenHeight(getActivity());
|
setupHeightAndBackground(mainView, R.id.marker_order_by_scroll_view);
|
||||||
final int statusBarHeight = AndroidUtils.getStatusBarHeight(getActivity());
|
|
||||||
final int navBarHeight = AndroidUtils.getNavBarHeight(getActivity());
|
|
||||||
|
|
||||||
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
||||||
@Override
|
|
||||||
public void onGlobalLayout() {
|
|
||||||
final View scrollView = mainView.findViewById(R.id.marker_order_by_scroll_view);
|
|
||||||
int scrollViewHeight = scrollView.getHeight();
|
|
||||||
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
|
|
||||||
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
|
|
||||||
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
|
|
||||||
if (scrollViewHeight > spaceForScrollView) {
|
|
||||||
scrollView.getLayoutParams().height = spaceForScrollView;
|
|
||||||
scrollView.requestLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!portrait) {
|
|
||||||
if (screenHeight - statusBarHeight - mainView.getHeight()
|
|
||||||
>= getResources().getDimension(R.dimen.bottom_sheet_content_padding_small)) {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, night,
|
|
||||||
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
|
||||||
} else {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, night,
|
|
||||||
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewTreeObserver obs = mainView.getViewTreeObserver();
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
|
||||||
obs.removeOnGlobalLayoutListener(this);
|
|
||||||
} else {
|
|
||||||
obs.removeGlobalOnLayoutListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
if (!portrait) {
|
|
||||||
final Window window = getDialog().getWindow();
|
|
||||||
WindowManager.LayoutParams params = window.getAttributes();
|
|
||||||
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
|
||||||
window.setAttributes(params);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Drawable getContentIcon(@DrawableRes int id) {
|
|
||||||
return getIcon(id, settings.isLightContent() ? R.color.on_map_icon_color : R.color.ctx_menu_info_text_dark);
|
|
||||||
}
|
|
||||||
|
|
||||||
private View.OnClickListener orderByModeOnClickListener = new View.OnClickListener() {
|
private View.OnClickListener orderByModeOnClickListener = new View.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -713,6 +713,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
PlanRouteOptionsBottomSheetDialogFragment fragment = new PlanRouteOptionsBottomSheetDialogFragment();
|
PlanRouteOptionsBottomSheetDialogFragment fragment = new PlanRouteOptionsBottomSheetDialogFragment();
|
||||||
|
fragment.setUsedOnMap(true);
|
||||||
fragment.setSelectAll(!(selectedCount == markersHelper.getMapMarkers().size() && markersHelper.isStartFromMyLocation()));
|
fragment.setSelectAll(!(selectedCount == markersHelper.getMapMarkers().size() && markersHelper.isStartFromMyLocation()));
|
||||||
fragment.setListener(createOptionsFragmentListener());
|
fragment.setListener(createOptionsFragmentListener());
|
||||||
fragment.show(mapActivity.getSupportFragmentManager(), PlanRouteOptionsBottomSheetDialogFragment.TAG);
|
fragment.show(mapActivity.getSupportFragmentManager(), PlanRouteOptionsBottomSheetDialogFragment.TAG);
|
||||||
|
|
|
@ -1,33 +1,24 @@
|
||||||
package net.osmand.plus.mapmarkers;
|
package net.osmand.plus.mapmarkers;
|
||||||
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.DrawableRes;
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.base.BottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
|
|
||||||
public class PlanRouteOptionsBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
public class PlanRouteOptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
public final static String TAG = "PlanRouteOptionsBottomSheetDialogFragment";
|
public final static String TAG = "PlanRouteOptionsBottomSheetDialogFragment";
|
||||||
|
|
||||||
private boolean portrait;
|
|
||||||
private boolean night;
|
|
||||||
private PlanRouteOptionsFragmentListener listener;
|
private PlanRouteOptionsFragmentListener listener;
|
||||||
private boolean selectAll;
|
private boolean selectAll;
|
||||||
|
|
||||||
|
@ -42,16 +33,12 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends BottomSheetDialog
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
boolean portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
||||||
night = getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
|
||||||
|
|
||||||
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_plan_route_options_bottom_sheet_dialog, container);
|
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_plan_route_options_bottom_sheet_dialog, container);
|
||||||
if (portrait) {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, night, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (night) {
|
if (nightMode) {
|
||||||
((TextView) mainView.findViewById(R.id.title)).setTextColor(ContextCompat.getColor(getActivity(), R.color.ctx_menu_info_text_dark));
|
((TextView) mainView.findViewById(R.id.title)).setTextColor(ContextCompat.getColor(getActivity(), R.color.ctx_menu_info_text_dark));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,61 +110,11 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends BottomSheetDialog
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final int screenHeight = AndroidUtils.getScreenHeight(getActivity());
|
setupHeightAndBackground(mainView, R.id.sort_by_scroll_view);
|
||||||
final int statusBarHeight = AndroidUtils.getStatusBarHeight(getActivity());
|
|
||||||
final int navBarHeight = AndroidUtils.getNavBarHeight(getActivity());
|
|
||||||
|
|
||||||
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
||||||
@Override
|
|
||||||
public void onGlobalLayout() {
|
|
||||||
final View scrollView = mainView.findViewById(R.id.sort_by_scroll_view);
|
|
||||||
int scrollViewHeight = scrollView.getHeight();
|
|
||||||
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
|
|
||||||
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
|
|
||||||
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
|
|
||||||
if (scrollViewHeight > spaceForScrollView) {
|
|
||||||
scrollView.getLayoutParams().height = spaceForScrollView;
|
|
||||||
scrollView.requestLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!portrait) {
|
|
||||||
if (screenHeight - statusBarHeight - mainView.getHeight() >= getResources().getDimension(R.dimen.bottom_sheet_content_padding_small)) {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, night,
|
|
||||||
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
|
||||||
} else {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, night,
|
|
||||||
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewTreeObserver obs = mainView.getViewTreeObserver();
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
|
||||||
obs.removeOnGlobalLayoutListener(this);
|
|
||||||
} else {
|
|
||||||
obs.removeGlobalOnLayoutListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
if (!portrait) {
|
|
||||||
final Window window = getDialog().getWindow();
|
|
||||||
WindowManager.LayoutParams params = window.getAttributes();
|
|
||||||
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
|
||||||
window.setAttributes(params);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Drawable getContentIcon(@DrawableRes int id) {
|
|
||||||
return getIcon(id, night ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PlanRouteOptionsFragmentListener {
|
interface PlanRouteOptionsFragmentListener {
|
||||||
|
|
||||||
void selectOnClick();
|
void selectOnClick();
|
||||||
|
|
|
@ -2,10 +2,7 @@ package net.osmand.plus.mapmarkers;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.DrawableRes;
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
|
@ -13,30 +10,23 @@ import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
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.base.BottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
|
||||||
import net.osmand.plus.helpers.FontCache;
|
import net.osmand.plus.helpers.FontCache;
|
||||||
|
|
||||||
public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
public class ShowDirectionBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
public final static String TAG = "ShowDirectionBottomSheetDialogFragment";
|
public final static String TAG = "ShowDirectionBottomSheetDialogFragment";
|
||||||
|
|
||||||
private ShowDirectionFragmentListener listener;
|
private ShowDirectionFragmentListener listener;
|
||||||
private boolean portrait;
|
|
||||||
private View mainView;
|
private View mainView;
|
||||||
private boolean night;
|
|
||||||
|
|
||||||
public void setListener(ShowDirectionFragmentListener listener) {
|
public void setListener(ShowDirectionFragmentListener listener) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
|
@ -46,14 +36,9 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
final OsmandSettings settings = getMyApplication().getSettings();
|
final OsmandSettings settings = getMyApplication().getSettings();
|
||||||
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
night = !settings.isLightContent();
|
|
||||||
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
|
||||||
|
|
||||||
mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_show_direction_bottom_sheet_dialog, container);
|
mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_show_direction_bottom_sheet_dialog, container);
|
||||||
if (portrait) {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, night, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
|
||||||
}
|
|
||||||
|
|
||||||
OsmandSettings.MapMarkersMode mode = settings.MAP_MARKERS_MODE.get();
|
OsmandSettings.MapMarkersMode mode = settings.MAP_MARKERS_MODE.get();
|
||||||
highlightSelectedItem(mode, true);
|
highlightSelectedItem(mode, true);
|
||||||
|
@ -63,7 +48,7 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
} else {
|
} else {
|
||||||
ImageView topBarImage = (ImageView) mainView.findViewById(R.id.top_bar_image);
|
ImageView topBarImage = (ImageView) mainView.findViewById(R.id.top_bar_image);
|
||||||
ImageView widgetImage = (ImageView) mainView.findViewById(R.id.widget_image);
|
ImageView widgetImage = (ImageView) mainView.findViewById(R.id.widget_image);
|
||||||
if (night) {
|
if (nightMode) {
|
||||||
topBarImage.setImageResource(R.drawable.img_help_markers_topbar_night);
|
topBarImage.setImageResource(R.drawable.img_help_markers_topbar_night);
|
||||||
widgetImage.setImageResource(R.drawable.img_help_markers_widgets_night);
|
widgetImage.setImageResource(R.drawable.img_help_markers_widgets_night);
|
||||||
} else {
|
} else {
|
||||||
|
@ -88,7 +73,7 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
widgetImage.setOnClickListener(showDirectionOnClickListener);
|
widgetImage.setOnClickListener(showDirectionOnClickListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (night) {
|
if (nightMode) {
|
||||||
((TextView) mainView.findViewById(R.id.show_direction_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
|
((TextView) mainView.findViewById(R.id.show_direction_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,62 +127,11 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final int screenHeight = AndroidUtils.getScreenHeight(getActivity());
|
setupHeightAndBackground(mainView, R.id.marker_show_direction_scroll_view);
|
||||||
final int statusBarHeight = AndroidUtils.getStatusBarHeight(getActivity());
|
|
||||||
final int navBarHeight = AndroidUtils.getNavBarHeight(getActivity());
|
|
||||||
|
|
||||||
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
||||||
@Override
|
|
||||||
public void onGlobalLayout() {
|
|
||||||
final View scrollView = mainView.findViewById(R.id.marker_show_direction_scroll_view);
|
|
||||||
int scrollViewHeight = scrollView.getHeight();
|
|
||||||
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
|
|
||||||
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
|
|
||||||
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
|
|
||||||
if (scrollViewHeight > spaceForScrollView) {
|
|
||||||
scrollView.getLayoutParams().height = spaceForScrollView;
|
|
||||||
scrollView.requestLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!portrait) {
|
|
||||||
if (screenHeight - statusBarHeight - mainView.getHeight()
|
|
||||||
>= getResources().getDimension(R.dimen.bottom_sheet_content_padding_small)) {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, night,
|
|
||||||
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
|
||||||
} else {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, night,
|
|
||||||
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewTreeObserver obs = mainView.getViewTreeObserver();
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
|
||||||
obs.removeOnGlobalLayoutListener(this);
|
|
||||||
} else {
|
|
||||||
obs.removeGlobalOnLayoutListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
if (!portrait) {
|
|
||||||
final Window window = getDialog().getWindow();
|
|
||||||
WindowManager.LayoutParams params = window.getAttributes();
|
|
||||||
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
|
||||||
window.setAttributes(params);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Drawable getContentIcon(@DrawableRes int id) {
|
|
||||||
return getIcon(id, night ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color);
|
|
||||||
}
|
|
||||||
|
|
||||||
private MapActivity getMapActivity() {
|
private MapActivity getMapActivity() {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
|
@ -209,7 +143,7 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
private void highlightSelectedItem(OsmandSettings.MapMarkersMode mode, boolean check) {
|
private void highlightSelectedItem(OsmandSettings.MapMarkersMode mode, boolean check) {
|
||||||
int iconBgColor = check ? R.color.dashboard_blue : R.color.on_map_icon_color;
|
int iconBgColor = check ? R.color.dashboard_blue : R.color.on_map_icon_color;
|
||||||
int iconColor = check ? R.color.color_dialog_buttons_dark : R.color.dashboard_blue;
|
int iconColor = check ? R.color.color_dialog_buttons_dark : R.color.dashboard_blue;
|
||||||
int textColor = ContextCompat.getColor(getContext(), check ? (night ? R.color.color_dialog_buttons_dark : R.color.dashboard_blue) : night ? R.color.color_white : R.color.color_black);
|
int textColor = ContextCompat.getColor(getContext(), check ? (nightMode ? R.color.color_dialog_buttons_dark : R.color.dashboard_blue) : nightMode ? R.color.color_white : R.color.color_black);
|
||||||
Typeface typeface = FontCache.getFont(getContext(), check ? "fonts/Roboto-Medium.ttf" : "fonts/Roboto-Regular.ttf");
|
Typeface typeface = FontCache.getFont(getContext(), check ? "fonts/Roboto-Medium.ttf" : "fonts/Roboto-Regular.ttf");
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case TOOLBAR:
|
case TOOLBAR:
|
||||||
|
|
|
@ -274,6 +274,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
OptionsBottomSheetDialogFragment fragment = new OptionsBottomSheetDialogFragment();
|
OptionsBottomSheetDialogFragment fragment = new OptionsBottomSheetDialogFragment();
|
||||||
|
fragment.setUsedOnMap(true);
|
||||||
fragment.setSnapToRoadEnabled(editingCtx.isInSnapToRoadMode());
|
fragment.setSnapToRoadEnabled(editingCtx.isInSnapToRoadMode());
|
||||||
fragment.setListener(createOptionsFragmentListener());
|
fragment.setListener(createOptionsFragmentListener());
|
||||||
fragment.setAddLineMode(newGpxData != null);
|
fragment.setAddLineMode(newGpxData != null);
|
||||||
|
@ -807,12 +808,14 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
|
|
||||||
private void openSelectedPointMenu(MapActivity mapActivity) {
|
private void openSelectedPointMenu(MapActivity mapActivity) {
|
||||||
SelectedPointBottomSheetDialogFragment fragment = new SelectedPointBottomSheetDialogFragment();
|
SelectedPointBottomSheetDialogFragment fragment = new SelectedPointBottomSheetDialogFragment();
|
||||||
|
fragment.setUsedOnMap(true);
|
||||||
fragment.setListener(createSelectedPointFragmentListener());
|
fragment.setListener(createSelectedPointFragmentListener());
|
||||||
fragment.show(mapActivity.getSupportFragmentManager(), SelectedPointBottomSheetDialogFragment.TAG);
|
fragment.show(mapActivity.getSupportFragmentManager(), SelectedPointBottomSheetDialogFragment.TAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openSaveAsNewTrackMenu(MapActivity mapActivity) {
|
private void openSaveAsNewTrackMenu(MapActivity mapActivity) {
|
||||||
SaveAsNewTrackBottomSheetDialogFragment fragment = new SaveAsNewTrackBottomSheetDialogFragment();
|
SaveAsNewTrackBottomSheetDialogFragment fragment = new SaveAsNewTrackBottomSheetDialogFragment();
|
||||||
|
fragment.setUsedOnMap(true);
|
||||||
fragment.setListener(createSaveAsNewTrackFragmentListener());
|
fragment.setListener(createSaveAsNewTrackFragmentListener());
|
||||||
fragment.show(mapActivity.getSupportFragmentManager(), SaveAsNewTrackBottomSheetDialogFragment.TAG);
|
fragment.show(mapActivity.getSupportFragmentManager(), SaveAsNewTrackBottomSheetDialogFragment.TAG);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,34 +1,24 @@
|
||||||
package net.osmand.plus.measurementtool;
|
package net.osmand.plus.measurementtool;
|
||||||
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.DrawableRes;
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.widget.SwitchCompat;
|
import android.support.v7.widget.SwitchCompat;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.base.BottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
|
||||||
import net.osmand.plus.widgets.TextViewEx;
|
import net.osmand.plus.widgets.TextViewEx;
|
||||||
|
|
||||||
public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
public final static String TAG = "OptionsBottomSheetDialogFragment";
|
public final static String TAG = "OptionsBottomSheetDialogFragment";
|
||||||
|
|
||||||
private OptionsFragmentListener listener;
|
private OptionsFragmentListener listener;
|
||||||
private boolean addLineMode;
|
private boolean addLineMode;
|
||||||
private boolean portrait;
|
|
||||||
private boolean nightMode;
|
|
||||||
private boolean snapToRoadEnabled;
|
private boolean snapToRoadEnabled;
|
||||||
|
|
||||||
public void setListener(OptionsFragmentListener listener) {
|
public void setListener(OptionsFragmentListener listener) {
|
||||||
|
@ -46,14 +36,9 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
|
||||||
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
|
||||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
|
|
||||||
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_options_bottom_sheet_dialog, null);
|
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_options_bottom_sheet_dialog, null);
|
||||||
if (portrait) {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nightMode) {
|
if (nightMode) {
|
||||||
((TextViewEx) mainView.findViewById(R.id.options_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
|
((TextViewEx) mainView.findViewById(R.id.options_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
|
||||||
|
@ -131,66 +116,11 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final int screenHeight = AndroidUtils.getScreenHeight(getActivity());
|
setupHeightAndBackground(mainView, R.id.measure_options_scroll_view);
|
||||||
final int statusBarHeight = AndroidUtils.getStatusBarHeight(getActivity());
|
|
||||||
final int navBarHeight = AndroidUtils.getNavBarHeight(getActivity());
|
|
||||||
|
|
||||||
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
||||||
@Override
|
|
||||||
public void onGlobalLayout() {
|
|
||||||
final View scrollView = mainView.findViewById(R.id.measure_options_scroll_view);
|
|
||||||
int scrollViewHeight = scrollView.getHeight();
|
|
||||||
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
|
|
||||||
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
|
|
||||||
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
|
|
||||||
if (scrollViewHeight > spaceForScrollView) {
|
|
||||||
scrollView.getLayoutParams().height = spaceForScrollView;
|
|
||||||
scrollView.requestLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!portrait) {
|
|
||||||
if (screenHeight - statusBarHeight - mainView.getHeight()
|
|
||||||
>= getResources().getDimension(R.dimen.bottom_sheet_content_padding_small)) {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode,
|
|
||||||
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
|
||||||
} else {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode,
|
|
||||||
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewTreeObserver obs = mainView.getViewTreeObserver();
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
|
||||||
obs.removeOnGlobalLayoutListener(this);
|
|
||||||
} else {
|
|
||||||
obs.removeGlobalOnLayoutListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
if (!portrait) {
|
|
||||||
final Window window = getDialog().getWindow();
|
|
||||||
WindowManager.LayoutParams params = window.getAttributes();
|
|
||||||
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
|
||||||
window.setAttributes(params);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Drawable getContentIcon(@DrawableRes int id) {
|
|
||||||
return getIcon(id, nightMode ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Drawable getActiveIcon(@DrawableRes int id) {
|
|
||||||
return getIcon(id, nightMode ? R.color.osmand_orange : R.color.color_myloc_distance);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface OptionsFragmentListener {
|
interface OptionsFragmentListener {
|
||||||
|
|
||||||
void snapToRoadOnCLick();
|
void snapToRoadOnCLick();
|
||||||
|
|
|
@ -1,33 +1,23 @@
|
||||||
package net.osmand.plus.measurementtool;
|
package net.osmand.plus.measurementtool;
|
||||||
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.DrawableRes;
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.base.BottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
|
||||||
|
|
||||||
public class SaveAsNewTrackBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
public class SaveAsNewTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
public final static String TAG = "SaveAsNewTrackBottomSheetDialogFragment";
|
public final static String TAG = "SaveAsNewTrackBottomSheetDialogFragment";
|
||||||
|
|
||||||
private SaveAsNewTrackFragmentListener listener;
|
private SaveAsNewTrackFragmentListener listener;
|
||||||
private boolean nightMode;
|
|
||||||
private boolean portrait;
|
|
||||||
|
|
||||||
public void setListener(SaveAsNewTrackFragmentListener listener) {
|
public void setListener(SaveAsNewTrackFragmentListener listener) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
|
@ -36,14 +26,9 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends BottomSheetDialogFr
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
|
||||||
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
|
||||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
|
|
||||||
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_save_as_new_track_bottom_sheet_dialog, container);
|
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_save_as_new_track_bottom_sheet_dialog, container);
|
||||||
if (portrait) {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||||
mainView.findViewById(R.id.images_row).setVisibility(View.GONE);
|
mainView.findViewById(R.id.images_row).setVisibility(View.GONE);
|
||||||
|
@ -92,62 +77,11 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends BottomSheetDialogFr
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final int screenHeight = AndroidUtils.getScreenHeight(getActivity());
|
setupHeightAndBackground(mainView, R.id.save_as_new_track_scroll_view);
|
||||||
final int statusBarHeight = AndroidUtils.getStatusBarHeight(getActivity());
|
|
||||||
final int navBarHeight = AndroidUtils.getNavBarHeight(getActivity());
|
|
||||||
|
|
||||||
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
||||||
@Override
|
|
||||||
public void onGlobalLayout() {
|
|
||||||
final View scrollView = mainView.findViewById(R.id.save_as_new_track_scroll_view);
|
|
||||||
int scrollViewHeight = scrollView.getHeight();
|
|
||||||
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
|
|
||||||
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
|
|
||||||
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
|
|
||||||
if (scrollViewHeight > spaceForScrollView) {
|
|
||||||
scrollView.getLayoutParams().height = spaceForScrollView;
|
|
||||||
scrollView.requestLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!portrait) {
|
|
||||||
if (screenHeight - statusBarHeight - mainView.getHeight()
|
|
||||||
>= AndroidUtils.dpToPx(getActivity(), 8)) {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode,
|
|
||||||
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
|
||||||
} else {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode,
|
|
||||||
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewTreeObserver obs = mainView.getViewTreeObserver();
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
|
||||||
obs.removeOnGlobalLayoutListener(this);
|
|
||||||
} else {
|
|
||||||
obs.removeGlobalOnLayoutListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
if (!portrait) {
|
|
||||||
final Window window = getDialog().getWindow();
|
|
||||||
WindowManager.LayoutParams params = window.getAttributes();
|
|
||||||
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
|
||||||
window.setAttributes(params);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Drawable getContentIcon(@DrawableRes int id) {
|
|
||||||
return getIcon(id, nightMode ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color);
|
|
||||||
}
|
|
||||||
|
|
||||||
private View.OnClickListener saveAsLineOnClickListener = new View.OnClickListener() {
|
private View.OnClickListener saveAsLineOnClickListener = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
|
|
@ -1,42 +1,31 @@
|
||||||
package net.osmand.plus.measurementtool;
|
package net.osmand.plus.measurementtool;
|
||||||
|
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.DrawableRes;
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
|
||||||
import net.osmand.plus.GPXUtilities.WptPt;
|
import net.osmand.plus.GPXUtilities.WptPt;
|
||||||
import net.osmand.plus.IconsCache;
|
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
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.base.BottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
|
||||||
import net.osmand.plus.measurementtool.NewGpxData.ActionType;
|
import net.osmand.plus.measurementtool.NewGpxData.ActionType;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SelectedPointBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
public final static String TAG = "SelectedPointBottomSheetDialogFragment";
|
public final static String TAG = "SelectedPointBottomSheetDialogFragment";
|
||||||
|
|
||||||
private SelectedPointFragmentListener listener;
|
private SelectedPointFragmentListener listener;
|
||||||
private boolean nightMode;
|
|
||||||
private boolean portrait;
|
|
||||||
|
|
||||||
public void setListener(SelectedPointFragmentListener listener) {
|
public void setListener(SelectedPointFragmentListener listener) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
|
@ -46,19 +35,12 @@ public class SelectedPointBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
final MapActivity mapActivity = (MapActivity) getActivity();
|
final MapActivity mapActivity = (MapActivity) getActivity();
|
||||||
nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
|
||||||
portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
|
||||||
final IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
|
|
||||||
final MeasurementToolLayer measurementLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
|
final MeasurementToolLayer measurementLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
|
||||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
|
|
||||||
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_selected_menu_bottom_sheet_dialog, null);
|
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_selected_menu_bottom_sheet_dialog, null);
|
||||||
if (portrait) {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
|
||||||
}
|
|
||||||
|
|
||||||
int color = nightMode ? R.color.osmand_orange : R.color.color_myloc_distance;
|
((ImageView) mainView.findViewById(R.id.selected_point_icon)).setImageDrawable(getActiveIcon(R.drawable.ic_action_measure_point));
|
||||||
((ImageView) mainView.findViewById(R.id.selected_point_icon)).setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_measure_point, color));
|
|
||||||
((ImageView) mainView.findViewById(R.id.move_point_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_move_point));
|
((ImageView) mainView.findViewById(R.id.move_point_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_move_point));
|
||||||
((ImageView) mainView.findViewById(R.id.delete_point_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_remove_dark));
|
((ImageView) mainView.findViewById(R.id.delete_point_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_remove_dark));
|
||||||
((ImageView) mainView.findViewById(R.id.add_point_after_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_addpoint_above));
|
((ImageView) mainView.findViewById(R.id.add_point_after_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_addpoint_above));
|
||||||
|
@ -157,62 +139,11 @@ public class SelectedPointBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final int screenHeight = AndroidUtils.getScreenHeight(getActivity());
|
setupHeightAndBackground(mainView, R.id.selected_point_options_scroll_view);
|
||||||
final int statusBarHeight = AndroidUtils.getStatusBarHeight(getActivity());
|
|
||||||
final int navBarHeight = AndroidUtils.getNavBarHeight(getActivity());
|
|
||||||
|
|
||||||
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
||||||
@Override
|
|
||||||
public void onGlobalLayout() {
|
|
||||||
final View scrollView = mainView.findViewById(R.id.selected_point_options_scroll_view);
|
|
||||||
int scrollViewHeight = scrollView.getHeight();
|
|
||||||
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
|
|
||||||
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
|
|
||||||
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
|
|
||||||
if (scrollViewHeight > spaceForScrollView) {
|
|
||||||
scrollView.getLayoutParams().height = spaceForScrollView;
|
|
||||||
scrollView.requestLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!portrait) {
|
|
||||||
if (screenHeight - statusBarHeight - mainView.getHeight()
|
|
||||||
>= getResources().getDimension(R.dimen.bottom_sheet_content_padding_small)) {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode,
|
|
||||||
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
|
||||||
} else {
|
|
||||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode,
|
|
||||||
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewTreeObserver obs = mainView.getViewTreeObserver();
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
|
||||||
obs.removeOnGlobalLayoutListener(this);
|
|
||||||
} else {
|
|
||||||
obs.removeGlobalOnLayoutListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
if (!portrait) {
|
|
||||||
final Window window = getDialog().getWindow();
|
|
||||||
WindowManager.LayoutParams params = window.getAttributes();
|
|
||||||
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
|
||||||
window.setAttributes(params);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Drawable getContentIcon(@DrawableRes int id) {
|
|
||||||
return getIcon(id, nightMode ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dismiss() {
|
public void dismiss() {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
|
|
|
@ -328,6 +328,7 @@ public class MapWidgetRegistry {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, int itemId, final int position, boolean isChecked) {
|
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, int itemId, final int position, boolean isChecked) {
|
||||||
ShowDirectionBottomSheetDialogFragment fragment = new ShowDirectionBottomSheetDialogFragment();
|
ShowDirectionBottomSheetDialogFragment fragment = new ShowDirectionBottomSheetDialogFragment();
|
||||||
|
fragment.setUsedOnMap(true);
|
||||||
fragment.setListener(new ShowDirectionBottomSheetDialogFragment.ShowDirectionFragmentListener() {
|
fragment.setListener(new ShowDirectionBottomSheetDialogFragment.ShowDirectionFragmentListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onMapMarkersModeChanged(boolean showDirectionEnabled) {
|
public void onMapMarkersModeChanged(boolean showDirectionEnabled) {
|
||||||
|
|
Loading…
Reference in a new issue