forked from organicmaps/organicmaps-tmp
[android] Added saving/restoring state of the altitude chart on tablet layout
This commit is contained in:
parent
f7221c6c06
commit
5d55ab9eb8
5 changed files with 57 additions and 19 deletions
|
@ -75,8 +75,6 @@ import com.mapswithme.util.ThemeUtils;
|
|||
import com.mapswithme.util.UiUtils;
|
||||
import com.mapswithme.util.Utils;
|
||||
import com.mapswithme.util.concurrency.UiThread;
|
||||
import com.mapswithme.util.log.DebugLogger;
|
||||
import com.mapswithme.util.log.Logger;
|
||||
import com.mapswithme.util.sharing.ShareOption;
|
||||
import com.mapswithme.util.sharing.SharingHelper;
|
||||
import com.mapswithme.util.statistics.AlohaHelper;
|
||||
|
@ -149,7 +147,6 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
|
||||
// The first launch of application ever - onboarding screen will be shown.
|
||||
private boolean mFirstStart;
|
||||
private final Logger mLogger = new DebugLogger(MwmActivity.class.getSimpleName());
|
||||
|
||||
public interface LeftAnimationTrackListener
|
||||
{
|
||||
|
@ -675,6 +672,13 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
if (!mIsFragmentContainer && RoutingController.get().isPlanning())
|
||||
mRoutingPlanInplaceController.onSaveState(outState);
|
||||
|
||||
if (mIsFragmentContainer)
|
||||
{
|
||||
RoutingPlanFragment fragment = (RoutingPlanFragment) getFragment(RoutingPlanFragment.class);
|
||||
if (fragment != null)
|
||||
fragment.saveAltitudeChartState(outState);
|
||||
}
|
||||
|
||||
RoutingController.get().onSaveState();
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@ public class BaseMwmFragmentActivity extends AppCompatActivity
|
|||
{
|
||||
private final BaseActivityDelegate mBaseDelegate = new BaseActivityDelegate(this);
|
||||
|
||||
@Nullable
|
||||
private Bundle mSavedInstanceState;
|
||||
|
||||
@Override
|
||||
public Activity get()
|
||||
{
|
||||
|
@ -91,6 +94,19 @@ public class BaseMwmFragmentActivity extends AppCompatActivity
|
|||
mBaseDelegate.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Bundle savedInstanceState)
|
||||
{
|
||||
super.onRestoreInstanceState(savedInstanceState);
|
||||
mSavedInstanceState = savedInstanceState;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Bundle getSavedInstanceState()
|
||||
{
|
||||
return mSavedInstanceState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item)
|
||||
{
|
||||
|
|
|
@ -3,8 +3,10 @@ package com.mapswithme.maps.routing;
|
|||
import android.animation.ValueAnimator;
|
||||
import android.app.Activity;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.IdRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CompoundButton;
|
||||
|
@ -27,6 +29,7 @@ import com.mapswithme.util.statistics.Statistics;
|
|||
public class RoutingPlanController extends ToolbarController
|
||||
{
|
||||
static final int ANIM_TOGGLE = MwmApplication.get().getResources().getInteger(R.integer.anim_slots_toggle);
|
||||
private static final String STATE_ALTITUDE_CHART_SHOWN = "altitude chart shown";
|
||||
|
||||
protected final View mFrame;
|
||||
private final ImageView mToggle;
|
||||
|
@ -203,11 +206,6 @@ public class RoutingPlanController extends ToolbarController
|
|||
mAltitudeChartShown = false;
|
||||
}
|
||||
|
||||
protected boolean isAltitudeChartShown()
|
||||
{
|
||||
return mAltitudeChartShown;
|
||||
}
|
||||
|
||||
public void updateBuildProgress(int progress, @Framework.RouterType int router)
|
||||
{
|
||||
updateProgressLabels();
|
||||
|
@ -327,4 +325,15 @@ public class RoutingPlanController extends ToolbarController
|
|||
UiUtils.show(altitudeChart);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveAltitudeChartState(@NonNull Bundle outState)
|
||||
{
|
||||
outState.putBoolean(STATE_ALTITUDE_CHART_SHOWN, mAltitudeChartShown);
|
||||
}
|
||||
|
||||
public void restoreAltitudeChartState(@NonNull Bundle state)
|
||||
{
|
||||
if (state.getBoolean(STATE_ALTITUDE_CHART_SHOWN))
|
||||
showRouteAltitudeChart(!isVehicleRouteChecked());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package com.mapswithme.maps.routing;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.R;
|
||||
|
@ -38,6 +37,10 @@ public class RoutingPlanFragment extends BaseMwmFragment
|
|||
}
|
||||
});
|
||||
|
||||
Bundle activityState = getMwmActivity().getSavedInstanceState();
|
||||
if (activityState != null)
|
||||
restoreAltitudeChartState(activityState);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -74,4 +77,14 @@ public class RoutingPlanFragment extends BaseMwmFragment
|
|||
{
|
||||
mPlanController.showRouteAltitudeChart(show);
|
||||
}
|
||||
|
||||
public void restoreAltitudeChartState(@NonNull Bundle state)
|
||||
{
|
||||
mPlanController.restoreAltitudeChartState(state);
|
||||
}
|
||||
|
||||
public void saveAltitudeChartState(@NonNull Bundle outState)
|
||||
{
|
||||
mPlanController.saveAltitudeChartState(outState);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package com.mapswithme.maps.routing;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.MwmActivity;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.bookmarks.data.MapObject;
|
||||
|
@ -19,7 +18,6 @@ import com.mapswithme.util.statistics.Statistics;
|
|||
public class RoutingPlanInplaceController extends RoutingPlanController
|
||||
{
|
||||
private static final String STATE_OPEN = "slots panel open";
|
||||
private static final String STATE_ALTITUDE_CHART_SHOWN = "altitude chart shown";
|
||||
|
||||
private Boolean mSlotsRestoredState;
|
||||
|
||||
|
@ -81,19 +79,18 @@ public class RoutingPlanInplaceController extends RoutingPlanController
|
|||
});
|
||||
}
|
||||
|
||||
public void onSaveState(Bundle outState)
|
||||
public void onSaveState(@NonNull Bundle outState)
|
||||
{
|
||||
outState.putBoolean(STATE_OPEN, isOpen());
|
||||
outState.putBoolean(STATE_ALTITUDE_CHART_SHOWN, isAltitudeChartShown());
|
||||
saveAltitudeChartState(outState);
|
||||
}
|
||||
|
||||
public void restoreState(Bundle state)
|
||||
public void restoreState(@NonNull Bundle state)
|
||||
{
|
||||
if (state.containsKey(STATE_OPEN))
|
||||
mSlotsRestoredState = state.getBoolean(STATE_OPEN);
|
||||
|
||||
if (state.getBoolean(STATE_ALTITUDE_CHART_SHOWN))
|
||||
showRouteAltitudeChart(!isVehicleRouteChecked());
|
||||
restoreAltitudeChartState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -102,5 +99,4 @@ public class RoutingPlanInplaceController extends RoutingPlanController
|
|||
ImageView altitudeChart = (ImageView) mActivity.findViewById(R.id.altitude_chart);
|
||||
showRouteAltitudeChartInternal(show, altitudeChart);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue