Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-08-05 20:25:00 +02:00
commit a24744e4e1
8 changed files with 249 additions and 103 deletions

View file

@ -349,7 +349,7 @@
</FrameLayout>
<FrameLayout
android:id="@+id/search_topbar"
android:id="@+id/custom_topbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
@ -361,14 +361,14 @@
android:orientation="vertical">
<LinearLayout
android:id="@+id/search_topbar_layout"
android:id="@+id/custom_topbar_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/dashboard_map_toolbar"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageButton
android:id="@+id/search_back_button"
android:id="@+id/custom_back_button"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="54dp"
android:layout_height="48dp"
@ -376,7 +376,7 @@
android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha"/>
<TextView
android:id="@+id/search_title"
android:id="@+id/custom_title"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
@ -387,11 +387,10 @@
android:lines="1"
android:ellipsize="end"
android:singleLine="true"
android:text="Search"
android:textSize="@dimen/abc_text_size_medium_material"/>
<ImageButton
android:id="@+id/search_close_button"
android:id="@+id/custom_close_button"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="48dp"
android:layout_height="48dp"

View file

@ -147,7 +147,7 @@
</FrameLayout>
<FrameLayout
android:id="@+id/search_topbar"
android:id="@+id/custom_topbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
@ -159,14 +159,14 @@
android:orientation="vertical">
<LinearLayout
android:id="@+id/search_topbar_layout"
android:id="@+id/custom_topbar_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/dashboard_map_toolbar"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageButton
android:id="@+id/search_back_button"
android:id="@+id/custom_back_button"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="54dp"
android:layout_height="48dp"
@ -174,7 +174,7 @@
android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha"/>
<TextView
android:id="@+id/search_title"
android:id="@+id/custom_title"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
@ -185,11 +185,10 @@
android:lines="1"
android:ellipsize="end"
android:singleLine="true"
android:text="Toolbar text"
android:textSize="@dimen/abc_text_size_medium_material"/>
<ImageButton
android:id="@+id/search_close_button"
android:id="@+id/custom_close_button"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="48dp"
android:layout_height="48dp"
@ -199,7 +198,7 @@
</LinearLayout>
<FrameLayout
android:id="@+id/search_topbar_shadow"
android:id="@+id/custom_topbar_shadow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="@drawable/bg_contextmenu_shadow"

View file

@ -54,7 +54,6 @@ import net.osmand.plus.AppInitializer;
import net.osmand.plus.AppInitializer.AppInitializeListener;
import net.osmand.plus.AppInitializer.InitEvents;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.BusyIndicator;
import net.osmand.plus.FirstUsageFragment;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
@ -92,11 +91,13 @@ import net.osmand.plus.routing.RoutingHelper.RouteCalculationProgressCallback;
import net.osmand.plus.search.QuickSearchDialogFragment;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.MapControlsLayer;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmAndMapLayersView;
import net.osmand.plus.views.OsmAndMapSurfaceView;
import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.corenative.NativeCoreContext;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarViewController;
import net.osmand.render.RenderingRulesStorage;
import net.osmand.util.Algorithms;
@ -168,7 +169,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
private boolean permissionGranted;
private boolean mIsDestroyed = false;
private boolean quickSearchTopbarActive = false;
private boolean topToolbarActive = false;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -1390,11 +1391,20 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
return fragment!= null && !fragment.isDetached() && !fragment.isRemoving() ? (QuickSearchDialogFragment) fragment : null;
}
public boolean isQuickSearchTopbarActive() {
return quickSearchTopbarActive && getQuickSearchDialogFragment() != null;
public boolean isTopToolbarActive() {
MapInfoLayer mapInfoLayer = getMapLayers().getMapInfoLayer();
return mapInfoLayer.hasTopToolbar();
}
public void setQuickSearchTopbarActive(boolean quickSearchTopbarActive) {
this.quickSearchTopbarActive = quickSearchTopbarActive;
public void showTopToolbar(TopToolbarViewController viewController) {
MapInfoLayer mapInfoLayer = getMapLayers().getMapInfoLayer();
mapInfoLayer.addTopToolbarViewController(viewController);
this.topToolbarActive = mapInfoLayer.hasTopToolbar();
}
public void hideTopToolbar(TopToolbarViewController viewController) {
MapInfoLayer mapInfoLayer = getMapLayers().getMapInfoLayer();
mapInfoLayer.removeTopToolbarViewController(viewController);
this.topToolbarActive = mapInfoLayer.hasTopToolbar();
}
}

View file

@ -1,45 +1,5 @@
package net.osmand.plus.search;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.osmand.AndroidUtils;
import net.osmand.Location;
import net.osmand.OsmAndCollator;
import net.osmand.ResultMatcher;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.osm.AbstractPoiType;
import net.osmand.plus.AppInitializer;
import net.osmand.plus.AppInitializer.AppInitializeListener;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.LockableViewPager;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.SearchHistoryHelper;
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.search.QuickSearchHelper.SearchHistoryAPI;
import net.osmand.search.SearchUICore;
import net.osmand.search.SearchUICore.SearchResultCollection;
import net.osmand.search.core.ObjectType;
import net.osmand.search.core.SearchCoreAPI;
import net.osmand.search.core.SearchCoreFactory.SearchAmenityTypesAPI;
import net.osmand.search.core.SearchPhrase;
import net.osmand.search.core.SearchResult;
import net.osmand.search.core.SearchSettings;
import net.osmand.search.core.SearchWord;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.DialogInterface;
@ -74,6 +34,48 @@ import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.Location;
import net.osmand.ResultMatcher;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.osm.AbstractPoiType;
import net.osmand.plus.AppInitializer;
import net.osmand.plus.AppInitializer.AppInitializeListener;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.LockableViewPager;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.SearchHistoryHelper;
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.search.QuickSearchHelper.SearchHistoryAPI;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarView;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarViewController;
import net.osmand.search.SearchUICore;
import net.osmand.search.SearchUICore.SearchResultCollection;
import net.osmand.search.core.ObjectType;
import net.osmand.search.core.SearchCoreAPI;
import net.osmand.search.core.SearchCoreFactory.SearchAmenityTypesAPI;
import net.osmand.search.core.SearchPhrase;
import net.osmand.search.core.SearchResult;
import net.osmand.search.core.SearchSettings;
import net.osmand.search.core.SearchWord;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class QuickSearchDialogFragment extends DialogFragment implements OsmAndCompassListener, OsmAndLocationListener {
public static final String TAG = "QuickSearchDialogFragment";
@ -95,6 +97,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
private QuickSearchMainListFragment mainSearchFragment;
private QuickSearchHistoryListFragment historySearchFragment;
private QuickSearchCategoriesListFragment categoriesSearchFragment;
private QuickSearchToolbarController toolbarController = new QuickSearchToolbarController();
private Toolbar toolbarEdit;
private TextView titleEdit;
@ -197,7 +200,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
}
app.getPoiFilters().clearSelectedPoiFilters();
app.getPoiFilters().addSelectedPoiFilter(filter);
getMapActivity().setQuickSearchTopbarActive(true);
showToolbar();
getMapActivity().refreshMap();
hide();
} else {
@ -211,7 +214,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
searchResult.location.getLatitude(), searchResult.location.getLongitude(),
searchResult.preferredZoom, pointDescription, true, searchResult.object);
getMapActivity().setQuickSearchTopbarActive(true);
showToolbar();
MapActivity.launchMapActivityMoveToTop(getActivity());
hide();
}
@ -382,6 +385,15 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
}
}
public void showToolbar() {
toolbarController.setTitle(getText());
getMapActivity().showTopToolbar(toolbarController);
}
public void hideToolbar() {
getMapActivity().hideTopToolbar(toolbarController);
}
public String getText() {
return searchEditText.getText().toString();
}
@ -393,7 +405,6 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
}
public void show() {
getMapActivity().setQuickSearchTopbarActive(false);
if (useMapCenter) {
LatLon mapCenter = getMapActivity().getMapView().getCurrentRotatedTileBox().getCenterLatLon();
SearchSettings ss = searchUICore.getSearchSettings().setOriginalLocation(
@ -527,7 +538,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
public void onDismiss(DialogInterface dialog) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
getMapActivity().setQuickSearchTopbarActive(false);
hideToolbar();
getChildFragmentManager().popBackStack();
}
super.onDismiss(dialog);
@ -1191,4 +1202,26 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
return SearchListFragmentType.MAIN;
}
}
public static class QuickSearchToolbarController extends TopToolbarViewController {
public QuickSearchToolbarController() {
super(TopToolbarViewController.TopToolbarViewControllerType.QUICK_SEARCH);
}
@Override
public void onBackPressed(TopToolbarView view) {
view.getMap().showQuickSearch(false, false);
}
@Override
public void onTitlePressed(TopToolbarView view) {
view.getMap().showQuickSearch(false, false);
}
@Override
public void onClosePressed(TopToolbarView view) {
view.getMap().closeQuickSearch();
}
}
}

View file

@ -220,10 +220,11 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
pointDescription = wpt.getPointDescription(getMyApplication());
break;
}
getMapActivity().setQuickSearchTopbarActive(showTopbar);
if (showTopbar) {
dialogFragment.showToolbar();
dialogFragment.hide();
} else {
dialogFragment.hideToolbar();
dialogFragment.dismiss();
}
getMyApplication().getSettings().setMapLocationToShow(

View file

@ -19,6 +19,7 @@ import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarView;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopTextView;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarViewController;
import net.osmand.plus.views.mapwidgets.MapMarkersWidgetsFactory;
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.MapWidgetRegInfo;
@ -99,7 +100,19 @@ public class MapInfoLayer extends OsmandMapLayer {
public void removeSideWidget(TextInfoWidget widget) {
mapInfoControls.removeSideWidgetInternal(widget);
}
public void addTopToolbarViewController(TopToolbarViewController viewController) {
topToolbarView.addViewController(viewController);
}
public void removeTopToolbarViewController(TopToolbarViewController viewController) {
topToolbarView.removeViewController(viewController);
}
public boolean hasTopToolbar() {
return topToolbarView.getTopViewController() != null;
}
public void registerAllControls(){
RouteInfoWidgetsFactory ric = new RouteInfoWidgetsFactory();
MapInfoWidgetsFactory mic = new MapInfoWidgetsFactory();

View file

@ -29,15 +29,16 @@ import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.helpers.WaypointDialogHelper;
import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.routing.RouteDirectionInfo;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.search.QuickSearchDialogFragment;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
import net.osmand.plus.views.mapwidgets.NextTurnInfoWidget.TurnDrawable;
import net.osmand.router.TurnType;
import java.util.LinkedList;
public class MapInfoWidgetsFactory {
public TextInfoWidget createAltitudeControl(final MapActivity map) {
@ -162,57 +163,144 @@ public class MapInfoWidgetsFactory {
}
public static abstract class TopToolbarViewController {
public abstract void updateInfo();
private TopToolbarViewControllerType type;
private int backButtonIconId = R.drawable.abc_ic_ab_back_mtrl_am_alpha;
private int closeButtonIconId = R.drawable.ic_action_remove_dark;
private String title = "";
public enum TopToolbarViewControllerType {
QUICK_SEARCH,
CONTEXT_MENU
}
public TopToolbarViewController(TopToolbarViewControllerType type) {
this.type = type;
}
public TopToolbarViewControllerType getType() {
return type;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public int getBackButtonIconId() {
return backButtonIconId;
}
public int getCloseButtonIconId() {
return closeButtonIconId;
}
public void updateToolbar(TopToolbarView view) {
view.getTitleView().setText(title);
}
public abstract void onBackPressed(TopToolbarView view);
public abstract void onTitlePressed(TopToolbarView view);
public abstract void onClosePressed(TopToolbarView view);
}
public static class TopToolbarView {
private final MapActivity map;
private TopToolbarViewController toolbarController;
private View searchTopBar;
private View searchTopBarLayout;
private ImageButton searchBackButton;
private TextView searchTitle;
private ImageButton searchCloseButton;
private LinkedList<TopToolbarViewController> viewControllers = new LinkedList<>();
private View topbar;
private View topBarLayout;
private ImageButton backButton;
private TextView titleView;
private ImageButton closeButton;
public TopToolbarView(final MapActivity map) {
this.map = map;
searchTopBar = map.findViewById(R.id.search_topbar);
searchTopBarLayout = map.findViewById(R.id.search_topbar_layout);
searchBackButton = (ImageButton) map.findViewById(R.id.search_back_button);
searchBackButton.setOnClickListener(new View.OnClickListener() {
topbar = map.findViewById(R.id.custom_topbar);
topBarLayout = map.findViewById(R.id.custom_topbar_layout);
backButton = (ImageButton) map.findViewById(R.id.custom_back_button);
backButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
map.showQuickSearch(false, false);
TopToolbarViewController viewController = getTopViewController();
if (viewController != null) {
viewController.onBackPressed(TopToolbarView.this);
}
}
});
searchTitle = (TextView) map.findViewById(R.id.search_title);
searchTitle.setOnClickListener(new View.OnClickListener() {
titleView = (TextView) map.findViewById(R.id.custom_title);
titleView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
map.showQuickSearch(false, false);
TopToolbarViewController viewController = getTopViewController();
if (viewController != null) {
viewController.onTitlePressed(TopToolbarView.this);
}
}
});
searchCloseButton = (ImageButton) map.findViewById(R.id.search_close_button);
searchCloseButton.setOnClickListener(new View.OnClickListener() {
closeButton = (ImageButton) map.findViewById(R.id.custom_close_button);
closeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
map.closeQuickSearch();
TopToolbarViewController viewController = getTopViewController();
if (viewController != null) {
viewController.onClosePressed(TopToolbarView.this);
}
}
});
updateVisibility(false);
}
public TopToolbarViewController getToolbarController() {
return toolbarController;
public MapActivity getMap() {
return map;
}
public void setToolbarController(TopToolbarViewController toolbarController) {
this.toolbarController = toolbarController;
public View getTopbar() {
return topbar;
}
public View getTopBarLayout() {
return topBarLayout;
}
public ImageButton getBackButton() {
return backButton;
}
public TextView getTitleView() {
return titleView;
}
public ImageButton getCloseButton() {
return closeButton;
}
public TopToolbarViewController getTopViewController() {
if (viewControllers.size() > 0) {
return viewControllers.get(viewControllers.size() - 1);
} else {
return null;
}
}
public void addViewController(TopToolbarViewController viewController) {
if (!viewControllers.contains(viewController)) {
viewControllers.add(viewController);
}
updateInfo();
}
public void removeViewController(TopToolbarViewController viewController) {
viewControllers.remove(viewController);
updateInfo();
}
public boolean updateVisibility(boolean visible) {
return updateVisibility(searchTopBar, visible);
return updateVisibility(topbar, visible);
}
public boolean updateVisibility(View v, boolean visible) {
@ -229,25 +317,28 @@ public class MapInfoWidgetsFactory {
}
public void updateInfo() {
boolean isQuickSearchActive = map.isQuickSearchTopbarActive();
if (isQuickSearchActive) {
QuickSearchDialogFragment fragment = map.getQuickSearchDialogFragment();
if (fragment != null) {
searchTitle.setText(fragment.getText());
}
TopToolbarViewController viewController = getTopViewController();
if (viewController != null) {
viewController.updateToolbar(this);
}
updateVisibility(isQuickSearchActive);
updateVisibility(viewController != null);
}
public void updateTextColor(boolean nightMode, int textColor) {
OsmandApplication app = map.getMyApplication();
searchTitle.setTextColor(textColor);
searchBackButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha, !nightMode));
searchCloseButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_remove_dark, !nightMode));
titleView.setTextColor(textColor);
TopToolbarViewController viewController = getTopViewController();
if (viewController != null) {
backButton.setImageDrawable(app.getIconsCache().getIcon(viewController.getBackButtonIconId(), !nightMode));
closeButton.setImageDrawable(app.getIconsCache().getIcon(viewController.getCloseButtonIconId(), !nightMode));
} else {
backButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha, !nightMode));
closeButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_remove_dark, !nightMode));
}
}
public void setBackgroundResource(int boxTop) {
searchTopBarLayout.setBackgroundResource(boxTop);
topBarLayout.setBackgroundResource(boxTop);
}
}
@ -352,7 +443,7 @@ public class MapInfoWidgetsFactory {
text = "";
}
}
if (map.isQuickSearchTopbarActive()) {
if (map.isTopToolbarActive()) {
updateVisibility(false);
} else if (!showNextTurn && updateWaypoint()) {
updateVisibility(true);

View file

@ -201,7 +201,7 @@ public class MapMarkersWidgetsFactory {
|| map.getMyApplication().getRoutingHelper().isRoutePlanningMode()
|| map.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().isVisible()
|| addressTopBar.getVisibility() == View.VISIBLE
|| map.isQuickSearchTopbarActive()) {
|| map.isTopToolbarActive()) {
updateVisibility(false);
return;
}