forked from organicmaps/organicmaps
[android] [bookmarks] draw popup in opengl-layer
This commit is contained in:
parent
ccc793872e
commit
fb7491a7d7
16 changed files with 342 additions and 230 deletions
|
@ -20,6 +20,7 @@
|
|||
#include "../../../../../platform/location.hpp"
|
||||
|
||||
#include "../../../../../base/math.hpp"
|
||||
#include "../../../../../base/logging.hpp"
|
||||
|
||||
#include "../../../../../std/shared_ptr.hpp"
|
||||
#include "../../../../../std/bind.hpp"
|
||||
|
@ -56,6 +57,8 @@ namespace android
|
|||
size_t const measurementsCount = 5;
|
||||
m_sensors[0].SetCount(measurementsCount);
|
||||
m_sensors[1].SetCount(measurementsCount);
|
||||
|
||||
m_work.GetBookmarkBalloon()->setOnClickListener(bind(&Framework::OnBalloonClick, this, _1));
|
||||
}
|
||||
|
||||
Framework::~Framework()
|
||||
|
@ -271,8 +274,8 @@ namespace android
|
|||
m_scheduledTask.reset(new ScheduledTask(bind(
|
||||
& android::Framework::CallLongClickListener,
|
||||
this,
|
||||
static_cast<int>(x1),
|
||||
static_cast<int>(y1)),
|
||||
static_cast<double>(x1),
|
||||
static_cast<double>(y1)),
|
||||
static_cast<int>(LONG_CLICK_LENGTH_SEC * 1000)
|
||||
));
|
||||
m_longClickTimer.Reset();
|
||||
|
@ -430,7 +433,9 @@ namespace android
|
|||
void Framework::ShowSearchResult(search::Result const & r)
|
||||
{
|
||||
m_doLoadState = false;
|
||||
|
||||
::Framework::AddressInfo info;
|
||||
info.MakeFrom(r);
|
||||
ActivatePopupWithAddressInfo(r.GetFeatureCenter(), info);
|
||||
m_work.ShowSearchResult(r);
|
||||
}
|
||||
|
||||
|
@ -552,38 +557,157 @@ namespace android
|
|||
return &m_work;
|
||||
}
|
||||
|
||||
void Framework::CallClickListener(int x, int y)
|
||||
void Framework::CallClickListener(double x, double y)
|
||||
{
|
||||
if (!m_onClickListener.empty())
|
||||
if (!HandleOnSmthClick(x, y))
|
||||
DeactivatePopup();
|
||||
}
|
||||
|
||||
void Framework::CallLongClickListener(double x, double y)
|
||||
{
|
||||
if (!HandleOnSmthClick(x, y))
|
||||
{
|
||||
m_onClickListener(x, y);
|
||||
AdditionalHandlingForLongClick(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
void Framework::CallLongClickListener(int x, int y)
|
||||
|
||||
bool Framework::HandleOnSmthClick(double x, double y)
|
||||
{
|
||||
if (!m_onLongClickListener.empty())
|
||||
BookmarkAndCategory bac = m_work.GetBookmark(m2::PointD(x, y));
|
||||
if (ValidateBookmarkAndCategory(bac))
|
||||
{
|
||||
m_onLongClickListener(x, y);
|
||||
Bookmark b = *(m_work.GetBmCategory(bac.first)->GetBookmark(bac.second));
|
||||
ActivatePopup(b.GetOrg(), b.GetName());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
::Framework::AddressInfo adInfo;
|
||||
m2::PointD pxPivot;
|
||||
if (m_work.GetVisiblePOI(m2::PointD(x, y), pxPivot, adInfo))
|
||||
{
|
||||
ActivatePopupWithAddressInfo(m_work.PtoG(pxPivot), adInfo);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void Framework::AddClickListener(Framework::TOnClickListener const & l)
|
||||
bool Framework::AdditionalHandlingForLongClick(double x, double y)
|
||||
{
|
||||
m_onClickListener = l;
|
||||
m2::PointD point(x, y);
|
||||
::Framework::AddressInfo adInfo;
|
||||
m_work.GetAddressInfo(point, adInfo);
|
||||
ActivatePopupWithAddressInfo(m_work.PtoG(point), adInfo);
|
||||
}
|
||||
|
||||
void Framework::RemoveClickListener()
|
||||
void Framework::ToCamelCase(string & s)
|
||||
{
|
||||
m_onClickListener.clear();
|
||||
if (s.length() > 0)
|
||||
{
|
||||
s[0] = toupper(s[0]);
|
||||
for(std::string::iterator it = s.begin() + 1; it != s.end(); ++it)
|
||||
{
|
||||
if(!isalpha(*(it - 1)) &&
|
||||
islower(*it))
|
||||
{
|
||||
*it = toupper(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Framework::AddLongClickListener(TOnLongClickListener const & l)
|
||||
void Framework::ActivatePopupWithAddressInfo(m2::PointD const & bmkPosition, ::Framework::AddressInfo const & adInfo)
|
||||
{
|
||||
m_onLongClickListener = l;
|
||||
string name = adInfo.m_name;
|
||||
string type = "";
|
||||
if (adInfo.GetBestType() != 0)
|
||||
type = adInfo.GetBestType();
|
||||
string bmkname;
|
||||
if (name.empty() && type.empty())
|
||||
{
|
||||
bmkname = m_work.GetStringsBundle().GetString("dropped_pin");
|
||||
}
|
||||
else
|
||||
if (!name.empty())
|
||||
{
|
||||
bmkname = name;
|
||||
}
|
||||
else
|
||||
if (!type.empty())
|
||||
{
|
||||
bmkname = type;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::stringstream cstream;
|
||||
cstream << name << " (" << type << ")";
|
||||
bmkname = cstream.str();
|
||||
}
|
||||
|
||||
ActivatePopup(bmkPosition, bmkname);
|
||||
m_work.DrawPlacemark(bmkPosition);
|
||||
m_work.Invalidate();
|
||||
}
|
||||
void Framework::RemoveLongClickListener()
|
||||
|
||||
void Framework::ActivatePopup(m2::PointD const & bmkPosition, string const & name)
|
||||
{
|
||||
m_onLongClickListener.clear();
|
||||
gui::BookmarkBalloon * b = m_work.GetBookmarkBalloon();
|
||||
m_work.DisablePlacemark();
|
||||
b->setBookmarkPivot(bmkPosition);
|
||||
b->setBookmarkName(name);
|
||||
b->setIsVisible(true);
|
||||
m_work.Invalidate();
|
||||
}
|
||||
|
||||
void Framework::DeactivatePopup()
|
||||
{
|
||||
gui::BookmarkBalloon * b = m_work.GetBookmarkBalloon();
|
||||
b->setIsVisible(false);
|
||||
m_work.DisablePlacemark();
|
||||
m_work.Invalidate();
|
||||
}
|
||||
|
||||
void Framework::OnBalloonClick(gui::Element * e)
|
||||
{
|
||||
gui::BookmarkBalloon * balloon = static_cast<gui::BookmarkBalloon *>(e);
|
||||
BookmarkAndCategory bac = m_work.GetBookmark(m_work.GtoP(balloon->getBookmarkPivot()));
|
||||
if (ValidateBookmarkAndCategory(bac))
|
||||
{
|
||||
m_balloonClickListener(bac);
|
||||
}
|
||||
else
|
||||
{
|
||||
BookmarkCategory * cat;
|
||||
if (m_work.GetBmCategoriesCount() == 0)
|
||||
{
|
||||
m_work.AddBookmark(m_work.GetStringsBundle().GetString("my_places"), Bookmark(balloon->getBookmarkPivot(), balloon->getBookmarkName(), "placemark-red"));
|
||||
cat = m_work.GetBmCategory(m_work.GetBmCategoriesCount()-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
cat = m_work.GetBmCategory(m_work.GetBmCategoriesCount()-1);
|
||||
LOG(LDEBUG,("Paladin", (balloon->getBookmarkPivot(), balloon->getBookmarkName(), "placemark-red")));
|
||||
m_work.AddBookmark(cat->GetName(), Bookmark(balloon->getBookmarkPivot(), balloon->getBookmarkName(), "placemark-red"));
|
||||
}
|
||||
cat->SaveToKMLFile();
|
||||
int catSize = cat->GetBookmarksCount() - 1;
|
||||
if (catSize > 0)
|
||||
{
|
||||
bac = BookmarkAndCategory(m_work.GetBmCategoriesCount()-1, catSize);
|
||||
m_balloonClickListener(bac);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Framework::AddBalloonClickListener(TOnBalloonClickListener const & l)
|
||||
{
|
||||
m_balloonClickListener = l;
|
||||
}
|
||||
void Framework::RemoveBalloonClickListener()
|
||||
{
|
||||
m_balloonClickListener.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include "../../../../../base/scheduled_task.hpp"
|
||||
#include "../../../../../base/strings_bundle.hpp"
|
||||
|
||||
#include "../../../../../search/result.hpp"
|
||||
|
||||
#include "../../../nv_event/nv_event.hpp"
|
||||
|
||||
class CountryStatusDisplay;
|
||||
|
@ -22,16 +24,13 @@ namespace android
|
|||
class Framework
|
||||
{
|
||||
private:
|
||||
typedef function<void(int, int)> TOnClickListener;
|
||||
typedef function<void(int, int)> TOnLongClickListener;
|
||||
::Framework m_work;
|
||||
|
||||
typedef function<void (BookmarkAndCategory)> TOnBalloonClickListener;
|
||||
VideoTimer * m_videoTimer;
|
||||
|
||||
void CallRepaint();
|
||||
|
||||
TOnClickListener m_onClickListener;
|
||||
TOnLongClickListener m_onLongClickListener;
|
||||
TOnBalloonClickListener m_balloonClickListener;
|
||||
boost::shared_ptr<ScheduledTask> m_scheduledTask;
|
||||
|
||||
int m_onClickFnsHandler;
|
||||
|
@ -59,9 +58,22 @@ namespace android
|
|||
|
||||
math::AvgVector<float, 3> m_sensors[2];
|
||||
|
||||
void CallClickListener(int x, int y);
|
||||
void CallLongClickListener(int x, int y);
|
||||
void CallClickListener(double x, double y);
|
||||
void CallLongClickListener(double x, double y);
|
||||
void KillLongTouchTask();
|
||||
|
||||
bool HandleOnSmthClick(double x, double y);
|
||||
bool AdditionalHandlingForLongClick(double x, double y);
|
||||
void ActivatePopup(m2::PointD const & bmkPosition, string const & name);
|
||||
void ActivatePopupWithAddressInfo(m2::PointD const & bmkPosition, ::Framework::AddressInfo const & adInfo);
|
||||
void OnBalloonClick(gui::Element * e);
|
||||
void ToCamelCase(string & c);
|
||||
|
||||
inline bool ValidateBookmarkAndCategory(BookmarkAndCategory const & bac)
|
||||
{
|
||||
return bac.first > -1 && bac.second > -1;
|
||||
}
|
||||
|
||||
public:
|
||||
Framework();
|
||||
~Framework();
|
||||
|
@ -118,12 +130,11 @@ namespace android
|
|||
|
||||
void Scale(double k);
|
||||
|
||||
void AddClickListener(TOnClickListener const & l);
|
||||
void RemoveClickListener();
|
||||
|
||||
void AddLongClickListener(TOnLongClickListener const & l);
|
||||
void RemoveLongClickListener();
|
||||
void AddBalloonClickListener(TOnBalloonClickListener const & l);
|
||||
void RemoveBalloonClickListener();
|
||||
|
||||
void DeactivatePopup();
|
||||
::Framework * NativeFramework();
|
||||
};
|
||||
}
|
||||
|
|
|
@ -12,46 +12,31 @@
|
|||
extern "C"
|
||||
{
|
||||
|
||||
void CallClickListener(shared_ptr<jobject> obj, jmethodID methodID, int x, int y)
|
||||
void CallBalloonClickListener(shared_ptr<jobject> obj, BookmarkAndCategory & bac)
|
||||
{
|
||||
jmethodID methodID = jni::GetJavaMethodID(jni::GetEnv(), *obj.get(), "onClick", "(II)V");
|
||||
if (methodID != 0)
|
||||
{
|
||||
jni::GetEnv()->CallVoidMethod(*obj.get(), methodID, x, y);
|
||||
jni::GetEnv()->CallVoidMethod(*obj.get(), methodID, bac.first, bac.second);
|
||||
}
|
||||
}
|
||||
|
||||
void CallLongClickListener(shared_ptr<jobject> obj, int x, int y)
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MWMActivity_setOnPopupClickListener(JNIEnv * env, jobject thiz, jobject l)
|
||||
{
|
||||
CallClickListener(obj, jni::GetJavaMethodID(jni::GetEnv(), *obj.get(), "onLongClick", "(II)V"), x, y);
|
||||
}
|
||||
|
||||
void CallShortClickListener(shared_ptr<jobject> obj, int x, int y)
|
||||
{
|
||||
CallClickListener(obj, jni::GetJavaMethodID(jni::GetEnv(), *obj.get(), "onClick", "(II)V"), x, y);
|
||||
return g_framework->AddBalloonClickListener(bind(&CallBalloonClickListener,jni::make_global_ref(l), _1));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MWMActivity_addOnLongClickListener(JNIEnv * env, jobject thiz, jobject l)
|
||||
Java_com_mapswithme_maps_MWMActivity_deactivatePopup(JNIEnv * env, jobject thiz)
|
||||
{
|
||||
return g_framework->AddLongClickListener(bind(&CallLongClickListener,jni::make_global_ref(l), _1, _2));
|
||||
return g_framework->DeactivatePopup();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MWMActivity_addOnClickListener(JNIEnv * env, jobject thiz, jobject l)
|
||||
Java_com_mapswithme_maps_MWMActivity_removeOnPopupClickListener()
|
||||
{
|
||||
return g_framework->AddClickListener(bind(&CallShortClickListener,jni::make_global_ref(l), _1, _2));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MWMActivity_removeOnLongClickListener()
|
||||
{
|
||||
g_framework->RemoveLongClickListener();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MWMActivity_removeOnClickListener()
|
||||
{
|
||||
g_framework->RemoveClickListener();
|
||||
g_framework->RemoveBalloonClickListener();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
|
|
|
@ -11,38 +11,22 @@ import android.content.DialogInterface;
|
|||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Point;
|
||||
import android.location.Location;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceHolder.Callback;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mapswithme.maps.bookmarks.BookmarkActivity;
|
||||
import com.mapswithme.maps.bookmarks.BookmarkCategoriesActivity;
|
||||
import com.mapswithme.maps.bookmarks.PopupLayout;
|
||||
import com.mapswithme.maps.bookmarks.data.AddressInfo;
|
||||
import com.mapswithme.maps.bookmarks.data.Bookmark;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
|
||||
import com.mapswithme.maps.bookmarks.data.ParcelablePoint;
|
||||
import com.mapswithme.maps.bookmarks.data.ParcelablePointD;
|
||||
import com.mapswithme.maps.location.LocationService;
|
||||
import com.mapswithme.maps.settings.UnitLocale;
|
||||
import com.mapswithme.util.ConnectionState;
|
||||
|
@ -60,26 +44,18 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
|
|||
private MWMApplication mApplication = null;
|
||||
private BroadcastReceiver m_externalStorageReceiver = null;
|
||||
private AlertDialog m_storageDisconnectedDialog = null;
|
||||
private BookmarkManager m_BookmarkManager;
|
||||
|
||||
//showDialog(int, Bundle) available only form API 8
|
||||
private String mProDialogMessage;
|
||||
|
||||
private interface OnLongClickListener
|
||||
private interface OnNativePopupClickListenter
|
||||
{
|
||||
void onLongClick(int x, int y);
|
||||
void onClick(int cat, int bmk);
|
||||
}
|
||||
|
||||
private interface OnClickListenter
|
||||
{
|
||||
void onClick(int x, int y);
|
||||
}
|
||||
|
||||
private native void addOnLongClickListener(Object l);
|
||||
private native void removeOnLongClickListener();
|
||||
|
||||
private native void addOnClickListener(Object l);
|
||||
private native void removeOnClickListener();
|
||||
private native void setOnPopupClickListener(Object l);
|
||||
private native void removeOnPopupClickListener();
|
||||
private native void deactivatePopup();
|
||||
|
||||
private LocationService getLocationService()
|
||||
{
|
||||
|
@ -308,7 +284,6 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
|
|||
|
||||
private boolean m_needCheckUpdate = true;
|
||||
|
||||
private PopupLayout m_popupLayout;
|
||||
|
||||
private void checkUpdateMaps()
|
||||
{
|
||||
|
@ -453,6 +428,7 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
|
|||
runOnUiThread(new Runnable()
|
||||
{
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
|
@ -560,122 +536,30 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
|
|||
|
||||
alignZoomButtons();
|
||||
|
||||
BookmarkTouchHandler handler = new BookmarkTouchHandler(m_popupLayout = (PopupLayout)findViewById(R.id.map_popup));
|
||||
m_BookmarkManager = BookmarkManager.getBookmarkManager(getApplicationContext());
|
||||
addOnLongClickListener(handler);
|
||||
addOnClickListener(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart()
|
||||
{
|
||||
super.onStart();
|
||||
if (getIntent().hasExtra(SearchActivity.SEARCH_RESULT))
|
||||
setOnPopupClickListener(new OnNativePopupClickListenter()
|
||||
{
|
||||
m_popupLayout.activate(m_BookmarkManager.previewBookmark((AddressInfo)getIntent().getParcelableExtra(SearchActivity.SEARCH_RESULT)),
|
||||
getWindowManager());
|
||||
getIntent().removeExtra(SearchActivity.SEARCH_RESULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(int cat, int bmk)
|
||||
{
|
||||
startActivity(
|
||||
new Intent(MWMActivity.this, BookmarkActivity.class)
|
||||
.putExtra(
|
||||
BookmarkActivity.PIN,
|
||||
new ParcelablePoint(cat, bmk
|
||||
)
|
||||
));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
if (m_popupLayout != null)
|
||||
{
|
||||
m_popupLayout.deactivate();
|
||||
}
|
||||
deactivatePopup();
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
private class BookmarkTouchHandler implements OnClickListenter, OnLongClickListener
|
||||
{
|
||||
private PopupLayout m_PopupLayout;
|
||||
|
||||
BookmarkTouchHandler(PopupLayout pop)
|
||||
{
|
||||
m_PopupLayout = pop;
|
||||
}
|
||||
@Override
|
||||
public void onLongClick(int x, int y)
|
||||
{
|
||||
handleOnSmthClick(x, y, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(final int x, final int y)
|
||||
{
|
||||
if (m_popupLayout.isActive())
|
||||
{
|
||||
if(!m_PopupLayout.handleClick(x, y, mApplication.isProVersion()))
|
||||
{
|
||||
if (mApplication.isProVersion())
|
||||
{
|
||||
handleOnSmthClick(x, y, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!mApplication.isProVersion())
|
||||
{
|
||||
showProVersionBanner(getString(R.string.bookmarks_in_pro_version));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
handleOnSmthClick(x, y, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean handleOnSmthClick(int x, int y, boolean longClick)
|
||||
{
|
||||
ParcelablePoint b = m_BookmarkManager.findBookmark(new ParcelablePointD(x, y));
|
||||
if (b != null)
|
||||
{
|
||||
m_PopupLayout.activate(m_BookmarkManager.getBookmark(b.getPoint().x, b.getPoint().y), getWindowManager());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
AddressInfo info = null;
|
||||
if ((info = m_BookmarkManager.getPOI(new ParcelablePointD(x, y))) != null)
|
||||
{
|
||||
m_PopupLayout.activate(m_BookmarkManager.previewBookmark(info), getWindowManager());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if (longClick)
|
||||
{
|
||||
info = m_BookmarkManager.getAddressInfo(new ParcelablePointD(x, y));
|
||||
m_PopupLayout.activate(m_BookmarkManager.previewBookmark(info), getWindowManager());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event)
|
||||
{
|
||||
m_popupLayout.requestInvalidation();
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy()
|
||||
{
|
||||
if (mApplication.isProVersion())
|
||||
removeOnLongClickListener();
|
||||
removeOnClickListener();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private void alignZoomButtons()
|
||||
{
|
||||
// Get screen density
|
||||
|
@ -839,7 +723,6 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
|
|||
startWatchingCompassStatusUpdate();
|
||||
|
||||
startWatchingExternalStorage();
|
||||
m_popupLayout.requestInvalidation();
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
|
|
|
@ -362,7 +362,7 @@ public class SearchActivity extends ListActivity implements LocationService.List
|
|||
}
|
||||
|
||||
/// Show tapped country or get suggestion or get category to search.
|
||||
public String onItemClick(int position, Intent mapIntent)
|
||||
public String onItemClick(int position)
|
||||
{
|
||||
if (isShowCategories())
|
||||
{
|
||||
|
@ -372,8 +372,6 @@ public class SearchActivity extends ListActivity implements LocationService.List
|
|||
}
|
||||
else
|
||||
{
|
||||
mapIntent.removeExtra(SEARCH_RESULT);
|
||||
|
||||
final SearchResult r = m_context.getResult(position, m_resultID);
|
||||
if (r != null)
|
||||
{
|
||||
|
@ -381,7 +379,6 @@ public class SearchActivity extends ListActivity implements LocationService.List
|
|||
{
|
||||
// show country and close activity
|
||||
SearchActivity.nativeShowItem(position);
|
||||
mapIntent.putExtra(SEARCH_RESULT, r.getAddressInfo());
|
||||
return null;
|
||||
}
|
||||
else
|
||||
|
@ -524,13 +521,10 @@ public class SearchActivity extends ListActivity implements LocationService.List
|
|||
protected void onListItemClick(ListView l, View v, int position, long id)
|
||||
{
|
||||
super.onListItemClick(l, v, position, id);
|
||||
|
||||
Intent mapIntent = new Intent(this, MWMActivity.class);
|
||||
mapIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
final String suggestion = getSA().onItemClick(position, mapIntent);
|
||||
final String suggestion = getSA().onItemClick(position);
|
||||
if (suggestion == null)
|
||||
{
|
||||
startActivity(mapIntent);
|
||||
finish();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -54,14 +54,7 @@ public class BookmarkActivity extends AbstractBookmarkActivity
|
|||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.pin);
|
||||
if (getIntent().getExtras().containsKey(BOOKMARK_POSITION))
|
||||
{
|
||||
// create new bookmark
|
||||
mPin = mManager.getBookmark(((ParcelablePointD)getIntent().getExtras().getParcelable(BOOKMARK_POSITION)));
|
||||
mPin.setName(getIntent().getExtras().getString(BOOKMARK_NAME));
|
||||
findViewById(R.id.pin_name).requestFocus();
|
||||
}
|
||||
else if (getIntent().getExtras().containsKey(PIN))
|
||||
if (getIntent().getExtras().containsKey(PIN))
|
||||
{
|
||||
Point mPinPair = ((ParcelablePoint)getIntent().getParcelableExtra(PIN)).getPoint();
|
||||
mCurrentCategoryId = mPinPair.x;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "../base/SRC_FIRST.hpp"
|
||||
#include "../base/SRC_FIRST.hpp"
|
||||
#include "straight_text_element.hpp"
|
||||
#include "overlay_renderer.hpp"
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "balloon.hpp"
|
||||
#include "balloon.hpp"
|
||||
#include "controller.hpp"
|
||||
|
||||
#include "../geometry/transformations.hpp"
|
||||
|
@ -108,45 +108,55 @@ namespace gui
|
|||
{
|
||||
m_textView->setIsDirtyLayout(true);
|
||||
m_imageView->setIsDirtyLayout(true);
|
||||
|
||||
m2::RectD tr = m_textView->roughBoundRect();
|
||||
m2::RectD ir = m_imageView->roughBoundRect();
|
||||
|
||||
double w = m_textMarginLeft + tr.SizeX() + m_textMarginRight
|
||||
+ m_imageMarginLeft + ir.SizeX() + m_imageMarginRight;
|
||||
double k = visualScale();
|
||||
double tml = m_textMarginLeft * k;
|
||||
double tmr = m_textMarginRight * k;
|
||||
double tmt = m_textMarginTop * k;
|
||||
double tmb = m_textMarginBottom * k;
|
||||
|
||||
double h = max(ir.SizeY() + m_imageMarginBottom + m_imageMarginTop,
|
||||
tr.SizeY() + m_textMarginBottom + m_textMarginTop);
|
||||
double iml = m_imageMarginLeft * k;
|
||||
double imr = m_imageMarginRight * k;
|
||||
double imt = m_imageMarginTop * k;
|
||||
double imb = m_imageMarginBottom * k;
|
||||
|
||||
double w = tml + tr.SizeX() + tmr
|
||||
+ iml + ir.SizeX() + imr;
|
||||
|
||||
double h = max(ir.SizeY() + imb + imt,
|
||||
tr.SizeY() + tmb + tmt);
|
||||
|
||||
m2::PointD const & pv = pivot();
|
||||
graphics::EPosition pos = position();
|
||||
|
||||
if (pos == graphics::EPosAbove)
|
||||
{
|
||||
m_textView->setPivot(m2::PointD(pv.x - w / 2 + m_textMarginLeft,
|
||||
m_textView->setPivot(m2::PointD(pv.x - w / 2 + tml,
|
||||
pv.y - h / 2 - m_arrowHeight));
|
||||
m_imageView->setPivot(m2::PointD(pv.x + w / 2 - m_imageMarginRight - ir.SizeX(),
|
||||
m_imageView->setPivot(m2::PointD(pv.x + w / 2 - imr - ir.SizeX(),
|
||||
pv.y - h / 2 - m_arrowHeight));
|
||||
}
|
||||
else if (pos == graphics::EPosUnder)
|
||||
{
|
||||
m_textView->setPivot(m2::PointD(pv.x - w / 2 + m_textMarginLeft,
|
||||
m_textView->setPivot(m2::PointD(pv.x - w / 2 + tml,
|
||||
pv.y + h / 2 + m_arrowHeight));
|
||||
m_imageView->setPivot(m2::PointD(pv.x + w / 2 - m_imageMarginRight - ir.SizeX(),
|
||||
m_imageView->setPivot(m2::PointD(pv.x + w / 2 - imr - ir.SizeX(),
|
||||
pv.y + h / 2 + m_arrowHeight));
|
||||
}
|
||||
else if (pos == graphics::EPosLeft)
|
||||
{
|
||||
m_textView->setPivot(m2::PointD(pv.x - w - m_arrowHeight + m_textMarginLeft,
|
||||
m_textView->setPivot(m2::PointD(pv.x - w - m_arrowHeight + tml,
|
||||
pv.y));
|
||||
m_imageView->setPivot(m2::PointD(pv.x - m_arrowHeight - m_imageMarginRight - ir.SizeX(),
|
||||
m_imageView->setPivot(m2::PointD(pv.x - m_arrowHeight - imr - ir.SizeX(),
|
||||
pv.y));
|
||||
}
|
||||
else if (pos == graphics::EPosRight)
|
||||
{
|
||||
m_textView->setPivot(m2::PointD(pv.x + m_arrowHeight + m_textMarginLeft,
|
||||
m_textView->setPivot(m2::PointD(pv.x + m_arrowHeight + tml,
|
||||
pv.y));
|
||||
m_imageView->setPivot(m2::PointD(pv.x + m_arrowHeight + m_textMarginLeft + tr.SizeX() + m_textMarginRight + m_imageMarginRight,
|
||||
m_imageView->setPivot(m2::PointD(pv.x + m_arrowHeight + tml + tr.SizeX() + tmr + imr,
|
||||
pv.y));
|
||||
}
|
||||
|
||||
|
@ -250,11 +260,6 @@ namespace gui
|
|||
|
||||
m_textView->draw(r, m);
|
||||
m_imageView->draw(r, m);
|
||||
|
||||
m2::RectD r1(pivot() * m, pivot() * m);
|
||||
r1.Inflate(2, 2);
|
||||
|
||||
r->drawRectangle(r1, graphics::Color(255, 0, 0, 255), graphics::maxDepth);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ HEADERS += \
|
|||
button.hpp \
|
||||
text_view.hpp \
|
||||
balloon.hpp \
|
||||
image_view.hpp
|
||||
image_view.hpp \
|
||||
|
||||
SOURCES += \
|
||||
controller.cpp \
|
||||
|
|
45
map/bookmark_balloon.cpp
Normal file
45
map/bookmark_balloon.cpp
Normal file
|
@ -0,0 +1,45 @@
|
|||
#include "bookmark_balloon.hpp"
|
||||
#include "framework.hpp"
|
||||
|
||||
#define POPUP_PADDING 23
|
||||
|
||||
namespace gui
|
||||
{
|
||||
BookmarkBalloon::BookmarkBalloon(Params const & p, Framework * framework)
|
||||
: Balloon(p),
|
||||
m_framework(framework)
|
||||
{
|
||||
}
|
||||
|
||||
void BookmarkBalloon::update()
|
||||
{
|
||||
Balloon::update();
|
||||
if (isVisible())
|
||||
{
|
||||
m2::PointD newPivot(m_framework->GtoP(m_bookmarkPivot));
|
||||
newPivot.y -= POPUP_PADDING * visualScale();
|
||||
setPivot(newPivot);
|
||||
}
|
||||
}
|
||||
|
||||
void BookmarkBalloon::setBookmarkPivot(m2::PointD const & pivot)
|
||||
{
|
||||
m_bookmarkPivot = pivot;
|
||||
}
|
||||
|
||||
m2::PointD const BookmarkBalloon::getBookmarkPivot()
|
||||
{
|
||||
return m_bookmarkPivot;
|
||||
}
|
||||
|
||||
void BookmarkBalloon::setBookmarkName(std::string const & name)
|
||||
{
|
||||
m_bookmarkName = name;
|
||||
setText(name);//.substr(0, 13));
|
||||
}
|
||||
|
||||
std::string const BookmarkBalloon::getBookmarkName()
|
||||
{
|
||||
return m_bookmarkName;
|
||||
}
|
||||
}
|
23
map/bookmark_balloon.hpp
Normal file
23
map/bookmark_balloon.hpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
|
||||
#include "../gui/balloon.hpp"
|
||||
|
||||
class Framework;
|
||||
|
||||
namespace gui
|
||||
{
|
||||
class BookmarkBalloon : public Balloon
|
||||
{
|
||||
private:
|
||||
void update();
|
||||
m2::PointD m_bookmarkPivot;
|
||||
Framework * m_framework;
|
||||
std::string m_bookmarkName;
|
||||
public:
|
||||
BookmarkBalloon(Params const & p, Framework * framework);
|
||||
void setBookmarkPivot(m2::PointD const & pivot);
|
||||
m2::PointD const getBookmarkPivot();
|
||||
void setBookmarkName(std::string const & name);
|
||||
std::string const getBookmarkName();
|
||||
};
|
||||
}
|
|
@ -156,6 +156,11 @@ CountryStatusDisplay * Framework::GetCountryStatusDisplay() const
|
|||
return m_informationDisplay.countryStatusDisplay().get();
|
||||
}
|
||||
|
||||
gui::BookmarkBalloon * Framework::GetBookmarkBalloon() const
|
||||
{
|
||||
return m_informationDisplay.bookmarkBalloon().get();
|
||||
}
|
||||
|
||||
static void GetResourcesMaps(vector<string> & outMaps)
|
||||
{
|
||||
Platform & pl = GetPlatform();
|
||||
|
@ -1585,3 +1590,8 @@ shared_ptr<location::State> const & Framework::GetLocationState() const
|
|||
{
|
||||
return m_informationDisplay.locationState();
|
||||
}
|
||||
|
||||
StringsBundle const & Framework::GetStringsBundle()
|
||||
{
|
||||
return m_stringsBundle;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,12 @@
|
|||
//#define DRAW_TOUCH_POINTS
|
||||
|
||||
namespace search { class Result; }
|
||||
namespace gui { class Controller; }
|
||||
|
||||
namespace gui
|
||||
{
|
||||
class Controller;
|
||||
class BookmarkBalloon;
|
||||
}
|
||||
namespace anim { class Controller; }
|
||||
|
||||
class CountryStatusDisplay;
|
||||
|
@ -234,6 +239,7 @@ public:
|
|||
|
||||
InformationDisplay & GetInformationDisplay();
|
||||
CountryStatusDisplay * GetCountryStatusDisplay() const;
|
||||
gui::BookmarkBalloon * GetBookmarkBalloon() const;
|
||||
|
||||
void PrepareToShutdown();
|
||||
|
||||
|
@ -422,6 +428,8 @@ public:
|
|||
|
||||
bool IsBenchmarking() const;
|
||||
|
||||
StringsBundle const & GetStringsBundle();
|
||||
|
||||
/// Checks, whether the country which contains
|
||||
/// the specified point is loaded
|
||||
bool IsCountryLoaded(m2::PointD const & pt) const;
|
||||
|
|
|
@ -75,6 +75,25 @@ InformationDisplay::InformationDisplay(Framework * framework)
|
|||
|
||||
m_locationState.reset(new location::State(lsp));
|
||||
|
||||
gui::Balloon::Params bp;
|
||||
|
||||
bp.m_position = graphics::EPosAbove;
|
||||
bp.m_depth = graphics::maxDepth;
|
||||
bp.m_pivot = m2::PointD(0, 0);
|
||||
bp.m_imageMarginBottom = 10;
|
||||
bp.m_imageMarginLeft = 10;
|
||||
bp.m_imageMarginRight = 10;
|
||||
bp.m_imageMarginTop = 10;
|
||||
bp.m_textMarginBottom = 10;
|
||||
bp.m_textMarginLeft = 10;
|
||||
bp.m_textMarginRight = 10;
|
||||
bp.m_textMarginTop = 10;
|
||||
bp.m_image = graphics::Image::Info("arrow.png");
|
||||
bp.m_text = "Bookmark";
|
||||
|
||||
m_bookmarkBalloon.reset(new gui::BookmarkBalloon(bp, framework));
|
||||
m_bookmarkBalloon->setIsVisible(false);
|
||||
|
||||
enableDebugPoints(false);
|
||||
enableRuler(false);
|
||||
enableCenter(false);
|
||||
|
@ -97,6 +116,7 @@ void InformationDisplay::setController(gui::Controller *controller)
|
|||
m_controller->AddElement(m_compassArrow);
|
||||
m_controller->AddElement(m_locationState);
|
||||
m_controller->AddElement(m_ruler);
|
||||
m_controller->AddElement(m_bookmarkBalloon);
|
||||
}
|
||||
|
||||
void InformationDisplay::setScreen(ScreenBase const & screen)
|
||||
|
@ -479,6 +499,11 @@ shared_ptr<CountryStatusDisplay> const & InformationDisplay::countryStatusDispla
|
|||
return m_countryStatusDisplay;
|
||||
}
|
||||
|
||||
shared_ptr<gui::BookmarkBalloon> const & InformationDisplay::bookmarkBalloon() const
|
||||
{
|
||||
return m_bookmarkBalloon;
|
||||
}
|
||||
|
||||
shared_ptr<location::State> const & InformationDisplay::locationState() const
|
||||
{
|
||||
return m_locationState;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "../storage/index.hpp"
|
||||
|
||||
#include "../gui/button.hpp"
|
||||
#include "../map/bookmark_balloon.hpp"
|
||||
|
||||
#include "../geometry/point2d.hpp"
|
||||
#include "../geometry/rect2d.hpp"
|
||||
|
@ -26,6 +27,7 @@ namespace gui
|
|||
{
|
||||
class Button;
|
||||
class Controller;
|
||||
class BookmarkBalloon;
|
||||
}
|
||||
|
||||
class Framework;
|
||||
|
@ -88,6 +90,7 @@ private:
|
|||
shared_ptr<CountryStatusDisplay> m_countryStatusDisplay;
|
||||
shared_ptr<CompassArrow> m_compassArrow;
|
||||
shared_ptr<location::State> m_locationState;
|
||||
shared_ptr<gui::BookmarkBalloon> m_bookmarkBalloon;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -141,6 +144,7 @@ public:
|
|||
void setEmptyCountryIndex(storage::TIndex const & idx);
|
||||
|
||||
shared_ptr<CountryStatusDisplay> const & countryStatusDisplay() const;
|
||||
shared_ptr<gui::BookmarkBalloon> const & bookmarkBalloon() const;
|
||||
shared_ptr<Ruler> const & ruler() const;
|
||||
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ HEADERS += \
|
|||
dialog_settings.hpp \
|
||||
mwm_url.hpp \
|
||||
feature_styler.hpp \
|
||||
bookmark_balloon.hpp \
|
||||
|
||||
SOURCES += \
|
||||
feature_vec_model.cpp \
|
||||
|
@ -93,6 +94,7 @@ SOURCES += \
|
|||
dialog_settings.cpp \
|
||||
mwm_url.cpp \
|
||||
feature_styler.cpp \
|
||||
bookmark_balloon.cpp \
|
||||
|
||||
!iphone*:!bada*:!android* {
|
||||
HEADERS += qgl_render_context.hpp
|
||||
|
|
Loading…
Add table
Reference in a new issue