[android] Refactored a bit, removed old code.

This commit is contained in:
Dmitry Yunitsky 2015-10-22 17:27:39 +03:00 committed by r.kuznetsov
parent ab3e1e12bd
commit 223179a1ef
8 changed files with 30 additions and 107 deletions

View file

@ -225,10 +225,10 @@ void Framework::ShowCountry(TIndex const & idx, bool zoomToDownloadButton)
{
if (zoomToDownloadButton)
{
m2::RectD const rect = m_work.GetCountryBounds(idx);
double const lon = MercatorBounds::XToLon(rect.Center().x);
double const lat = MercatorBounds::YToLat(rect.Center().y);
m_work.ShowRect(lat, lon, 10);
m2::RectD const rect = m_work.GetCountryBounds(idx);
double const lon = MercatorBounds::XToLon(rect.Center().x);
double const lat = MercatorBounds::YToLat(rect.Center().y);
m_work.ShowRect(lat, lon, 10);
}
else
m_work.ShowCountry(idx);
@ -347,43 +347,6 @@ void Framework::RemoveLocalMaps()
m_work.DeregisterAllMaps();
}
void Framework::GetMapsWithoutSearch(vector<string> & out) const
{
// Actually, this routing is obsolete and comes from ancient times
// when mwm was without search index.
if (!Settings::IsFirstLaunchForDate(150101))
return;
ASSERT(out.empty(), ());
::Platform const & pl = GetPlatform();
vector<LocalCountryFile> localFiles;
platform::FindAllLocalMaps(localFiles);
for (LocalCountryFile const & localFile : localFiles)
{
CountryFile const countryFile = localFile.GetCountryFile();
// skip World and WorldCoast
if (countryFile.GetNameWithoutExt() == WORLD_FILE_NAME ||
countryFile.GetNameWithoutExt() == WORLD_COASTS_FILE_NAME)
{
continue;
}
try
{
FilesContainerR cont(platform::GetCountryReader(localFile, MapOptions::Map));
if (!cont.IsExist(SEARCH_INDEX_FILE_TAG))
out.push_back(countryFile.GetNameWithoutExt());
}
catch (RootException const & ex)
{
// sdcard can contain dummy _*.mwm files. Suppress these errors.
LOG(LWARNING, ("Bad mwm file:", countryFile.GetNameWithoutExt(), "Error:", ex.Msg()));
}
}
}
BookmarkAndCategory Framework::AddBookmark(size_t cat, m2::PointD const & pt, BookmarkData & bm)
{
return BookmarkAndCategory(cat, m_work.AddBookmark(cat, pt, bm));

View file

@ -121,8 +121,6 @@ namespace android
void AddLocalMaps();
void RemoveLocalMaps();
void GetMapsWithoutSearch(vector<string> & out) const;
storage::TIndex GetCountryIndex(double lat, double lon) const;
string GetCountryCode(double lat, double lon) const;

View file

@ -94,7 +94,7 @@ extern "C"
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_MapFragment_nativeConnectDownloadButton(JNIEnv * env, jobject thiz)
{
jmethodID methodID = jni::GetJavaMethodID(env, thiz, "OnDownloadCountryClicked", "(IIII)V");
jmethodID methodID = jni::GetJavaMethodID(env, thiz, "onDownloadCountryClicked", "(IIII)V");
g_framework->NativeFramework()->SetDownloadCountryListener(bind(&CallOnDownloadCountryClicked,
jni::make_global_ref(thiz), _1, _2, methodID));
}
@ -184,7 +184,8 @@ extern "C"
jint id2, jfloat x2, jfloat y2,
jint maskedPointer)
{
g_framework->Touch(static_cast<int>(action), android::Framework::Finger(id1, x1, y1),
g_framework->Touch(static_cast<int>(action),
android::Framework::Finger(id1, x1, y1),
android::Framework::Finger(id2, x2, y2), maskedPointer);
}

View file

@ -12,7 +12,7 @@ public:
void CallVoid(jlong arg);
private:
char const* m_name;
char const * m_name;
char const * m_signature;
jmethodID m_methodID;
jobject m_object;

View file

@ -202,7 +202,7 @@ public class MapFragment extends BaseMwmFragment
return false;
int action = event.getActionMasked();
int maskedPointer = event.getActionIndex();
int pointerIndex = event.getActionIndex();
switch (action)
{
case MotionEvent.ACTION_POINTER_UP:
@ -210,18 +210,18 @@ public class MapFragment extends BaseMwmFragment
break;
case MotionEvent.ACTION_UP:
action = NATIVE_ACTION_UP;
maskedPointer = 0;
pointerIndex = 0;
break;
case MotionEvent.ACTION_POINTER_DOWN:
action = NATIVE_ACTION_DOWN;
break;
case MotionEvent.ACTION_DOWN:
action = NATIVE_ACTION_DOWN;
maskedPointer = 0;
pointerIndex = 0;
break;
case MotionEvent.ACTION_MOVE:
action = NATIVE_ACTION_MOVE;
maskedPointer = INVALID_POINTER_MASK;
pointerIndex = INVALID_POINTER_MASK;
break;
case MotionEvent.ACTION_CANCEL:
action = NATIVE_ACTION_CANCEL;
@ -231,26 +231,18 @@ public class MapFragment extends BaseMwmFragment
switch (count)
{
case 1:
final float x = event.getX();
final float y = event.getY();
nativeOnTouch(action, event.getPointerId(0), x, y, INVALID_TOUCH_ID, 0, 0, 0);
nativeOnTouch(action, event.getPointerId(0), event.getX(), event.getY(), INVALID_TOUCH_ID, 0, 0, 0);
return true;
default:
final float x0 = event.getX(0);
final float y0 = event.getY(0);
final float x1 = event.getX(1);
final float y1 = event.getY(1);
nativeOnTouch(action, event.getPointerId(0), x0, y0, event.getPointerId(1), x1, y1, maskedPointer);
nativeOnTouch(action,
event.getPointerId(0), event.getX(0), event.getY(0),
event.getPointerId(1), event.getX(1), event.getY(1), pointerIndex);
return true;
}
}
@SuppressWarnings("UnusedDeclaration")
public void OnDownloadCountryClicked(final int group, final int country, final int region, final int options)
public void onDownloadCountryClicked(final int group, final int country, final int region, final int options)
{
UiThread.run(new Runnable()
{

View file

@ -943,7 +943,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
return true;
}
// Callbacks from native map objects touch event.
// Callbacks from native touch events on map objects.
@Override
public void onApiPointActivated(final double lat, final double lon, final String name, final String id)
{
@ -970,28 +970,13 @@ public class MwmActivity extends BaseMwmFragmentActivity
{
final MapObject poi = new MapObject.Poi(name, lat, lon, type);
poi.addMetadata(metaTypes, metaValues);
runOnUiThread(new Runnable()
{
@Override
public void run()
{
activateMapObject(poi);
}
});
activateMapObject(poi);
}
@Override
public void onBookmarkActivated(final int category, final int bookmarkIndex)
{
runOnUiThread(new Runnable()
{
@Override
public void run()
{
activateMapObject(BookmarkManager.INSTANCE.getBookmark(category, bookmarkIndex));
}
});
activateMapObject(BookmarkManager.INSTANCE.getBookmark(category, bookmarkIndex));
}
@Override
@ -1015,16 +1000,9 @@ public class MwmActivity extends BaseMwmFragmentActivity
@Override
public void onAdditionalLayerActivated(final String name, final String type, final double lat, final double lon, final int[] metaTypes, final String[] metaValues)
{
runOnUiThread(new Runnable()
{
@Override
public void run()
{
final MapObject sr = new MapObject.SearchResult(name, type, lat, lon);
sr.addMetadata(metaTypes, metaValues);
activateMapObject(sr);
}
});
final MapObject sr = new MapObject.SearchResult(name, type, lat, lon);
sr.addMetadata(metaTypes, metaValues);
activateMapObject(sr);
}
private void activateMapObject(MapObject object)
@ -1043,16 +1021,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
public void onDismiss()
{
if (!mPlacePage.hasMapObject(null))
{
runOnUiThread(new Runnable()
{
@Override
public void run()
{
mPlacePage.hide();
}
});
}
mPlacePage.hide();
}
@Override

View file

@ -53,11 +53,11 @@ char const * UserEventStream::CANCEL_FILTER = "CancelFilter";
uint8_t const TouchEvent::INVALID_MASKED_POINTER = 0xFF;
void TouchEvent::PrepareTouches(array<Touch, 2> const & previousToches)
void TouchEvent::PrepareTouches(array<Touch, 2> const & previousTouches)
{
if (GetValidTouchesCount(m_touches) == 2 && GetValidTouchesCount(previousToches) > 0)
if (GetValidTouchesCount(m_touches) == 2 && GetValidTouchesCount(previousTouches) > 0)
{
if (previousToches[0].m_id == m_touches[1].m_id)
if (previousTouches[0].m_id == m_touches[1].m_id)
Swap();
}
}

View file

@ -24,7 +24,7 @@ namespace df
struct Touch
{
m2::PointF m_location = m2::PointF::Zero();
int64_t m_id = -1; // if id == -1 then touch invalid
int64_t m_id = -1; // if id == -1 then touch is invalid
};
struct TouchEvent
@ -54,8 +54,8 @@ struct TouchEvent
/// Methods for work with current touches
/// For example : user put down one finger. We will have one touch in m_touches
/// and GetFirstMaskedPointer return index of this pointer in m_touces (0 in this case)
/// Than user put down second finger. m_touches will have 2 valid elements, but new finger only one.
/// and GetFirstMaskedPointer return index of this pointer in m_touches (0 in this case)
/// Then user puts down the second finger. m_touches will have 2 valid elements, but new finger only one.
/// In this case GetFirstMaskedPointer returns index of new pointer.
/// If user put down both fingers simultaneously, then GetFirst and GetSecond
/// will return valid not equal INVALID_MASKED_POINTER