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"?>
<LinearLayout
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"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -13,7 +14,7 @@
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/items_container"
android:id="@+id/scrollable_items_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
@ -21,29 +22,73 @@
</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
android:id="@+id/close_row_divider"
android:id="@+id/bottom_row_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<FrameLayout
android:id="@+id/close_row"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
android:background="?attr/selectableItemBackground">
android:layout_height="@dimen/bottom_sheet_cancel_button_height">
<TextView
android:id="@+id/close_row_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"
android:textStyle="bold"
tools:text="@string/shared_string_cancel"/>
<FrameLayout
android:id="@+id/dismiss_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/selectableItemBackground">
</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>

View file

@ -3761,6 +3761,6 @@
<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>

View file

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

View file

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

View file

@ -4,6 +4,7 @@ import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
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;
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) {
item.inflate(app, itemsContainer, nightMode);
}
int closeRowDividerColorId = getCloseRowDividerColorId();
if (closeRowDividerColorId != -1) {
mainView.findViewById(R.id.close_row_divider)
.setBackgroundColor(ContextCompat.getColor(getContext(), closeRowDividerColorId));
int bottomDividerColorId = getBottomDividerColorId();
if (bottomDividerColorId != -1) {
mainView.findViewById(R.id.bottom_row_divider).setBackgroundColor(getResolvedColor(bottomDividerColorId));
}
mainView.findViewById(R.id.close_row).setOnClickListener(new View.OnClickListener() {
mainView.findViewById(R.id.dismiss_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onCloseRowClickAction();
onDismissButtonClickAction();
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);
@ -123,23 +148,27 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
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) {
final Activity activity = getActivity();
final int screenHeight = AndroidUtils.getScreenHeight(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() {
@Override
public void onGlobalLayout() {
final View scrollView = mainView.findViewById(R.id.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();
final View viewToAdjust = useScrollableItemsContainer() ? mainView.findViewById(R.id.scroll_view) : itemsContainer;
if (viewToAdjust.getHeight() > availableHeight) {
viewToAdjust.getLayoutParams().height = availableHeight;
viewToAdjust.requestLayout();
}
// 8dp is the shadow height
@ -160,17 +189,30 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
});
}
protected boolean useScrollableItemsContainer() {
return true;
}
@ColorRes
protected int getCloseRowDividerColorId() {
protected int getBottomDividerColorId() {
return -1;
}
@StringRes
protected int getCloseRowTextId() {
protected int getDismissButtonTextId() {
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();
items.add(replaceStartItem);
items.add(new DividerHalfItem(getContext(), getCloseRowDividerColorId()));
items.add(new DividerHalfItem(getContext(), getBottomDividerColorId()));
BaseBottomSheetItem subsequentDestItem = new BottomSheetItemWithDescription.Builder()
.setDescription(getString(R.string.subsequent_dest_description))
@ -135,7 +135,7 @@ public class AddWaypointBottomSheetDialogFragment extends MenuBottomSheetDialogF
}
@Override
protected int getCloseRowDividerColorId() {
protected int getBottomDividerColorId() {
return nightMode ? R.color.route_info_bottom_view_bg_dark : -1;
}

View file

@ -790,10 +790,5 @@ public class ImportHelper {
.create();
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
protected int getCloseRowTextId() {
protected int getDismissButtonTextId() {
return R.string.shared_string_close;
}

View file

@ -77,6 +77,11 @@ public abstract class AddGroupBottomSheetDialogFragment extends MenuBottomSheetD
super.onDestroyView();
}
@Override
protected boolean useScrollableItemsContainer() {
return false;
}
private void showProgressBar() {
mainView.findViewById(R.id.groups_recycler_view).setVisibility(View.GONE);
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.support.annotation.ColorRes;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.view.View;
import net.osmand.plus.OsmandSettings;
@ -122,7 +121,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
BaseBottomSheetItem formatItem = new BottomSheetItemWithCompoundButton.Builder()
.setChecked(selectedItem)
.setButtonTintList(selectedItem
? ColorStateList.valueOf(ContextCompat.getColor(context, getActiveColorId()))
? ColorStateList.valueOf(getResolvedColor(getActiveColorId()))
: null)
.setIcon(selectedItem ? getActiveIcon(R.drawable.ic_action_coordinates_latitude) : formatIcon)
.setTitle(CoordinateInputFormats.formatToHumanString(context, format))
@ -142,7 +141,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
}
@Override
protected int getCloseRowTextId() {
protected int getDismissButtonTextId() {
return R.string.shared_string_close;
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,7 +4,6 @@ import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import net.osmand.data.LatLon;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@ -23,6 +22,7 @@ public class ParkingTypeBottomSheetDialogFragment extends MenuBottomSheetDialogF
@Override
public void createMenuItems(Bundle savedInstanceState) {
items.add(new TitleItem(getString(R.string.parking_options)));
BaseBottomSheetItem byTypeItem = new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(R.drawable.ic_action_time_start))
.setTitle(getString(R.string.osmand_parking_no_lim_text))
@ -47,17 +47,18 @@ public class ParkingTypeBottomSheetDialogFragment extends MenuBottomSheetDialogF
}
})
.create();
items.add(byDateItem);
}
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);
MapActivity mapActivity = (MapActivity) getActivity();
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()) {
plugin.showDeleteEventWarning(mapActivity);
}