Merge pull request #1409 from trashkalmar/switch-theme-on-routing-only

[android] fix: Switch day/night theme while routing only.
This commit is contained in:
Dmitry Yunitsky 2016-01-15 18:39:54 +03:00
commit 5c7adfd8b5
2 changed files with 21 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()
@ -455,6 +458,7 @@ public class RoutingController
setBuildState(BuildState.NONE);
setState(State.NONE);
ThemeSwitcher.restart();
Framework.nativeCloseRouting();
}

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);