Add the ability to specify status bar color in the notification json
This commit is contained in:
parent
fa5cd2f507
commit
9da7469c17
3 changed files with 32 additions and 8 deletions
|
@ -5,7 +5,6 @@ import android.content.res.Configuration;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -18,18 +17,15 @@ import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.Version;
|
import net.osmand.plus.Version;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
||||||
|
|
||||||
public class SecondSplashScreenFragment extends Fragment {
|
public class SecondSplashScreenFragment extends BaseOsmAndFragment {
|
||||||
public static final String TAG = "SecondSplashScreenFragment";
|
public static final String TAG = "SecondSplashScreenFragment";
|
||||||
public static boolean SHOW = true;
|
public static boolean SHOW = true;
|
||||||
public static boolean VISIBLE = false;
|
public static boolean VISIBLE = false;
|
||||||
|
|
||||||
public OsmandApplication getMyApplication() {
|
|
||||||
return ((OsmandApplication) getActivity().getApplication());
|
|
||||||
}
|
|
||||||
|
|
||||||
public MapActivity getMapActivity() {
|
public MapActivity getMapActivity() {
|
||||||
return (MapActivity) getActivity();
|
return (MapActivity) getActivity();
|
||||||
}
|
}
|
||||||
|
@ -161,4 +157,9 @@ public class SecondSplashScreenFragment extends Fragment {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
getMapActivity().enableDrawer();
|
getMapActivity().enableDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getStatusBarColorId() {
|
||||||
|
return R.color.status_bar_transparent_light;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,7 @@ import net.osmand.plus.firstusage.FirstUsageWelcomeFragment;
|
||||||
import net.osmand.plus.firstusage.FirstUsageWizardFragment;
|
import net.osmand.plus.firstusage.FirstUsageWizardFragment;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.helpers.DiscountHelper;
|
import net.osmand.plus.helpers.DiscountHelper;
|
||||||
|
import net.osmand.plus.helpers.DiscountHelper.DiscountBarController;
|
||||||
import net.osmand.plus.helpers.ExternalApiHelper;
|
import net.osmand.plus.helpers.ExternalApiHelper;
|
||||||
import net.osmand.plus.helpers.ImportHelper;
|
import net.osmand.plus.helpers.ImportHelper;
|
||||||
import net.osmand.plus.helpers.ImportHelper.ImportGpxBottomSheetDialogFragment;
|
import net.osmand.plus.helpers.ImportHelper.ImportGpxBottomSheetDialogFragment;
|
||||||
|
@ -858,13 +859,18 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
getWindow().setStatusBarColor(ContextCompat.getColor(this, colorId));
|
getWindow().setStatusBarColor(ContextCompat.getColor(this, colorId));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
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);
|
||||||
boolean quickSearchTopBar = getTopToolbarController(TopToolbarControllerType.QUICK_SEARCH) != null;
|
boolean quickSearchTopBar = getTopToolbarController(TopToolbarControllerType.QUICK_SEARCH) != null;
|
||||||
boolean contextMenuTopBar = getTopToolbarController(TopToolbarControllerType.CONTEXT_MENU) != null;
|
boolean contextMenuTopBar = getTopToolbarController(TopToolbarControllerType.CONTEXT_MENU) != null;
|
||||||
boolean poiFilterTopBar = getTopToolbarController(TopToolbarControllerType.POI_FILTER) != null;
|
boolean poiFilterTopBar = getTopToolbarController(TopToolbarControllerType.POI_FILTER) != null;
|
||||||
boolean mapTopBar = findViewById(R.id.map_top_bar).getVisibility() == View.VISIBLE;
|
boolean mapTopBar = findViewById(R.id.map_top_bar).getVisibility() == View.VISIBLE;
|
||||||
boolean markerTopBar = findViewById(R.id.map_markers_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) {
|
if (((quickSearchTopBar || poiFilterTopBar || mapTopBar) && mapControlsVisible) || contextMenuTopBar) {
|
||||||
colorId = night ? R.color.status_bar_route_dark : R.color.status_bar_route_light;
|
colorId = night ? R.color.status_bar_route_dark : R.color.status_bar_route_light;
|
||||||
} else if (markerTopBar && mapControlsVisible) {
|
} else if (markerTopBar && mapControlsVisible) {
|
||||||
|
@ -872,7 +878,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
} else {
|
} else {
|
||||||
colorId = night ? R.color.status_bar_transparent_dark : R.color.status_bar_transparent_light;
|
colorId = night ? R.color.status_bar_transparent_dark : R.color.status_bar_transparent_light;
|
||||||
}
|
}
|
||||||
getWindow().setStatusBarColor(ContextCompat.getColor(this, colorId));
|
if (color == -1) {
|
||||||
|
color = ContextCompat.getColor(this, colorId);
|
||||||
|
}
|
||||||
|
getWindow().setStatusBarColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -198,6 +198,7 @@ public class DiscountHelper {
|
||||||
toolbarController.setDescrTextClrs(data.descrColor, data.descrColor);
|
toolbarController.setDescrTextClrs(data.descrColor, data.descrColor);
|
||||||
toolbarController.setBackBtnIconIds(iconId, iconId);
|
toolbarController.setBackBtnIconIds(iconId, iconId);
|
||||||
toolbarController.setBackBtnIconClrs(data.iconColor, data.iconColor);
|
toolbarController.setBackBtnIconClrs(data.iconColor, data.iconColor);
|
||||||
|
toolbarController.setStatusBarColor(data.statusBarColor);
|
||||||
if (!Algorithms.isEmpty(data.url)) {
|
if (!Algorithms.isEmpty(data.url)) {
|
||||||
View.OnClickListener clickListener = new View.OnClickListener() {
|
View.OnClickListener clickListener = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -303,6 +304,8 @@ public class DiscountHelper {
|
||||||
int titleColor = -1;
|
int titleColor = -1;
|
||||||
@ColorInt
|
@ColorInt
|
||||||
int descrColor = -1;
|
int descrColor = -1;
|
||||||
|
@ColorInt
|
||||||
|
int statusBarColor = -1;
|
||||||
|
|
||||||
static ControllerData parse(OsmandApplication app, JSONObject obj) throws JSONException {
|
static ControllerData parse(OsmandApplication app, JSONObject obj) throws JSONException {
|
||||||
ControllerData res = new ControllerData();
|
ControllerData res = new ControllerData();
|
||||||
|
@ -314,6 +317,7 @@ public class DiscountHelper {
|
||||||
res.bgColor = parseColor("bg_color", obj);
|
res.bgColor = parseColor("bg_color", obj);
|
||||||
res.titleColor = parseColor("title_color", obj);
|
res.titleColor = parseColor("title_color", obj);
|
||||||
res.descrColor = parseColor("description_color", obj);
|
res.descrColor = parseColor("description_color", obj);
|
||||||
|
res.statusBarColor = parseColor("status_bar_color", obj);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +330,9 @@ public class DiscountHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class DiscountBarController extends TopToolbarController {
|
public static class DiscountBarController extends TopToolbarController {
|
||||||
|
|
||||||
|
private int statusBarColor;
|
||||||
|
|
||||||
DiscountBarController() {
|
DiscountBarController() {
|
||||||
super(TopToolbarControllerType.DISCOUNT);
|
super(TopToolbarControllerType.DISCOUNT);
|
||||||
|
@ -338,6 +344,14 @@ public class DiscountHelper {
|
||||||
setBgIds(R.color.discount_bar_bg, R.color.discount_bar_bg,
|
setBgIds(R.color.discount_bar_bg, R.color.discount_bar_bg,
|
||||||
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() {
|
||||||
|
return statusBarColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatusBarColor(int statusBarColor) {
|
||||||
|
this.statusBarColor = statusBarColor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void logError(String msg, Throwable e) {
|
private static void logError(String msg, Throwable e) {
|
||||||
|
|
Loading…
Reference in a new issue