Add some improvements (2)

This commit is contained in:
Alexander Sytnyk 2017-08-14 17:41:24 +03:00
parent 186f40350d
commit 3dd616590c
6 changed files with 43 additions and 3 deletions

View file

@ -157,4 +157,5 @@
<dimen name="my_places_empty_state_text_button_padding_top">64dp</dimen>
<dimen name="snap_to_road_bottom_sheet_cancel_button_height">48dp</dimen>
<dimen name="landscape_bottom_sheet_dialog_fragment_width">360dp</dimen>
</resources>

View file

@ -1246,6 +1246,7 @@ public class OsmandSettings {
public static final int BOTTOM_CONSTANT = 1;
public static final int MIDDLE_BOTTOM_CONSTANT = 2;
public static final int MIDDLE_TOP_CONSTANT = 3;
public static final int LANDSCAPE_MIDDLE_RIGHT_CONSTANT = 4;
public final CommonPreference<Boolean> CENTER_POSITION_ON_MAP = new BooleanPreference("center_position_on_map", false).makeProfile();
// this value string is synchronized with settings_pref.xml preference name

View file

@ -62,6 +62,7 @@ import java.util.List;
import java.util.Locale;
import static net.osmand.plus.GPXUtilities.GPXFile;
import static net.osmand.plus.OsmandSettings.LANDSCAPE_MIDDLE_RIGHT_CONSTANT;
import static net.osmand.plus.OsmandSettings.MIDDLE_TOP_CONSTANT;
import static net.osmand.plus.helpers.GpxImportHelper.GPX_SUFFIX;
@ -471,7 +472,11 @@ public class MeasurementToolFragment extends Fragment {
}
OsmandMapTileView tileView = mapActivity.getMapView();
previousMapPosition = tileView.getMapPosition();
tileView.setMapPosition(MIDDLE_TOP_CONSTANT);
if (portrait) {
tileView.setMapPosition(MIDDLE_TOP_CONSTANT);
} else {
tileView.setMapPosition(LANDSCAPE_MIDDLE_RIGHT_CONSTANT);
}
mapActivity.refreshMap();
}
}

View file

@ -8,6 +8,8 @@ import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import net.osmand.AndroidUtils;
@ -21,6 +23,7 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
private OptionsOnClickListener listener;
private boolean addLineMode;
private boolean portrait;
public void setOptionsOnClickListener(OptionsOnClickListener listener) {
this.listener = listener;
@ -35,7 +38,7 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
boolean portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_options_bottom_sheet_dialog, null);
if (portrait) {
@ -112,6 +115,17 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
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 : 0);

View file

@ -9,6 +9,8 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@ -18,6 +20,7 @@ import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.base.BottomSheetDialogFragment;
import net.osmand.plus.helpers.AndroidUiHelper;
import java.util.ArrayList;
import java.util.List;
@ -80,6 +83,17 @@ public class SnapToRoadBottomSheetDialogFragment extends BottomSheetDialogFragme
return view;
}
@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);
}
}
private int getNavBarHeight() {
if (!hasNavBar()) {
return 0;

View file

@ -585,7 +585,12 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
} else {
ratioy = 0.5f;
}
final float ratiox = mapPositionX == 0 ? 0.5f : 0.75f;
final float ratiox;
if (mapPosition == OsmandSettings.LANDSCAPE_MIDDLE_RIGHT_CONSTANT) {
ratiox = 0.7f;
} else {
ratiox = mapPositionX == 0 ? 0.5f : 0.75f;
}
final int cy = (int) (ratioy * view.getHeight());
final int cx = (int) (ratiox * view.getWidth());
if (currentViewport.getPixWidth() != view.getWidth() || currentViewport.getPixHeight() != view.getHeight() ||