Skip to content

Commit

Permalink
Merge branch 'organicmaps:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
d4f5409d authored Aug 5, 2024
2 parents a794d7c + e9616ed commit 67ac45d
Show file tree
Hide file tree
Showing 93 changed files with 1,264 additions and 84 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/coverage-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ jobs:
shell: bash
working-directory: build
env:
# drape_tests - requires X Window
QT_QPA_PLATFORM: "offscreen"
# generator_integration_tests - https://github.com/organicmaps/organicmaps/issues/225
# opening_hours_integration_tests - https://github.com/organicmaps/organicmaps/issues/219
# opening_hours_supported_features_tests - https://github.com/organicmaps/organicmaps/issues/219
# routing_integration_tests - https://github.com/organicmaps/organicmaps/issues/221
# shaders_tests - https://github.com/organicmaps/organicmaps/issues/223
# world_feed_integration_tests - https://github.com/organicmaps/organicmaps/issues/215
CTEST_EXCLUDE_REGEX: "drape_tests|generator_integration_tests|opening_hours_integration_tests|opening_hours_supported_features_tests|routing_benchmarks|routing_integration_tests|routing_quality_tests|search_quality_tests|storage_integration_tests|shaders_tests|world_feed_integration_tests"
CTEST_EXCLUDE_REGEX: "generator_integration_tests|opening_hours_integration_tests|opening_hours_supported_features_tests|routing_benchmarks|routing_integration_tests|routing_quality_tests|search_quality_tests|storage_integration_tests|shaders_tests|world_feed_integration_tests"
run: |
sudo locale-gen en_US
sudo locale-gen en_US.UTF-8
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/linux-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,14 @@ jobs:
shell: bash
working-directory: build
env:
# drape_tests - requires X Window
QT_QPA_PLATFORM: "offscreen"
# generator_integration_tests - https://github.com/organicmaps/organicmaps/issues/225
# opening_hours_integration_tests - https://github.com/organicmaps/organicmaps/issues/219
# opening_hours_supported_features_tests - https://github.com/organicmaps/organicmaps/issues/219
# routing_integration_tests - https://github.com/organicmaps/organicmaps/issues/221
# shaders_tests - https://github.com/organicmaps/organicmaps/issues/223
# world_feed_integration_tests - https://github.com/organicmaps/organicmaps/issues/215
CTEST_EXCLUDE_REGEX: "drape_tests|generator_integration_tests|opening_hours_integration_tests|opening_hours_supported_features_tests|routing_benchmarks|routing_integration_tests|routing_quality_tests|search_quality_tests|storage_integration_tests|shaders_tests|world_feed_integration_tests"
CTEST_EXCLUDE_REGEX: "generator_integration_tests|opening_hours_integration_tests|opening_hours_supported_features_tests|routing_benchmarks|routing_integration_tests|routing_quality_tests|search_quality_tests|storage_integration_tests|shaders_tests|world_feed_integration_tests"
run: |
sudo locale-gen en_US
sudo locale-gen en_US.UTF-8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ public enum MetadataType
FMD_WHEELCHAIR(43),
FMD_LOCAL_REF(44),
FMD_DRIVE_THROUGH(45),
FMD_WEBSITE_MENU(46);
FMD_WEBSITE_MENU(46),
FMD_SELF_SERVICE(47),
FMD_OUTDOOR_SEATING(48);
private final int mMetaType;

MetadataType(int metadataType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public class LanesDrawable extends Drawable
@ColorRes
private static final int ACTIVE_LANE_TINT_RES = R.color.white_primary;
@ColorRes
private static final int INACTIVE_LANE_TINT_RES = R.color.icon_tint_light;
private static final int INACTIVE_LANE_TINT_RES = R.color.white_38;
@ColorRes
private static final int INACTIVE_LANE_TINT_NIGHT_RES = R.color.icon_tint_light_night;
private static final int INACTIVE_LANE_TINT_NIGHT_RES = R.color.white_40;

@DimenRes
private static final int MARGIN_RES = R.dimen.margin_quarter;
Expand Down
11 changes: 11 additions & 0 deletions android/app/src/main/java/app/organicmaps/editor/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ public static void nativeSetBuildingLevels(String levels)
public static native boolean nativeHasWifi();
public static native void nativeSetHasWifi(boolean hasWifi);

public static void nativeSetSwitchInput(int id, Boolean switchValue, String checkedValue, String uncheckedValue)
{
nativeSetMetadata(id, switchValue ? checkedValue : uncheckedValue);
}

public static boolean nativeGetSwitchInput(int id, String checkedValue)
{
String value = nativeGetMetadata(id);
return value.equals(checkedValue);
}

public static native boolean nativeIsAddressEditable();
public static native boolean nativeIsNameEditable();
public static native boolean nativeIsPointType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount)
private TextView mEditPhoneLink;
private TextView mCuisine;
private SwitchCompat mWifi;
private TextView mSelfService;
private SwitchCompat mOutdoorSeating;

// Default Metadata entries.
private static final class MetadataEntry
Expand Down Expand Up @@ -192,8 +194,11 @@ public void onTextChanged(CharSequence s, int start, int before, int count)
initMetadataEntry(Metadata.MetadataType.FMD_CONTACT_LINE, R.string.error_enter_correct_line_page);

mCuisine.setText(Editor.nativeGetFormattedCuisine());
String selfServiceMetadata = Editor.nativeGetMetadata(Metadata.MetadataType.FMD_SELF_SERVICE.toInt());
mSelfService.setText(Utils.getTagValueLocalized(view.getContext(), "self_service", selfServiceMetadata));
initMetadataEntry(Metadata.MetadataType.FMD_OPERATOR, 0);
mWifi.setChecked(Editor.nativeHasWifi());
mOutdoorSeating.setChecked(Editor.nativeGetSwitchInput(Metadata.MetadataType.FMD_OUTDOOR_SEATING.toInt(),"yes"));
refreshOpeningTime();
refreshEditableFields();
refreshResetButton();
Expand All @@ -216,6 +221,8 @@ boolean setEdits()
Editor.nativeSetHasWifi(mWifi.isChecked());
Editor.nativeSetNames(mParent.getNamesAsArray());

Editor.nativeSetSwitchInput(Metadata.MetadataType.FMD_OUTDOOR_SEATING.toInt(), mOutdoorSeating.isChecked(), "yes", "no");

for (var e : mMetadata.entrySet())
Editor.nativeSetMetadata(e.getKey().toInt(), e.getValue().mEdit.getText().toString());

Expand Down Expand Up @@ -452,6 +459,14 @@ private void initViews(View view)
View blockWifi = view.findViewById(R.id.block_wifi);
mWifi = view.findViewById(R.id.sw__wifi);
blockWifi.setOnClickListener(this);

View blockSelfService = view.findViewById(R.id.block_self_service);
blockSelfService.setOnClickListener(this);
mSelfService = view.findViewById(R.id.self_service);

View blockOutdoorSeating = view.findViewById(R.id.block_outdoor_seating);
mOutdoorSeating = view.findViewById(R.id.sw__outdoor_seating);
blockOutdoorSeating.setOnClickListener(this);
View blockOpeningHours = view.findViewById(R.id.block_opening_hours);
mEditOpeningHours = blockOpeningHours.findViewById(R.id.edit_opening_hours);
mEditOpeningHours.setOnClickListener(this);
Expand All @@ -469,6 +484,8 @@ private void initViews(View view)
mDetailsBlocks.put(Metadata.MetadataType.FMD_PHONE_NUMBER, blockPhone);
mDetailsBlocks.put(Metadata.MetadataType.FMD_CUISINE, blockCuisine);
mDetailsBlocks.put(Metadata.MetadataType.FMD_INTERNET, blockWifi);
mDetailsBlocks.put(Metadata.MetadataType.FMD_SELF_SERVICE, blockSelfService);
mDetailsBlocks.put(Metadata.MetadataType.FMD_OUTDOOR_SEATING, blockOutdoorSeating);
mDetailsBlocks.put(Metadata.MetadataType.FMD_WEBSITE, websiteBlock);
mDetailsBlocks.put(Metadata.MetadataType.FMD_WEBSITE_MENU, websiteMenuBlock);
mDetailsBlocks.put(Metadata.MetadataType.FMD_EMAIL, emailBlock);
Expand Down Expand Up @@ -508,6 +525,8 @@ else if (id == R.id.phone || id == R.id.edit_phone)
mParent.editPhone();
else if (id == R.id.block_wifi)
mWifi.toggle();
else if (id == R.id.block_self_service)
mParent.editSelfService();
else if (id == R.id.block_street)
mParent.editStreet();
else if (id == R.id.block_cuisine)
Expand All @@ -525,6 +544,8 @@ else if (id == R.id.about_osm)
Utils.openUrl(requireActivity(), getString(R.string.osm_wiki_about_url));
else if (id == R.id.reset)
reset();
else if (id == R.id.block_outdoor_seating)
mOutdoorSeating.toggle();
}

private void showAdditionalNames(boolean show)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import app.organicmaps.MwmApplication;
import app.organicmaps.R;
import app.organicmaps.base.BaseMwmToolbarFragment;
import app.organicmaps.bookmarks.data.Metadata;
import app.organicmaps.editor.data.Language;
import app.organicmaps.editor.data.LocalizedName;
import app.organicmaps.editor.data.LocalizedStreet;
Expand Down Expand Up @@ -50,7 +51,8 @@ enum Mode
STREET,
CUISINE,
LANGUAGE,
PHONE
PHONE,
SELF_SERVICE
}

private Mode mMode;
Expand Down Expand Up @@ -171,7 +173,7 @@ public boolean onBackPressed()
{
switch (mMode)
{
case OPENING_HOURS, STREET, CUISINE, LANGUAGE, PHONE -> editMapObject();
case OPENING_HOURS, STREET, CUISINE, LANGUAGE, PHONE, SELF_SERVICE -> editMapObject();
default -> Utils.navigateToParent(requireActivity());
}
return true;
Expand Down Expand Up @@ -224,6 +226,11 @@ protected void editCuisine()
editWithFragment(Mode.CUISINE, R.string.select_cuisine, null, CuisineFragment.class, true);
}

protected void editSelfService()
{
editWithFragment(Mode.SELF_SERVICE, R.string.select_option, null, SelfServiceFragment.class, false);
}

protected void addLanguage()
{
Bundle args = new Bundle();
Expand Down Expand Up @@ -298,6 +305,8 @@ public void onClick(View v)
Editor.nativeSetSelectedCuisines(cuisines);
editMapObject();
}
case SELF_SERVICE ->
setSelection(Metadata.MetadataType.FMD_SELF_SERVICE, ((SelfServiceFragment) getChildFragmentManager().findFragmentByTag(SelfServiceFragment.class.getName())).getSelection());
case LANGUAGE -> editMapObject();
case MAP_OBJECT ->
{
Expand Down Expand Up @@ -394,6 +403,12 @@ public void setStreet(LocalizedStreet street)
editMapObject();
}

public void setSelection(Metadata.MetadataType metadata, String selection)
{
Editor.nativeSetMetadata(metadata.toInt(), selection);
editMapObject();
}

public boolean addingNewObject()
{
return mIsNewObject;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package app.organicmaps.editor;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import app.organicmaps.R;
import app.organicmaps.util.UiUtils;
import app.organicmaps.util.Utils;

public class SelfServiceAdapter extends RecyclerView.Adapter<SelfServiceAdapter.ViewHolder>
{
private final String[] mItems = new String[]{"yes", "only", "partially", "no"};
private final SelfServiceFragment mFragment;
private String mSelectedOption;


public SelfServiceAdapter(@NonNull SelfServiceFragment host, @NonNull String selected)
{
mFragment = host;
mSelectedOption = selected;
}

public String getSelected()
{
return mSelectedOption;
}

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
{
return new SelfServiceAdapter.ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_selection, parent, false));
}

@Override
public void onBindViewHolder(SelfServiceAdapter.ViewHolder holder, int position)
{
holder.bind(position);
}

@Override
public int getItemCount()
{
return mItems.length;
}

protected class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener
{
final TextView selfServiceDef;
final CompoundButton selected;

public ViewHolder(View itemView)
{
super(itemView);
selfServiceDef = itemView.findViewById(R.id.self_service_default);
selected = itemView.findViewById(R.id.self_service_selected);
itemView.setOnClickListener(this);
selected.setOnClickListener(v -> {
selected.toggle();
SelfServiceAdapter.ViewHolder.this.onClick(selected);
});
}

public void bind(int position)
{
Context context = itemView.getContext();
selected.setChecked(mSelectedOption.equals(mItems[position]));
String text = Utils.getTagValueLocalized(context, "self_service", mItems[position]);
selfServiceDef.setText(text);
}

@Override
public void onClick(View v)
{
mSelectedOption = mItems[getBindingAdapterPosition()];
notifyDataSetChanged();
mFragment.saveSelection(mSelectedOption);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package app.organicmaps.editor;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import app.organicmaps.base.BaseMwmRecyclerFragment;
import app.organicmaps.bookmarks.data.Metadata;
import app.organicmaps.editor.data.LocalizedStreet;

public class SelfServiceFragment extends BaseMwmRecyclerFragment<SelfServiceAdapter>
{
private String mSelectedString;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
return super.onCreateView(inflater, container, savedInstanceState);
}

@NonNull
public String getSelection()
{
return getAdapter().getSelected();
}

@CallSuper
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState)
{
mSelectedString = Editor.nativeGetMetadata(Metadata.MetadataType.FMD_SELF_SERVICE.toInt());
super.onViewCreated(view, savedInstanceState);
}

@NonNull
@Override
protected SelfServiceAdapter createAdapter()
{
return new SelfServiceAdapter(this, mSelectedString);
}

protected void saveSelection(String selection)
{
if (getParentFragment() instanceof EditorHostFragment)
((EditorHostFragment) getParentFragment()).setSelection(Metadata.MetadataType.FMD_SELF_SERVICE, selection);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package app.organicmaps.maplayer;

import android.content.Context;
import android.util.AttributeSet;

import com.google.android.material.floatingactionbutton.FloatingActionButton;

import app.organicmaps.R;

public class LayersButton extends FloatingActionButton
{
private boolean mAreLayersActive = false;

public LayersButton(Context context)
{
super(context);
}

public LayersButton(Context context, AttributeSet attrs)
{
super(context, attrs);
}

public LayersButton(Context context, AttributeSet attrs, int defStyleAttr)
{
super(context, attrs, defStyleAttr);
}

@Override
public int[] onCreateDrawableState(int extraSpace)
{
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
if (mAreLayersActive)
mergeDrawableStates(drawableState, new int[]{R.attr.layers_enabled});
return drawableState;
}

public void setHasActiveLayers(boolean areLayersActive)
{
mAreLayersActive = areLayersActive;
refreshDrawableState();
}
}
Loading

0 comments on commit 67ac45d

Please sign in to comment.