X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=ao-tools%2Faltosui%2FAltosPreferences.java;h=526275635ff07b90960aa3bd74aeaa8e402a5f13;hp=0296d9355db7a2086ade1aa97ce737c028ed58d2;hb=61590b8729831cb138b2ba6b88802c208d114753;hpb=563a9dcdfef42718370c49f16cc2271642b3e055 diff --git a/ao-tools/altosui/AltosPreferences.java b/ao-tools/altosui/AltosPreferences.java index 0296d935..52627563 100644 --- a/ao-tools/altosui/AltosPreferences.java +++ b/ao-tools/altosui/AltosPreferences.java @@ -31,6 +31,18 @@ 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"; + + /* callsign preference name */ + final static String callsignPreference = "CALLSIGN"; + + /* firmware directory preference name */ + final static String firmwaredirPreference = "FIRMWARE"; + /* Default logdir is ~/TeleMetrum */ final static String logdirName = "TeleMetrum"; @@ -40,6 +52,18 @@ class AltosPreferences { /* Log directory */ static File logdir; + /* Telemetry channel */ + static int channel; + + /* Voice preference */ + static boolean voice; + + /* Callsign preference */ + static String callsign; + + /* Firmware directory */ + static File firmwaredir; + public static void init(Component ui) { preferences = Preferences.userRoot().node("/org/altusmetrum/altosui"); @@ -55,6 +79,18 @@ class AltosPreferences { if (!logdir.exists()) logdir.mkdirs(); } + + channel = preferences.getInt(channelPreference, 0); + + voice = preferences.getBoolean(voicePreference, true); + + callsign = preferences.get(callsignPreference,"N0CALL"); + + String firmwaredir_string = preferences.get(firmwaredirPreference, null); + if (firmwaredir_string != null) + firmwaredir = new File(firmwaredir_string); + else + firmwaredir = null; } static void flush_preferences() { @@ -114,4 +150,52 @@ 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; + } + + public static void set_callsign(String new_callsign) { + callsign = new_callsign; + synchronized(preferences) { + preferences.put(callsignPreference, callsign); + flush_preferences(); + } + } + + public static String callsign() { + return callsign; + } + + public static void set_firmwaredir(File new_firmwaredir) { + firmwaredir = new_firmwaredir; + synchronized (preferences) { + preferences.put(firmwaredirPreference, firmwaredir.getPath()); + flush_preferences(); + } + } + + public static File firmwaredir() { + return firmwaredir; + } }