swap names so v3.0 is the default TeleDongle version to turn on
[fw/altos] / altosdroid / src / org / altusmetrum / AltosDroid / AltosDroidPreferences.java
1 /*
2  * Copyright © 2014 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17 package org.altusmetrum.AltosDroid;
18
19 import android.content.Context;
20 import org.altusmetrum.altoslib_6.*;
21
22 public class AltosDroidPreferences extends AltosPreferences {
23
24         /* Active device preference name */
25         final static String activeDevicePreference = "ACTIVE-DEVICE";
26
27         static String active_device_address;
28
29         public static void init(Context context) {
30                 if (backend != null)
31                         return;
32
33                 AltosPreferences.init(new AltosDroidPreferencesBackend(context));
34
35                 active_device_address = backend.getString(activeDevicePreference, null);
36         }
37
38         public static void set_active_device(String address) {
39                 synchronized(backend) {
40                         active_device_address = address;
41                         backend.putString(activeDevicePreference, active_device_address);
42                         flush_preferences();
43                 }
44         }
45
46         public static String active_device() {
47                 synchronized(backend) {
48                         return active_device_address;
49                 }
50         }
51 }