Ticket #18866: 18866.1.patch

File 18866.1.patch, 5.1 KB (added by taylor.smock, 2 years ago)

Remove the potlatch2 style from JOSM source

  • src/org/openstreetmap/josm/data/preferences/sources/MapPaintPrefHelper.java

    Subject: [PATCH] #18866
    ---
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/data/preferences/sources/MapPaintPrefHelper.java b/src/org/openstreetmap/josm/data/preferences/sources/MapPaintPrefHelper.java
    a b  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    66import java.util.ArrayList;
    7 import java.util.Arrays;
    87import java.util.Collection;
     8import java.util.Collections;
    99import java.util.List;
    1010import java.util.Map;
    1111import java.util.Objects;
     
    7272        }
    7373        Config.getPref().putList("mappaint.style.known-defaults", new ArrayList<>(knownDefaults));
    7474
    75         // XML style is not bundled anymore
    76         list.removeIf(se -> "resource://styles/standard/elemstyles.xml".equals(se.url));
    77 
    7875        return changed;
    7976    }
    8077
     
    8683        defJosmMapcss.icon = new ImageProvider("logo").getResource();
    8784        defJosmMapcss.title = tr("JOSM default (MapCSS)");
    8885        defJosmMapcss.description = tr("Internal style to be used as base for runtime switchable overlay styles");
    89         ExtendedSourceEntry defPL2 = new ExtendedSourceEntry(type, "potlatch2.mapcss", "resource://styles/standard/potlatch2.mapcss");
    90         defPL2.active = false;
    91         defPL2.name = "standard";
    92         defPL2.icon = new ImageProvider("dialogs/mappaint", "pl2_small").getResource();
    93         defPL2.title = tr("Potlatch 2");
    94         defPL2.description = tr("the main Potlatch 2 style");
    95 
    96         return Arrays.asList(defJosmMapcss, defPL2);
     86        return Collections.singletonList(defJosmMapcss);
    9787    }
    9888
    9989    @Override
  • src/org/openstreetmap/josm/data/Preferences.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/data/Preferences.java b/src/org/openstreetmap/josm/data/Preferences.java
    a b  
    900900            putBoolean("preferences.reset.draw.rawgps.lines", true);
    901901            putInt("draw.rawgps.lines", -1);
    902902        }
     903        updateMapPaintKnownDefaults();
    903904        if (modifiedDefault) {
    904905            try {
    905906                saveDefaults();
     
    911912        }
    912913    }
    913914
     915    /**
     916     * Update the known defaults for the map paintstyles.
     917     */
     918    private void updateMapPaintKnownDefaults() {
     919        final String url = "url";
     920        final String active = "active";
     921        final String potlatch2 = "resource://styles/standard/potlatch2.mapcss";
     922        final String remotePotlatch2 = "https://josm.openstreetmap.de/josmfile?page=Styles/Potlatch2&zip=1";
     923
     924        // Remove potlatch2 from the known defaults
     925        final List<String> knownDefaults = new ArrayList<>(getList("mappaint.style.known-defaults"));
     926        // See #18866: Potlatch 2 internal theme removed in favor of remote theme by Stereo
     927        knownDefaults.removeIf(potlatch2::equals);
     928
     929        // Moved from MapPaintPrefHelper for consistency
     930        // XML style is not bundled anymore
     931        knownDefaults.removeIf("resource://styles/standard/elemstyles.xml"::equals);
     932        putList("mappaint.style.known-defaults", knownDefaults);
     933
     934        // Replace potlatch2 in the current style entries, but only if it is enabled. Otherwise, remove it.
     935        final List<Map<String, String>> styleEntries = new ArrayList<>(getListOfMaps("mappaint.style.entries"));
     936        final boolean potlatchEnabled = styleEntries.stream().filter(map -> potlatch2.equals(map.get(url)))
     937                .anyMatch(map -> Boolean.parseBoolean(map.get(active)));
     938        final boolean remotePotlatch2Present = styleEntries.stream().anyMatch(map -> remotePotlatch2.equals(map.get(url)));
     939        // Remove potlatch2 if it is not enabled _or_ the remote potlatch2 version is present
     940        styleEntries.removeIf(map -> (!potlatchEnabled || remotePotlatch2Present) && potlatch2.equals(map.get(url)));
     941        styleEntries.replaceAll(TreeMap::new); // The maps are initially immutable.
     942        for (Map<String, String> map : styleEntries) {
     943            if (potlatch2.equals(map.get(url))) {
     944                map.put(url, remotePotlatch2);
     945            }
     946        }
     947        putListOfMaps("mappaint.style.entries", styleEntries);
     948    }
     949
    914950    /**
    915951     * Enables or not the preferences file auto-save mechanism (save each time a setting is changed).
    916952     * This behaviour is enabled by default.
  • deleted file resources/styles/standard/potlatch2.mapcss

    diff --git a/resources/styles/standard/potlatch2.mapcss b/resources/styles/standard/potlatch2.mapcss
    deleted file mode 100644
    index 88796b06e7d3753f0afcd789ccae63f7be1c92e4..0000000000000000000000000000000000000000
    GIT binary patch
    literal 0
    Hc$@<O00001