Fix getting type of content (light/dark)
This commit is contained in:
parent
f88b554709
commit
d7bc5c840d
11 changed files with 32 additions and 52 deletions
|
@ -3,6 +3,7 @@ package net.osmand.plus.base;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.support.annotation.DrawableRes;
|
import android.support.annotation.DrawableRes;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewTreeObserver;
|
import android.view.ViewTreeObserver;
|
||||||
|
@ -15,6 +16,18 @@ import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
|
|
||||||
public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
||||||
|
|
||||||
|
private static final String USED_ON_MAP_KEY = "used_on_map";
|
||||||
|
|
||||||
|
protected boolean usedOnMap;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
usedOnMap = savedInstanceState.getBoolean(USED_ON_MAP_KEY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
@ -26,6 +39,12 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putBoolean(USED_ON_MAP_KEY, usedOnMap);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Drawable getContentIcon(@DrawableRes int id) {
|
protected Drawable getContentIcon(@DrawableRes int id) {
|
||||||
return getIcon(id, isNightMode() ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color);
|
return getIcon(id, isNightMode() ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color);
|
||||||
|
@ -77,5 +96,10 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract boolean isNightMode();
|
protected boolean isNightMode() {
|
||||||
|
if (usedOnMap) {
|
||||||
|
getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||||
|
}
|
||||||
|
return !getMyApplication().getSettings().isLightContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -632,6 +632,7 @@ public class GpxImportHelper {
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
usedOnMap = true;
|
||||||
boolean night = isNightMode();
|
boolean night = isNightMode();
|
||||||
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
|
|
||||||
|
@ -678,10 +679,5 @@ public class GpxImportHelper {
|
||||||
|
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean isNightMode() {
|
|
||||||
return getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,11 +162,6 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean isNightMode() {
|
|
||||||
return !getMyApplication().getSettings().isLightContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void highlightSelectedItem(boolean check) {
|
private void highlightSelectedItem(boolean check) {
|
||||||
int iconColor = check ? R.color.dashboard_blue : night ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color;
|
int iconColor = check ? R.color.dashboard_blue : night ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color;
|
||||||
int textColor = ContextCompat.getColor(getContext(), check ? (night ? R.color.color_dialog_buttons_dark : R.color.dashboard_blue) : night ? R.color.color_white : R.color.color_black);
|
int textColor = ContextCompat.getColor(getContext(), check ? (night ? R.color.color_dialog_buttons_dark : R.color.dashboard_blue) : night ? R.color.color_white : R.color.color_black);
|
||||||
|
|
|
@ -35,6 +35,7 @@ public class HistoryMarkerMenuBottomSheetDialogFragment extends MenuBottomSheetD
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
usedOnMap = true;
|
||||||
final boolean nightMode = isNightMode();
|
final boolean nightMode = isNightMode();
|
||||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
|
|
||||||
|
@ -92,11 +93,6 @@ public class HistoryMarkerMenuBottomSheetDialogFragment extends MenuBottomSheetD
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean isNightMode() {
|
|
||||||
return getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
|
||||||
}
|
|
||||||
|
|
||||||
interface HistoryMarkerMenuFragmentListener {
|
interface HistoryMarkerMenuFragmentListener {
|
||||||
|
|
||||||
void onMakeMarkerActive(int pos);
|
void onMakeMarkerActive(int pos);
|
||||||
|
|
|
@ -147,11 +147,6 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean isNightMode() {
|
|
||||||
return !getMyApplication().getSettings().isLightContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MarkerOptionsFragmentListener {
|
interface MarkerOptionsFragmentListener {
|
||||||
|
|
||||||
void sortByOnClick();
|
void sortByOnClick();
|
||||||
|
|
|
@ -64,11 +64,6 @@ public class OrderByBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean isNightMode() {
|
|
||||||
return !getMyApplication().getSettings().isLightContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private View.OnClickListener orderByModeOnClickListener = new View.OnClickListener() {
|
private View.OnClickListener orderByModeOnClickListener = new View.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -33,8 +33,9 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends MenuBottomSheetDi
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
usedOnMap = true;
|
||||||
boolean portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
boolean portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
||||||
boolean night = getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
boolean night = isNightMode();
|
||||||
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
|
|
||||||
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_plan_route_options_bottom_sheet_dialog, container);
|
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_plan_route_options_bottom_sheet_dialog, container);
|
||||||
|
@ -116,11 +117,6 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends MenuBottomSheetDi
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean isNightMode() {
|
|
||||||
return getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PlanRouteOptionsFragmentListener {
|
interface PlanRouteOptionsFragmentListener {
|
||||||
|
|
||||||
void selectOnClick();
|
void selectOnClick();
|
||||||
|
|
|
@ -134,11 +134,6 @@ public class ShowDirectionBottomSheetDialogFragment extends MenuBottomSheetDialo
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean isNightMode() {
|
|
||||||
return !getMyApplication().getSettings().isLightContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private MapActivity getMapActivity() {
|
private MapActivity getMapActivity() {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
usedOnMap = true;
|
||||||
boolean nightMode = isNightMode();
|
boolean nightMode = isNightMode();
|
||||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
|
|
||||||
|
@ -122,11 +123,6 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean isNightMode() {
|
|
||||||
return getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
|
||||||
}
|
|
||||||
|
|
||||||
interface OptionsFragmentListener {
|
interface OptionsFragmentListener {
|
||||||
|
|
||||||
void snapToRoadOnCLick();
|
void snapToRoadOnCLick();
|
||||||
|
|
|
@ -26,6 +26,7 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends MenuBottomSheetDial
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
usedOnMap = true;
|
||||||
boolean nightMode = isNightMode();
|
boolean nightMode = isNightMode();
|
||||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
|
|
||||||
|
@ -103,11 +104,6 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends MenuBottomSheetDial
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean isNightMode() {
|
|
||||||
return getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
|
||||||
}
|
|
||||||
|
|
||||||
interface SaveAsNewTrackFragmentListener {
|
interface SaveAsNewTrackFragmentListener {
|
||||||
|
|
||||||
void saveAsRoutePointOnClick();
|
void saveAsRoutePointOnClick();
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
usedOnMap = true;
|
||||||
final MapActivity mapActivity = (MapActivity) getActivity();
|
final MapActivity mapActivity = (MapActivity) getActivity();
|
||||||
boolean nightMode = isNightMode();
|
boolean nightMode = isNightMode();
|
||||||
final MeasurementToolLayer measurementLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
|
final MeasurementToolLayer measurementLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
|
||||||
|
@ -145,11 +146,6 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean isNightMode() {
|
|
||||||
return getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dismiss() {
|
public void dismiss() {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
|
|
Loading…
Reference in a new issue