Merge pull request #5761 from osmandapp/UiImprovements

Fix search and editing toasts
This commit is contained in:
Alexander Sytnyk 2018-08-01 14:15:22 +03:00 committed by GitHub
commit 07ed7d8b72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 11 deletions

View file

@ -237,7 +237,7 @@
android:paddingLeft="@dimen/bottom_sheet_content_margin"
android:paddingRight="@dimen/bottom_sheet_content_margin"
android:paddingTop="@dimen/context_menu_padding_margin_tiny"
android:text="@string/search_no_results_description"
android:text="@string/search_no_results_feedback"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium" />

View file

@ -11,6 +11,9 @@
Thx - Hardy
-->
<string name="thank_you_for_feedback">Thank you for feedback</string>
<string name="poi_cannot_be_found">Node or way cannot be found.</string>
<string name="search_no_results_feedback">No search results?\nGive us feedback</string>
<string name="release_3_1">
• Navigation: Fix progress bar, fast swapping of the start and end point of the route\n\n
• Map markers: fix turn on/off groups, ability to hide markers from the map\n\n
@ -23,7 +26,6 @@
<string name="increase_search_radius_to">Increase search radius to %1$s</string>
<string name="send_search_query_description"><![CDATA[We will send your search query: <b>\"%1$s\"</b>, as well as your location.<br/><br/>
We do not collect personal information, we only need search data to improve the search algorithm.<br/>]]></string>
<string name="search_no_results_description">No results?\nTell us about this.</string>
<string name="send_search_query">Send search query?</string>
<string name="shared_string_world">World</string>
<string name="point_deleted">Point %1$s deleted</string>
@ -2673,7 +2675,6 @@
<string name="favourites_remove_dialog_success">Favorite point {0} deleted.</string>
<string name="poi_edit_title">Edit POI</string>
<string name="poi_create_title">Create POI</string>
<string name="poi_error_poi_not_found">Node cannot be found, or amenity consists of several nodes, which is not yet supported.</string>
<string name="poi_remove_confirm_template">Delete {0} (comment)?</string>
<string name="poi_remove_title">Delete POI</string>
<string name="poi_remove_success">POI deleted</string>

View file

@ -707,7 +707,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
fragment.show(activity.getSupportFragmentManager(), TAG);
} else {
Toast.makeText(activity,
activity.getString(R.string.poi_error_poi_not_found),
activity.getString(R.string.poi_cannot_be_found),
Toast.LENGTH_LONG).show();
}
}
@ -777,7 +777,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
public void deletePoiWithDialog(final Entity entity) {
if (entity == null) {
Toast.makeText(activity, activity.getResources().getString(R.string.poi_error_poi_not_found), Toast.LENGTH_LONG).show();
Toast.makeText(activity, activity.getResources().getString(R.string.poi_cannot_be_found), Toast.LENGTH_LONG).show();
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(activity);

View file

@ -645,10 +645,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
if (!app.getSettings().isInternetConnectionAvailable()) {
Toast.makeText(app, R.string.internet_not_available, Toast.LENGTH_LONG).show();
} else {
if (location != null && searchQuery != null) {
if (searchQuery != null) {
Bundle args = new Bundle();
SendSearchQueryBottomSheet fragment = new SendSearchQueryBottomSheet();
args.putString(MISSING_SEARCH_LOCATION_KEY, location.toString());
args.putString(MISSING_SEARCH_LOCATION_KEY, String.valueOf(location));
args.putString(MISSING_SEARCH_QUERY_KEY, searchQuery);
fragment.setArguments(args);
fragment.show(mapActivity.getSupportFragmentManager(), SendSearchQueryBottomSheet.TAG);

View file

@ -17,6 +17,10 @@ import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import net.osmand.util.Algorithms;
import org.json.JSONException;
import org.json.JSONObject;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
@ -37,7 +41,7 @@ public class SendSearchQueryBottomSheet extends MenuBottomSheetDialogFragment {
}
String searchQuery = args.getString(MISSING_SEARCH_QUERY_KEY);
String searchLocation = args.getString(MISSING_SEARCH_LOCATION_KEY);
if (Algorithms.isEmpty(searchQuery) || Algorithms.isEmpty(searchLocation)) {
if (Algorithms.isEmpty(searchQuery)) {
return;
}
params.put(searchQuery, searchLocation);
@ -63,15 +67,32 @@ public class SendSearchQueryBottomSheet extends MenuBottomSheetDialogFragment {
@Override
protected void onRightBottomButtonClick() {
OsmandApplication app = getMyApplication();
final OsmandApplication app = getMyApplication();
if (app != null) {
if (!app.getSettings().isInternetConnectionAvailable()) {
Toast.makeText(app, R.string.internet_not_available, Toast.LENGTH_LONG).show();
dismiss();
} else {
AndroidNetworkUtils.sendRequestAsync(app, "http://osmand.net/api/missing_search", params,
null, true, true, null);
null, true, true, new AndroidNetworkUtils.OnRequestResultListener() {
@Override
public void onResult(String result) {
if (result != null && isAdded()) {
try {
JSONObject obj = new JSONObject(result);
if (!obj.has("error")) {
Toast.makeText(app, getString(R.string.thank_you_for_feedback), Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(app, MessageFormat.format(getString(R.string.error_message_pattern), obj.getString("error")), Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
}
}
dismiss();
}
});
}
}
}
}