diff options
-rw-r--r-- | android/src/com/mapswithme/maps/SplashActivity.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/android/src/com/mapswithme/maps/SplashActivity.java b/android/src/com/mapswithme/maps/SplashActivity.java index d114a9f25d..2f847c4462 100644 --- a/android/src/com/mapswithme/maps/SplashActivity.java +++ b/android/src/com/mapswithme/maps/SplashActivity.java @@ -8,9 +8,11 @@ import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.DialogFragment; +import android.support.v4.app.FragmentManager; import android.support.v7.app.AppCompatActivity; import android.view.View; +import com.mapswithme.maps.downloader.UpdaterDialogFragment; import com.mapswithme.maps.editor.ViralFragment; import com.mapswithme.maps.news.BaseNewsFragment; import com.mapswithme.maps.news.NewsFragment; @@ -95,6 +97,7 @@ public class SplashActivity extends AppCompatActivity protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); + handleUpdateMapsFragmentCorrectly(savedInstanceState); UiThread.cancelDelayedTasks(mPermissionsDelayedTask); UiThread.cancelDelayedTasks(mInitCoreDelayedTask); UiThread.cancelDelayedTasks(mFinalDelayedTask); @@ -102,6 +105,39 @@ public class SplashActivity extends AppCompatActivity initView(); } + private void handleUpdateMapsFragmentCorrectly(@Nullable Bundle savedInstanceState) + { + if (savedInstanceState == null) + return; + + FragmentManager fm = getSupportFragmentManager(); + DialogFragment updaterFragment = (DialogFragment) fm + .findFragmentByTag(UpdaterDialogFragment.class.getName()); + + if (updaterFragment == null) + return; + + // If the user revoked the external storage permission while the app was killed + // we can't update maps automatically during recovering process, so just dismiss updater fragment + // and ask the user to grant the permission. + if (!PermissionsUtils.isExternalStorageGranted()) + { + fm.beginTransaction().remove(updaterFragment).commitAllowingStateLoss(); + fm.executePendingTransactions(); + StoragePermissionsDialogFragment.show(this); + } + else + { + // If external permissions are still granted we just need to check platform + // and core initialization, because we may be in the recovering process, + // i.e. method onResume() may not be invoked in that case. + if (!MwmApplication.get().arePlatformAndCoreInitialized()) + { + init(); + } + } + } + @Override protected void onResume() { |