diff --git a/OsmAnd/res/layout/dash_first_time.xml b/OsmAnd/res/layout/dash_first_time.xml
new file mode 100644
index 0000000000..601d9986a1
--- /dev/null
+++ b/OsmAnd/res/layout/dash_first_time.xml
@@ -0,0 +1,110 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml
index 84905aff11..5c9a9f1cbc 100644
--- a/OsmAnd/res/values/sizes.xml
+++ b/OsmAnd/res/values/sizes.xml
@@ -97,4 +97,5 @@
24sp
18sp
14sp
+ 22sp
\ No newline at end of file
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 764961df4a..18b3bf5a4d 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,6 +9,10 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
+ Download maps
+ Select your region
+ OsmAnd allows you to use maps and offline navigation!
+ Welcome
Current route
OSM changes added to local changes
Mark to delete
diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java
index 12d2ff4107..35ad45776e 100644
--- a/OsmAnd/src/net/osmand/plus/AppInitializer.java
+++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java
@@ -1,14 +1,14 @@
package net.osmand.plus;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Random;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.ProgressDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
import net.osmand.IProgress;
import net.osmand.IndexConstants;
@@ -39,15 +39,16 @@ import net.osmand.util.Algorithms;
import org.xmlpull.v1.XmlPullParserException;
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.ProgressDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Random;
+
import btools.routingapp.BRouterServiceConnection;
/**
@@ -123,9 +124,9 @@ public class AppInitializer implements IProgress {
initSettings = true;
}
- public boolean isFirstTime(Activity a) {
- initUiVars(a);
- return firstTime;
+ public boolean isFirstTime(Activity activity) {
+ SharedPreferences pref = activity.getPreferences(Context.MODE_WORLD_WRITEABLE);
+ return !pref.contains(FIRST_TIME_APP_RUN);
}
public boolean checkAppVersionChanged(Activity activity) {
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
index 67a2b7616a..f9a697686e 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
@@ -101,6 +101,8 @@ public class MapActivity extends AccessibleActivity {
private OsmandApplication app;
private OsmandSettings settings;
+ boolean firstTime;
+
private Dialog progressDlg = null;
private List dialogProviders = new ArrayList(2);
@@ -123,6 +125,16 @@ public class MapActivity extends AccessibleActivity {
return notification;
}
+ public boolean isFirstTime(){
+ return firstTime;
+ }
+
+ public void userClosedWelcomeCard(){
+ firstTime = false;
+ dashboardOnMap.refreshDashboardFragments();
+
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
long tm = System.currentTimeMillis();
@@ -141,6 +153,7 @@ public class MapActivity extends AccessibleActivity {
if (mapViewTrackingUtilities == null) {
mapViewTrackingUtilities = new MapViewTrackingUtilities(app);
}
+ firstTime = app.getAppInitializer().isFirstTime(this);
dashboardOnMap.createDashboardView();
checkAppInitialization();
parseLaunchIntentLocation();
@@ -191,6 +204,7 @@ public class MapActivity extends AccessibleActivity {
System.err.println("OnCreate for MapActivity took " + (System.currentTimeMillis() - tm) + " ms");
}
mapView.refreshMap(true);
+
}
private void checkAppInitialization() {
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashErrorFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashErrorFragment.java
index d429985dea..16cea2f34b 100644
--- a/OsmAnd/src/net/osmand/plus/dashboard/DashErrorFragment.java
+++ b/OsmAnd/src/net/osmand/plus/dashboard/DashErrorFragment.java
@@ -22,7 +22,8 @@ import android.widget.Button;
import android.widget.TextView;
/**
- * Created by Denis on 02.12.14.
+ * Created by Denis
+ * on 02.12.14.
*/
public class DashErrorFragment extends DashBaseFragment {
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashFirstTimeFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashFirstTimeFragment.java
new file mode 100644
index 0000000000..2aaab5660b
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/dashboard/DashFirstTimeFragment.java
@@ -0,0 +1,91 @@
+package net.osmand.plus.dashboard;
+
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import net.osmand.plus.OsmandSettings;
+import net.osmand.plus.R;
+import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.download.DownloadActivity;
+
+/**
+ * Created by Denis on
+ * 26.03.2015.
+ */
+public class DashFirstTimeFragment extends DashBaseFragment {
+
+ public static final String TAG = "DASH_FIRST_TIME_FRAGMENT";
+
+
+ @Override
+ public void onOpenDash() {
+
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ View view = getActivity().getLayoutInflater().inflate(R.layout.dash_first_time, container, false);
+
+ view.findViewById(R.id.select_region).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+ final OsmandSettings.DrivingRegion[] drs = OsmandSettings.DrivingRegion.values();
+
+ final OsmandSettings.DrivingRegion currentRegion = getMyApplication().getSettings().DRIVING_REGION.get();
+
+ String[] entries = new String[drs.length];
+ int currentIndex = 0;
+ for (int i = 0; i < entries.length; i++) {
+ if (currentRegion.equals(drs[i])){
+ currentIndex = i;
+ }
+ entries[i] = getString(drs[i].name); // + " (" + drs[i].defMetrics.toHumanString(this) +")" ;
+ }
+ builder.setSingleChoiceItems(entries, currentIndex, null);
+ builder.setNegativeButton(R.string.shared_string_cancel, null);
+ builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ int selectedPosition = ((AlertDialog)dialog).getListView().getCheckedItemPosition();
+ getMyApplication().getSettings().DRIVING_REGION.set(drs[selectedPosition]);
+ updateCurrentRegion(getView());
+ }
+ });
+ builder.show();
+ }
+ });
+
+ view.findViewById(R.id.hide).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ ((MapActivity)getActivity()).userClosedWelcomeCard();
+ }
+ });
+
+ view.findViewById(R.id.download_map).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(getActivity(), DownloadActivity.class);
+ intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB);
+ getActivity().startActivity(intent);
+ }
+ });
+
+ updateCurrentRegion(view);
+ ((ImageView)view.findViewById(R.id.car_icon)).setImageDrawable(getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_car_dark));
+ return view;
+ }
+
+ private void updateCurrentRegion(View view) {
+ ((TextView) view.findViewById(R.id.region)).setText(getMyApplication().getSettings().DRIVING_REGION.get().name);
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
index 57b3d8ab95..b2cff112a2 100644
--- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
+++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
@@ -1,41 +1,9 @@
package net.osmand.plus.dashboard;
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import net.osmand.data.LatLon;
-import net.osmand.plus.ContextMenuAdapter;
-import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
-import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
-import net.osmand.plus.IconsCache;
-import net.osmand.plus.OsmandApplication;
-import net.osmand.plus.OsmandPlugin;
-import net.osmand.plus.R;
-import net.osmand.plus.activities.IntermediatePointsDialog;
-import net.osmand.plus.activities.MapActivity;
-import net.osmand.plus.audionotes.DashAudioVideoNotesFragment;
-import net.osmand.plus.development.DashSimulateFragment;
-import net.osmand.plus.development.OsmandDevelopmentPlugin;
-import net.osmand.plus.dialogs.ConfigureMapMenu;
-import net.osmand.plus.download.DownloadActivity;
-import net.osmand.plus.helpers.ScreenOrientationHelper;
-import net.osmand.plus.helpers.WaypointDialogHelper;
-import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
-import net.osmand.plus.monitoring.DashTrackFragment;
-import net.osmand.plus.osmedit.DashOsmEditsFragment;
-import net.osmand.plus.osmo.DashOsMoFragment;
-import net.osmand.plus.parkingpoint.DashParkingFragment;
-import net.osmand.plus.routing.RoutingHelper;
-import net.osmand.plus.views.DownloadedRegionsLayer;
-import net.osmand.plus.views.OsmandMapTileView;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
-import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.v4.app.Fragment;
@@ -67,6 +35,38 @@ import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCal
import com.github.ksoichiro.android.observablescrollview.ScrollState;
import com.software.shell.fab.ActionButton;
+import net.osmand.data.LatLon;
+import net.osmand.plus.ContextMenuAdapter;
+import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
+import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
+import net.osmand.plus.IconsCache;
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.OsmandPlugin;
+import net.osmand.plus.R;
+import net.osmand.plus.activities.IntermediatePointsDialog;
+import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.audionotes.DashAudioVideoNotesFragment;
+import net.osmand.plus.development.DashSimulateFragment;
+import net.osmand.plus.development.OsmandDevelopmentPlugin;
+import net.osmand.plus.dialogs.ConfigureMapMenu;
+import net.osmand.plus.download.DownloadActivity;
+import net.osmand.plus.helpers.ScreenOrientationHelper;
+import net.osmand.plus.helpers.WaypointDialogHelper;
+import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
+import net.osmand.plus.monitoring.DashTrackFragment;
+import net.osmand.plus.osmedit.DashOsmEditsFragment;
+import net.osmand.plus.osmo.DashOsMoFragment;
+import net.osmand.plus.parkingpoint.DashParkingFragment;
+import net.osmand.plus.routing.RoutingHelper;
+import net.osmand.plus.views.DownloadedRegionsLayer;
+import net.osmand.plus.views.OsmandMapTileView;
+
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
/**
*/
public class DashboardOnMap implements ObservableScrollViewCallbacks {
@@ -373,6 +373,11 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
public void setDashboardVisibility(boolean visible, DashboardType type, boolean animation) {
setDashboardVisibility(visible, type, this.visible ? visibleType : null, animation);
}
+
+ public void refreshDashboardFragments(){
+ addOrUpdateDashboardFragments(mapActivity.isFirstTime());
+ }
+
public void setDashboardVisibility(boolean visible, DashboardType type, DashboardType prevItem, boolean animation) {
if(visible == this.visible && type == visibleType) {
return;
@@ -395,7 +400,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
View listViewLayout = dashboardView.findViewById(R.id.dash_list_view_layout);
ScrollView scrollView = (ScrollView) dashboardView.findViewById(R.id.main_scroll);
if(visibleType == DashboardType.DASHBOARD) {
- addOrUpdateDashboardFragments();
+ addOrUpdateDashboardFragments(mapActivity.isFirstTime());
scrollView.setVisibility(View.VISIBLE);
listViewLayout.setVisibility(View.GONE);
updateTopButton(scrollView.getScrollY());
@@ -431,7 +436,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
}
}
-
+
private void updateListAdapter() {
ContextMenuAdapter cm = null;
if (DashboardType.WAYPOINTS == visibleType || DashboardType.WAYPOINTS_FLAT == visibleType) {
@@ -614,16 +619,16 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
}
- private void addOrUpdateDashboardFragments() {
+ private void addOrUpdateDashboardFragments(boolean firstTime) {
// boolean showCards = mapActivity.getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.get();
- boolean showCards = true;
+ boolean showCards = !firstTime;
FragmentManager manager = mapActivity.getSupportFragmentManager();
FragmentTransaction fragmentTransaction = manager.beginTransaction();
-
-
+ showFragment(manager, fragmentTransaction, DashFirstTimeFragment.TAG, DashFirstTimeFragment.class, firstTime);
+
showFragment(manager, fragmentTransaction, DashErrorFragment.TAG, DashErrorFragment.class,
mapActivity.getMyApplication().getAppInitializer().checkPreviousRunsForExceptions(mapActivity) && showCards);
showFragment(manager, fragmentTransaction, DashNavigationFragment.TAG, DashNavigationFragment.class, showCards);