Merge branch 'master' into remove_waypoint

This commit is contained in:
Dmitriy Ruban 2020-07-02 18:08:31 +03:00 committed by GitHub
commit 806a7cf4f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 63 additions and 32 deletions

View file

@ -12,6 +12,7 @@
--> -->
<string name="quick_action_remove_next_destination_descr">The current destination point on the route will be deleted. If it will be the Destination, navigation will stop.</string> <string name="quick_action_remove_next_destination_descr">The current destination point on the route will be deleted. If it will be the Destination, navigation will stop.</string>
<string name="please_provide_point_name_error">Please provide a name for the point</string>
<string name="use_volume_buttons_as_zoom">Volume buttons as zoom</string> <string name="use_volume_buttons_as_zoom">Volume buttons as zoom</string>
<string name="use_volume_buttons_as_zoom_descr">Enable to control the map zoom level with device volume buttons.</string> <string name="use_volume_buttons_as_zoom_descr">Enable to control the map zoom level with device volume buttons.</string>
<string name="quick_action_remove_next_destination">Delete next destination point</string> <string name="quick_action_remove_next_destination">Delete next destination point</string>

View file

@ -559,9 +559,30 @@ public abstract class MenuController extends BaseMenuController implements Colla
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
if (mapActivity != null) { if (mapActivity != null) {
if (openingHoursInfo != null) { if (openingHoursInfo != null) {
StringBuilder sb = new StringBuilder();
int colorOpen = mapActivity.getResources().getColor(R.color.ctx_menu_amenity_opened_text_color); int colorOpen = mapActivity.getResources().getColor(R.color.ctx_menu_amenity_opened_text_color);
int colorClosed = mapActivity.getResources().getColor(R.color.ctx_menu_amenity_closed_text_color); int colorClosed = mapActivity.getResources().getColor(R.color.ctx_menu_amenity_closed_text_color);
return getSpannableOpeningHours(openingHoursInfo, colorOpen, colorClosed);
} else if (shouldShowMapSize()) {
return mapActivity.getString(R.string.file_size_in_mb, indexItem.getArchiveSizeMB());
}
}
return "";
}
@DrawableRes
public int getAdditionalInfoIconRes() {
if (openingHoursInfo != null) {
return R.drawable.ic_action_opening_hour_16;
} else if (shouldShowMapSize()) {
return R.drawable.ic_sdcard_16;
}
return 0;
}
public static SpannableString getSpannableOpeningHours(List<OpeningHours.Info> openingHoursInfo,
int colorOpen,
int colorClosed) {
StringBuilder sb = new StringBuilder();
int[] pos = new int[openingHoursInfo.size()]; int[] pos = new int[openingHoursInfo.size()];
for (int i = 0; i < openingHoursInfo.size(); i++) { for (int i = 0; i < openingHoursInfo.size(); i++) {
OpeningHours.Info info = openingHoursInfo.get(i); OpeningHours.Info info = openingHoursInfo.get(i);
@ -579,22 +600,6 @@ public abstract class MenuController extends BaseMenuController implements Colla
k = pos[i]; k = pos[i];
} }
return infoStr; return infoStr;
} else if (shouldShowMapSize()) {
return mapActivity.getString(R.string.file_size_in_mb, indexItem.getArchiveSizeMB());
}
}
return "";
}
@DrawableRes
public int getAdditionalInfoIconRes() {
if (openingHoursInfo != null) {
return R.drawable.ic_action_opening_hour_16;
} else if (shouldShowMapSize()) {
return R.drawable.ic_sdcard_16;
}
return 0;
} }
private boolean shouldShowMapSize() { private boolean shouldShowMapSize() {

View file

@ -11,6 +11,8 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
@ -163,7 +165,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
} }
}); });
view.findViewById(R.id.buttons_divider).setVisibility(View.VISIBLE); view.findViewById(R.id.buttons_divider).setVisibility(View.VISIBLE);
View saveButton = view.findViewById(R.id.right_bottom_button); final View saveButton = view.findViewById(R.id.right_bottom_button);
saveButton.setVisibility(View.VISIBLE); saveButton.setVisibility(View.VISIBLE);
saveButton.setOnClickListener(new View.OnClickListener() { saveButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -183,11 +185,32 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
UiUtilities.setupDialogButton(nightMode, cancelButton, UiUtilities.DialogButtonType.SECONDARY, R.string.shared_string_cancel); UiUtilities.setupDialogButton(nightMode, cancelButton, UiUtilities.DialogButtonType.SECONDARY, R.string.shared_string_cancel);
UiUtilities.setupDialogButton(nightMode, saveButton, UiUtilities.DialogButtonType.PRIMARY, R.string.shared_string_save); UiUtilities.setupDialogButton(nightMode, saveButton, UiUtilities.DialogButtonType.PRIMARY, R.string.shared_string_save);
TextInputLayout nameCaption = (TextInputLayout) view.findViewById(R.id.name_caption); final TextInputLayout nameCaption = (TextInputLayout) view.findViewById(R.id.name_caption);
nameCaption.setHint(getString(R.string.shared_string_name)); nameCaption.setHint(getString(R.string.shared_string_name));
nameEdit = (EditText) view.findViewById(R.id.name_edit); nameEdit = (EditText) view.findViewById(R.id.name_edit);
nameEdit.setText(getNameInitValue()); nameEdit.setText(getNameInitValue());
nameEdit.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if (s.toString().trim().isEmpty()) {
nameCaption.setError(app.getString(R.string.please_provide_point_name_error));
saveButton.setEnabled(false);
} else {
nameCaption.setError(null);
saveButton.setEnabled(true);
}
}
});
nameIcon = (ImageView) view.findViewById(R.id.name_icon); nameIcon = (ImageView) view.findViewById(R.id.name_icon);
TextView categoryEdit = view.findViewById(R.id.groupName); TextView categoryEdit = view.findViewById(R.id.groupName);
if (categoryEdit != null) { if (categoryEdit != null) {

View file

@ -3,6 +3,7 @@ package net.osmand.plus.search;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.text.SpannableString;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -13,7 +14,9 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.appcompat.view.ContextThemeWrapper; import androidx.appcompat.view.ContextThemeWrapper;
import androidx.core.content.ContextCompat;
import androidx.core.view.ViewCompat; import androidx.core.view.ViewCompat;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
@ -26,6 +29,7 @@ import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities.UpdateLocationViewCache; import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.search.listitems.QuickSearchHeaderListItem; import net.osmand.plus.search.listitems.QuickSearchHeaderListItem;
import net.osmand.plus.search.listitems.QuickSearchListItem; import net.osmand.plus.search.listitems.QuickSearchListItem;
import net.osmand.plus.search.listitems.QuickSearchListItemType; import net.osmand.plus.search.listitems.QuickSearchListItemType;
@ -402,19 +406,17 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
&& ((Amenity) listItem.getSearchResult().object).getOpeningHours() != null) { && ((Amenity) listItem.getSearchResult().object).getOpeningHours() != null) {
Amenity amenity = (Amenity) listItem.getSearchResult().object; Amenity amenity = (Amenity) listItem.getSearchResult().object;
OpeningHoursParser.OpeningHours rs = OpeningHoursParser.parseOpenedHours(amenity.getOpeningHours()); OpeningHoursParser.OpeningHours rs = OpeningHoursParser.parseOpenedHours(amenity.getOpeningHours());
if (rs != null) { if (rs != null && rs.getInfo() != null) {
Calendar inst = Calendar.getInstance(); int colorOpen = R.color.ctx_menu_amenity_opened_text_color;
inst.setTimeInMillis(System.currentTimeMillis()); int colorClosed = R.color.ctx_menu_amenity_closed_text_color;
boolean worksNow = !amenity.isClosed() && rs.isOpenedForTime(inst); SpannableString openHours = MenuController.getSpannableOpeningHours(
inst.setTimeInMillis(System.currentTimeMillis() + 30 * 60 * 1000); // 30 minutes later rs.getInfo(),
boolean worksLater = rs.isOpenedForTime(inst); ContextCompat.getColor(app, colorOpen),
int colorId = worksNow ? worksLater ? R.color.color_ok : R.color.color_intermediate : R.color.color_warning; ContextCompat.getColor(app, colorClosed));
int colorId = rs.isOpenedForTime(Calendar.getInstance()) ? colorOpen : colorClosed;
timeLayout.setVisibility(View.VISIBLE); timeLayout.setVisibility(View.VISIBLE);
timeIcon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_time_16, colorId)); timeIcon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_time_16, colorId));
timeText.setTextColor(app.getResources().getColor(colorId)); timeText.setText(openHours);
String rt = amenity.isClosed() ? app.getResources().getString(R.string.poi_operational_status_closed) : rs.getCurrentRuleTime(inst);
timeText.setText(rt == null ? "" : rt);
} else { } else {
timeLayout.setVisibility(View.GONE); timeLayout.setVisibility(View.GONE);
} }