Merge pull request #5477 from osmandapp/updatelocview

Refactor update location view
This commit is contained in:
vshcherb 2018-05-24 10:26:09 +02:00 committed by GitHub
commit c9d960387a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
134 changed files with 998 additions and 1269 deletions

View file

@ -13,7 +13,6 @@ import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Build; import android.os.Build;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import net.osmand.IProgress; import net.osmand.IProgress;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
@ -27,6 +26,7 @@ import net.osmand.plus.activities.DayNightHelper;
import net.osmand.plus.activities.LocalIndexHelper; import net.osmand.plus.activities.LocalIndexHelper;
import net.osmand.plus.activities.LocalIndexInfo; import net.osmand.plus.activities.LocalIndexInfo;
import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.ui.AbstractLoadLocalIndexTask; import net.osmand.plus.download.ui.AbstractLoadLocalIndexTask;
import net.osmand.plus.helpers.AvoidSpecificRoads; import net.osmand.plus.helpers.AvoidSpecificRoads;
@ -67,7 +67,6 @@ import java.util.Locale;
import java.util.Random; import java.util.Random;
import btools.routingapp.BRouterServiceConnection; import btools.routingapp.BRouterServiceConnection;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getPendingIntent; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getPendingIntent;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLastCheck; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLastCheck;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLiveUpdatesOn; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLiveUpdatesOn;
@ -448,6 +447,7 @@ public class AppInitializer implements IProgress {
app.mapMarkersDbHelper = startupInit(new MapMarkersDbHelper(app), MapMarkersDbHelper.class); app.mapMarkersDbHelper = startupInit(new MapMarkersDbHelper(app), MapMarkersDbHelper.class);
app.mapMarkersHelper = startupInit(new MapMarkersHelper(app), MapMarkersHelper.class); app.mapMarkersHelper = startupInit(new MapMarkersHelper(app), MapMarkersHelper.class);
app.searchUICore = startupInit(new QuickSearchHelper(app), QuickSearchHelper.class); app.searchUICore = startupInit(new QuickSearchHelper(app), QuickSearchHelper.class);
app.mapViewTrackingUtilities = startupInit(new MapViewTrackingUtilities(app), MapViewTrackingUtilities.class);
app.travelDbHelper = new TravelDbHelper(app); app.travelDbHelper = new TravelDbHelper(app);
if (app.getSettings().SELECTED_TRAVEL_BOOK.get() != null) { if (app.getSettings().SELECTED_TRAVEL_BOOK.get() != null) {
app.travelDbHelper.initTravelBooks(); app.travelDbHelper.initTravelBooks();

View file

@ -110,7 +110,7 @@ public class ContextMenuAdapter {
@LayoutRes @LayoutRes
private int layoutId; private int layoutId;
private final ConfigureMapMenu.OnClickListener changeAppModeListener; private final ConfigureMapMenu.OnClickListener changeAppModeListener;
private final IconsCache mIconsCache; private final UiUtilities mIconsCache;
public ContextMenuArrayAdapter(Activity context, public ContextMenuArrayAdapter(Activity context,
@LayoutRes int layoutRes, @LayoutRes int layoutRes,
@ -124,7 +124,7 @@ public class ContextMenuAdapter {
this.lightTheme = lightTheme; this.lightTheme = lightTheme;
this.layoutId = layoutRes; this.layoutId = layoutRes;
this.changeAppModeListener = changeAppModeListener; this.changeAppModeListener = changeAppModeListener;
mIconsCache = app.getIconsCache(); mIconsCache = app.getUIUtilities();
} }
@Override @Override
@ -169,7 +169,7 @@ public class ContextMenuAdapter {
} }
if (layoutId == R.layout.help_to_improve_item) { if (layoutId == R.layout.help_to_improve_item) {
TextView feedbackButton = (TextView) convertView.findViewById(R.id.feedbackButton); TextView feedbackButton = (TextView) convertView.findViewById(R.id.feedbackButton);
Drawable pollIcon = app.getIconsCache().getThemedIcon(R.drawable.ic_action_big_poll); Drawable pollIcon = app.getUIUtilities().getThemedIcon(R.drawable.ic_action_big_poll);
feedbackButton.setCompoundDrawablesWithIntrinsicBounds(null, pollIcon, null, null); feedbackButton.setCompoundDrawablesWithIntrinsicBounds(null, pollIcon, null, null);
feedbackButton.setOnClickListener(new View.OnClickListener() { feedbackButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -181,7 +181,7 @@ public class ContextMenuAdapter {
}); });
TextView contactUsButton = (TextView) convertView.findViewById(R.id.contactUsButton); TextView contactUsButton = (TextView) convertView.findViewById(R.id.contactUsButton);
Drawable contactUsIcon = Drawable contactUsIcon =
app.getIconsCache().getThemedIcon(R.drawable.ic_action_big_feedback); app.getUIUtilities().getThemedIcon(R.drawable.ic_action_big_feedback);
contactUsButton.setCompoundDrawablesWithIntrinsicBounds(null, contactUsIcon, null, contactUsButton.setCompoundDrawablesWithIntrinsicBounds(null, contactUsIcon, null,
null); null);
final String email = app.getString(R.string.support_email); final String email = app.getString(R.string.support_email);

View file

@ -107,7 +107,7 @@ public class ContextMenuItem {
if (skipPaintingWithoutColor || getColorRes() != INVALID_ID) { if (skipPaintingWithoutColor || getColorRes() != INVALID_ID) {
return getColorRes(); return getColorRes();
} else { } else {
return IconsCache.getDefaultColorRes(context); return UiUtilities.getDefaultColorRes(context);
} }
} }

View file

@ -1,88 +0,0 @@
package net.osmand.plus;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.view.MenuItem;
import gnu.trove.map.hash.TLongObjectHashMap;
public class IconsCache {
private TLongObjectHashMap<Drawable> drawable = new TLongObjectHashMap<>();
private OsmandApplication app;
public IconsCache(OsmandApplication app) {
this.app = app;
}
private Drawable getDrawable(@DrawableRes int resId, @ColorRes int clrId) {
long hash = ((long)resId << 31l) + clrId;
Drawable d = drawable.get(hash);
if (d == null) {
d = ContextCompat.getDrawable(app, resId);
d = DrawableCompat.wrap(d);
d.mutate();
if (clrId != 0) {
DrawableCompat.setTint(d, ContextCompat.getColor(app, clrId));
}
drawable.put(hash, d);
}
return d;
}
private Drawable getPaintedDrawable(@DrawableRes int resId, @ColorInt int color){
long hash = ((long)resId << 31l) + color;
Drawable d = drawable.get(hash);
if(d == null) {
d = ContextCompat.getDrawable(app, resId);
d = DrawableCompat.wrap(d);
d.mutate();
DrawableCompat.setTint(d, color);
drawable.put(hash, d);
}
return d;
}
public Drawable getPaintedIcon(@DrawableRes int id, @ColorInt int color){
return getPaintedDrawable(id, color);
}
public Drawable getIcon(@DrawableRes int id, @ColorRes int colorId) {
return getDrawable(id, colorId);
}
public Drawable getIcon(@DrawableRes int backgroundId, @DrawableRes int id, @ColorRes int colorId) {
Drawable b = getDrawable(backgroundId, 0);
Drawable f = getDrawable(id, colorId);
Drawable[] layers = new Drawable[2];
layers[0] = b;
layers[1] = f;
return new LayerDrawable(layers);
}
public Drawable getThemedIcon(@DrawableRes int id) {
return getDrawable(id, app.getSettings().isLightContent() ? R.color.icon_color : 0);
}
public Drawable getIcon(@DrawableRes int id) {
return getDrawable(id, 0);
}
public Drawable getIcon(@DrawableRes int id, boolean light) {
return getDrawable(id, light ? R.color.icon_color : 0);
}
@ColorRes
public static int getDefaultColorRes(Context context) {
final OsmandApplication app = (OsmandApplication) context.getApplicationContext();
boolean light = app.getSettings().isLightContent();
return light ? R.color.icon_color : R.color.color_white;
}
}

View file

@ -556,14 +556,7 @@ public class OsmAndLocationProvider implements SensorEventListener {
} }
} }
public synchronized Float getHeading() { public Float getHeading() {
// if (heading != null && lastValSin != avgValSin && System.currentTimeMillis() - lastHeadingCalcTime > 700) {
// avgValSin = lastValSin;
// avgValCos = lastValCos;
// Arrays.fill(previousCompassValuesA, avgValSin);
// Arrays.fill(previousCompassValuesB, avgValCos);
// updateCompassVal();
// }
return heading; return heading;
} }

View file

@ -42,6 +42,7 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.api.SQLiteAPI; import net.osmand.plus.api.SQLiteAPI;
import net.osmand.plus.api.SQLiteAPIImpl; import net.osmand.plus.api.SQLiteAPIImpl;
import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.dialogs.RateUsBottomSheetDialog; import net.osmand.plus.dialogs.RateUsBottomSheetDialog;
import net.osmand.plus.download.DownloadIndexesThread; import net.osmand.plus.download.DownloadIndexesThread;
import net.osmand.plus.helpers.AvoidSpecificRoads; import net.osmand.plus.helpers.AvoidSpecificRoads;
@ -87,7 +88,7 @@ public class OsmandApplication extends MultiDexApplication {
OsmAndAppCustomization appCustomization; OsmAndAppCustomization appCustomization;
private final SQLiteAPI sqliteAPI = new SQLiteAPIImpl(this); private final SQLiteAPI sqliteAPI = new SQLiteAPIImpl(this);
private final OsmAndTaskManager taskManager = new OsmAndTaskManager(this); private final OsmAndTaskManager taskManager = new OsmAndTaskManager(this);
private final IconsCache iconsCache = new IconsCache(this); private final UiUtilities iconsCache = new UiUtilities(this);
Handler uiHandler; Handler uiHandler;
private boolean plusVersionInApp; private boolean plusVersionInApp;
@ -122,6 +123,7 @@ public class OsmandApplication extends MultiDexApplication {
QuickSearchHelper searchUICore; QuickSearchHelper searchUICore;
TravelDbHelper travelDbHelper; TravelDbHelper travelDbHelper;
InAppPurchaseHelper inAppPurchaseHelper; InAppPurchaseHelper inAppPurchaseHelper;
MapViewTrackingUtilities mapViewTrackingUtilities;
RoutingConfiguration.Builder defaultRoutingConfig; RoutingConfiguration.Builder defaultRoutingConfig;
private Locale preferredLocale = null; private Locale preferredLocale = null;
@ -214,10 +216,11 @@ public class OsmandApplication extends MultiDexApplication {
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
public IconsCache getIconsCache() { public UiUtilities getUIUtilities() {
return iconsCache; return iconsCache;
} }
@Override @Override
public void onTerminate() { public void onTerminate() {
super.onTerminate(); super.onTerminate();
@ -420,7 +423,7 @@ public class OsmandApplication extends MultiDexApplication {
View view = uiContext.getLayoutInflater().inflate(R.layout.select_voice_first, null); View view = uiContext.getLayoutInflater().inflate(R.layout.select_voice_first, null);
((ImageView) view.findViewById(R.id.icon)) ((ImageView) view.findViewById(R.id.icon))
.setImageDrawable(getIconsCache().getIcon(R.drawable.ic_action_volume_up, getSettings().isLightContent())); .setImageDrawable(getUIUtilities().getIcon(R.drawable.ic_action_volume_up, getSettings().isLightContent()));
view.findViewById(R.id.spinner).setOnClickListener(new View.OnClickListener() { view.findViewById(R.id.spinner).setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -441,7 +444,7 @@ public class OsmandApplication extends MultiDexApplication {
}); });
((ImageView) view.findViewById(R.id.dropDownIcon)) ((ImageView) view.findViewById(R.id.dropDownIcon))
.setImageDrawable(getIconsCache().getIcon(R.drawable.ic_action_arrow_drop_down, getSettings().isLightContent())); .setImageDrawable(getUIUtilities().getIcon(R.drawable.ic_action_arrow_drop_down, getSettings().isLightContent()));
builder.setCancelable(true); builder.setCancelable(true);
builder.setNegativeButton(R.string.shared_string_cancel, null); builder.setNegativeButton(R.string.shared_string_cancel, null);
@ -1003,4 +1006,8 @@ public class OsmandApplication extends MultiDexApplication {
}); });
bld.show(); bld.show();
} }
public MapViewTrackingUtilities getMapViewTrackingUtilities() {
return mapViewTrackingUtilities;
}
} }

View file

@ -0,0 +1,226 @@
package net.osmand.plus;
import gnu.trove.map.hash.TLongObjectHashMap;
import net.osmand.Location;
import net.osmand.data.LatLon;
import net.osmand.plus.views.DirectionDrawable;
import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
public class UiUtilities {
private TLongObjectHashMap<Drawable> drawableCache = new TLongObjectHashMap<>();
private OsmandApplication app;
private static final int ORIENTATION_0 = 0;
private static final int ORIENTATION_90 = 3;
private static final int ORIENTATION_270 = 1;
private static final int ORIENTATION_180 = 2;
public UiUtilities(OsmandApplication app) {
this.app = app;
}
private Drawable getDrawable(@DrawableRes int resId, @ColorRes int clrId) {
long hash = ((long) resId << 31l) + clrId;
Drawable d = drawableCache.get(hash);
if (d == null) {
d = ContextCompat.getDrawable(app, resId);
d = DrawableCompat.wrap(d);
d.mutate();
if (clrId != 0) {
DrawableCompat.setTint(d, ContextCompat.getColor(app, clrId));
}
drawableCache.put(hash, d);
}
return d;
}
private Drawable getPaintedDrawable(@DrawableRes int resId, @ColorInt int color) {
long hash = ((long) resId << 31l) + color;
Drawable d = drawableCache.get(hash);
if (d == null) {
d = ContextCompat.getDrawable(app, resId);
d = DrawableCompat.wrap(d);
d.mutate();
DrawableCompat.setTint(d, color);
drawableCache.put(hash, d);
}
return d;
}
public Drawable getPaintedIcon(@DrawableRes int id, @ColorInt int color) {
return getPaintedDrawable(id, color);
}
public Drawable getIcon(@DrawableRes int id, @ColorRes int colorId) {
return getDrawable(id, colorId);
}
public Drawable getIcon(@DrawableRes int backgroundId, @DrawableRes int id, @ColorRes int colorId) {
Drawable b = getDrawable(backgroundId, 0);
Drawable f = getDrawable(id, colorId);
Drawable[] layers = new Drawable[2];
layers[0] = b;
layers[1] = f;
return new LayerDrawable(layers);
}
public Drawable getThemedIcon(@DrawableRes int id) {
return getDrawable(id, app.getSettings().isLightContent() ? R.color.icon_color : 0);
}
public Drawable getIcon(@DrawableRes int id) {
return getDrawable(id, 0);
}
public Drawable getIcon(@DrawableRes int id, boolean light) {
return getDrawable(id, light ? R.color.icon_color : 0);
}
@ColorRes
public static int getDefaultColorRes(Context context) {
final OsmandApplication app = (OsmandApplication) context.getApplicationContext();
boolean light = app.getSettings().isLightContent();
return light ? R.color.icon_color : R.color.color_white;
}
public UpdateLocationViewCache getUpdateLocationViewCache(){
UpdateLocationViewCache uvc = new UpdateLocationViewCache();
uvc.screenOrientation = getScreenOrientation();
return uvc;
}
public static class UpdateLocationViewCache {
int screenOrientation;
public boolean paintTxt = true;
public int arrowResId;
public int arrowColor;
public int textColor;
public LatLon specialFrom;
}
public void updateLocationView(UpdateLocationViewCache cache, ImageView arrow, TextView txt,
double toLat, double toLon) {
updateLocationView(cache, arrow, txt, new LatLon(toLat, toLon));
}
public void updateLocationView(UpdateLocationViewCache cache, ImageView arrow, TextView txt,
LatLon toLoc) {
float[] mes = new float[2];
boolean stale = false;
LatLon fromLoc = cache == null ? null : cache.specialFrom;
boolean useCenter = fromLoc != null;
Float h = null;
if (fromLoc == null) {
Location loc = app.getLocationProvider().getLastKnownLocation();
h = app.getLocationProvider().getHeading();
if (loc == null) {
loc = app.getLocationProvider().getLastStaleKnownLocation();
stale = true;
}
if (loc != null) {
fromLoc = new LatLon(loc.getLatitude(), loc.getLongitude());
} else {
useCenter = true;
fromLoc = app.getMapViewTrackingUtilities().getMapLocation();
h = app.getMapViewTrackingUtilities().getMapRotate();
if(h != null) {
h = -h;
}
}
}
if (fromLoc != null && toLoc != null) {
Location.distanceBetween(toLoc.getLatitude(), toLoc.getLongitude(), fromLoc.getLatitude(),
fromLoc.getLongitude(), mes);
}
if (arrow != null) {
boolean newImage = false;
int arrowResId = cache == null ? 0 : cache.arrowResId;
if (arrowResId == 0) {
arrowResId = R.drawable.ic_direction_arrow;
}
DirectionDrawable dd;
if (!(arrow.getDrawable() instanceof DirectionDrawable)) {
newImage = true;
dd = new DirectionDrawable(app, arrow.getWidth(), arrow.getHeight());
} else {
dd = (DirectionDrawable) arrow.getDrawable();
}
int imgColorSet = cache == null ? 0 : cache.arrowColor;
if (imgColorSet == 0) {
imgColorSet = useCenter ? R.color.color_distance : R.color.color_myloc_distance;
if (stale) {
imgColorSet = R.color.icon_color;
}
}
dd.setImage(arrowResId, imgColorSet);
if (fromLoc == null || h == null || toLoc == null) {
dd.setAngle(0);
} else {
float orientation = (cache == null ? 0 : -cache.screenOrientation) ;
dd.setAngle(mes[1] - h + 180 + orientation);
}
if (newImage) {
arrow.setImageDrawable(dd);
}
arrow.invalidate();
}
if (txt != null) {
if (fromLoc != null && toLoc != null) {
if (cache.paintTxt) {
int textColorSet = cache.textColor;
if (textColorSet == 0) {
textColorSet = useCenter ? R.color.color_distance : R.color.color_myloc_distance;
if (stale) {
textColorSet = R.color.icon_color;
}
}
txt.setTextColor(app.getResources().getColor(textColorSet));
}
txt.setText(OsmAndFormatter.getFormattedDistance(mes[0], app));
} else {
txt.setText("");
}
}
}
public int getScreenOrientation() {
int screenOrientation = ((WindowManager) app.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
switch (screenOrientation) {
case ORIENTATION_0: // Device default (normally portrait)
screenOrientation = 0;
break;
case ORIENTATION_90: // Landscape right
screenOrientation = 90;
break;
case ORIENTATION_270: // Landscape left
screenOrientation = 270;
break;
case ORIENTATION_180: // Upside down
screenOrientation = 180;
break;
}
//Looks like screenOrientation correction must not be applied for devices without compass?
Sensor compass = ((SensorManager) app.getSystemService(Context.SENSOR_SERVICE)).getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
if (compass == null) {
screenOrientation = 0;
}
return screenOrientation;
}
}

View file

@ -44,7 +44,7 @@ public abstract class ActionBarPreferenceActivity extends AppCompatPreferenceAct
shadowView = null; shadowView = null;
} }
tb.setClickable(true); tb.setClickable(true);
tb.setNavigationIcon(((OsmandApplication) getApplication()).getIconsCache().getIcon(R.drawable.ic_arrow_back)); tb.setNavigationIcon(((OsmandApplication) getApplication()).getUIUtilities().getIcon(R.drawable.ic_arrow_back));
tb.setNavigationContentDescription(R.string.access_shared_string_navigate_up); tb.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
tb.setBackgroundColor(getResources().getColor(getResIdFromAttribute(this, R.attr.pstsTabBackground))); tb.setBackgroundColor(getResources().getColor(getResIdFromAttribute(this, R.attr.pstsTabBackground)));
tb.setTitleTextColor(getResources().getColor(getResIdFromAttribute(this, R.attr.pstsTextColor))); tb.setTitleTextColor(getResources().getColor(getResIdFromAttribute(this, R.attr.pstsTextColor)));

View file

@ -244,7 +244,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
if (color == 0) { if (color == 0) {
colorImageView.setImageDrawable(getContentIcon(R.drawable.ic_action_circle)); colorImageView.setImageDrawable(getContentIcon(R.drawable.ic_action_circle));
} else { } else {
colorImageView.setImageDrawable(getMyApplication().getIconsCache().getPaintedIcon(R.drawable.ic_action_circle, color)); colorImageView.setImageDrawable(getMyApplication().getUIUtilities().getPaintedIcon(R.drawable.ic_action_circle, color));
} }
} }
@ -284,7 +284,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
TextView textView = (TextView) v.findViewById(R.id.text1); TextView textView = (TextView) v.findViewById(R.id.text1);
textView.setText(app.getString(ColorDialogs.paletteColors[position])); textView.setText(app.getString(ColorDialogs.paletteColors[position]));
textView.setCompoundDrawablesWithIntrinsicBounds(null, null, textView.setCompoundDrawablesWithIntrinsicBounds(null, null,
app.getIconsCache().getPaintedIcon(R.drawable.ic_action_circle, color), null); app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_circle, color), null);
textView.setCompoundDrawablePadding(AndroidUtils.dpToPx(getContext(), 10f)); textView.setCompoundDrawablePadding(AndroidUtils.dpToPx(getContext(), 10f));
v.findViewById(R.id.divider).setVisibility(View.GONE); v.findViewById(R.id.divider).setVisibility(View.GONE);
} }

View file

@ -3,6 +3,24 @@
*/ */
package net.osmand.plus.activities; package net.osmand.plus.activities;
import java.text.Collator;
import java.util.Comparator;
import java.util.List;
import net.osmand.Location;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.OsmAndListFragment;
import net.osmand.util.MapUtils;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
@ -20,23 +38,6 @@ import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.OsmAndListFragment;
import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.util.MapUtils;
import java.util.Comparator;
import java.util.List;
public class FavoritesListFragment extends OsmAndListFragment implements SearchActivityChild, OsmAndCompassListener { public class FavoritesListFragment extends OsmAndListFragment implements SearchActivityChild, OsmAndCompassListener {
public static final String SELECT_FAVORITE_POINT_INTENT_KEY = "SELECT_FAVORITE_POINT_INTENT_KEY"; public static final String SELECT_FAVORITE_POINT_INTENT_KEY = "SELECT_FAVORITE_POINT_INTENT_KEY";
@ -48,7 +49,7 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
private OsmandSettings settings; private OsmandSettings settings;
private boolean compassRegistered; private boolean compassRegistered;
float lastHeading ;
@Override @Override
public void onAttach(Activity activity) { public void onAttach(Activity activity) {
@ -67,7 +68,7 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
double lat = intent.getDoubleExtra(SearchActivity.SEARCH_LAT, 0); double lat = intent.getDoubleExtra(SearchActivity.SEARCH_LAT, 0);
double lon = intent.getDoubleExtra(SearchActivity.SEARCH_LON, 0); double lon = intent.getDoubleExtra(SearchActivity.SEARCH_LON, 0);
if (lat != 0 || lon != 0) { if (lat != 0 || lon != 0) {
favouritesAdapter.location = new LatLon(lat, lon); favouritesAdapter.cache.specialFrom = new LatLon(lat, lon);
} }
} }
} }
@ -85,15 +86,10 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
if (getActivity() instanceof SearchActivity && ((SearchActivity) getActivity()).getSearchPoint() != null) {
if (favouritesAdapter.location == null && getActivity() instanceof SearchActivity) { favouritesAdapter.cache.specialFrom = ((SearchActivity) getActivity()).getSearchPoint();
favouritesAdapter.location = ((SearchActivity) getActivity()).getSearchPoint();
} }
if (favouritesAdapter.location == null) { locationUpdate(favouritesAdapter.cache.specialFrom);
favouritesAdapter.location = settings.getLastKnownMapLocation();
}
favouritesAdapter.screenOrientation = DashLocationFragment.getScreenOrientation(getActivity());
locationUpdate(favouritesAdapter.location);
} }
@Override @Override
@ -106,13 +102,17 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
app.getLocationProvider().addCompassListener(this); app.getLocationProvider().addCompassListener(this);
compassRegistered = true; compassRegistered = true;
} }
favouritesAdapter.searchAroundLocation = true; favouritesAdapter.cache.specialFrom = null;
} else { } else {
favouritesAdapter.searchAroundLocation = false; favouritesAdapter.cache.specialFrom = ((SearchActivity) getActivity()).getSearchPoint();
} }
} }
if (favouritesAdapter != null) { if (favouritesAdapter != null) {
favouritesAdapter.updateLocation(l); if(l != null) {
favouritesAdapter.sortByName();
} else {
favouritesAdapter.sortByDistance(l);
}
} }
} }
@ -156,33 +156,27 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
public static class FavouritesAdapter extends ArrayAdapter<FavouritePoint> { public static class FavouritesAdapter extends ArrayAdapter<FavouritePoint> {
private Activity activity; private Activity activity;
private LatLon location;
private OsmandApplication app; private OsmandApplication app;
private boolean searchAroundLocation; private boolean shouldShowMenuButton;
private int screenOrientation; private UpdateLocationViewCache cache;
private Float heading;
private boolean shoudShowMenuButton;
public FavouritesAdapter(Activity activity, List<FavouritePoint> list, public FavouritesAdapter(Activity activity, List<FavouritePoint> list,
boolean shoudShowMenuButton) { boolean shouldShowMenuButton) {
super(activity, R.layout.favorites_list_item, list); super(activity, R.layout.favorites_list_item, list);
this.activity = activity; this.activity = activity;
this.app = ((OsmandApplication) activity.getApplication()); this.app = ((OsmandApplication) activity.getApplication());
this.shoudShowMenuButton = shoudShowMenuButton; this.shouldShowMenuButton = shouldShowMenuButton;
cache = app.getUIUtilities().getUpdateLocationViewCache();
} }
public LatLon getLocation() {
return location;
}
public void updateLocation(LatLon l) { public void updateLocation(final LatLon l) {
location = l;
sort(new Comparator<FavouritePoint>() { sort(new Comparator<FavouritePoint>() {
@Override @Override
public int compare(FavouritePoint object1, FavouritePoint object2) { public int compare(FavouritePoint object1, FavouritePoint object2) {
if (location != null) { if (l != null) {
double d1 = MapUtils.getDistance(location, object1.getLatitude(), object1.getLongitude()); double d1 = MapUtils.getDistance(l, object1.getLatitude(), object1.getLongitude());
double d2 = MapUtils.getDistance(location, object2.getLatitude(), object2.getLongitude()); double d2 = MapUtils.getDistance(l, object2.getLatitude(), object2.getLongitude());
if (d1 == d2) { if (d1 == d2) {
return 0; return 0;
} else if (d1 > d2) { } else if (d1 > d2) {
@ -204,7 +198,7 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView; View row = convertView;
if (row == null) { if (row == null) {
LayoutInflater inflater = activity.getLayoutInflater(); // favourite dank LayoutInflater inflater = activity.getLayoutInflater();
row = inflater.inflate(R.layout.favorites_list_item, parent, false); row = inflater.inflate(R.layout.favorites_list_item, parent, false);
} }
@ -212,14 +206,14 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
TextView distanceText = (TextView) row.findViewById(R.id.distance); TextView distanceText = (TextView) row.findViewById(R.id.distance);
ImageView icon = (ImageView) row.findViewById(R.id.favourite_icon); ImageView icon = (ImageView) row.findViewById(R.id.favourite_icon);
ImageView direction = (ImageView) row.findViewById(R.id.direction); ImageView direction = (ImageView) row.findViewById(R.id.direction);
ImageView giImage= (ImageView)row.findViewById(R.id.group_image); ImageView giImage = (ImageView) row.findViewById(R.id.group_image);
direction.setVisibility(View.VISIBLE); direction.setVisibility(View.VISIBLE);
final FavouritePoint favorite = getItem(position); final FavouritePoint favorite = getItem(position);
if (shoudShowMenuButton) { if (shouldShowMenuButton) {
ImageButton options = (ImageButton) row.findViewById(R.id.options); ImageButton options = (ImageButton) row.findViewById(R.id.options);
options.setFocusable(false); options.setFocusable(false);
options.setImageDrawable(((OsmandApplication) activity.getApplication()) options.setImageDrawable(((OsmandApplication) activity.getApplication()).getUIUtilities()
.getIconsCache().getThemedIcon(R.drawable.ic_overflow_menu_white)); .getThemedIcon(R.drawable.ic_overflow_menu_white));
options.setVisibility(View.VISIBLE); options.setVisibility(View.VISIBLE);
options.setOnClickListener(new View.OnClickListener() { options.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -230,25 +224,65 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
} }
if (!favorite.getCategory().isEmpty()) { if (!favorite.getCategory().isEmpty()) {
giImage.setVisibility(View.VISIBLE); giImage.setVisibility(View.VISIBLE);
giImage.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_small_group)); giImage.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_small_group));
} else { } else {
giImage.setVisibility(View.GONE); giImage.setVisibility(View.GONE);
} }
((TextView) row.findViewById(R.id.group_name)).setText(favorite.getCategory()); ((TextView) row.findViewById(R.id.group_name)).setText(favorite.getCategory());
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity, favorite.getColor(), false)); icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity, favorite.getColor(), false));
DashLocationFragment.updateLocationView(!searchAroundLocation, location, heading, direction, distanceText,
favorite.getLatitude(), favorite.getLongitude(), screenOrientation, app); app.getUIUtilities().updateLocationView(cache, direction, distanceText,
favorite.getLatitude(), favorite.getLongitude());
name.setText(getName(favorite)); name.setText(getName(favorite));
final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item); final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item);
icon.setVisibility(View.VISIBLE); icon.setVisibility(View.VISIBLE);
ch.setVisibility(View.GONE); ch.setVisibility(View.GONE);
if (activity instanceof SearchActivity) if (activity instanceof SearchActivity)
ViewCompat.setAccessibilityDelegate(row, ((SearchActivity)activity).getAccessibilityAssistant()); ViewCompat.setAccessibilityDelegate(row, ((SearchActivity) activity).getAccessibilityAssistant());
return row; return row;
} }
public void sortByName() {
final Collator inst = Collator.getInstance();
sort(new Comparator<FavouritePoint>() {
@Override
public int compare(FavouritePoint o1, FavouritePoint o2) {
return inst.compare(o1.getName(), o2.getName());
}
});
}
public void sortByDistance(final LatLon loc) {
sort(new Comparator<FavouritePoint>() {
@Override
public int compare(FavouritePoint lhs, FavouritePoint rhs) {
if (loc == null) {
return 0;
}
double ld = MapUtils.getDistance(loc, lhs.getLatitude(), lhs.getLongitude());
double rd = MapUtils.getDistance(loc, rhs.getLatitude(), rhs.getLongitude());
return Double.compare(ld, rd);
}
});
}
public void sortByDefault() {
Location loc = app.getLocationProvider().getLastStaleKnownLocation();
LatLon map = app.getMapViewTrackingUtilities().getMapLocation();
if (loc != null) {
sortByDistance(new LatLon(loc.getLatitude(), loc.getLongitude()));
} else if(map != null){
sortByDistance(map);
} else{
sortByName();
}
}
} }
public OsmandApplication getMyApplication() { public OsmandApplication getMyApplication() {
@ -260,9 +294,8 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
// 99 in next line used to one-time initialize arrows (with reference vs. fixed-north direction) on non-compass // 99 in next line used to one-time initialize arrows (with reference vs. fixed-north direction) on non-compass
// devices // devices
FragmentActivity activity = getActivity(); FragmentActivity activity = getActivity();
float lastHeading = favouritesAdapter.heading != null ? favouritesAdapter.heading : 99; if (Math.abs(MapUtils.degreesDiff(lastHeading, value)) > 5) {
favouritesAdapter.heading = value; lastHeading = value;
if (Math.abs(MapUtils.degreesDiff(lastHeading, favouritesAdapter.heading)) > 5) {
if (activity instanceof SearchActivity) { if (activity instanceof SearchActivity) {
((SearchActivity)activity).getAccessibilityAssistant().lockEvents(); ((SearchActivity)activity).getAccessibilityAssistant().lockEvents();
favouritesAdapter.notifyDataSetChanged(); favouritesAdapter.notifyDataSetChanged();
@ -270,8 +303,6 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
} else { } else {
favouritesAdapter.notifyDataSetChanged(); favouritesAdapter.notifyDataSetChanged();
} }
} else {
favouritesAdapter.heading = lastHeading;
} }
if (activity instanceof SearchActivity) { if (activity instanceof SearchActivity) {
final View selected = ((SearchActivity)activity).getAccessibilityAssistant().getFocusedView(); final View selected = ((SearchActivity)activity).getAccessibilityAssistant().getFocusedView();
@ -281,7 +312,7 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
if ((position != AdapterView.INVALID_POSITION) && (position >= getListView().getHeaderViewsCount())) { if ((position != AdapterView.INVALID_POSITION) && (position >= getListView().getHeaderViewsCount())) {
FavouritePoint point = favouritesAdapter.getItem(position - getListView().getHeaderViewsCount()); FavouritePoint point = favouritesAdapter.getItem(position - getListView().getHeaderViewsCount());
LatLon location = new LatLon(point.getLatitude(), point.getLongitude()); LatLon location = new LatLon(point.getLatitude(), point.getLongitude());
((SearchActivity)activity).getNavigationInfo().updateTargetDirection(location, favouritesAdapter.heading.floatValue()); ((SearchActivity)activity).getNavigationInfo().updateTargetDirection(location, value);
} }
} catch (Exception e) { } catch (Exception e) {
return; return;

View file

@ -105,7 +105,7 @@ public class FavoritesSearchFragment extends DialogFragment {
} }
toolbar = (Toolbar) view.findViewById(R.id.toolbar); toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setNavigationIcon(app.getIconsCache().getThemedIcon(R.drawable.ic_arrow_back)); toolbar.setNavigationIcon(app.getUIUtilities().getThemedIcon(R.drawable.ic_arrow_back));
toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up); toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
toolbar.setNavigationOnClickListener( toolbar.setNavigationOnClickListener(
new View.OnClickListener() { new View.OnClickListener() {
@ -141,7 +141,7 @@ public class FavoritesSearchFragment extends DialogFragment {
progressBar = (ProgressBar) view.findViewById(R.id.searchProgressBar); progressBar = (ProgressBar) view.findViewById(R.id.searchProgressBar);
clearButton = (ImageButton) view.findViewById(R.id.clearButton); clearButton = (ImageButton) view.findViewById(R.id.clearButton);
clearButton.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_remove_dark)); clearButton.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_remove_dark));
clearButton.setOnClickListener( clearButton.setOnClickListener(
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override

View file

@ -149,7 +149,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
View searchView = inflater.inflate(R.layout.search_fav_list_item, null); View searchView = inflater.inflate(R.layout.search_fav_list_item, null);
searchView.setBackgroundResource(light ? R.color.bg_color_light : R.color.bg_color_dark); searchView.setBackgroundResource(light ? R.color.bg_color_light : R.color.bg_color_dark);
TextView title = (TextView) searchView.findViewById(R.id.title); TextView title = (TextView) searchView.findViewById(R.id.title);
title.setCompoundDrawablesWithIntrinsicBounds(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_search_dark), null, null, null); title.setCompoundDrawablesWithIntrinsicBounds(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_search_dark), null, null, null);
title.setHint(R.string.shared_string_search); title.setHint(R.string.shared_string_search);
searchView.setOnClickListener(new View.OnClickListener() { searchView.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -783,7 +783,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
int disabledColor = light ? R.color.secondary_text_light : R.color.secondary_text_dark; int disabledColor = light ? R.color.secondary_text_light : R.color.secondary_text_dark;
row.findViewById(R.id.group_divider).setVisibility(groupPosition == 0 ? View.GONE : View.VISIBLE); row.findViewById(R.id.group_divider).setVisibility(groupPosition == 0 ? View.GONE : View.VISIBLE);
int color = model.color == 0 || model.color == Color.BLACK ? getResources().getColor(R.color.color_favorite) : model.color; int color = model.color == 0 || model.color == Color.BLACK ? getResources().getColor(R.color.color_favorite) : model.color;
setCategoryIcon(app, app.getIconsCache().getPaintedIcon( setCategoryIcon(app, app.getUIUtilities().getPaintedIcon(
R.drawable.ic_action_fav_dark, visible ? (color | 0xff000000) : getResources().getColor(disabledColor)), R.drawable.ic_action_fav_dark, visible ? (color | 0xff000000) : getResources().getColor(disabledColor)),
groupPosition, isExpanded, row, light); groupPosition, isExpanded, row, light);
adjustIndicator(app, groupPosition, isExpanded, row, light); adjustIndicator(app, groupPosition, isExpanded, row, light);
@ -833,7 +833,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
} }
final View ch = row.findViewById(R.id.options); final View ch = row.findViewById(R.id.options);
if (!selectionMode) { if (!selectionMode) {
((ImageView) ch).setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_overflow_menu_white)); ((ImageView) ch).setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_overflow_menu_white));
ch.setVisibility(View.VISIBLE); ch.setVisibility(View.VISIBLE);
ch.setContentDescription(getString(R.string.shared_string_settings)); ch.setContentDescription(getString(R.string.shared_string_settings));
ch.setOnClickListener(new View.OnClickListener() { ch.setOnClickListener(new View.OnClickListener() {
@ -877,7 +877,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
if (showOptionsButton) { if (showOptionsButton) {
ImageView options = (ImageView) row.findViewById(R.id.options); ImageView options = (ImageView) row.findViewById(R.id.options);
options.setFocusable(false); options.setFocusable(false);
options.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon( options.setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(
R.drawable.ic_overflow_menu_white)); R.drawable.ic_overflow_menu_white));
options.setVisibility(View.VISIBLE); options.setVisibility(View.VISIBLE);
options.setOnClickListener(new View.OnClickListener() { options.setOnClickListener(new View.OnClickListener() {

View file

@ -252,7 +252,7 @@ public class IntermediatePointsDialog {
} else { } else {
int icon = position == intermediates.size() - 1? R.drawable.ic_action_target: int icon = position == intermediates.size() - 1? R.drawable.ic_action_target:
R.drawable.ic_action_intermediate; R.drawable.ic_action_intermediate;
tv.setCompoundDrawablesWithIntrinsicBounds(app.getIconsCache().getThemedIcon(icon), null, null, null); tv.setCompoundDrawablesWithIntrinsicBounds(app.getUIUtilities().getThemedIcon(icon), null, null, null);
tv.setCompoundDrawablePadding(padding); tv.setCompoundDrawablePadding(padding);
final CheckBox ch = ((CheckBox) v.findViewById(R.id.toggle_item)); final CheckBox ch = ((CheckBox) v.findViewById(R.id.toggle_item));
ch.setVisibility(View.VISIBLE); ch.setVisibility(View.VISIBLE);

View file

@ -160,7 +160,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
private static final Log LOG = PlatformUtil.getLog(MapActivity.class); private static final Log LOG = PlatformUtil.getLog(MapActivity.class);
private static MapViewTrackingUtilities mapViewTrackingUtilities; private MapViewTrackingUtilities mapViewTrackingUtilities;
private static MapContextMenu mapContextMenu = new MapContextMenu(); private static MapContextMenu mapContextMenu = new MapContextMenu();
private static Intent prevActivityIntent = null; private static Intent prevActivityIntent = null;
@ -220,7 +220,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
boolean portraitMode = AndroidUiHelper.isOrientationPortrait(this); boolean portraitMode = AndroidUiHelper.isOrientationPortrait(this);
boolean largeDevice = AndroidUiHelper.isXLargeDevice(this); boolean largeDevice = AndroidUiHelper.isXLargeDevice(this);
landscapeLayout = !portraitMode && !largeDevice; landscapeLayout = !portraitMode && !largeDevice;
mapViewTrackingUtilities = app.getMapViewTrackingUtilities();
mapContextMenu.setMapActivity(this); mapContextMenu.setMapActivity(this);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -1226,10 +1226,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
} }
public LatLon getMapLocation() { public LatLon getMapLocation() {
if (mapView == null) { return mapViewTrackingUtilities.getMapLocation();
return settings.getLastKnownMapLocation();
}
return new LatLon(mapView.getLatitude(), mapView.getLongitude());
} }
public float getMapRotate() { public float getMapRotate() {
@ -1451,9 +1448,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
return mapViewTrackingUtilities; return mapViewTrackingUtilities;
} }
public static MapViewTrackingUtilities getSingleMapViewTrackingUtilities() {
return mapViewTrackingUtilities;
}
protected void parseLaunchIntentLocation() { protected void parseLaunchIntentLocation() {
Intent intent = getIntent(); Intent intent = getIntent();

View file

@ -327,7 +327,7 @@ public class MapActivityLayers {
@Override @Override
public void onShow(DialogInterface dialog) { public void onShow(DialogInterface dialog) {
Button neutralButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); Button neutralButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
Drawable drawable = app.getIconsCache().getThemedIcon(R.drawable.ic_action_singleselect); Drawable drawable = app.getUIUtilities().getThemedIcon(R.drawable.ic_action_singleselect);
neutralButton.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); neutralButton.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
neutralButton.setContentDescription(app.getString(R.string.shared_string_filters)); neutralButton.setContentDescription(app.getString(R.string.shared_string_filters));
} }
@ -391,7 +391,7 @@ public class MapActivityLayers {
@Override @Override
public void onShow(DialogInterface dialog) { public void onShow(DialogInterface dialog) {
Button neutralButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); Button neutralButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
Drawable drawable = app.getIconsCache().getThemedIcon(R.drawable.ic_action_multiselect); Drawable drawable = app.getUIUtilities().getThemedIcon(R.drawable.ic_action_multiselect);
neutralButton.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); neutralButton.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
neutralButton.setContentDescription(app.getString(R.string.apply_filters)); neutralButton.setContentDescription(app.getString(R.string.apply_filters));
} }

View file

@ -106,7 +106,7 @@ public class NavigatePointFragment extends Fragment implements SearchActivityChi
} }
MenuItem menuItem = menu.add(0, SHOW_ON_MAP, 0, R.string.shared_string_show_on_map); MenuItem menuItem = menu.add(0, SHOW_ON_MAP, 0, R.string.shared_string_show_on_map);
MenuItemCompat.setShowAsAction(menuItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); MenuItemCompat.setShowAsAction(menuItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
menuItem = menuItem.setIcon(app.getIconsCache().getIcon(R.drawable.ic_action_marker_dark, light)); menuItem = menuItem.setIcon(app.getUIUtilities().getIcon(R.drawable.ic_action_marker_dark, light));
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override @Override

View file

@ -122,7 +122,7 @@ public class OpeningHoursView {
} }
TextView label = (TextView)row.findViewById(R.id.label); TextView label = (TextView)row.findViewById(R.id.label);
ImageView icon = (ImageView)row.findViewById(R.id.remove); ImageView icon = (ImageView)row.findViewById(R.id.remove);
icon.setBackgroundDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_remove_dark)); icon.setBackgroundDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_remove_dark));
if(selectedRule == position){ if(selectedRule == position){
label.setTypeface(null, Typeface.BOLD); label.setTypeface(null, Typeface.BOLD);
label.setTextSize(22); label.setTextSize(22);

View file

@ -19,7 +19,7 @@ public class OsmandActionBarActivity extends OsmandInAppPurchaseActivity {
//should be called after set content view //should be called after set content view
protected void setupHomeButton(){ protected void setupHomeButton(){
Drawable back = ((OsmandApplication)getApplication()).getIconsCache().getIcon(R.drawable.ic_arrow_back); Drawable back = ((OsmandApplication)getApplication()).getUIUtilities().getIcon(R.drawable.ic_arrow_back);
back.setColorFilter(ContextCompat.getColor(this, R.color.color_white), PorterDuff.Mode.MULTIPLY); back.setColorFilter(ContextCompat.getColor(this, R.color.color_white), PorterDuff.Mode.MULTIPLY);
final ActionBar supportActionBar = getSupportActionBar(); final ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) { if (supportActionBar != null) {

View file

@ -13,10 +13,10 @@ public abstract class OsmandBaseExpandableListAdapter extends BaseExpandableList
protected void adjustIndicator(OsmandApplication app, int groupPosition, boolean isExpanded, View row, boolean light) { protected void adjustIndicator(OsmandApplication app, int groupPosition, boolean isExpanded, View row, boolean light) {
ImageView indicator = (ImageView) row.findViewById(R.id.explist_indicator); ImageView indicator = (ImageView) row.findViewById(R.id.explist_indicator);
if (!isExpanded) { if (!isExpanded) {
indicator.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_arrow_down, light)); indicator.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_arrow_down, light));
indicator.setContentDescription(row.getContext().getString(R.string.access_collapsed_list)); indicator.setContentDescription(row.getContext().getString(R.string.access_collapsed_list));
} else { } else {
indicator.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_arrow_up, light)); indicator.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_arrow_up, light));
indicator.setContentDescription(row.getContext().getString(R.string.access_expanded_list)); indicator.setContentDescription(row.getContext().getString(R.string.access_expanded_list));
} }
indicator.setVisibility(getChildrenCount(groupPosition) > 0 ? View.VISIBLE : View.GONE); indicator.setVisibility(getChildrenCount(groupPosition) > 0 ? View.VISIBLE : View.GONE);
@ -25,9 +25,9 @@ public abstract class OsmandBaseExpandableListAdapter extends BaseExpandableList
protected void setCategoryIcon(OsmandApplication app, int resId, int groupPosition, boolean isExpanded, View row, boolean light) { protected void setCategoryIcon(OsmandApplication app, int resId, int groupPosition, boolean isExpanded, View row, boolean light) {
ImageView icon = (ImageView) row.findViewById(R.id.category_icon); ImageView icon = (ImageView) row.findViewById(R.id.category_icon);
if (resId == 0) { if (resId == 0) {
icon.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_folder_stroke, light)); icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_folder_stroke, light));
} else { } else {
icon.setImageDrawable(app.getIconsCache().getIcon(resId, light)); icon.setImageDrawable(app.getUIUtilities().getIcon(resId, light));
} }
} }

View file

@ -54,7 +54,7 @@ public abstract class OsmandListActivity extends
public MenuItem createMenuItem(Menu m, int id, int titleRes, int iconDark, int menuItemType) { public MenuItem createMenuItem(Menu m, int id, int titleRes, int iconDark, int menuItemType) {
MenuItem menuItem = m.add(0, id, 0, titleRes); MenuItem menuItem = m.add(0, id, 0, titleRes);
if (iconDark != 0) { if (iconDark != 0) {
menuItem.setIcon(getMyApplication().getIconsCache().getIcon(iconDark)); menuItem.setIcon(getMyApplication().getUIUtilities().getIcon(iconDark));
} }
menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override @Override

View file

@ -132,7 +132,7 @@ public class PluginActivity extends OsmandActionBarActivity {
Button getButton = (Button)findViewById(R.id.plugin_get); Button getButton = (Button)findViewById(R.id.plugin_get);
Button settingsButton = (Button)findViewById(R.id.plugin_settings); Button settingsButton = (Button)findViewById(R.id.plugin_settings);
settingsButton.setCompoundDrawablesWithIntrinsicBounds( settingsButton.setCompoundDrawablesWithIntrinsicBounds(
getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_settings), getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_settings),
null, null, null); null, null, null);
View installHeader = findViewById(R.id.plugin_install_header); View installHeader = findViewById(R.id.plugin_install_header);
@ -142,7 +142,7 @@ public class PluginActivity extends OsmandActionBarActivity {
settingsButton.setVisibility(View.GONE); settingsButton.setVisibility(View.GONE);
installHeader.setVisibility(View.VISIBLE); installHeader.setVisibility(View.VISIBLE);
View worldGlobeIcon = installHeader.findViewById(R.id.ic_world_globe); View worldGlobeIcon = installHeader.findViewById(R.id.ic_world_globe);
Drawable worldGlobeDrawable = getMyApplication().getIconsCache().getThemedIcon( Drawable worldGlobeDrawable = getMyApplication().getUIUtilities().getThemedIcon(
R.drawable.ic_world_globe_dark); R.drawable.ic_world_globe_dark);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
worldGlobeIcon.setBackground(worldGlobeDrawable); worldGlobeIcon.setBackground(worldGlobeDrawable);

View file

@ -124,7 +124,7 @@ public class PluginsActivity extends OsmandListActivity {
ImageView pluginOptions = (ImageView) view.findViewById(R.id.plugin_options); ImageView pluginOptions = (ImageView) view.findViewById(R.id.plugin_options);
pluginOptions.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_overflow_menu_white)); pluginOptions.setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_overflow_menu_white));
pluginOptions.setOnClickListener(new View.OnClickListener() { pluginOptions.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {

View file

@ -1,6 +1,30 @@
package net.osmand.plus.activities; package net.osmand.plus.activities;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.osmand.IProgress;
import net.osmand.IndexConstants;
import net.osmand.data.PointDescription;
import net.osmand.osm.io.NetworkUtils;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.DrivingRegion;
import net.osmand.plus.OsmandSettings.MetricsConstants;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.dashboard.DashChooseAppDirFragment;
import net.osmand.plus.dashboard.DashChooseAppDirFragment.ChooseAppDirFragment;
import net.osmand.plus.dashboard.DashChooseAppDirFragment.MoveFilesToDifferentDirectory;
import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.render.NativeOsmandLibrary;
import net.osmand.render.RenderingRulesStorage;
import android.app.Dialog; import android.app.Dialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnClickListener;
@ -31,32 +55,6 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import net.osmand.IProgress;
import net.osmand.IndexConstants;
import net.osmand.data.PointDescription;
import net.osmand.osm.io.NetworkUtils;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.DrivingRegion;
import net.osmand.plus.OsmandSettings.MetricsConstants;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.dashboard.DashChooseAppDirFragment;
import net.osmand.plus.dashboard.DashChooseAppDirFragment.ChooseAppDirFragment;
import net.osmand.plus.dashboard.DashChooseAppDirFragment.MoveFilesToDifferentDirectory;
import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.plus.render.NativeOsmandLibrary;
import net.osmand.render.RenderingRulesStorage;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class SettingsGeneralActivity extends SettingsBaseActivity implements OnRequestPermissionsResultCallback { public class SettingsGeneralActivity extends SettingsBaseActivity implements OnRequestPermissionsResultCallback {
@ -168,7 +166,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
if (drs.get(which) == null) { if (drs.get(which) == null) {
settings.DRIVING_REGION_AUTOMATIC.set(true); settings.DRIVING_REGION_AUTOMATIC.set(true);
MapViewTrackingUtilities mapViewTrackingUtilities = MapActivity.getSingleMapViewTrackingUtilities(); MapViewTrackingUtilities mapViewTrackingUtilities = getMyApplication().getMapViewTrackingUtilities();
if (mapViewTrackingUtilities != null) { if (mapViewTrackingUtilities != null) {
mapViewTrackingUtilities.resetDrivingRegionUpdate(); mapViewTrackingUtilities.resetDrivingRegionUpdate();
} }

View file

@ -46,7 +46,7 @@ import net.osmand.plus.GPXUtilities.TrkSegment;
import net.osmand.plus.GPXUtilities.WptPt; import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
@ -108,7 +108,7 @@ public class ShowRouteInfoDialogFragment extends DialogFragment {
view = inflater.inflate(R.layout.route_info_layout, container, false); view = inflater.inflate(R.layout.route_info_layout, container, false);
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar); Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_arrow_back)); toolbar.setNavigationIcon(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_arrow_back));
toolbar.setNavigationContentDescription(R.string.shared_string_close); toolbar.setNavigationContentDescription(R.string.shared_string_close);
toolbar.setNavigationOnClickListener(new View.OnClickListener() { toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override @Override
@ -118,9 +118,9 @@ public class ShowRouteInfoDialogFragment extends DialogFragment {
}); });
((ImageView) view.findViewById(R.id.distance_icon)) ((ImageView) view.findViewById(R.id.distance_icon))
.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_route_distance)); .setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_route_distance));
((ImageView) view.findViewById(R.id.time_icon)) ((ImageView) view.findViewById(R.id.time_icon))
.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_time_span)); .setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_time_span));
buildMenuButtons(); buildMenuButtons();
@ -337,13 +337,13 @@ public class ShowRouteInfoDialogFragment extends DialogFragment {
((TextView) headerView.findViewById(R.id.ascent_text)).setText(asc); ((TextView) headerView.findViewById(R.id.ascent_text)).setText(asc);
((ImageView) headerView.findViewById(R.id.average_icon)) ((ImageView) headerView.findViewById(R.id.average_icon))
.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_altitude_average)); .setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_altitude_average));
((ImageView) headerView.findViewById(R.id.range_icon)) ((ImageView) headerView.findViewById(R.id.range_icon))
.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_altitude_average)); .setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_altitude_average));
((ImageView) headerView.findViewById(R.id.descent_icon)) ((ImageView) headerView.findViewById(R.id.descent_icon))
.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_altitude_descent)); .setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_altitude_descent));
((ImageView) headerView.findViewById(R.id.ascent_icon)) ((ImageView) headerView.findViewById(R.id.ascent_icon))
.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_altitude_ascent)); .setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_altitude_ascent));
headerView.findViewById(R.id.details_view).setOnClickListener(new View.OnClickListener() { headerView.findViewById(R.id.details_view).setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -415,7 +415,7 @@ public class ShowRouteInfoDialogFragment extends DialogFragment {
} }
private void buildMenuButtons() { private void buildMenuButtons() {
IconsCache iconsCache = getMyApplication().getIconsCache(); UiUtilities iconsCache = getMyApplication().getUIUtilities();
ImageButton printRoute = (ImageButton) view.findViewById(R.id.print_route); ImageButton printRoute = (ImageButton) view.findViewById(R.id.print_route);
printRoute.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_gprint_dark)); printRoute.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_gprint_dark));
printRoute.setOnClickListener(new View.OnClickListener() { printRoute.setOnClickListener(new View.OnClickListener() {

View file

@ -76,15 +76,15 @@ public class AppModeDialog {
ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon); ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon);
boolean nightMode = isNightMode(ctx, useMapTheme); boolean nightMode = isNightMode(ctx, useMapTheme);
if (checked) { if (checked) {
iv.setImageDrawable(ctx.getIconsCache().getIcon(mode.getSmallIconDark(), nightMode ? R.color.route_info_checked_mode_icon_color_dark : R.color.route_info_checked_mode_icon_color_light)); iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getSmallIconDark(), nightMode ? R.color.route_info_checked_mode_icon_color_dark : R.color.route_info_checked_mode_icon_color_light));
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_checked))); iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_checked)));
tb.findViewById(R.id.selection).setVisibility(View.VISIBLE); tb.findViewById(R.id.selection).setVisibility(View.VISIBLE);
} else { } else {
if (useMapTheme) { if (useMapTheme) {
iv.setImageDrawable(ctx.getIconsCache().getIcon(mode.getSmallIconDark(), R.color.route_info_unchecked_mode_icon_color)); iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getSmallIconDark(), R.color.route_info_unchecked_mode_icon_color));
iv.setBackgroundResource(AndroidUtils.resolveAttribute(ctx, android.R.attr.selectableItemBackground)); iv.setBackgroundResource(AndroidUtils.resolveAttribute(ctx, android.R.attr.selectableItemBackground));
} else { } else {
iv.setImageDrawable(ctx.getIconsCache().getThemedIcon(mode.getSmallIconDark())); iv.setImageDrawable(ctx.getUIUtilities().getThemedIcon(mode.getSmallIconDark()));
} }
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_unchecked))); iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_unchecked)));
tb.findViewById(R.id.selection).setVisibility(View.INVISIBLE); tb.findViewById(R.id.selection).setVisibility(View.INVISIBLE);
@ -123,7 +123,7 @@ public class AppModeDialog {
int metricsY = (int) ctx.getResources().getDimension(R.dimen.route_info_modes_height); int metricsY = (int) ctx.getResources().getDimension(R.dimen.route_info_modes_height);
View tb = layoutInflater.inflate(R.layout.mode_view, null); View tb = layoutInflater.inflate(R.layout.mode_view, null);
ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon); ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon);
iv.setImageDrawable(ctx.getIconsCache().getIcon(mode.getSmallIconDark(), isNightMode(ctx, useMapTheme) ? R.color.route_info_checked_mode_icon_color_dark : R.color.route_info_checked_mode_icon_color_light)); iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getSmallIconDark(), isNightMode(ctx, useMapTheme) ? R.color.route_info_checked_mode_icon_color_dark : R.color.route_info_checked_mode_icon_color_light));
iv.setContentDescription(mode.toHumanString(ctx)); iv.setContentDescription(mode.toHumanString(ctx));
// tb.setCompoundDrawablesWithIntrinsicBounds(null, ctx.getIconsCache().getIcon(mode.getIconId(), R.color.app_mode_icon_color), null, null); // tb.setCompoundDrawablesWithIntrinsicBounds(null, ctx.getIconsCache().getIcon(mode.getIconId(), R.color.app_mode_icon_color), null, null);
LayoutParams lp = new LinearLayout.LayoutParams(metricsX, metricsY); LayoutParams lp = new LinearLayout.LayoutParams(metricsX, metricsY);

View file

@ -179,7 +179,7 @@ public class SearchAddressFragment extends Fragment {
} }
}); });
OsmandApplication app = getApplication(); OsmandApplication app = getApplication();
Drawable icon = getApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_remove_dark); Drawable icon = getApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_remove_dark);
((ImageView)findViewById(R.id.ResetBuilding)).setBackgroundDrawable(icon); ((ImageView)findViewById(R.id.ResetBuilding)).setBackgroundDrawable(icon);
findViewById(R.id.ResetBuilding).setOnClickListener(new View.OnClickListener(){ findViewById(R.id.ResetBuilding).setOnClickListener(new View.OnClickListener(){
@Override @Override

View file

@ -1,5 +1,22 @@
package net.osmand.plus.activities.search; package net.osmand.plus.activities.search;
import java.util.List;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
import net.osmand.plus.base.OsmAndListFragment;
import net.osmand.plus.helpers.SearchHistoryHelper;
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
import net.osmand.util.MapUtils;
import android.app.Activity; import android.app.Activity;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
@ -24,24 +41,6 @@ import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.TextView.BufferType; import android.widget.TextView.BufferType;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
import net.osmand.plus.base.OsmAndListFragment;
import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.plus.helpers.SearchHistoryHelper;
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
import net.osmand.util.MapUtils;
import java.util.List;
public class SearchHistoryFragment extends OsmAndListFragment implements SearchActivityChild, OsmAndCompassListener { public class SearchHistoryFragment extends OsmAndListFragment implements SearchActivityChild, OsmAndCompassListener {
private LatLon location; private LatLon location;
@ -51,9 +50,9 @@ public class SearchHistoryFragment extends OsmAndListFragment implements SearchA
public static final String SEARCH_LON = SearchActivity.SEARCH_LON; public static final String SEARCH_LON = SearchActivity.SEARCH_LON;
private HistoryAdapter historyAdapter; private HistoryAdapter historyAdapter;
private Float heading; private Float heading;
private boolean searchAroundLocation;
private boolean compassRegistered; private boolean compassRegistered;
private int screenOrientation; private UpdateLocationViewCache updateLocationViewCache;
private double lastHeading;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -125,19 +124,18 @@ public class SearchHistoryFragment extends OsmAndListFragment implements SearchA
//Hardy: onResume() code is needed so that search origin is properly reflected in tab contents when origin has been changed on one tab, then tab is changed to another one. //Hardy: onResume() code is needed so that search origin is properly reflected in tab contents when origin has been changed on one tab, then tab is changed to another one.
location = null; location = null;
FragmentActivity activity = getActivity(); FragmentActivity activity = getActivity();
updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache();
Intent intent = activity.getIntent(); Intent intent = activity.getIntent();
if (intent != null) { if (intent != null) {
double lat = intent.getDoubleExtra(SEARCH_LAT, 0); double lat = intent.getDoubleExtra(SEARCH_LAT, 0);
double lon = intent.getDoubleExtra(SEARCH_LON, 0); double lon = intent.getDoubleExtra(SEARCH_LON, 0);
if (lat != 0 || lon != 0) { if (lat != 0 || lon != 0) {
historyAdapter.location = new LatLon(lat, lon); updateLocationViewCache.specialFrom = new LatLon(lat, lon);
} }
} }
if (location == null && activity instanceof SearchActivity) { if (activity instanceof SearchActivity && ((SearchActivity) activity).getSearchPoint() != null) {
location = ((SearchActivity) activity).getSearchPoint(); updateLocationViewCache.specialFrom = ((SearchActivity) activity).getSearchPoint();
}
if (location == null) {
location = ((OsmandApplication) activity.getApplication()).getSettings().getLastKnownMapLocation();
} }
historyAdapter.clear(); historyAdapter.clear();
for (HistoryEntry entry : helper.getHistoryEntries()) { for (HistoryEntry entry : helper.getHistoryEntries()) {
@ -145,12 +143,11 @@ public class SearchHistoryFragment extends OsmAndListFragment implements SearchA
} }
locationUpdate(location); locationUpdate(location);
clearButton.setVisibility(historyAdapter.isEmpty() ? View.GONE : View.VISIBLE); clearButton.setVisibility(historyAdapter.isEmpty() ? View.GONE : View.VISIBLE);
screenOrientation = DashLocationFragment.getScreenOrientation(getActivity());
} }
@Override @Override
public void locationUpdate(LatLon l) { public void locationUpdate(LatLon l) {
//location = l;
if (getActivity() instanceof SearchActivity) { if (getActivity() instanceof SearchActivity) {
if (((SearchActivity) getActivity()).isSearchAroundCurrentLocation() && l != null) { if (((SearchActivity) getActivity()).isSearchAroundCurrentLocation() && l != null) {
if (!compassRegistered) { if (!compassRegistered) {
@ -159,13 +156,13 @@ public class SearchHistoryFragment extends OsmAndListFragment implements SearchA
app.getLocationProvider().addCompassListener(this); app.getLocationProvider().addCompassListener(this);
compassRegistered = true; compassRegistered = true;
} }
searchAroundLocation = true; updateLocationViewCache.specialFrom = null;
} else { } else {
searchAroundLocation = false; updateLocationViewCache.specialFrom = ((SearchActivity) getActivity()).getSearchPoint();
} }
} }
if (historyAdapter != null) { if (historyAdapter != null) {
historyAdapter.updateLocation(l); historyAdapter.updateLocation();
} }
} }
@ -205,7 +202,7 @@ public class SearchHistoryFragment extends OsmAndListFragment implements SearchA
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v); final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
MenuItem item = optionsMenu.getMenu().add( MenuItem item = optionsMenu.getMenu().add(
R.string.shared_string_remove).setIcon( R.string.shared_string_remove).setIcon(
getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_delete_dark)); getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_delete_dark));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
@ -218,11 +215,9 @@ public class SearchHistoryFragment extends OsmAndListFragment implements SearchA
} }
class HistoryAdapter extends ArrayAdapter<HistoryEntry> { class HistoryAdapter extends ArrayAdapter<HistoryEntry> {
private LatLon location;
public void updateLocation(LatLon l) { public void updateLocation() {
location = l;
notifyDataSetChanged(); notifyDataSetChanged();
} }
@ -241,10 +236,11 @@ public class SearchHistoryFragment extends OsmAndListFragment implements SearchA
udpateHistoryItem(historyEntry, row, location, getActivity(), getMyApplication()); udpateHistoryItem(historyEntry, row, location, getActivity(), getMyApplication());
TextView distanceText = (TextView) row.findViewById(R.id.distance); TextView distanceText = (TextView) row.findViewById(R.id.distance);
ImageView direction = (ImageView) row.findViewById(R.id.direction); ImageView direction = (ImageView) row.findViewById(R.id.direction);
DashLocationFragment.updateLocationView(!searchAroundLocation, location, heading, direction, distanceText, getMyApplication().getUIUtilities().updateLocationView(updateLocationViewCache,
historyEntry.getLat(), historyEntry.getLon(), screenOrientation, getMyApplication()); direction, distanceText, historyEntry.getLat(),
historyEntry.getLon());
ImageButton options = (ImageButton) row.findViewById(R.id.options); ImageButton options = (ImageButton) row.findViewById(R.id.options);
options.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_overflow_menu_white)); options.setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_overflow_menu_white));
options.setVisibility(View.VISIBLE); options.setVisibility(View.VISIBLE);
options.setOnClickListener(new View.OnClickListener() { options.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -264,7 +260,7 @@ public class SearchHistoryFragment extends OsmAndListFragment implements SearchA
TextView nameText = (TextView) row.findViewById(R.id.name); TextView nameText = (TextView) row.findViewById(R.id.name);
TextView distanceText = (TextView) row.findViewById(R.id.distance); TextView distanceText = (TextView) row.findViewById(R.id.distance);
ImageView direction = (ImageView) row.findViewById(R.id.direction); ImageView direction = (ImageView) row.findViewById(R.id.direction);
IconsCache ic = app.getIconsCache(); UiUtilities ic = app.getUIUtilities();
direction.setImageDrawable(ic.getIcon(R.drawable.ic_direction_arrow, R.color.color_distance)); direction.setImageDrawable(ic.getIcon(R.drawable.ic_direction_arrow, R.color.color_distance));
String distance = ""; String distance = "";
if (location != null) { if (location != null) {
@ -326,12 +322,9 @@ public class SearchHistoryFragment extends OsmAndListFragment implements SearchA
@Override @Override
public void updateCompassValue(float value) { public void updateCompassValue(float value) {
// 99 in next line used to one-time initalize arrows (with reference vs. fixed-north direction) on non-compass
// devices
FragmentActivity activity = getActivity(); FragmentActivity activity = getActivity();
float lastHeading = heading != null ? heading : 99; if (Math.abs(MapUtils.degreesDiff(lastHeading, value)) > 5) {
heading = value; lastHeading = value;
if (heading != null && Math.abs(MapUtils.degreesDiff(lastHeading, heading)) > 5) {
if (activity instanceof SearchActivity) { if (activity instanceof SearchActivity) {
((SearchActivity)activity).getAccessibilityAssistant().lockEvents(); ((SearchActivity)activity).getAccessibilityAssistant().lockEvents();
historyAdapter.notifyDataSetChanged(); historyAdapter.notifyDataSetChanged();
@ -339,8 +332,6 @@ public class SearchHistoryFragment extends OsmAndListFragment implements SearchA
} else { } else {
historyAdapter.notifyDataSetChanged(); historyAdapter.notifyDataSetChanged();
} }
} else {
heading = lastHeading;
} }
if (activity instanceof SearchActivity) { if (activity instanceof SearchActivity) {
final View selected = ((SearchActivity)activity).getAccessibilityAssistant().getFocusedView(); final View selected = ((SearchActivity)activity).getAccessibilityAssistant().getFocusedView();

View file

@ -3,6 +3,46 @@
*/ */
package net.osmand.plus.activities.search; package net.osmand.plus.activities.search;
import gnu.trove.set.hash.TLongHashSet;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import net.osmand.Location;
import net.osmand.ResultMatcher;
import net.osmand.access.AccessibilityAssistant;
import net.osmand.access.NavigationInfo;
import net.osmand.data.Amenity;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.osm.PoiType;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.R.color;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
import net.osmand.plus.activities.EditPOIFilterActivity;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OsmandListActivity;
import net.osmand.plus.poi.NominatimPoiFilter;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.poi.PoiUIFilter.AmenityNameFilter;
import net.osmand.plus.render.RenderingIcons;
import net.osmand.plus.views.DirectionDrawable;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
import net.osmand.util.OpeningHoursParser;
import net.osmand.util.OpeningHoursParser.OpeningHours;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
@ -36,47 +76,6 @@ import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import net.osmand.Location;
import net.osmand.ResultMatcher;
import net.osmand.access.AccessibilityAssistant;
import net.osmand.access.NavigationInfo;
import net.osmand.data.Amenity;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.osm.PoiType;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.R.color;
import net.osmand.plus.activities.EditPOIFilterActivity;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OsmandListActivity;
import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.plus.poi.NominatimPoiFilter;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.poi.PoiUIFilter.AmenityNameFilter;
import net.osmand.plus.render.RenderingIcons;
import net.osmand.plus.views.DirectionDrawable;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
import net.osmand.util.OpeningHoursParser;
import net.osmand.util.OpeningHoursParser.OpeningHours;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import gnu.trove.set.hash.TLongHashSet;
/** /**
* Search poi activity * Search poi activity
*/ */
@ -133,7 +132,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
}); });
showFilterItem = menu.add(0, FILTER, 0, R.string.search_poi_filter); showFilterItem = menu.add(0, FILTER, 0, R.string.search_poi_filter);
MenuItemCompat.setShowAsAction(showFilterItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); MenuItemCompat.setShowAsAction(showFilterItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
showFilterItem = showFilterItem.setIcon(getMyApplication().getIconsCache().getIcon( showFilterItem = showFilterItem.setIcon(getMyApplication().getUIUtilities().getIcon(
R.drawable.ic_action_filter_dark)); R.drawable.ic_action_filter_dark));
showFilterItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { showFilterItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override @Override
@ -156,7 +155,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
showOnMapItem = menu.add(0, SHOW_ON_MAP, 0, R.string.shared_string_show_on_map); showOnMapItem = menu.add(0, SHOW_ON_MAP, 0, R.string.shared_string_show_on_map);
MenuItemCompat.setShowAsAction(showOnMapItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); MenuItemCompat.setShowAsAction(showOnMapItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
showOnMapItem = showOnMapItem.setIcon(getMyApplication().getIconsCache().getIcon( showOnMapItem = showOnMapItem.setIcon(getMyApplication().getUIUtilities().getIcon(
R.drawable.ic_show_on_map)); R.drawable.ic_show_on_map));
showOnMapItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { showOnMapItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override @Override
@ -264,9 +263,9 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
}); });
searchFilter.setHint(R.string.filter_poi_hint); searchFilter.setHint(R.string.filter_poi_hint);
((ImageView) findViewById(R.id.search_icon)).setImageDrawable( ((ImageView) findViewById(R.id.search_icon)).setImageDrawable(
getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_filter_dark)); getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_filter_dark));
((ImageView) findViewById(R.id.options)). ((ImageView) findViewById(R.id.options)).
setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_overflow_menu_white)); setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_overflow_menu_white));
findViewById(R.id.options).setOnClickListener(new View.OnClickListener() { findViewById(R.id.options).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -346,7 +345,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
private void showOptionsMenu(View v) { private void showOptionsMenu(View v) {
// Show menu with search all, name finder, name finder poi // Show menu with search all, name finder, name finder poi
IconsCache iconsCache = getMyApplication().getIconsCache(); UiUtilities iconsCache = getMyApplication().getUIUtilities();
final PopupMenu optionsMenu = new PopupMenu(this, v); final PopupMenu optionsMenu = new PopupMenu(this, v);
final PoiUIFilter f = this.filter; final PoiUIFilter f = this.filter;
@ -380,7 +379,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
} }
private void addFilter(PopupMenu optionsMenu, final String value) { private void addFilter(PopupMenu optionsMenu, final String value) {
IconsCache iconsCache = getMyApplication().getIconsCache(); UiUtilities iconsCache = getMyApplication().getUIUtilities();
MenuItem item = optionsMenu.getMenu().add(getString(R.string.search_poi_filter) + ": " + value) MenuItem item = optionsMenu.getMenu().add(getString(R.string.search_poi_filter) + ": " + value)
.setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_filter_dark)); .setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_filter_dark));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@ -557,7 +556,8 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
try { try {
int position = getListView().getPositionForView(selected); int position = getListView().getPositionForView(selected);
if ((position != AdapterView.INVALID_POSITION) && (position >= getListView().getHeaderViewsCount())) { if ((position != AdapterView.INVALID_POSITION) && (position >= getListView().getHeaderViewsCount())) {
navigationInfo.updateTargetDirection(amenityAdapter.getItem(position - getListView().getHeaderViewsCount()).getLocation(), heading.floatValue()); navigationInfo.updateTargetDirection(amenityAdapter.getItem(position - getListView().getHeaderViewsCount()).
getLocation(), heading.floatValue());
} }
} catch (Exception e) { } catch (Exception e) {
return; return;
@ -717,10 +717,11 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
class AmenityAdapter extends ArrayAdapter<Amenity> { class AmenityAdapter extends ArrayAdapter<Amenity> {
private AmenityFilter listFilter; private AmenityFilter listFilter;
private List<Amenity> originalAmenityList; private List<Amenity> originalAmenityList;
private int screenOrientation; private UpdateLocationViewCache updateLocationViewCache;
AmenityAdapter(List<Amenity> list) { AmenityAdapter(List<Amenity> list) {
super(SearchPOIActivity.this, R.layout.searchpoi_list, list); super(SearchPOIActivity.this, R.layout.searchpoi_list, list);
updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache();
originalAmenityList = new ArrayList<Amenity>(list); originalAmenityList = new ArrayList<Amenity>(list);
this.setNotifyOnChange(false); this.setNotifyOnChange(false);
} }
@ -731,7 +732,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
public void setNewModel(List<Amenity> amenityList) { public void setNewModel(List<Amenity> amenityList) {
setNotifyOnChange(false); setNotifyOnChange(false);
screenOrientation = DashLocationFragment.getScreenOrientation(SearchPOIActivity.this); updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache();
originalAmenityList = new ArrayList<Amenity>(amenityList); originalAmenityList = new ArrayList<Amenity>(amenityList);
clear(); clear();
for (Amenity obj : amenityList) { for (Amenity obj : amenityList) {
@ -768,7 +769,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
timeIcon.setVisibility(View.VISIBLE); timeIcon.setVisibility(View.VISIBLE);
timeText.setVisibility(View.VISIBLE); timeText.setVisibility(View.VISIBLE);
timeIcon.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_small_time, colorId)); timeIcon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_small_time, colorId));
timeText.setTextColor(app.getResources().getColor(colorId)); timeText.setTextColor(app.getResources().getColor(colorId));
String rt = rs.getCurrentRuleTime(inst); String rt = rs.getCurrentRuleTime(inst);
timeText.setText(rt == null ? "" : rt); timeText.setText(rt == null ? "" : rt);
@ -790,19 +791,12 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
direction.setImageDrawable(draw); direction.setImageDrawable(draw);
} }
net.osmand.Location loc = location; net.osmand.Location loc = location;
if (loc != null) { if(searchNearBy) {
mes = new float[2]; updateLocationViewCache.specialFrom = null;
LatLon l = amenity.getLocation(); } else if(loc != null) {
net.osmand.Location.distanceBetween(l.getLatitude(), l.getLongitude(), loc.getLatitude(), updateLocationViewCache.specialFrom = new LatLon(loc.getLatitude(), loc.getLongitude());
loc.getLongitude(), mes);
} }
if (loc != null) { getMyApplication().getUIUtilities().updateLocationView(updateLocationViewCache, direction, distanceText, amenity.getLocation());
float a = heading != null ? heading : 0;
draw.setAngle(mes[1] - a + 180 + screenOrientation);
} else {
draw.setAngle(0);
}
draw.setColorId(searchNearBy ? color.color_myloc_distance : color.color_distance);
direction.setImageDrawable(draw); direction.setImageDrawable(draw);
PoiType st = amenity.getType().getPoiTypeByKeyName(amenity.getSubType()); PoiType st = amenity.getType().getPoiTypeByKeyName(amenity.getSubType());
if (st != null) { if (st != null) {
@ -817,15 +811,10 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
icon.setImageDrawable(null); icon.setImageDrawable(null);
} }
String distance = " ";
if (mes != null) {
distance = " " + OsmAndFormatter.getFormattedDistance((int) mes[0], getMyApplication()) + " "; //$NON-NLS-1$
}
String poiType = OsmAndFormatter.getPoiStringWithoutType(amenity, String poiType = OsmAndFormatter.getPoiStringWithoutType(amenity,
app.getSettings().MAP_PREFERRED_LOCALE.get(), app.getSettings().MAP_PREFERRED_LOCALE.get(),
app.getSettings().MAP_TRANSLITERATE_NAMES.get()); app.getSettings().MAP_TRANSLITERATE_NAMES.get());
label.setText(poiType); label.setText(poiType);
distanceText.setText(distance);
ViewCompat.setAccessibilityDelegate(row, accessibilityAssistant); ViewCompat.setAccessibilityDelegate(row, accessibilityAssistant);
return (row); return (row);
} }

View file

@ -30,7 +30,7 @@ import net.osmand.CollatorStringMatcher.StringMatcherMode;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.osm.AbstractPoiType; import net.osmand.osm.AbstractPoiType;
import net.osmand.osm.PoiType; import net.osmand.osm.PoiType;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -67,7 +67,7 @@ public class SearchPoiFilterFragment extends OsmAndListFragment implements Searc
v.findViewById(R.id.SearchFilterLayout).setVisibility(View.VISIBLE); v.findViewById(R.id.SearchFilterLayout).setVisibility(View.VISIBLE);
((EditText) v.findViewById(R.id.searchEditText)).setHint(R.string.search_poi_category_hint); ((EditText) v.findViewById(R.id.searchEditText)).setHint(R.string.search_poi_category_hint);
((ImageView) v.findViewById(R.id.search_icon)).setImageDrawable( ((ImageView) v.findViewById(R.id.search_icon)).setImageDrawable(
getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_search_dark)); getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_search_dark));
setupSearchEditText((EditText) v.findViewById(R.id.searchEditText)); setupSearchEditText((EditText) v.findViewById(R.id.searchEditText));
setupOptions((ImageView) v.findViewById(R.id.options)); setupOptions((ImageView) v.findViewById(R.id.options));
@ -76,7 +76,7 @@ public class SearchPoiFilterFragment extends OsmAndListFragment implements Searc
} }
private void setupOptions(ImageView options) { private void setupOptions(ImageView options) {
options.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_overflow_menu_white)); options.setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_overflow_menu_white));
options.setOnClickListener(new View.OnClickListener() { options.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -326,7 +326,7 @@ public class SearchPoiFilterFragment extends OsmAndListFragment implements Searc
private void showOptionsMenu(View v) { private void showOptionsMenu(View v) {
// Show menu with search all, name finder, name finder poi // Show menu with search all, name finder, name finder poi
IconsCache iconsCache = getMyApplication().getIconsCache(); UiUtilities iconsCache = getMyApplication().getUIUtilities();
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v); final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
MenuItem item = optionsMenu.getMenu().add(R.string.poi_filter_custom_filter) MenuItem item = optionsMenu.getMenu().add(R.string.poi_filter_custom_filter)

View file

@ -10,7 +10,7 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin.AVActionType; import net.osmand.plus.audionotes.AudioVideoNotesPlugin.AVActionType;
@ -124,7 +124,7 @@ public class AudioVideoNoteRecordingMenu {
public void update() { public void update() {
CurrentRecording recording = plugin.getCurrentRecording(); CurrentRecording recording = plugin.getCurrentRecording();
IconsCache iconsCache = plugin.getMapActivity().getMyApplication().getIconsCache(); UiUtilities iconsCache = plugin.getMapActivity().getMyApplication().getUIUtilities();
ImageView leftButtonIcon = (ImageView) view.findViewById(R.id.leftButtonIcon); ImageView leftButtonIcon = (ImageView) view.findViewById(R.id.leftButtonIcon);
View leftButtonView = view.findViewById(R.id.leftButtonView); View leftButtonView = view.findViewById(R.id.leftButtonView);

View file

@ -94,7 +94,7 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
View view = inflater.inflate(R.layout.note, null, false); View view = inflater.inflate(R.layout.note, null, false);
getNoteView(recording, view, getMyApplication()); getNoteView(recording, view, getMyApplication());
((ImageView) view.findViewById(R.id.play)).setImageDrawable(getMyApplication().getIconsCache() ((ImageView) view.findViewById(R.id.play)).setImageDrawable(getMyApplication().getUIUtilities()
.getThemedIcon(R.drawable.ic_play_dark)); .getThemedIcon(R.drawable.ic_play_dark));
view.findViewById(R.id.play).setOnClickListener(new View.OnClickListener() { view.findViewById(R.id.play).setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -146,11 +146,11 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
Drawable iconDrawable; Drawable iconDrawable;
if (recording.isAudio()) { if (recording.isAudio()) {
iconDrawable = ctx.getIconsCache().getIcon(R.drawable.ic_type_audio, R.color.color_distance); iconDrawable = ctx.getUIUtilities().getIcon(R.drawable.ic_type_audio, R.color.color_distance);
} else if (recording.isVideo()) { } else if (recording.isVideo()) {
iconDrawable = ctx.getIconsCache().getIcon(R.drawable.ic_type_video, R.color.color_distance); iconDrawable = ctx.getUIUtilities().getIcon(R.drawable.ic_type_video, R.color.color_distance);
} else { } else {
iconDrawable = ctx.getIconsCache().getIcon(R.drawable.ic_type_img, R.color.color_distance); iconDrawable = ctx.getUIUtilities().getIcon(R.drawable.ic_type_img, R.color.color_distance);
} }
icon.setImageDrawable(iconDrawable); icon.setImageDrawable(iconDrawable);
return iconDrawable; return iconDrawable;

View file

@ -212,7 +212,7 @@ public class NotesAdapter extends ArrayAdapter<Object> {
int iconRes = recording.isAudio() ? R.drawable.ic_type_audio int iconRes = recording.isAudio() ? R.drawable.ic_type_audio
: (recording.isVideo() ? R.drawable.ic_type_video : R.drawable.ic_type_img); : (recording.isVideo() ? R.drawable.ic_type_video : R.drawable.ic_type_img);
int colorRes = app.getSettings().isLightContent() ? R.color.icon_color : R.color.ctx_menu_info_text_dark; int colorRes = app.getSettings().isLightContent() ? R.color.icon_color : R.color.ctx_menu_info_text_dark;
holder.icon.setImageDrawable(app.getIconsCache().getIcon(iconRes, colorRes)); holder.icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes, colorRes));
} }
holder.bottomDivider.setVisibility(hideBottomDivider(position) ? View.GONE : View.VISIBLE); holder.bottomDivider.setVisibility(hideBottomDivider(position) ? View.GONE : View.VISIBLE);
@ -230,7 +230,7 @@ public class NotesAdapter extends ArrayAdapter<Object> {
} }
}); });
} else { } else {
holder.options.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_overflow_menu_white)); holder.options.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_overflow_menu_white));
holder.options.setOnClickListener(new View.OnClickListener() { holder.options.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {

View file

@ -10,14 +10,14 @@ import android.support.v7.app.AppCompatActivity;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.ImageView; import android.widget.ImageView;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
public class BaseOsmAndDialogFragment extends DialogFragment { public class BaseOsmAndDialogFragment extends DialogFragment {
private IconsCache iconsCache; private UiUtilities iconsCache;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -35,9 +35,9 @@ public class BaseOsmAndDialogFragment extends DialogFragment {
return (AppCompatActivity) getActivity(); return (AppCompatActivity) getActivity();
} }
protected IconsCache getIconsCache() { protected UiUtilities getIconsCache() {
if (iconsCache == null) { if (iconsCache == null) {
iconsCache = getMyApplication().getIconsCache(); iconsCache = getMyApplication().getUIUtilities();
} }
return iconsCache; return iconsCache;
} }

View file

@ -18,7 +18,7 @@ import android.view.ViewTreeObserver;
import android.view.animation.Animation; import android.view.animation.Animation;
import android.widget.ImageView; import android.widget.ImageView;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
@ -26,7 +26,7 @@ import net.osmand.plus.activities.OsmandActionBarActivity;
import net.osmand.plus.activities.OsmandInAppPurchaseActivity; import net.osmand.plus.activities.OsmandInAppPurchaseActivity;
public class BaseOsmAndFragment extends Fragment implements TransitionAnimator { public class BaseOsmAndFragment extends Fragment implements TransitionAnimator {
private IconsCache iconsCache; private UiUtilities iconsCache;
private int statusBarColor = -1; private int statusBarColor = -1;
private boolean transitionAnimationAllowed = true; private boolean transitionAnimationAllowed = true;
@ -165,26 +165,26 @@ public class BaseOsmAndFragment extends Fragment implements TransitionAnimator {
} }
@Nullable @Nullable
protected IconsCache getIconsCache() { protected UiUtilities getIconsCache() {
OsmandApplication app = getMyApplication(); OsmandApplication app = getMyApplication();
if (iconsCache == null && app != null) { if (iconsCache == null && app != null) {
iconsCache = app.getIconsCache(); iconsCache = app.getUIUtilities();
} }
return iconsCache; return iconsCache;
} }
protected Drawable getPaintedContentIcon(@DrawableRes int id, @ColorInt int color) { protected Drawable getPaintedContentIcon(@DrawableRes int id, @ColorInt int color) {
IconsCache cache = getIconsCache(); UiUtilities cache = getIconsCache();
return cache != null ? cache.getPaintedIcon(id, color) : null; return cache != null ? cache.getPaintedIcon(id, color) : null;
} }
protected Drawable getIcon(@DrawableRes int id, @ColorRes int colorId) { protected Drawable getIcon(@DrawableRes int id, @ColorRes int colorId) {
IconsCache cache = getIconsCache(); UiUtilities cache = getIconsCache();
return cache != null ? cache.getIcon(id, colorId) : null; return cache != null ? cache.getIcon(id, colorId) : null;
} }
protected Drawable getContentIcon(@DrawableRes int id) { protected Drawable getContentIcon(@DrawableRes int id) {
IconsCache cache = getIconsCache(); UiUtilities cache = getIconsCache();
return cache != null ? cache.getThemedIcon(id) : null; return cache != null ? cache.getThemedIcon(id) : null;
} }

View file

@ -79,7 +79,7 @@ public abstract class BottomSheetDialogFragment extends DialogFragment {
protected Drawable getIcon(@DrawableRes int drawableRes, @ColorRes int color) { protected Drawable getIcon(@DrawableRes int drawableRes, @ColorRes int color) {
OsmandApplication app = getMyApplication(); OsmandApplication app = getMyApplication();
if (app != null) { if (app != null) {
return app.getIconsCache().getIcon(drawableRes, color); return app.getUIUtilities().getIcon(drawableRes, color);
} else { } else {
return null; return null;
} }
@ -89,7 +89,7 @@ public abstract class BottomSheetDialogFragment extends DialogFragment {
protected Drawable getContentIcon(@DrawableRes int drawableRes) { protected Drawable getContentIcon(@DrawableRes int drawableRes) {
OsmandApplication app = getMyApplication(); OsmandApplication app = getMyApplication();
if (app != null) { if (app != null) {
return app.getIconsCache().getThemedIcon(drawableRes); return app.getUIUtilities().getThemedIcon(drawableRes);
} else { } else {
return null; return null;
} }

View file

@ -440,6 +440,20 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
mapView.refreshMap(); mapView.refreshMap();
} }
} }
public LatLon getMapLocation() {
if (mapView == null) {
return settings.getLastKnownMapLocation();
}
return new LatLon(mapView.getLatitude(), mapView.getLongitude());
}
public Float getMapRotate() {
if (mapView == null) {
return null;
}
return mapView.getRotate();
}
@Override @Override
public void newRouteIsCalculated(boolean newRoute, ValueHolder<Boolean> showToast) { public void newRouteIsCalculated(boolean newRoute, ValueHolder<Boolean> showToast) {

View file

@ -49,7 +49,7 @@ public class DashErrorFragment extends DashBaseFragment {
String msg = MessageFormat.format(getString(R.string.previous_run_crashed), OsmandApplication.EXCEPTION_PATH); String msg = MessageFormat.format(getString(R.string.previous_run_crashed), OsmandApplication.EXCEPTION_PATH);
Typeface typeface = FontCache.getRobotoMedium(getActivity()); Typeface typeface = FontCache.getRobotoMedium(getActivity());
ImageView iv = ((ImageView) view.findViewById(R.id.error_icon)); ImageView iv = ((ImageView) view.findViewById(R.id.error_icon));
iv.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_crashlog)); iv.setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_crashlog));
TextView message = ((TextView) view.findViewById(R.id.error_header)); TextView message = ((TextView) view.findViewById(R.id.error_header));
message.setTypeface(typeface); message.setTypeface(typeface);
message.setText(msg); message.setText(msg);

View file

@ -105,7 +105,7 @@ public class DashFavoritesFragment extends DashLocationFragment {
ImageView groupImage = (ImageView)view.findViewById(R.id.group_image); ImageView groupImage = (ImageView)view.findViewById(R.id.group_image);
if (point.getCategory().length() > 0) { if (point.getCategory().length() > 0) {
((TextView) view.findViewById(R.id.group_name)).setText(point.getCategory()); ((TextView) view.findViewById(R.id.group_name)).setText(point.getCategory());
groupImage.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_small_group)); groupImage.setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_small_group));
} else { } else {
groupImage.setVisibility(View.GONE); groupImage.setVisibility(View.GONE);
} }
@ -120,7 +120,7 @@ public class DashFavoritesFragment extends DashLocationFragment {
name.setTypeface(Typeface.DEFAULT, point.isVisible() ? Typeface.NORMAL : Typeface.ITALIC); name.setTypeface(Typeface.DEFAULT, point.isVisible() ? Typeface.NORMAL : Typeface.ITALIC);
view.findViewById(R.id.navigate_to).setVisibility(View.VISIBLE); view.findViewById(R.id.navigate_to).setVisibility(View.VISIBLE);
((ImageView) view.findViewById(R.id.navigate_to)).setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_gdirections_dark)); ((ImageView) view.findViewById(R.id.navigate_to)).setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_gdirections_dark));
view.findViewById(R.id.navigate_to).setOnClickListener(new View.OnClickListener() { view.findViewById(R.id.navigate_to).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {

View file

@ -1,24 +1,15 @@
package net.osmand.plus.dashboard; package net.osmand.plus.dashboard;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import net.osmand.Location;
import net.osmand.data.LatLon;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.views.DirectionDrawable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.osmand.data.LatLon;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
import android.annotation.SuppressLint;
import android.widget.ImageView;
import android.widget.TextView;
/** /**
* Created by Denis * Created by Denis
* on 26.01.2015. * on 26.01.2015.
@ -26,12 +17,7 @@ import java.util.List;
@SuppressLint("ResourceAsColor") @SuppressLint("ResourceAsColor")
public abstract class DashLocationFragment extends DashBaseFragment { public abstract class DashLocationFragment extends DashBaseFragment {
private static final int ORIENTATION_0 = 0;
private static final int ORIENTATION_90 = 3;
private static final int ORIENTATION_270 = 1;
private static final int ORIENTATION_180 = 2;
protected List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>(); protected List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
private int screenOrientation;
public static class DashLocationView { public static class DashLocationView {
public ImageView arrow; public ImageView arrow;
@ -46,40 +32,14 @@ public abstract class DashLocationFragment extends DashBaseFragment {
this.txt = txt; this.txt = txt;
this.loc = loc; this.loc = loc;
} }
} }
@Override @Override
public void onOpenDash() { public void onOpenDash() {
//Hardy: getRotation() is the correction if device's screen orientation != the default display's standard orientation //Hardy: getRotation() is the correction if device's screen orientation != the default display's standard orientation
screenOrientation = getScreenOrientation(getActivity());
} }
public static int getScreenOrientation(Activity a) {
int screenOrientation = ((WindowManager) a.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
switch (screenOrientation) {
case ORIENTATION_0: // Device default (normally portrait)
screenOrientation = 0;
break;
case ORIENTATION_90: // Landscape right
screenOrientation = 90;
break;
case ORIENTATION_270: // Landscape left
screenOrientation = 270;
break;
case ORIENTATION_180: // Upside down
screenOrientation = 180;
break;
}
//Looks like screenOrientation correction must not be applied for devices without compass?
Sensor compass = ((SensorManager) a.getSystemService(Context.SENSOR_SERVICE)).getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
if (compass == null) {
screenOrientation = 0;
}
return screenOrientation;
}
public LatLon getDefaultLocation() { public LatLon getDefaultLocation() {
DashboardOnMap d = dashboard; DashboardOnMap d = dashboard;
@ -94,114 +54,16 @@ public abstract class DashLocationFragment extends DashBaseFragment {
if (d == null) { if (d == null) {
return; return;
} }
float head = d.getHeading(); UiUtilities ic = getMyApplication().getUIUtilities();
float mapRotation = d.getMapRotation(); UpdateLocationViewCache cache = ic.getUpdateLocationViewCache();
LatLon mw = d.getMapViewLocation();
boolean useCenter = !d.isMapLinkedToLocation();
float h = useCenter ? -mapRotation : head;
for (DashLocationView lv : distances) { for (DashLocationView lv : distances) {
updateLocationView(useCenter, mw, h, lv.arrow, lv.arrowResId, lv.txt, lv.loc, screenOrientation, cache.arrowResId = lv.arrowResId;
getMyApplication(), lv.paint); cache.paintTxt = lv.paint;
ic.updateLocationView(cache, lv.arrow, lv.txt, lv.loc);
} }
} }
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h, public void updateLocation(boolean centerChanged, boolean locationChanged, boolean compassChanged) {
ImageView arrow, int imgColor, TextView txt, int textColor, double toLat, double toLon,
int screenOrientation, OsmandApplication app, Context ctx) {
updateLocationView(useCenter, fromLoc, h, arrow, 0, imgColor, txt, textColor, new LatLon(toLat, toLon), screenOrientation, app, true);
}
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, TextView txt, double toLat, double toLon,
int screenOrientation, OsmandApplication app) {
updateLocationView(useCenter, fromLoc, h, arrow, 0, txt, new LatLon(toLat, toLon), screenOrientation, app, true);
}
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, int arrowResId, TextView txt, LatLon toLoc,
int screenOrientation, OsmandApplication app, boolean paint) {
updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, 0, txt, 0, toLoc, screenOrientation, app, paint);
}
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, int arrowResId, int imgColor, TextView txt, LatLon toLoc,
int screenOrientation, OsmandApplication app, boolean paint) {
updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, imgColor, txt, 0, toLoc, screenOrientation, app, paint);
}
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, int arrowResId, int imgColor, TextView txt, int textColor, LatLon toLoc,
int screenOrientation, OsmandApplication app, boolean paint) {
float[] mes = new float[2];
boolean stale = false;
if(!useCenter) {
Location loc = app.getLocationProvider().getLastKnownLocation();
if(loc == null) {
loc = app.getLocationProvider().getLastStaleKnownLocation();
stale = true;
}
if(loc != null) {
fromLoc = new LatLon(loc.getLatitude(), loc.getLongitude());
} else {
fromLoc = null;
}
}
if (fromLoc != null && toLoc != null) {
Location.distanceBetween(toLoc.getLatitude(), toLoc.getLongitude(), fromLoc.getLatitude(), fromLoc.getLongitude(), mes);
}
if (arrow != null) {
boolean newImage = false;
if (arrowResId == 0) {
arrowResId = R.drawable.ic_direction_arrow;
}
DirectionDrawable dd;
if(!(arrow.getDrawable() instanceof DirectionDrawable)) {
newImage = true;
dd = new DirectionDrawable(app, arrow.getWidth(), arrow.getHeight());
} else {
dd = (DirectionDrawable) arrow.getDrawable();
}
int imgColorSet = imgColor;
if (imgColorSet == 0) {
imgColorSet = useCenter ? R.color.color_distance : R.color.color_myloc_distance;
if(stale) {
imgColorSet = R.color.icon_color;
}
}
dd.setImage(arrowResId, imgColorSet);
if (fromLoc == null || h == null || toLoc == null) {
dd.setAngle(0);
} else {
dd.setAngle(mes[1] - h + 180 + screenOrientation);
}
if (newImage) {
arrow.setImageDrawable(dd);
}
arrow.invalidate();
}
if (txt != null) {
if (fromLoc != null && toLoc != null) {
if (paint) {
int textColorSet = textColor;
if(textColorSet == 0) {
textColorSet = useCenter ? R.color.color_distance : R.color.color_myloc_distance ;
if(stale) {
textColorSet = R.color.icon_color;
}
}
txt.setTextColor(app.getResources().getColor(textColorSet));
}
txt.setText(OsmAndFormatter.getFormattedDistance(mes[0], app));
} else {
txt.setText("");
}
}
}
public void updateLocation(boolean centerChanged, boolean locationChanged, boolean compassChanged) {
if (compassChanged && !dashboard.isMapLinkedToLocation()) { if (compassChanged && !dashboard.isMapLinkedToLocation()) {
return; return;
} }

View file

@ -72,9 +72,9 @@ public class DashNavigationFragment extends DashBaseFragment {
ImageView cancel = (ImageView) view.findViewById(R.id.cancel); ImageView cancel = (ImageView) view.findViewById(R.id.cancel);
ImageView play = (ImageView) view.findViewById(R.id.play); ImageView play = (ImageView) view.findViewById(R.id.play);
name.setText(routingHelper.getGeneralRouteInformation()); name.setText(routingHelper.getGeneralRouteInformation());
icon.setImageDrawable(getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_start_navigation, icon.setImageDrawable(getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_start_navigation,
R.color.color_myloc_distance)); R.color.color_myloc_distance));
cancel.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_remove_dark) cancel.setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_remove_dark)
); );
cancel.setOnClickListener(new OnClickListener() { cancel.setOnClickListener(new OnClickListener() {
@ -107,7 +107,7 @@ public class DashNavigationFragment extends DashBaseFragment {
private void updatePlayButton(final RoutingHelper routingHelper, final MapActivity map, final ImageView play) { private void updatePlayButton(final RoutingHelper routingHelper, final MapActivity map, final ImageView play) {
boolean toContinueNavigation = routingHelper.isRoutePlanningMode(); boolean toContinueNavigation = routingHelper.isRoutePlanningMode();
play.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon( play.setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(
toContinueNavigation ? R.drawable.ic_play_dark : R.drawable.ic_pause) toContinueNavigation ? R.drawable.ic_play_dark : R.drawable.ic_pause)
); );
play.setContentDescription(getString(toContinueNavigation ? R.string.continue_navigation : play.setContentDescription(getString(toContinueNavigation ? R.string.continue_navigation :

View file

@ -89,7 +89,7 @@ public class DashRecentsFragment extends DashLocationFragment {
SearchHistoryFragment.udpateHistoryItem(historyEntry, view, loc, getActivity(), getMyApplication()); SearchHistoryFragment.udpateHistoryItem(historyEntry, view, loc, getActivity(), getMyApplication());
view.findViewById(R.id.divider).setVisibility(View.VISIBLE); view.findViewById(R.id.divider).setVisibility(View.VISIBLE);
view.findViewById(R.id.navigate_to).setVisibility(View.VISIBLE); view.findViewById(R.id.navigate_to).setVisibility(View.VISIBLE);
((ImageView) view.findViewById(R.id.navigate_to)).setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_gdirections_dark)); ((ImageView) view.findViewById(R.id.navigate_to)).setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_gdirections_dark));
view.findViewById(R.id.navigate_to).setOnClickListener(new View.OnClickListener() { view.findViewById(R.id.navigate_to).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {

View file

@ -30,7 +30,7 @@ public class DashSearchFragment extends DashBaseFragment {
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_search_fragment, container, false); View view = getActivity().getLayoutInflater().inflate(R.layout.dash_search_fragment, container, false);
TextView searchFor = (TextView) view.findViewById(R.id.search_for); TextView searchFor = (TextView) view.findViewById(R.id.search_for);
searchFor.setCompoundDrawablesWithIntrinsicBounds(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_search_dark), null, null, null); searchFor.setCompoundDrawablesWithIntrinsicBounds(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_search_dark), null, null, null);
searchFor.setCompoundDrawablePadding(AndroidUtils.dpToPx(getActivity(), 16f)); searchFor.setCompoundDrawablePadding(AndroidUtils.dpToPx(getActivity(), 16f));
view.findViewById(R.id.search_card).setOnClickListener(new View.OnClickListener() { view.findViewById(R.id.search_card).setOnClickListener(new View.OnClickListener() {

View file

@ -150,7 +150,7 @@ public class DashWaypointsFragment extends DashLocationFragment {
id = R.drawable.list_destination; id = R.drawable.list_destination;
} }
((ImageView) view.findViewById(R.id.favourite_icon)).setImageDrawable(getMyApplication().getIconsCache() ((ImageView) view.findViewById(R.id.favourite_icon)).setImageDrawable(getMyApplication().getUIUtilities()
.getIcon(id, 0)); .getIcon(id, 0));
DashLocationView dv = new DashLocationView(direction, label, new LatLon(point.getLatitude(), DashLocationView dv = new DashLocationView(direction, label, new LatLon(point.getLatitude(),
point.getLongitude())); point.getLongitude()));
@ -161,7 +161,7 @@ public class DashWaypointsFragment extends DashLocationFragment {
options.setVisibility(View.VISIBLE); options.setVisibility(View.VISIBLE);
final boolean optionsVisible = (SHOW_ALL && getMyApplication().getTargetPointsHelper().getIntermediatePoints().size() > 0); final boolean optionsVisible = (SHOW_ALL && getMyApplication().getTargetPointsHelper().getIntermediatePoints().size() > 0);
options.setImageDrawable(getMyApplication().getIconsCache(). options.setImageDrawable(getMyApplication().getUIUtilities().
getThemedIcon(optionsVisible ? R.drawable.ic_overflow_menu_white : getThemedIcon(optionsVisible ? R.drawable.ic_overflow_menu_white :
R.drawable.ic_action_remove_dark)); R.drawable.ic_action_remove_dark));
options.setOnClickListener(new View.OnClickListener() { options.setOnClickListener(new View.OnClickListener() {
@ -176,7 +176,7 @@ public class DashWaypointsFragment extends DashLocationFragment {
}); });
ImageButton navigate = ((ImageButton)view.findViewById(R.id.navigate_to)); ImageButton navigate = ((ImageButton)view.findViewById(R.id.navigate_to));
navigate.setImageDrawable(getMyApplication().getIconsCache(). navigate.setImageDrawable(getMyApplication().getUIUtilities().
getThemedIcon(R.drawable.ic_action_gdirections_dark)); getThemedIcon(R.drawable.ic_action_gdirections_dark));
navigate.setVisibility(target? View.VISIBLE : View.GONE); navigate.setVisibility(target? View.VISIBLE : View.GONE);
navigate.setOnClickListener(new View.OnClickListener() { navigate.setOnClickListener(new View.OnClickListener() {
@ -241,7 +241,7 @@ public class DashWaypointsFragment extends DashLocationFragment {
if (point.index > 0 || target) { if (point.index > 0 || target) {
final int ind = target ? allTargets.size() - 1 : point.index; final int ind = target ? allTargets.size() - 1 : point.index;
item = optionsMenu.getMenu().add(R.string.waypoint_visit_before) item = optionsMenu.getMenu().add(R.string.waypoint_visit_before)
.setIcon(getMyApplication().getIconsCache(). .setIcon(getMyApplication().getUIUtilities().
getThemedIcon(R.drawable.ic_action_up_dark)); getThemedIcon(R.drawable.ic_action_up_dark));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override @Override
@ -256,7 +256,7 @@ public class DashWaypointsFragment extends DashLocationFragment {
} }
if (!target) { if (!target) {
item = optionsMenu.getMenu().add(R.string.waypoint_visit_after) item = optionsMenu.getMenu().add(R.string.waypoint_visit_after)
.setIcon(getMyApplication().getIconsCache(). .setIcon(getMyApplication().getUIUtilities().
getThemedIcon(R.drawable.ic_action_down_dark)); getThemedIcon(R.drawable.ic_action_down_dark));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override @Override
@ -271,7 +271,7 @@ public class DashWaypointsFragment extends DashLocationFragment {
} }
} }
item = optionsMenu.getMenu().add( item = optionsMenu.getMenu().add(
R.string.shared_string_remove).setIcon(getMyApplication().getIconsCache(). R.string.shared_string_remove).setIcon(getMyApplication().getUIUtilities().
getThemedIcon(R.drawable.ic_action_remove_dark)); getThemedIcon(R.drawable.ic_action_remove_dark));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override @Override

View file

@ -51,7 +51,7 @@ import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnRowItemClick; import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
import net.osmand.plus.ContextMenuItem; import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
@ -443,12 +443,12 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
flat.setVisibility(View.GONE); flat.setVisibility(View.GONE);
ImageView settingsButton = (ImageView) dashboardView.findViewById(R.id.toolbar_settings); ImageView settingsButton = (ImageView) dashboardView.findViewById(R.id.toolbar_settings);
settingsButton.setVisibility(View.GONE); settingsButton.setVisibility(View.GONE);
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache(); UiUtilities iconsCache = mapActivity.getMyApplication().getUIUtilities();
ImageView lst = (ImageView) dashboardView.findViewById(R.id.toolbar_list); ImageView lst = (ImageView) dashboardView.findViewById(R.id.toolbar_list);
lst.setVisibility(View.GONE); lst.setVisibility(View.GONE);
ImageView back = (ImageView) dashboardView.findViewById(R.id.toolbar_back); ImageView back = (ImageView) dashboardView.findViewById(R.id.toolbar_back);
back.setImageDrawable( back.setImageDrawable(
getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back)); getMyApplication().getUIUtilities().getIcon(R.drawable.ic_arrow_back));
back.setOnClickListener(new View.OnClickListener() { back.setOnClickListener(new View.OnClickListener() {
@Override @Override

View file

@ -41,8 +41,8 @@ public class DashSimulateFragment extends DashBaseFragment {
: R.string.animate_route); : R.string.animate_route);
ImageButton actionButton = (ImageButton) getView().findViewById(R.id.stop); ImageButton actionButton = (ImageButton) getView().findViewById(R.id.stop);
actionButton.setImageDrawable( actionButton.setImageDrawable(
!routeAnimating ? getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_play_dark) !routeAnimating ? getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_play_dark)
: getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_rec_stop)); : getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_rec_stop));
actionButton.setContentDescription(getString(routeAnimating ? R.string.animate_route_off : R.string.animate_route)); actionButton.setContentDescription(getString(routeAnimating ? R.string.animate_route_off : R.string.animate_route));
} }

View file

@ -387,9 +387,9 @@ public class ConfigureMapMenu {
View v = super.getView(position, convertView, parent); View v = super.getView(position, convertView, parent);
final ImageView icon = (ImageView) v.findViewById(R.id.icon); final ImageView icon = (ImageView) v.findViewById(R.id.icon);
if (checkedItems[position]) { if (checkedItems[position]) {
icon.setImageDrawable(app.getIconsCache().getIcon(iconIds[position], R.color.osmand_orange)); icon.setImageDrawable(app.getUIUtilities().getIcon(iconIds[position], R.color.osmand_orange));
} else { } else {
icon.setImageDrawable(app.getIconsCache().getThemedIcon(iconIds[position])); icon.setImageDrawable(app.getUIUtilities().getThemedIcon(iconIds[position]));
} }
v.findViewById(R.id.divider).setVisibility(View.GONE); v.findViewById(R.id.divider).setVisibility(View.GONE);
v.findViewById(R.id.description).setVisibility(View.GONE); v.findViewById(R.id.description).setVisibility(View.GONE);
@ -402,9 +402,9 @@ public class ConfigureMapMenu {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
checkedItems[position] = isChecked; checkedItems[position] = isChecked;
if (checkedItems[position]) { if (checkedItems[position]) {
icon.setImageDrawable(app.getIconsCache().getIcon(iconIds[position], R.color.osmand_orange)); icon.setImageDrawable(app.getUIUtilities().getIcon(iconIds[position], R.color.osmand_orange));
} else { } else {
icon.setImageDrawable(app.getIconsCache().getThemedIcon(iconIds[position])); icon.setImageDrawable(app.getUIUtilities().getThemedIcon(iconIds[position]));
} }
} }
}); });
@ -1385,14 +1385,14 @@ public class ConfigureMapMenu {
iconId = R.drawable.ic_action_gpx_width_thin; iconId = R.drawable.ic_action_gpx_width_thin;
} }
textView.setCompoundDrawablesWithIntrinsicBounds(null, null, textView.setCompoundDrawablesWithIntrinsicBounds(null, null,
app.getIconsCache().getPaintedIcon(iconId, currentColor), null); app.getUIUtilities().getPaintedIcon(iconId, currentColor), null);
} else { } else {
if (item.color == -1) { if (item.color == -1) {
textView.setCompoundDrawablesWithIntrinsicBounds(null, null, textView.setCompoundDrawablesWithIntrinsicBounds(null, null,
app.getIconsCache().getThemedIcon(R.drawable.ic_action_circle), null); app.getUIUtilities().getThemedIcon(R.drawable.ic_action_circle), null);
} else { } else {
textView.setCompoundDrawablesWithIntrinsicBounds(null, null, textView.setCompoundDrawablesWithIntrinsicBounds(null, null,
app.getIconsCache().getPaintedIcon(R.drawable.ic_action_circle, item.color), null); app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_circle, item.color), null);
} }
} }
textView.setCompoundDrawablePadding(AndroidUtils.dpToPx(getContext(), 10f)); textView.setCompoundDrawablePadding(AndroidUtils.dpToPx(getContext(), 10f));

View file

@ -36,7 +36,7 @@ public class ErrorBottomSheetDialog extends BottomSheetDialogFragment {
String msg = MessageFormat.format(getString(R.string.previous_run_crashed), OsmandApplication.EXCEPTION_PATH); String msg = MessageFormat.format(getString(R.string.previous_run_crashed), OsmandApplication.EXCEPTION_PATH);
Typeface typeface = FontCache.getRobotoMedium(getActivity()); Typeface typeface = FontCache.getRobotoMedium(getActivity());
ImageView iv = ((ImageView) view.findViewById(R.id.error_icon)); ImageView iv = ((ImageView) view.findViewById(R.id.error_icon));
iv.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_crashlog)); iv.setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_crashlog));
TextView message = ((TextView) view.findViewById(R.id.error_header)); TextView message = ((TextView) view.findViewById(R.id.error_header));
message.setTypeface(typeface); message.setTypeface(typeface);
message.setText(msg); message.setText(msg);

View file

@ -19,8 +19,8 @@ import android.widget.EditText;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.Location;
import net.osmand.data.FavouritePoint; import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
@ -42,11 +42,10 @@ public class FavoriteDialogs {
public static final String KEY_FAVORITE = "favorite"; public static final String KEY_FAVORITE = "favorite";
public static Dialog createReplaceFavouriteDialog(final Activity activity, final Bundle args) { public static Dialog createReplaceFavouriteDialog(final Activity activity, final Bundle args) {
final FavouritesDbHelper helper = ((OsmandApplication) activity.getApplication()).getFavorites(); OsmandApplication app = (OsmandApplication) activity.getApplication();
final FavouritesDbHelper helper = app.getFavorites();
final List<FavouritePoint> points = new ArrayList<FavouritePoint>(helper.getFavouritePoints()); final List<FavouritePoint> points = new ArrayList<FavouritePoint>(helper.getFavouritePoints());
final FavouritesAdapter favouritesAdapter = new FavouritesAdapter(activity, final FavouritesAdapter favouritesAdapter = new FavouritesAdapter(activity, points,false);
((OsmandApplication) activity.getApplication()).getFavorites().getFavouritePoints(),
false);
final Dialog[] dlgHolder = new Dialog[1]; final Dialog[] dlgHolder = new Dialog[1];
OnItemClickListener click = new AdapterView.OnItemClickListener() { OnItemClickListener click = new AdapterView.OnItemClickListener() {
@ -56,9 +55,8 @@ public class FavoriteDialogs {
} }
}; };
if (activity instanceof MapActivity) { favouritesAdapter.sortByDefault();
favouritesAdapter.updateLocation(((MapActivity) activity).getMapLocation());
}
if(points.size() == 0){ if(points.size() == 0){
Toast.makeText(activity, activity.getString(R.string.fav_points_not_exist), Toast.LENGTH_SHORT).show(); Toast.makeText(activity, activity.getString(R.string.fav_points_not_exist), Toast.LENGTH_SHORT).show();
return null; return null;
@ -210,25 +208,7 @@ public class FavoriteDialogs {
final OnDismissListener dismissListener, final Dialog[] dialogHolder, final boolean sortByDist) { final OnDismissListener dismissListener, final Dialog[] dialogHolder, final boolean sortByDist) {
ListView listView = new ListView(uiContext); ListView listView = new ListView(uiContext);
AlertDialog.Builder bld = new AlertDialog.Builder(uiContext); AlertDialog.Builder bld = new AlertDialog.Builder(uiContext);
final Collator inst = Collator.getInstance(); favouritesAdapter.sortByDefault();
favouritesAdapter.sort(new Comparator<FavouritePoint>() {
@Override
public int compare(FavouritePoint lhs, FavouritePoint rhs) {
if (sortByDist) {
if (favouritesAdapter.getLocation() == null) {
return 0;
}
double ld = MapUtils.getDistance(favouritesAdapter.getLocation(), lhs.getLatitude(),
lhs.getLongitude());
double rd = MapUtils.getDistance(favouritesAdapter.getLocation(), rhs.getLatitude(),
rhs.getLongitude());
return Double.compare(ld, rd);
}
return inst.compare(lhs.getName(), rhs.getName());
}
});
listView.setAdapter(favouritesAdapter); listView.setAdapter(favouritesAdapter);
listView.setOnItemClickListener(click); listView.setOnItemClickListener(click);
bld.setPositiveButton(sortByDist ? R.string.sort_by_name : bld.setPositiveButton(sortByDist ? R.string.sort_by_name :

View file

@ -4,7 +4,7 @@ import android.graphics.drawable.Drawable;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.download.DownloadActivityType;
@ -29,11 +29,11 @@ public class DownloadGroupViewHolder {
Drawable iconLeft; Drawable iconLeft;
if (group.getType() == DownloadResourceGroup.DownloadResourceGroupType.VOICE_REC if (group.getType() == DownloadResourceGroup.DownloadResourceGroupType.VOICE_REC
|| group.getType() == DownloadResourceGroup.DownloadResourceGroupType.VOICE_TTS) { || group.getType() == DownloadResourceGroup.DownloadResourceGroupType.VOICE_TTS) {
iconLeft = ctx.getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_volume_up); iconLeft = ctx.getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_volume_up);
} else if (group.getType() == DownloadResourceGroup.DownloadResourceGroupType.FONTS) { } else if (group.getType() == DownloadResourceGroup.DownloadResourceGroupType.FONTS) {
iconLeft = ctx.getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_map_language); iconLeft = ctx.getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_map_language);
} else { } else {
IconsCache cache = ctx.getMyApplication().getIconsCache(); UiUtilities cache = ctx.getMyApplication().getUIUtilities();
if (isParentWorld(group) || isParentWorld(group.getParentGroup())) { if (isParentWorld(group) || isParentWorld(group.getParentGroup())) {
iconLeft = cache.getThemedIcon(R.drawable.ic_world_globe_dark); iconLeft = cache.getThemedIcon(R.drawable.ic_world_globe_dark);
} else { } else {

View file

@ -28,7 +28,7 @@ import android.widget.TextView;
import net.osmand.AndroidNetworkUtils; import net.osmand.AndroidNetworkUtils;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -105,7 +105,7 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
activity.getAccessibilityAssistant().registerPage(view, DownloadActivity.DOWNLOAD_TAB_NUMBER); activity.getAccessibilityAssistant().registerPage(view, DownloadActivity.DOWNLOAD_TAB_NUMBER);
toolbar = (Toolbar) view.findViewById(R.id.toolbar); toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back)); toolbar.setNavigationIcon(getMyApplication().getUIUtilities().getIcon(R.drawable.ic_arrow_back));
toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up); toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
toolbar.setNavigationOnClickListener(new View.OnClickListener() { toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override @Override
@ -159,7 +159,7 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
if (!openAsDialog() && purchaseHelper != null && !purchaseHelper.hasInventory()) { if (!openAsDialog() && purchaseHelper != null && !purchaseHelper.hasInventory()) {
restorePurchasesView = activity.getLayoutInflater().inflate(R.layout.restore_purchases_list_footer, null); restorePurchasesView = activity.getLayoutInflater().inflate(R.layout.restore_purchases_list_footer, null);
((ImageView) restorePurchasesView.findViewById(R.id.icon)).setImageDrawable( ((ImageView) restorePurchasesView.findViewById(R.id.icon)).setImageDrawable(
getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_reset_to_default_dark)); getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_reset_to_default_dark));
restorePurchasesView.findViewById(R.id.button).setOnClickListener(new OnClickListener() { restorePurchasesView.findViewById(R.id.button).setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -181,7 +181,7 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
searchView = activity.getLayoutInflater().inflate(R.layout.simple_list_menu_item, null); searchView = activity.getLayoutInflater().inflate(R.layout.simple_list_menu_item, null);
searchView.setBackgroundResource(android.R.drawable.list_selector_background); searchView.setBackgroundResource(android.R.drawable.list_selector_background);
TextView title = (TextView) searchView.findViewById(R.id.title); TextView title = (TextView) searchView.findViewById(R.id.title);
title.setCompoundDrawablesWithIntrinsicBounds(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_search_dark), null, null, null); title.setCompoundDrawablesWithIntrinsicBounds(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_search_dark), null, null, null);
title.setHint(R.string.search_map_hint); title.setHint(R.string.search_map_hint);
searchView.setOnClickListener(new OnClickListener() { searchView.setOnClickListener(new OnClickListener() {
@Override @Override
@ -532,11 +532,11 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
Drawable iconLeft; Drawable iconLeft;
if (group.getType() == DownloadResourceGroupType.VOICE_REC if (group.getType() == DownloadResourceGroupType.VOICE_REC
|| group.getType() == DownloadResourceGroupType.VOICE_TTS) { || group.getType() == DownloadResourceGroupType.VOICE_TTS) {
iconLeft = ctx.getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_volume_up); iconLeft = ctx.getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_volume_up);
} else if (group.getType() == DownloadResourceGroupType.FONTS) { } else if (group.getType() == DownloadResourceGroupType.FONTS) {
iconLeft = ctx.getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_map_language); iconLeft = ctx.getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_map_language);
} else { } else {
IconsCache cache = ctx.getMyApplication().getIconsCache(); UiUtilities cache = ctx.getMyApplication().getUIUtilities();
if (isParentWorld(group) || isParentWorld(group.getParentGroup())) { if (isParentWorld(group) || isParentWorld(group.getParentGroup())) {
iconLeft = cache.getThemedIcon(R.drawable.ic_world_globe_dark); iconLeft = cache.getThemedIcon(R.drawable.ic_world_globe_dark);
} else { } else {

View file

@ -384,7 +384,7 @@ public class ItemViewHolder {
final File fl = indexItem.getTargetFile(context.getMyApplication()); final File fl = indexItem.getTargetFile(context.getMyApplication());
if (fl.exists()) { if (fl.exists()) {
item = optionsMenu.getMenu().add(R.string.shared_string_remove).setIcon( item = optionsMenu.getMenu().add(R.string.shared_string_remove).setIcon(
context.getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_remove_dark)); context.getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_remove_dark));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
@ -424,7 +424,7 @@ public class ItemViewHolder {
}); });
} }
item = optionsMenu.getMenu().add(R.string.shared_string_download) item = optionsMenu.getMenu().add(R.string.shared_string_download)
.setIcon(context.getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_import)); .setIcon(context.getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_import));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
@ -437,10 +437,10 @@ public class ItemViewHolder {
} }
private Drawable getContentIcon(DownloadActivity context, int resourceId) { private Drawable getContentIcon(DownloadActivity context, int resourceId) {
return context.getMyApplication().getIconsCache().getThemedIcon(resourceId); return context.getMyApplication().getUIUtilities().getThemedIcon(resourceId);
} }
private Drawable getContentIcon(DownloadActivity context, int resourceId, int color) { private Drawable getContentIcon(DownloadActivity context, int resourceId, int color) {
return context.getMyApplication().getIconsCache().getPaintedIcon(resourceId, color); return context.getMyApplication().getUIUtilities().getPaintedIcon(resourceId, color);
} }
} }

View file

@ -21,7 +21,7 @@ import net.osmand.map.ITileSource;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.ItemClickListener; import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
import net.osmand.plus.ContextMenuItem; import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -1100,7 +1100,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
public void bindLocalIndexInfo(final LocalIndexInfo child) { public void bindLocalIndexInfo(final LocalIndexInfo child) {
options.setImageDrawable(ctx.getMyApplication().getIconsCache() options.setImageDrawable(ctx.getMyApplication().getUIUtilities()
.getThemedIcon(R.drawable.ic_overflow_menu_white)); .getThemedIcon(R.drawable.ic_overflow_menu_white));
options.setContentDescription(ctx.getString(R.string.shared_string_more)); options.setContentDescription(ctx.getString(R.string.shared_string_more));
options.setOnClickListener(new View.OnClickListener() { options.setOnClickListener(new View.OnClickListener() {
@ -1177,14 +1177,14 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
} }
private Drawable getContentIcon(DownloadActivity context, int resourceId, int colorId) { private Drawable getContentIcon(DownloadActivity context, int resourceId, int colorId) {
return context.getMyApplication().getIconsCache().getIcon(resourceId, colorId); return context.getMyApplication().getUIUtilities().getIcon(resourceId, colorId);
} }
} }
} }
private void openPopUpMenu(View v, final LocalIndexInfo info) { private void openPopUpMenu(View v, final LocalIndexInfo info) {
IconsCache iconsCache = getMyApplication().getIconsCache(); UiUtilities iconsCache = getMyApplication().getUIUtilities();
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v); final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
DirectionsDialogs.setupPopUpMenuIcon(optionsMenu); DirectionsDialogs.setupPopUpMenuIcon(optionsMenu);
final boolean restore = info.isBackupedData(); final boolean restore = info.isBackupedData();

View file

@ -72,7 +72,7 @@ public class AvoidSpecificRoads {
final RouteDataObject obj = getItem(position); final RouteDataObject obj = getItem(position);
v.findViewById(R.id.all_points).setVisibility(View.GONE); v.findViewById(R.id.all_points).setVisibility(View.GONE);
((ImageView) v.findViewById(R.id.waypoint_icon)).setImageDrawable( ((ImageView) v.findViewById(R.id.waypoint_icon)).setImageDrawable(
app.getIconsCache().getThemedIcon(R.drawable.ic_action_road_works_dark)); app.getUIUtilities().getThemedIcon(R.drawable.ic_action_road_works_dark));
double dist = MapUtils.getDistance(mapLocation, MapUtils.get31LatitudeY(obj.getPoint31YTile(0)), double dist = MapUtils.getDistance(mapLocation, MapUtils.get31LatitudeY(obj.getPoint31YTile(0)),
MapUtils.get31LongitudeX(obj.getPoint31XTile(0))); MapUtils.get31LongitudeX(obj.getPoint31XTile(0)));
((TextView) v.findViewById(R.id.waypoint_dist)).setText(OsmAndFormatter.getFormattedDistance((float) dist, app)); ((TextView) v.findViewById(R.id.waypoint_dist)).setText(OsmAndFormatter.getFormattedDistance((float) dist, app));
@ -80,7 +80,7 @@ public class AvoidSpecificRoads {
((TextView) v.findViewById(R.id.waypoint_text)).setText(getText(obj)); ((TextView) v.findViewById(R.id.waypoint_text)).setText(getText(obj));
ImageButton remove = (ImageButton) v.findViewById(R.id.info_close); ImageButton remove = (ImageButton) v.findViewById(R.id.info_close);
remove.setVisibility(View.VISIBLE); remove.setVisibility(View.VISIBLE);
remove.setImageDrawable(app.getIconsCache().getThemedIcon( remove.setImageDrawable(app.getUIUtilities().getThemedIcon(
R.drawable.ic_action_remove_dark)); R.drawable.ic_action_remove_dark));
remove.setOnClickListener(new View.OnClickListener() { remove.setOnClickListener(new View.OnClickListener() {

View file

@ -67,7 +67,7 @@ import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
import net.osmand.plus.GPXUtilities.Speed; import net.osmand.plus.GPXUtilities.Speed;
import net.osmand.plus.GPXUtilities.TrkSegment; import net.osmand.plus.GPXUtilities.TrkSegment;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
@ -327,7 +327,7 @@ public class GpxUiHelper {
final List<GPXInfo> list, final List<GPXInfo> list,
final ContextMenuAdapter adapter) { final ContextMenuAdapter adapter) {
final OsmandApplication app = (OsmandApplication) activity.getApplication(); final OsmandApplication app = (OsmandApplication) activity.getApplication();
final IconsCache iconsCache = app.getIconsCache(); final UiUtilities iconsCache = app.getUIUtilities();
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR); final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
AlertDialog.Builder builder = new AlertDialog.Builder(activity); AlertDialog.Builder builder = new AlertDialog.Builder(activity);
final int layout = R.layout.list_menu_item_native_singlechoice; final int layout = R.layout.list_menu_item_native_singlechoice;
@ -747,13 +747,13 @@ public class GpxUiHelper {
v.findViewById(R.id.unknown_section).setVisibility(View.GONE); v.findViewById(R.id.unknown_section).setVisibility(View.GONE);
ImageView distanceI = (ImageView) v.findViewById(R.id.distance_icon); ImageView distanceI = (ImageView) v.findViewById(R.id.distance_icon);
distanceI.setVisibility(View.VISIBLE); distanceI.setVisibility(View.VISIBLE);
distanceI.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_small_distance)); distanceI.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_small_distance));
ImageView pointsI = (ImageView) v.findViewById(R.id.points_icon); ImageView pointsI = (ImageView) v.findViewById(R.id.points_icon);
pointsI.setVisibility(View.VISIBLE); pointsI.setVisibility(View.VISIBLE);
pointsI.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_small_point)); pointsI.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_small_point));
ImageView timeI = (ImageView) v.findViewById(R.id.time_icon); ImageView timeI = (ImageView) v.findViewById(R.id.time_icon);
timeI.setVisibility(View.VISIBLE); timeI.setVisibility(View.VISIBLE);
timeI.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_small_time)); timeI.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_small_time));
TextView time = (TextView) v.findViewById(R.id.time); TextView time = (TextView) v.findViewById(R.id.time);
TextView distance = (TextView) v.findViewById(R.id.distance); TextView distance = (TextView) v.findViewById(R.id.distance);
TextView pointsCount = (TextView) v.findViewById(R.id.points_count); TextView pointsCount = (TextView) v.findViewById(R.id.points_count);
@ -817,9 +817,9 @@ public class GpxUiHelper {
} }
int color = GpxAppearanceAdapter.parseTrackColor(renderer, prefColorValue); int color = GpxAppearanceAdapter.parseTrackColor(renderer, prefColorValue);
if (color == -1) { if (color == -1) {
colorImageView.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_circle)); colorImageView.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_circle));
} else { } else {
colorImageView.setImageDrawable(app.getIconsCache().getPaintedIcon(R.drawable.ic_action_circle, color)); colorImageView.setImageDrawable(app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_circle, color));
} }
} }
@ -1610,7 +1610,7 @@ public class GpxUiHelper {
} }
public Drawable getImageDrawable(@NonNull OsmandApplication app) { public Drawable getImageDrawable(@NonNull OsmandApplication app) {
return app.getIconsCache().getThemedIcon(imageId); return app.getUIUtilities().getThemedIcon(imageId);
} }
public static String getName(@NonNull Context ctx, @NonNull GPXDataSetType[] types) { public static String getName(@NonNull Context ctx, @NonNull GPXDataSetType[] types) {
@ -1663,7 +1663,7 @@ public class GpxUiHelper {
} }
public Drawable getImageDrawable(OsmandApplication app) { public Drawable getImageDrawable(OsmandApplication app) {
return app.getIconsCache().getThemedIcon(imageId); return app.getUIUtilities().getThemedIcon(imageId);
} }
} }

View file

@ -82,7 +82,7 @@ public class MapMarkerDialogHelper {
textDist.setTextColor(ctx.getResources() textDist.setTextColor(ctx.getResources()
.getColor(useCenter ? R.color.color_distance : R.color.color_myloc_distance)); .getColor(useCenter ? R.color.color_distance : R.color.color_myloc_distance));
} else { } else {
waypointIcon.setImageDrawable(app.getIconsCache() waypointIcon.setImageDrawable(app.getUIUtilities()
.getIcon(R.drawable.ic_action_flag_dark, !nightMode)); .getIcon(R.drawable.ic_action_flag_dark, !nightMode));
AndroidUtils.setTextSecondaryColor(ctx, text, nightMode); AndroidUtils.setTextSecondaryColor(ctx, text, nightMode);
AndroidUtils.setTextSecondaryColor(ctx, textDist, nightMode); AndroidUtils.setTextSecondaryColor(ctx, textDist, nightMode);
@ -124,6 +124,6 @@ public class MapMarkerDialogHelper {
} }
public static Drawable getMapMarkerIcon(OsmandApplication app, int colorIndex) { public static Drawable getMapMarkerIcon(OsmandApplication app, int colorIndex) {
return app.getIconsCache().getIcon(R.drawable.ic_action_flag_dark, MapMarker.getColorId(colorIndex)); return app.getUIUtilities().getIcon(R.drawable.ic_action_flag_dark, MapMarker.getColorId(colorIndex));
} }
} }

View file

@ -147,11 +147,11 @@ public class WaypointDialogHelper {
AndroidUtils.setTextSecondaryColor(activity, textDeviation, nightMode); AndroidUtils.setTextSecondaryColor(activity, textDeviation, nightMode);
if (ps.deviationDirectionRight) { if (ps.deviationDirectionRight) {
textDeviation.setCompoundDrawablesWithIntrinsicBounds( textDeviation.setCompoundDrawablesWithIntrinsicBounds(
app.getIconsCache().getIcon(R.drawable.ic_small_turn_right, colorId), app.getUIUtilities().getIcon(R.drawable.ic_small_turn_right, colorId),
null, null, null); null, null, null);
} else { } else {
textDeviation.setCompoundDrawablesWithIntrinsicBounds( textDeviation.setCompoundDrawablesWithIntrinsicBounds(
app.getIconsCache().getIcon(R.drawable.ic_small_turn_left, colorId), app.getUIUtilities().getIcon(R.drawable.ic_small_turn_left, colorId),
null, null, null); null, null, null);
} }
} }
@ -404,7 +404,7 @@ public class WaypointDialogHelper {
int iconResId = nightMode ? R.color.marker_circle_button_color_dark : R.color.ctx_menu_title_color_dark; int iconResId = nightMode ? R.color.marker_circle_button_color_dark : R.color.ctx_menu_title_color_dark;
remove.setVisibility(View.VISIBLE); remove.setVisibility(View.VISIBLE);
remove.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_remove_dark, iconResId)); remove.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_remove_dark, iconResId));
remove.setEnabled(canRemove); remove.setEnabled(canRemove);
remove.setAlpha(canRemove ? 1 : .5f); remove.setAlpha(canRemove ? 1 : .5f);
if (canRemove) { if (canRemove) {
@ -434,7 +434,7 @@ public class WaypointDialogHelper {
move.setVisibility(notFlatTargets ? View.VISIBLE : View.GONE); move.setVisibility(notFlatTargets ? View.VISIBLE : View.GONE);
if (notFlatTargets) { if (notFlatTargets) {
move.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_reorder, iconResId)); move.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_reorder, iconResId));
move.setTag(new DragIcon() { move.setTag(new DragIcon() {
@Override @Override
public void onClick() { public void onClick() {

View file

@ -13,7 +13,7 @@ import net.osmand.data.LocationPoint;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.osm.PoiType; import net.osmand.osm.PoiType;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings.MetricsConstants; import net.osmand.plus.OsmandSettings.MetricsConstants;
@ -704,7 +704,7 @@ public class WaypointHelper {
return null; return null;
} else if (type == TARGETS) { } else if (type == TARGETS) {
IconsCache iconsCache = app.getIconsCache(); UiUtilities iconsCache = app.getUIUtilities();
if (((TargetPoint) point).start) { if (((TargetPoint) point).start) {
if (app.getTargetPointsHelper().getPointToStart() == null) { if (app.getTargetPointsHelper().getPointToStart() == null) {
return iconsCache.getIcon(R.drawable.ic_action_location_color, 0); return iconsCache.getIcon(R.drawable.ic_action_location_color, 0);

View file

@ -179,7 +179,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
TextView regionNameHeaderTextView = (TextView) subscriptionHeader.findViewById(R.id.regionHeaderTextView); TextView regionNameHeaderTextView = (TextView) subscriptionHeader.findViewById(R.id.regionHeaderTextView);
TextView regionNameTextView = (TextView) subscriptionHeader.findViewById(R.id.regionTextView); TextView regionNameTextView = (TextView) subscriptionHeader.findViewById(R.id.regionTextView);
statusTextView.setText(getString(R.string.osm_live_active)); statusTextView.setText(getString(R.string.osm_live_active));
statusIcon.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_done)); statusIcon.setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_done));
regionNameHeaderTextView.setText(R.string.osm_live_support_region); regionNameHeaderTextView.setText(R.string.osm_live_support_region);
String countryName = getSettings().BILLING_USER_COUNTRY.get(); String countryName = getSettings().BILLING_USER_COUNTRY.get();
if (Algorithms.isEmpty(countryName)) { if (Algorithms.isEmpty(countryName)) {
@ -618,7 +618,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
} }
private Drawable getSecondaryColorPaintedIcon(@DrawableRes int drawable) { private Drawable getSecondaryColorPaintedIcon(@DrawableRes int drawable) {
return fragment.getMyActivity().getMyApplication().getIconsCache() return fragment.getMyActivity().getMyApplication().getUIUtilities()
.getPaintedIcon(drawable, secondaryColor); .getPaintedIcon(drawable, secondaryColor);
} }
} }

View file

@ -135,9 +135,9 @@ public class SubscriptionFragment extends BaseOsmAndDialogFragment implements In
View view = inflater.inflate(R.layout.subscription_fragment, container, false); View view = inflater.inflate(R.layout.subscription_fragment, container, false);
ImageButton closeButton = (ImageButton) view.findViewById(R.id.closeButton); ImageButton closeButton = (ImageButton) view.findViewById(R.id.closeButton);
if (editMode) { if (editMode) {
closeButton.setImageDrawable(getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_mode_back)); closeButton.setImageDrawable(getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_mode_back));
} else { } else {
closeButton.setImageDrawable(getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_remove_dark)); closeButton.setImageDrawable(getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_remove_dark));
} }
closeButton.setOnClickListener(new View.OnClickListener() { closeButton.setOnClickListener(new View.OnClickListener() {
@Override @Override

View file

@ -158,7 +158,7 @@ public class AdditionalActionsBottomSheetDialogFragment extends net.osmand.plus.
@Override @Override
protected Drawable getContentIcon(@DrawableRes int id) { protected Drawable getContentIcon(@DrawableRes int id) {
return getMyApplication().getIconsCache().getIcon(id, nightMode ? R.color.grid_menu_icon_dark : R.color.on_map_icon_color); return getMyApplication().getUIUtilities().getIcon(id, nightMode ? R.color.grid_menu_icon_dark : R.color.on_map_icon_color);
} }
private int getCancelRowBgResId() { private int getCancelRowBgResId() {

View file

@ -2,7 +2,7 @@ package net.osmand.plus.mapcontextmenu;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
@ -71,7 +71,7 @@ public abstract class BaseMenuController {
} }
protected Drawable getIconOrig(int iconId) { protected Drawable getIconOrig(int iconId) {
IconsCache iconsCache = getMapActivity().getMyApplication().getIconsCache(); UiUtilities iconsCache = getMapActivity().getMyApplication().getUIUtilities();
return iconsCache.getIcon(iconId, 0); return iconsCache.getIcon(iconId, 0);
} }
@ -80,17 +80,17 @@ public abstract class BaseMenuController {
} }
protected Drawable getIcon(int iconId, int colorId) { protected Drawable getIcon(int iconId, int colorId) {
IconsCache iconsCache = getMapActivity().getMyApplication().getIconsCache(); UiUtilities iconsCache = getMapActivity().getMyApplication().getUIUtilities();
return iconsCache.getIcon(iconId, colorId); return iconsCache.getIcon(iconId, colorId);
} }
protected Drawable getPaintedIcon(int iconId, int color) { protected Drawable getPaintedIcon(int iconId, int color) {
IconsCache iconsCache = getMapActivity().getMyApplication().getIconsCache(); UiUtilities iconsCache = getMapActivity().getMyApplication().getUIUtilities();
return iconsCache.getPaintedIcon(iconId, color); return iconsCache.getPaintedIcon(iconId, color);
} }
protected Drawable getIcon(int iconId, int colorLightId, int colorDarkId) { protected Drawable getIcon(int iconId, int colorLightId, int colorDarkId) {
IconsCache iconsCache = getMapActivity().getMyApplication().getIconsCache(); UiUtilities iconsCache = getMapActivity().getMyApplication().getUIUtilities();
return iconsCache.getIcon(iconId, isLight() ? colorLightId : colorDarkId); return iconsCache.getIcon(iconId, isLight() ? colorLightId : colorDarkId);
} }
} }

View file

@ -1,15 +1,8 @@
package net.osmand.plus.mapcontextmenu; package net.osmand.plus.mapcontextmenu;
import android.app.Dialog; import java.lang.ref.WeakReference;
import android.app.ProgressDialog; import java.util.LinkedList;
import android.content.DialogInterface; import java.util.List;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.LinearLayout;
import net.osmand.CallbackWithObject; import net.osmand.CallbackWithObject;
import net.osmand.Location; import net.osmand.Location;
@ -56,11 +49,16 @@ import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils; import android.app.Dialog;
import android.app.ProgressDialog;
import java.lang.ref.WeakReference; import android.content.DialogInterface;
import java.util.LinkedList; import android.graphics.drawable.Drawable;
import java.util.List; import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.LinearLayout;
public class MapContextMenu extends MenuTitleController implements StateChangedListener<ApplicationMode>, public class MapContextMenu extends MenuTitleController implements StateChangedListener<ApplicationMode>,
MapMarkerChangedListener, TargetPointChangedListener { MapMarkerChangedListener, TargetPointChangedListener {
@ -84,10 +82,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
private boolean centerMarker; private boolean centerMarker;
private int mapZoom; private int mapZoom;
private LatLon myLocation;
private Float heading;
private boolean inLocationUpdate = false; private boolean inLocationUpdate = false;
private boolean cachedMyLocation;
private boolean appModeChanged; private boolean appModeChanged;
private boolean appModeListenerAdded; private boolean appModeListenerAdded;
private boolean autoHide; private boolean autoHide;
@ -294,9 +289,6 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
boolean update, boolean restorePrevious) { boolean update, boolean restorePrevious) {
OsmandApplication app = mapActivity.getMyApplication(); OsmandApplication app = mapActivity.getMyApplication();
if (myLocation == null) {
updateMyLocation(app.getLocationProvider().getLastKnownLocation(), false);
}
if (!update && isVisible()) { if (!update && isVisible()) {
if (this.object == null || !this.object.equals(object)) { if (this.object == null || !this.object.equals(object)) {
@ -423,7 +415,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
} }
public void onFragmentResume() { public void onFragmentResume() {
if (active && displayDistanceDirection() && myLocation != null) { if (active && displayDistanceDirection()) {
updateLocation(false, true, false); updateLocation(false, true, false);
} }
} }
@ -1249,27 +1241,12 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
return getCurrentMenuState() == MenuState.HEADER_ONLY; return getCurrentMenuState() == MenuState.HEADER_ONLY;
} }
public LatLon getMyLocation() {
return myLocation;
}
public boolean isCachedMyLocation() {
return cachedMyLocation;
}
public Float getHeading() {
return heading;
}
private void updateMyLocation(Location location, boolean updateLocationUi) { private void updateMyLocation(Location location, boolean updateLocationUi) {
if (location == null) { if (location == null) {
location = getMapActivity().getMyApplication().getLocationProvider().getLastStaleKnownLocation(); location = getMapActivity().getMyApplication().getLocationProvider().getLastStaleKnownLocation();
cachedMyLocation = location != null;
} else {
cachedMyLocation = false;
} }
if (location != null) { if (location != null) {
myLocation = new LatLon(location.getLatitude(), location.getLongitude());
if (updateLocationUi) { if (updateLocationUi) {
updateLocation(false, true, false); updateLocation(false, true, false);
} }
@ -1284,15 +1261,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
public void updateCompassValue(float value) { public void updateCompassValue(float value) {
if (active && displayDistanceDirection()) { if (active && displayDistanceDirection()) {
// 99 in next line used to one-time initialize arrows (with reference vs. fixed-north direction) updateLocation(false, false, true);
// on non-compass devices
float lastHeading = heading != null ? heading : 99;
heading = value;
if (Math.abs(MapUtils.degreesDiff(lastHeading, heading)) > 5) {
updateLocation(false, false, true);
} else {
heading = lastHeading;
}
} }
} }

View file

@ -1,5 +1,36 @@
package net.osmand.plus.mapcontextmenu; package net.osmand.plus.mapcontextmenu;
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
import static net.osmand.plus.mapcontextmenu.MenuBuilder.SHADOW_HEIGHT_TOP_DP;
import java.util.List;
import net.osmand.AndroidUtils;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.QuadPoint;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.LockableScrollView;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
import net.osmand.plus.mapcontextmenu.MenuController.MenuState;
import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController;
import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController;
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController;
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.TransportStopsLayer;
import net.osmand.plus.views.controls.HorizontalSwipeConfirm;
import net.osmand.plus.views.controls.SingleTapConfirm;
import net.osmand.util.Algorithms;
import android.animation.Animator; import android.animation.Animator;
import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorListenerAdapter;
import android.annotation.TargetApi; import android.annotation.TargetApi;
@ -35,38 +66,6 @@ import android.widget.OverScroller;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.QuadPoint;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.LockableScrollView;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
import net.osmand.plus.mapcontextmenu.MenuController.MenuState;
import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController;
import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController;
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController;
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.TransportStopsLayer;
import net.osmand.plus.views.controls.HorizontalSwipeConfirm;
import net.osmand.plus.views.controls.SingleTapConfirm;
import net.osmand.util.Algorithms;
import java.util.List;
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
import static net.osmand.plus.mapcontextmenu.MenuBuilder.SHADOW_HEIGHT_TOP_DP;
public class MapContextMenuFragment extends BaseOsmAndFragment implements DownloadEvents { public class MapContextMenuFragment extends BaseOsmAndFragment implements DownloadEvents {
public static final String TAG = "MapContextMenuFragment"; public static final String TAG = "MapContextMenuFragment";
@ -134,6 +133,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private int screenOrientation; private int screenOrientation;
private boolean created; private boolean created;
private UpdateLocationViewCache updateLocationViewCache;
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
@ -141,6 +142,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
processScreenHeight(container); processScreenHeight(container);
menu = getMapActivity().getContextMenu(); menu = getMapActivity().getContextMenu();
updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache();
markerPaddingPx = dpToPx(MARKER_PADDING_DP); markerPaddingPx = dpToPx(MARKER_PADDING_DP);
markerPaddingXPx = dpToPx(MARKER_PADDING_X_DP); markerPaddingXPx = dpToPx(MARKER_PADDING_X_DP);
@ -751,7 +753,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
} }
private void updateImageButton(ImageButton button, int iconLightId, int iconDarkId, int bgLightId, int bgDarkId, boolean night) { private void updateImageButton(ImageButton button, int iconLightId, int iconDarkId, int bgLightId, int bgDarkId, boolean night) {
button.setImageDrawable(getMapActivity().getMyApplication().getIconsCache().getIcon(night ? iconDarkId : iconLightId)); button.setImageDrawable(getMapActivity().getMyApplication().getUIUtilities().getIcon(night ? iconDarkId : iconLightId));
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
button.setBackground(getMapActivity().getResources().getDrawable(night ? bgDarkId : bgLightId, button.setBackground(getMapActivity().getResources().getDrawable(night ? bgDarkId : bgLightId,
getMapActivity().getTheme())); getMapActivity().getTheme()));
@ -1171,7 +1173,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
dismissMenu(); dismissMenu();
return; return;
} }
screenOrientation = DashLocationFragment.getScreenOrientation(getActivity()); updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache();
getMapActivity().getMapViewTrackingUtilities().setContextMenu(menu); getMapActivity().getMapViewTrackingUtilities().setContextMenu(menu);
getMapActivity().getMapViewTrackingUtilities().setMapLinkedToLocation(false); getMapActivity().getMapViewTrackingUtilities().setMapLinkedToLocation(false);
wasDrawerDisabled = getMapActivity().isDrawerDisabled(); wasDrawerDisabled = getMapActivity().isDrawerDisabled();
@ -1495,7 +1497,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
OsmandApplication app = getMyApplication(); OsmandApplication app = getMyApplication();
if (app != null && view != null) { if (app != null && view != null) {
View compassView = view.findViewById(R.id.compass_layout); View compassView = view.findViewById(R.id.compass_layout);
if (menu.getMyLocation() != null && menu.displayDistanceDirection() && menu.getCurrentMenuState() != MenuState.FULL_SCREEN) { if (menu.displayDistanceDirection() && menu.getCurrentMenuState() != MenuState.FULL_SCREEN) {
updateDistanceDirection(); updateDistanceDirection();
compassView.setVisibility(View.VISIBLE); compassView.setVisibility(View.VISIBLE);
} else { } else {
@ -1534,10 +1536,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
if (app != null && activity != null && view != null) { if (app != null && activity != null && view != null) {
TextView distanceText = (TextView) view.findViewById(R.id.distance); TextView distanceText = (TextView) view.findViewById(R.id.distance);
ImageView direction = (ImageView) view.findViewById(R.id.direction); ImageView direction = (ImageView) view.findViewById(R.id.direction);
float myHeading = menu.getHeading() == null ? 0f : menu.getHeading(); getMyApplication().getUIUtilities().updateLocationView(updateLocationViewCache, direction, distanceText, menu.getLatLon());
int color = menu.isCachedMyLocation() ? R.color.icon_color : 0;
DashLocationFragment.updateLocationView(false, menu.getMyLocation(), myHeading, direction, color, distanceText,
color, menu.getLatLon().getLatitude(), menu.getLatLon().getLongitude(), screenOrientation, app, activity);
} }
} }

View file

@ -35,7 +35,7 @@ import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.data.QuadRect; import net.osmand.data.QuadRect;
import net.osmand.osm.PoiCategory; import net.osmand.osm.PoiCategory;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
@ -745,7 +745,7 @@ public class MenuBuilder {
} }
public Drawable getRowIcon(int iconId) { public Drawable getRowIcon(int iconId) {
IconsCache iconsCache = app.getIconsCache(); UiUtilities iconsCache = app.getUIUtilities();
return iconsCache.getIcon(iconId, light ? R.color.ctx_menu_bottom_view_icon_light : R.color.ctx_menu_bottom_view_icon_dark); return iconsCache.getIcon(iconId, light ? R.color.ctx_menu_bottom_view_icon_light : R.color.ctx_menu_bottom_view_icon_dark);
} }
@ -782,7 +782,7 @@ public class MenuBuilder {
} }
public Drawable getCollapseIcon(boolean collapsed) { public Drawable getCollapseIcon(boolean collapsed) {
return app.getIconsCache().getIcon(collapsed ? R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up, return app.getUIUtilities().getIcon(collapsed ? R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up,
light ? R.color.ctx_menu_collapse_icon_color_light : R.color.ctx_menu_collapse_icon_color_dark); light ? R.color.ctx_menu_collapse_icon_color_light : R.color.ctx_menu_collapse_icon_color_dark);
} }
@ -826,7 +826,7 @@ public class MenuBuilder {
titleView.setTextSize(16); titleView.setTextSize(16);
titleView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark)); titleView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark));
String desc = route.getDescription(getMapActivity().getMyApplication(), true); String desc = route.getDescription(getMapActivity().getMyApplication(), true);
Drawable arrow = app.getIconsCache().getIcon(R.drawable.ic_arrow_right_16, light ? R.color.ctx_menu_route_icon_color_light : R.color.ctx_menu_route_icon_color_dark); Drawable arrow = app.getUIUtilities().getIcon(R.drawable.ic_arrow_right_16, light ? R.color.ctx_menu_route_icon_color_light : R.color.ctx_menu_route_icon_color_dark);
arrow.setBounds(0, 0, arrow.getIntrinsicWidth(), arrow.getIntrinsicHeight()); arrow.setBounds(0, 0, arrow.getIntrinsicWidth(), arrow.getIntrinsicHeight());
titleView.setText(AndroidUtils.replaceCharsWithIcon(desc, arrow, arrowChars)); titleView.setText(AndroidUtils.replaceCharsWithIcon(desc, arrow, arrowChars));

View file

@ -260,9 +260,9 @@ public class AmenityMenuBuilder extends MenuBuilder {
}); });
button.setAllCaps(true); button.setAllCaps(true);
button.setText(R.string.context_menu_read_full_article); button.setText(R.string.context_menu_read_full_article);
Drawable normal = app.getIconsCache().getIcon(R.drawable.ic_action_read_text, Drawable normal = app.getUIUtilities().getIcon(R.drawable.ic_action_read_text,
light ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n); light ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n);
Drawable pressed = app.getIconsCache().getIcon(R.drawable.ic_action_read_text, Drawable pressed = app.getUIUtilities().getIcon(R.drawable.ic_action_read_text,
light ? R.color.ctx_menu_controller_button_text_color_light_p : R.color.ctx_menu_controller_button_text_color_dark_p); light ? R.color.ctx_menu_controller_button_text_color_light_p : R.color.ctx_menu_controller_button_text_color_dark_p);
button.setCompoundDrawablesWithIntrinsicBounds(Build.VERSION.SDK_INT >= 21 button.setCompoundDrawablesWithIntrinsicBounds(Build.VERSION.SDK_INT >= 21
? AndroidUtils.createPressedStateListDrawable(normal, pressed) : normal, null, null, null); ? AndroidUtils.createPressedStateListDrawable(normal, pressed) : normal, null, null, null);

View file

@ -93,7 +93,7 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
int disabledColor = light ? R.color.secondary_text_light : R.color.secondary_text_dark; int disabledColor = light ? R.color.secondary_text_light : R.color.secondary_text_dark;
color = favoriteGroup.visible ? (color | 0xff000000) : view.getResources().getColor(disabledColor); color = favoriteGroup.visible ? (color | 0xff000000) : view.getResources().getColor(disabledColor);
String name = view.getContext().getString(R.string.context_menu_points_of_group); String name = view.getContext().getString(R.string.context_menu_points_of_group);
buildRow(view, app.getIconsCache().getPaintedIcon(R.drawable.ic_action_folder, color), null, name, 0, null, buildRow(view, app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_folder, color), null, name, 0, null,
true, getCollapsableFavouritesView(view.getContext(), true, favoriteGroup, fav), true, getCollapsableFavouritesView(view.getContext(), true, favoriteGroup, fav),
false, 0, false, null, false); false, 0, false, null, false);
} }

View file

@ -65,7 +65,7 @@ public class GpxItemMenuBuilder extends MenuBuilder {
llIconParams.setMargins(0, 0, gpxSmallIconMargin, 0); llIconParams.setMargins(0, 0, gpxSmallIconMargin, 0);
llIconParams.gravity = Gravity.CENTER_VERTICAL; llIconParams.gravity = Gravity.CENTER_VERTICAL;
icon.setLayoutParams(llIconParams); icon.setLayoutParams(llIconParams);
icon.setImageDrawable(app.getIconsCache().getThemedIcon(iconId)); icon.setImageDrawable(app.getUIUtilities().getThemedIcon(iconId));
ll.addView(icon); ll.addView(icon);
} }

View file

@ -109,7 +109,7 @@ public class WptPtMenuBuilder extends MenuBuilder {
File file = new File(gpx.path); File file = new File(gpx.path);
String gpxName = file.getName().replace(".gpx", "").replace("/", " ").replace("_", " "); String gpxName = file.getName().replace(".gpx", "").replace("/", " ").replace("_", " ");
int color = getPointColor(wpt, getFileColor(selectedGpxFile)); int color = getPointColor(wpt, getFileColor(selectedGpxFile));
buildRow(view, app.getIconsCache().getPaintedIcon(R.drawable.ic_type_waypoints_group, color), null, title, 0, gpxName, buildRow(view, app.getUIUtilities().getPaintedIcon(R.drawable.ic_type_waypoints_group, color), null, title, 0, gpxName,
true, getCollapsableWaypointsView(view.getContext(), true, gpx, wpt), true, getCollapsableWaypointsView(view.getContext(), true, gpx, wpt),
false, 0, false, null, false); false, 0, false, null, false);
} }

View file

@ -76,7 +76,7 @@ public abstract class AbstractCard {
final Toolbar topBar = new Toolbar(ctx); final Toolbar topBar = new Toolbar(ctx);
topBar.setClickable(true); topBar.setClickable(true);
Drawable back = app.getIconsCache().getIcon(R.drawable.ic_action_remove_dark); Drawable back = app.getUIUtilities().getIcon(R.drawable.ic_action_remove_dark);
topBar.setNavigationIcon(back); topBar.setNavigationIcon(back);
topBar.setNavigationContentDescription(R.string.shared_string_close); topBar.setNavigationContentDescription(R.string.shared_string_close);
topBar.setTitle(title); topBar.setTitle(title);

View file

@ -328,7 +328,7 @@ public abstract class ImageCard extends AbstractCard {
R.drawable.context_menu_card_light, R.drawable.context_menu_card_dark); R.drawable.context_menu_card_light, R.drawable.context_menu_card_dark);
if (icon == null && topIconId != 0) { if (icon == null && topIconId != 0) {
icon = getMyApplication().getIconsCache().getIcon(topIconId); icon = getMyApplication().getUIUtilities().getIcon(topIconId);
} }
if (icon == null) { if (icon == null) {
iconImageView.setVisibility(View.GONE); iconImageView.setVisibility(View.GONE);
@ -373,9 +373,9 @@ public abstract class ImageCard extends AbstractCard {
} }
if (buttonIcon == null && buttonIconId != 0) { if (buttonIcon == null && buttonIconId != 0) {
if (buttonIconColor != 0) { if (buttonIconColor != 0) {
buttonIcon = getMyApplication().getIconsCache().getPaintedIcon(buttonIconId, buttonIconColor); buttonIcon = getMyApplication().getUIUtilities().getPaintedIcon(buttonIconId, buttonIconColor);
} else { } else {
buttonIcon = getMyApplication().getIconsCache().getIcon(buttonIconId); buttonIcon = getMyApplication().getUIUtilities().getIcon(buttonIconId);
} }
} }
button.setCompoundDrawablesWithIntrinsicBounds(buttonIcon, null, null, null); button.setCompoundDrawablesWithIntrinsicBounds(buttonIcon, null, null, null);

View file

@ -6,7 +6,7 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapillary.MapillaryPlugin; import net.osmand.plus.mapillary.MapillaryPlugin;
@ -25,7 +25,7 @@ public class NoImagesCard extends AbstractCard {
@Override @Override
public void update() { public void update() {
if (view != null) { if (view != null) {
IconsCache ic = getMyApplication().getIconsCache(); UiUtilities ic = getMyApplication().getUIUtilities();
boolean night = getMyApplication().getDaynightHelper().isNightModeForMapControls(); boolean night = getMyApplication().getDaynightHelper().isNightModeForMapControls();
MapActivity ctx = getMapActivity(); MapActivity ctx = getMapActivity();
AndroidUtils.setBackgroundColor(ctx, view, night, R.color.bg_color_light, R.color.bg_color_dark); AndroidUtils.setBackgroundColor(ctx, view, night, R.color.bg_color_light, R.color.bg_color_dark);

View file

@ -47,7 +47,7 @@ public abstract class PointEditorFragment extends BaseOsmAndFragment {
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar); Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setTitle(getToolbarTitle()); toolbar.setTitle(getToolbarTitle());
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back)); toolbar.setNavigationIcon(getMyApplication().getUIUtilities().getIcon(R.drawable.ic_arrow_back));
toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up); toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
toolbar.setTitleTextColor(getResources().getColor(getResIdFromAttribute(getMapActivity(), R.attr.pstsTextColor))); toolbar.setTitleTextColor(getResources().getColor(getResIdFromAttribute(getMapActivity(), R.attr.pstsTextColor)));
toolbar.setNavigationOnClickListener(new View.OnClickListener() { toolbar.setNavigationOnClickListener(new View.OnClickListener() {

View file

@ -18,7 +18,7 @@ import net.osmand.AndroidUtils;
import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.GPXUtilities.GPXFile; import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.WptPt; import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
@ -168,7 +168,7 @@ public class SelectCategoryDialogFragment extends DialogFragment {
private static Drawable getIcon(final Activity activity, int iconId) { private static Drawable getIcon(final Activity activity, int iconId) {
OsmandApplication app = (OsmandApplication)activity.getApplication(); OsmandApplication app = (OsmandApplication)activity.getApplication();
IconsCache iconsCache = app.getIconsCache(); UiUtilities iconsCache = app.getUIUtilities();
boolean light = app.getSettings().isLightContent(); boolean light = app.getSettings().isLightContent();
return iconsCache.getIcon(iconId, return iconsCache.getIcon(iconId,
light ? R.color.icon_color : R.color.icon_color_light); light ? R.color.icon_color : R.color.icon_color_light);

View file

@ -15,7 +15,7 @@ import android.widget.TextView;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper;
@ -55,7 +55,7 @@ public class DestinationReachedMenuFragment extends Fragment {
} }
}); });
IconsCache iconsCache = getMapActivity().getMyApplication().getIconsCache(); UiUtilities iconsCache = getMapActivity().getMyApplication().getUIUtilities();
ImageButton closeImageButton = (ImageButton) view.findViewById(R.id.closeImageButton); ImageButton closeImageButton = (ImageButton) view.findViewById(R.id.closeImageButton);
closeImageButton.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_remove_dark, menu.isLight())); closeImageButton.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_remove_dark, menu.isLight()));

View file

@ -1,5 +1,13 @@
package net.osmand.plus.mapcontextmenu.other; package net.osmand.plus.mapcontextmenu.other;
import java.util.List;
import net.osmand.data.FavouritePoint;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
import net.osmand.plus.base.FavoriteImageDrawable;
import android.app.Activity;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -7,35 +15,19 @@ import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.util.MapUtils;
import java.util.List;
public class FavouritesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class FavouritesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private final List<FavouritePoint> favouritePoints; private final List<FavouritePoint> favouritePoints;
private OsmandApplication app; private OsmandApplication app;
private IconsCache iconsCache;
private View.OnClickListener listener; private View.OnClickListener listener;
private LatLon location; private UpdateLocationViewCache cache;
private Float heading;
private boolean useCenter;
private int screenOrientation;
public FavouritesAdapter(OsmandApplication app, List<FavouritePoint> FavouritePoints) { public FavouritesAdapter(OsmandApplication app, List<FavouritePoint> FavouritePoints) {
this.app = app; this.app = app;
iconsCache = app.getIconsCache();
this.favouritePoints = FavouritePoints; this.favouritePoints = FavouritePoints;
cache = app.getUIUtilities().getUpdateLocationViewCache();
} }
@Override @Override
@ -57,15 +49,8 @@ public class FavouritesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
favouritesViewHolder.description.setText(favouritePoint.getCategory()); favouritesViewHolder.description.setText(favouritePoint.getCategory());
} }
favouritesViewHolder.favouriteImage.setImageDrawable(FavoriteImageDrawable.getOrCreate(app, favouritePoint.getColor(), false)); favouritesViewHolder.favouriteImage.setImageDrawable(FavoriteImageDrawable.getOrCreate(app, favouritePoint.getColor(), false));
if (location == null) { app.getUIUtilities().updateLocationView(cache, favouritesViewHolder.arrowImage, favouritesViewHolder.distance,
return; favouritePoint.getLatitude(), favouritePoint.getLongitude());
}
float dist = (float) MapUtils.getDistance(favouritePoint.getLatitude(), favouritePoint.getLongitude(), location.getLatitude(), location.getLongitude());
favouritesViewHolder.distance.setText(OsmAndFormatter.getFormattedDistance(dist, app));
favouritesViewHolder.arrowImage.setImageDrawable(iconsCache.getIcon(R.drawable.ic_direction_arrow));
DashLocationFragment.updateLocationView(useCenter, location, heading, favouritesViewHolder.arrowImage,
favouritesViewHolder.distance, favouritePoint.getLatitude(), favouritePoint.getLongitude(),
screenOrientation, app);
} }
} }
@ -82,21 +67,6 @@ public class FavouritesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
this.listener = listener; this.listener = listener;
} }
public void setScreenOrientation(int screenOrientation) {
this.screenOrientation = screenOrientation;
}
public void setLocation(LatLon location) {
this.location = location;
}
public void setHeading(Float heading) {
this.heading = heading;
}
public void setUseCenter(boolean useCenter) {
this.useCenter = useCenter;
}
class FavouritesViewHolder extends RecyclerView.ViewHolder { class FavouritesViewHolder extends RecyclerView.ViewHolder {

View file

@ -37,9 +37,6 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
private static final String IS_SORTED = "sorted"; private static final String IS_SORTED = "sorted";
private static final String SORTED_BY_TYPE = "sortedByType"; private static final String SORTED_BY_TYPE = "sortedByType";
private Location location;
private LatLon latLon;
private Float heading;
private List<FavouritePoint> favouritePoints; private List<FavouritePoint> favouritePoints;
private FavouritesAdapter adapter; private FavouritesAdapter adapter;
private RecyclerView recyclerView; private RecyclerView recyclerView;
@ -49,6 +46,7 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
private boolean compassUpdateAllowed = true; private boolean compassUpdateAllowed = true;
private boolean target; private boolean target;
private boolean intermediate; private boolean intermediate;
private float lastHeading;
@Override @Override
public void createMenuItems(final Bundle savedInstanceState) { public void createMenuItems(final Bundle savedInstanceState) {
@ -66,16 +64,7 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
recyclerView = (RecyclerView) View.inflate(new ContextThemeWrapper(getContext(), themeRes), recyclerView = (RecyclerView) View.inflate(new ContextThemeWrapper(getContext(), themeRes),
R.layout.recyclerview, null); R.layout.recyclerview, null);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
location = getMyApplication().getLocationProvider().getLastStaleKnownLocation();
adapter = new FavouritesAdapter(getMyApplication(), favouritePoints); adapter = new FavouritesAdapter(getMyApplication(), favouritePoints);
if (location != null) {
latLon = new LatLon(location.getLatitude(), location.getLongitude());
adapter.setUseCenter(false);
} else {
latLon = ((MapActivity) getActivity()).getMapLocation();
adapter.setUseCenter(true);
}
adapter.setLocation(latLon);
sortFavourites(); sortFavourites();
final BottomSheetItemTitleWithDescrAndButton[] title = new BottomSheetItemTitleWithDescrAndButton[1]; final BottomSheetItemTitleWithDescrAndButton[] title = new BottomSheetItemTitleWithDescrAndButton[1];
title[0] = (BottomSheetItemTitleWithDescrAndButton) new BottomSheetItemTitleWithDescrAndButton.Builder() title[0] = (BottomSheetItemTitleWithDescrAndButton) new BottomSheetItemTitleWithDescrAndButton.Builder()
@ -171,7 +160,6 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
adapter.setScreenOrientation(DashLocationFragment.getScreenOrientation(getActivity()));
startLocationUpdate(); startLocationUpdate();
} }
@ -184,26 +172,14 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
@Override @Override
public void updateLocation(Location location) { public void updateLocation(Location location) {
boolean newLocation = this.location == null && location != null; updateLocationUi();
boolean locationChanged = this.location != null && location != null
&& this.location.getLatitude() != location.getLatitude()
&& this.location.getLongitude() != location.getLongitude();
if (newLocation || locationChanged) {
this.location = location;
updateLocationUi();
}
} }
@Override @Override
public void updateCompassValue(float value) { public void updateCompassValue(float value) {
// 99 in next line used to one-time initialize arrows (with reference vs. fixed-north direction) if (Math.abs(MapUtils.degreesDiff(lastHeading, value)) > 5) {
// on non-compass devices lastHeading = value;
float lastHeading = heading != null ? heading : 99;
heading = value;
if (Math.abs(MapUtils.degreesDiff(lastHeading, heading)) > 5) {
updateLocationUi(); updateLocationUi();
} else {
heading = lastHeading;
} }
} }
@ -216,15 +192,6 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
mapActivity.getMyApplication().runInUIThread(new Runnable() { mapActivity.getMyApplication().runInUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
if (location == null) {
location = getMyApplication().getLocationProvider().getLastStaleKnownLocation();
}
boolean useCenter = location == null;
latLon = useCenter ? mapActivity.getMapLocation() : new LatLon(location.getLatitude(), location.getLongitude());
adapter.setUseCenter(useCenter);
adapter.setLocation(latLon);
adapter.setHeading(useCenter ? -mapActivity.getMapRotate() : heading != null ? heading : 99);
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
}); });
@ -266,6 +233,9 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
private void sortFavourites() { private void sortFavourites() {
final Collator inst = Collator.getInstance(); final Collator inst = Collator.getInstance();
Location stale = getMyApplication().getLocationProvider().getLastStaleKnownLocation();
final LatLon latLon = stale != null ? new LatLon(stale.getLatitude(), stale.getLongitude()) :
getMyApplication().getMapViewTrackingUtilities().getMapLocation();
Collections.sort(favouritePoints, new Comparator<FavouritePoint>() { Collections.sort(favouritePoints, new Comparator<FavouritePoint>() {
@Override @Override
public int compare(FavouritePoint lhs, FavouritePoint rhs) { public int compare(FavouritePoint lhs, FavouritePoint rhs) {

View file

@ -28,7 +28,7 @@ import net.osmand.data.RotatedTileBox;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.GeocodingLookupService; import net.osmand.plus.GeocodingLookupService;
import net.osmand.plus.GeocodingLookupService.AddressLookupRequest; import net.osmand.plus.GeocodingLookupService.AddressLookupRequest;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
@ -231,7 +231,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
main.findViewById(R.id.InfoDuration).setVisibility(View.GONE); main.findViewById(R.id.InfoDuration).setVisibility(View.GONE);
textView.setText(R.string.route_is_too_long_v2); textView.setText(R.string.route_is_too_long_v2);
textView.setVisibility(View.VISIBLE); textView.setVisibility(View.VISIBLE);
iconView.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getIcon(R.drawable.ic_warning, isLight())); iconView.setImageDrawable(mapActivity.getMyApplication().getUIUtilities().getIcon(R.drawable.ic_warning, isLight()));
} else { } else {
main.findViewById(R.id.dividerToDropDown).setVisibility(View.GONE); main.findViewById(R.id.dividerToDropDown).setVisibility(View.GONE);
main.findViewById(R.id.RouteInfoControls).setVisibility(View.GONE); main.findViewById(R.id.RouteInfoControls).setVisibility(View.GONE);
@ -294,7 +294,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
ImageView viaIcon = (ImageView) parentView.findViewById(R.id.viaIcon); ImageView viaIcon = (ImageView) parentView.findViewById(R.id.viaIcon);
viaIcon.setImageDrawable(getIconOrig(R.drawable.list_intermediate)); viaIcon.setImageDrawable(getIconOrig(R.drawable.list_intermediate));
swapDirectionView.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_change_navigation_points, swapDirectionView.setImageDrawable(mapActivity.getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_change_navigation_points,
isLight() ? R.color.route_info_control_icon_color_light : R.color.route_info_control_icon_color_dark)); isLight() ? R.color.route_info_control_icon_color_light : R.color.route_info_control_icon_color_dark));
swapDirectionView.setOnClickListener(new View.OnClickListener() { swapDirectionView.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -378,7 +378,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
updateToIcon(parentView); updateToIcon(parentView);
ImageView toDropDownIcon = (ImageView) parentView.findViewById(R.id.toDropDownIcon); ImageView toDropDownIcon = (ImageView) parentView.findViewById(R.id.toDropDownIcon);
toDropDownIcon.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_arrow_drop_down, isLight())); toDropDownIcon.setImageDrawable(mapActivity.getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_arrow_drop_down, isLight()));
} }
private void updateToIcon(View parentView) { private void updateToIcon(View parentView) {
@ -448,7 +448,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
updateFromIcon(parentView); updateFromIcon(parentView);
ImageView fromDropDownIcon = (ImageView) parentView.findViewById(R.id.fromDropDownIcon); ImageView fromDropDownIcon = (ImageView) parentView.findViewById(R.id.fromDropDownIcon);
fromDropDownIcon.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_arrow_drop_down, isLight())); fromDropDownIcon.setImageDrawable(mapActivity.getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_arrow_drop_down, isLight()));
} }
public void updateFromIcon(View parentView) { public void updateFromIcon(View parentView) {
@ -520,7 +520,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
} }
private Drawable getIconOrig(int iconId) { private Drawable getIconOrig(int iconId) {
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache(); UiUtilities iconsCache = mapActivity.getMyApplication().getUIUtilities();
return iconsCache.getIcon(iconId, 0); return iconsCache.getIcon(iconId, 0);
} }
@ -550,7 +550,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
mainView.findViewById(R.id.RouteInfoControls).setVisibility(View.VISIBLE); mainView.findViewById(R.id.RouteInfoControls).setVisibility(View.VISIBLE);
final OsmandApplication ctx = mapActivity.getMyApplication(); final OsmandApplication ctx = mapActivity.getMyApplication();
ImageView prev = (ImageView) mainView.findViewById(R.id.Prev); ImageView prev = (ImageView) mainView.findViewById(R.id.Prev);
prev.setImageDrawable(ctx.getIconsCache().getIcon(R.drawable.ic_prev, isLight())); prev.setImageDrawable(ctx.getUIUtilities().getIcon(R.drawable.ic_prev, isLight()));
if (directionInfo >= 0) { if (directionInfo >= 0) {
prev.setVisibility(View.VISIBLE); prev.setVisibility(View.VISIBLE);
prev.setOnClickListener(new View.OnClickListener() { prev.setOnClickListener(new View.OnClickListener() {
@ -578,7 +578,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
} }
ImageView next = (ImageView) mainView.findViewById(R.id.Next); ImageView next = (ImageView) mainView.findViewById(R.id.Next);
next.setVisibility(View.VISIBLE); next.setVisibility(View.VISIBLE);
next.setImageDrawable(ctx.getIconsCache().getIcon(R.drawable.ic_next, isLight())); next.setImageDrawable(ctx.getUIUtilities().getIcon(R.drawable.ic_next, isLight()));
next.setOnClickListener(new View.OnClickListener() { next.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -614,9 +614,9 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
infoDurationView.setVisibility(View.GONE); infoDurationView.setVisibility(View.GONE);
textView.setVisibility(View.VISIBLE); textView.setVisibility(View.VISIBLE);
} else { } else {
infoIcon.setImageDrawable(ctx.getIconsCache().getIcon(R.drawable.ic_action_route_distance, R.color.route_info_unchecked_mode_icon_color)); infoIcon.setImageDrawable(ctx.getUIUtilities().getIcon(R.drawable.ic_action_route_distance, R.color.route_info_unchecked_mode_icon_color));
infoIcon.setVisibility(View.VISIBLE); infoIcon.setVisibility(View.VISIBLE);
durationIcon.setImageDrawable(ctx.getIconsCache().getIcon(R.drawable.ic_action_time_span, R.color.route_info_unchecked_mode_icon_color)); durationIcon.setImageDrawable(ctx.getUIUtilities().getIcon(R.drawable.ic_action_time_span, R.color.route_info_unchecked_mode_icon_color));
durationIcon.setVisibility(View.VISIBLE); durationIcon.setVisibility(View.VISIBLE);
infoDistanceView.setVisibility(View.VISIBLE); infoDistanceView.setVisibility(View.VISIBLE);
infoDurationView.setVisibility(View.VISIBLE); infoDurationView.setVisibility(View.VISIBLE);
@ -997,7 +997,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
if (row.icon != null) { if (row.icon != null) {
icon = row.icon; icon = row.icon;
} else if (row.iconId > 0) { } else if (row.iconId > 0) {
icon = mapActivity.getMyApplication().getIconsCache().getThemedIcon(row.iconId); icon = mapActivity.getMyApplication().getUIUtilities().getThemedIcon(row.iconId);
} }
label.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); label.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
label.setCompoundDrawablePadding(AndroidUtils.dpToPx(mapActivity, 16f)); label.setCompoundDrawablePadding(AndroidUtils.dpToPx(mapActivity, 16f));

View file

@ -11,7 +11,7 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.R; import net.osmand.plus.R;
import java.util.List; import java.util.List;
@ -50,7 +50,7 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter<MapMultiSelectionMe
} }
} }
}); });
IconsCache iconsCache = menu.getMapActivity().getMyApplication().getIconsCache(); UiUtilities iconsCache = menu.getMapActivity().getMyApplication().getUIUtilities();
final View iconLayout = convertView.findViewById(R.id.context_menu_icon_layout); final View iconLayout = convertView.findViewById(R.id.context_menu_icon_layout);
final ImageView iconView = (ImageView) convertView.findViewById(R.id.context_menu_icon_view); final ImageView iconView = (ImageView) convertView.findViewById(R.id.context_menu_icon_view);
Drawable icon = item.getRightIcon(); Drawable icon = item.getRightIcon();

View file

@ -454,7 +454,7 @@ public class RoutePreferencesMenu {
v.findViewById(R.id.description_text).setVisibility(View.GONE); v.findViewById(R.id.description_text).setVisibility(View.GONE);
v.findViewById(R.id.select_button).setVisibility(View.GONE); v.findViewById(R.id.select_button).setVisibility(View.GONE);
((ImageView) v.findViewById(R.id.icon)) ((ImageView) v.findViewById(R.id.icon))
.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_volume_up, !nightMode)); .setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_volume_up, !nightMode));
final CompoundButton btn = (CompoundButton) v.findViewById(R.id.toggle_item); final CompoundButton btn = (CompoundButton) v.findViewById(R.id.toggle_item);
btn.setVisibility(View.VISIBLE); btn.setVisibility(View.VISIBLE);
btn.setChecked(!routingHelper.getVoiceRouter().isMute()); btn.setChecked(!routingHelper.getVoiceRouter().isMute());
@ -474,7 +474,7 @@ public class RoutePreferencesMenu {
View v = mapActivity.getLayoutInflater().inflate(R.layout.switch_select_list_item, null); View v = mapActivity.getLayoutInflater().inflate(R.layout.switch_select_list_item, null);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode); AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
((ImageView) v.findViewById(R.id.icon)) ((ImageView) v.findViewById(R.id.icon))
.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_road_works_dark, !nightMode)); .setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_road_works_dark, !nightMode));
v.findViewById(R.id.toggle_item).setVisibility(View.GONE); v.findViewById(R.id.toggle_item).setVisibility(View.GONE);
final TextView btn = (TextView) v.findViewById(R.id.select_button); final TextView btn = (TextView) v.findViewById(R.id.select_button);
btn.setTextColor(btn.getLinkTextColors()); btn.setTextColor(btn.getLinkTextColors());
@ -560,7 +560,7 @@ public class RoutePreferencesMenu {
final TextView gpxSpinner = (TextView) v.findViewById(R.id.GPXRouteSpinner); final TextView gpxSpinner = (TextView) v.findViewById(R.id.GPXRouteSpinner);
AndroidUtils.setTextPrimaryColor(mapActivity, gpxSpinner, nightMode); AndroidUtils.setTextPrimaryColor(mapActivity, gpxSpinner, nightMode);
((ImageView) v.findViewById(R.id.dropDownIcon)) ((ImageView) v.findViewById(R.id.dropDownIcon))
.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_arrow_drop_down, !nightMode)); .setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_arrow_drop_down, !nightMode));
updateSpinnerItems(gpxSpinner); updateSpinnerItems(gpxSpinner);
return v; return v;
} }
@ -568,7 +568,7 @@ public class RoutePreferencesMenu {
View v = mapActivity.getLayoutInflater().inflate(R.layout.layers_list_activity_item, null); View v = mapActivity.getLayoutInflater().inflate(R.layout.layers_list_activity_item, null);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode); AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
final ImageView icon = (ImageView) v.findViewById(R.id.icon); final ImageView icon = (ImageView) v.findViewById(R.id.icon);
icon.setImageDrawable(app.getIconsCache().getIcon(R.drawable.map_action_settings, !nightMode)); icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.map_action_settings, !nightMode));
icon.setVisibility(View.VISIBLE); icon.setVisibility(View.VISIBLE);
TextView titleView = (TextView) v.findViewById(R.id.title); TextView titleView = (TextView) v.findViewById(R.id.title);
titleView.setText(R.string.routing_settings_2); titleView.setText(R.string.routing_settings_2);

View file

@ -27,7 +27,7 @@ import net.osmand.plus.GPXUtilities.TrkSegment;
import net.osmand.plus.GPXUtilities.WptPt; import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.GPXUtilities.GPXFile; import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
@ -450,7 +450,7 @@ public class TrackDetailsMenu {
}); });
final OsmandApplication app = mapActivity.getMyApplication(); final OsmandApplication app = mapActivity.getMyApplication();
final IconsCache ic = app.getIconsCache(); final UiUtilities ic = app.getUIUtilities();
GpxUiHelper.setupGPXChart(app, chart, 4); GpxUiHelper.setupGPXChart(app, chart, 4);

View file

@ -136,7 +136,7 @@ public class MapillaryAutoCompleteAdapter extends ArrayAdapter<String> implement
nameTv.setText(names.get(position)); nameTv.setText(names.get(position));
if (wrong) { if (wrong) {
Drawable icon = app.getIconsCache().getPaintedIcon(R.drawable.ic_warning, app.getResources().getColor(R.color.color_warning)); Drawable icon = app.getUIUtilities().getPaintedIcon(R.drawable.ic_warning, app.getResources().getColor(R.color.color_warning));
iconIv.setImageDrawable(icon); iconIv.setImageDrawable(icon);
iconIv.setVisibility(View.VISIBLE); iconIv.setVisibility(View.VISIBLE);
} }

View file

@ -32,7 +32,7 @@ import net.osmand.data.QuadRect;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
import net.osmand.map.ITileSource; import net.osmand.map.ITileSource;
import net.osmand.map.TileSourceManager; import net.osmand.map.TileSourceManager;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuBuilder;
@ -85,12 +85,12 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
private double fetchedTileLon = Double.NaN; private double fetchedTileLon = Double.NaN;
private List<MapillaryImage> sequenceImages = new ArrayList<>(); private List<MapillaryImage> sequenceImages = new ArrayList<>();
private AtomicInteger downloadRequestNumber = new AtomicInteger(); private AtomicInteger downloadRequestNumber = new AtomicInteger();
private IconsCache ic; private UiUtilities ic;
public MapillaryImageDialog(@NonNull MapActivity mapActivity, @NonNull Bundle bundle) { public MapillaryImageDialog(@NonNull MapActivity mapActivity, @NonNull Bundle bundle) {
super(mapActivity, CardDialogType.MAPILLARY); super(mapActivity, CardDialogType.MAPILLARY);
restoreFields(bundle); restoreFields(bundle);
this.ic = mapActivity.getMyApplication().getIconsCache(); this.ic = mapActivity.getMyApplication().getUIUtilities();
} }
public MapillaryImageDialog(MapActivity mapActivity, String key, String sKey, String imageUrl, public MapillaryImageDialog(MapActivity mapActivity, String key, String sKey, String imageUrl,
@ -104,7 +104,7 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
this.viewerUrl = viewerUrl; this.viewerUrl = viewerUrl;
this.latLon = latLon; this.latLon = latLon;
this.ca = ca; this.ca = ca;
this.ic = mapActivity.getMyApplication().getIconsCache(); this.ic = mapActivity.getMyApplication().getUIUtilities();
this.sync = sync; this.sync = sync;
} }
@ -204,7 +204,7 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
@Override @Override
protected void createMenuItems(Menu menu) { protected void createMenuItems(Menu menu) {
MenuItem item = menu.add(R.string.open_mapillary) MenuItem item = menu.add(R.string.open_mapillary)
.setIcon(getMapActivity().getMyApplication().getIconsCache().getThemedIcon( .setIcon(getMapActivity().getMyApplication().getUIUtilities().getThemedIcon(
R.drawable.ic_action_mapillary)); R.drawable.ic_action_mapillary));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override @Override

View file

@ -47,7 +47,6 @@ import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
@ -58,6 +57,7 @@ import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.MapViewTrackingUtilities; import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.dashboard.DashLocationFragment; import net.osmand.plus.dashboard.DashLocationFragment;
@ -99,6 +99,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
private boolean locationUpdateStarted; private boolean locationUpdateStarted;
private boolean compassUpdateAllowed = true; private boolean compassUpdateAllowed = true;
public void setListener(OnMapMarkersSavedListener listener) { public void setListener(OnMapMarkersSavedListener listener) {
this.listener = listener; this.listener = listener;
} }
@ -497,7 +498,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
adapter.setScreenOrientation(DashLocationFragment.getScreenOrientation(getActivity()));
startLocationUpdate(); startLocationUpdate();
final View focusedView = getDialog().getCurrentFocus(); final View focusedView = getDialog().getCurrentFocus();
@ -1020,7 +1021,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
} }
private Drawable getColoredIcon(@DrawableRes int resId, @ColorRes int colorResId) { private Drawable getColoredIcon(@DrawableRes int resId, @ColorRes int colorResId) {
return getMyApplication().getIconsCache().getIcon(resId, colorResId); return getMyApplication().getUIUtilities().getIcon(resId, colorResId);
} }
private MapActivity getMapActivity() { private MapActivity getMapActivity() {
@ -1065,15 +1066,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
mapActivity.getMyApplication().runInUIThread(new Runnable() { mapActivity.getMyApplication().runInUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
if (location == null) {
location = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
}
MapViewTrackingUtilities utilities = mapActivity.getMapViewTrackingUtilities();
boolean useCenter = !(utilities.isMapLinkedToLocation() && location != null);
adapter.setUseCenter(useCenter);
adapter.setLocation(useCenter ? mapActivity.getMapLocation() : new LatLon(location.getLatitude(), location.getLongitude()));
adapter.setHeading(useCenter ? -mapActivity.getMapRotate() : heading != null ? heading : 99);
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
}); });

View file

@ -36,11 +36,11 @@ public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment {
private Float heading; private Float heading;
private boolean useCenter; private boolean useCenter;
private boolean nightMode; private boolean nightMode;
private int screenOrientation;
private boolean target; private boolean target;
private boolean intermediate; private boolean intermediate;
private OnMarkerSelectListener onClickListener; private OnMarkerSelectListener onClickListener;
private int screenOrientation;
@Nullable @Nullable
@Override @Override
@ -63,7 +63,7 @@ public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment {
MapRouteInfoMenu routeInfoMenu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu(); MapRouteInfoMenu routeInfoMenu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu();
onClickListener = routeInfoMenu.getOnMarkerSelectListener(); onClickListener = routeInfoMenu.getOnMarkerSelectListener();
screenOrientation = DashLocationFragment.getScreenOrientation(mapActivity); screenOrientation = app.getUIUtilities().getScreenOrientation();
MapViewTrackingUtilities trackingUtils = mapActivity.getMapViewTrackingUtilities(); MapViewTrackingUtilities trackingUtils = mapActivity.getMapViewTrackingUtilities();
if (trackingUtils != null) { if (trackingUtils != null) {
@ -84,7 +84,7 @@ public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment {
View view = inflater.inflate(R.layout.map_marker_selection_fragment, container, false); View view = inflater.inflate(R.layout.map_marker_selection_fragment, container, false);
ImageButton closeButton = (ImageButton) view.findViewById(R.id.closeButton); ImageButton closeButton = (ImageButton) view.findViewById(R.id.closeButton);
closeButton.setImageDrawable(getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_mode_back)); closeButton.setImageDrawable(getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_mode_back));
closeButton.setOnClickListener(new View.OnClickListener() { closeButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {

View file

@ -147,7 +147,6 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
adapter.setScreenOrientation(DashLocationFragment.getScreenOrientation(getActivity()));
startLocationUpdate(); startLocationUpdate();
} }
@ -220,12 +219,6 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL
if (location == null) { if (location == null) {
location = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation(); location = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
} }
MapViewTrackingUtilities utilities = mapActivity.getMapViewTrackingUtilities();
boolean useCenter = !(utilities.isMapLinkedToLocation() && location != null);
adapter.setUseCenter(useCenter);
adapter.setLocation(useCenter ? mapActivity.getMapLocation() : new LatLon(location.getLatitude(), location.getLongitude()));
adapter.setHeading(useCenter ? -mapActivity.getMapRotate() : heading != null ? heading : 99);
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
}); });

View file

@ -147,7 +147,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
View mainView = inflater.inflate(R.layout.fragment_map_markers_dialog, container); View mainView = inflater.inflate(R.layout.fragment_map_markers_dialog, container);
Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.map_markers_toolbar); Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.map_markers_toolbar);
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back)); toolbar.setNavigationIcon(getMyApplication().getUIUtilities().getIcon(R.drawable.ic_arrow_back));
toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up); toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
toolbar.setNavigationOnClickListener(new View.OnClickListener() { toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override @Override

View file

@ -1,5 +1,22 @@
package net.osmand.plus.mapmarkers; package net.osmand.plus.mapmarkers;
import net.osmand.AndroidUtils;
import net.osmand.Location;
import net.osmand.data.Amenity;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapmarkers.SelectionMarkersGroupBottomSheetDialogFragment.AddMarkersGroupFragmentListener;
import net.osmand.plus.mapmarkers.adapters.MapMarkerItemViewHolder;
import net.osmand.plus.mapmarkers.adapters.MapMarkersGroupsAdapter;
import net.osmand.plus.widgets.EmptyStateRecyclerView;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.Canvas; import android.graphics.Canvas;
@ -22,34 +39,11 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import net.osmand.AndroidUtils;
import net.osmand.Location;
import net.osmand.data.Amenity;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.plus.mapmarkers.SelectionMarkersGroupBottomSheetDialogFragment.AddMarkersGroupFragmentListener;
import net.osmand.plus.mapmarkers.adapters.MapMarkerItemViewHolder;
import net.osmand.plus.mapmarkers.adapters.MapMarkersGroupsAdapter;
import net.osmand.plus.widgets.EmptyStateRecyclerView;
import net.osmand.util.MapUtils;
public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassListener, OsmAndLocationListener { public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassListener, OsmAndLocationListener {
public static final String TAG = "MapMarkersGroupsFragment"; public static final String TAG = "MapMarkersGroupsFragment";
private MapMarkersGroupsAdapter adapter; private MapMarkersGroupsAdapter adapter;
private Float heading;
private Location location;
private boolean locationUpdateStarted; private boolean locationUpdateStarted;
private Paint backgroundPaint = new Paint(); private Paint backgroundPaint = new Paint();
private Paint iconPaint = new Paint(); private Paint iconPaint = new Paint();
@ -400,7 +394,6 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
adapter.setScreenOrientation(DashLocationFragment.getScreenOrientation(getActivity()));
startLocationUpdate(); startLocationUpdate();
} }
@ -442,27 +435,12 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
@Override @Override
public void updateLocation(Location location) { public void updateLocation(Location location) {
boolean newLocation = this.location == null && location != null; updateLocationUi();
boolean locationChanged = this.location != null && location != null
&& this.location.getLatitude() != location.getLatitude()
&& this.location.getLongitude() != location.getLongitude();
if (newLocation || locationChanged) {
this.location = location;
updateLocationUi();
}
} }
@Override @Override
public void updateCompassValue(float value) { public void updateCompassValue(float value) {
// 99 in next line used to one-time initialize arrows (with reference vs. fixed-north direction) updateLocationUi();
// on non-compass devices
float lastHeading = heading != null ? heading : 99;
heading = value;
if (Math.abs(MapUtils.degreesDiff(lastHeading, heading)) > 5) {
updateLocationUi();
} else {
heading = lastHeading;
}
} }
private OsmandApplication getMyApplication() { private OsmandApplication getMyApplication() {
@ -481,15 +459,6 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
mapActivity.getMyApplication().runInUIThread(new Runnable() { mapActivity.getMyApplication().runInUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
if (location == null) {
location = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
}
MapViewTrackingUtilities utilities = mapActivity.getMapViewTrackingUtilities();
boolean useCenter = !(utilities.isMapLinkedToLocation() && location != null);
adapter.setUseCenter(useCenter);
adapter.setLocation(useCenter ? mapActivity.getMapLocation() : new LatLon(location.getLatitude(), location.getLongitude()));
adapter.setHeading(useCenter ? -mapActivity.getMapRotate() : heading != null ? heading : 99);
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
}); });

View file

@ -1,5 +1,13 @@
package net.osmand.plus.mapmarkers.adapters; package net.osmand.plus.mapmarkers.adapters;
import java.util.List;
import net.osmand.AndroidUtils;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
import net.osmand.plus.activities.MapActivity;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.support.annotation.ColorInt; import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes; import android.support.annotation.ColorRes;
@ -10,51 +18,25 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import net.osmand.AndroidUtils;
import net.osmand.data.LatLon;
import net.osmand.plus.IconsCache;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashLocationFragment;
import java.util.List;
public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder> { public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder> {
private MapActivity mapActivity; private MapActivity mapActivity;
private IconsCache iconsCache; private UiUtilities iconsCache;
private List<MapMarker> mapMarkers; private List<MapMarker> mapMarkers;
private boolean nightTheme; private boolean nightTheme;
private UpdateLocationViewCache updateViewCache;
private LatLon location;
private Float heading;
private boolean useCenter;
private int screenOrientation;
public CoordinateInputAdapter(MapActivity mapActivity, List<MapMarker> mapMarkers) { public CoordinateInputAdapter(MapActivity mapActivity, List<MapMarker> mapMarkers) {
this.mapActivity = mapActivity; this.mapActivity = mapActivity;
iconsCache = mapActivity.getMyApplication().getIconsCache(); iconsCache = mapActivity.getMyApplication().getUIUtilities();
updateViewCache = iconsCache.getUpdateLocationViewCache();
this.mapMarkers = mapMarkers; this.mapMarkers = mapMarkers;
nightTheme = !mapActivity.getMyApplication().getSettings().isLightContent(); nightTheme = !mapActivity.getMyApplication().getSettings().isLightContent();
} }
public void setLocation(LatLon location) {
this.location = location;
}
public void setHeading(Float heading) {
this.heading = heading;
}
public void setUseCenter(boolean useCenter) {
this.useCenter = useCenter;
}
public void setScreenOrientation(int screenOrientation) {
this.screenOrientation = screenOrientation;
}
@Override @Override
public MapMarkerItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public MapMarkerItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
@ -98,11 +80,8 @@ public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemVi
holder.divider.setVisibility((!singleItem && !lastItem) ? View.VISIBLE : View.GONE); holder.divider.setVisibility((!singleItem && !lastItem) ? View.VISIBLE : View.GONE);
holder.title.setText(mapMarker.getName(mapActivity)); holder.title.setText(mapMarker.getName(mapActivity));
mapActivity.getMyApplication().getUIUtilities().updateLocationView(updateViewCache,
DashLocationFragment.updateLocationView(useCenter, location, holder.iconDirection, holder.distance, mapMarker.getLatitude(), mapMarker.getLongitude());
heading, holder.iconDirection, R.drawable.ic_direction_arrow,
holder.distance, new LatLon(mapMarker.getLatitude(), mapMarker.getLongitude()),
screenOrientation, mapActivity.getMyApplication(), true);
} }
@Override @Override

View file

@ -8,7 +8,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;

View file

@ -6,7 +6,7 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -17,11 +17,11 @@ public abstract class GroupsAdapter extends RecyclerView.Adapter<RecyclerView.Vi
private GroupsAdapterListener listener; private GroupsAdapterListener listener;
protected OsmandApplication app; protected OsmandApplication app;
protected IconsCache iconsCache; protected UiUtilities iconsCache;
public GroupsAdapter(Context context) { public GroupsAdapter(Context context) {
this.app = (OsmandApplication) context.getApplicationContext(); this.app = (OsmandApplication) context.getApplicationContext();
this.iconsCache = app.getIconsCache(); this.iconsCache = app.getUIUtilities();
} }
public void setAdapterListener(GroupsAdapterListener listener) { public void setAdapterListener(GroupsAdapterListener listener) {

View file

@ -11,11 +11,12 @@ import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashLocationFragment; import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -35,15 +36,15 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
private Snackbar snackbar; private Snackbar snackbar;
private boolean showDirectionEnabled; private boolean showDirectionEnabled;
private LatLon location;
private Float heading;
private boolean useCenter;
private int screenOrientation;
private boolean night; private boolean night;
private UiUtilities uiUtilities;
private UpdateLocationViewCache updateLocationViewCache;
public MapMarkersActiveAdapter(MapActivity mapActivity) { public MapMarkersActiveAdapter(MapActivity mapActivity) {
setHasStableIds(true); setHasStableIds(true);
this.mapActivity = mapActivity; this.mapActivity = mapActivity;
uiUtilities = mapActivity.getMyApplication().getUIUtilities();
updateLocationViewCache = uiUtilities.getUpdateLocationViewCache();
markers = mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkers(); markers = mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkers();
night = !mapActivity.getMyApplication().getSettings().isLightContent(); night = !mapActivity.getMyApplication().getSettings().isLightContent();
showDirectionEnabled = mapActivity.getMyApplication().getSettings().MARKERS_DISTANCE_INDICATION_ENABLED.get(); showDirectionEnabled = mapActivity.getMyApplication().getSettings().MARKERS_DISTANCE_INDICATION_ENABLED.get();
@ -56,23 +57,6 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
public void setAdapterListener(MapMarkersActiveAdapterListener listener) { public void setAdapterListener(MapMarkersActiveAdapterListener listener) {
this.listener = listener; this.listener = listener;
} }
public void setLocation(LatLon location) {
this.location = location;
}
public void setHeading(Float heading) {
this.heading = heading;
}
public void setUseCenter(boolean useCenter) {
this.useCenter = useCenter;
}
public void setScreenOrientation(int screenOrientation) {
this.screenOrientation = screenOrientation;
}
@Override @Override
public MapMarkerItemViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { public MapMarkerItemViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_new, viewGroup, false); View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_new, viewGroup, false);
@ -87,7 +71,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
@Override @Override
public void onBindViewHolder(final MapMarkerItemViewHolder holder, final int pos) { public void onBindViewHolder(final MapMarkerItemViewHolder holder, final int pos) {
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache(); UiUtilities iconsCache = mapActivity.getMyApplication().getUIUtilities();
MapMarker marker = markers.get(pos); MapMarker marker = markers.get(pos);
ImageView markerImageViewToUpdate; ImageView markerImageViewToUpdate;
@ -193,10 +177,9 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
} }
}); });
DashLocationFragment.updateLocationView(useCenter, location, updateLocationViewCache.arrowResId = drawableResToUpdate;
heading, markerImageViewToUpdate, drawableResToUpdate, updateLocationViewCache.arrowColor = showDirectionEnabled && displayedInWidget ? markerColor : 0;
showDirectionEnabled && displayedInWidget ? markerColor : 0, holder.distance, markerLatLon, uiUtilities.updateLocationView(updateLocationViewCache, markerImageViewToUpdate, holder.distance, markerLatLon);
screenOrientation, mapActivity.getMyApplication(), true);
} }
@Override @Override

View file

@ -10,7 +10,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.ImageView; import android.widget.ImageView;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
@ -18,7 +17,7 @@ import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.GPXUtilities; import net.osmand.plus.GPXUtilities;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.GroupHeader; import net.osmand.plus.MapMarkersHelper.GroupHeader;
import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
@ -26,6 +25,7 @@ import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
import net.osmand.plus.MapMarkersHelper.ShowHideHistoryButton; import net.osmand.plus.MapMarkersHelper.ShowHideHistoryButton;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashLocationFragment; import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.plus.mapmarkers.SelectWptCategoriesBottomSheetDialogFragment; import net.osmand.plus.mapmarkers.SelectWptCategoriesBottomSheetDialogFragment;
@ -60,15 +60,12 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
private OsmandApplication app; private OsmandApplication app;
private List<Object> items = new ArrayList<>(); private List<Object> items = new ArrayList<>();
private boolean night; private boolean night;
private int screenOrientation;
private LatLon location;
private Float heading;
private boolean useCenter;
private boolean showDirectionEnabled; private boolean showDirectionEnabled;
private List<MapMarker> showDirectionMarkers; private List<MapMarker> showDirectionMarkers;
private Snackbar snackbar; private Snackbar snackbar;
private MapMarkersGroupsAdapterListener listener; private MapMarkersGroupsAdapterListener listener;
private UpdateLocationViewCache updateLocationViewCache;
public void setListener(MapMarkersGroupsAdapterListener listener) { public void setListener(MapMarkersGroupsAdapterListener listener) {
this.listener = listener; this.listener = listener;
@ -77,6 +74,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
public MapMarkersGroupsAdapter(MapActivity mapActivity) { public MapMarkersGroupsAdapter(MapActivity mapActivity) {
this.mapActivity = mapActivity; this.mapActivity = mapActivity;
app = mapActivity.getMyApplication(); app = mapActivity.getMyApplication();
updateLocationViewCache = app.getUIUtilities().getUpdateLocationViewCache();
night = !mapActivity.getMyApplication().getSettings().isLightContent(); night = !mapActivity.getMyApplication().getSettings().isLightContent();
updateShowDirectionMarkers(); updateShowDirectionMarkers();
createDisplayGroups(); createDisplayGroups();
@ -225,22 +223,6 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
return pos; return pos;
} }
public void setLocation(LatLon location) {
this.location = location;
}
public void setHeading(Float heading) {
this.heading = heading;
}
public void setUseCenter(boolean useCenter) {
this.useCenter = useCenter;
}
public void setScreenOrientation(int screenOrientation) {
this.screenOrientation = screenOrientation;
}
public void updateDisplayedData() { public void updateDisplayedData() {
createDisplayGroups(); createDisplayGroups();
updateShowDirectionMarkers(); updateShowDirectionMarkers();
@ -274,7 +256,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
@Override @Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) { public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
IconsCache iconsCache = app.getIconsCache(); UiUtilities iconsCache = app.getUIUtilities();
if (holder instanceof MapMarkerItemViewHolder) { if (holder instanceof MapMarkerItemViewHolder) {
final MapMarkerItemViewHolder itemViewHolder = (MapMarkerItemViewHolder) holder; final MapMarkerItemViewHolder itemViewHolder = (MapMarkerItemViewHolder) holder;
final MapMarker marker = (MapMarker) getItem(position); final MapMarker marker = (MapMarker) getItem(position);
@ -392,10 +374,9 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
itemViewHolder.bottomShadow.setVisibility(lastItem ? View.VISIBLE : View.GONE); itemViewHolder.bottomShadow.setVisibility(lastItem ? View.VISIBLE : View.GONE);
LatLon markerLatLon = new LatLon(marker.getLatitude(), marker.getLongitude()); LatLon markerLatLon = new LatLon(marker.getLatitude(), marker.getLongitude());
DashLocationFragment.updateLocationView(useCenter, location, updateLocationViewCache.arrowResId = drawableResToUpdate;
heading, markerImageViewToUpdate, drawableResToUpdate, markerToHighlight ? color : 0, updateLocationViewCache.arrowColor = markerToHighlight ? color : 0;
itemViewHolder.distance, markerLatLon, app.getUIUtilities().updateLocationView(updateLocationViewCache, markerImageViewToUpdate, itemViewHolder.distance, markerLatLon);
screenOrientation, app, true);
} else if (holder instanceof MapMarkerHeaderViewHolder) { } else if (holder instanceof MapMarkerHeaderViewHolder) {
final MapMarkerHeaderViewHolder headerViewHolder = (MapMarkerHeaderViewHolder) holder; final MapMarkerHeaderViewHolder headerViewHolder = (MapMarkerHeaderViewHolder) holder;
final Object header = getItem(position); final Object header = getItem(position);
@ -575,7 +556,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
categoriesViewHolder.title.setText(getGroupWptCategoriesString(group)); categoriesViewHolder.title.setText(getGroupWptCategoriesString(group));
categoriesViewHolder.divider.setVisibility(View.VISIBLE); categoriesViewHolder.divider.setVisibility(View.VISIBLE);
categoriesViewHolder.button.setCompoundDrawablesWithIntrinsicBounds( categoriesViewHolder.button.setCompoundDrawablesWithIntrinsicBounds(
null, null, app.getIconsCache().getIcon(R.drawable.ic_action_filter, null, null, app.getUIUtilities().getIcon(R.drawable.ic_action_filter,
night ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light), null); night ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light), null);
categoriesViewHolder.button.setOnClickListener(openChooseCategoriesDialog); categoriesViewHolder.button.setOnClickListener(openChooseCategoriesDialog);
categoriesViewHolder.title.setOnClickListener(openChooseCategoriesDialog); categoriesViewHolder.title.setOnClickListener(openChooseCategoriesDialog);

View file

@ -8,7 +8,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -111,7 +111,7 @@ public class MapMarkersHistoryAdapter extends RecyclerView.Adapter<RecyclerView.
@Override @Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
IconsCache iconsCache = app.getIconsCache(); UiUtilities iconsCache = app.getUIUtilities();
if (holder instanceof MapMarkerItemViewHolder) { if (holder instanceof MapMarkerItemViewHolder) {
final MapMarkerItemViewHolder itemViewHolder = (MapMarkerItemViewHolder) holder; final MapMarkerItemViewHolder itemViewHolder = (MapMarkerItemViewHolder) holder;
final MapMarker marker = (MapMarker) getItem(position); final MapMarker marker = (MapMarker) getItem(position);

View file

@ -16,7 +16,7 @@ import net.osmand.data.PointDescription;
import net.osmand.plus.GPXUtilities.WptPt; import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.GeocodingLookupService.AddressLookupRequest; import net.osmand.plus.GeocodingLookupService.AddressLookupRequest;
import net.osmand.plus.GeocodingLookupService.OnAddressLookupResult; import net.osmand.plus.GeocodingLookupService.OnAddressLookupResult;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
@ -89,7 +89,7 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
public void onBindViewHolder(final MapMarkerItemViewHolder holder, int pos) { public void onBindViewHolder(final MapMarkerItemViewHolder holder, int pos) {
OsmandApplication app = mapActivity.getMyApplication(); OsmandApplication app = mapActivity.getMyApplication();
boolean night = app.getDaynightHelper().isNightModeForMapControls(); boolean night = app.getDaynightHelper().isNightModeForMapControls();
IconsCache iconsCache = app.getIconsCache(); UiUtilities iconsCache = app.getUIUtilities();
boolean locationItem = showLocationItem && pos == 0; boolean locationItem = showLocationItem && pos == 0;
boolean firstMarkerItem = showLocationItem ? pos == 1 : pos == 0; boolean firstMarkerItem = showLocationItem ? pos == 1 : pos == 0;

View file

@ -141,7 +141,7 @@ public class SnapToRoadBottomSheetDialogFragment extends android.support.design.
} }
private Drawable getContentIcon(@DrawableRes int id) { private Drawable getContentIcon(@DrawableRes int id) {
return getMyApplication().getIconsCache() return getMyApplication().getUIUtilities()
.getIcon(id, nightMode ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color); .getIcon(id, nightMode ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color);
} }

View file

@ -13,7 +13,7 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.plus.GPXUtilities.WptPt; import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
@ -57,7 +57,7 @@ public class MeasurementToolAdapter extends RecyclerView.Adapter<MeasurementTool
@Override @Override
public void onBindViewHolder(final MeasureToolItemVH holder, int pos) { public void onBindViewHolder(final MeasureToolItemVH holder, int pos) {
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache(); UiUtilities iconsCache = mapActivity.getMyApplication().getUIUtilities();
holder.iconReorder.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_reorder)); holder.iconReorder.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_reorder));
holder.iconReorder.setOnTouchListener(new View.OnTouchListener() { holder.iconReorder.setOnTouchListener(new View.OnTouchListener() {
@Override @Override

View file

@ -200,10 +200,10 @@ public class DashTrackFragment extends DashBaseFragment {
final boolean isRecording = app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get(); final boolean isRecording = app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get();
ImageButton stop = ((ImageButton) v.findViewById(R.id.stop)); ImageButton stop = ((ImageButton) v.findViewById(R.id.stop));
if (isRecording) { if (isRecording) {
stop.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_rec_stop)); stop.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_rec_stop));
stop.setContentDescription(app.getString(R.string.gpx_monitoring_stop)); stop.setContentDescription(app.getString(R.string.gpx_monitoring_stop));
} else { } else {
stop.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_rec_start)); stop.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_rec_start));
stop.setContentDescription(app.getString(R.string.gpx_monitoring_start)); stop.setContentDescription(app.getString(R.string.gpx_monitoring_start));
} }
stop.setOnClickListener(new View.OnClickListener() { stop.setOnClickListener(new View.OnClickListener() {
@ -230,7 +230,7 @@ public class DashTrackFragment extends DashBaseFragment {
} else { } else {
save.setVisibility(View.GONE); save.setVisibility(View.GONE);
} }
save.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_gsave_dark)); save.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_gsave_dark));
save.setContentDescription(app.getString(R.string.save_current_track)); save.setContentDescription(app.getString(R.string.save_current_track));
((TextView) v.findViewById(R.id.points_count)).setText(String.valueOf(sth.getPoints())); ((TextView) v.findViewById(R.id.points_count)).setText(String.valueOf(sth.getPoints()));
@ -239,17 +239,17 @@ public class DashTrackFragment extends DashBaseFragment {
v.findViewById(R.id.points_icon).setVisibility(View.VISIBLE); v.findViewById(R.id.points_icon).setVisibility(View.VISIBLE);
ImageView distance = (ImageView) v.findViewById(R.id.distance_icon); ImageView distance = (ImageView) v.findViewById(R.id.distance_icon);
distance.setVisibility(View.VISIBLE); distance.setVisibility(View.VISIBLE);
distance.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_small_distance)); distance.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_small_distance));
ImageView pointsCount = (ImageView) v.findViewById(R.id.points_icon); ImageView pointsCount = (ImageView) v.findViewById(R.id.points_icon);
pointsCount.setVisibility(View.VISIBLE); pointsCount.setVisibility(View.VISIBLE);
pointsCount.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_small_point)); pointsCount.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_small_point));
} }
private void updateShowOnMap(final OsmandApplication app, final File f, final View pView, final ImageButton showOnMap) { private void updateShowOnMap(final OsmandApplication app, final File f, final View pView, final ImageButton showOnMap) {
final GpxSelectionHelper selectedGpxHelper = app.getSelectedGpxHelper(); final GpxSelectionHelper selectedGpxHelper = app.getSelectedGpxHelper();
final SelectedGpxFile selected = selectedGpxHelper.getSelectedFileByPath(f.getAbsolutePath()); final SelectedGpxFile selected = selectedGpxHelper.getSelectedFileByPath(f.getAbsolutePath());
if(selected != null) { if(selected != null) {
showOnMap.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_show_on_map, R.color.color_distance)); showOnMap.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_show_on_map, R.color.color_distance));
showOnMap.setOnClickListener(new View.OnClickListener() { showOnMap.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -262,7 +262,7 @@ public class DashTrackFragment extends DashBaseFragment {
} }
}); });
} else { } else {
showOnMap.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_show_on_map)); showOnMap.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_show_on_map));
showOnMap.setOnClickListener(new View.OnClickListener() { showOnMap.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {

View file

@ -60,7 +60,7 @@ import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
@ -222,7 +222,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
final boolean isRecording = app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get(); final boolean isRecording = app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get();
ImageView icon = (ImageView) currentGpxView.findViewById(R.id.icon); ImageView icon = (ImageView) currentGpxView.findViewById(R.id.icon);
icon.setImageDrawable(app.getIconsCache().getIcon(R.drawable.monitoring_rec_big)); icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.monitoring_rec_big));
icon.setVisibility(selectionMode && showOnMapMode ? View.GONE : View.VISIBLE); icon.setVisibility(selectionMode && showOnMapMode ? View.GONE : View.VISIBLE);
final boolean light = app.getSettings().isLightContent(); final boolean light = app.getSettings().isLightContent();
@ -234,14 +234,14 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
TextView segmentTime = (TextView) currentGpxView.findViewById(R.id.segment_time); TextView segmentTime = (TextView) currentGpxView.findViewById(R.id.segment_time);
segmentTime.setText(OsmAndFormatter.getFormattedDurationShort((int)(sth.getDuration() / 1000))); segmentTime.setText(OsmAndFormatter.getFormattedDurationShort((int)(sth.getDuration() / 1000)));
segmentTime.setVisibility(View.VISIBLE); segmentTime.setVisibility(View.VISIBLE);
stop.setCompoundDrawablesWithIntrinsicBounds(app.getIconsCache() stop.setCompoundDrawablesWithIntrinsicBounds(app.getUIUtilities()
.getIcon(R.drawable.ic_action_rec_stop, light ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark), null, null, null); .getIcon(R.drawable.ic_action_rec_stop, light ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark), null, null, null);
stop.setText(app.getString(R.string.shared_string_control_stop)); stop.setText(app.getString(R.string.shared_string_control_stop));
stop.setContentDescription(app.getString(R.string.gpx_monitoring_stop)); stop.setContentDescription(app.getString(R.string.gpx_monitoring_stop));
} else { } else {
currentGpxView.findViewById(R.id.segment_time_div).setVisibility(View.GONE); currentGpxView.findViewById(R.id.segment_time_div).setVisibility(View.GONE);
currentGpxView.findViewById(R.id.segment_time).setVisibility(View.GONE); currentGpxView.findViewById(R.id.segment_time).setVisibility(View.GONE);
stop.setCompoundDrawablesWithIntrinsicBounds(app.getIconsCache() stop.setCompoundDrawablesWithIntrinsicBounds(app.getUIUtilities()
.getIcon(R.drawable.ic_action_rec_start, light ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark), null, null, null); .getIcon(R.drawable.ic_action_rec_start, light ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark), null, null, null);
stop.setText(app.getString(R.string.shared_string_record)); stop.setText(app.getString(R.string.shared_string_record));
stop.setContentDescription(app.getString(R.string.gpx_monitoring_start)); stop.setContentDescription(app.getString(R.string.gpx_monitoring_start));
@ -259,7 +259,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
} }
}); });
Button save = (Button) currentGpxView.findViewById(R.id.save_button); Button save = (Button) currentGpxView.findViewById(R.id.save_button);
save.setCompoundDrawablesWithIntrinsicBounds(app.getIconsCache() save.setCompoundDrawablesWithIntrinsicBounds(app.getUIUtilities()
.getIcon(R.drawable.ic_action_gsave_dark, light ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark), null, null, null); .getIcon(R.drawable.ic_action_gsave_dark, light ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark), null, null, null);
save.setOnClickListener(new View.OnClickListener() { save.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -379,9 +379,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
public void createCurrentTrackView() { public void createCurrentTrackView() {
ImageView distanceI = (ImageView) currentGpxView.findViewById(R.id.distance_icon); ImageView distanceI = (ImageView) currentGpxView.findViewById(R.id.distance_icon);
distanceI.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_small_distance)); distanceI.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_small_distance));
ImageView pointsI = (ImageView) currentGpxView.findViewById(R.id.points_icon); ImageView pointsI = (ImageView) currentGpxView.findViewById(R.id.points_icon);
pointsI.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_small_point)); pointsI.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_small_point));
updateCurrentTrack(); updateCurrentTrack();
} }
@ -1069,7 +1069,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
ImageView icon = (ImageView) v.findViewById(R.id.icon); ImageView icon = (ImageView) v.findViewById(R.id.icon);
ImageButton options = (ImageButton) v.findViewById(R.id.options); ImageButton options = (ImageButton) v.findViewById(R.id.options);
options.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_overflow_menu_white)); options.setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_overflow_menu_white));
options.setOnClickListener(new View.OnClickListener() { options.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -1176,7 +1176,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
final CheckBox ch = (CheckBox) v.findViewById(R.id.toggle_item); final CheckBox ch = (CheckBox) v.findViewById(R.id.toggle_item);
ch.setVisibility(View.GONE); ch.setVisibility(View.GONE);
if (isSelectedGroup(groupPosition)) { if (isSelectedGroup(groupPosition)) {
setCategoryIcon(app, app.getIconsCache().getIcon(R.drawable.ic_map, R.color.osmand_orange), groupPosition, isExpanded, v, light); setCategoryIcon(app, app.getUIUtilities().getIcon(R.drawable.ic_map, R.color.osmand_orange), groupPosition, isExpanded, v, light);
} else { } else {
setCategoryIcon(app, 0, groupPosition, isExpanded, v, light); setCategoryIcon(app, 0, groupPosition, isExpanded, v, light);
} }
@ -1353,7 +1353,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
} }
private void openPopUpMenu(View v, final GpxInfo gpxInfo) { private void openPopUpMenu(View v, final GpxInfo gpxInfo) {
IconsCache iconsCache = getMyApplication().getIconsCache(); UiUtilities iconsCache = getMyApplication().getUIUtilities();
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v); final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
DirectionsDialogs.setupPopUpMenuIcon(optionsMenu); DirectionsDialogs.setupPopUpMenuIcon(optionsMenu);
@ -1790,14 +1790,14 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
// ImageView icon = (ImageView) v.findViewById(!isDashItem? R.id.icon : R.id.show_on_map); // ImageView icon = (ImageView) v.findViewById(!isDashItem? R.id.icon : R.id.show_on_map);
ImageView icon = (ImageView) v.findViewById(R.id.icon); ImageView icon = (ImageView) v.findViewById(R.id.icon);
icon.setVisibility(View.VISIBLE); icon.setVisibility(View.VISIBLE);
icon.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_polygom_dark)); icon.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_polygom_dark));
if (child.isCorrupted()) { if (child.isCorrupted()) {
viewName.setTypeface(Typeface.DEFAULT, Typeface.ITALIC); viewName.setTypeface(Typeface.DEFAULT, Typeface.ITALIC);
} else { } else {
viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL); viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
} }
if (getSelectedGpxFile(child, app) != null) { if (getSelectedGpxFile(child, app) != null) {
icon.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_polygom_dark, R.color.color_distance)); icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_polygom_dark, R.color.color_distance));
} }
GPXTrackAnalysis analysis = getGpxTrackAnalysis(child, app); GPXTrackAnalysis analysis = getGpxTrackAnalysis(child, app);
boolean sectionRead = analysis == null; boolean sectionRead = analysis == null;
@ -1826,13 +1826,13 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
v.findViewById(R.id.unknown_section).setVisibility(View.GONE); v.findViewById(R.id.unknown_section).setVisibility(View.GONE);
ImageView distanceI = (ImageView) v.findViewById(R.id.distance_icon); ImageView distanceI = (ImageView) v.findViewById(R.id.distance_icon);
distanceI.setVisibility(View.VISIBLE); distanceI.setVisibility(View.VISIBLE);
distanceI.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_small_distance)); distanceI.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_small_distance));
ImageView pointsI = (ImageView) v.findViewById(R.id.points_icon); ImageView pointsI = (ImageView) v.findViewById(R.id.points_icon);
pointsI.setVisibility(View.VISIBLE); pointsI.setVisibility(View.VISIBLE);
pointsI.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_small_point)); pointsI.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_small_point));
ImageView timeI = (ImageView) v.findViewById(R.id.time_icon); ImageView timeI = (ImageView) v.findViewById(R.id.time_icon);
timeI.setVisibility(View.VISIBLE); timeI.setVisibility(View.VISIBLE);
timeI.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_small_time)); timeI.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_small_time));
TextView time = (TextView) v.findViewById(R.id.time); TextView time = (TextView) v.findViewById(R.id.time);
TextView distance = (TextView) v.findViewById(R.id.distance); TextView distance = (TextView) v.findViewById(R.id.distance);
TextView pointsCount = (TextView) v.findViewById(R.id.points_count); TextView pointsCount = (TextView) v.findViewById(R.id.points_count);

View file

@ -181,7 +181,7 @@ public class EditTrackGroupDialogFragment extends MenuBottomSheetDialogFragment
if (color == 0) { if (color == 0) {
colorImageView.setImageDrawable(getContentIcon(R.drawable.ic_action_circle)); colorImageView.setImageDrawable(getContentIcon(R.drawable.ic_action_circle));
} else { } else {
colorImageView.setImageDrawable(getMyApplication().getIconsCache().getPaintedIcon(R.drawable.ic_action_circle, color)); colorImageView.setImageDrawable(getMyApplication().getUIUtilities().getPaintedIcon(R.drawable.ic_action_circle, color));
} }
} }

View file

@ -32,7 +32,7 @@ import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
import net.osmand.plus.IconsCache; import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
@ -62,7 +62,7 @@ public class SplitSegmentDialogFragment extends DialogFragment {
private List<Double> distanceSplit = new ArrayList<>(); private List<Double> distanceSplit = new ArrayList<>();
private TIntArrayList timeSplit = new TIntArrayList(); private TIntArrayList timeSplit = new TIntArrayList();
private int selectedSplitInterval; private int selectedSplitInterval;
private IconsCache ic; private UiUtilities ic;
private int minMaxSpeedLayoutWidth; private int minMaxSpeedLayoutWidth;
private Paint minMaxSpeedPaint; private Paint minMaxSpeedPaint;
private Rect minMaxSpeedTextBounds; private Rect minMaxSpeedTextBounds;
@ -73,7 +73,7 @@ public class SplitSegmentDialogFragment extends DialogFragment {
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
app = getMyApplication(); app = getMyApplication();
ic = app.getIconsCache(); ic = app.getUIUtilities();
boolean isLightTheme = app.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME; boolean isLightTheme = app.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
int themeId = isLightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme; int themeId = isLightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
setStyle(STYLE_NO_FRAME, themeId); setStyle(STYLE_NO_FRAME, themeId);
@ -109,7 +109,7 @@ public class SplitSegmentDialogFragment extends DialogFragment {
if (trackActivityActionBar != null) { if (trackActivityActionBar != null) {
titleTextView.setText(trackActivityActionBar.getTitle()); titleTextView.setText(trackActivityActionBar.getTitle());
} }
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back)); toolbar.setNavigationIcon(getMyApplication().getUIUtilities().getIcon(R.drawable.ic_arrow_back));
toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up); toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
toolbar.setNavigationOnClickListener(new View.OnClickListener() { toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override @Override
@ -254,7 +254,7 @@ public class SplitSegmentDialogFragment extends DialogFragment {
int color = app.getResources().getColor(colorId); int color = app.getResources().getColor(colorId);
title.setTextColor(color); title.setTextColor(color);
text.setTextColor(color); text.setTextColor(color);
img.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_arrow_drop_down, colorId)); img.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_arrow_drop_down, colorId));
} }
private void updateSplitIntervalView(View view) { private void updateSplitIntervalView(View view) {

Some files were not shown because too many files have changed in this diff Show more