diff --git a/OsmAnd/src/net/osmand/plus/download/ui/DataStoragePlaceDialogFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/DataStoragePlaceDialogFragment.java index 8bd107fff7..a159d4bb6f 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/DataStoragePlaceDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/DataStoragePlaceDialogFragment.java @@ -17,6 +17,7 @@ import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; +import net.osmand.IProgress; import net.osmand.plus.OnDismissDialogFragmentListener; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; @@ -24,6 +25,7 @@ import net.osmand.plus.R; import net.osmand.plus.base.BottomSheetDialogFragment; import net.osmand.plus.dashboard.DashChooseAppDirFragment; import net.osmand.plus.download.DownloadActivity; +import net.osmand.plus.download.DownloadIndexesThread; import java.io.File; @@ -196,11 +198,22 @@ public class DataStoragePlaceDialogFragment extends BottomSheetDialogFragment { return sz; } + private void checkAssets() { + getMyApplication().getResourceManager().checkAssets(IProgress.EMPTY_PROGRESS, true); + } + + private void updateDownloadIndexes() { + DownloadIndexesThread downloadIndexesThread = getMyApplication().getDownloadThread(); + downloadIndexesThread.runReloadIndexFilesSilent(); + } + private View.OnClickListener deviceMemoryOnClickListener = new View.OnClickListener() { @Override public void onClick(View v) { saveFilesLocation(deviceStorageType, deviceStorage, getActivity()); + checkAssets(); + updateDownloadIndexes(); isInterestedInFirstTime = false; dismiss(); } @@ -211,6 +224,8 @@ public class DataStoragePlaceDialogFragment extends BottomSheetDialogFragment { @Override public void onClick(View v) { saveFilesLocation(sharedStorageType, sharedStorage, getActivity()); + checkAssets(); + updateDownloadIndexes(); isInterestedInFirstTime = false; dismiss(); } @@ -221,6 +236,8 @@ public class DataStoragePlaceDialogFragment extends BottomSheetDialogFragment { @Override public void onClick(View v) { boolean res = saveFilesLocation(cardStorageType, cardStorage, getActivity()); + checkAssets(); + updateDownloadIndexes(); isInterestedInFirstTime = false; if (res) { dismiss(); diff --git a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java index 26fa4599c1..98255722b9 100644 --- a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java +++ b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java @@ -350,7 +350,7 @@ public class ResourceManager { public List reloadIndexesOnStart(AppInitializer progress, List warnings){ close(); // check we have some assets to copy to sdcard - warnings.addAll(checkAssets(progress)); + warnings.addAll(checkAssets(progress, false)); progress.notifyEvent(InitEvents.ASSETS_COPIED); reloadIndexes(progress, warnings); progress.notifyEvent(InitEvents.MAPS_INITIALIZED); @@ -414,9 +414,9 @@ public class ResourceManager { return warnings; } - private List checkAssets(IProgress progress) { + public List checkAssets(IProgress progress, boolean forceUpdate) { String fv = Version.getFullVersion(context); - if (!fv.equalsIgnoreCase(context.getSettings().PREVIOUS_INSTALLED_VERSION.get())) { + if (!fv.equalsIgnoreCase(context.getSettings().PREVIOUS_INSTALLED_VERSION.get()) || forceUpdate) { File applicationDataDir = context.getAppPath(null); applicationDataDir.mkdirs(); if (applicationDataDir.canWrite()) { @@ -424,7 +424,7 @@ public class ResourceManager { progress.startTask(context.getString(R.string.installing_new_resources), -1); AssetManager assetManager = context.getAssets(); boolean isFirstInstall = context.getSettings().PREVIOUS_INSTALLED_VERSION.get().equals(""); - unpackBundledAssets(assetManager, applicationDataDir, progress, isFirstInstall); + unpackBundledAssets(assetManager, applicationDataDir, progress, isFirstInstall || forceUpdate); context.getSettings().PREVIOUS_INSTALLED_VERSION.set(fv); copyRegionsBoundaries(); // see Issue #3381