summaryrefslogtreecommitdiff
path: root/altoslib
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-04-26 21:01:44 -0400
committerKeith Packard <keithp@keithp.com>2016-04-26 21:02:40 -0400
commitd81f94fd5339d513de9bde5a2e19f8eca526344f (patch)
tree25d8261d6ddb6b8217b4e92690997d59a0a06285 /altoslib
parent204ae5142702044eb8ad2697a55028e904067958 (diff)
altosdroid: Split setup functions to separate dialog
Remove them from the options menu, handle all preferences through listeners. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib')
-rw-r--r--altoslib/AltosMapTypeListener.java22
-rw-r--r--altoslib/AltosPreferences.java39
-rw-r--r--altoslib/Makefile.am1
3 files changed, 62 insertions, 0 deletions
diff --git a/altoslib/AltosMapTypeListener.java b/altoslib/AltosMapTypeListener.java
new file mode 100644
index 00000000..b82bda3f
--- /dev/null
+++ b/altoslib/AltosMapTypeListener.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright © 2012 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.altoslib_10;
+
+public interface AltosMapTypeListener {
+ public void map_type_changed(int map_type);
+}
diff --git a/altoslib/AltosPreferences.java b/altoslib/AltosPreferences.java
index 43fc9f22..4bf48f6d 100644
--- a/altoslib/AltosPreferences.java
+++ b/altoslib/AltosPreferences.java
@@ -128,6 +128,9 @@ public class AltosPreferences {
public static int map_cache = 9;
+ final static String mapTypePreference = "MAP-TYPE";
+ static int map_type;
+
public static AltosFrequency[] load_common_frequencies() {
AltosFrequency[] frequencies = null;
boolean existing = false;
@@ -221,6 +224,7 @@ public class AltosPreferences {
map_cache = backend.getInt(mapCachePreference, 9);
map_cache_listeners = new LinkedList<AltosMapCacheListener>();
+ map_type = backend.getInt(mapTypePreference, AltosMap.maptype_hybrid);
}
public static void flush_preferences() {
@@ -638,4 +642,39 @@ public class AltosPreferences {
return map_cache;
}
}
+
+ static LinkedList<AltosMapTypeListener> map_type_listeners;
+
+ public static void set_map_type(int map_type) {
+ synchronized(backend) {
+ AltosPreferences.map_type = map_type;
+ backend.putInt(mapTypePreference, map_type);
+ flush_preferences();
+ }
+ if (map_type_listeners != null) {
+ for (AltosMapTypeListener l : map_type_listeners) {
+ l.map_type_changed(map_type);
+ }
+ }
+ }
+
+ public static int map_type() {
+ synchronized(backend) {
+ return map_type;
+ }
+ }
+
+ public static void register_map_type_listener(AltosMapTypeListener l) {
+ synchronized(backend) {
+ if (map_type_listeners == null)
+ map_type_listeners = new LinkedList<AltosMapTypeListener>();
+ map_type_listeners.add(l);
+ }
+ }
+
+ public static void unregister_map_type_listener(AltosMapTypeListener l) {
+ synchronized(backend) {
+ map_type_listeners.remove(l);
+ }
+ }
}
diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am
index e5d8c964..73638782 100644
--- a/altoslib/Makefile.am
+++ b/altoslib/Makefile.am
@@ -157,6 +157,7 @@ altoslib_JAVA = \
AltosLaunchSites.java \
AltosMapLoaderListener.java \
AltosMapLoader.java \
+ AltosMapTypeListener.java \
AltosVersion.java
JAR=altoslib_$(ALTOSLIB_VERSION).jar