Improve check for bottom sheets night mode
This commit is contained in:
parent
687607698d
commit
bbdd436a15
3 changed files with 20 additions and 11 deletions
|
@ -311,7 +311,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
return nightMode ? R.drawable.bg_bottom_sheet_sides_landscape_dark : R.drawable.bg_bottom_sheet_sides_landscape_light;
|
return nightMode ? R.drawable.bg_bottom_sheet_sides_landscape_dark : R.drawable.bg_bottom_sheet_sides_landscape_light;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isNightMode(@NonNull OsmandApplication app) {
|
protected boolean isNightMode(@NonNull OsmandApplication app) {
|
||||||
if (usedOnMap) {
|
if (usedOnMap) {
|
||||||
return app.getDaynightHelper().isNightModeForMapControls();
|
return app.getDaynightHelper().isNightModeForMapControls();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,11 +41,6 @@ public class SelectAppModesBottomSheetDialogFragment extends AppModesBottomSheet
|
||||||
if (appMode == null) {
|
if (appMode == null) {
|
||||||
appMode = app.getSettings().getApplicationMode();
|
appMode = app.getSettings().getApplicationMode();
|
||||||
}
|
}
|
||||||
if (usedOnMap) {
|
|
||||||
nightMode = app.getDaynightHelper().isNightModeForMapControlsForProfile(getAppMode());
|
|
||||||
} else {
|
|
||||||
nightMode = !app.getSettings().isLightContentForMode(getAppMode());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -112,6 +107,15 @@ public class SelectAppModesBottomSheetDialogFragment extends AppModesBottomSheet
|
||||||
outState.putBoolean(APP_MODE_CHANGEABLE_KEY, appModeChangeable);
|
outState.putBoolean(APP_MODE_CHANGEABLE_KEY, appModeChangeable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isNightMode(@NonNull OsmandApplication app) {
|
||||||
|
if (usedOnMap) {
|
||||||
|
return app.getDaynightHelper().isNightModeForMapControlsForProfile(getAppMode());
|
||||||
|
} else {
|
||||||
|
return !app.getSettings().isLightContentForMode(getAppMode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void showInstance(@NonNull FragmentManager fm, Fragment target, boolean usedOnMap,
|
public static void showInstance(@NonNull FragmentManager fm, Fragment target, boolean usedOnMap,
|
||||||
@Nullable ApplicationMode appMode, boolean appModeChangeable) {
|
@Nullable ApplicationMode appMode, boolean appModeChangeable) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.support.v7.preference.DialogPreference.TargetFragment;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
|
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -35,11 +36,6 @@ public abstract class BasePreferenceBottomSheet extends MenuBottomSheetDialogFra
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
appMode = ApplicationMode.valueOfStringKey(savedInstanceState.getString(APP_MODE_KEY), null);
|
appMode = ApplicationMode.valueOfStringKey(savedInstanceState.getString(APP_MODE_KEY), null);
|
||||||
}
|
}
|
||||||
if (usedOnMap) {
|
|
||||||
nightMode = requiredMyApplication().getDaynightHelper().isNightModeForMapControlsForProfile(getAppMode());
|
|
||||||
} else {
|
|
||||||
nightMode = !requiredMyApplication().getSettings().isLightContentForMode(getAppMode());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -50,6 +46,15 @@ public abstract class BasePreferenceBottomSheet extends MenuBottomSheetDialogFra
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isNightMode(@NonNull OsmandApplication app) {
|
||||||
|
if (usedOnMap) {
|
||||||
|
return app.getDaynightHelper().isNightModeForMapControlsForProfile(getAppMode());
|
||||||
|
} else {
|
||||||
|
return !app.getSettings().isLightContentForMode(getAppMode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getPrefId() {
|
public String getPrefId() {
|
||||||
if (prefId == null) {
|
if (prefId == null) {
|
||||||
Bundle args = getArguments();
|
Bundle args = getArguments();
|
||||||
|
|
Loading…
Reference in a new issue