*/
package org.altusmetrum.AltosDroid;
+import java.io.*;
+import java.util.*;
+import java.text.*;
+
import android.content.Context;
-import org.altusmetrum.altoslib_7.*;
+import org.altusmetrum.altoslib_10.*;
public class AltosDroidPreferences extends AltosPreferences {
static DeviceAddress active_device_address;
+ /* Map source preference name */
+ final static String mapSourcePreference = "MAP-SOURCE";
+
+ static final int MAP_SOURCE_OFFLINE = 0;
+ static final int MAP_SOURCE_ONLINE = 1;
+
+ static int map_source;
+
public static void init(Context context) {
if (backend != null)
return;
if (address != null && name != null)
active_device_address = new DeviceAddress (address, name);
+
+ map_source = backend.getInt(mapSourcePreference, MAP_SOURCE_ONLINE);
}
public static void set_active_device(DeviceAddress address) {
return active_device_address;
}
}
+
+ static LinkedList<AltosDroidMapSourceListener> map_source_listeners;
+
+ public static void set_map_source(int map_source) {
+ synchronized(backend) {
+ AltosDroidPreferences.map_source = map_source;
+ backend.putInt(mapSourcePreference, map_source);
+ flush_preferences();
+ }
+ if (map_source_listeners != null) {
+ for (AltosDroidMapSourceListener l : map_source_listeners) {
+ l.map_source_changed(map_source);
+ }
+ }
+ }
+
+ public static int map_source() {
+ synchronized(backend) {
+ return map_source;
+ }
+ }
+
+ public static void register_map_source_listener(AltosDroidMapSourceListener l) {
+ synchronized(backend) {
+ if (map_source_listeners == null)
+ map_source_listeners = new LinkedList<AltosDroidMapSourceListener>();
+ map_source_listeners.add(l);
+ }
+ }
+
+ public static void unregister_map_source_listener(AltosDroidMapSourceListener l) {
+ synchronized(backend) {
+ map_source_listeners.remove(l);
+ }
+ }
}