[android] fix: Switch day/night theme while routing only.

This commit is contained in:
Alexander Marchuk 2016-01-14 20:17:48 +03:00
parent 38b0c021de
commit 2240199b1a
2 changed files with 22 additions and 12 deletions

View file

@ -26,6 +26,7 @@ import com.mapswithme.maps.R;
import com.mapswithme.maps.bookmarks.data.MapObject;
import com.mapswithme.maps.location.LocationHelper;
import com.mapswithme.util.Config;
import com.mapswithme.util.ThemeSwitcher;
import com.mapswithme.util.ThemeUtils;
import com.mapswithme.util.Utils;
import com.mapswithme.util.concurrency.UiThread;
@ -376,6 +377,8 @@ public class RoutingController
mContainer.showRoutePlan(false, null);
mContainer.showNavigation(true);
ThemeSwitcher.restart();
}
private void suggestRebuildRoute()
@ -456,6 +459,8 @@ public class RoutingController
setState(State.NONE);
Framework.nativeCloseRouting();
ThemeSwitcher.restart();
}
public boolean cancel()

View file

@ -6,6 +6,7 @@ import android.location.Location;
import com.mapswithme.maps.Framework;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.location.LocationHelper;
import com.mapswithme.maps.routing.RoutingController;
import com.mapswithme.util.concurrency.UiThread;
public final class ThemeSwitcher
@ -37,19 +38,23 @@ public final class ThemeSwitcher
@Override
public void run()
{
String theme;
Location last = LocationHelper.INSTANCE.getLastLocation();
if (last == null)
{
LocationHelper.INSTANCE.addLocationListener(mLocationListener, true);
theme = Config.getCurrentUiTheme();
}
else
{
LocationHelper.INSTANCE.removeLocationListener(mLocationListener);
String theme = ThemeUtils.THEME_DEFAULT;
boolean day = Framework.nativeIsDayTime(System.currentTimeMillis() / 1000, last.getLatitude(), last.getLongitude());
theme = (day ? ThemeUtils.THEME_DEFAULT : ThemeUtils.THEME_NIGHT);
if (RoutingController.get().isNavigating())
{
Location last = LocationHelper.INSTANCE.getLastLocation();
if (last == null)
{
LocationHelper.INSTANCE.addLocationListener(mLocationListener, true);
theme = Config.getCurrentUiTheme();
}
else
{
LocationHelper.INSTANCE.removeLocationListener(mLocationListener);
boolean day = Framework.nativeIsDayTime(System.currentTimeMillis() / 1000, last.getLatitude(), last.getLongitude());
theme = (day ? ThemeUtils.THEME_DEFAULT : ThemeUtils.THEME_NIGHT);
}
}
Config.setCurrentUiTheme(theme);