Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2018-03-15 23:34:17 +01:00
commit d7adf8b329
18 changed files with 152 additions and 65 deletions

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -13,7 +14,7 @@
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<LinearLayout <LinearLayout
android:id="@+id/items_container" android:id="@+id/scrollable_items_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
@ -21,29 +22,73 @@
</ScrollView> </ScrollView>
<LinearLayout
android:id="@+id/non_scrollable_items_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone"/>
<View <View
android:id="@+id/close_row_divider" android:id="@+id/bottom_row_divider"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:background="?attr/dashboard_divider"/> android:background="?attr/dashboard_divider"/>
<FrameLayout <LinearLayout
android:id="@+id/close_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_cancel_button_height" android:layout_height="@dimen/bottom_sheet_cancel_button_height">
android:background="?attr/selectableItemBackground">
<TextView <FrameLayout
android:id="@+id/close_row_text" android:id="@+id/dismiss_button"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_gravity="center" android:layout_weight="1"
android:textAllCaps="true" android:background="?attr/selectableItemBackground">
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
android:textStyle="bold"
tools:text="@string/shared_string_cancel"/>
</FrameLayout> <net.osmand.plus.widgets.TextViewEx
android:id="@+id/dismiss_button_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Cancel"/>
</FrameLayout>
<View
android:id="@+id/bottom_buttons_divider"
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/dashboard_divider"
android:visibility="gone"
tools:visibility="visible"/>
<FrameLayout
android:id="@+id/right_bottom_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/selectableItemBackground"
android:visibility="gone"
tools:visibility="visible">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/right_bottom_button_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Some Action"/>
</FrameLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -3761,6 +3761,6 @@
<string name="poi_whitewater_rapid_name">Name of the river rapids</string> <string name="poi_whitewater_rapid_name">Name of the river rapids</string>
<string name="poi_outpost">Shop's delivery point</string> <string name="poi_outpost">Shop\'s delivery point</string>
</resources> </resources>

View file

@ -939,7 +939,7 @@ public class MapMarkersHelper {
} }
private void updateSyncGroupDisabled(@NonNull MapMarkersGroup group, boolean disabled) { private void updateSyncGroupDisabled(@NonNull MapMarkersGroup group, boolean disabled) {
List<MapMarker> groupMarkers = group.getMarkers(); List<MapMarker> groupMarkers = new ArrayList<>(group.getMarkers());
for (MapMarker marker : groupMarkers) { for (MapMarker marker : groupMarkers) {
if (marker.history) { if (marker.history) {
if (disabled) { if (disabled) {

View file

@ -127,7 +127,7 @@ public class ItemMenuBottomSheetDialogFragment extends MenuBottomSheetDialogFrag
} }
@Override @Override
protected int getCloseRowTextId() { protected int getDismissButtonTextId() {
return R.string.shared_string_close; return R.string.shared_string_close;
} }

View file

@ -4,6 +4,7 @@ import android.app.Activity;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes; import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -61,25 +62,49 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
View mainView = View.inflate(new ContextThemeWrapper(app, themeRes), R.layout.bottom_sheet_menu_base, null); View mainView = View.inflate(new ContextThemeWrapper(app, themeRes), R.layout.bottom_sheet_menu_base, null);
itemsContainer = (LinearLayout) mainView.findViewById(R.id.items_container); if (useScrollableItemsContainer()) {
itemsContainer = (LinearLayout) mainView.findViewById(R.id.scrollable_items_container);
} else {
mainView.findViewById(R.id.scroll_view).setVisibility(View.GONE);
itemsContainer = (LinearLayout) mainView.findViewById(R.id.non_scrollable_items_container);
itemsContainer.setVisibility(View.VISIBLE);
}
for (BaseBottomSheetItem item : items) { for (BaseBottomSheetItem item : items) {
item.inflate(app, itemsContainer, nightMode); item.inflate(app, itemsContainer, nightMode);
} }
int closeRowDividerColorId = getCloseRowDividerColorId(); int bottomDividerColorId = getBottomDividerColorId();
if (closeRowDividerColorId != -1) { if (bottomDividerColorId != -1) {
mainView.findViewById(R.id.close_row_divider) mainView.findViewById(R.id.bottom_row_divider).setBackgroundColor(getResolvedColor(bottomDividerColorId));
.setBackgroundColor(ContextCompat.getColor(getContext(), closeRowDividerColorId));
} }
mainView.findViewById(R.id.close_row).setOnClickListener(new View.OnClickListener() {
mainView.findViewById(R.id.dismiss_button).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
onCloseRowClickAction(); onDismissButtonClickAction();
dismiss(); dismiss();
} }
}); });
((TextView) mainView.findViewById(R.id.close_row_text)).setText(getCloseRowTextId()); ((TextView) mainView.findViewById(R.id.dismiss_button_text)).setText(getDismissButtonTextId());
int rightBottomButtonTextId = getRightBottomButtonTextId();
if (rightBottomButtonTextId != -1) {
View buttonsDivider = mainView.findViewById(R.id.bottom_buttons_divider);
buttonsDivider.setVisibility(View.VISIBLE);
if (bottomDividerColorId != -1) {
buttonsDivider.setBackgroundColor(getResolvedColor(bottomDividerColorId));
}
View rightButton = mainView.findViewById(R.id.right_bottom_button);
rightButton.setVisibility(View.VISIBLE);
rightButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onRightBottomButtonClick();
}
});
((TextView) rightButton.findViewById(R.id.right_bottom_button_text)).setText(rightBottomButtonTextId);
}
setupHeightAndBackground(mainView); setupHeightAndBackground(mainView);
@ -123,23 +148,27 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
return getIcon(id, nightMode ? R.color.osmand_orange : R.color.color_myloc_distance); return getIcon(id, nightMode ? R.color.osmand_orange : R.color.color_myloc_distance);
} }
@ColorInt
protected int getResolvedColor(@ColorRes int colorId) {
return ContextCompat.getColor(getContext(), colorId);
}
protected void setupHeightAndBackground(final View mainView) { protected void setupHeightAndBackground(final View mainView) {
final Activity activity = getActivity(); final Activity activity = getActivity();
final int screenHeight = AndroidUtils.getScreenHeight(activity); final int screenHeight = AndroidUtils.getScreenHeight(activity);
final int statusBarHeight = AndroidUtils.getStatusBarHeight(activity); final int statusBarHeight = AndroidUtils.getStatusBarHeight(activity);
final int navBarHeight = AndroidUtils.getNavBarHeight(activity); final int availableHeight = screenHeight - statusBarHeight - AndroidUtils.getNavBarHeight(activity)
- AndroidUtils.dpToPx(getContext(), 1) // divider height
- getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height); // bottom row height
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override @Override
public void onGlobalLayout() { public void onGlobalLayout() {
final View scrollView = mainView.findViewById(R.id.scroll_view); final View viewToAdjust = useScrollableItemsContainer() ? mainView.findViewById(R.id.scroll_view) : itemsContainer;
int scrollViewHeight = scrollView.getHeight(); if (viewToAdjust.getHeight() > availableHeight) {
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1); viewToAdjust.getLayoutParams().height = availableHeight;
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height); viewToAdjust.requestLayout();
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
if (scrollViewHeight > spaceForScrollView) {
scrollView.getLayoutParams().height = spaceForScrollView;
scrollView.requestLayout();
} }
// 8dp is the shadow height // 8dp is the shadow height
@ -160,17 +189,30 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
}); });
} }
protected boolean useScrollableItemsContainer() {
return true;
}
@ColorRes @ColorRes
protected int getCloseRowDividerColorId() { protected int getBottomDividerColorId() {
return -1; return -1;
} }
@StringRes @StringRes
protected int getCloseRowTextId() { protected int getDismissButtonTextId() {
return R.string.shared_string_cancel; return R.string.shared_string_cancel;
} }
protected void onCloseRowClickAction() { protected void onDismissButtonClickAction() {
}
@StringRes
protected int getRightBottomButtonTextId() {
return -1;
}
protected void onRightBottomButtonClick() {
} }

View file

@ -75,7 +75,7 @@ public class AddWaypointBottomSheetDialogFragment extends MenuBottomSheetDialogF
.create(); .create();
items.add(replaceStartItem); items.add(replaceStartItem);
items.add(new DividerHalfItem(getContext(), getCloseRowDividerColorId())); items.add(new DividerHalfItem(getContext(), getBottomDividerColorId()));
BaseBottomSheetItem subsequentDestItem = new BottomSheetItemWithDescription.Builder() BaseBottomSheetItem subsequentDestItem = new BottomSheetItemWithDescription.Builder()
.setDescription(getString(R.string.subsequent_dest_description)) .setDescription(getString(R.string.subsequent_dest_description))
@ -135,7 +135,7 @@ public class AddWaypointBottomSheetDialogFragment extends MenuBottomSheetDialogF
} }
@Override @Override
protected int getCloseRowDividerColorId() { protected int getBottomDividerColorId() {
return nightMode ? R.color.route_info_bottom_view_bg_dark : -1; return nightMode ? R.color.route_info_bottom_view_bg_dark : -1;
} }

View file

@ -790,10 +790,5 @@ public class ImportHelper {
.create(); .create();
items.add(asGpxItem); items.add(asGpxItem);
} }
@ColorInt
private int getResolvedColor(@ColorRes int colorId) {
return ContextCompat.getColor(getContext(), colorId);
}
} }
} }

View file

@ -1068,7 +1068,7 @@ public class WaypointDialogHelper {
} }
@Override @Override
protected int getCloseRowTextId() { protected int getDismissButtonTextId() {
return R.string.shared_string_close; return R.string.shared_string_close;
} }

View file

@ -77,6 +77,11 @@ public abstract class AddGroupBottomSheetDialogFragment extends MenuBottomSheetD
super.onDestroyView(); super.onDestroyView();
} }
@Override
protected boolean useScrollableItemsContainer() {
return false;
}
private void showProgressBar() { private void showProgressBar() {
mainView.findViewById(R.id.groups_recycler_view).setVisibility(View.GONE); mainView.findViewById(R.id.groups_recycler_view).setVisibility(View.GONE);
mainView.findViewById(R.id.progress_bar).setVisibility(View.VISIBLE); mainView.findViewById(R.id.progress_bar).setVisibility(View.VISIBLE);

View file

@ -6,7 +6,6 @@ import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.ColorRes; import android.support.annotation.ColorRes;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.view.View; import android.view.View;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
@ -122,7 +121,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
BaseBottomSheetItem formatItem = new BottomSheetItemWithCompoundButton.Builder() BaseBottomSheetItem formatItem = new BottomSheetItemWithCompoundButton.Builder()
.setChecked(selectedItem) .setChecked(selectedItem)
.setButtonTintList(selectedItem .setButtonTintList(selectedItem
? ColorStateList.valueOf(ContextCompat.getColor(context, getActiveColorId())) ? ColorStateList.valueOf(getResolvedColor(getActiveColorId()))
: null) : null)
.setIcon(selectedItem ? getActiveIcon(R.drawable.ic_action_coordinates_latitude) : formatIcon) .setIcon(selectedItem ? getActiveIcon(R.drawable.ic_action_coordinates_latitude) : formatIcon)
.setTitle(CoordinateInputFormats.formatToHumanString(context, format)) .setTitle(CoordinateInputFormats.formatToHumanString(context, format))
@ -142,7 +141,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
} }
@Override @Override
protected int getCloseRowTextId() { protected int getDismissButtonTextId() {
return R.string.shared_string_close; return R.string.shared_string_close;
} }

View file

@ -92,7 +92,7 @@ public class HistoryMarkerMenuBottomSheetDialogFragment extends MenuBottomSheetD
} }
@Override @Override
protected int getCloseRowTextId() { protected int getDismissButtonTextId() {
return R.string.shared_string_close; return R.string.shared_string_close;
} }

View file

@ -116,7 +116,7 @@ public class OrderByBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
} }
@Override @Override
protected int getCloseRowTextId() { protected int getDismissButtonTextId() {
return R.string.shared_string_close; return R.string.shared_string_close;
} }

View file

@ -121,7 +121,7 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends MenuBottomSheetDi
} }
@Override @Override
protected int getCloseRowTextId() { protected int getDismissButtonTextId() {
return R.string.shared_string_close; return R.string.shared_string_close;
} }

View file

@ -60,7 +60,7 @@ public class SelectionMarkersGroupBottomSheetDialogFragment extends MenuBottomSh
} }
@Override @Override
protected int getCloseRowTextId() { protected int getDismissButtonTextId() {
return R.string.shared_string_close; return R.string.shared_string_close;
} }

View file

@ -124,7 +124,7 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
} }
@Override @Override
protected int getCloseRowTextId() { protected int getDismissButtonTextId() {
return R.string.shared_string_close; return R.string.shared_string_close;
} }

View file

@ -130,12 +130,12 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo
} }
@Override @Override
protected int getCloseRowTextId() { protected int getDismissButtonTextId() {
return R.string.shared_string_close; return R.string.shared_string_close;
} }
@Override @Override
protected void onCloseRowClickAction() { protected void onDismissButtonClickAction() {
if (listener != null) { if (listener != null) {
listener.onClearSelection(); listener.onClearSelection();
} }

View file

@ -119,7 +119,7 @@ public class OsmEditOptionsBottomSheetDialogFragment extends MenuBottomSheetDial
} }
@Override @Override
protected int getCloseRowTextId() { protected int getDismissButtonTextId() {
return R.string.shared_string_close; return R.string.shared_string_close;
} }

View file

@ -4,7 +4,6 @@ import android.app.Dialog;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import net.osmand.data.LatLon;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
@ -23,6 +22,7 @@ public class ParkingTypeBottomSheetDialogFragment extends MenuBottomSheetDialogF
@Override @Override
public void createMenuItems(Bundle savedInstanceState) { public void createMenuItems(Bundle savedInstanceState) {
items.add(new TitleItem(getString(R.string.parking_options))); items.add(new TitleItem(getString(R.string.parking_options)));
BaseBottomSheetItem byTypeItem = new SimpleBottomSheetItem.Builder() BaseBottomSheetItem byTypeItem = new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(R.drawable.ic_action_time_start)) .setIcon(getContentIcon(R.drawable.ic_action_time_start))
.setTitle(getString(R.string.osmand_parking_no_lim_text)) .setTitle(getString(R.string.osmand_parking_no_lim_text))
@ -47,17 +47,18 @@ public class ParkingTypeBottomSheetDialogFragment extends MenuBottomSheetDialogF
} }
}) })
.create(); .create();
items.add(byDateItem); items.add(byDateItem);
} }
private void addParkingPosition(boolean limited) { private void addParkingPosition(boolean limited) {
Bundle args = getArguments();
double latitude = args.getDouble(LAT_KEY);
double longitude = args.getDouble(LON_KEY);
ParkingPositionPlugin plugin = OsmandPlugin.getEnabledPlugin(ParkingPositionPlugin.class); ParkingPositionPlugin plugin = OsmandPlugin.getEnabledPlugin(ParkingPositionPlugin.class);
MapActivity mapActivity = (MapActivity) getActivity();
if (plugin != null) { if (plugin != null) {
MapActivity mapActivity = (MapActivity) getActivity();
Bundle args = getArguments();
double latitude = args.getDouble(LAT_KEY);
double longitude = args.getDouble(LON_KEY);
if (plugin.isParkingEventAdded()) { if (plugin.isParkingEventAdded()) {
plugin.showDeleteEventWarning(mapActivity); plugin.showDeleteEventWarning(mapActivity);
} }