From d3354ffa5693caf0d6bcc2d4137b621a3f0867be Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Mon, 22 May 2017 20:23:57 +0300 Subject: [PATCH] Fix #3783 --- .../net/osmand/plus/OsmandApplication.java | 15 +++++++++- .../osmand/plus/activities/MapActivity.java | 2 ++ .../plus/download/DownloadFileHelper.java | 28 ++++++++++--------- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index 4f9e0633cd..b81c18bca2 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -28,7 +28,6 @@ import net.osmand.CallbackWithObject; import net.osmand.PlatformUtil; import net.osmand.access.AccessibilityPlugin; import net.osmand.aidl.OsmandAidlApi; -import net.osmand.aidl.OsmandAidlService; import net.osmand.data.LatLon; import net.osmand.map.OsmandRegions; import net.osmand.map.WorldRegion; @@ -73,6 +72,20 @@ import btools.routingapp.BRouterServiceConnection; import btools.routingapp.IBRouterService; public class OsmandApplication extends MultiDexApplication { + public static boolean isActivityVisible() { + return activityVisible; + } + + public static void activityResumed() { + activityVisible = true; + } + + public static void activityPaused() { + activityVisible = false; + } + + private static boolean activityVisible; + public static final String EXCEPTION_PATH = "exception.log"; //$NON-NLS-1$ private static final org.apache.commons.logging.Log LOG = PlatformUtil.getLog(OsmandApplication.class); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 689bfa3640..307805eea1 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -685,6 +685,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven new XMasDialogFragment().show(getSupportFragmentManager(), XMasDialogFragment.TAG); } FirstUsageWelcomeFragment.SHOW = false; + OsmandApplication.activityResumed(); } @Override @@ -1029,6 +1030,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven getMyApplication().getAppCustomization().pauseActivity(MapActivity.class); app.getResourceManager().interruptRendering(); OsmandPlugin.onMapActivityPause(this); + OsmandApplication.activityPaused(); } public void updateApplicationModeSettings() { diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadFileHelper.java b/OsmAnd/src/net/osmand/plus/download/DownloadFileHelper.java index c93d70cd81..e20cb3fdf8 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadFileHelper.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadFileHelper.java @@ -1,17 +1,5 @@ package net.osmand.plus.download; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.zip.GZIPInputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - import net.osmand.IProgress; import net.osmand.IndexConstants; import net.osmand.PlatformUtil; @@ -24,6 +12,18 @@ import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.zip.GZIPInputStream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + public class DownloadFileHelper { private final static Log log = PlatformUtil.getLog(DownloadFileHelper.class); @@ -224,7 +224,9 @@ public class DownloadFileHelper { copyVoiceConfig(de); } toReIndex.add(de.targetFile); - showWarningCallback.showWarning(ctx.getString(R.string.shared_string_download_successful)); + if (OsmandApplication.isActivityVisible()) { + showWarningCallback.showWarning(ctx.getString(R.string.shared_string_download_successful)); + } return true; } catch (IOException e) { log.error("Exception ocurred", e); //$NON-NLS-1$