Skip to content

Commit

Permalink
#17: fixed dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
k3b committed Jun 19, 2021
1 parent 07442d9 commit a3a646f
Show file tree
Hide file tree
Showing 13 changed files with 137 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,8 @@
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;

import de.k3b.android.locationMapViewer.geobmp.GeoBmpDto;
import de.k3b.geo.GeoLoadService;
import de.k3b.geo.api.IGeoInfoHandler;
import de.k3b.geo.io.gpx.GeoXmlOrTextParser;
import de.k3b.util.Unzip;
import de.k3b.util.Unzip2;

Expand Down Expand Up @@ -120,18 +116,7 @@ public static void loadGeoPointDtos(Context context, Uri uri, IGeoInfoHandler po
}
}
}
public static void loadGeoPointDtosFromText(String pois, IGeoInfoHandler pointCollector) {
if (pois != null) {
List<GeoBmpDto> result = new GeoXmlOrTextParser<GeoBmpDto>().get(new GeoBmpDto(), pois);

if (result != null) {
for(GeoBmpDto item : result) {
pointCollector.onGeoInfo(item);
}
}
}
}

public static String getName(Uri uri) {
String decodedPath = null;
if (uri != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@
import de.k3b.android.geo.DocumentFileSymbolConverter;
import de.k3b.android.locationMapViewer.constants.Constants;
import de.k3b.android.locationMapViewer.geobmp.BookmarkListOverlay;
import de.k3b.android.locationMapViewer.geobmp.BookmarkUtil;
import de.k3b.android.locationMapViewer.geobmp.GeoBmpDto;
import de.k3b.geo.geobmp.BookmarkUtil;
import de.k3b.android.locationMapViewer.geobmp.GeoBmpDtoAndroid;
import de.k3b.android.osmdroid.GuestureOverlay;
import de.k3b.android.osmdroid.ZoomUtil;
import de.k3b.android.widgets.AboutDialogPreference;
Expand Down Expand Up @@ -161,7 +161,7 @@ public class LocationMapViewer extends FilePermissionActivity implements Constan
private SeekBar mZoomBar;

/** first visible window as bookmark candidate */
private GeoBmpDto initialWindow = null;
private GeoBmpDtoAndroid initialWindow = null;
private BookmarkListOverlay bookmarkListOverlay;
private ImageButton cmdShowMenu = null;
private Boolean showLocation = null;
Expand Down Expand Up @@ -222,7 +222,7 @@ protected void onCreateEx(Bundle savedInstanceState) {
mPOIOverlayCluster = (mUseClusterPoints) ? createPointOfInterestOverlay(overlays) : null;

if (geoPointFromIntent != null) {
initialWindow = new GeoBmpDto(geoPointFromIntent);
initialWindow = new GeoBmpDtoAndroid(geoPointFromIntent);
BitmapDrawable drawable = (BitmapDrawable) getDrawableEx(R.drawable.marker_no_data);
initialWindow.setBitmap(drawable.getBitmap());

Expand Down Expand Up @@ -256,7 +256,7 @@ protected void onCreateEx(Bundle savedInstanceState) {

this.bookmarkListOverlay = new BookmarkListOverlay(this, this) {
@Override
protected void onSelChanged(GeoBmpDto newSelection) {
protected void onSelChanged(GeoBmpDtoAndroid newSelection) {
super.onSelChanged(newSelection);

if (newSelection != null) {
Expand Down Expand Up @@ -836,25 +836,25 @@ private void onOpenDir(CharSequence title) {
}

/** implements interface BookmarkListOverlay.AdditionalPoints */
public GeoBmpDto[] getAdditionalPoints() {
public GeoBmpDtoAndroid[] getAdditionalPoints() {
GeoPoint gps = (this.mLocationOverlay != null) ? this.mLocationOverlay.getMyLocation() : null;

GeoBmpDto gpsWindow = null;
GeoBmpDtoAndroid gpsWindow = null;
if (gps != null) {
gpsWindow = new GeoBmpDto();
gpsWindow = new GeoBmpDtoAndroid();
GeoUtil.createBookmark(gps, IGeoPointInfo.NO_ZOOM, getString(R.string.bookmark_template_gps), gpsWindow);
BitmapDrawable drawable = (BitmapDrawable) getDrawableEx(R.drawable.person);
gpsWindow.setBitmap(drawable.getBitmap());

}
GeoBmpDto currentWindow = getCurrentAsGeoPointDto(getString(R.string.bookmark_template_current));
return new GeoBmpDto[]{currentWindow, gpsWindow, initialWindow};
GeoBmpDtoAndroid currentWindow = getCurrentAsGeoPointDto(getString(R.string.bookmark_template_current));
return new GeoBmpDtoAndroid[]{currentWindow, gpsWindow, initialWindow};
}

private GeoBmpDto getCurrentAsGeoPointDto(String name) {
GeoBmpDto current = new GeoBmpDto();
private GeoBmpDtoAndroid getCurrentAsGeoPointDto(String name) {
GeoBmpDtoAndroid current = new GeoBmpDtoAndroid();
GeoUtil.createBookmark(this.mMapView.getMapCenter(), (int) this.mMapView.getZoomLevelDouble(), name, current);
current.setBitmap(GeoUtil.createBitmapFromMapView(mMapView, GeoBmpDto.WIDTH, GeoBmpDto.HEIGHT));
current.setBitmap(GeoUtil.createBitmapFromMapView(mMapView, GeoBmpDtoAndroid.WIDTH, GeoBmpDtoAndroid.HEIGHT));
return current;
}

Expand Down Expand Up @@ -953,7 +953,7 @@ private void openGeoFile(Uri uri, DocumentFile relativeRootDir, Map<String, Docu
}
AndroidGeoLoadService.loadGeoPointDtos(this, uri, pointCollectorWithSymbolConverter, name, isZipStream);
}
AndroidGeoLoadService.loadGeoPointDtosFromText(intent.getStringExtra("de.k3b.POIS"), pointCollector);
AndroidGeoLoadService.loadGeoPointDtosFromText(intent.getStringExtra("de.k3b.POIS"), pointCollector, new GeoBmpDtoAndroid());

zoomTo(geoPointFromIntent, pointCollectorWithSymbolConverter);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015 by k3b.
* Copyright (c) 2015-2021 by k3b.
*
* This file is part of LocationMapViewer.
*
Expand Down Expand Up @@ -30,6 +30,7 @@
import de.k3b.android.locationMapViewer.R;
import de.k3b.geo.api.IGeoPointInfo;
import de.k3b.geo.api.IGeoRepository;
import de.k3b.geo.geobmp.BookmarkUtil;

/**
* Gui-type independendant handling to display/update a BookmarkList.
Expand All @@ -39,25 +40,25 @@
public class BookmarkListController {
private static final String BOOKMARKS_FILE_NAME = "favorites.txt";

private GeoBmpDto currentItem;
private GeoBmpDtoAndroid currentItem;

public BookmarkListController setAdditionalPoints(GeoBmpDto[] additionalPoints) {
public BookmarkListController setAdditionalPoints(GeoBmpDtoAndroid[] additionalPoints) {
this.additionalPoints = additionalPoints;
for (GeoBmpDto template : this.additionalPoints) {
for (GeoBmpDtoAndroid template : this.additionalPoints) {
BookmarkUtil.markAsTemplate(template);
}
return this;
}

interface OnSelChangedListener
{
void onSelChanged(GeoBmpDto newSelection);
void onSelChanged(GeoBmpDtoAndroid newSelection);
}

private final Context context;
private final ListView listView;
private final IGeoRepository<GeoBmpDto> repository;
private GeoBmpDto[] additionalPoints = null;
private final IGeoRepository<GeoBmpDtoAndroid> repository;
private GeoBmpDtoAndroid[] additionalPoints = null;
private OnSelChangedListener selChangedListener = null;

public BookmarkListController(Context context, final ListView listView) {
Expand All @@ -68,7 +69,7 @@ public BookmarkListController(Context context, final ListView listView) {
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
final GeoBmpDto currenSelection = (GeoBmpDto) listView.getItemAtPosition(position);
final GeoBmpDtoAndroid currenSelection = (GeoBmpDtoAndroid) listView.getItemAtPosition(position);
setCurrentItem(currenSelection);
}
});
Expand All @@ -79,7 +80,7 @@ public void onItemClick(AdapterView<?> adapterView, View view, int position, lon
@Override
public void onItemSelected(AdapterView<?> adapterView, View childView,
int position, long id) {
onSelChanged((GeoBmpDto) listView.getItemAtPosition(position));
onSelChanged((GeoBmpDtoAndroid) listView.getItemAtPosition(position));
}
@Override
Expand All @@ -97,15 +98,15 @@ public void setSelChangedListener(OnSelChangedListener selChangedListener) {
}

public BookmarkListController reloadGuiFromRepository() {
final ArrayAdapter<GeoBmpDto> adapter = GeoBmpListAdapter.createAdapter(this.context,
final ArrayAdapter<GeoBmpDtoAndroid> adapter = GeoBmpListAdapter.createAdapter(this.context,
R.layout.geobmp_list_view_row, repository, additionalPoints);
this.listView.setAdapter(adapter);
this.setCurrentItem(adapter.isEmpty() ? null : adapter.getItem(0));
return this;
}


public void setCurrentItem(GeoBmpDto newSelection) {
public void setCurrentItem(GeoBmpDtoAndroid newSelection) {
final GeoBmpListAdapter listAdapter = (GeoBmpListAdapter) this.listView.getAdapter();
listAdapter.setCurrentSelecion(newSelection);

Expand All @@ -116,16 +117,16 @@ public void setCurrentItem(GeoBmpDto newSelection) {
}
}

public GeoBmpDto getCurrentItem() {
public GeoBmpDtoAndroid getCurrentItem() {
return currentItem;
}

public void update(IGeoPointInfo geoPointInfo) {
if (BookmarkUtil.isValid(geoPointInfo)) {
GeoBmpDto item = (GeoBmpDto) geoPointInfo;
GeoBmpDtoAndroid item = (GeoBmpDtoAndroid) geoPointInfo;
if (BookmarkUtil.isNew(item)) {
item.setId(repository.createId());
List<GeoBmpDto> items = this.repository.load();
List<GeoBmpDtoAndroid> items = this.repository.load();
items.add(0, item);
}
this.repository.save();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015 by k3b.
* Copyright (c) 2015-2021 by k3b.
*
* This file is part of LocationMapViewer.
*
Expand Down Expand Up @@ -39,6 +39,7 @@
import de.k3b.android.locationMapViewer.constants.Constants;
import de.k3b.geo.api.IGeoInfoHandler;
import de.k3b.geo.api.IGeoPointInfo;
import de.k3b.geo.geobmp.BookmarkUtil;

/**
* Handles BookmarkList as part of the mapview
Expand All @@ -49,7 +50,7 @@ public class BookmarkListOverlay implements IGeoInfoHandler, Constants {
private ActionBarDrawerToggle mDrawerToggle;

public interface AdditionalPoints {
GeoBmpDto[] getAdditionalPoints();
GeoBmpDtoAndroid[] getAdditionalPoints();
}
// private static final int MENU_ADD_CATEGORY = Menu.FIRST;
private static final int EDIT_MENU_ID = Menu.FIRST + 137;
Expand All @@ -72,7 +73,7 @@ public BookmarkListOverlay(Activity context, AdditionalPoints additionalPointPro
bookMarkController = new BookmarkListController(context, (ListView) context.findViewById(android.R.id.list));
bookMarkController.setSelChangedListener(new BookmarkListController.OnSelChangedListener() {
@Override
public void onSelChanged(GeoBmpDto newSelection) {
public void onSelChanged(GeoBmpDtoAndroid newSelection) {
BookmarkListOverlay.this.onSelChanged(newSelection);
}
});
Expand All @@ -81,7 +82,7 @@ public void onSelChanged(GeoBmpDto newSelection) {
createButtons();
}

protected void onSelChanged(GeoBmpDto newSelection) {
protected void onSelChanged(GeoBmpDtoAndroid newSelection) {
final boolean sel = (newSelection != null);
cmdEdit.setEnabled(sel);
cmdDelete.setEnabled(sel && BookmarkUtil.isBookmark(newSelection));
Expand Down Expand Up @@ -188,7 +189,7 @@ public BookmarkListOverlay setBookmarkListVisible(boolean visible) {
return this;
}

public void showGeoPointEditDialog(GeoBmpDto geoPointInfo) {
public void showGeoPointEditDialog(GeoBmpDtoAndroid geoPointInfo) {
if (geoPointInfo != null) {
if (this.edit == null) {
this.edit = new GeoBmpEditDialog(this.context, this, R.layout.geobmp_edit_name);
Expand Down Expand Up @@ -216,7 +217,7 @@ public Dialog onCreateDialog(final int id) {

/** before deleting: "Are you shure?" */
private void deleteConfirm() {
final GeoBmpDto currentItem = this.bookMarkController.getCurrentItem();
final GeoBmpDtoAndroid currentItem = this.bookMarkController.getCurrentItem();
if (currentItem != null) {
final String message = String.format(
this.context.getString(R.string.format_question_delete).toString(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015 by k3b.
* Copyright (c) 2015-2021 by k3b.
*
* This file is part of LocationMapViewer.
*
Expand Down Expand Up @@ -33,7 +33,7 @@
import de.k3b.util.IsoDateTimeParser;

/**
* Connects a {@link GeoBmpDto} data element
* Connects a {@link GeoBmpDtoAndroid} data element
* with the corresponding gui elements.
*
* This implements convention over configuration.
Expand All @@ -43,7 +43,7 @@
*/
public class GeoBmpBinder {
/** hack for adapter in listview where i cannot controll the class generated */
public static void toGui(final View gui, GeoBmpDto item) {
public static void toGui(final View gui, GeoBmpDtoAndroid item) {
toGui(new IViewHolder() {
@Override
public View findViewById(int id) {
Expand All @@ -52,7 +52,7 @@ public View findViewById(int id) {
}, item);
}

public static void toGui(IViewHolder gui, GeoBmpDto item) {
public static void toGui(IViewHolder gui, GeoBmpDtoAndroid item) {
TextView textView;

textView = (TextView) gui.findViewById(R.id.name);
Expand Down Expand Up @@ -87,7 +87,7 @@ public static void toGui(IViewHolder gui, GeoBmpDto item) {
if (thumbnail != null) thumbnail.setImageBitmap(item.getBitmap());
}

public static void fromGui(IViewHolder gui, GeoBmpDto currentItem) {
public static void fromGui(IViewHolder gui, GeoBmpDtoAndroid currentItem) {
EditText textView;

// id and bitmap are not read from gui
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2015-2021 by k3b.
*
* This file is part of LocationMapViewer.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>
*/

package de.k3b.android.locationMapViewer.geobmp;

import android.graphics.Bitmap;

import java.io.Serializable;

import de.k3b.geo.api.GeoPointDto;
import de.k3b.geo.geobmp.GeoBmpDto;

/**
* a GeoPoint with a bitmap.
*
* Created by k3b on 24.03.2015.
*/
public class GeoBmpDtoAndroid extends GeoBmpDto<Bitmap> implements Serializable {
public GeoBmpDtoAndroid() {};
public GeoBmpDtoAndroid(GeoPointDto geoPointFromIntent) {
super(geoPointFromIntent);
}
}
Loading

0 comments on commit a3a646f

Please sign in to comment.