This commit is contained in:
Alexey Kulish 2016-08-11 15:17:09 +03:00
parent a3e2995a21
commit 1f8c916b9d
11 changed files with 614 additions and 224 deletions

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<nine-patch android:src="@drawable/bg_card_shadow" />
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/discount_bar_bg" />
<corners android:radius="@dimen/map_button_rect_rad" />
</shape>
</item>
</layer-list>

View file

@ -349,56 +349,76 @@
</FrameLayout> </FrameLayout>
<FrameLayout <FrameLayout
android:id="@+id/custom_topbar" android:id="@+id/widget_top_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clickable="true"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible"> tools:visibility="visible">
<LinearLayout <LinearLayout
android:id="@+id/widget_top_bar_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/custom_topbar_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/dashboard_map_toolbar"
android:gravity="center_vertical" android:gravity="center_vertical"
android:minHeight="@dimen/dashboard_map_toolbar"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageButton <ImageButton
android:id="@+id/custom_back_button" android:id="@+id/widget_top_bar_back_button"
style="@style/Widget.AppCompat.ActionButton" style="@style/Widget.AppCompat.ActionButton"
android:layout_width="54dp" android:layout_width="56dp"
android:layout_height="48dp" android:layout_height="56dp"
android:layout_gravity="top"
android:contentDescription="@string/back_to_search" android:contentDescription="@string/back_to_search"
android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha"/> android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha"/>
<TextView <LinearLayout
android:id="@+id/custom_title" android:id="@+id/widget_top_bar_title_layout"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingTop="10dp">
<TextView
android:id="@+id/widget_top_bar_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@null" android:background="@null"
android:clickable="true" android:ellipsize="end"
android:gravity="center_vertical"
android:lines="1"
android:singleLine="true"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/abc_text_size_medium_material"
tools:text="OsmAnd+ 50% discount"/>
<TextView
android:id="@+id/widget_top_bar_description"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@null"
android:ellipsize="end"
android:gravity="center_vertical" android:gravity="center_vertical"
android:textColor="?android:textColorPrimary" android:textColor="?android:textColorPrimary"
android:lines="1" android:textSize="@dimen/default_sub_text_size"
android:ellipsize="end" android:visibility="gone"
android:singleLine="true" tools:text="New version of OsmAnd+ with 50% discount"/>
android:textSize="@dimen/abc_text_size_medium_material"/>
<ImageButton
android:id="@+id/custom_close_button"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="48dp"
android:layout_height="48dp"
android:contentDescription="@string/shared_string_close"
android:src="@drawable/ic_action_remove_dark"/>
</LinearLayout> </LinearLayout>
<ImageButton
android:id="@+id/widget_top_bar_close_button"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="48dp"
android:layout_height="56dp"
android:layout_gravity="top"
android:contentDescription="@string/shared_string_close"
android:src="@drawable/ic_action_remove_dark"/>
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>

View file

@ -147,9 +147,10 @@
</FrameLayout> </FrameLayout>
<FrameLayout <FrameLayout
android:id="@+id/custom_topbar" android:id="@+id/widget_top_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clickable="true"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible"> tools:visibility="visible">
@ -159,46 +160,72 @@
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:id="@+id/custom_topbar_layout" android:id="@+id/widget_top_bar_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/dashboard_map_toolbar" android:layout_height="wrap_content"
android:minHeight="@dimen/dashboard_map_toolbar"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageButton <ImageButton
android:id="@+id/custom_back_button" android:id="@+id/widget_top_bar_back_button"
style="@style/Widget.AppCompat.ActionButton" style="@style/Widget.AppCompat.ActionButton"
android:layout_width="54dp" android:layout_width="56dp"
android:layout_height="48dp" android:layout_height="56dp"
android:layout_gravity="top"
android:contentDescription="@string/back_to_search" android:contentDescription="@string/back_to_search"
android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha"/> android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha"/>
<TextView <LinearLayout
android:id="@+id/custom_title" android:id="@+id/widget_top_bar_title_layout"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingTop="10dp">
<TextView
android:id="@+id/widget_top_bar_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@null" android:background="@null"
android:clickable="true" android:ellipsize="end"
android:gravity="center_vertical"
android:lines="1"
android:singleLine="true"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/abc_text_size_medium_material"
tools:text="OsmAnd+ 50% discount"/>
<TextView
android:id="@+id/widget_top_bar_description"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@null"
android:ellipsize="end"
android:gravity="center_vertical" android:gravity="center_vertical"
android:textColor="?android:textColorPrimary" android:textColor="?android:textColorPrimary"
android:lines="1" android:textSize="@dimen/default_sub_text_size"
android:ellipsize="end" android:visibility="gone"
android:singleLine="true" tools:text="New version of OsmAnd+ with 50% discount"/>
android:textSize="@dimen/abc_text_size_medium_material"/>
</LinearLayout>
<ImageButton <ImageButton
android:id="@+id/custom_close_button" android:id="@+id/widget_top_bar_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="56dp"
android:layout_gravity="top"
android:contentDescription="@string/shared_string_close" android:contentDescription="@string/shared_string_close"
android:src="@drawable/ic_action_remove_dark"/> android:src="@drawable/ic_action_remove_dark"/>
</LinearLayout> </LinearLayout>
<FrameLayout <FrameLayout
android:id="@+id/custom_topbar_shadow" android:id="@+id/widget_top_bar_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"

View file

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="discount_bar_bg">#357ef2</color>
<color name="searchbar_text_dark">#fff</color> <color name="searchbar_text_dark">#fff</color>
<color name="searchbar_text_light">#212121</color> <color name="searchbar_text_light">#212121</color>
<color name="searchbar_text_hint_dark">#7a8c99</color> <color name="searchbar_text_hint_dark">#7a8c99</color>

View file

@ -852,6 +852,10 @@ public class OsmandSettings {
public final OsmandPreference<Boolean> BILLING_PURCHASE_TOKEN_SENT = new BooleanPreference("billing_purchase_token_sent", false).makeGlobal(); public final OsmandPreference<Boolean> BILLING_PURCHASE_TOKEN_SENT = new BooleanPreference("billing_purchase_token_sent", false).makeGlobal();
public final OsmandPreference<Boolean> LIVE_UPDATES_PURCHASED = new BooleanPreference("billing_live_updates_purchased", false).makeGlobal(); public final OsmandPreference<Boolean> LIVE_UPDATES_PURCHASED = new BooleanPreference("billing_live_updates_purchased", false).makeGlobal();
public final OsmandPreference<Integer> DISCOUNT_ID = new IntPreference("discount_id", 0).makeGlobal();
public final OsmandPreference<Integer> DISCOUNT_SHOW_NUMBER_OF_STARTS = new IntPreference("number_of_starts_on_discount_show", 0).makeGlobal();
public final OsmandPreference<Long> DISCOUNT_SHOW_DATETIME_MS = new LongPreference("show_discount_datetime_ms", 0).makeGlobal();
// this value string is synchronized with settings_pref.xml preference name // this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<String> USER_OSM_BUG_NAME = public final OsmandPreference<String> USER_OSM_BUG_NAME =
new StringPreference("user_osm_bug_name", "NoName/OsmAnd").makeGlobal(); new StringPreference("user_osm_bug_name", "NoName/OsmAnd").makeGlobal();

View file

@ -75,6 +75,7 @@ import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
import net.osmand.plus.download.ui.DataStoragePlaceDialogFragment; import net.osmand.plus.download.ui.DataStoragePlaceDialogFragment;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.DiscountHelper;
import net.osmand.plus.helpers.ExternalApiHelper; import net.osmand.plus.helpers.ExternalApiHelper;
import net.osmand.plus.helpers.GpxImportHelper; import net.osmand.plus.helpers.GpxImportHelper;
import net.osmand.plus.helpers.WakeLockHelper; import net.osmand.plus.helpers.WakeLockHelper;
@ -579,6 +580,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
routingHelper.addListener(this); routingHelper.addListener(this);
app.getMapMarkersHelper().addListener(this); app.getMapMarkersHelper().addListener(this);
DiscountHelper.checkAndDisplay(this);
QuickSearchDialogFragment searchDialogFragment = getQuickSearchDialogFragment(); QuickSearchDialogFragment searchDialogFragment = getQuickSearchDialogFragment();
if (searchDialogFragment != null) { if (searchDialogFragment != null) {
if (searchDialogFragment.isSearchHidden()) { if (searchDialogFragment.isSearchHidden()) {
@ -1411,15 +1414,15 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
return mapInfoLayer.hasTopToolbar(); return mapInfoLayer.hasTopToolbar();
} }
public void showTopToolbar(TopToolbarController viewController) { public void showTopToolbar(TopToolbarController controller) {
MapInfoLayer mapInfoLayer = getMapLayers().getMapInfoLayer(); MapInfoLayer mapInfoLayer = getMapLayers().getMapInfoLayer();
mapInfoLayer.addTopToolbarViewController(viewController); mapInfoLayer.addTopToolbarController(controller);
this.topToolbarActive = mapInfoLayer.hasTopToolbar(); this.topToolbarActive = mapInfoLayer.hasTopToolbar();
} }
public void hideTopToolbar(TopToolbarController viewController) { public void hideTopToolbar(TopToolbarController controller) {
MapInfoLayer mapInfoLayer = getMapLayers().getMapInfoLayer(); MapInfoLayer mapInfoLayer = getMapLayers().getMapInfoLayer();
mapInfoLayer.removeTopToolbarViewController(viewController); mapInfoLayer.removeTopToolbarController(controller);
this.topToolbarActive = mapInfoLayer.hasTopToolbar(); this.topToolbarActive = mapInfoLayer.hasTopToolbar();
} }

View file

@ -0,0 +1,200 @@
package net.osmand.plus.helpers;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.util.Log;
import android.view.View;
import net.osmand.AndroidNetworkUtils;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
import net.osmand.util.Algorithms;
import org.json.JSONObject;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DiscountHelper {
private static final String TAG = "DiscountHelper";
//private static final String DISCOUNT_JSON = "discount.json";
private static long mLastCheckTime;
private static String mTitle;
private static String mDescription;
private static String mIcon;
private static String mUrl;
private static boolean mBannerVisible;
public static void checkAndDisplay(final MapActivity mapActivity) {
if (mBannerVisible) {
showDiscountBanner(mapActivity, mTitle, mDescription, mIcon, mUrl);
}
if (System.currentTimeMillis() - mLastCheckTime < 1000 * 60 * 60 * 24
|| !mapActivity.getMyApplication().getSettings().isInternetConnectionAvailable()) {
return;
}
mLastCheckTime = System.currentTimeMillis();
new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... params) {
try {
String res = AndroidNetworkUtils.sendRequest(mapActivity.getMyApplication(),
"http://osmand.net/api/motd", null, "Requesting discount info...");
return res;
} catch (Exception e) {
logError("Requesting discount info error: ", e);
return null;
}
}
@Override
protected void onPostExecute(String response) {
if (response != null) {
processDiscountResponse(response, mapActivity);
}
}
}.execute();
}
@SuppressLint("SimpleDateFormat")
private static void processDiscountResponse(String response, MapActivity mapActivity) {
try {
OsmandApplication app = mapActivity.getMyApplication();
JSONObject obj = new JSONObject(response);
String message = obj.getString("message");
String description = obj.getString("description");
String icon = obj.getString("icon");
String url = parseUrl(app, obj.getString("url"));
SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm");
Date start = df.parse(obj.getString("start"));
Date end = df.parse(obj.getString("end"));
int showStartFrequency = obj.getInt("show_start_frequency");
int showDayFrequency = obj.getInt("show_day_frequency");
JSONObject application = obj.getJSONObject("application");
String appName = app.getPackageName();
Date date = new Date();
if (application.has(appName) && application.getBoolean(appName)
&& date.after(start) && date.before(end)) {
OsmandSettings settings = app.getSettings();
int discountId = getDiscountId(message, description, start, end);
if (settings.DISCOUNT_ID.get() != discountId
|| app.getAppInitializer().getNumberOfStarts() - settings.DISCOUNT_SHOW_NUMBER_OF_STARTS.get() >= showStartFrequency
|| System.currentTimeMillis() - settings.DISCOUNT_SHOW_DATETIME_MS.get() > 1000L * 60 * 60 * 24 * showDayFrequency) {
settings.DISCOUNT_ID.set(discountId);
settings.DISCOUNT_SHOW_NUMBER_OF_STARTS.set(app.getAppInitializer().getNumberOfStarts());
settings.DISCOUNT_SHOW_DATETIME_MS.set(System.currentTimeMillis());
showDiscountBanner(mapActivity, message, description, icon, url);
}
}
} catch (Exception e) {
logError("JSON parsing error: ", e);
}
}
private static String parseUrl(OsmandApplication app, String url) {
if (!Algorithms.isEmpty(url)) {
int i = url.indexOf("osmand-market-app:");
if (i != -1) {
String appName = url.substring(i + 18);
return Version.marketPrefix(app) + appName;
}
}
return url;
}
private static int getDiscountId(String message, String description, Date start, Date end) {
final int prime = 31;
int result = 1;
result = prime * result + ((message == null) ? 0 : message.hashCode());
result = prime * result + ((description == null) ? 0 : description.hashCode());
result = prime * result + ((start == null) ? 0 : start.hashCode());
result = prime * result + ((end == null) ? 0 : end.hashCode());
return result;
}
private static void showDiscountBanner(final MapActivity mapActivity, final String title, final String description, final String icon, final String url) {
final DiscountBarController toolbarController = new DiscountBarController();
toolbarController.setTitle(title);
toolbarController.setDescription(description);
int iconId = mapActivity.getResources().getIdentifier(icon, "drawable", mapActivity.getMyApplication().getPackageName());
toolbarController.setBackBtnIconIds(iconId, iconId);
if (!Algorithms.isEmpty(url)) {
toolbarController.setOnBackButtonClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mBannerVisible = false;
openUrl(mapActivity, url);
}
});
toolbarController.setOnTitleClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mBannerVisible = false;
openUrl(mapActivity, url);
}
});
}
toolbarController.setOnCloseButtonClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mBannerVisible = false;
mapActivity.hideTopToolbar(toolbarController);
}
});
mTitle = title;
mDescription = description;
mIcon = icon;
mUrl = url;
mBannerVisible = true;
mapActivity.showTopToolbar(toolbarController);
}
private static void openUrl(MapActivity mapActivity, String url) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
mapActivity.startActivity(intent);
}
private static class DiscountBarController extends TopToolbarController {
public DiscountBarController() {
super(TopToolbarControllerType.DISCOUNT);
setSingleLineTitle(false);
setBackBtnIconClrIds(0, 0);
setCloseBtnIconClrIds(0, 0);
setTitleTextClrIds(R.color.primary_text_dark, R.color.primary_text_dark);
setDescrTextClrIds(R.color.primary_text_dark, R.color.primary_text_dark);
setBgIds(R.color.discount_bar_bg, R.color.discount_bar_bg,
R.drawable.discount_bar_bg_land, R.drawable.discount_bar_bg_land);
}
}
private static void logError(String msg) {
Log.e(TAG, msg);
}
private static void logError(String msg, Throwable e) {
Log.e(TAG, "Error: " + msg, e);
}
}

View file

@ -17,8 +17,6 @@ import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute; import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute;
import net.osmand.plus.views.TransportStopsLayer; import net.osmand.plus.views.TransportStopsLayer;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController.TopToolbarViewControllerType;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarView;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.List; import java.util.List;
@ -31,23 +29,26 @@ public class TransportRouteController extends MenuController {
final TransportStopRoute transportRoute) { final TransportStopRoute transportRoute) {
super(new MenuBuilder(app), pointDescription, mapActivity); super(new MenuBuilder(app), pointDescription, mapActivity);
this.transportRoute = transportRoute; this.transportRoute = transportRoute;
toolbarController = new TopToolbarController(TopToolbarViewControllerType.CONTEXT_MENU) { toolbarController = new TransportRouteToolbarController();
toolbarController.setTitle(getNameStr());
toolbarController.setOnBackButtonClickListener(new OnClickListener() {
@Override @Override
public void onBackPressed(TopToolbarView view) { public void onClick(View v) {
getMapActivity().getContextMenu().backToolbarAction(TransportRouteController.this); mapActivity.getContextMenu().backToolbarAction(TransportRouteController.this);
} }
});
toolbarController.setOnTitleClickListener(new OnClickListener() {
@Override @Override
public void onTitlePressed(TopToolbarView view) { public void onClick(View v) {
showMenuAndRoute(getLatLon(), true); showMenuAndRoute(getLatLon(), true);
} }
});
toolbarController.setOnCloseButtonClickListener(new OnClickListener() {
@Override @Override
public void onClosePressed(TopToolbarView view) { public void onClick(View v) {
getMapActivity().getContextMenu().closeToolbar(TransportRouteController.this); mapActivity.getContextMenu().closeToolbar(TransportRouteController.this);
} }
}; });
toolbarController.setTitle(getNameStr());
} }
@Override @Override
@ -193,4 +194,11 @@ public class TransportRouteController extends MenuController {
TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer(); TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
stopsLayer.setRoute(null); stopsLayer.setRoute(null);
} }
public static class TransportRouteToolbarController extends TopToolbarController {
public TransportRouteToolbarController() {
super(TopToolbarControllerType.CONTEXT_MENU);
}
}
} }

View file

@ -59,7 +59,6 @@ import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.search.QuickSearchHelper.SearchHistoryAPI; import net.osmand.plus.search.QuickSearchHelper.SearchHistoryAPI;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarView;
import net.osmand.search.SearchUICore; import net.osmand.search.SearchUICore;
import net.osmand.search.SearchUICore.SearchResultCollection; import net.osmand.search.SearchUICore.SearchResultCollection;
import net.osmand.search.core.ObjectType; import net.osmand.search.core.ObjectType;
@ -102,7 +101,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 QuickSearchToolbarController toolbarController;
private Toolbar toolbarEdit; private Toolbar toolbarEdit;
private TextView titleEdit; private TextView titleEdit;
@ -151,6 +150,26 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
final MapActivity mapActivity = getMapActivity(); final MapActivity mapActivity = getMapActivity();
final View view = inflater.inflate(R.layout.search_dialog_fragment, container, false); final View view = inflater.inflate(R.layout.search_dialog_fragment, container, false);
toolbarController = new QuickSearchToolbarController();
toolbarController.setOnBackButtonClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mapActivity.showQuickSearch(ShowQuickSearchMode.CURRENT, false);
}
});
toolbarController.setOnTitleClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mapActivity.showQuickSearch(ShowQuickSearchMode.CURRENT, false);
}
});
toolbarController.setOnCloseButtonClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mapActivity.closeQuickSearch();
}
});
Bundle arguments = getArguments(); Bundle arguments = getArguments();
if (savedInstanceState != null) { if (savedInstanceState != null) {
searchQuery = savedInstanceState.getString(QUICK_SEARCH_QUERY_KEY); searchQuery = savedInstanceState.getString(QUICK_SEARCH_QUERY_KEY);
@ -1259,22 +1278,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
public static class QuickSearchToolbarController extends TopToolbarController { public static class QuickSearchToolbarController extends TopToolbarController {
public QuickSearchToolbarController() { public QuickSearchToolbarController() {
super(TopToolbarController.TopToolbarViewControllerType.QUICK_SEARCH); super(TopToolbarControllerType.QUICK_SEARCH);
}
@Override
public void onBackPressed(TopToolbarView view) {
view.getMap().showQuickSearch(ShowQuickSearchMode.CURRENT, false);
}
@Override
public void onTitlePressed(TopToolbarView view) {
view.getMap().showQuickSearch(ShowQuickSearchMode.CURRENT, false);
}
@Override
public void onClosePressed(TopToolbarView view) {
view.getMap().closeQuickSearch();
} }
} }
} }

View file

@ -101,16 +101,16 @@ public class MapInfoLayer extends OsmandMapLayer {
mapInfoControls.removeSideWidgetInternal(widget); mapInfoControls.removeSideWidgetInternal(widget);
} }
public void addTopToolbarViewController(TopToolbarController viewController) { public void addTopToolbarController(TopToolbarController controller) {
topToolbarView.addViewController(viewController); topToolbarView.addController(controller);
} }
public void removeTopToolbarViewController(TopToolbarController viewController) { public void removeTopToolbarController(TopToolbarController controller) {
topToolbarView.removeViewController(viewController); topToolbarView.removeController(controller);
} }
public boolean hasTopToolbar() { public boolean hasTopToolbar() {
return topToolbarView.getTopViewController() != null; return topToolbarView.getTopController() != null;
} }
public void registerAllControls(){ public void registerAllControls(){
@ -124,7 +124,7 @@ public class MapInfoLayer extends OsmandMapLayer {
updateStreetName(false, calculateTextState()); updateStreetName(false, calculateTextState());
topToolbarView = new TopToolbarView(map); topToolbarView = new TopToolbarView(map);
updateTopToolbar(false, calculateTextStateSearch()); updateTopToolbar(false);
alarmControl = ric.createAlarmInfoControl(app, map); alarmControl = ric.createAlarmInfoControl(app, map);
alarmControl.setVisibility(false); alarmControl.setVisibility(false);
@ -231,7 +231,7 @@ public class MapInfoLayer extends OsmandMapLayer {
updateReg(ts, reg); updateReg(ts, reg);
} }
updateStreetName(nightMode, ts); updateStreetName(nightMode, ts);
updateTopToolbar(nightMode, calculateTextStateSearch()); updateTopToolbar(nightMode);
lanesControl.updateTextSize(nightMode, ts.textColor, ts.textShadowColor, ts.textBold, ts.textShadowRadius / 2); lanesControl.updateTextSize(nightMode, ts.textColor, ts.textShadowColor, ts.textBold, ts.textShadowRadius / 2);
rulerControl.updateTextSize(nightMode, ts.textColor, ts.textShadowColor, (int) (2 * view.getDensity())); rulerControl.updateTextSize(nightMode, ts.textColor, ts.textShadowColor, (int) (2 * view.getDensity()));
this.expand.setBackgroundResource(ts.expand); this.expand.setBackgroundResource(ts.expand);
@ -246,10 +246,8 @@ public class MapInfoLayer extends OsmandMapLayer {
streetNameView.updateTextColor(nightMode, ts.textColor, ts.textShadowColor, ts.textBold, ts.textShadowRadius); streetNameView.updateTextColor(nightMode, ts.textColor, ts.textShadowColor, ts.textBold, ts.textShadowRadius);
} }
private void updateTopToolbar(boolean nightMode, TextState ts) { private void updateTopToolbar(boolean nightMode) {
int bgColorId = nightMode ? R.color.bg_color_dark : R.color.bg_color_light; topToolbarView.updateColors(nightMode);
topToolbarView.setBackgroundResource(AndroidUiHelper.isOrientationPortrait(map) ? bgColorId : ts.boxFree);
topToolbarView.updateTextColor(nightMode, ts.textColor);
} }
private void updateReg(TextState ts, MapWidgetRegInfo reg) { private void updateReg(TextState ts, MapWidgetRegInfo reg) {
@ -298,27 +296,6 @@ public class MapInfoLayer extends OsmandMapLayer {
return ts; return ts;
} }
private TextState calculateTextStateSearch() {
boolean nightMode = drawSettings != null && drawSettings.isNightMode();
TextState ts = new TextState();
ts.night = nightMode;
ts.textColor = nightMode ? ContextCompat.getColor(view.getContext(), R.color.widgettext_night) : Color.BLACK;
if (nightMode) {
ts.boxTop = R.drawable.btn_flat_night;
ts.rightRes = R.drawable.btn_left_round_night;
ts.leftRes = R.drawable.btn_right_round_night;
ts.expand = R.drawable.btn_inset_circle_night;
ts.boxFree = R.drawable.btn_round_night;
} else {
ts.boxTop = R.drawable.btn_flat;
ts.rightRes = R.drawable.btn_left_round;
ts.leftRes = R.drawable.btn_right_round;
ts.expand = R.drawable.btn_inset_circle;
ts.boxFree = R.drawable.btn_round;
}
return ts;
}
@Override @Override
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings drawSettings) { public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings drawSettings) {
this.drawSettings = drawSettings; this.drawSettings = drawSettings;

View file

@ -6,6 +6,7 @@ import android.content.Intent;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
@ -26,6 +27,7 @@ import net.osmand.plus.Version;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.actions.StartGPSStatus; import net.osmand.plus.activities.actions.StartGPSStatus;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType; import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.helpers.AndroidUiHelper;
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;
@ -34,6 +36,7 @@ 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.views.OsmandMapLayer.DrawSettings; import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController.TopToolbarControllerType;
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;
@ -86,10 +89,10 @@ public class MapInfoWidgetsFactory {
@Override @Override
public boolean updateInfo(DrawSettings d) { public boolean updateInfo(DrawSettings d) {
GPSInfo gpsInfo = loc.getGPSInfo(); GPSInfo gpsInfo = loc.getGPSInfo();
if(gpsInfo.usedSatellites != u || gpsInfo.foundSatellites != f) { if (gpsInfo.usedSatellites != u || gpsInfo.foundSatellites != f) {
u = gpsInfo.usedSatellites; u = gpsInfo.usedSatellites;
f = gpsInfo.foundSatellites; f = gpsInfo.foundSatellites;
setText(gpsInfo.usedSatellites+"/"+gpsInfo.foundSatellites, ""); setText(gpsInfo.usedSatellites + "/" + gpsInfo.foundSatellites, "");
return true; return true;
} }
return false; return false;
@ -97,10 +100,10 @@ public class MapInfoWidgetsFactory {
}; };
gpsInfoControl.setIcons(R.drawable.widget_gps_info_day, R.drawable.widget_gps_info_night); gpsInfoControl.setIcons(R.drawable.widget_gps_info_day, R.drawable.widget_gps_info_night);
gpsInfoControl.setText(null, null); gpsInfoControl.setText(null, null);
gpsInfoControl.setOnClickListener(new View.OnClickListener() { gpsInfoControl.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (app.getNavigationService() != null){ if (app.getNavigationService() != null) {
AlertDialog.Builder dlg = new AlertDialog.Builder(map); AlertDialog.Builder dlg = new AlertDialog.Builder(map);
dlg.setTitle(app.getString(R.string.sleep_mode_stop_dialog)); dlg.setTitle(app.getString(R.string.sleep_mode_stop_dialog));
@ -109,9 +112,9 @@ public class MapInfoWidgetsFactory {
if (soi == 0) { if (soi == 0) {
dlg.setMessage(app.getString(R.string.gps_wake_up_timer) + ": " + app.getString(R.string.int_continuosly)); dlg.setMessage(app.getString(R.string.gps_wake_up_timer) + ": " + app.getString(R.string.int_continuosly));
} else if (soi <= 90000) { } else if (soi <= 90000) {
dlg.setMessage(app.getString(R.string.gps_wake_up_timer) + ": " + Integer.toString(soi/1000) + " " + app.getString(R.string.int_seconds)); dlg.setMessage(app.getString(R.string.gps_wake_up_timer) + ": " + Integer.toString(soi / 1000) + " " + app.getString(R.string.int_seconds));
} else { } else {
dlg.setMessage(app.getString(R.string.gps_wake_up_timer) + ": " + Integer.toString(soi/1000/60) + " " + app.getString(R.string.int_min)); dlg.setMessage(app.getString(R.string.gps_wake_up_timer) + ": " + Integer.toString(soi / 1000 / 60) + " " + app.getString(R.string.int_min));
} }
dlg.setPositiveButton(app.getString(R.string.keep_navigation_service), null); dlg.setPositiveButton(app.getString(R.string.keep_navigation_service), null);
@ -163,96 +166,156 @@ public class MapInfoWidgetsFactory {
return gpsInfoControl; return gpsInfoControl;
} }
public static abstract class TopToolbarController { public static class TopToolbarController {
private TopToolbarViewControllerType type; private TopToolbarControllerType 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 { int bgLightId = R.color.bg_color_light;
int bgDarkId = R.color.bg_color_dark;
int bgLightLandId = R.drawable.btn_round;
int bgDarkLandId = R.drawable.btn_round_night;
int backBtnIconLightId = R.drawable.abc_ic_ab_back_mtrl_am_alpha;
int backBtnIconDarkId = R.drawable.abc_ic_ab_back_mtrl_am_alpha;
int backBtnIconClrLightId = R.color.icon_color;
int backBtnIconClrDarkId = 0;
int closeBtnIconLightId = R.drawable.ic_action_remove_dark;
int closeBtnIconDarkId = R.drawable.ic_action_remove_dark;
int closeBtnIconClrLightId = R.color.icon_color;
int closeBtnIconClrDarkId = 0;
int titleTextClrLightId = R.color.primary_text_light;
int titleTextClrDarkId = R.color.primary_text_dark;
int descrTextClrLightId = R.color.primary_text_light;
int descrTextClrDarkId = R.color.primary_text_dark;
boolean singleLineTitle = true;
boolean nightMode = false;
String title = "";
String description = null;
OnClickListener onBackButtonClickListener;
OnClickListener onTitleClickListener;
OnClickListener onCloseButtonClickListener;
public enum TopToolbarControllerType {
QUICK_SEARCH, QUICK_SEARCH,
CONTEXT_MENU CONTEXT_MENU,
DISCOUNT,
} }
public TopToolbarController(TopToolbarViewControllerType type) { public TopToolbarController(TopToolbarControllerType type) {
this.type = type; this.type = type;
} }
public TopToolbarViewControllerType getType() { public TopToolbarControllerType getType() {
return type; return type;
} }
public String getTitle() {
return title;
}
public void setTitle(String title) { public void setTitle(String title) {
this.title = title; this.title = title;
} }
public int getBackButtonIconId() { public void setSingleLineTitle(boolean singleLineTitle) {
return backButtonIconId; this.singleLineTitle = singleLineTitle;
} }
public int getCloseButtonIconId() { public void setDescription(String description) {
return closeButtonIconId; this.description = description;
}
public void setBgIds(int bgLightId, int bgDarkId, int bgLightLandId, int bgDarkLandId) {
this.bgLightId = bgLightId;
this.bgDarkId = bgDarkId;
this.bgLightLandId = bgLightLandId;
this.bgDarkLandId = bgDarkLandId;
}
public void setBackBtnIconIds(int backBtnIconLightId, int backBtnIconDarkId) {
this.backBtnIconLightId = backBtnIconLightId;
this.backBtnIconDarkId = backBtnIconDarkId;
}
public void setBackBtnIconClrIds(int backBtnIconClrLightId, int backBtnIconClrDarkId) {
this.backBtnIconClrLightId = backBtnIconClrLightId;
this.backBtnIconClrDarkId = backBtnIconClrDarkId;
}
public void setCloseBtnIconIds(int closeBtnIconLightId, int closeBtnIconDarkId) {
this.closeBtnIconLightId = closeBtnIconLightId;
this.closeBtnIconDarkId = closeBtnIconDarkId;
}
public void setCloseBtnIconClrIds(int closeBtnIconClrLightId, int closeBtnIconClrDarkId) {
this.closeBtnIconClrLightId = closeBtnIconClrLightId;
this.closeBtnIconClrDarkId = closeBtnIconClrDarkId;
}
public void setTitleTextClrIds(int titleTextClrLightId, int titleTextClrDarkId) {
this.titleTextClrLightId = titleTextClrLightId;
this.titleTextClrDarkId = titleTextClrDarkId;
}
public void setDescrTextClrIds(int descrTextClrLightId, int descrTextClrDarkId) {
this.descrTextClrLightId = descrTextClrLightId;
this.descrTextClrDarkId = descrTextClrDarkId;
}
public void setOnBackButtonClickListener(OnClickListener onBackButtonClickListener) {
this.onBackButtonClickListener = onBackButtonClickListener;
}
public void setOnTitleClickListener(OnClickListener onTitleClickListener) {
this.onTitleClickListener = onTitleClickListener;
}
public void setOnCloseButtonClickListener(OnClickListener onCloseButtonClickListener) {
this.onCloseButtonClickListener = onCloseButtonClickListener;
} }
public void updateToolbar(TopToolbarView view) { public void updateToolbar(TopToolbarView view) {
view.getTitleView().setText(title); TextView titleView = view.getTitleView();
TextView descrView = view.getDescrView();
if (title != null) {
titleView.setText(title);
view.updateVisibility(titleView, true);
} else {
view.updateVisibility(titleView, false);
}
if (description != null) {
descrView.setText(description);
view.updateVisibility(descrView, true);
} else {
view.updateVisibility(descrView, false);
}
} }
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 LinkedList<TopToolbarController> viewControllers = new LinkedList<>(); private LinkedList<TopToolbarController> controllers = new LinkedList<>();
private TopToolbarController defaultController = new TopToolbarController(TopToolbarControllerType.CONTEXT_MENU);
private View topbar; private View topbar;
private View topBarLayout; private View topBarLayout;
private View topBarTitleLayout;
private ImageButton backButton; private ImageButton backButton;
private TextView titleView; private TextView titleView;
private TextView descrView;
private ImageButton closeButton; private ImageButton closeButton;
private boolean nightMode;
public TopToolbarView(final MapActivity map) { public TopToolbarView(final MapActivity map) {
this.map = map; this.map = map;
topbar = map.findViewById(R.id.custom_topbar); topbar = map.findViewById(R.id.widget_top_bar);
topBarLayout = map.findViewById(R.id.custom_topbar_layout); topBarLayout = map.findViewById(R.id.widget_top_bar_layout);
backButton = (ImageButton) map.findViewById(R.id.custom_back_button); topBarTitleLayout = map.findViewById(R.id.widget_top_bar_title_layout);
backButton.setOnClickListener(new View.OnClickListener() { backButton = (ImageButton) map.findViewById(R.id.widget_top_bar_back_button);
@Override closeButton = (ImageButton) map.findViewById(R.id.widget_top_bar_close_button);
public void onClick(View v) { titleView = (TextView) map.findViewById(R.id.widget_top_bar_title);
TopToolbarController viewController = getTopViewController(); descrView = (TextView) map.findViewById(R.id.widget_top_bar_description);
if (viewController != null) {
viewController.onBackPressed(TopToolbarView.this);
}
}
});
titleView = (TextView) map.findViewById(R.id.custom_title);
titleView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TopToolbarController viewController = getTopViewController();
if (viewController != null) {
viewController.onTitlePressed(TopToolbarView.this);
}
}
});
closeButton = (ImageButton) map.findViewById(R.id.custom_close_button);
closeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TopToolbarController viewController = getTopViewController();
if (viewController != null) {
viewController.onClosePressed(TopToolbarView.this);
}
}
});
updateVisibility(false); updateVisibility(false);
} }
@ -276,31 +339,37 @@ public class MapInfoWidgetsFactory {
return titleView; return titleView;
} }
public TextView getDescrView() {
return descrView;
}
public ImageButton getCloseButton() { public ImageButton getCloseButton() {
return closeButton; return closeButton;
} }
public TopToolbarController getTopViewController() { public TopToolbarController getTopController() {
if (viewControllers.size() > 0) { if (controllers.size() > 0) {
return viewControllers.get(viewControllers.size() - 1); return controllers.get(controllers.size() - 1);
} else { } else {
return null; return null;
} }
} }
public void addViewController(TopToolbarController viewController) { public void addController(TopToolbarController controller) {
for (Iterator ctrlIter = viewControllers.iterator(); ctrlIter.hasNext(); ) { for (Iterator ctrlIter = controllers.iterator(); ctrlIter.hasNext(); ) {
TopToolbarController controller = (TopToolbarController) ctrlIter.next(); TopToolbarController ctrl = (TopToolbarController) ctrlIter.next();
if (controller.getType() == viewController.getType()) { if (ctrl.getType() == controller.getType()) {
ctrlIter.remove(); ctrlIter.remove();
} }
} }
viewControllers.add(viewController); controllers.add(controller);
updateColors();
updateInfo(); updateInfo();
} }
public void removeViewController(TopToolbarController viewController) { public void removeController(TopToolbarController controller) {
viewControllers.remove(viewController); controllers.remove(controller);
updateColors();
updateInfo(); updateInfo();
} }
@ -321,29 +390,82 @@ public class MapInfoWidgetsFactory {
return false; return false;
} }
private void initToolbar(TopToolbarController controller) {
backButton.setOnClickListener(controller.onBackButtonClickListener);
topBarTitleLayout.setOnClickListener(controller.onTitleClickListener);
closeButton.setOnClickListener(controller.onCloseButtonClickListener);
}
public void updateInfo() { public void updateInfo() {
TopToolbarController viewController = getTopViewController(); TopToolbarController controller = getTopController();
if (viewController != null) { if (controller != null) {
viewController.updateToolbar(this); initToolbar(controller);
} controller.updateToolbar(this);
updateVisibility(viewController != null);
}
public void updateTextColor(boolean nightMode, int textColor) {
OsmandApplication app = map.getMyApplication();
titleView.setTextColor(textColor);
TopToolbarController viewController = getTopViewController();
if (viewController != null) {
backButton.setImageDrawable(app.getIconsCache().getIcon(viewController.getBackButtonIconId(), !nightMode));
closeButton.setImageDrawable(app.getIconsCache().getIcon(viewController.getCloseButtonIconId(), !nightMode));
} else { } else {
backButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha, !nightMode)); initToolbar(defaultController);
closeButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_remove_dark, !nightMode)); defaultController.updateToolbar(this);
}
updateVisibility(controller != null);
}
public void updateColors(TopToolbarController controller) {
OsmandApplication app = map.getMyApplication();
controller.nightMode = nightMode;
if (nightMode) {
topBarLayout.setBackgroundResource(AndroidUiHelper.isOrientationPortrait(map) ? controller.bgDarkId : controller.bgDarkLandId);
if (controller.backBtnIconDarkId == 0) {
backButton.setImageDrawable(null);
} else {
backButton.setImageDrawable(app.getIconsCache().getIcon(controller.backBtnIconDarkId, controller.backBtnIconClrDarkId));
}
if (controller.closeBtnIconDarkId == 0) {
closeButton.setImageDrawable(null);
} else {
closeButton.setImageDrawable(app.getIconsCache().getIcon(controller.closeBtnIconDarkId, controller.closeBtnIconClrDarkId));
}
int titleColor = map.getResources().getColor(controller.titleTextClrDarkId);
int descrColor = map.getResources().getColor(controller.descrTextClrDarkId);
titleView.setTextColor(titleColor);
descrView.setTextColor(descrColor);
} else {
topBarLayout.setBackgroundResource(AndroidUiHelper.isOrientationPortrait(map) ? controller.bgLightId : controller.bgLightLandId);
if (controller.backBtnIconLightId == 0) {
backButton.setImageDrawable(null);
} else {
backButton.setImageDrawable(app.getIconsCache().getIcon(controller.backBtnIconLightId, controller.backBtnIconClrLightId));
}
if (controller.closeBtnIconLightId == 0) {
closeButton.setImageDrawable(null);
} else {
closeButton.setImageDrawable(app.getIconsCache().getIcon(controller.closeBtnIconLightId, controller.closeBtnIconClrLightId));
}
int titleColor = map.getResources().getColor(controller.titleTextClrLightId);
int descrColor = map.getResources().getColor(controller.descrTextClrLightId);
titleView.setTextColor(titleColor);
descrView.setTextColor(descrColor);
}
if (controller.singleLineTitle) {
titleView.setSingleLine(true);
} else {
titleView.setSingleLine(false);
} }
} }
public void setBackgroundResource(int boxTop) { public void updateColors() {
topBarLayout.setBackgroundResource(boxTop); TopToolbarController controller = getTopController();
if (controller != null) {
updateColors(controller);
} else {
updateColors(defaultController);
}
}
public void updateColors(boolean nightMode) {
this.nightMode = nightMode;
for (TopToolbarController controller : controllers) {
controller.nightMode = nightMode;
}
updateColors();
} }
} }
@ -441,9 +563,15 @@ public class MapInfoWidgetsFactory {
settings.SHOW_STREET_NAME.get()) { settings.SHOW_STREET_NAME.get()) {
RouteDataObject rt = locationProvider.getLastKnownRouteSegment(); RouteDataObject rt = locationProvider.getLastKnownRouteSegment();
if (rt != null) { if (rt != null) {
<<<<<<< HEAD
text = RoutingHelper.formatStreetName(rt.getName(settings.MAP_PREFERRED_LOCALE.get()), text = RoutingHelper.formatStreetName(rt.getName(settings.MAP_PREFERRED_LOCALE.get()),
rt.getRef(), rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get()), ">"); rt.getRef(), rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get()), ">");
} }
=======
text = RoutingHelper.formatStreetName(rt.getName(settings.MAP_PREFERRED_LOCALE.get()),
rt.getRef(), rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get()), map.getMyApplication().getString(R.string.towards));
}
>>>>>>> d82263a... Added discount banner
if (text == null) { if (text == null) {
text = ""; text = "";
} else { } else {
@ -480,7 +608,11 @@ public class MapInfoWidgetsFactory {
addressText.setCompoundDrawables(null, null, null, null); addressText.setCompoundDrawables(null, null, null, null);
} }
} }
<<<<<<< HEAD
if (!text.equals(addressText.getText().toString()) && !text.equals("+ " + addressText.getText().toString())) { if (!text.equals(addressText.getText().toString()) && !text.equals("+ " + addressText.getText().toString())) {
=======
if (!text.equals(addressText.getText().toString())) {
>>>>>>> d82263a... Added discount banner
if (!text.equals("")) { if (!text.equals("")) {
topBar.setContentDescription(text); topBar.setContentDescription(text);
} else { } else {
@ -512,13 +644,13 @@ public class MapInfoWidgetsFactory {
if (updated || changed) { if (updated || changed) {
ImageView all = (ImageView) waypointInfoBar.findViewById(R.id.waypoint_more); ImageView all = (ImageView) waypointInfoBar.findViewById(R.id.waypoint_more);
ImageView remove = (ImageView) waypointInfoBar.findViewById(R.id.waypoint_close); ImageView remove = (ImageView) waypointInfoBar.findViewById(R.id.waypoint_close);
all.setOnClickListener(new View.OnClickListener() { all.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
map.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS); map.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS);
} }
}); });
remove.setOnClickListener(new View.OnClickListener() { remove.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
waypointHelper.removeVisibleLocationPoint(pnt); waypointHelper.removeVisibleLocationPoint(pnt);