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.TextView;
import android.widget.Toast; import android.widget.Toast;
import net.osmand.IProgress;
import net.osmand.plus.OnDismissDialogFragmentListener; import net.osmand.plus.OnDismissDialogFragmentListener;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
@ -24,6 +25,7 @@ import net.osmand.plus.R;
import net.osmand.plus.base.BottomSheetDialogFragment; import net.osmand.plus.base.BottomSheetDialogFragment;
import net.osmand.plus.dashboard.DashChooseAppDirFragment; import net.osmand.plus.dashboard.DashChooseAppDirFragment;
import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadIndexesThread;
import java.io.File; import java.io.File;
@ -196,11 +198,22 @@ public class DataStoragePlaceDialogFragment extends BottomSheetDialogFragment {
return sz; 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 = private View.OnClickListener deviceMemoryOnClickListener =
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
saveFilesLocation(deviceStorageType, deviceStorage, getActivity()); saveFilesLocation(deviceStorageType, deviceStorage, getActivity());
checkAssets();
updateDownloadIndexes();
isInterestedInFirstTime = false; isInterestedInFirstTime = false;
dismiss(); dismiss();
} }
@ -211,6 +224,8 @@ public class DataStoragePlaceDialogFragment extends BottomSheetDialogFragment {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
saveFilesLocation(sharedStorageType, sharedStorage, getActivity()); saveFilesLocation(sharedStorageType, sharedStorage, getActivity());
checkAssets();
updateDownloadIndexes();
isInterestedInFirstTime = false; isInterestedInFirstTime = false;
dismiss(); dismiss();
} }
@ -221,6 +236,8 @@ public class DataStoragePlaceDialogFragment extends BottomSheetDialogFragment {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
boolean res = saveFilesLocation(cardStorageType, cardStorage, getActivity()); boolean res = saveFilesLocation(cardStorageType, cardStorage, getActivity());
checkAssets();
updateDownloadIndexes();
isInterestedInFirstTime = false; isInterestedInFirstTime = false;
if (res) { if (res) {
dismiss(); dismiss();

View file

@ -350,7 +350,7 @@ public class ResourceManager {
public List<String> reloadIndexesOnStart(AppInitializer progress, List<String> warnings){ public List<String> reloadIndexesOnStart(AppInitializer progress, List<String> warnings){
close(); close();
// check we have some assets to copy to sdcard // check we have some assets to copy to sdcard
warnings.addAll(checkAssets(progress)); warnings.addAll(checkAssets(progress, false));
progress.notifyEvent(InitEvents.ASSETS_COPIED); progress.notifyEvent(InitEvents.ASSETS_COPIED);
reloadIndexes(progress, warnings); reloadIndexes(progress, warnings);
progress.notifyEvent(InitEvents.MAPS_INITIALIZED); progress.notifyEvent(InitEvents.MAPS_INITIALIZED);
@ -414,9 +414,9 @@ public class ResourceManager {
return warnings; return warnings;
} }
private List<String> checkAssets(IProgress progress) { public List<String> checkAssets(IProgress progress, boolean forceUpdate) {
String fv = Version.getFullVersion(context); 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); File applicationDataDir = context.getAppPath(null);
applicationDataDir.mkdirs(); applicationDataDir.mkdirs();
if (applicationDataDir.canWrite()) { if (applicationDataDir.canWrite()) {
@ -424,7 +424,7 @@ public class ResourceManager {
progress.startTask(context.getString(R.string.installing_new_resources), -1); progress.startTask(context.getString(R.string.installing_new_resources), -1);
AssetManager assetManager = context.getAssets(); AssetManager assetManager = context.getAssets();
boolean isFirstInstall = context.getSettings().PREVIOUS_INSTALLED_VERSION.get().equals(""); 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); context.getSettings().PREVIOUS_INSTALLED_VERSION.set(fv);
copyRegionsBoundaries(); copyRegionsBoundaries();
// see Issue #3381 // see Issue #3381