Introduced custom top toolbar
This commit is contained in:
parent
77c709915e
commit
15936e358c
8 changed files with 249 additions and 103 deletions
|
@ -349,7 +349,7 @@
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/search_topbar"
|
android:id="@+id/custom_topbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
|
@ -361,14 +361,14 @@
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/search_topbar_layout"
|
android:id="@+id/custom_topbar_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/dashboard_map_toolbar"
|
android:layout_height="@dimen/dashboard_map_toolbar"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/search_back_button"
|
android:id="@+id/custom_back_button"
|
||||||
style="@style/Widget.AppCompat.ActionButton"
|
style="@style/Widget.AppCompat.ActionButton"
|
||||||
android:layout_width="54dp"
|
android:layout_width="54dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
|
@ -376,7 +376,7 @@
|
||||||
android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha"/>
|
android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/search_title"
|
android:id="@+id/custom_title"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
@ -387,11 +387,10 @@
|
||||||
android:lines="1"
|
android:lines="1"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:text="Search"
|
|
||||||
android:textSize="@dimen/abc_text_size_medium_material"/>
|
android:textSize="@dimen/abc_text_size_medium_material"/>
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/search_close_button"
|
android:id="@+id/custom_close_button"
|
||||||
style="@style/Widget.AppCompat.ActionButton"
|
style="@style/Widget.AppCompat.ActionButton"
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
|
|
|
@ -147,7 +147,7 @@
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/search_topbar"
|
android:id="@+id/custom_topbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
|
@ -159,14 +159,14 @@
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/search_topbar_layout"
|
android:id="@+id/custom_topbar_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/dashboard_map_toolbar"
|
android:layout_height="@dimen/dashboard_map_toolbar"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/search_back_button"
|
android:id="@+id/custom_back_button"
|
||||||
style="@style/Widget.AppCompat.ActionButton"
|
style="@style/Widget.AppCompat.ActionButton"
|
||||||
android:layout_width="54dp"
|
android:layout_width="54dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
|
@ -174,7 +174,7 @@
|
||||||
android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha"/>
|
android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/search_title"
|
android:id="@+id/custom_title"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
@ -185,11 +185,10 @@
|
||||||
android:lines="1"
|
android:lines="1"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:text="Toolbar text"
|
|
||||||
android:textSize="@dimen/abc_text_size_medium_material"/>
|
android:textSize="@dimen/abc_text_size_medium_material"/>
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/search_close_button"
|
android:id="@+id/custom_close_button"
|
||||||
style="@style/Widget.AppCompat.ActionButton"
|
style="@style/Widget.AppCompat.ActionButton"
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
|
@ -199,7 +198,7 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/search_topbar_shadow"
|
android:id="@+id/custom_topbar_shadow"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:foreground="@drawable/bg_contextmenu_shadow"
|
android:foreground="@drawable/bg_contextmenu_shadow"
|
||||||
|
|
|
@ -54,7 +54,6 @@ import net.osmand.plus.AppInitializer;
|
||||||
import net.osmand.plus.AppInitializer.AppInitializeListener;
|
import net.osmand.plus.AppInitializer.AppInitializeListener;
|
||||||
import net.osmand.plus.AppInitializer.InitEvents;
|
import net.osmand.plus.AppInitializer.InitEvents;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.BusyIndicator;
|
|
||||||
import net.osmand.plus.FirstUsageFragment;
|
import net.osmand.plus.FirstUsageFragment;
|
||||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||||
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
|
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.search.QuickSearchDialogFragment;
|
||||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||||
import net.osmand.plus.views.MapControlsLayer;
|
import net.osmand.plus.views.MapControlsLayer;
|
||||||
|
import net.osmand.plus.views.MapInfoLayer;
|
||||||
import net.osmand.plus.views.OsmAndMapLayersView;
|
import net.osmand.plus.views.OsmAndMapLayersView;
|
||||||
import net.osmand.plus.views.OsmAndMapSurfaceView;
|
import net.osmand.plus.views.OsmAndMapSurfaceView;
|
||||||
import net.osmand.plus.views.OsmandMapLayer;
|
import net.osmand.plus.views.OsmandMapLayer;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import net.osmand.plus.views.corenative.NativeCoreContext;
|
import net.osmand.plus.views.corenative.NativeCoreContext;
|
||||||
|
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarViewController;
|
||||||
import net.osmand.render.RenderingRulesStorage;
|
import net.osmand.render.RenderingRulesStorage;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
@ -168,7 +169,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
private boolean permissionGranted;
|
private boolean permissionGranted;
|
||||||
|
|
||||||
private boolean mIsDestroyed = false;
|
private boolean mIsDestroyed = false;
|
||||||
private boolean quickSearchTopbarActive = false;
|
private boolean topToolbarActive = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
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;
|
return fragment!= null && !fragment.isDetached() && !fragment.isRemoving() ? (QuickSearchDialogFragment) fragment : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isQuickSearchTopbarActive() {
|
public boolean isTopToolbarActive() {
|
||||||
return quickSearchTopbarActive && getQuickSearchDialogFragment() != null;
|
MapInfoLayer mapInfoLayer = getMapLayers().getMapInfoLayer();
|
||||||
|
return mapInfoLayer.hasTopToolbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setQuickSearchTopbarActive(boolean quickSearchTopbarActive) {
|
public void showTopToolbar(TopToolbarViewController viewController) {
|
||||||
this.quickSearchTopbarActive = quickSearchTopbarActive;
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,45 +1,5 @@
|
||||||
package net.osmand.plus.search;
|
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.annotation.SuppressLint;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
@ -74,6 +34,48 @@ import android.widget.ListView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
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 class QuickSearchDialogFragment extends DialogFragment implements OsmAndCompassListener, OsmAndLocationListener {
|
||||||
|
|
||||||
public static final String TAG = "QuickSearchDialogFragment";
|
public static final String TAG = "QuickSearchDialogFragment";
|
||||||
|
@ -95,6 +97,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
private QuickSearchMainListFragment mainSearchFragment;
|
private QuickSearchMainListFragment mainSearchFragment;
|
||||||
private QuickSearchHistoryListFragment historySearchFragment;
|
private QuickSearchHistoryListFragment historySearchFragment;
|
||||||
private QuickSearchCategoriesListFragment categoriesSearchFragment;
|
private QuickSearchCategoriesListFragment categoriesSearchFragment;
|
||||||
|
private QuickSearchToolbarController toolbarController = new QuickSearchToolbarController();
|
||||||
|
|
||||||
private Toolbar toolbarEdit;
|
private Toolbar toolbarEdit;
|
||||||
private TextView titleEdit;
|
private TextView titleEdit;
|
||||||
|
@ -197,7 +200,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
}
|
}
|
||||||
app.getPoiFilters().clearSelectedPoiFilters();
|
app.getPoiFilters().clearSelectedPoiFilters();
|
||||||
app.getPoiFilters().addSelectedPoiFilter(filter);
|
app.getPoiFilters().addSelectedPoiFilter(filter);
|
||||||
getMapActivity().setQuickSearchTopbarActive(true);
|
showToolbar();
|
||||||
getMapActivity().refreshMap();
|
getMapActivity().refreshMap();
|
||||||
hide();
|
hide();
|
||||||
} else {
|
} else {
|
||||||
|
@ -211,7 +214,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
searchResult.location.getLatitude(), searchResult.location.getLongitude(),
|
searchResult.location.getLatitude(), searchResult.location.getLongitude(),
|
||||||
searchResult.preferredZoom, pointDescription, true, searchResult.object);
|
searchResult.preferredZoom, pointDescription, true, searchResult.object);
|
||||||
|
|
||||||
getMapActivity().setQuickSearchTopbarActive(true);
|
showToolbar();
|
||||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||||
hide();
|
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() {
|
public String getText() {
|
||||||
return searchEditText.getText().toString();
|
return searchEditText.getText().toString();
|
||||||
}
|
}
|
||||||
|
@ -393,7 +405,6 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show() {
|
public void show() {
|
||||||
getMapActivity().setQuickSearchTopbarActive(false);
|
|
||||||
if (useMapCenter) {
|
if (useMapCenter) {
|
||||||
LatLon mapCenter = getMapActivity().getMapView().getCurrentRotatedTileBox().getCenterLatLon();
|
LatLon mapCenter = getMapActivity().getMapView().getCurrentRotatedTileBox().getCenterLatLon();
|
||||||
SearchSettings ss = searchUICore.getSearchSettings().setOriginalLocation(
|
SearchSettings ss = searchUICore.getSearchSettings().setOriginalLocation(
|
||||||
|
@ -527,7 +538,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
public void onDismiss(DialogInterface dialog) {
|
public void onDismiss(DialogInterface dialog) {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
getMapActivity().setQuickSearchTopbarActive(false);
|
hideToolbar();
|
||||||
getChildFragmentManager().popBackStack();
|
getChildFragmentManager().popBackStack();
|
||||||
}
|
}
|
||||||
super.onDismiss(dialog);
|
super.onDismiss(dialog);
|
||||||
|
@ -1191,4 +1202,26 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
return SearchListFragmentType.MAIN;
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,10 +220,11 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
||||||
pointDescription = wpt.getPointDescription(getMyApplication());
|
pointDescription = wpt.getPointDescription(getMyApplication());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
getMapActivity().setQuickSearchTopbarActive(showTopbar);
|
|
||||||
if (showTopbar) {
|
if (showTopbar) {
|
||||||
|
dialogFragment.showToolbar();
|
||||||
dialogFragment.hide();
|
dialogFragment.hide();
|
||||||
} else {
|
} else {
|
||||||
|
dialogFragment.hideToolbar();
|
||||||
dialogFragment.dismiss();
|
dialogFragment.dismiss();
|
||||||
}
|
}
|
||||||
getMyApplication().getSettings().setMapLocationToShow(
|
getMyApplication().getSettings().setMapLocationToShow(
|
||||||
|
|
|
@ -19,6 +19,7 @@ import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
|
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
|
||||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarView;
|
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarView;
|
||||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopTextView;
|
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.MapMarkersWidgetsFactory;
|
||||||
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
|
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
|
||||||
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.MapWidgetRegInfo;
|
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.MapWidgetRegInfo;
|
||||||
|
@ -99,7 +100,19 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
public void removeSideWidget(TextInfoWidget widget) {
|
public void removeSideWidget(TextInfoWidget widget) {
|
||||||
mapInfoControls.removeSideWidgetInternal(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(){
|
public void registerAllControls(){
|
||||||
RouteInfoWidgetsFactory ric = new RouteInfoWidgetsFactory();
|
RouteInfoWidgetsFactory ric = new RouteInfoWidgetsFactory();
|
||||||
MapInfoWidgetsFactory mic = new MapInfoWidgetsFactory();
|
MapInfoWidgetsFactory mic = new MapInfoWidgetsFactory();
|
||||||
|
|
|
@ -29,15 +29,16 @@ import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
|
||||||
import net.osmand.plus.helpers.WaypointDialogHelper;
|
import net.osmand.plus.helpers.WaypointDialogHelper;
|
||||||
import net.osmand.plus.helpers.WaypointHelper;
|
import net.osmand.plus.helpers.WaypointHelper;
|
||||||
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
|
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
|
||||||
|
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
|
||||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||||
import net.osmand.plus.routing.RouteDirectionInfo;
|
import net.osmand.plus.routing.RouteDirectionInfo;
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
import net.osmand.plus.search.QuickSearchDialogFragment;
|
|
||||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
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.plus.views.mapwidgets.NextTurnInfoWidget.TurnDrawable;
|
||||||
import net.osmand.router.TurnType;
|
import net.osmand.router.TurnType;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
public class MapInfoWidgetsFactory {
|
public class MapInfoWidgetsFactory {
|
||||||
|
|
||||||
public TextInfoWidget createAltitudeControl(final MapActivity map) {
|
public TextInfoWidget createAltitudeControl(final MapActivity map) {
|
||||||
|
@ -162,57 +163,144 @@ public class MapInfoWidgetsFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class TopToolbarViewController {
|
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 {
|
public static class TopToolbarView {
|
||||||
private final MapActivity map;
|
private final MapActivity map;
|
||||||
private TopToolbarViewController toolbarController;
|
private LinkedList<TopToolbarViewController> viewControllers = new LinkedList<>();
|
||||||
private View searchTopBar;
|
private View topbar;
|
||||||
private View searchTopBarLayout;
|
private View topBarLayout;
|
||||||
private ImageButton searchBackButton;
|
private ImageButton backButton;
|
||||||
private TextView searchTitle;
|
private TextView titleView;
|
||||||
private ImageButton searchCloseButton;
|
private ImageButton closeButton;
|
||||||
|
|
||||||
public TopToolbarView(final MapActivity map) {
|
public TopToolbarView(final MapActivity map) {
|
||||||
this.map = map;
|
this.map = map;
|
||||||
|
|
||||||
searchTopBar = map.findViewById(R.id.search_topbar);
|
topbar = map.findViewById(R.id.custom_topbar);
|
||||||
searchTopBarLayout = map.findViewById(R.id.search_topbar_layout);
|
topBarLayout = map.findViewById(R.id.custom_topbar_layout);
|
||||||
searchBackButton = (ImageButton) map.findViewById(R.id.search_back_button);
|
backButton = (ImageButton) map.findViewById(R.id.custom_back_button);
|
||||||
searchBackButton.setOnClickListener(new View.OnClickListener() {
|
backButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
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);
|
titleView = (TextView) map.findViewById(R.id.custom_title);
|
||||||
searchTitle.setOnClickListener(new View.OnClickListener() {
|
titleView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
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);
|
closeButton = (ImageButton) map.findViewById(R.id.custom_close_button);
|
||||||
searchCloseButton.setOnClickListener(new View.OnClickListener() {
|
closeButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
map.closeQuickSearch();
|
TopToolbarViewController viewController = getTopViewController();
|
||||||
|
if (viewController != null) {
|
||||||
|
viewController.onClosePressed(TopToolbarView.this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
updateVisibility(false);
|
updateVisibility(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TopToolbarViewController getToolbarController() {
|
public MapActivity getMap() {
|
||||||
return toolbarController;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setToolbarController(TopToolbarViewController toolbarController) {
|
public View getTopbar() {
|
||||||
this.toolbarController = toolbarController;
|
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) {
|
public boolean updateVisibility(boolean visible) {
|
||||||
return updateVisibility(searchTopBar, visible);
|
return updateVisibility(topbar, visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateVisibility(View v, boolean visible) {
|
public boolean updateVisibility(View v, boolean visible) {
|
||||||
|
@ -229,25 +317,28 @@ public class MapInfoWidgetsFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateInfo() {
|
public void updateInfo() {
|
||||||
boolean isQuickSearchActive = map.isQuickSearchTopbarActive();
|
TopToolbarViewController viewController = getTopViewController();
|
||||||
if (isQuickSearchActive) {
|
if (viewController != null) {
|
||||||
QuickSearchDialogFragment fragment = map.getQuickSearchDialogFragment();
|
viewController.updateToolbar(this);
|
||||||
if (fragment != null) {
|
|
||||||
searchTitle.setText(fragment.getText());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
updateVisibility(isQuickSearchActive);
|
updateVisibility(viewController != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateTextColor(boolean nightMode, int textColor) {
|
public void updateTextColor(boolean nightMode, int textColor) {
|
||||||
OsmandApplication app = map.getMyApplication();
|
OsmandApplication app = map.getMyApplication();
|
||||||
searchTitle.setTextColor(textColor);
|
titleView.setTextColor(textColor);
|
||||||
searchBackButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha, !nightMode));
|
TopToolbarViewController viewController = getTopViewController();
|
||||||
searchCloseButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_remove_dark, !nightMode));
|
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) {
|
public void setBackgroundResource(int boxTop) {
|
||||||
searchTopBarLayout.setBackgroundResource(boxTop);
|
topBarLayout.setBackgroundResource(boxTop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,7 +443,7 @@ public class MapInfoWidgetsFactory {
|
||||||
text = "";
|
text = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (map.isQuickSearchTopbarActive()) {
|
if (map.isTopToolbarActive()) {
|
||||||
updateVisibility(false);
|
updateVisibility(false);
|
||||||
} else if (!showNextTurn && updateWaypoint()) {
|
} else if (!showNextTurn && updateWaypoint()) {
|
||||||
updateVisibility(true);
|
updateVisibility(true);
|
||||||
|
|
|
@ -201,7 +201,7 @@ public class MapMarkersWidgetsFactory {
|
||||||
|| map.getMyApplication().getRoutingHelper().isRoutePlanningMode()
|
|| map.getMyApplication().getRoutingHelper().isRoutePlanningMode()
|
||||||
|| map.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().isVisible()
|
|| map.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().isVisible()
|
||||||
|| addressTopBar.getVisibility() == View.VISIBLE
|
|| addressTopBar.getVisibility() == View.VISIBLE
|
||||||
|| map.isQuickSearchTopbarActive()) {
|
|| map.isTopToolbarActive()) {
|
||||||
updateVisibility(false);
|
updateVisibility(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue