Refactor the updating of the status bar color
This commit is contained in:
parent
4a2b9abda1
commit
180a26077f
7 changed files with 47 additions and 20 deletions
|
@ -862,23 +862,20 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
int color = -1;
|
int color = -1;
|
||||||
boolean mapControlsVisible = findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE;
|
boolean mapControlsVisible = findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE;
|
||||||
boolean night = app.getDaynightHelper().isNightModeForMapControls();
|
boolean night = app.getDaynightHelper().isNightModeForMapControls();
|
||||||
TopToolbarController discountController = getTopToolbarController(TopToolbarControllerType.DISCOUNT);
|
TopToolbarController toolbarController = getMapLayers().getMapInfoLayer().getTopToolbarController();
|
||||||
boolean quickSearchTopBar = getTopToolbarController(TopToolbarControllerType.QUICK_SEARCH) != null;
|
if (toolbarController != null && mapControlsVisible) {
|
||||||
boolean contextMenuTopBar = getTopToolbarController(TopToolbarControllerType.CONTEXT_MENU) != null;
|
color = toolbarController.getStatusBarColor(this, night);
|
||||||
boolean poiFilterTopBar = getTopToolbarController(TopToolbarControllerType.POI_FILTER) != null;
|
|
||||||
boolean mapTopBar = findViewById(R.id.map_top_bar).getVisibility() == View.VISIBLE;
|
|
||||||
boolean markerTopBar = findViewById(R.id.map_markers_top_bar).getVisibility() == View.VISIBLE;
|
|
||||||
if (discountController != null) {
|
|
||||||
color = ((DiscountBarController) discountController).getStatusBarColor();
|
|
||||||
}
|
|
||||||
if (((quickSearchTopBar || poiFilterTopBar || mapTopBar) && mapControlsVisible) || contextMenuTopBar) {
|
|
||||||
colorId = night ? R.color.status_bar_route_dark : R.color.status_bar_route_light;
|
|
||||||
} else if (markerTopBar && mapControlsVisible) {
|
|
||||||
colorId = R.color.status_bar_dark;
|
|
||||||
} else {
|
|
||||||
colorId = night ? R.color.status_bar_transparent_dark : R.color.status_bar_transparent_light;
|
|
||||||
}
|
}
|
||||||
if (color == -1) {
|
if (color == -1) {
|
||||||
|
boolean mapTopBar = findViewById(R.id.map_top_bar).getVisibility() == View.VISIBLE;
|
||||||
|
boolean markerTopBar = findViewById(R.id.map_markers_top_bar).getVisibility() == View.VISIBLE;
|
||||||
|
if (mapTopBar && mapControlsVisible) {
|
||||||
|
colorId = night ? R.color.status_bar_route_dark : R.color.status_bar_route_light;
|
||||||
|
} else if (markerTopBar && mapControlsVisible) {
|
||||||
|
colorId = R.color.status_bar_dark;
|
||||||
|
} else {
|
||||||
|
colorId = night ? R.color.status_bar_transparent_dark : R.color.status_bar_transparent_light;
|
||||||
|
}
|
||||||
color = ContextCompat.getColor(this, colorId);
|
color = ContextCompat.getColor(this, colorId);
|
||||||
}
|
}
|
||||||
getWindow().setStatusBarColor(color);
|
getWindow().setStatusBarColor(color);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.osmand.plus.helpers;
|
package net.osmand.plus.helpers;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
@ -332,7 +333,7 @@ public class DiscountHelper {
|
||||||
|
|
||||||
public static class DiscountBarController extends TopToolbarController {
|
public static class DiscountBarController extends TopToolbarController {
|
||||||
|
|
||||||
private int statusBarColor;
|
private int statusBarColor = -1;
|
||||||
|
|
||||||
DiscountBarController() {
|
DiscountBarController() {
|
||||||
super(TopToolbarControllerType.DISCOUNT);
|
super(TopToolbarControllerType.DISCOUNT);
|
||||||
|
@ -345,11 +346,12 @@ public class DiscountHelper {
|
||||||
R.drawable.discount_bar_bg_land, R.drawable.discount_bar_bg_land);
|
R.drawable.discount_bar_bg_land, R.drawable.discount_bar_bg_land);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStatusBarColor() {
|
@Override
|
||||||
|
public int getStatusBarColor(Context context, boolean night) {
|
||||||
return statusBarColor;
|
return statusBarColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatusBarColor(int statusBarColor) {
|
void setStatusBarColor(int statusBarColor) {
|
||||||
this.statusBarColor = statusBarColor;
|
this.statusBarColor = statusBarColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.osmand.plus.mapcontextmenu.other;
|
package net.osmand.plus.mapcontextmenu.other;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
@ -24,14 +25,14 @@ import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.QuadRect;
|
import net.osmand.data.QuadRect;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.plus.GPXUtilities;
|
import net.osmand.plus.GPXUtilities;
|
||||||
|
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||||
import net.osmand.plus.GPXUtilities.WptPt;
|
import net.osmand.plus.GPXUtilities.WptPt;
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
|
||||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||||
import net.osmand.plus.UiUtilities;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
|
@ -630,6 +631,11 @@ public class TrackDetailsMenu {
|
||||||
super.updateToolbar(view);
|
super.updateToolbar(view);
|
||||||
view.getShadowView().setVisibility(View.GONE);
|
view.getShadowView().setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getStatusBarColor(Context context, boolean night) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TrackChartPoints {
|
public class TrackChartPoints {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.osmand.plus.mapmarkers;
|
package net.osmand.plus.mapmarkers;
|
||||||
|
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
@ -965,5 +966,10 @@ public class PlanRouteFragment extends BaseOsmAndFragment implements OsmAndLocat
|
||||||
shadow.setVisibility(View.GONE);
|
shadow.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getStatusBarColor(Context context, boolean night) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.osmand.plus.measurementtool;
|
package net.osmand.plus.measurementtool;
|
||||||
|
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
@ -1579,5 +1580,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
||||||
shadow.setVisibility(View.GONE);
|
shadow.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getStatusBarColor(Context context, boolean night) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,6 +126,10 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
return topToolbarView.getTopController() != null;
|
return topToolbarView.getTopController() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TopToolbarController getTopToolbarController() {
|
||||||
|
return topToolbarView == null ? null : topToolbarView.getTopController();
|
||||||
|
}
|
||||||
|
|
||||||
public TopToolbarController getTopToolbarController(TopToolbarControllerType type) {
|
public TopToolbarController getTopToolbarController(TopToolbarControllerType type) {
|
||||||
return topToolbarView == null ? null : topToolbarView.getController(type);
|
return topToolbarView == null ? null : topToolbarView.getController(type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.osmand.plus.views.mapwidgets;
|
package net.osmand.plus.views.mapwidgets;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.support.annotation.ColorInt;
|
import android.support.annotation.ColorInt;
|
||||||
import android.support.annotation.ColorRes;
|
import android.support.annotation.ColorRes;
|
||||||
|
@ -318,6 +319,11 @@ public class MapInfoWidgetsFactory {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ColorInt
|
||||||
|
public int getStatusBarColor(Context context, boolean night) {
|
||||||
|
return ContextCompat.getColor(context, night ? R.color.status_bar_route_dark : R.color.status_bar_route_light);
|
||||||
|
}
|
||||||
|
|
||||||
public void setTitle(String title) {
|
public void setTitle(String title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue