Merge branch 'master' of ssh://github.com/osmandapp/Osmand into measurement_tools

This commit is contained in:
Alexander Sytnyk 2017-07-31 18:13:51 +03:00
commit 16804410f2
2 changed files with 21 additions and 4 deletions

View file

@ -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();

View file

@ -350,7 +350,7 @@ public class ResourceManager {
public List<String> reloadIndexesOnStart(AppInitializer progress, List<String> 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<String> checkAssets(IProgress progress) {
public List<String> 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