Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2014-08-11 18:09:14 +02:00
commit 7b2590387c
5 changed files with 31 additions and 25 deletions

View file

@ -16,6 +16,7 @@ import net.osmand.plus.activities.PluginsActivity;
import net.osmand.plus.activities.SettingsActivity;
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;
@ -24,15 +25,14 @@ import android.view.Window;
public class OsmAndAppCustomization {
protected OsmandApplication app;
protected OsmandSettings osmandSettings;
public void setup(OsmandApplication app) {
this.app = app;
this.osmandSettings = new OsmandSettings(app, new net.osmand.plus.api.SettingsAPIImpl(app));
}
public OsmandSettings createSettings(SettingsAPI api) {
return new OsmandSettings(app, api);
}
public OsmandSettings getOsmandSettings(){ return osmandSettings;}
// Main menu
public boolean checkExceptionsOnStart() {
return true;

View file

@ -24,12 +24,14 @@ import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.api.SQLiteAPI;
import net.osmand.plus.api.SQLiteAPIImpl;
import net.osmand.plus.api.SettingsAPIImpl;
import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.monitoring.LiveMonitoringHelper;
import net.osmand.plus.render.NativeOsmandLibrary;
import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.resources.ResourceManager;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.sherpafy.SherpafyCustomization;
import net.osmand.plus.voice.CommandPlayer;
import net.osmand.plus.voice.CommandPlayerException;
import net.osmand.plus.voice.CommandPlayerFactory;
@ -126,9 +128,6 @@ public class OsmandApplication extends Application {
}
super.onCreate();
new Toast(this); // activate in UI thread to avoid further exceptions
appCustomization = new OsmAndAppCustomization();
appCustomization.setup(this);
sqliteAPI = new SQLiteAPIImpl(this);
try {
bRouterServiceConnection = BRouterServiceConnection.connect(this);
@ -136,13 +135,21 @@ public class OsmandApplication extends Application {
e.printStackTrace();
}
// settings used everywhere so they need to be created first
osmandSettings = appCustomization.createSettings(new net.osmand.plus.api.SettingsAPIImpl(this));
if(Version.isSherpafy(this)) {
appCustomization = new SherpafyCustomization();
} else {
appCustomization = new OsmAndAppCustomization();
}
appCustomization.setup(this);
osmandSettings = appCustomization.getOsmandSettings();
// always update application mode to default
if(!osmandSettings.FOLLOW_THE_ROUTE.get()){
osmandSettings.APPLICATION_MODE.set(osmandSettings.DEFAULT_APPLICATION_MODE.get());
}
applyTheme(this);
routingHelper = new RoutingHelper(this, player);

View file

@ -197,7 +197,6 @@ public class MainMenuActivity extends Activity {
super.onCreate(savedInstanceState);
if(Version.isSherpafy(getMyApplication())) {
final Intent mapIntent = new Intent(this, TourViewActivity.class);
getMyApplication().setAppCustomization(new SherpafyCustomization());
startActivity(mapIntent);
finish();
return;

View file

@ -11,18 +11,17 @@ import java.util.TreeSet;
import net.osmand.IProgress;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LocationPoint;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.R;
import net.osmand.plus.activities.DownloadIndexActivity;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivityLayers;
import net.osmand.plus.api.FileSettingsAPIImpl;
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;
@ -38,7 +37,7 @@ 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 OsmandSettings originalSettings;
private CommonPreference<String> selectedTourPref;
private CommonPreference<String> selectedStagePref;
private List<TourInformation> tourPresent = new ArrayList<TourInformation>();
@ -47,14 +46,15 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
private File toursFolder;
private CommonPreference<String> accessCodePref;
private List<FavouritePoint> cachedFavorites = new ArrayList<FavouritePoint>();
private SettingsAPI originalApi;
@Override
public void setup(OsmandApplication app) {
super.setup(app);
originalSettings = createSettings(app.getSettings().getSettingsAPI());
selectedTourPref = originalSettings.registerStringPreference(SELECTED_TOUR, null).makeGlobal();
accessCodePref = originalSettings.registerStringPreference(ACCESS_CODE, "").makeGlobal();
toursFolder = new File(originalSettings.getExternalStorageDirectory(), "osmand/tours");
originalApi = osmandSettings.getSettingsAPI();
selectedTourPref = osmandSettings.registerStringPreference(SELECTED_TOUR, null).makeGlobal();
accessCodePref = osmandSettings.registerStringPreference(ACCESS_CODE, "").makeGlobal();
toursFolder = new File(osmandSettings.getExternalStorageDirectory(), "osmand/tours");
}
public boolean setAccessCode(String acCode) {
@ -162,7 +162,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
}
}
if (selectedName == null) {
app.getSettings().setSettingsAPI(originalSettings.getSettingsAPI());
app.getSettings().setSettingsAPI(originalApi);
}
}
}

View file

@ -67,9 +67,9 @@ public class TourViewActivity extends SherlockFragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
if (!(getMyApplication().getAppCustomization() instanceof SherpafyCustomization)) {
getMyApplication().setAppCustomization(new SherpafyCustomization());
}
// if (!(getMyApplication().getAppCustomization() instanceof SherpafyCustomization)) {
// getMyApplication().setAppCustomization(new SherpafyCustomization());
// }
customization = (SherpafyCustomization) getMyApplication().getAppCustomization();
setTheme(R.style.OsmandLightTheme);
((OsmandApplication) getApplication()).setLanguage(this);