Updated to fix of 119 bug in Jira

This commit is contained in:
unknown 2014-07-02 13:20:26 +03:00
parent 18e88f9e1f
commit fc508f4ce5

View file

@ -115,6 +115,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
});
return vs;
}
@Override
public void onResume() {
super.onResume();
@ -127,7 +128,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
public void onPause() {
super.onPause();
if(operationTask != null){
if (operationTask != null) {
operationTask.cancel(true);
}
}
@ -177,7 +178,7 @@ 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();
.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)
@ -185,9 +186,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
OsmandPlugin.onOptionsMenuActivity(getSherlockActivity(), this, optionsMenuAdapter);
for (int j = 0; j < optionsMenuAdapter.length(); j++) {
MenuItem item;
item = menu.add(0, optionsMenuAdapter.getItemId(j), j + 1, optionsMenuAdapter.getItemName(j));
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
);
item = menu.add(0, optionsMenuAdapter.getItemId(j), j + 1, optionsMenuAdapter.getItemName(j));
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
);
if (optionsMenuAdapter.getImageId(j, isLightActionBar()) != 0) {
item.setIcon(optionsMenuAdapter.getImageId(j, isLightActionBar()));
}
@ -195,14 +196,14 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
}
public void doAction(int actionResId){
if(actionResId == R.string.local_index_mi_delete){
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(actionMode != null) {
if (actionMode != null) {
actionMode.finish();
}
}
@ -228,14 +229,14 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
private void updateSelectionMode(ActionMode m) {
if(selectedItems.size() > 0) {
if (selectedItems.size() > 0) {
m.setTitle(selectedItems.size() + " " + app.getString(R.string.selected));
} else{
} else {
m.setTitle("");
}
}
private void openShowOnMapMode(){
private void openShowOnMapMode() {
selectionMode = true;
selectedItems.clear();
final Set<GpxInfo> originalSelectedItems = listAdapter.getSelectedGpx();
@ -247,14 +248,13 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
selectionMode = true;
updateSelectionMode(mode);
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.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;
@ -289,15 +289,15 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
public void openSelectionMode(final int actionResId, int darkIcon, int lightIcon,
final DialogInterface.OnClickListener listener){
public void openSelectionMode(final int actionResId, int darkIcon, int lightIcon,
final DialogInterface.OnClickListener listener) {
final int actionIconId = !isLightActionBar() ? darkIcon : lightIcon;
String value = app.getString(actionResId);
if (value.endsWith("...")) {
value = value.substring(0, value.length() - 3);
}
final String actionButton = value;
if(listAdapter.getGroupCount() == 0){
if (listAdapter.getGroupCount() == 0) {
AccessibleToast.makeText(getActivity(), app.getString(R.string.local_index_no_items_to_do, actionButton.toLowerCase()), Toast.LENGTH_SHORT).show();
return;
}
@ -310,7 +310,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
selectionMode = true;
MenuItem it = menu.add(actionResId);
if(actionIconId != 0) {
if (actionIconId != 0) {
it.setIcon(actionIconId);
}
it.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM |
@ -348,7 +348,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
});
if(R.string.local_index_mi_upload_gpx == actionResId){
if (R.string.local_index_mi_upload_gpx == actionResId) {
((TextView) getView().findViewById(R.id.DescriptionText)).setText(R.string.local_index_upload_gpx_description);
((TextView) getView().findViewById(R.id.DescriptionText)).setVisibility(View.VISIBLE);
}
@ -358,7 +358,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
private void renameFile(GpxInfo info) {
final File f = info.file;
Builder b = new AlertDialog.Builder(getActivity());
if(f.exists()){
if (f.exists()) {
final EditText editText = new EditText(getActivity());
editText.setPadding(7, 3, 7, 3);
editText.setText(f.getName());
@ -372,10 +372,10 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
if (dest.exists()) {
AccessibleToast.makeText(getActivity(), R.string.file_with_name_already_exists, Toast.LENGTH_LONG).show();
} else {
if(!f.getParentFile().exists()) {
if (!f.getParentFile().exists()) {
f.getParentFile().mkdirs();
}
if(f.renameTo(dest)){
if (f.renameTo(dest)) {
asyncLoader = new LoadGpxTask();
asyncLoader.execute(getActivity());
} else {
@ -437,12 +437,21 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
}
};
if(info.gpx != null && info.file != null){
if(getMyApplication().getSelectedGpxHelper().getSelectedFileByPath(info.file.getAbsolutePath()) == null) {
adapter.item(R.string.local_index_select_gpx_file).listen(listener).reg();
} else {
adapter.item(R.string.local_index_unselect_gpx_file).listen(listener).reg();
}
if (info.gpx != null) {
if (info.file == null){
GpxSelectionHelper.SelectedGpxFile selectedGpxFile = selectedGpxHelper.getSelectedCurrentRecordingTrack();
if (selectedGpxFile != null && selectedGpxFile.getGpxFile() == info.gpx){
adapter.item(R.string.local_index_unselect_gpx_file).listen(listener).reg();
} else {
adapter.item(R.string.local_index_select_gpx_file).listen(listener).reg();
}
} else {
if (getMyApplication().getSelectedGpxHelper().getSelectedFileByPath(info.file.getAbsolutePath()) == null) {
adapter.item(R.string.local_index_select_gpx_file).listen(listener).reg();
} else {
adapter.item(R.string.local_index_unselect_gpx_file).listen(listener).reg();
}
}
}
adapter.item(R.string.show_gpx_route).listen(listener).reg();
if (info.file != null) {
@ -480,11 +489,11 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
protected List<GpxInfo> doInBackground(Activity... params) {
List<GpxInfo> result = new ArrayList<GpxInfo>();
if(!savingTrackHelper.getCurrentGpx().isEmpty()) {
if (!savingTrackHelper.getCurrentGpx().isEmpty()) {
loadFile(new GpxInfo(savingTrackHelper.getCurrentGpx(),
app.getString(R.string.gpx_available_current_track)));
}
loadGPXData(app.getAppPath(IndexConstants.GPX_INDEX_DIR), result, this);
loadGPXData(app.getAppPath(IndexConstants.GPX_INDEX_DIR), result, this);
return result;
}
@ -509,7 +518,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
public void setResult(List<GpxInfo> result) {
this.result = result;
listAdapter.clear();
if(result != null){
if (result != null) {
for (GpxInfo v : result) {
listAdapter.addLocalIndexInfo(v);
}
@ -524,9 +533,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
getSherlockActivity().setSupportProgressBarIndeterminateVisibility(false);
}
private File[] listFilesSorted(File dir){
private File[] listFilesSorted(File dir) {
File[] listFiles = dir.listFiles();
if(listFiles == null) {
if (listFiles == null) {
return new File[0];
}
Arrays.sort(listFiles);
@ -544,7 +553,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
private void loadGPXFolder(File mapPath, List<GpxInfo> result, LoadGpxTask loadTask,
List<GpxInfo> progress, String gpxSubfolder) {
List<GpxInfo> progress, String gpxSubfolder) {
for (File gpxFile : listFilesSorted(mapPath)) {
if (gpxFile.isDirectory()) {
String sub = gpxSubfolder.length() == 0 ? gpxFile.getName() : gpxSubfolder + "/" + gpxFile.getName();
@ -571,9 +580,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
protected class GpxIndexesAdapter extends OsmandBaseExpandableListAdapter implements Filterable {
protected class GpxIndexesAdapter extends OsmandBaseExpandableListAdapter implements Filterable {
Map<String, List<GpxInfo>> data = new LinkedHashMap<String, List<GpxInfo>>();
List<String> category = new ArrayList<String>();
@ -620,7 +627,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
public void addLocalIndexInfo(GpxInfo info) {
String catName;
if(info.gpx != null && info.gpx.showCurrentTrack) {
if (info.gpx != null && info.gpx.showCurrentTrack) {
catName = info.name;
} else {
catName = app.getString(R.string.local_indexes_cat_gpx) + " " + info.subfolder;
@ -660,7 +667,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
View v = convertView;
final GpxInfo child = (GpxInfo) getChild(groupPosition, childPosition);
if (v == null ) {
if (v == null) {
LayoutInflater inflater = getActivity().getLayoutInflater();
v = inflater.inflate(net.osmand.plus.R.layout.local_index_list_item, parent, false);
}
@ -670,7 +677,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
if (child.isCorrupted()) {
viewName.setTextColor(corruptedColor);
viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
} else if(selectedGpxHelper.getSelectedFileByName(child.getFileName()) != null){
} else if (selectedGpxHelper.getSelectedFileByName(child.getFileName()) != null) {
viewName.setTextColor(okColor);
viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
} else {
@ -680,7 +687,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
if (child.getSize() >= 0) {
String size;
if (child.getSize() > 100) {
size = formatMb.format(new Object[] { (float) child.getSize() / (1 << 10) });
size = formatMb.format(new Object[]{(float) child.getSize() / (1 << 10)});
} else {
size = child.getSize() + " kB";
}
@ -704,7 +711,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
public void onClick(View v) {
if(checkbox.isChecked()){
if (checkbox.isChecked()) {
selectedItems.add(child);
} else {
selectedItems.remove(child);
@ -757,7 +764,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
public String getGroup(int groupPosition) {
return category.get(groupPosition) ;
return category.get(groupPosition);
}
@Override
@ -782,7 +789,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
public Filter getFilter() {
if(filter == null) {
if (filter == null) {
filter = new SearchFilter();
}
return filter;
@ -798,7 +805,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
break;
}
}
if(found != -1) {
if (found != -1) {
data.get(category.get(found)).remove(g);
}
}
@ -856,7 +863,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
protected void onProgressUpdate(GpxInfo... values) {
for(GpxInfo g : values) {
for (GpxInfo g : values) {
listAdapter.delete(g);
}
listAdapter.notifyDataSetChanged();
@ -898,10 +905,10 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
protected void onProgressUpdate(GpxInfo... values) {
for(GpxInfo g : values) {
for (GpxInfo g : values) {
final boolean visible = selectedItems.contains(g);
selectedGpxHelper.selectGpxFile(g.gpx, visible, false);
if(visible && toShow == null) {
if (visible && toShow == null) {
toShow = g.gpx.findPointToShow();
}
}
@ -917,7 +924,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
protected void onPostExecute(String result) {
selectedGpxHelper.runUiListeners();
getSherlockActivity().setProgressBarIndeterminateVisibility(false);
if(showOnMap && toShow != null) {
if (showOnMap && toShow != null) {
getMyApplication().getSettings().setMapLocationToShow(toShow.lat, toShow.lon,
getMyApplication().getSettings().getLastKnownMapZoom());
MapActivity.launchMapActivityMoveToTop(getActivity());
@ -938,8 +945,8 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
} else {
String cs = constraint.toString().toLowerCase();
List<GpxInfo> res = new ArrayList<GpxInfo>();
for(GpxInfo r : raw) {
if(r.getName().toLowerCase().indexOf(cs) != -1) {
for (GpxInfo r : raw) {
if (r.getName().toLowerCase().indexOf(cs) != -1) {
res.add(r);
}
}
@ -971,10 +978,10 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
public void onDestroy() {
super.onDestroy();
if(descriptionLoader != null) {
if (descriptionLoader != null) {
descriptionLoader.cancel(true);
}
if(asyncLoader != null) {
if (asyncLoader != null) {
asyncLoader.cancel(true);
}
}
@ -1002,19 +1009,19 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
public static class GpxInfo {
public GPXFile gpx;
public File file;
public String subfolder;
public GPXFile gpx;
public File file;
public String subfolder;
private String name = null;
private int sz = -1;
private String fileName = null;
private String name = null;
private int sz = -1;
private String fileName = null;
private String description;
private boolean corrupted;
private boolean expanded;
private Spanned htmlDescription;
public GpxInfo(){
public GpxInfo() {
}
public GpxInfo(GPXFile file, String name) {
@ -1023,7 +1030,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
public String getName() {
if(name == null) {
if (name == null) {
name = formatName(file.getName());
}
return name;
@ -1042,8 +1049,8 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
public int getSize() {
if(sz == -1) {
if(file == null) {
if (sz == -1) {
if (file == null) {
return -1;
}
sz = (int) (file.length() >> 10);
@ -1060,14 +1067,14 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
public CharSequence getDescription() {
if(description == null) {
if (description == null) {
return "";
}
return description;
}
public Spanned getHtmlDescription() {
if(htmlDescription != null) {
if (htmlDescription != null) {
return htmlDescription;
}
htmlDescription = Html.fromHtml(getDescription().toString().replace("\n", "<br/>"));
@ -1075,35 +1082,34 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
public void setGpx(GPXFile gpx) {
this.gpx = gpx;
}
public void updateGpxInfo(OsmandApplication app ) {
if(gpx == null){
public void updateGpxInfo(OsmandApplication app) {
if (gpx == null) {
gpx = GPXUtilities.loadGPXFile(app, file);
}
if(gpx.warning != null){
if (gpx.warning != null) {
corrupted = true;
description = gpx.warning;
} else {
// 'Long-press for options' message
description = GpxUiHelper.getDescription(app, gpx, file, true) +
app.getString(R.string.local_index_gpx_info_show);
description = GpxUiHelper.getDescription(app, gpx, file, true) +
app.getString(R.string.local_index_gpx_info_show);
}
htmlDescription = null;
getHtmlDescription();
}
public String getFileName() {
if(fileName != null) {
if (fileName != null) {
return fileName;
}
if(file == null) {
if (file == null) {
return "";
}
return fileName = file.getName();
}
}
}
}