Fix Osm Live for DEV. Remove flickering of - in map markers

This commit is contained in:
Alexey Kulish 2016-02-23 17:49:08 +03:00
parent 19297a7bd0
commit 14bbe24a7d
5 changed files with 57 additions and 32 deletions

View file

@ -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");
}

View file

@ -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() {

View file

@ -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);

View file

@ -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());

View file

@ -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;