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.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
|
@ -15,6 +16,18 @@ import net.osmand.plus.helpers.AndroidUiHelper;
|
|||
|
||||
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
|
||||
public void 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
|
||||
protected Drawable getContentIcon(@DrawableRes int id) {
|
||||
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
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
usedOnMap = true;
|
||||
boolean night = isNightMode();
|
||||
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
|
||||
|
@ -678,10 +679,5 @@ public class GpxImportHelper {
|
|||
|
||||
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) {
|
||||
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);
|
||||
|
|
|
@ -35,6 +35,7 @@ public class HistoryMarkerMenuBottomSheetDialogFragment extends MenuBottomSheetD
|
|||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
usedOnMap = true;
|
||||
final boolean nightMode = isNightMode();
|
||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
|
||||
|
@ -92,11 +93,6 @@ public class HistoryMarkerMenuBottomSheetDialogFragment extends MenuBottomSheetD
|
|||
return mainView;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isNightMode() {
|
||||
return getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
}
|
||||
|
||||
interface HistoryMarkerMenuFragmentListener {
|
||||
|
||||
void onMakeMarkerActive(int pos);
|
||||
|
|
|
@ -147,11 +147,6 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
|
|||
return mainView;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isNightMode() {
|
||||
return !getMyApplication().getSettings().isLightContent();
|
||||
}
|
||||
|
||||
interface MarkerOptionsFragmentListener {
|
||||
|
||||
void sortByOnClick();
|
||||
|
|
|
@ -64,11 +64,6 @@ public class OrderByBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
|
|||
return mainView;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isNightMode() {
|
||||
return !getMyApplication().getSettings().isLightContent();
|
||||
}
|
||||
|
||||
private View.OnClickListener orderByModeOnClickListener = new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,8 +33,9 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends MenuBottomSheetDi
|
|||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
usedOnMap = true;
|
||||
boolean portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
||||
boolean night = getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
boolean night = isNightMode();
|
||||
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);
|
||||
|
@ -116,11 +117,6 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends MenuBottomSheetDi
|
|||
return mainView;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isNightMode() {
|
||||
return getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
}
|
||||
|
||||
interface PlanRouteOptionsFragmentListener {
|
||||
|
||||
void selectOnClick();
|
||||
|
|
|
@ -134,11 +134,6 @@ public class ShowDirectionBottomSheetDialogFragment extends MenuBottomSheetDialo
|
|||
return mainView;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isNightMode() {
|
||||
return !getMyApplication().getSettings().isLightContent();
|
||||
}
|
||||
|
||||
private MapActivity getMapActivity() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null) {
|
||||
|
|
|
@ -36,6 +36,7 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
|
|||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
usedOnMap = true;
|
||||
boolean nightMode = isNightMode();
|
||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
|
||||
|
@ -122,11 +123,6 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
|
|||
return mainView;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isNightMode() {
|
||||
return getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
}
|
||||
|
||||
interface OptionsFragmentListener {
|
||||
|
||||
void snapToRoadOnCLick();
|
||||
|
|
|
@ -26,6 +26,7 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends MenuBottomSheetDial
|
|||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
usedOnMap = true;
|
||||
boolean nightMode = isNightMode();
|
||||
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 {
|
||||
|
||||
void saveAsRoutePointOnClick();
|
||||
|
|
|
@ -34,6 +34,7 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo
|
|||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
usedOnMap = true;
|
||||
final MapActivity mapActivity = (MapActivity) getActivity();
|
||||
boolean nightMode = isNightMode();
|
||||
final MeasurementToolLayer measurementLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
|
||||
|
@ -145,11 +146,6 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo
|
|||
return mainView;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isNightMode() {
|
||||
return getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
if (listener != null) {
|
||||
|
|
Loading…
Reference in a new issue