forked from organicmaps/organicmaps
[android] Experimental: add additional toolbar for search mode.
This commit is contained in:
parent
0f7ff1ad69
commit
f8c4eefed5
6 changed files with 113 additions and 17 deletions
|
@ -184,13 +184,16 @@ Java_com_mapswithme_maps_SearchActivity_nativeFinishSearch(JNIEnv * env, jobject
|
|||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_mapswithme_maps_SearchActivity_nativeRunSearch(
|
||||
JNIEnv * env, jobject thiz,
|
||||
jstring s, jstring lang, jdouble lat, jdouble lon, jint flags, jint queryID)
|
||||
JNIEnv * env, jobject thiz, jstring s, jstring lang,
|
||||
jdouble lat, jdouble lon, jint flags, jint searchMode, jint queryID)
|
||||
{
|
||||
search::SearchParams params;
|
||||
|
||||
params.m_query = jni::ToNativeString(env, s);
|
||||
params.SetInputLanguage(jni::ToNativeString(env, lang));
|
||||
|
||||
params.SetSearchMode(searchMode);
|
||||
|
||||
if ((flags & 1) == 0) params.SetForceSearch(true);
|
||||
if ((flags & 2) != 0) params.SetPosition(lat, lon);
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:weightSum="6.0">
|
||||
|
||||
<ImageButton android:id="@+id/search_food"
|
||||
<ImageButton
|
||||
android:layout_weight="1.0"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -41,48 +41,81 @@
|
|||
android:background="@drawable/ltgray_button"
|
||||
android:onClick="onSearchFood"/>
|
||||
|
||||
<ImageButton android:id="@+id/search_money"
|
||||
<ImageButton
|
||||
android:layout_weight="1.0"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/money"
|
||||
android:background="@drawable/ltgray_button"
|
||||
android:background="@drawable/ltgray_button"
|
||||
android:onClick="onSearchMoney"/>
|
||||
|
||||
<ImageButton android:id="@+id/search_fuel"
|
||||
<ImageButton
|
||||
android:layout_weight="1.0"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/fuel"
|
||||
android:background="@drawable/ltgray_button"
|
||||
android:background="@drawable/ltgray_button"
|
||||
android:onClick="onSearchFuel"/>
|
||||
|
||||
<ImageButton android:id="@+id/search_shop"
|
||||
<ImageButton
|
||||
android:layout_weight="1.0"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/shop"
|
||||
android:background="@drawable/ltgray_button"
|
||||
android:background="@drawable/ltgray_button"
|
||||
android:onClick="onSearchShop"/>
|
||||
|
||||
<ImageButton android:id="@+id/search_transport"
|
||||
<ImageButton
|
||||
android:layout_weight="1.0"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/transport"
|
||||
android:background="@drawable/ltgray_button"
|
||||
android:background="@drawable/ltgray_button"
|
||||
android:onClick="onSearchTransport"/>
|
||||
|
||||
<ImageButton android:id="@+id/search_tourism"
|
||||
<ImageButton
|
||||
android:layout_weight="1.0"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/tourism"
|
||||
android:background="@drawable/ltgray_button"
|
||||
android:background="@drawable/ltgray_button"
|
||||
android:onClick="onSearchTourism"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout android:id="@+id/search_mode_toolbar"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:weightSum="3.0">
|
||||
|
||||
<Button
|
||||
android:layout_weight="1.0"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/search_mode_all"
|
||||
android:background="@drawable/ltgray_button"
|
||||
android:onClick="onSearchModeAll"/>
|
||||
|
||||
<Button
|
||||
android:layout_weight="1.0"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/search_mode_nearme"
|
||||
android:background="@drawable/ltgray_button"
|
||||
android:onClick="onSearchModeNearMe"/>
|
||||
|
||||
<Button
|
||||
android:layout_weight="1.0"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/search_mode_viewport"
|
||||
android:background="@drawable/ltgray_button"
|
||||
android:onClick="onSearchModeViewport"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ListView android:id="@android:id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
|
|
|
@ -210,4 +210,10 @@
|
|||
<string name="measurement_units">Единицы измерения</string>
|
||||
<!-- Detailed description of Measurement Units settings button -->
|
||||
<string name="measurement_units_summary">Использовать километры или мили</string>
|
||||
<!-- Do search in all sources -->
|
||||
<string name="search_mode_all">Везде</string>
|
||||
<!-- Do search near my position only -->
|
||||
<string name="search_mode_nearme">Около меня</string>
|
||||
<!-- Do search in current viewport only -->
|
||||
<string name="search_mode_viewport">В текущем экране</string>
|
||||
</resources>
|
||||
|
|
|
@ -214,4 +214,10 @@
|
|||
<string name="measurement_units">Measurement Units</string>
|
||||
<!-- Detailed description of Measurement Units settings button -->
|
||||
<string name="measurement_units_summary">Choose between miles and kilometres</string>
|
||||
<!-- Do search in all sources -->
|
||||
<string name="search_mode_all">All</string>
|
||||
<!-- Do search near my position only -->
|
||||
<string name="search_mode_nearme">Near me</string>
|
||||
<!-- Do search in current viewport only -->
|
||||
<string name="search_mode_viewport">In current viewport</string>
|
||||
</resources>
|
||||
|
|
|
@ -229,6 +229,11 @@ public class SearchActivity extends ListActivity implements LocationService.List
|
|||
return (LinearLayout) findViewById(R.id.search_toolbar);
|
||||
}
|
||||
|
||||
private LinearLayout getModeToolbar()
|
||||
{
|
||||
return (LinearLayout) findViewById(R.id.search_mode_toolbar);
|
||||
}
|
||||
|
||||
private String getSearchString()
|
||||
{
|
||||
final String s = getSearchBox().getText().toString();
|
||||
|
@ -408,7 +413,7 @@ public class SearchActivity extends ListActivity implements LocationService.List
|
|||
});
|
||||
}
|
||||
|
||||
/// @name Amenity buttons listeners
|
||||
/// @name Amenity buttons listeners.
|
||||
//@{
|
||||
public void onSearchFood(View v) { runSearch("food "); }
|
||||
public void onSearchMoney(View v) { runSearch("money "); }
|
||||
|
@ -418,6 +423,13 @@ public class SearchActivity extends ListActivity implements LocationService.List
|
|||
public void onSearchTourism(View v) { runSearch("tourism "); }
|
||||
//@}
|
||||
|
||||
/// @name Search mode buttons listeners.
|
||||
//@{
|
||||
public void onSearchModeAll(View v) { runSearch(ALL); }
|
||||
public void onSearchModeNearMe(View v) { runSearch(AROUND_POSITION); }
|
||||
public void onSearchModeViewport(View v) { runSearch(IN_VIEWPORT); }
|
||||
//@}
|
||||
|
||||
private void runSearch(String s)
|
||||
{
|
||||
EditText box = getSearchBox();
|
||||
|
@ -429,6 +441,21 @@ public class SearchActivity extends ListActivity implements LocationService.List
|
|||
box.setSelection(s.length());
|
||||
}
|
||||
|
||||
/// @name This constants should be equal with search.params.hpp
|
||||
//@{
|
||||
private static final int AROUND_POSITION = 1;
|
||||
private static final int IN_VIEWPORT = 2;
|
||||
private static final int SEARCH_WORLD = 4;
|
||||
private static final int ALL = AROUND_POSITION | IN_VIEWPORT | SEARCH_WORLD;
|
||||
//@}
|
||||
private int m_searchMode = ALL;
|
||||
|
||||
private void runSearch(int mode)
|
||||
{
|
||||
m_searchMode = mode;
|
||||
runSearch();
|
||||
}
|
||||
|
||||
private void runSearch()
|
||||
{
|
||||
// TODO Need to get input language
|
||||
|
@ -438,7 +465,7 @@ public class SearchActivity extends ListActivity implements LocationService.List
|
|||
final String s = getSearchString();
|
||||
|
||||
final int id = m_queryID + QUERY_STEP;
|
||||
if (nativeRunSearch(s, lang, m_lat, m_lon, m_flags, id))
|
||||
if (nativeRunSearch(s, lang, m_lat, m_lon, m_flags, m_searchMode, id))
|
||||
{
|
||||
// store current query
|
||||
m_queryID = id;
|
||||
|
@ -448,8 +475,13 @@ public class SearchActivity extends ListActivity implements LocationService.List
|
|||
m_flags |= NOT_FIRST_QUERY;
|
||||
|
||||
// set toolbar visible only for empty search string
|
||||
final boolean emptyQuery = s.length() == 0;
|
||||
|
||||
LinearLayout bar = getSearchToolbar();
|
||||
bar.setVisibility(s.length() == 0 ? View.VISIBLE : View.GONE);
|
||||
bar.setVisibility(emptyQuery ? View.VISIBLE : View.GONE);
|
||||
|
||||
bar = getModeToolbar();
|
||||
bar.setVisibility(emptyQuery ? View.GONE : View.VISIBLE);
|
||||
|
||||
// show search progress
|
||||
m_progress.setVisibility(View.VISIBLE);
|
||||
|
@ -468,6 +500,7 @@ public class SearchActivity extends ListActivity implements LocationService.List
|
|||
nativeGetResult(int position, int queryID, double lat, double lon, boolean mode, double north);
|
||||
|
||||
private native boolean nativeRunSearch(String s, String lang,
|
||||
double lat, double lon, int mode, int queryID);
|
||||
double lat, double lon, int flags,
|
||||
int searchMode, int queryID);
|
||||
private static native void nativeShowItem(int position);
|
||||
}
|
||||
|
|
15
strings.txt
15
strings.txt
|
@ -1360,3 +1360,18 @@
|
|||
ko = 마일과 킬로미터 중에서 선택하십시오
|
||||
cs = Vyberte míle nebo kilometry
|
||||
nl = Kies tussen mijlen en kilometers
|
||||
[search_mode_all]
|
||||
en = All
|
||||
tags = ios, android
|
||||
comment = Do search in all sources
|
||||
ru = Везде
|
||||
[search_mode_nearme]
|
||||
en = Near me
|
||||
tags = ios, android
|
||||
comment = Do search near my position only
|
||||
ru = Около меня
|
||||
[search_mode_viewport]
|
||||
en = In current viewport
|
||||
tags = ios, android
|
||||
comment = Do search in current viewport only
|
||||
ru = В текущем экране
|
||||
|
|
Loading…
Add table
Reference in a new issue