From 13b4ad78b42913f6f7cbfae0add85baeb7fda447 Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Wed, 28 Oct 2015 16:06:19 +0200 Subject: [PATCH] Update dialog partilly implemnented --- OsmAnd/no_translate.xml | 10 +++--- .../src/net/osmand/plus/AppInitializer.java | 21 ++++-------- .../osmand/plus/activities/MapActivity.java | 25 +++++++------- .../plus/dialogs/WhatsNewDialogFragment.java | 33 +++++++++++++++++++ 4 files changed, 57 insertions(+), 32 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/dialogs/WhatsNewDialogFragment.java diff --git a/OsmAnd/no_translate.xml b/OsmAnd/no_translate.xml index ceaa3a3ca8..3013835a52 100644 --- a/OsmAnd/no_translate.xml +++ b/OsmAnd/no_translate.xml @@ -1,5 +1,5 @@ - + OsmAnd~ 2.2.0 - - New road indexes (including map data, poi, address) - - New speed system (knots and minutes per km) - - New context menu - - Drawer and start with the map + \u2022 New Wikipedia data is structured by country and contains many more points than before\n\n + \u2022 Better route recalculation (after several attempts engine suggests a different route)\n\n + \u2022 POI Search now supports more specific queries (like fuel type and religion specific queries)\n\n + and more... UA-28342846-2 10 diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 3dfb3f20f9..040a50bc68 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -18,7 +18,6 @@ import net.osmand.map.WorldRegion; import net.osmand.osm.AbstractPoiType; import net.osmand.osm.MapPoiTypes; import net.osmand.plus.activities.DayNightHelper; -import net.osmand.plus.activities.HelpActivity; import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.helpers.AvoidSpecificRoads; @@ -79,23 +78,23 @@ public class AppInitializer implements IProgress { private long startTime; private long startBgTime; private boolean appInitializing = true; - private List warnings = new ArrayList(); + private List warnings = new ArrayList<>(); private String taskName; - private List listeners = new ArrayList(); + private List listeners = new ArrayList<>(); private SharedPreferences startPrefs; public enum InitEvents { FAVORITES_INITIALIZED, NATIVE_INITIALIZED, NATIVE_OPEN_GLINITIALIZED, TASK_CHANGED, MAPS_INITIALIZED, POI_TYPES_INITIALIZED, ASSETS_COPIED, INIT_RENDERERS, - RESTORE_BACKUPS, INDEX_REGION_BOUNDARIES, SAVE_GPX_TRACKS, LOAD_GPX_TRACKS; + RESTORE_BACKUPS, INDEX_REGION_BOUNDARIES, SAVE_GPX_TRACKS, LOAD_GPX_TRACKS } public interface AppInitializeListener { - public void onProgress(AppInitializer init, InitEvents event); + void onProgress(AppInitializer init, InitEvents event); - public void onFinish(AppInitializer init); + void onFinish(AppInitializer init); } @@ -167,10 +166,6 @@ public class AppInitializer implements IProgress { boolean showRecentChangesDialog = !firstTime && appVersionChanged; // showRecentChangesDialog = true; if (showRecentChangesDialog && !activityChangesShowed) { - final Intent helpIntent = new Intent(activity, HelpActivity.class); - helpIntent.putExtra(HelpActivity.TITLE, Version.getAppVersion(app)); - helpIntent.putExtra(HelpActivity.URL, LATEST_CHANGES_URL); - activity.startActivity(helpIntent); activityChangesShowed = true; return true; } @@ -369,9 +364,7 @@ public class AppInitializer implements IProgress { if (routingXml.exists() && routingXml.canRead()) { try { return RoutingConfiguration.parseFromInputStream(new FileInputStream(routingXml)); - } catch (XmlPullParserException e) { - throw new IllegalStateException(e); - } catch (IOException e) { + } catch (XmlPullParserException | IOException e) { throw new IllegalStateException(e); } } else { @@ -662,8 +655,6 @@ public class AppInitializer implements IProgress { } } }, "Initializing app").start(); - ; - } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index d850db1d14..13ba9a3972 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -17,7 +17,6 @@ import android.os.Message; import android.support.v4.app.NotificationCompat.Builder; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.NotificationCompat; -import android.util.Log; import android.view.Gravity; import android.view.KeyEvent; import android.view.MotionEvent; @@ -25,20 +24,18 @@ import android.view.View; import android.view.ViewStub; import android.view.Window; import android.view.WindowManager; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.ListView; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; + import net.osmand.Location; +import net.osmand.PlatformUtil; import net.osmand.StateChangedListener; import net.osmand.access.AccessibilityPlugin; import net.osmand.access.AccessibleActivity; import net.osmand.access.AccessibleToast; import net.osmand.access.MapAccessibilityActions; import net.osmand.core.android.AtlasMapRendererView; -import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.QuadPoint; @@ -50,7 +47,6 @@ import net.osmand.plus.AppInitializer.AppInitializeListener; import net.osmand.plus.AppInitializer.InitEvents; import net.osmand.plus.ApplicationMode; import net.osmand.plus.BusyIndicator; -import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.FirstUsageFragment; import net.osmand.plus.OsmAndConstants; import net.osmand.plus.OsmandApplication; @@ -64,6 +60,7 @@ import net.osmand.plus.activities.search.SearchActivity; import net.osmand.plus.base.FailSafeFuntions; import net.osmand.plus.base.MapViewTrackingUtilities; import net.osmand.plus.dashboard.DashboardOnMap; +import net.osmand.plus.dialogs.WhatsNewDialogFragment; import net.osmand.plus.helpers.GpxImportHelper; import net.osmand.plus.helpers.WakeLockHelper; import net.osmand.plus.mapcontextmenu.MapContextMenu; @@ -83,12 +80,13 @@ import net.osmand.plus.views.corenative.NativeCoreContext; import net.osmand.render.RenderingRulesStorage; import net.osmand.util.Algorithms; +import org.apache.commons.logging.Log; + import java.io.File; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.Random; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -97,6 +95,8 @@ public class MapActivity extends AccessibleActivity { private static final int LONG_KEYPRESS_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 2; private static final int LONG_KEYPRESS_DELAY = 500; + private static final Log LOG = PlatformUtil.getLog(MapActivity.class); + private static MapViewTrackingUtilities mapViewTrackingUtilities; /** @@ -122,7 +122,7 @@ public class MapActivity extends AccessibleActivity { private Dialog progressDlg = null; - private List dialogProviders = new ArrayList(2); + private List dialogProviders = new ArrayList<>(2); private StateChangedListener applicationModeListener; private GpxImportHelper gpxImportHelper; private WakeLockHelper wakeLockHelper; @@ -170,7 +170,9 @@ public class MapActivity extends AccessibleActivity { mapView = new OsmandMapTileView(this, getWindow().getDecorView().getWidth(), getWindow().getDecorView().getHeight()); - app.getAppInitializer().checkAppVersionChanged(this); + if(app.getAppInitializer().checkAppVersionChanged(this)) { + new WhatsNewDialogFragment().show(getSupportFragmentManager(), null); + } mapActions = new MapActivityActions(this); mapLayers = new MapActivityLayers(this); if (mapViewTrackingUtilities == null) { @@ -350,7 +352,7 @@ public class MapActivity extends AccessibleActivity { @Override public Object onRetainCustomNonConfigurationInstance() { - LinkedHashMap l = new LinkedHashMap(); + LinkedHashMap l = new LinkedHashMap<>(); for (OsmandMapLayer ml : mapView.getLayers()) { ml.onRetainNonConfigurationInstance(l); } @@ -769,8 +771,6 @@ public class MapActivity extends AccessibleActivity { protected void onPostExecute(Void result) { } - - ; }.execute((Void) null); } @@ -916,6 +916,7 @@ public class MapActivity extends AccessibleActivity { settings.setMapLocationToShow(lt, ln, z, new PointDescription( PointDescription.POINT_TYPE_MARKER, getString(R.string.shared_location))); } catch (NumberFormatException e) { + LOG.error("error", e); } } } diff --git a/OsmAnd/src/net/osmand/plus/dialogs/WhatsNewDialogFragment.java b/OsmAnd/src/net/osmand/plus/dialogs/WhatsNewDialogFragment.java new file mode 100644 index 0000000000..5430907167 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/dialogs/WhatsNewDialogFragment.java @@ -0,0 +1,33 @@ +package net.osmand.plus.dialogs; + +import android.app.Dialog; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v4.app.DialogFragment; +import android.support.v7.app.AlertDialog; + +import net.osmand.PlatformUtil; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.Version; + +import org.apache.commons.logging.Log; + +public class WhatsNewDialogFragment extends DialogFragment { + private static final Log LOG = PlatformUtil.getLog(WhatsNewDialogFragment.class); + private static final String FILE_ANDROID_ASSET_HELP = "file:///android_asset/help/"; + + @NonNull + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + final OsmandApplication osmandApplication = (OsmandApplication) getActivity().getApplication(); + final String appVersion = Version.getAppVersion(osmandApplication); + builder.setTitle("What's new in " + appVersion) + .setMessage(getString(R.string.last_release)) + .setNegativeButton(R.string.shared_string_close, null); + // TODO: 10/28/15 Implement + builder.setPositiveButton("Read more", null); + return builder.create(); + } +}