Fix opening hours UI
This commit is contained in:
parent
6fbfbf1b65
commit
c8c2f03989
8 changed files with 32 additions and 10 deletions
|
@ -1016,7 +1016,7 @@ public class OpeningHoursParser {
|
|||
if (b.charAt(b.length() - 1) != ' ') {
|
||||
b.append(" ");
|
||||
}
|
||||
b.append("(").append(comment).append(")");
|
||||
b.append("- ").append(comment);
|
||||
} else {
|
||||
b.append(comment);
|
||||
}
|
||||
|
@ -1136,7 +1136,7 @@ public class OpeningHoursParser {
|
|||
}
|
||||
String res = sb.toString();
|
||||
if (res.length() > 0 && !Algorithms.isEmpty(comment)) {
|
||||
res += " (" + comment + ")";
|
||||
res += " - " + comment;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -108,6 +108,15 @@
|
|||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="Museum"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/additional_info_image_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top"
|
||||
android:paddingTop="1dp"
|
||||
android:paddingRight="@dimen/context_menu_padding_margin_small"
|
||||
tools:src="@drawable/ic_action_opening_hour_16"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/additional_info_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -1182,7 +1182,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
|
||||
public int getAdditionalInfoColor() {
|
||||
if (menuController != null) {
|
||||
return menuController.getAdditionalInfoColor();
|
||||
return menuController.getAdditionalInfoColorId();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1360,8 +1360,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
line3.setCompoundDrawablePadding(dpToPx(5f));
|
||||
}
|
||||
|
||||
ImageView additionalInfoImageView = (ImageView) view.findViewById(R.id.additional_info_image_view);
|
||||
TextView additionalInfoTextView = (TextView) view.findViewById(R.id.additional_info_text_view);
|
||||
CharSequence additionalInfoStr = menu.getAdditionalInfo();
|
||||
boolean showAdditionalImage = false;
|
||||
if (!TextUtils.isEmpty(additionalInfoStr)) {
|
||||
int colorId = menu.getAdditionalInfoColor();
|
||||
int additionalInfoIconRes = menu.getAdditionalInfoIconRes();
|
||||
|
@ -1369,8 +1371,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
additionalInfoTextView.setTextColor(ContextCompat.getColor(getContext(), colorId));
|
||||
if (additionalInfoIconRes != 0) {
|
||||
Drawable additionalIcon = getIcon(additionalInfoIconRes, colorId);
|
||||
additionalInfoTextView.setCompoundDrawablesWithIntrinsicBounds(additionalIcon, null, null, null);
|
||||
additionalInfoTextView.setCompoundDrawablePadding(dpToPx(8));
|
||||
additionalInfoImageView.setImageDrawable(additionalIcon);
|
||||
showAdditionalImage = true;
|
||||
}
|
||||
}
|
||||
additionalInfoTextView.setText(additionalInfoStr);
|
||||
|
@ -1378,6 +1380,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
} else {
|
||||
additionalInfoTextView.setVisibility(View.GONE);
|
||||
}
|
||||
additionalInfoImageView.setVisibility(showAdditionalImage ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
updateCompassVisibility();
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.graphics.drawable.Drawable;
|
|||
import android.graphics.drawable.StateListDrawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
@ -478,9 +479,17 @@ public abstract class MenuController extends BaseMenuController implements Colla
|
|||
return "";
|
||||
}
|
||||
|
||||
public int getAdditionalInfoColor() {
|
||||
@ColorRes
|
||||
public int getAdditionalInfoColorId() {
|
||||
if (openingHoursInfo != null) {
|
||||
return 0;
|
||||
boolean open = false;
|
||||
for (OpeningHours.Info info : openingHoursInfo) {
|
||||
if (info.isOpened() || info.isOpened24_7()) {
|
||||
open = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return open ? R.color.ctx_menu_amenity_opened_text_color : R.color.ctx_menu_amenity_closed_text_color;
|
||||
} else if (indexItem != null) {
|
||||
return R.color.icon_color;
|
||||
}
|
||||
|
@ -516,6 +525,7 @@ public abstract class MenuController extends BaseMenuController implements Colla
|
|||
return "";
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
public int getAdditionalInfoIconRes() {
|
||||
if (openingHoursInfo != null) {
|
||||
return R.drawable.ic_action_opening_hour_16;
|
||||
|
|
|
@ -191,7 +191,7 @@ public class MapDataMenuController extends MenuController {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getAdditionalInfoColor() {
|
||||
public int getAdditionalInfoColorId() {
|
||||
return R.color.icon_color;
|
||||
}
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ public class EditPOIMenuController extends MenuController {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getAdditionalInfoColor() {
|
||||
public int getAdditionalInfoColorId() {
|
||||
if (osmPoint.getAction() == Action.DELETE) {
|
||||
return R.color.color_osm_edit_delete;
|
||||
} else if (osmPoint.getAction() == Action.MODIFY || osmPoint.getAction() == Action.REOPEN) {
|
||||
|
|
|
@ -73,7 +73,7 @@ public class ParkingPositionMenuController extends MenuController {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getAdditionalInfoColor() {
|
||||
public int getAdditionalInfoColorId() {
|
||||
return plugin.getParkingType() ? R.color.ctx_menu_amenity_closed_text_color : R.color.icon_color;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue