Fix small issues

This commit is contained in:
Victor Shcherb 2014-06-08 12:53:07 +02:00
parent 8896c1b397
commit aba4a57d27
9 changed files with 308 additions and 123 deletions

View file

@ -9,13 +9,14 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="gpx_selection_number_of_points">%1$s points</string>
<string name="gpx_selection_number_of_points"> %1$s points</string>
<string name="gpx_selection_current_track">recording</string>
<string name="gpx_selection_route_points">Gpx %1$s - Route points %2$s</string>
<string name="gpx_selection_points">Gpx %1$s - Points</string>
<string name="gpx_selection_track">Gpx %1$s - Track %2$s</string>
<string name="gpx_available_current_track">Current recording track</string>
<string name="gpx_file_is_empty">Gpx track is empty</string>
<string name="selected_track">Track</string>
<string name="selected_track">Selected tracks</string>
<string name="my_tracks">All tracks</string>
<string name="my_favorites">My Favorites</string>
<string name="my_data_Button">My Data</string>

View file

@ -8,7 +8,6 @@ import net.osmand.plus.GPXUtilities.Route;
import net.osmand.plus.GPXUtilities.Track;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.activities.SavingTrackHelper;
import android.content.Context;
import android.graphics.Bitmap;
public class GpxSelectionHelper {
@ -85,7 +84,7 @@ public class GpxSelectionHelper {
for (Route r : g.routes) {
GpxDisplayGroup group = new GpxDisplayGroup(g);
group.setType(GpxDisplayItemType.TRACK_ROUTE_POINTS);
String d = getString(R.string.gpx_selection_number_of_points, r.points.size());
String d = getString(R.string.gpx_selection_number_of_points, name, r.points.size());
if(r.name != null && r.name.length() > 0) {
d = r.name + " " + d;
}
@ -100,7 +99,7 @@ public class GpxSelectionHelper {
GpxDisplayGroup group = new GpxDisplayGroup(g);
group.setType(GpxDisplayItemType.TRACK_POINTS);
group.setDescription(getString(R.string.gpx_selection_number_of_points, g.points.size()));
group.setName(getString(R.string.gpx_selection_points));
group.setName(getString(R.string.gpx_selection_points, name));
dg.add(group);
List<GpxDisplayItem> list = group.getModifiableList();
for (WptPt r : g.points) {
@ -123,6 +122,24 @@ public class GpxSelectionHelper {
return null;
}
public SelectedGpxFile getSelectedFileByName(String path) {
for (SelectedGpxFile s : selectedGPXFiles) {
if (s.getGpxFile().path.endsWith("/" + path)) {
return s;
}
}
return null;
}
public SelectedGpxFile getSelectedCurrentRecordingTrack() {
for (SelectedGpxFile s : selectedGPXFiles) {
if (s.isShowCurrentTrack()) {
return s;
}
}
return null;
}
public void setGpxFileToDisplay(GPXFile... gpxs) {
// special case for gpx current route
for(GPXFile gpx : gpxs) {
@ -266,7 +283,7 @@ public class GpxSelectionHelper {
}
public String getGroupName(Context ctx) {
public String getGroupName() {
return name;
}
}

View file

@ -5,18 +5,22 @@ import java.text.Collator;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import net.osmand.IndexConstants;
import net.osmand.access.AccessibleToast;
import net.osmand.data.LatLon;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
@ -72,76 +76,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
private LoadLocalIndexDescriptionTask descriptionLoader;
private ContextMenuAdapter optionsMenuAdapter;
private AsyncTask<GpxInfo, ?, ?> operationTask;
private GpxSelectionHelper selectedGpxHelper;
private SavingTrackHelper savingTrackHelper;
public static class GpxInfo {
public GPXFile gpx;
public File file;
public String subfolder;
private String name = null;
private int sz = -1;
private String description;
private boolean corrupted;
private boolean expanded;
public String getName() {
if(name == null) {
name = formatName(file.getName());
}
return name;
}
private String formatName(String name) {
int ext = name.indexOf('.');
if (ext != -1) {
name = name.substring(0, ext);
}
return name.replace('_', ' ');
}
public boolean isCorrupted() {
return corrupted;
}
public int getSize() {
if(sz == -1) {
sz = (int) (file.length() >> 10);
}
return sz;
}
public boolean isExpanded() {
return expanded;
}
public void setExpanded(boolean expanded) {
this.expanded = expanded;
}
public CharSequence getDescription() {
if(description == null) {
return "";
}
return description;
}
public void updateGpxInfo(OsmandApplication app ) {
if(gpx == null){
gpx = GPXUtilities.loadGPXFile(app, file);
}
if(gpx.warning != null){
corrupted = true;
description = gpx.warning;
} else {
// 'Long-press for options' message
description = GpxUiHelper.getDescription(app, gpx, file) +
app.getString(R.string.local_index_gpx_info_show);
}
}
public String getFileName() {
return file.getName();
}
}
@Override
public void onAttach(Activity activity) {
@ -149,6 +86,8 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
final Collator collator = Collator.getInstance();
collator.setStrength(Collator.SECONDARY);
asyncLoader = new LoadGpxTask();
selectedGpxHelper = ((OsmandApplication) activity.getApplication()).getSelectedGpxHelper();
savingTrackHelper = ((OsmandApplication) activity.getApplication()).getSavingTrackHelper();
listAdapter = new GpxIndexesAdapter(getActivity());
setAdapter(listAdapter);
}
@ -224,6 +163,8 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
if (itemId == R.string.local_index_mi_reload) {
asyncLoader = new LoadGpxTask();
asyncLoader.execute(getActivity());
} else if (itemId == R.string.show_gpx_route) {
openShowOnMapMode();
} else if (itemId == R.string.local_index_mi_delete) {
openSelectionMode(itemId, R.drawable.ic_action_delete_dark, R.drawable.ic_action_delete_light,
new DialogInterface.OnClickListener() {
@ -236,6 +177,8 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
}
};
optionsMenuAdapter.item(R.string.show_gpx_route)
.icons(R.drawable.ic_action_map_marker_dark, R.drawable.ic_action_map_marker_light).listen(listener).reg();
optionsMenuAdapter.item(R.string.local_index_mi_delete)
.icons(R.drawable.ic_action_delete_dark, R.drawable.ic_action_delete_light).listen(listener).reg();
optionsMenuAdapter.item(R.string.local_index_mi_reload)
@ -256,12 +199,10 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
public void doAction(int actionResId){
if(actionResId == R.string.local_index_mi_delete){
operationTask = new DeleteGpxTask();
operationTask.execute(selectedItems.toArray(new GpxInfo[selectedItems.size()]));
} else {
operationTask = null;
}
if(operationTask != null){
operationTask.execute(selectedItems.toArray(new GpxInfo[selectedItems.size()]));
}
if(actionMode != null) {
actionMode.finish();
}
@ -287,13 +228,60 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
getSherlockActivity().setSupportProgressBarIndeterminateVisibility(false);
}
public void openSelectionMode(int stringRes, int darkIcon, int lightIcon, DialogInterface.OnClickListener listener) {
openSelectionMode(stringRes, !isLightActionBar() ? darkIcon : lightIcon, listener);
private void openShowOnMapMode(){
selectionMode = true;
selectedItems.clear();
final Set<GpxInfo> originalSelectedItems = listAdapter.getSelectedGpx();
selectedItems.addAll(originalSelectedItems);
actionMode = getSherlockActivity().startActionMode(new Callback() {
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
selectionMode = true;
MenuItem it = menu.add(R.string.show_gpx_route);
it.setIcon(!isLightActionBar() ? R.drawable.ic_action_map_marker_dark : R.drawable.ic_action_map_marker_light);
it.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM |
MenuItem.SHOW_AS_ACTION_WITH_TEXT);
return true;
}
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
return false;
}
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
if (selectedItems.isEmpty()) {
return true;
}
runSelection(true);
return true;
}
private void runSelection(boolean showOnMap) {
operationTask = new SelectGpxTask(showOnMap);
originalSelectedItems.addAll(selectedItems);
operationTask.execute(originalSelectedItems.toArray(new GpxInfo[originalSelectedItems.size()]));
}
@Override
public void onDestroyActionMode(ActionMode mode) {
selectionMode = false;
getView().findViewById(R.id.DescriptionText).setVisibility(View.GONE);
runSelection(false);
listAdapter.notifyDataSetChanged();
}
});
listAdapter.notifyDataSetChanged();
}
private void openSelectionMode(final int actionResId, final int actionIconId,
public void openSelectionMode(final int actionResId, int darkIcon, int lightIcon,
final DialogInterface.OnClickListener listener){
final int actionIconId = !isLightActionBar() ? darkIcon : lightIcon;
String value = getString(actionResId);
if (value.endsWith("...")) {
value = value.substring(0, value.length() - 3);
@ -434,9 +422,11 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
};
adapter.item(R.string.show_gpx_route).listen(listener).reg();
adapter.item(R.string.local_index_mi_rename).listen(listener).reg();
adapter.item(R.string.local_index_mi_delete).listen(listener).reg();
adapter.item(R.string.local_index_mi_export).listen(listener).reg();
if (info.file != null) {
adapter.item(R.string.local_index_mi_rename).listen(listener).reg();
adapter.item(R.string.local_index_mi_delete).listen(listener).reg();
adapter.item(R.string.local_index_mi_export).listen(listener).reg();
}
OsmandPlugin.onContextMenuActivity(getSherlockActivity(), this, info, adapter);
}
@ -467,6 +457,10 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
protected List<GpxInfo> doInBackground(Activity... params) {
List<GpxInfo> result = new ArrayList<GpxInfo>();
if(savingTrackHelper.getCurrentGpx().isEmpty()) {
loadFile(new GpxInfo(savingTrackHelper.getCurrentGpx(),
getMyApplication().getString(R.string.gpx_available_current_track)));
}
loadGPXData(getMyApplication().getAppPath(IndexConstants.GPX_INDEX_DIR), result, this);
return result;
}
@ -575,6 +569,26 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
ta.recycle();
}
public Set<GpxInfo> getSelectedGpx() {
Set<GpxInfo> originalSelectedItems = new HashSet<GpxInfo>();
for (List<GpxInfo> l : data.values()) {
if (l != null) {
for (GpxInfo g : l) {
boolean add = false;
if (g.gpx != null && g.gpx.showCurrentTrack) {
add = selectedGpxHelper.getSelectedCurrentRecordingTrack() != null;
} else {
add = selectedGpxHelper.getSelectedFileByName(g.getFileName()) != null;
}
if (add) {
originalSelectedItems.add(g);
}
}
}
}
return originalSelectedItems;
}
public void clear() {
data.clear();
category.clear();
@ -582,18 +596,24 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
public void addLocalIndexInfo(GpxInfo info) {
String catName;
if(info.gpx != null && info.gpx.showCurrentTrack) {
catName = info.name;
} else {
catName = info.subfolder;
}
int found = -1;
// search from end
for (int i = category.size() - 1; i >= 0; i--) {
String cat = category.get(i);
if (Algorithms.objectEquals(info.subfolder, cat)) {
if (Algorithms.objectEquals(catName, cat)) {
found = i;
break;
}
}
if (found == -1) {
found = category.size();
category.add(info.subfolder);
category.add(catName);
}
if (!data.containsKey(category.get(found))) {
data.put(category.get(found), new ArrayList<GpxInfo>());
@ -623,9 +643,13 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
TextView viewName = ((TextView) v.findViewById(R.id.local_index_name));
viewName.setText(child.getName());
if (child.isCorrupted()) {
viewName.setTextColor(corruptedColor);
viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
} else if(selectedGpxHelper.getSelectedFileByPath(child.getFileName()) != null){
viewName.setTextColor(okColor);
viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
} else {
viewName.setTextColor(defaultColor);
viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
@ -768,6 +792,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
protected void onPreExecute() {
showProgressBar();
}
@Override
@ -777,7 +802,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
protected void onPostExecute(GpxInfo[] result) {
hideProgressBar();
listAdapter.notifyDataSetChanged();
}
}
@ -789,7 +816,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
int count = 0;
int total = 0;
for (GpxInfo info : params) {
if (!isCancelled()) {
if (!isCancelled() && !info.gpx.showCurrentTrack) {
boolean successfull = false;
successfull = Algorithms.removeAllFiles(info.file);
total++;
@ -822,6 +849,56 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
AccessibleToast.makeText(getSherlockActivity(), result, Toast.LENGTH_LONG).show();
}
}
public class SelectGpxTask extends AsyncTask<GpxInfo, GpxInfo, String> {
private boolean showOnMap;
private WptPt toShow;
public SelectGpxTask(boolean showOnMap) {
this.showOnMap = showOnMap;
}
@Override
protected String doInBackground(GpxInfo... params) {
for (GpxInfo info : params) {
if (!isCancelled()) {
info.updateGpxInfo(getMyApplication());
publishProgress(info);
}
}
return "";
}
@Override
protected void onProgressUpdate(GpxInfo... values) {
for(GpxInfo g : values) {
final boolean visible = selectedItems.contains(g);
selectedGpxHelper.selectGpxFile(g.gpx, visible);
if(visible && toShow == null) {
toShow = g.gpx.findPointToShow();
}
}
listAdapter.notifyDataSetInvalidated();
}
@Override
protected void onPreExecute() {
getSherlockActivity().setProgressBarIndeterminateVisibility(true);
}
@Override
protected void onPostExecute(String result) {
getSherlockActivity().setProgressBarIndeterminateVisibility(false);
if(showOnMap && toShow != null) {
getMyApplication().getSettings().setMapLocationToShow(toShow.lat, toShow.lon,
getMyApplication().getSettings().getLastKnownMapZoom());
MapActivity.launchMapActivityMoveToTop(getActivity());
}
}
}
private class SearchFilter extends Filter {
@ -892,4 +969,96 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
return true;
}
public static class GpxInfo {
public GPXFile gpx;
public File file;
public String subfolder;
private String name = null;
private int sz = -1;
private String fileName = null;
private String description;
private boolean corrupted;
private boolean expanded;
public GpxInfo(){
}
public GpxInfo(GPXFile file, String name) {
this.gpx = file;
this.name = name;
}
public String getName() {
if(name == null) {
name = formatName(file.getName());
}
return name;
}
private String formatName(String name) {
int ext = name.indexOf('.');
if (ext != -1) {
name = name.substring(0, ext);
}
return name.replace('_', ' ');
}
public boolean isCorrupted() {
return corrupted;
}
public int getSize() {
if(sz == -1) {
if(file == null) {
return -1;
}
sz = (int) (file.length() >> 10);
}
return sz;
}
public boolean isExpanded() {
return expanded;
}
public void setExpanded(boolean expanded) {
this.expanded = expanded;
}
public CharSequence getDescription() {
if(description == null) {
return "";
}
return description;
}
public void setGpx(GPXFile gpx) {
this.gpx = gpx;
}
public void updateGpxInfo(OsmandApplication app ) {
if(gpx == null){
gpx = GPXUtilities.loadGPXFile(app, file);
}
if(gpx.warning != null){
corrupted = true;
description = gpx.warning;
} else {
// 'Long-press for options' message
description = GpxUiHelper.getDescription(app, gpx, file) +
app.getString(R.string.local_index_gpx_info_show);
}
}
public String getFileName() {
if(fileName != null) {
return fileName;
}
if(file == null) {
return "";
}
return fileName = file.getName();
}
}
}

View file

@ -45,7 +45,8 @@ public class FavouritesActivity extends SherlockFragmentActivity {
super.onCreate(icicle);
setSupportProgressBarIndeterminateVisibility(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle("");
getSupportActionBar().setTitle(R.string.favorites_Button);
// getSupportActionBar().setTitle("");
// getSupportActionBar().setIcon(R.drawable.tab_search_favorites_icon);
File[] lf = ((OsmandApplication) getApplication()).getAppPath(TRACKS).listFiles();
boolean hasGpx = false;

View file

@ -66,7 +66,9 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
this.ctx = ctx;
this.currentTrack = new SelectedGpxFile();
this.currentTrack.setShowCurrentTrack(true);
this.currentTrack.getGpxFile().showCurrentTrack = true;
GPXFile gx = new GPXFile();
gx.showCurrentTrack = true;
this.currentTrack.setGpxFile(gx);
this.currentTrack.getGpxFile().tracks.add(new Track());
updateScript = "INSERT INTO " + TRACK_NAME +
" (" +TRACK_COL_LAT +", " +TRACK_COL_LON+", " +TRACK_COL_ALTITUDE+", " +TRACK_COL_SPEED

View file

@ -13,7 +13,6 @@ import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ExpandableListView;
import android.widget.Filter;
import android.widget.TextView;
@ -160,7 +159,7 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
adjustIndicator(groupPosition, isExpanded, row);
TextView label = (TextView) row.findViewById(R.id.category_name);
final GpxDisplayGroup model = getGroup(groupPosition);
label.setText(model.getGroupName(app));
label.setText(model.getGroupName());
// final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
// if (selectionMode) {
// ch.setVisibility(View.VISIBLE);

View file

@ -32,7 +32,7 @@ public class UploadGPXFilesTask extends AsyncTask<GpxInfo, String, String> {
int count = 0;
int total = 0;
for (GpxInfo info : params) {
if (!isCancelled()) {
if (!isCancelled() && info.file != null) {
String warning = null;
File file = info.file;
warning = new OpenstreetmapRemoteUtil(la, null).uploadGPXFile(tagstring, description, visibility,

View file

@ -49,7 +49,6 @@ import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ListView;
import android.widget.TextView;
@ -571,24 +570,23 @@ public class MapInfoLayer extends OsmandMapLayer {
return progressBar;
}
private static class ConfigLayout extends FrameLayout implements UpdateableWidget {
private ImageViewWidget config;
private static class UpdateFrameLayout extends FrameLayout implements UpdateableWidget {
private ImageViewWidget widget;
private ConfigLayout(Context c, ImageViewWidget config) {
private UpdateFrameLayout(Context c, ImageViewWidget widget) {
super(c);
this.config = config;
this.widget = widget;
}
@Override
public boolean updateInfo(DrawSettings drawSettings) {
return config.updateInfo(drawSettings);
return widget.updateInfo(drawSettings);
}
}
private View createConfiguration(){
final OsmandMapTileView view = map.getMapView();
FrameLayout.LayoutParams fparams = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
final Drawable config = view.getResources().getDrawable(R.drawable.map_config);
final Drawable configWhite = view.getResources().getDrawable(R.drawable.map_config_white);
ImageViewWidget configuration = new ImageViewWidget(map) {
@ -605,18 +603,8 @@ public class MapInfoLayer extends OsmandMapLayer {
return false;
}
};
configuration.setBackgroundDrawable(config);
FrameLayout fl = new ConfigLayout(view.getContext(), configuration) ;
fl.addView(configuration, fparams);
//fparams = new FrameLayout.LayoutParams(config.getMinimumWidth(), config.getMinimumHeight());
//fl.addView(progressBar, fparams);
fl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openViewConfigureDialog();
}
});
return fl;
configuration.setImageDrawable(config);
return configuration;
}
private View createLayer(){
// final Drawable globusDrawable = view.getResources().getDrawable(R.drawable.map_globus);
@ -678,15 +666,23 @@ public class MapInfoLayer extends OsmandMapLayer {
return defValue;
}
private View createBackToLocation(MapInfoWidgetsFactory mic){
private UpdateFrameLayout createBackToLocation(MapInfoWidgetsFactory mic){
progressBar = new View(view.getContext());
View backToLocation = mic.createBackToLocation(map);
//backToLock needed to set needed size of controls
final ImageViewWidget widget = mic.createBackToLocation(map);
Drawable backToLoc = map.getResources().getDrawable(R.drawable.back_to_loc);
FrameLayout layout = new FrameLayout(map.getMapView().getContext());
FrameLayout.LayoutParams fparams = new FrameLayout.LayoutParams(backToLoc.getMinimumWidth(), backToLoc.getMinimumHeight());
layout.addView(backToLocation,fparams);
layout.addView(progressBar,fparams);
UpdateFrameLayout layout = new UpdateFrameLayout(view.getContext(), widget) ;
FrameLayout.LayoutParams fparams;
//= new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
fparams = new FrameLayout.LayoutParams(backToLoc.getMinimumWidth(), backToLoc.getMinimumHeight());
layout.addView(widget, fparams);
fparams = new FrameLayout.LayoutParams(backToLoc.getMinimumWidth(), backToLoc.getMinimumHeight());
layout.addView(progressBar, fparams);
layout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
widget.performClick();
}
});
return layout;
}
}

View file

@ -100,21 +100,21 @@ public class MapInfoWidgetsFactory {
public ImageView createBackToLocation(final MapActivity map){
public ImageViewWidget createBackToLocation(final MapActivity map){
final Drawable backToLoc = map.getResources().getDrawable(R.drawable.back_to_loc);
final Drawable backToLocWhite = map.getResources().getDrawable(R.drawable.back_to_loc_white);
final Drawable backToLocDisabled = map.getResources().getDrawable(R.drawable.la_backtoloc_disabled);
final Drawable backToLocDisabledWhite = map.getResources().getDrawable(R.drawable.la_backtoloc_disabled_white);
final Drawable backToLocTracked = map.getResources().getDrawable(R.drawable.back_to_loc_tracked);
final Drawable backToLocTrackedWhite = map.getResources().getDrawable(R.drawable.back_to_loc_tracked_white);
ImageView backToLocation = new ImageViewWidget(map) {
ImageViewWidget backToLocation = new ImageViewWidget(map) {
Drawable lastDrawable = null;
@Override
public boolean updateInfo(DrawSettings drawSettings) {
boolean nightMode = drawSettings == null ? false : drawSettings.isNightMode();
boolean enabled = map.getMyApplication().getLocationProvider().getLastKnownLocation() != null;
boolean tracked = map.getMapViewTrackingUtilities().isMapLinkedToLocation();
boolean tracked = MapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation();
Drawable d;
if(!enabled) {
d = nightMode ? backToLocDisabledWhite : backToLocDisabled;
@ -130,12 +130,12 @@ public class MapInfoWidgetsFactory {
return true;
}
};
//backToLocation.setPadding((int) (5 * scaleCoefficient), 0, (int) (5 * scaleCoefficient), 0);
backToLocation.setPadding((int) (5 * scaleCoefficient), 0, (int) (5 * scaleCoefficient), 0);
backToLocation.setImageDrawable(map.getResources().getDrawable(R.drawable.back_to_loc));
backToLocation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
map.getMapViewTrackingUtilities().backToLocationImpl();
MapActivity.getMapViewTrackingUtilities().backToLocationImpl();
}
});
return backToLocation;