Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android fixes #13

Closed
wants to merge 10 commits into from
Closed

Android fixes #13

wants to merge 10 commits into from

Conversation

mbender74
Copy link

Fixes for FragmentManager: No view found for id 0x2 (unknown) for fragment SupportMapFragment tidev#282
and corrections now the mapView works as expected
Feat: added code for offlineOverlay image tiles like my PR soon to be done for iOS for offlineOverlay map features....

android/src/ti/map/ViewProxy.java Outdated Show resolved Hide resolved
android/src/ti/map/ViewProxy.java Outdated Show resolved Hide resolved

TiUIView mapview = new TiUIMapView(this, activity);

// ((TiUIMapView) view).createMapFragment();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the comment if not needed

@@ -1226,7 +1238,8 @@ private float handleGetZoomLevel()
public void setLocation(Object location)
{
if (location instanceof HashMap) {
HashMap dict = (HashMap) location;
HashMap<String, Object> dict = new HashMap<>();
dict.put("", location);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty key

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, that way no warnings from compiler because of wrong hashmap type

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if that has to be diffrent, I don´t know :-D

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the warning: [rawtypes] found raw type: HashMap warnings have been there the whole time. If you make a ti clean and build again you'll see many other warnings like

HashMap centerOffsetProperty = (HashMap) anno.getProperty(MapModule.PROPERTY_CENTER_OFFSET);
[ERROR] [GRADLE]                                ^
[ERROR] [GRADLE]   missing type arguments for generic class HashMap<K,V>

but it still builds fine. I would rather keep the part from before and we fix those warnings at another point. I've not tested setLocation but dict.put("", location); doesn't look right either 🤣

@m1ga
Copy link
Owner

m1ga commented Jun 17, 2022

why did you do the PR on my fork 😄 ?

@mbender74
Copy link
Author

var mapView = mapModule.createView({
			id:'mapview',
			userLocation: true,
			minZoom:14,
			maxZoom:18,
			mapType: Map.SATELLITE_TYPE,
			animate: false,
			region: {
				latitude: 49.54119,
				longitude: 7.33233,
				latitudeDelta: parseFloat((parseFloat(49.5487)-parseFloat(49.5300))/2),
				longitudeDelta: parseFloat((parseFloat(7.3453)-parseFloat(7.3170))/2),
			},
			offlineOverlay: {
				tilesPath:'/maps/tiles',
				tileExtension:'jpg',
				tileSize:256,
				maxRegion: {
					minLat:49.5300,
					maxLat:49.5487,
					minLong:7.3170,
					maxLong:7.3453,
					maxZoom:18,
					minZoom:14
				}
			},
			pitchEnabled: true,
			rotateEnabled: true,
			compassEnabled: true,
			showsBuildings: true,
			showsPointsOfInterest: true,
			top:0,
			bottom:0,
			left:0,
			right:0,
			width: Ti.UI.FILL,
			height: Ti.UI.FILL,
		});

maps.zip

@mbender74
Copy link
Author

because you need to test first

@mbender74
Copy link
Author

will do on main repo if found for good :-)

@mbender74
Copy link
Author

this fragment bug, also with your further improvements, which did not take any properties, just rendering the world.... take me hours over hours... this morning, I finally get it to work :-)

Copy link
Author

@mbender74 mbender74 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comments removed

@mbender74 mbender74 marked this pull request as draft June 17, 2022 12:37
@mbender74
Copy link
Author

in the maps.zip are demo map tiles, that will show the offlineOverlay feature

@m1ga
Copy link
Owner

m1ga commented Jun 17, 2022

offline tiles work fine. Make sure to add the properties to the docs (https://github.com/m1ga/ti.map/blob/master/apidoc/View.yml).
Can't test the other issue since it wasn't my bug.
I've created this issue: tidev#480 which still won't work and it will only show one map.

because you need to test first

but my fork is not up to date (only one PR with iOS stuff) and I can test it from your fork or the official repo too 😄 This only makes me double the work since I have to test it here and in the tidev repo. I rather prefer doing the PR in the main repo right way or no PR and just use your fork until its ready 😉

@mbender74
Copy link
Author

ok, I will also check if I can fix tidev#480
and then I will push to official....

Copy link
Owner

@m1ga m1ga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comments. In case you don't use Android Studio: use it 😄 makes it easier to spot unused variables and imports!

Comment on lines 4 to 6
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused imports

Comment on lines 40 to 45
// @Override
// public View onCreateView(LayoutInflater arg0, ViewGroup arg1, Bundle arg2) {
// Log.e(TAG, " onCreateView");
// View v = super.onCreateView(arg0, arg1, arg2);
// return v;
// }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove if not needed

private float maxZoomPreference = 20;
private LatLngBounds boundingRegion;
private Context mainContext;
private GroundOverlay overlayBackground;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never used

private Context mainContext;
private GroundOverlay overlayBackground;
private Integer backgroundColor = null;
private boolean transactionCommitted = false;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused

mapView = new MapView(proxy.getActivity(), gOptions);
container.addView(mapView);
mapView.onCreate(Bundle.EMPTY);
mapView.onResume();
Copy link
Owner

@m1ga m1ga Jun 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that onResume needed?

Comment on lines 1535 to 1552
// Intercept the touch event to find out the correct clicksource if clicking
// on the info window.
protected boolean interceptTouchEvent(MotionEvent ev)
{
if (ev.getAction() == MotionEvent.ACTION_UP && selectedAnnotation != null) {
TiMapInfoWindow infoWindow = selectedAnnotation.getMapInfoWindow();
TiMarker timarker = selectedAnnotation.getTiMarker();
if (infoWindow != null && timarker != null) {
Marker marker = timarker.getMarker();
if (map != null && marker != null && marker.isInfoWindowShown()) {
Point markerPoint = map.getProjection().toScreenLocation(marker.getPosition());
infoWindow.analyzeTouchEvent(ev, markerPoint, selectedAnnotation.getIconImageHeight());
}
}
}
return false;
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you move that function? Unnecessary change 😄

Comment on lines 3 to 30
import android.content.res.AssetFileDescriptor;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import com.google.android.gms.maps.model.Tile;
import com.google.android.gms.maps.model.TileProvider;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.IOException;
import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.common.AsyncResult;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.kroll.common.TiMessenger;
import org.appcelerator.titanium.TiApplication;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.io.TiBaseFile;
import org.appcelerator.titanium.io.TiFileFactory;
import org.appcelerator.titanium.io.TiFileProvider;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.util.TiFileHelper2;
import org.appcelerator.titanium.util.TiRHelper;
import org.appcelerator.titanium.view.TiDrawableReference;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only

import android.graphics.Bitmap;

import com.google.android.gms.maps.model.Tile;
import com.google.android.gms.maps.model.TileProvider;

import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.view.TiDrawableReference;

import java.io.ByteArrayOutputStream;

are used

Comment on lines 115 to 116
TiUIView view = new TiUIMapView(this);
return view;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the variable and just return new...

@mbender74 mbender74 closed this Jun 21, 2022
@mbender74 mbender74 deleted the android-fixes branch June 21, 2022 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants