forked from organicmaps/organicmaps
[android] MapTask for urls and crash-free app.
This commit is contained in:
parent
7e4df5f451
commit
5f293be4bf
6 changed files with 77 additions and 20 deletions
|
@ -326,10 +326,4 @@ extern "C"
|
|||
return g_framework->NativeFramework()->AddBookmarksFile(jni::ToNativeString(env, path));
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_mapswithme_maps_DownloadResourcesActivity_setViewPortByUrl(
|
||||
JNIEnv * env, jobject thiz, jstring url)
|
||||
{
|
||||
return g_framework->SetViewportByUrl(jni::ToNativeString(env, url));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,18 +53,12 @@ namespace android
|
|||
|
||||
m_bmType = "placemark-red";
|
||||
|
||||
// for (size_t i = 0; i < ARRAY_SIZE(m_images); ++i)
|
||||
// m_images[i] = 0;
|
||||
|
||||
shared_ptr<location::State> locState = NativeFramework()->GetLocationState();
|
||||
locState->AddOnPositionClickListener(bind(&Framework::OnPositionClicked, this, _1));
|
||||
}
|
||||
|
||||
Framework::~Framework()
|
||||
{
|
||||
// for (size_t i = 0; i < ARRAY_SIZE(m_images); ++i)
|
||||
// delete m_images[i];
|
||||
|
||||
delete m_videoTimer;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,8 +61,8 @@ namespace android
|
|||
typedef graphics::Image::Info ImageT;
|
||||
ImageT m_images[2];
|
||||
enum PopupImageIndexT { IMAGE_PLUS = 0, IMAGE_ARROW = 1 };
|
||||
void ActivatePopup(m2::PointD const & pos, string const & name, PopupImageIndexT index);
|
||||
|
||||
void ActivatePopup(m2::PointD const & pos, string const & name, PopupImageIndexT index);
|
||||
void ActivatePopupWithAddressInfo(m2::PointD const & pos, ::Framework::AddressInfo const & addrInfo);
|
||||
|
||||
shared_ptr<BookmarkBalloon> m_bmBaloon;
|
||||
|
|
|
@ -139,4 +139,11 @@ extern "C"
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_mapswithme_maps_MWMActivity_setViewPortByUrl(JNIEnv * env, jobject thiz, jstring url)
|
||||
{
|
||||
return g_framework->SetViewportByUrl(jni::ToNativeString(env, url));
|
||||
}
|
||||
} // extern "C"
|
||||
|
|
|
@ -21,6 +21,8 @@ import android.widget.ProgressBar;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mapswithme.maps.MWMActivity.MapTask;
|
||||
import com.mapswithme.maps.MWMActivity.OpenUrlTask;
|
||||
import com.mapswithme.maps.MapStorage.Index;
|
||||
import com.mapswithme.maps.location.LocationService;
|
||||
import com.mapswithme.util.ConnectionState;
|
||||
|
@ -51,6 +53,8 @@ public class DownloadResourcesActivity extends Activity implements LocationServi
|
|||
private CheckBox mDownloadCountryCheckBox = null;
|
||||
private LocationService mLocationService = null;
|
||||
private Index mCountryIndex = null;
|
||||
|
||||
private MapTask mMapTaskToForward;
|
||||
|
||||
private IntentProcessor[] mIntentProcessors = { new GeoIntentProcessor(),
|
||||
new HttpGe0IntentProcessor(),
|
||||
|
@ -248,6 +252,14 @@ public class DownloadResourcesActivity extends Activity implements LocationServi
|
|||
// Disable animation because MWMActivity should appear exactly over this one
|
||||
// Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
|
||||
mwmActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
|
||||
//add task to forward
|
||||
if (mMapTaskToForward != null)
|
||||
{
|
||||
mwmActivityIntent.putExtra(MWMActivity.EXTRA_TASK, mMapTaskToForward);
|
||||
mMapTaskToForward = null;
|
||||
}
|
||||
|
||||
startActivity(mwmActivityIntent);
|
||||
|
||||
finish();
|
||||
|
@ -617,8 +629,8 @@ public class DownloadResourcesActivity extends Activity implements LocationServi
|
|||
@Override
|
||||
public boolean processIntent(Intent intent)
|
||||
{
|
||||
final Uri data = intent.getData();
|
||||
return data != null ? setViewPortByUrl(data.toString()) : false;
|
||||
mMapTaskToForward = new OpenUrlTask(intent.getData().toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -635,8 +647,8 @@ public class DownloadResourcesActivity extends Activity implements LocationServi
|
|||
@Override
|
||||
public boolean processIntent(Intent intent)
|
||||
{
|
||||
final Uri data = intent.getData();
|
||||
return data != null ? setViewPortByUrl(data.toString()) : false;
|
||||
mMapTaskToForward = new OpenUrlTask(intent.getData().toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -660,7 +672,8 @@ public class DownloadResourcesActivity extends Activity implements LocationServi
|
|||
if (data != null)
|
||||
{
|
||||
final String ge0Url = "ge0:/" + data.getPath();
|
||||
return setViewPortByUrl(ge0Url);
|
||||
mMapTaskToForward = new OpenUrlTask(ge0Url);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
@ -694,6 +707,4 @@ public class DownloadResourcesActivity extends Activity implements LocationServi
|
|||
private native Index findIndexByPos(double lat, double lon);
|
||||
private native void cancelCurrentFile();
|
||||
private native boolean loadKMZFile(String path);
|
||||
//===============S=C=H=E=M=E======================//
|
||||
private native boolean setViewPortByUrl(String url);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.mapswithme.maps;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Locale;
|
||||
|
||||
import android.app.Activity;
|
||||
|
@ -35,6 +36,8 @@ import com.nvidia.devtech.NvEventQueueActivity;
|
|||
|
||||
public class MWMActivity extends NvEventQueueActivity implements LocationService.Listener
|
||||
{
|
||||
public static final String EXTRA_TASK = "map_task";
|
||||
|
||||
private static final int PRO_VERSION_DIALOG = 110001;
|
||||
private static final String PRO_VERSION_DIALOG_MSG = "pro_version_dialog_msg";
|
||||
//VideoTimer m_timer;
|
||||
|
@ -558,8 +561,31 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Intent intent = getIntent();
|
||||
// We need check for tasks both in onCreate and onNewIntent
|
||||
// because of bug in OS: https://code.google.com/p/android/issues/detail?id=38629
|
||||
handleTask(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent)
|
||||
{
|
||||
super.onNewIntent(intent);
|
||||
handleTask(intent);
|
||||
}
|
||||
|
||||
private void handleTask(Intent intent)
|
||||
{
|
||||
if (intent != null && intent.hasExtra(EXTRA_TASK))
|
||||
{
|
||||
MapTask mapTask = (MapTask) intent.getSerializableExtra(EXTRA_TASK);
|
||||
mapTask.run(this);
|
||||
intent.removeExtra(EXTRA_TASK);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
|
@ -904,6 +930,29 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
|
|||
m_externalStorageReceiver = null;
|
||||
}
|
||||
}
|
||||
|
||||
public interface MapTask extends Serializable
|
||||
{
|
||||
public boolean run(MWMActivity target);
|
||||
}
|
||||
|
||||
public static class OpenUrlTask implements MapTask
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final String mUrl;
|
||||
|
||||
public OpenUrlTask(String url)
|
||||
{
|
||||
Utils.checkNotNull(url);
|
||||
mUrl = url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(MWMActivity target)
|
||||
{
|
||||
return target.setViewPortByUrl(mUrl);
|
||||
}
|
||||
}
|
||||
|
||||
private native void nativeStorageConnected();
|
||||
private native void nativeStorageDisconnected();
|
||||
|
@ -918,4 +967,6 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
|
|||
private native void nativeCompassUpdated(long time, double magneticNorth, double trueNorth, double accuracy);
|
||||
|
||||
private native boolean nativeIsInChina(double lat, double lon);
|
||||
|
||||
private native boolean setViewPortByUrl(String url);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue