Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2014-08-13 02:13:35 +02:00
commit 040be2d2df
10 changed files with 49 additions and 19 deletions

View file

@ -26,6 +26,7 @@
<ImageButton android:id="@+id/all_points"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/more"
android:layout_gravity="center_vertical"
android:visibility="gone"
style="@style/Widget.Sherlock.ActionButton"
@ -34,6 +35,7 @@
<ImageButton android:id="@+id/info_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/close"
android:layout_gravity="center_vertical"
android:layout_marginRight="4dp"
style="@style/Widget.Sherlock.ActionButton"

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<resources>
<string name="sherpafy_public_access">Public access</string>
<string name="start_new_stage">Do you want to interrupt current stage and start new ?</string>
<string name="enter_access_code">Enter access code to see if you are entitled for a specific tour (optional)</string>
<string name="sherpafy_stage_tab_fav">Fav</string>

View file

@ -9,6 +9,7 @@
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
-->
<string name="more">More...</string>
<string name="rendering_value_browse_map_name">Browse map</string>
<string name="rendering_value_car_name">Car</string>
<string name="rendering_value_bicycle_name">Bicycle</string>

View file

@ -5,6 +5,7 @@ import java.util.List;
import java.util.Map;
import net.osmand.IProgress;
import net.osmand.IndexConstants;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LocationPoint;
import net.osmand.plus.activities.DownloadIndexActivity;
@ -18,7 +19,6 @@ import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.api.SettingsAPI;
import net.osmand.plus.api.SettingsAPIImpl;
import net.osmand.plus.download.DownloadActivityType;
import net.osmand.plus.views.OsmandMapTileView;
import android.app.Activity;
import android.view.Window;
@ -107,4 +107,8 @@ public class OsmAndAppCustomization {
public List<FavouritePoint> getFavorites() {
return null;
}
public String getIndexesUrl() {
return "http://"+IndexConstants.INDEX_DOWNLOAD_DOMAIN+"/get_indexes?gzip&" + Version.getVersionAsURLParam(app); //$NON-NLS-1$;
}
}

View file

@ -4,8 +4,6 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -16,8 +14,6 @@ import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.Version;
import net.osmand.plus.sherpafy.TourDownloadType;
import org.apache.commons.logging.Log;
import org.xmlpull.v1.XmlPullParser;
@ -29,7 +25,6 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.AssetManager;
import android.text.format.DateFormat;
public class DownloadOsmandIndexesHelper {
private final static Log log = PlatformUtil.getLog(DownloadOsmandIndexesHelper.class);
@ -38,8 +33,7 @@ public class DownloadOsmandIndexesHelper {
public static IndexFileList getIndexesList(Context ctx) {
PackageManager pm =ctx.getPackageManager();
AssetManager amanager = ctx.getAssets();
String versionUrlParam = Version.getVersionAsURLParam(((OsmandApplication) ctx.getApplicationContext()));
IndexFileList result = downloadIndexesListFromInternet(ctx, versionUrlParam);
IndexFileList result = downloadIndexesListFromInternet((OsmandApplication) ctx.getApplicationContext());
if (result == null) {
result = new IndexFileList();
} else {
@ -115,12 +109,13 @@ public class DownloadOsmandIndexesHelper {
}
private static IndexFileList downloadIndexesListFromInternet(Context ctx, String versionAsUrl){
private static IndexFileList downloadIndexesListFromInternet(OsmandApplication ctx){
try {
IndexFileList result = new IndexFileList();
log.debug("Start loading list of index files"); //$NON-NLS-1$
try {
String strUrl = "http://"+IndexConstants.INDEX_DOWNLOAD_DOMAIN+"/get_indexes?gzip&" + versionAsUrl; //$NON-NLS-1$
String strUrl = ctx.getAppCustomization().getIndexesUrl();
log.info(strUrl);
URL url = new URL(strUrl );
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();

View file

@ -64,7 +64,7 @@ public class WaypointDialogHelper {
updatePointInfoView(closePointDialog, point);
closePointDialog.setBackgroundColor(mapActivity.getResources().getColor(R.color.color_black));
((TextView)closePointDialog.findViewById(R.id.waypoint_text)).setTextColor(Color.WHITE);
((TextView) closePointDialog.findViewById(R.id.waypoint_text)).setTextColor(Color.WHITE);
View all = closePointDialog.findViewById(R.id.all_points);
all.setVisibility(vlp.size() <= 1 ? View.GONE : View.VISIBLE);
all.setOnClickListener(new View.OnClickListener() {

View file

@ -10,6 +10,7 @@ import java.util.Map;
import java.util.TreeSet;
import net.osmand.IProgress;
import net.osmand.IndexConstants;
import net.osmand.data.FavouritePoint;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.GPXUtilities;
@ -17,6 +18,7 @@ import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.activities.DownloadIndexActivity;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivityLayers;
@ -25,6 +27,7 @@ import net.osmand.plus.api.SettingsAPI;
import net.osmand.plus.download.DownloadActivityType;
import net.osmand.plus.sherpafy.TourInformation.StageFavorite;
import net.osmand.plus.sherpafy.TourInformation.StageInformation;
import net.osmand.util.Algorithms;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
@ -37,9 +40,10 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
private static final String SELECTED_TOUR = "selected_tour";
private static final String ACCESS_CODE = "access_code";
private static final String SELECTED_STAGE = "selected_stage";
private static final String VISITED_STAGES = "visited_stages";
private CommonPreference<String> selectedTourPref;
private CommonPreference<String> selectedStagePref;
private CommonPreference<String> visitedStagesPref;
private List<TourInformation> tourPresent = new ArrayList<TourInformation>();
private StageInformation selectedStage = null;
private TourInformation selectedTour = null;
@ -59,7 +63,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
public boolean setAccessCode(String acCode) {
acCode = acCode.toUpperCase();
if(validate(acCode)) {
if(validate(acCode) || Algorithms.isEmpty(acCode)) {
accessCodePref.set(acCode);
return true;
}
@ -194,6 +198,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
app.showToastMessage(R.string.settings_file_create_error);
}
selectedStagePref = app.getSettings().registerStringPreference(SELECTED_STAGE, null).makeGlobal();
visitedStagesPref = app.getSettings().registerStringPreference(VISITED_STAGES, null).makeGlobal();
selectedTour = tourInformation;
}
@ -310,4 +315,13 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
public List<FavouritePoint> getFavorites() {
return cachedFavorites;
}
@Override
public String getIndexesUrl() {
String s = "http://"+IndexConstants.INDEX_DOWNLOAD_DOMAIN+"/tours.php?gzip&" + Version.getVersionAsURLParam(app);
if(!Algorithms.isEmpty(accessCodePref.get())) {
s += "&code="+accessCodePref.get();
}
return s;
}
}

View file

@ -96,7 +96,13 @@ public class SherpafySelectToursFragment extends SherlockListFragment {
ll.setPadding(5, 3, 5, 0);
ll.addView(editText, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
builder.setView(ll);
builder.setNegativeButton(R.string.default_buttons_cancel, null);
builder.setNegativeButton(R.string.sherpafy_public_access, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
custom.setAccessCode("");
((TourViewActivity) getActivity()).startDownloadActivity();
}
});
builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {

View file

@ -8,6 +8,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.download.DownloadActivityType;
import net.osmand.plus.download.IndexItem;
import net.osmand.util.Algorithms;
import android.content.Context;
public class TourDownloadType extends DownloadActivityType {
@ -43,7 +44,11 @@ public class TourDownloadType extends DownloadActivityType {
}
public String getUrlSuffix(OsmandApplication ctx) {
return "&tour=yes";
String accessCode = "";
if (ctx.getAppCustomization() instanceof SherpafyCustomization) {
accessCode = ((SherpafyCustomization) ctx.getAppCustomization()).getAccessCode();
}
return "&tour=yes" + (Algorithms.isEmpty(accessCode) ? "" : "&code=" + accessCode);
}
public String getVisibleDescription(IndexItem indexItem, Context ctx) {

View file

@ -3,8 +3,6 @@ package net.osmand.plus.sherpafy;
import java.util.List;
import java.util.WeakHashMap;
import android.view.KeyEvent;
import android.widget.*;
import net.osmand.IProgress;
import net.osmand.data.LatLon;
import net.osmand.plus.GPXUtilities.GPXFile;
@ -32,7 +30,12 @@ import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
@ -57,7 +60,6 @@ public class TourViewActivity extends SherlockFragmentActivity {
private SherpafyCustomization customization;
private Point displaySize;
private ActionBarDrawerToggle mDrawerToggle;
private DrawerLayout mDrawerLayout;
private ListView mDrawerList;
@ -108,7 +110,6 @@ public class TourViewActivity extends SherlockFragmentActivity {
}
});
displaySize = new Point(getWindowManager().getDefaultDisplay().getWidth(), getWindowManager().getDefaultDisplay().getHeight());
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_navigation_drawer_light,
R.string.default_buttons_other_actions, R.string.close);
if (getMyApplication().isApplicationInitializing()) {
@ -435,6 +436,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
WptPt point = null;
GPXFile gpx = null;
customization.selectTour(tour, IProgress.EMPTY_PROGRESS);
customization.selectStage(stage, IProgress.EMPTY_PROGRESS);
if (customization.getSelectedStage() != null) {
gpx = customization.getSelectedStage().getGpx();