Add the ability to specify status bar color in the notification json
This commit is contained in:
parent
6e14f7b495
commit
4a2b9abda1
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.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -18,18 +17,15 @@ 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.base.BaseOsmAndFragment;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
||||
|
||||
public class SecondSplashScreenFragment extends Fragment {
|
||||
public class SecondSplashScreenFragment extends BaseOsmAndFragment {
|
||||
public static final String TAG = "SecondSplashScreenFragment";
|
||||
public static boolean SHOW = true;
|
||||
public static boolean VISIBLE = false;
|
||||
|
||||
public OsmandApplication getMyApplication() {
|
||||
return ((OsmandApplication) getActivity().getApplication());
|
||||
}
|
||||
|
||||
public MapActivity getMapActivity() {
|
||||
return (MapActivity) getActivity();
|
||||
}
|
||||
|
@ -161,4 +157,9 @@ public class SecondSplashScreenFragment extends Fragment {
|
|||
super.onPause();
|
||||
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.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.helpers.DiscountHelper;
|
||||
import net.osmand.plus.helpers.DiscountHelper.DiscountBarController;
|
||||
import net.osmand.plus.helpers.ExternalApiHelper;
|
||||
import net.osmand.plus.helpers.ImportHelper;
|
||||
import net.osmand.plus.helpers.ImportHelper.ImportGpxBottomSheetDialogFragment;
|
||||
|
@ -858,13 +859,18 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
getWindow().setStatusBarColor(ContextCompat.getColor(this, colorId));
|
||||
return;
|
||||
}
|
||||
int color = -1;
|
||||
boolean mapControlsVisible = findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE;
|
||||
boolean night = app.getDaynightHelper().isNightModeForMapControls();
|
||||
TopToolbarController discountController = getTopToolbarController(TopToolbarControllerType.DISCOUNT);
|
||||
boolean quickSearchTopBar = getTopToolbarController(TopToolbarControllerType.QUICK_SEARCH) != null;
|
||||
boolean contextMenuTopBar = getTopToolbarController(TopToolbarControllerType.CONTEXT_MENU) != null;
|
||||
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) {
|
||||
|
@ -872,7 +878,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
} else {
|
||||
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.setBackBtnIconIds(iconId, iconId);
|
||||
toolbarController.setBackBtnIconClrs(data.iconColor, data.iconColor);
|
||||
toolbarController.setStatusBarColor(data.statusBarColor);
|
||||
if (!Algorithms.isEmpty(data.url)) {
|
||||
View.OnClickListener clickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -303,6 +304,8 @@ public class DiscountHelper {
|
|||
int titleColor = -1;
|
||||
@ColorInt
|
||||
int descrColor = -1;
|
||||
@ColorInt
|
||||
int statusBarColor = -1;
|
||||
|
||||
static ControllerData parse(OsmandApplication app, JSONObject obj) throws JSONException {
|
||||
ControllerData res = new ControllerData();
|
||||
|
@ -314,6 +317,7 @@ public class DiscountHelper {
|
|||
res.bgColor = parseColor("bg_color", obj);
|
||||
res.titleColor = parseColor("title_color", obj);
|
||||
res.descrColor = parseColor("description_color", obj);
|
||||
res.statusBarColor = parseColor("status_bar_color", obj);
|
||||
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() {
|
||||
super(TopToolbarControllerType.DISCOUNT);
|
||||
|
@ -338,6 +344,14 @@ public class DiscountHelper {
|
|||
setBgIds(R.color.discount_bar_bg, R.color.discount_bar_bg,
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue