Hide splash screen when map is shown
This commit is contained in:
parent
9b54fb7725
commit
e144f0858a
3 changed files with 22 additions and 9 deletions
|
@ -22,7 +22,7 @@ import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
public class SecondSplashScreenFragment extends Fragment {
|
public class SecondSplashScreenFragment extends Fragment {
|
||||||
public static final String TAG = "SecondSplashScreenFragment";
|
public static final String TAG = "SecondSplashScreenFragment";
|
||||||
public static boolean SHOW = true;
|
public static boolean SHOW = true;
|
||||||
private static final int SECOND_SPLASH_TIME_OUT = 5000;
|
private static final int SECOND_SPLASH_TIME_OUT = 8000;
|
||||||
private boolean started = false;
|
private boolean started = false;
|
||||||
private FragmentActivity activity;
|
private FragmentActivity activity;
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
|
@ -142,18 +142,15 @@ public class SecondSplashScreenFragment extends Fragment {
|
||||||
}
|
}
|
||||||
if (!started) {
|
if (!started) {
|
||||||
started = true;
|
started = true;
|
||||||
|
SecondSplashScreenFragment.SHOW = false;
|
||||||
new Handler().postDelayed(new Runnable() {
|
new Handler().postDelayed(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (activity instanceof MapActivity) {
|
android.util.Log.d("Splash", "dismisssplashinsplash");
|
||||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
if (activity instanceof MapActivity && !((MapActivity) activity).isActivityDestroyed()) {
|
||||||
if (app.getSettings().MAP_SCREEN_ORIENTATION.get() != activity.getRequestedOrientation()) {
|
((MapActivity)activity).dismissSecondSplashScreen();
|
||||||
activity.setRequestedOrientation(app.getSettings().MAP_SCREEN_ORIENTATION.get());
|
|
||||||
// can't return from this method we are not sure if activity will be recreated or not
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
activity.getSupportFragmentManager().beginTransaction().remove(SecondSplashScreenFragment.this).commitAllowingStateLoss();
|
|
||||||
}
|
}
|
||||||
}, SECOND_SPLASH_TIME_OUT);
|
}, SECOND_SPLASH_TIME_OUT);
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,6 +189,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
private boolean mIsDestroyed = false;
|
private boolean mIsDestroyed = false;
|
||||||
private InAppHelper inAppHelper;
|
private InAppHelper inAppHelper;
|
||||||
|
|
||||||
|
private SecondSplashScreenFragment secondSplashScreenFragment;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
setRequestedOrientation(AndroidUiHelper.getScreenOrientation(this));
|
setRequestedOrientation(AndroidUiHelper.getScreenOrientation(this));
|
||||||
|
@ -692,7 +694,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
}
|
}
|
||||||
FirstUsageWelcomeFragment.SHOW = false;
|
FirstUsageWelcomeFragment.SHOW = false;
|
||||||
if (SecondSplashScreenFragment.SHOW) {
|
if (SecondSplashScreenFragment.SHOW) {
|
||||||
getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, new SecondSplashScreenFragment(), SecondSplashScreenFragment.TAG).commitAllowingStateLoss();
|
secondSplashScreenFragment = new SecondSplashScreenFragment();
|
||||||
|
getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, secondSplashScreenFragment, SecondSplashScreenFragment.TAG).commitAllowingStateLoss();
|
||||||
} else {
|
} else {
|
||||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
||||||
if (settings.MAP_SCREEN_ORIENTATION.get() != getRequestedOrientation()) {
|
if (settings.MAP_SCREEN_ORIENTATION.get() != getRequestedOrientation()) {
|
||||||
|
@ -700,7 +703,16 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
// can't return from this method we are not sure if activity will be recreated or not
|
// can't return from this method we are not sure if activity will be recreated or not
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dismissSecondSplashScreen() {
|
||||||
SecondSplashScreenFragment.SHOW = false;
|
SecondSplashScreenFragment.SHOW = false;
|
||||||
|
getSupportFragmentManager().beginTransaction().remove(secondSplashScreenFragment).commitAllowingStateLoss();
|
||||||
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
||||||
|
if (app.getSettings().MAP_SCREEN_ORIENTATION.get() != getRequestedOrientation()) {
|
||||||
|
setRequestedOrientation(app.getSettings().MAP_SCREEN_ORIENTATION.get());
|
||||||
|
// can't return from this method we are not sure if activity will be recreated or not
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,6 +29,7 @@ import android.view.WindowManager;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
|
import net.osmand.SecondSplashScreenFragment;
|
||||||
import net.osmand.access.AccessibilityActionsProvider;
|
import net.osmand.access.AccessibilityActionsProvider;
|
||||||
import net.osmand.core.android.MapRendererView;
|
import net.osmand.core.android.MapRendererView;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
@ -655,6 +656,9 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
||||||
} else if (doubleTapScaleDetector.isInZoomMode()) {
|
} else if (doubleTapScaleDetector.isInZoomMode()) {
|
||||||
drawMapPosition(canvas, doubleTapScaleDetector.getCenterX(), doubleTapScaleDetector.getCenterY());
|
drawMapPosition(canvas, doubleTapScaleDetector.getCenterX(), doubleTapScaleDetector.getCenterY());
|
||||||
}
|
}
|
||||||
|
if (activity instanceof MapActivity && !((MapActivity) activity).isActivityDestroyed() && ((MapActivity) activity).getSupportFragmentManager().findFragmentByTag(SecondSplashScreenFragment.TAG) != null) {
|
||||||
|
((MapActivity) activity).dismissSecondSplashScreen();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue