Merge pull request #774 from trashkalmar/mm-2106-save-slots-state-master

[android] fix: Restore slots state after device rotated.
This commit is contained in:
Dmitry Yunitsky 2015-11-30 17:45:53 +03:00
commit 7f9f7d63a2
3 changed files with 33 additions and 2 deletions

View file

@ -576,6 +576,9 @@ public class MwmActivity extends BaseMwmFragmentActivity
outState.putParcelable(STATE_MAP_OBJECT, mPlacePage.getMapObject());
}
if (!mIsFragmentContainer && RoutingController.get().isPlanning())
mRoutingPlanInplaceController.onSaveState(outState);
super.onSaveInstanceState(outState);
}
@ -589,6 +592,9 @@ public class MwmActivity extends BaseMwmFragmentActivity
mPlacePage.setMapObject((MapObject) savedInstanceState.getParcelable(STATE_MAP_OBJECT));
mPlacePage.setState(State.PREVIEW);
}
if (!mIsFragmentContainer && RoutingController.get().isPlanning())
mRoutingPlanInplaceController.restoreState(savedInstanceState);
}
@Override

View file

@ -8,6 +8,7 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RadioGroup;
import android.widget.TextView;
import com.mapswithme.maps.Framework;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
@ -246,4 +247,9 @@ public class RoutingPlanController extends ToolbarController
UiUtils.hide(mToggle);
showSlots(true, false);
}
public boolean isOpen()
{
return mOpen;
}
}

View file

@ -1,5 +1,6 @@
package com.mapswithme.maps.routing;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
@ -12,6 +13,10 @@ import com.mapswithme.util.statistics.Statistics;
public class RoutingPlanInplaceController extends RoutingPlanController
{
private static final String STATE_OPEN = "slots panel open";
private Boolean mSlotsRestoredState;
public RoutingPlanInplaceController(MwmActivity activity)
{
super(activity.findViewById(R.id.routing_plan_frame), activity);
@ -24,8 +29,11 @@ public class RoutingPlanInplaceController extends RoutingPlanController
if (show)
{
showSlots(!(RoutingController.get().getStartPoint() instanceof MapObject.MyPosition) || (RoutingController.get().getEndPoint() == null),
false);
boolean open = (mSlotsRestoredState == null ? !(RoutingController.get().getStartPoint() instanceof MapObject.MyPosition) ||
(RoutingController.get().getEndPoint() == null)
: mSlotsRestoredState);
showSlots(open, false);
mSlotsRestoredState = null;
}
UiUtils.showIf(show, mFrame);
@ -55,4 +63,15 @@ public class RoutingPlanInplaceController extends RoutingPlanController
}
});
}
public void onSaveState(Bundle outState)
{
outState.putBoolean(STATE_OPEN, isOpen());
}
public void restoreState(Bundle state)
{
if (state.containsKey(STATE_OPEN))
mSlotsRestoredState = state.getBoolean(STATE_OPEN);
}
}