Make voice and channel menus work.
[fw/altos] / ao-tools / altosui / AltosPreferences.java
index 0296d9355db7a2086ade1aa97ce737c028ed58d2..297e1aae77ba0819a71af5ef53718a648cf2f727 100644 (file)
@@ -31,6 +31,12 @@ class AltosPreferences {
        /* logdir preference name */
        final static String logdirPreference = "LOGDIR";
 
+       /* channel preference name */
+       final static String channelPreference = "CHANNEL";
+
+       /* voice preference name */
+       final static String voicePreference = "VOICE";
+
        /* Default logdir is ~/TeleMetrum */
        final static String logdirName = "TeleMetrum";
 
@@ -40,6 +46,12 @@ class AltosPreferences {
        /* Log directory */
        static File logdir;
 
+       /* Telemetry channel */
+       static int channel;
+
+       /* Voice preference */
+       static boolean voice;
+
        public static void init(Component ui) {
                preferences = Preferences.userRoot().node("/org/altusmetrum/altosui");
 
@@ -55,6 +67,10 @@ class AltosPreferences {
                        if (!logdir.exists())
                                logdir.mkdirs();
                }
+
+               channel = preferences.getInt(channelPreference, 0);
+
+               voice = preferences.getBoolean(voicePreference, true);
        }
 
        static void flush_preferences() {
@@ -114,4 +130,28 @@ class AltosPreferences {
        public static File logdir() {
                return logdir;
        }
+
+       public static void set_channel(int new_channel) {
+               channel = new_channel;
+               synchronized (preferences) {
+                       preferences.putInt(channelPreference, channel);
+                       flush_preferences();
+               }
+       }
+
+       public static int channel() {
+               return channel;
+       }
+
+       public static void set_voice(boolean new_voice) {
+               voice = new_voice;
+               synchronized (preferences) {
+                       preferences.putBoolean(voicePreference, voice);
+                       flush_preferences();
+               }
+       }
+
+       public static boolean voice() {
+               return voice;
+       }
 }