Add info about 24/7
This commit is contained in:
parent
dc1bf40158
commit
358166b4b4
7 changed files with 118 additions and 19 deletions
|
@ -186,6 +186,14 @@ public class OpeningHoursParser {
|
|||
return isOpenDay || isOpenPrevious;
|
||||
}
|
||||
|
||||
public boolean isOpen24_7() {
|
||||
boolean open24_7 = false;
|
||||
for (OpeningHoursRule r : rules) {
|
||||
open24_7 = r.isOpen24_7();
|
||||
}
|
||||
return open24_7;
|
||||
}
|
||||
|
||||
public String getCurrentRuleTime(Calendar cal) {
|
||||
// make exception for overlapping times i.e.
|
||||
// (1) Mo 14:00-16:00; Tu off
|
||||
|
@ -341,6 +349,8 @@ public class OpeningHoursParser {
|
|||
public String toRuleString();
|
||||
|
||||
public String toLocalRuleString();
|
||||
|
||||
boolean isOpen24_7();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -628,7 +638,6 @@ public class OpeningHoursParser {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toRuleString() {
|
||||
return toRuleString(daysStr, monthsStr);
|
||||
|
@ -658,24 +667,17 @@ public class OpeningHoursParser {
|
|||
addArray(dayMonths, null, b);
|
||||
}
|
||||
// Day
|
||||
boolean open24_7 = true;
|
||||
for (int i = 0; i < 7; i++) {
|
||||
if (!days[i]) {
|
||||
open24_7 = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
appendDaysString(b, dayNames);
|
||||
// Time
|
||||
if (startTimes == null || startTimes.size() == 0) {
|
||||
b.append("off");
|
||||
} else {
|
||||
if (isOpen24_7()) {
|
||||
return "24/7";
|
||||
}
|
||||
for (int i = 0; i < startTimes.size(); i++) {
|
||||
int startTime = startTimes.get(i);
|
||||
int endTime = endTimes.get(i);
|
||||
if (open24_7 && startTime == 0 && endTime / 60 == 24) {
|
||||
return "24/7";
|
||||
}
|
||||
if(i > 0) {
|
||||
b.append(", ");
|
||||
}
|
||||
|
@ -725,6 +727,28 @@ public class OpeningHoursParser {
|
|||
return toRuleString(localDaysStr, localMothsStr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen24_7() {
|
||||
boolean open24_7 = true;
|
||||
for (int i = 0; i < 7; i++) {
|
||||
if (!days[i]) {
|
||||
open24_7 = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (open24_7 && startTimes != null && startTimes.size() > 0) {
|
||||
for (int i = 0; i < startTimes.size(); i++) {
|
||||
int startTime = startTimes.get(i);
|
||||
int endTime = endTimes.get(i);
|
||||
if (startTime == 0 && endTime / 60 == 24) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toRuleString();
|
||||
|
@ -915,6 +939,11 @@ public class OpeningHoursParser {
|
|||
return toRuleString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen24_7() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toRuleString();
|
||||
|
|
|
@ -82,16 +82,25 @@
|
|||
android:layout_height="@dimen/context_menu_sub_info_height"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
tools:text="Closed till 10:00"
|
||||
android:id="@+id/context_menu_line3"
|
||||
<LinearLayout
|
||||
android:id="@+id/opening_hours_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text=" • "/>
|
||||
<TextView
|
||||
tools:text="Closed till 10:00"
|
||||
android:id="@+id/opening_hours_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/context_menu_padding_margin_default"
|
||||
android:paddingRight="@dimen/context_menu_padding_margin_default"
|
||||
android:text="•"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/compass_layout"
|
||||
|
|
|
@ -343,5 +343,7 @@
|
|||
<color name="ctx_menu_bottom_view_icon">#505050</color>
|
||||
<color name="ctx_menu_bottom_view_text_color_light">#212121</color>
|
||||
<color name="ctx_menu_bottom_view_text_color_dark">#cccccc</color>
|
||||
<color name="ctx_menu_amenity_opened_text_color">#5baf3f</color>
|
||||
<color name="ctx_menu_amenity_closed_text_color">#c66545</color>
|
||||
|
||||
</resources>
|
|
@ -1103,6 +1103,16 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
}
|
||||
line2.setText(line2Str.toString());
|
||||
}
|
||||
|
||||
View openingHoursView = view.findViewById(R.id.opening_hours_view);
|
||||
TextView openingHoursTextView = (TextView) view.findViewById(R.id.opening_hours_text_view);
|
||||
openingHoursTextView.setTextColor(ContextCompat.getColor(getContext(), menu.isOpened() ? R.color.ctx_menu_amenity_opened_text_color : R.color.ctx_menu_amenity_closed_text_color));
|
||||
if (menu.isOpen24_7()) {
|
||||
openingHoursTextView.setText(getString(R.string.shared_string_is_open_24_7));
|
||||
openingHoursView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
openingHoursView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
updateCompassVisibility();
|
||||
}
|
||||
|
|
|
@ -424,6 +424,10 @@ public abstract class MenuController extends BaseMenuController {
|
|||
return "";
|
||||
}
|
||||
|
||||
public boolean isOpen24_7() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getCommonTypeStr() {
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ public abstract class MenuTitleController {
|
|||
protected String commonTypeStr = "";
|
||||
protected Drawable secondLineTypeIcon;
|
||||
protected String streetStr = "";
|
||||
protected boolean open24_7;
|
||||
|
||||
private AddressLookupRequest addressLookupRequest;
|
||||
|
||||
|
@ -98,6 +99,18 @@ public abstract class MenuTitleController {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isOpen24_7() {
|
||||
return open24_7;
|
||||
}
|
||||
|
||||
public boolean isOpened() {
|
||||
if (isOpen24_7()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void initTitle() {
|
||||
searchAddressStr = PointDescription.getSearchAddressStr(getMapActivity());
|
||||
addressNotFoundStr = PointDescription.getAddressNotFoundStr(getMapActivity());
|
||||
|
@ -111,6 +124,8 @@ public abstract class MenuTitleController {
|
|||
if (needStreetName()) {
|
||||
acquireStreetName();
|
||||
}
|
||||
|
||||
acquireOpeningHoursData();
|
||||
}
|
||||
|
||||
protected boolean needStreetName() {
|
||||
|
@ -186,6 +201,13 @@ public abstract class MenuTitleController {
|
|||
getMapActivity().getMyApplication().getGeocodingLookupService().lookupAddress(addressLookupRequest);
|
||||
}
|
||||
|
||||
protected void acquireOpeningHoursData() {
|
||||
MenuController menuController = getMenuController();
|
||||
if (menuController != null) {
|
||||
open24_7 = menuController.isOpen24_7();
|
||||
}
|
||||
}
|
||||
|
||||
protected void onSearchAddressDone() {
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,10 @@ import net.osmand.plus.resources.TransportIndexRepository;
|
|||
import net.osmand.plus.views.TransportStopsLayer;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
import net.osmand.util.OpeningHoursParser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
@ -116,6 +118,11 @@ public class AmenityMenuController extends MenuController {
|
|||
return getTypeStr(amenity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen24_7() {
|
||||
return isOpen24_7(amenity);
|
||||
}
|
||||
|
||||
public static String getTypeStr(Amenity amenity) {
|
||||
PoiCategory pc = amenity.getType();
|
||||
PoiType pt = pc.getPoiTypeByKeyName(amenity.getSubType());
|
||||
|
@ -128,6 +135,22 @@ public class AmenityMenuController extends MenuController {
|
|||
return typeStr;
|
||||
}
|
||||
|
||||
public static boolean isOpen24_7(Amenity amenity) {
|
||||
boolean isOpen24_7 = false;
|
||||
OpeningHoursParser.OpeningHours openingHours = OpeningHoursParser.parseOpenedHours(amenity.getOpeningHours());
|
||||
if (openingHours == null) {
|
||||
isOpen24_7 = false;
|
||||
} else {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
if (openingHours.isOpenedForTime(calendar)) {
|
||||
if (openingHours.isOpen24_7()) {
|
||||
isOpen24_7 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isOpen24_7;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommonTypeStr() {
|
||||
PoiCategory pc = amenity.getType();
|
||||
|
|
Loading…
Reference in a new issue