Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2018-03-05 22:41:01 +01:00
commit 1a3e203b1d
8 changed files with 130 additions and 59 deletions

View file

@ -284,7 +284,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
getString(R.string.lang_af) + incompleteSuffix,
getString(R.string.lang_ar),
getString(R.string.lang_ast) + incompleteSuffix,
getString(R.string.lang_az) + incompleteSuffix,
getString(R.string.lang_az),
getString(R.string.lang_be),
getString(R.string.lang_be_by),
getString(R.string.lang_bg),

View file

@ -41,7 +41,7 @@ public class TransportStopRouteAdapter extends ArrayAdapter<TransportStopRoute>
TransportStopRoute transportStopRoute = getItem(position);
if (transportStopRoute != null) {
TextView transportStopRouteTextView = (TextView) convertView.findViewById(R.id.transport_stop_route_text);
transportStopRouteTextView.setText(transportStopRoute.route.getRef());
transportStopRouteTextView.setText(getAdjustedRouteRef(transportStopRoute.route.getRef()));
GradientDrawable gradientDrawableBg = (GradientDrawable) transportStopRouteTextView.getBackground();
gradientDrawableBg.setColor(transportStopRoute.getColor(app, nightMode));
}
@ -58,6 +58,19 @@ public class TransportStopRouteAdapter extends ArrayAdapter<TransportStopRoute>
return convertView;
}
private String getAdjustedRouteRef(String ref) {
if (ref != null) {
int charPos = ref.lastIndexOf(':');
if (charPos != -1) {
ref = ref.substring(0, charPos);
}
if (ref.length() > 4) {
ref = ref.substring(0, 4);
}
}
return ref;
}
public interface OnClickListener {
void onClick(int position);
}

View file

@ -1,6 +1,7 @@
package net.osmand.plus.mapcontextmenu;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
@ -181,7 +182,7 @@ public class WikipediaDialogFragment extends DialogFragment {
@Override
public void onClick(View view) {
String article = "https://" + langSelected.toLowerCase() + ".wikipedia.org/wiki/" + title.replace(' ', '_');
showFullArticle(Uri.parse(article));
showFullArticle(getContext(), Uri.parse(article), darkMode);
}
});
@ -207,16 +208,16 @@ public class WikipediaDialogFragment extends DialogFragment {
}
}
private void showFullArticle(Uri uri) {
public static void showFullArticle(Context context, Uri uri, boolean nightMode) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder()
.setToolbarColor(ContextCompat.getColor(getContext(), darkMode ? R.color.actionbar_dark_color : R.color.actionbar_light_color))
.setToolbarColor(ContextCompat.getColor(context, nightMode ? R.color.actionbar_dark_color : R.color.actionbar_light_color))
.build();
customTabsIntent.launchUrl(getContext(), uri);
customTabsIntent.launchUrl(context, uri);
} else {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(uri);
startActivity(i);
context.startActivity(i);
}
}

View file

@ -290,9 +290,13 @@ public class AmenityMenuBuilder extends MenuBuilder {
ll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(text));
v.getContext().startActivity(intent);
if (text.contains(".wikipedia.org/w")) {
WikipediaDialogFragment.showFullArticle(v.getContext(), Uri.parse(text), !light);
} else {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(text));
v.getContext().startActivity(intent);
}
}
});
} else if (isWiki) {

View file

@ -16,7 +16,6 @@ import net.osmand.AndroidUtils;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu.MenuObject;
import net.osmand.plus.widgets.TextViewEx;
import java.util.LinkedList;
import java.util.List;
@ -37,6 +36,7 @@ public class MapMultiSelectionMenuFragment extends Fragment implements MultiSele
menu = ((MapActivity) getActivity()).getContextMenu().getMultiSelectionMenu();
view = inflater.inflate(R.layout.menu_obj_selection_fragment, container, false);
if (menu.isLandscapeLayout()) {
AndroidUtils.setBackground(view.getContext(), view, !menu.isLight(),
R.drawable.multi_selection_menu_bg_light_land, R.drawable.multi_selection_menu_bg_dark_land);
@ -58,15 +58,18 @@ public class MapMultiSelectionMenuFragment extends Fragment implements MultiSele
runLayoutListener();
view.findViewById(R.id.divider).setBackgroundColor(ContextCompat.getColor(getContext(), menu.isLight() ? R.color.multi_selection_menu_divider_light : R.color.multi_selection_menu_divider_dark));
view.findViewById(R.id.divider).setBackgroundColor(ContextCompat.getColor(getContext(), menu.isLight()
? R.color.multi_selection_menu_divider_light : R.color.multi_selection_menu_divider_dark));
((TextView) view.findViewById(R.id.cancel_row_text)).setTextColor(ContextCompat.getColor(getContext(), menu.isLight() ? R.color.multi_selection_menu_close_btn_light : R.color.multi_selection_menu_close_btn_dark));
((TextView) view.findViewById(R.id.cancel_row_text)).setTextColor(ContextCompat.getColor(getContext(),
menu.isLight() ? R.color.multi_selection_menu_close_btn_light : R.color.multi_selection_menu_close_btn_dark));
view.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismissMenu();
}
});
return view;
}
@ -148,7 +151,8 @@ public class MapMultiSelectionMenuFragment extends Fragment implements MultiSele
int maxHeight = (int) (headerHeight + cancelRowHeight);
for (int i = 0; i < 3; i++) {
View childView = listAdapter.getView(0, null, (ListView) contentView.findViewById(R.id.list));
childView.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
childView.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
maxHeight += childView.getMeasuredHeight();
}
int height = contentView.getHeight();

View file

@ -4,6 +4,8 @@ package net.osmand.plus.parkingpoint;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AlertDialog;
import android.text.format.DateFormat;
import android.text.format.Time;
@ -242,49 +244,16 @@ public class ParkingPositionPlugin extends OsmandPlugin {
* It allows user to choose a type of parking (time-limited or time-unlimited).
*/
public void showAddParkingDialog(final MapActivity mapActivity, final double latitude, final double longitude) {
final boolean wasEventPreviouslyAdded = isParkingEventAdded();
final ContextMenuAdapter menuAdapter = new ContextMenuAdapter();
ContextMenuItem.ItemBuilder itemBuilder = new ContextMenuItem.ItemBuilder();
menuAdapter.addItem(itemBuilder.setTitleId(R.string.osmand_parking_no_lim_text, app)
.setIcon(R.drawable.ic_action_time_start).setTag(1).createItem());
menuAdapter.addItem(itemBuilder.setTitleId(R.string.osmand_parking_time_limit, app)
.setIcon(R.drawable.ic_action_time_span).setTag(2).createItem());
final AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
boolean light = app.getSettings().isLightContent();
final ArrayAdapter<ContextMenuItem> listAdapter = menuAdapter.createListAdapter(mapActivity, light);
builder.setTitle(R.string.parking_options);
builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(final DialogInterface dialog, int which) {
ContextMenuItem item = menuAdapter.getItem(which);
int index = item.getTag();
if (index == 1) {
dialog.dismiss();
if (wasEventPreviouslyAdded) {
showDeleteEventWarning(mapActivity);
}
addOrRemoveParkingEvent(false);
setParkingPosition(mapActivity, latitude, longitude, false);
showContextMenuIfNeeded(mapActivity,true);
mapActivity.getMapView().refreshMap();
} else if (index == 2) {
if (wasEventPreviouslyAdded) {
showDeleteEventWarning(mapActivity);
}
setParkingPosition(mapActivity, latitude, longitude, true);
showSetTimeLimitDialog(mapActivity, dialog);
mapActivity.getMapView().refreshMap();
}
}
});
builder.setNegativeButton(R.string.shared_string_cancel, null);
builder.create().show();
Bundle args = new Bundle();
args.putDouble(ParkingTypeBottomSheetDialogFragment.LAT_KEY, latitude);
args.putDouble(ParkingTypeBottomSheetDialogFragment.LON_KEY, longitude);
FragmentManager fragmentManager=mapActivity.getSupportFragmentManager();
ParkingTypeBottomSheetDialogFragment fragment = new ParkingTypeBottomSheetDialogFragment();
fragment.setArguments(args);
fragment.show(fragmentManager, ParkingTypeBottomSheetDialogFragment.TAG);
}
private void showContextMenuIfNeeded(final MapActivity mapActivity, boolean animated) {
void showContextMenuIfNeeded(final MapActivity mapActivity, boolean animated) {
if (parkingLayer != null) {
MapContextMenu menu = mapActivity.getContextMenu();
if (menu.isVisible()) {
@ -324,7 +293,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
* @param mapActivity
* @param choose
*/
private void showSetTimeLimitDialog(final MapActivity mapActivity, final DialogInterface choose) {
void showSetTimeLimitDialog(final MapActivity mapActivity, final DialogInterface choose) {
final View setTimeParking = mapActivity.getLayoutInflater().inflate(R.layout.parking_set_time_limit, null);
AlertDialog.Builder setTime = new AlertDialog.Builder(mapActivity);
setTime.setView(setTimeParking);
@ -414,7 +383,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
* Method shows warning, if previously the event for time-limited parking was added to Calendar app.
* @param activity
*/
private void showDeleteEventWarning(final Activity activity) {
void showDeleteEventWarning(final Activity activity) {
if (isParkingEventAdded()) {
AlertDialog.Builder deleteEventWarning = new AlertDialog.Builder(activity);
deleteEventWarning.setTitle(activity.getString(R.string.osmand_parking_warning));
@ -436,7 +405,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
* @param longitude
* @param isLimited
*/
private void setParkingPosition(final MapActivity mapActivity, final double latitude, final double longitude, boolean isLimited) {
void setParkingPosition(final MapActivity mapActivity, final double latitude, final double longitude, boolean isLimited) {
setParkingPosition(latitude, longitude);
setParkingType(isLimited);
setParkingStartTime(Calendar.getInstance().getTimeInMillis());

View file

@ -0,0 +1,77 @@
package net.osmand.plus.parkingpoint;
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;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
public class ParkingTypeBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
public static final String TAG = "ParkingTypeBottomSheetDialogFragment";
public static final String LAT_KEY = "latitude";
public static final String LON_KEY = "longitude";
@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))
.setLayoutId(R.layout.bottom_sheet_item_simple)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
addParkingPosition(false);
}
})
.create();
items.add(byTypeItem);
BaseBottomSheetItem byDateItem = new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(R.drawable.ic_action_time_span))
.setTitle(getString(R.string.osmand_parking_time_limit))
.setLayoutId(R.layout.bottom_sheet_item_simple)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
addParkingPosition(true);
}
})
.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) {
if (plugin.isParkingEventAdded()) {
plugin.showDeleteEventWarning(mapActivity);
}
if (limited) {
plugin.setParkingPosition(mapActivity, latitude, longitude, true);
plugin.showSetTimeLimitDialog(mapActivity, new Dialog(getContext()));
mapActivity.refreshMap();
} else {
plugin.addOrRemoveParkingEvent(false);
plugin.setParkingPosition(mapActivity, latitude, longitude, false);
plugin.showContextMenuIfNeeded(mapActivity, true);
mapActivity.refreshMap();
}
}
dismiss();
}
}

View file

@ -216,7 +216,10 @@ public class MapMarkersWidgetsFactory {
}
boolean mapLinkedToLoc = map.getMapViewTrackingUtilities().isMapLinkedToLocation();
Float heading = !mapLinkedToLoc ? 0f : map.getMapViewTrackingUtilities().getHeading();
Float heading = 0f;
if (mapLinkedToLoc) {
heading = map.getMapViewTrackingUtilities().getHeading();
}
MapMarker marker = markers.get(0);
updateUI(loc, heading, marker, arrowImg, distText, okButton, addressText, true, customLocation != null);