From 14bbe24a7da5d6a92dea53312a831973094fb672 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Tue, 23 Feb 2016 17:49:08 +0300 Subject: [PATCH] Fix Osm Live for DEV. Remove flickering of - in map markers --- OsmAnd/src/net/osmand/plus/Version.java | 2 +- .../plus/activities/MapActivityActions.java | 23 +++++++------ .../plus/liveupdates/LiveUpdatesFragment.java | 32 +++++++++---------- .../plus/liveupdates/OsmLiveActivity.java | 4 +++ .../mapwidgets/MapMarkersWidgetsFactory.java | 28 +++++++++++++--- 5 files changed, 57 insertions(+), 32 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/Version.java b/OsmAnd/src/net/osmand/plus/Version.java index 56032d7922..87ef8d174a 100644 --- a/OsmAnd/src/net/osmand/plus/Version.java +++ b/OsmAnd/src/net/osmand/plus/Version.java @@ -37,7 +37,7 @@ public class Version { return ctx.getString(R.string.versionFeatures).contains("+amazon"); } - private static boolean isGooglePlayEnabled(OsmandApplication ctx) { + public static boolean isGooglePlayEnabled(OsmandApplication ctx) { return ctx.getString(R.string.versionFeatures).contains("+play_market"); } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 6ad5e75458..cc0f26fd09 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -40,6 +40,7 @@ import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper; +import net.osmand.plus.Version; import net.osmand.plus.activities.actions.OsmAndDialogs; import net.osmand.plus.activities.search.SearchActivity; import net.osmand.plus.dashboard.DashboardOnMap.DashboardType; @@ -691,16 +692,18 @@ public class MapActivityActions implements DialogProvider { } }).reg(); - optionsMenuHelper.item(R.string.osm_live).iconColor(R.drawable.ic_action_osm_live) - .listen(new OnContextMenuClick() { - @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { - Intent intent = new Intent(mapActivity, OsmLiveActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); - mapActivity.startActivity(intent); - return false; - } - }).reg(); + if (Version.isGooglePlayEnabled(app)) { + optionsMenuHelper.item(R.string.osm_live).iconColor(R.drawable.ic_action_osm_live) + .listen(new OnContextMenuClick() { + @Override + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + Intent intent = new Intent(mapActivity, OsmLiveActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + mapActivity.startActivity(intent); + return false; + } + }).reg(); + } optionsMenuHelper.item(R.string.prefs_plugins).iconColor(R.drawable.ic_extension_dark) .listen(new OnContextMenuClick() { diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java index b4315de162..6d9d453e5c 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java @@ -37,6 +37,7 @@ import net.osmand.map.WorldRegion; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; +import net.osmand.plus.Version; import net.osmand.plus.activities.LocalIndexHelper; import net.osmand.plus.activities.LocalIndexInfo; import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; @@ -130,23 +131,22 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppList progressBar = (ProgressBar) view.findViewById(R.id.progress); - //test - //getSettings().LIVE_UPDATES_PURCHASED.set(true); + if (!Version.isDeveloperVersion(getMyApplication())) { + subscriptionHeader = inflater.inflate(R.layout.live_updates_header, listView, false); + updateSubscriptionHeader(); - subscriptionHeader = inflater.inflate(R.layout.live_updates_header, listView, false); - updateSubscriptionHeader(); - - listView.addHeaderView(subscriptionHeader); - listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - if (position == 0 && !processing && InAppHelper.isSubscribedToLiveUpdates()) { - SubscriptionFragment subscriptionFragment = new SubscriptionFragment(); - subscriptionFragment.setEditMode(true); - subscriptionFragment.show(getChildFragmentManager(), SubscriptionFragment.TAG); + listView.addHeaderView(subscriptionHeader); + listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + if (position == 0 && !processing && InAppHelper.isSubscribedToLiveUpdates()) { + SubscriptionFragment subscriptionFragment = new SubscriptionFragment(); + subscriptionFragment.setEditMode(true); + subscriptionFragment.show(getChildFragmentManager(), SubscriptionFragment.TAG); + } } - } - }); + }); + } loadLocalIndexesTask = new LoadLocalIndexTask(adapter, this).execute(); return view; @@ -232,7 +232,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppList @SuppressWarnings("deprecation") @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - if (getSettings().LIVE_UPDATES_PURCHASED.get()) { + if (getSettings().LIVE_UPDATES_PURCHASED.get() && !Version.isDeveloperVersion(getMyApplication())) { ActionBar actionBar = getMyActivity().getSupportActionBar(); if (actionBar != null) { actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/OsmLiveActivity.java b/OsmAnd/src/net/osmand/plus/liveupdates/OsmLiveActivity.java index 983a7c6ab1..c582f3d424 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/OsmLiveActivity.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/OsmLiveActivity.java @@ -11,6 +11,7 @@ import android.view.MenuItem; import net.osmand.PlatformUtil; import net.osmand.plus.R; +import net.osmand.plus.Version; import net.osmand.plus.download.AbstractDownloadActivity; import net.osmand.plus.download.DownloadIndexesThread; import net.osmand.plus.inapp.InAppHelper; @@ -34,6 +35,9 @@ public class OsmLiveActivity extends AbstractDownloadActivity setContentView(R.layout.activity_livie_updates); inAppHelper = new InAppHelper(getMyApplication()); + if (Version.isDeveloperVersion(getMyApplication())) { + inAppHelper = null; + } ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager); pagerAdapter = new LiveUpdatesFragmentPagerAdapter(getSupportFragmentManager()); diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java index 212a062f20..38526cf00a 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java @@ -52,8 +52,10 @@ public class MapMarkersWidgetsFactory { private ImageButton moreButton; private ImageButton moreButton2nd; + private MapMarker marker; private int markerColorIndex = -1; private String markerDistText; + private MapMarker marker2nd; private int markerColorIndex2nd = -1; private String markerDistText2nd; @@ -249,13 +251,17 @@ public class MapMarkersWidgetsFactory { arrowImg.invalidate(); int dist = (int) mes[0]; - String txt; + String txt = null; if (loc != null) { txt = OsmAndFormatter.getFormattedDistance(dist, map.getMyApplication()); } else { - txt = "—"; + if ((firstLine && marker != this.marker) || (!firstLine && marker != this.marker2nd)) { + txt = "—"; + } + } + if (txt != null) { + distText.setText(txt); } - distText.setText(txt); updateVisibility(okButton, !customLocation && loc != null && dist < MIN_DIST_OK_VISIBLE); String descr; @@ -272,11 +278,17 @@ public class MapMarkersWidgetsFactory { addressText.setText(descr); if (firstLine) { + this.marker = marker; markerColorIndex = marker.colorIndex; - markerDistText = txt; + if (txt != null) { + markerDistText = txt; + } } else { + this.marker2nd = marker; markerColorIndex2nd = marker.colorIndex; - markerDistText2nd = txt; + if (txt != null) { + markerDistText2nd = txt; + } } } @@ -294,6 +306,7 @@ public class MapMarkersWidgetsFactory { setImageDrawable(map.getMyApplication().getIconsCache() .getIcon(R.drawable.widget_marker_day, MapMarkerDialogHelper.getMapMarkerColorId(markerColorIndex))); + cachedMarkerColorIndex = markerColorIndex; res = true; } if (!markerDistText.equals(cachedMarkerDistText)) { @@ -303,11 +316,13 @@ public class MapMarkersWidgetsFactory { } else { setText(markerDistText.substring(0, ls), markerDistText.substring(ls + 1)); } + cachedMarkerDistText = markerDistText; res = true; } return res; } else if (cachedMarkerDistText != null) { + cachedMarkerColorIndex = -1; cachedMarkerDistText = null; setText(null, null); return true; @@ -338,6 +353,7 @@ public class MapMarkersWidgetsFactory { setImageDrawable(map.getMyApplication().getIconsCache() .getIcon(R.drawable.widget_marker_day, MapMarkerDialogHelper.getMapMarkerColorId(markerColorIndex2nd))); + cachedMarkerColorIndex = markerColorIndex2nd; res = true; } if (!markerDistText2nd.equals(cachedMarkerDistText)) { @@ -347,11 +363,13 @@ public class MapMarkersWidgetsFactory { } else { setText(markerDistText2nd.substring(0, ls), markerDistText2nd.substring(ls + 1)); } + cachedMarkerDistText = markerDistText2nd; res = true; } return res; } else if (cachedMarkerDistText != null) { + cachedMarkerColorIndex = -1; cachedMarkerDistText = null; setText(null, null); return true;