aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/Settings.java
blob: ee201e26d7451f2e17df48c4c98ec2ad7d103072 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
package cgeo.geocaching;

import cgeo.geocaching.apps.cache.navi.NavigationAppFactory.NavigationAppsEnum;
import cgeo.geocaching.connector.gc.GCConstants;
import cgeo.geocaching.connector.gc.Login;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LiveMapStrategy.Strategy;
import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.maps.MapProviderFactory;
import cgeo.geocaching.maps.interfaces.GeoPointImpl;
import cgeo.geocaching.maps.interfaces.MapProvider;
import cgeo.geocaching.maps.mapsforge.MapsforgeMapProvider;
import cgeo.geocaching.utils.CryptUtils;
import cgeo.geocaching.utils.Log;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.preference.PreferenceManager;

import java.util.Locale;

/**
 * General c:geo preferences/settings set by the user
 */
public final class Settings {

    private static final String KEY_TEMP_TOKEN_SECRET = "temp-token-secret";
    private static final String KEY_TEMP_TOKEN_PUBLIC = "temp-token-public";
    private static final String KEY_HELP_SHOWN = "helper";
    private static final String KEY_ANYLONGITUDE = "anylongitude";
    private static final String KEY_ANYLATITUDE = "anylatitude";
    private static final String KEY_PUBLICLOC = "publicloc";
    private static final String KEY_USE_OFFLINEMAPS = "offlinemaps";
    private static final String KEY_USE_OFFLINEWPMAPS = "offlinewpmaps";
    private static final String KEY_WEB_DEVICE_CODE = "webDeviceCode";
    private static final String KEY_WEBDEVICE_NAME = "webDeviceName";
    private static final String KEY_MAP_LIVE = "maplive";
    private static final String KEY_MAP_SOURCE = "mapsource";
    private static final String KEY_USE_TWITTER = "twitter";
    private static final String KEY_SHOW_ADDRESS = "showaddress";
    private static final String KEY_SHOW_CAPTCHA = "showcaptcha";
    private static final String KEY_MAP_TRAIL = "maptrail";
    private static final String KEY_LAST_MAP_ZOOM = "mapzoom";
    private static final String KEY_LAST_MAP_LAT = "maplat";
    private static final String KEY_LAST_MAP_LON = "maplon";
    private static final String KEY_LIVE_LIST = "livelist";
    private static final String KEY_METRIC_UNITS = "units";
    private static final String KEY_SKIN = "skin";
    private static final String KEY_LAST_USED_LIST = "lastlist";
    private static final String KEY_CACHE_TYPE = "cachetype";
    private static final String KEY_TWITTER_TOKEN_SECRET = "tokensecret";
    private static final String KEY_TWITTER_TOKEN_PUBLIC = "tokenpublic";
    private static final String KEY_VERSION = "version";
    private static final String KEY_LOAD_DESCRIPTION = "autoloaddesc";
    private static final String KEY_RATING_WANTED = "ratingwanted";
    private static final String KEY_ELEVATION_WANTED = "elevationwanted";
    private static final String KEY_FRIENDLOGS_WANTED = "friendlogswanted";
    private static final String KEY_USE_ENGLISH = "useenglish";
    private static final String KEY_USE_COMPASS = "usecompass";
    private static final String KEY_AUTO_VISIT_TRACKABLES = "trackautovisit";
    private static final String KEY_AUTO_INSERT_SIGNATURE = "sigautoinsert";
    private static final String KEY_ALTITUDE_CORRECTION = "altcorrection";
    private static final String KEY_USE_GOOGLE_NAVIGATION = "usegnav";
    private static final String KEY_STORE_LOG_IMAGES = "logimages";
    private static final String KEY_EXCLUDE_DISABLED = "excludedisabled";
    private static final String KEY_EXCLUDE_OWN = "excludemine";
    private static final String KEY_MAPFILE = "mfmapfile";
    private static final String KEY_SIGNATURE = "signature";
    private static final String KEY_GCVOTE_PASSWORD = "pass-vote";
    private static final String KEY_PASSWORD = "password";
    private static final String KEY_USERNAME = "username";
    private static final String KEY_MEMBER_STATUS = "memberstatus";
    private static final String KEY_COORD_INPUT_FORMAT = "coordinputformat";
    private static final String KEY_LOG_OFFLINE = "log_offline";
    private static final String KEY_LOAD_DIRECTION_IMG = "loaddirectionimg";
    private static final String KEY_GC_CUSTOM_DATE = "gccustomdate";
    private static final String KEY_SHOW_WAYPOINTS_THRESHOLD = "gcshowwaypointsthreshold";
    private static final String KEY_COOKIE_STORE = "cookiestore";
    private static final String KEY_OPEN_LAST_DETAILS_PAGE = "opendetailslastpage";
    private static final String KEY_LAST_DETAILS_PAGE = "lastdetailspage";
    private static final String KEY_DEFAULT_NAVIGATION_TOOL = "defaultNavigationTool";
    private static final String KEY_DEFAULT_NAVIGATION_TOOL_2 = "defaultNavigationTool2";
    private static final String KEY_LIVE_MAP_STRATEGY = "livemapstrategy";
    private static final String KEY_DEBUG = "debug";
    private static final String KEY_HIDE_LIVE_MAP_HINT = "hidelivemaphint";
    private static final String KEY_LIVE_MAP_HINT_SHOW_COUNT = "livemaphintshowcount";
    private static final String KEY_SETTINGS_VERSION = "settingsversion";
    private static final String KEY_DB_ON_SDCARD = "dbonsdcard";
    private static final String KEY_LAST_TRACKABLE_ACTION = "trackableaction";
    private static final String KEY_SHARE_AFTER_EXPORT = "shareafterexport";
    private static final String KEY_GPX_EXPORT_DIR = "gpxExportDir";

    private final static int unitsMetric = 1;

    // twitter api keys
    private final static String keyConsumerPublic = CryptUtils.rot13("ESnsCvAv3kEupF1GCR3jGj");
    private final static String keyConsumerSecret = CryptUtils.rot13("7vQWceACV9umEjJucmlpFe9FCMZSeqIqfkQ2BnhV9x");

    private interface PrefRunnable {
        void edit(final Editor edit);
    }

    public enum coordInputFormatEnum {
        Plain,
        Deg,
        Min,
        Sec;

        static coordInputFormatEnum fromInt(int id) {
            final coordInputFormatEnum[] values = coordInputFormatEnum.values();
            if (id < 0 || id >= values.length) {
                return Min;
            }
            return values[id];
        }
    }

    private static String username = null;
    private static String password = null;

    private static final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(cgeoapplication.getInstance().getBaseContext());
    static {
        migrateSettings();
        Log.setDebugUnsaved(sharedPrefs.getBoolean(KEY_DEBUG, false));
    }

    // maps
    private static MapProvider mapProvider = null;

    private Settings() {
        // this class is not to be instantiated;
    }

    private static void migrateSettings() {
        // migrate from non standard file location and integer based boolean types
        if (sharedPrefs.getInt(KEY_SETTINGS_VERSION, 0) < 1) {
            final String oldPreferencesName = "cgeo.pref";
            final SharedPreferences old = cgeoapplication.getInstance().getSharedPreferences(oldPreferencesName, Context.MODE_PRIVATE);
            final Editor e = sharedPrefs.edit();

            e.putString(KEY_TEMP_TOKEN_SECRET, old.getString(KEY_TEMP_TOKEN_SECRET, null));
            e.putString(KEY_TEMP_TOKEN_PUBLIC, old.getString(KEY_TEMP_TOKEN_PUBLIC, null));
            e.putBoolean(KEY_HELP_SHOWN, old.getInt(KEY_HELP_SHOWN, 0) != 0);
            e.putFloat(KEY_ANYLONGITUDE, old.getFloat(KEY_ANYLONGITUDE, 0));
            e.putFloat(KEY_ANYLATITUDE, old.getFloat(KEY_ANYLATITUDE, 0));
            e.putBoolean(KEY_PUBLICLOC, 0 != old.getInt(KEY_PUBLICLOC, 0));
            e.putBoolean(KEY_USE_OFFLINEMAPS, 0 != old.getInt(KEY_USE_OFFLINEMAPS, 1));
            e.putBoolean(KEY_USE_OFFLINEWPMAPS, 0 != old.getInt(KEY_USE_OFFLINEWPMAPS, 0));
            e.putString(KEY_WEB_DEVICE_CODE, old.getString(KEY_WEB_DEVICE_CODE, null));
            e.putString(KEY_WEBDEVICE_NAME, old.getString(KEY_WEBDEVICE_NAME, null));
            e.putBoolean(KEY_MAP_LIVE, old.getInt(KEY_MAP_LIVE, 1) != 0);
            e.putInt(KEY_MAP_SOURCE, old.getInt(KEY_MAP_SOURCE, 0));
            e.putBoolean(KEY_USE_TWITTER, 0 != old.getInt(KEY_USE_TWITTER, 0));
            e.putBoolean(KEY_SHOW_ADDRESS, 0 != old.getInt(KEY_SHOW_ADDRESS, 1));
            e.putBoolean(KEY_SHOW_CAPTCHA, old.getBoolean(KEY_SHOW_CAPTCHA, false));
            e.putBoolean(KEY_MAP_TRAIL, old.getInt(KEY_MAP_TRAIL, 1) != 0);
            e.putInt(KEY_LAST_MAP_ZOOM, old.getInt(KEY_LAST_MAP_ZOOM, 14));
            e.putBoolean(KEY_LIVE_LIST, 0 != old.getInt(KEY_LIVE_LIST, 1));
            e.putBoolean(KEY_METRIC_UNITS, old.getInt(KEY_METRIC_UNITS, unitsMetric) == unitsMetric);
            e.putBoolean(KEY_SKIN, old.getInt(KEY_SKIN, 0) != 0);
            e.putInt(KEY_LAST_USED_LIST, old.getInt(KEY_LAST_USED_LIST, StoredList.STANDARD_LIST_ID));
            e.putString(KEY_CACHE_TYPE, old.getString(KEY_CACHE_TYPE, CacheType.ALL.id));
            e.putString(KEY_TWITTER_TOKEN_SECRET, old.getString(KEY_TWITTER_TOKEN_SECRET, null));
            e.putString(KEY_TWITTER_TOKEN_PUBLIC, old.getString(KEY_TWITTER_TOKEN_PUBLIC, null));
            e.putInt(KEY_VERSION, old.getInt(KEY_VERSION, 0));
            e.putBoolean(KEY_LOAD_DESCRIPTION, 0 != old.getInt(KEY_LOAD_DESCRIPTION, 0));
            e.putBoolean(KEY_RATING_WANTED, old.getBoolean(KEY_RATING_WANTED, true));
            e.putBoolean(KEY_ELEVATION_WANTED, old.getBoolean(KEY_ELEVATION_WANTED, true));
            e.putBoolean(KEY_FRIENDLOGS_WANTED, old.getBoolean(KEY_FRIENDLOGS_WANTED, true));
            e.putBoolean(KEY_USE_ENGLISH, old.getBoolean(KEY_USE_ENGLISH, false));
            e.putBoolean(KEY_USE_COMPASS, 0 != old.getInt(KEY_USE_COMPASS, 1));
            e.putBoolean(KEY_AUTO_VISIT_TRACKABLES, old.getBoolean(KEY_AUTO_VISIT_TRACKABLES, false));
            e.putBoolean(KEY_AUTO_INSERT_SIGNATURE, old.getBoolean(KEY_AUTO_INSERT_SIGNATURE, false));
            e.putInt(KEY_ALTITUDE_CORRECTION, old.getInt(KEY_ALTITUDE_CORRECTION, 0));
            e.putBoolean(KEY_USE_GOOGLE_NAVIGATION, 0 != old.getInt(KEY_USE_GOOGLE_NAVIGATION, 1));
            e.putBoolean(KEY_STORE_LOG_IMAGES, old.getBoolean(KEY_STORE_LOG_IMAGES, false));
            e.putBoolean(KEY_EXCLUDE_DISABLED, 0 != old.getInt(KEY_EXCLUDE_DISABLED, 0));
            e.putBoolean(KEY_EXCLUDE_OWN, 0 != old.getInt(KEY_EXCLUDE_OWN, 0));
            e.putString(KEY_MAPFILE, old.getString(KEY_MAPFILE, null));
            e.putString(KEY_SIGNATURE, old.getString(KEY_SIGNATURE, null));
            e.putString(KEY_GCVOTE_PASSWORD, old.getString(KEY_GCVOTE_PASSWORD, null));
            e.putString(KEY_PASSWORD, old.getString(KEY_PASSWORD, null));
            e.putString(KEY_USERNAME, old.getString(KEY_USERNAME, null));
            e.putString(KEY_MEMBER_STATUS, old.getString(KEY_MEMBER_STATUS, ""));
            e.putInt(KEY_COORD_INPUT_FORMAT, old.getInt(KEY_COORD_INPUT_FORMAT, 0));
            e.putBoolean(KEY_LOG_OFFLINE, old.getBoolean(KEY_LOG_OFFLINE, false));
            e.putBoolean(KEY_LOAD_DIRECTION_IMG, old.getBoolean(KEY_LOAD_DIRECTION_IMG, true));
            e.putString(KEY_GC_CUSTOM_DATE, old.getString(KEY_GC_CUSTOM_DATE, null));
            e.putInt(KEY_SHOW_WAYPOINTS_THRESHOLD, old.getInt(KEY_SHOW_WAYPOINTS_THRESHOLD, 0));
            e.putString(KEY_COOKIE_STORE, old.getString(KEY_COOKIE_STORE, null));
            e.putBoolean(KEY_OPEN_LAST_DETAILS_PAGE, old.getBoolean(KEY_OPEN_LAST_DETAILS_PAGE, false));
            e.putInt(KEY_LAST_DETAILS_PAGE, old.getInt(KEY_LAST_DETAILS_PAGE, 1));
            e.putInt(KEY_DEFAULT_NAVIGATION_TOOL, old.getInt(KEY_DEFAULT_NAVIGATION_TOOL, 0));
            e.putInt(KEY_DEFAULT_NAVIGATION_TOOL_2, old.getInt(KEY_DEFAULT_NAVIGATION_TOOL_2, 0));
            e.putInt(KEY_LIVE_MAP_STRATEGY, old.getInt(KEY_LIVE_MAP_STRATEGY, Strategy.AUTO.id));
            e.putBoolean(KEY_DEBUG, old.getBoolean(KEY_DEBUG, false));
            e.putBoolean(KEY_HIDE_LIVE_MAP_HINT, old.getInt(KEY_HIDE_LIVE_MAP_HINT, 0) != 0);
            e.putInt(KEY_LIVE_MAP_HINT_SHOW_COUNT, old.getInt(KEY_LIVE_MAP_HINT_SHOW_COUNT, 0));

            e.putInt(KEY_SETTINGS_VERSION, 1); // mark migrated
            e.commit();
        }
    }

    public static void setLanguage(boolean useEnglish) {
        final Configuration config = new Configuration();
        config.locale = useEnglish ? new Locale("en") : Locale.getDefault();
        final Resources resources = cgeoapplication.getInstance().getResources();
        resources.updateConfiguration(config, resources.getDisplayMetrics());
    }

    public static boolean isLogin() {
        final String preUsername = sharedPrefs.getString(KEY_USERNAME, null);
        final String prePassword = sharedPrefs.getString(KEY_PASSWORD, null);

        return !StringUtils.isBlank(preUsername) && !StringUtils.isBlank(prePassword);
    }

    /**
     * Get login and password information.
     *
     * @return a pair (login, password) or null if no valid information is stored
     */
    public static ImmutablePair<String, String> getLogin() {
        if (username == null || password == null) {
            final String preUsername = sharedPrefs.getString(KEY_USERNAME, null);
            final String prePassword = sharedPrefs.getString(KEY_PASSWORD, null);

            if (preUsername == null || prePassword == null) {
                return null;
            }

            username = preUsername;
            password = prePassword;
        }
        return new ImmutablePair<String, String>(username, password);
    }

    public static String getUsername() {
        return username != null ? username : sharedPrefs.getString(KEY_USERNAME, null);
    }

    public static boolean setLogin(final String username, final String password) {
        Settings.username = username;
        Settings.password = password;
        return editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                if (StringUtils.isBlank(username) || StringUtils.isBlank(password)) {
                    // erase username and password
                    edit.remove(KEY_USERNAME);
                    edit.remove(KEY_PASSWORD);
                } else {
                    // save username and password
                    edit.putString(KEY_USERNAME, username);
                    edit.putString(KEY_PASSWORD, password);
                }
            }
        });
    }

    public static boolean isPremiumMember() {
        // Basic Member, Premium Member, ???
        String memberStatus = Settings.getMemberStatus();
        if (memberStatus == null) {
            return false;
        }
        return GCConstants.MEMBER_STATUS_PM.equalsIgnoreCase(memberStatus);
    }

    public static String getMemberStatus() {
        return sharedPrefs.getString(KEY_MEMBER_STATUS, "");
    }

    public static boolean setMemberStatus(final String memberStatus) {
        return editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                if (StringUtils.isBlank(memberStatus)) {
                    edit.remove(KEY_MEMBER_STATUS);
                } else {
                    edit.putString(KEY_MEMBER_STATUS, memberStatus);
                }
            }
        });
    }

    public static boolean isGCvoteLogin() {
        final String preUsername = sharedPrefs.getString(KEY_USERNAME, null);
        final String prePassword = sharedPrefs.getString(KEY_GCVOTE_PASSWORD, null);

        return !StringUtils.isBlank(preUsername) && !StringUtils.isBlank(prePassword);
    }

    public static boolean setGCvoteLogin(final String password) {
        return editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                if (StringUtils.isBlank(password)) {
                    // erase password
                    edit.remove(KEY_GCVOTE_PASSWORD);
                } else {
                    // save password
                    edit.putString(KEY_GCVOTE_PASSWORD, password);
                }
            }
        });
    }

    public static ImmutablePair<String, String> getGCvoteLogin() {
        final String username = sharedPrefs.getString(KEY_USERNAME, null);
        final String password = sharedPrefs.getString(KEY_GCVOTE_PASSWORD, null);

        if (StringUtils.isBlank(username) || StringUtils.isBlank(password)) {
            return null;
        }

        return new ImmutablePair<String, String>(username, password);
    }

    public static boolean setSignature(final String signature) {
        return editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                if (StringUtils.isBlank(signature)) {
                    // erase signature
                    edit.remove(KEY_SIGNATURE);
                } else {
                    // save signature
                    edit.putString(KEY_SIGNATURE, signature);
                }
            }
        });
    }

    public static String getSignature() {
        return sharedPrefs.getString(KEY_SIGNATURE, null);
    }

    public static boolean setCookieStore(final String cookies) {
        return editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(final Editor edit) {
                if (StringUtils.isBlank(cookies)) {
                    // erase cookies
                    edit.remove(KEY_COOKIE_STORE);
                } else {
                    // save cookies
                    edit.putString(KEY_COOKIE_STORE, cookies);
                }
            }
        });
    }

    public static String getCookieStore() {
        return sharedPrefs.getString(KEY_COOKIE_STORE, null);
    }

    /**
     * @param cacheType
     *            The cache type used for future filtering
     */
    public static void setCacheType(final CacheType cacheType) {
        editSharedSettings(new PrefRunnable() {
            @Override
            public void edit(Editor edit) {
                if (cacheType == null) {
                    edit.remove(KEY_CACHE_TYPE);
                } else {
                    edit.putString(KEY_CACHE_TYPE, cacheType.id);
                }
            }
        });
    }

    public static void setLiveMap(final boolean live) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_MAP_LIVE, live);
            }
        });
    }

    public static int getLastList() {
        return sharedPrefs.getInt(KEY_LAST_USED_LIST, StoredList.STANDARD_LIST_ID);
    }

    public static void saveLastList(final int listId) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putInt(KEY_LAST_USED_LIST, listId);
            }
        });
    }

    public static void setWebNameCode(final String name, final String code) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {

                edit.putString(KEY_WEBDEVICE_NAME, name);
                edit.putString(KEY_WEB_DEVICE_CODE, code);
            }
        });
    }

    public static MapProvider getMapProvider() {
        if (mapProvider == null) {
            mapProvider = MapProviderFactory.getMapProvider(getMapSource());
        }
        return mapProvider;
    }

    public static String getMapFile() {
        return sharedPrefs.getString(KEY_MAPFILE, null);
    }

    public static boolean setMapFile(final String mapFile) {
        return editSharedSettings(new PrefRunnable() {
            @Override
            public void edit(Editor edit) {
                edit.putString(KEY_MAPFILE, mapFile);
            }
        });
    }

    public static boolean isValidMapFile() {
        return isValidMapFile(getMapFile());
    }

    public static boolean isValidMapFile(final String mapFileIn) {
        return MapsforgeMapProvider.isValidMapFile(mapFileIn);
    }

    public static coordInputFormatEnum getCoordInputFormat() {
        return coordInputFormatEnum.fromInt(sharedPrefs.getInt(KEY_COORD_INPUT_FORMAT, 0));
    }

    public static void setCoordInputFormat(final coordInputFormatEnum format) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putInt(KEY_COORD_INPUT_FORMAT, format.ordinal());
            }
        });
    }

    static void setLogOffline(final boolean offline) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_LOG_OFFLINE, offline);
            }
        });
    }

    public static boolean getLogOffline() {
        return sharedPrefs.getBoolean(KEY_LOG_OFFLINE, false);
    }

    static void setLoadDirImg(final boolean value) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_LOAD_DIRECTION_IMG, value);
            }
        });
    }

    public static boolean getLoadDirImg() {
        return !isPremiumMember() && sharedPrefs.getBoolean(KEY_LOAD_DIRECTION_IMG, true);
    }

    public static void setGcCustomDate(final String format) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putString(KEY_GC_CUSTOM_DATE, format);
            }
        });
    }

    /**
     * @return User selected date format on GC.com
     * @see Login#gcCustomDateFormats
     */
    public static String getGcCustomDate() {
        return sharedPrefs.getString(KEY_GC_CUSTOM_DATE, null);
    }

    public static boolean isExcludeMyCaches() {
        return sharedPrefs.getBoolean(KEY_EXCLUDE_OWN, false);
    }

    /**
     * edit some settings without knowing how to get the settings editor or how to commit
     *
     * @param runnable
     * @return
     */
    private static boolean editSharedSettings(final PrefRunnable runnable) {
        final SharedPreferences.Editor prefsEdit = sharedPrefs.edit();
        runnable.edit(prefsEdit);
        return prefsEdit.commit();
    }

    public static void setExcludeMine(final boolean exclude) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_EXCLUDE_OWN, exclude);
            }
        });
    }

    public static void setUseEnglish(final boolean english) {
        editSharedSettings(new PrefRunnable() {
            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_USE_ENGLISH, english);
                setLanguage(english);
            }
        });
    }

    public static boolean isUseEnglish() {
        return sharedPrefs.getBoolean(KEY_USE_ENGLISH, false);
    }

    public static boolean isShowAddress() {
        return sharedPrefs.getBoolean(KEY_SHOW_ADDRESS, true);
    }

    public static void setShowAddress(final boolean showAddress) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_SHOW_ADDRESS, showAddress);
            }
        });
    }

    public static boolean isShowCaptcha() {
        return !isPremiumMember() && sharedPrefs.getBoolean(KEY_SHOW_CAPTCHA, false);
    }

    public static void setShowCaptcha(final boolean showCaptcha) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_SHOW_CAPTCHA, showCaptcha);
            }
        });
    }

    public static boolean isExcludeDisabledCaches() {
        return sharedPrefs.getBoolean(KEY_EXCLUDE_DISABLED, false);
    }

    public static void setExcludeDisabledCaches(final boolean exclude) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_EXCLUDE_DISABLED, exclude);
            }
        });
    }

    public static boolean isStoreOfflineMaps() {
        return sharedPrefs.getBoolean(KEY_USE_OFFLINEMAPS, true);
    }

    public static void setStoreOfflineMaps(final boolean offlineMaps) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_USE_OFFLINEMAPS, offlineMaps);
            }
        });
    }

    public static boolean isStoreOfflineWpMaps() {
        return sharedPrefs.getBoolean(KEY_USE_OFFLINEWPMAPS, false);
    }

    public static void setStoreOfflineWpMaps(final boolean offlineMaps) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_USE_OFFLINEWPMAPS, offlineMaps);
            }
        });
    }

    public static boolean isStoreLogImages() {
        return sharedPrefs.getBoolean(KEY_STORE_LOG_IMAGES, false);
    }

    public static void setStoreLogImages(final boolean storeLogImages) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_STORE_LOG_IMAGES, storeLogImages);
            }
        });
    }

    public static boolean isUseGoogleNavigation() {
        return sharedPrefs.getBoolean(KEY_USE_GOOGLE_NAVIGATION, true);
    }

    public static void setUseGoogleNavigation(final boolean useGoogleNavigation) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_USE_GOOGLE_NAVIGATION, useGoogleNavigation);
            }
        });
    }

    public static boolean isAutoLoadDescription() {
        return sharedPrefs.getBoolean(KEY_LOAD_DESCRIPTION, false);
    }

    public static void setAutoLoadDesc(final boolean autoLoad) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_LOAD_DESCRIPTION, autoLoad);
            }
        });
    }

    public static boolean isRatingWanted() {
        return sharedPrefs.getBoolean(KEY_RATING_WANTED, true);
    }

    public static void setRatingWanted(final boolean ratingWanted) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_RATING_WANTED, ratingWanted);
            }
        });
    }

    public static boolean isElevationWanted() {
        return sharedPrefs.getBoolean(KEY_ELEVATION_WANTED, true);
    }

    public static void setElevationWanted(final boolean elevationWanted) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_ELEVATION_WANTED, elevationWanted);
            }
        });
    }

    public static boolean isFriendLogsWanted() {
        if (!isLogin()) {
            // don't show a friends log if the user is anonymous
            return false;
        }
        return sharedPrefs.getBoolean(KEY_FRIENDLOGS_WANTED, true);
    }

    public static void setFriendLogsWanted(final boolean friendLogsWanted) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_FRIENDLOGS_WANTED, friendLogsWanted);
            }
        });
    }

    public static boolean isLiveList() {
        return sharedPrefs.getBoolean(KEY_LIVE_LIST, true);
    }

    public static void setLiveList(final boolean liveList) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_LIVE_LIST, liveList);
            }
        });
    }

    public static boolean isPublicLoc() {
        return sharedPrefs.getBoolean(KEY_PUBLICLOC, false);
    }

    public static void setPublicLoc(final boolean publicLocation) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_PUBLICLOC, publicLocation);
            }
        });
    }

    public static boolean isTrackableAutoVisit() {
        return sharedPrefs.getBoolean(KEY_AUTO_VISIT_TRACKABLES, false);
    }

    public static void setTrackableAutoVisit(final boolean autoVisit) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_AUTO_VISIT_TRACKABLES, autoVisit);
            }
        });
    }

    public static boolean isAutoInsertSignature() {
        return sharedPrefs.getBoolean(KEY_AUTO_INSERT_SIGNATURE, false);
    }

    public static void setAutoInsertSignature(final boolean autoInsert) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_AUTO_INSERT_SIGNATURE, autoInsert);
            }
        });
    }

    public static boolean isUseMetricUnits() {
        return sharedPrefs.getBoolean(KEY_METRIC_UNITS, true);
    }

    public static void setUseMetricUnits(final boolean metric) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_METRIC_UNITS, metric);
            }
        });
    }

    public static boolean isLiveMap() {
        return sharedPrefs.getBoolean(KEY_MAP_LIVE, true);
    }

    public static boolean isMapTrail() {
        return sharedPrefs.getBoolean(KEY_MAP_TRAIL, true);
    }

    public static void setMapTrail(final boolean showTrail) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_MAP_TRAIL, showTrail);
            }
        });
    }

    public static int getMapZoom() {
        return sharedPrefs.getInt(KEY_LAST_MAP_ZOOM, 14);
    }

    public static void setMapZoom(final int mapZoomLevel) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putInt(KEY_LAST_MAP_ZOOM, mapZoomLevel);
            }
        });
    }

    public static GeoPointImpl getMapCenter() {
        return getMapProvider().getMapItemFactory()
                .getGeoPointBase(new Geopoint(sharedPrefs.getInt(KEY_LAST_MAP_LAT, 0) / 1e6,
                        sharedPrefs.getInt(KEY_LAST_MAP_LON, 0) / 1e6));
    }

    public static void setMapCenter(final GeoPointImpl mapViewCenter) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putInt(KEY_LAST_MAP_LAT, mapViewCenter.getLatitudeE6());
                edit.putInt(KEY_LAST_MAP_LON, mapViewCenter.getLongitudeE6());
            }
        });
    }

    public static int getMapSource() {
        return sharedPrefs.getInt(KEY_MAP_SOURCE, 0);
    }

    public static void setMapSource(final int newMapSource) {
        if (!MapProviderFactory.isSameActivity(getMapSource(), newMapSource)) {
            mapProvider = null;
        }
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putInt(KEY_MAP_SOURCE, newMapSource);
            }
        });
    }

    public static void setAnyCoordinates(final Geopoint coords) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                if (null != coords) {
                    edit.putFloat(KEY_ANYLATITUDE, (float) coords.getLatitude());
                    edit.putFloat(KEY_ANYLONGITUDE, (float) coords.getLongitude());
                } else {
                    edit.remove(KEY_ANYLATITUDE);
                    edit.remove(KEY_ANYLONGITUDE);
                }
            }
        });

    }

    public static Geopoint getAnyCoordinates() {
        if (sharedPrefs.contains(KEY_ANYLATITUDE) && sharedPrefs.contains(KEY_ANYLONGITUDE)) {
            float lat = sharedPrefs.getFloat(KEY_ANYLATITUDE, 0);
            float lon = sharedPrefs.getFloat(KEY_ANYLONGITUDE, 0);
            return new Geopoint(lat, lon);
        }
        return null;
    }

    public static boolean isUseCompass() {
        return sharedPrefs.getBoolean(KEY_USE_COMPASS, true);
    }

    public static void setUseCompass(final boolean useCompass) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_USE_COMPASS, useCompass);
            }
        });
    }

    public static boolean isHelpShown() {
        return sharedPrefs.getBoolean(KEY_HELP_SHOWN, false);
    }

    public static void setHelpShown() {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_HELP_SHOWN, true);
            }
        });
    }

    public static boolean isLightSkin() {
        return sharedPrefs.getBoolean(KEY_SKIN, false);
    }

    public static void setLightSkin(final boolean lightSkin) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_SKIN, lightSkin);
            }
        });
    }

    public static String getKeyConsumerPublic() {
        return keyConsumerPublic;
    }

    public static String getKeyConsumerSecret() {
        return keyConsumerSecret;
    }

    public static int getAltCorrection() {
        return sharedPrefs.getInt(KEY_ALTITUDE_CORRECTION, 0);
    }

    public static boolean setAltCorrection(final int altitude) {
        return editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putInt(KEY_ALTITUDE_CORRECTION, altitude);
            }
        });
    }

    public static String getWebDeviceCode() {
        return sharedPrefs.getString(KEY_WEB_DEVICE_CODE, null);
    }

    public static String getWebDeviceName() {
        return sharedPrefs.getString(KEY_WEBDEVICE_NAME, null);
    }

    /**
     * @return The cache type used for filtering or ALL if no filter is active. Returns never null
     */
    public static CacheType getCacheType() {
        return CacheType.getById(sharedPrefs.getString(KEY_CACHE_TYPE, CacheType.ALL.id));
    }

    /**
     * The Threshold for the showing of child waypoints
     *
     * @return
     */

    public static int getWayPointsThreshold() {
        return sharedPrefs.getInt(KEY_SHOW_WAYPOINTS_THRESHOLD, 0);
    }

    public static void setShowWaypointsThreshold(final int threshold) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putInt(KEY_SHOW_WAYPOINTS_THRESHOLD, threshold);
            }
        });
    }

    public static boolean isUseTwitter() {
        return sharedPrefs.getBoolean(KEY_USE_TWITTER, false);
    }

    public static void setUseTwitter(final boolean useTwitter) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_USE_TWITTER, useTwitter);
            }
        });
    }

    public static boolean isTwitterLoginValid() {
        return !StringUtils.isBlank(getTokenPublic()) && !StringUtils.isBlank(getTokenSecret());
    }

    public static String getTokenPublic() {
        return sharedPrefs.getString(KEY_TWITTER_TOKEN_PUBLIC, null);
    }

    public static String getTokenSecret() {
        return sharedPrefs.getString(KEY_TWITTER_TOKEN_SECRET, null);

    }

    public static int getVersion() {
        return sharedPrefs.getInt(KEY_VERSION, 0);
    }

    public static void setTwitterTokens(final String tokenPublic, final String tokenSecret, boolean enableTwitter) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putString(KEY_TWITTER_TOKEN_PUBLIC, tokenPublic);
                edit.putString(KEY_TWITTER_TOKEN_SECRET, tokenSecret);
                if (tokenPublic != null) {
                    edit.remove(KEY_TEMP_TOKEN_PUBLIC);
                    edit.remove(KEY_TEMP_TOKEN_SECRET);
                }
            }
        });
        setUseTwitter(enableTwitter);
    }

    public static void setTwitterTempTokens(final String tokenPublic, final String tokenSecret) {
        editSharedSettings(new PrefRunnable() {
            @Override
            public void edit(Editor edit) {
                edit.putString(KEY_TEMP_TOKEN_PUBLIC, tokenPublic);
                edit.putString(KEY_TEMP_TOKEN_SECRET, tokenSecret);
            }
        });
    }

    public static ImmutablePair<String, String> getTempToken() {
        String tokenPublic = sharedPrefs.getString(KEY_TEMP_TOKEN_PUBLIC, null);
        String tokenSecret = sharedPrefs.getString(KEY_TEMP_TOKEN_SECRET, null);
        return new ImmutablePair<String, String>(tokenPublic, tokenSecret);
    }

    public static void setVersion(final int version) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putInt(KEY_VERSION, version);
            }
        });
    }

    public static boolean isOpenLastDetailsPage() {
        return sharedPrefs.getBoolean(KEY_OPEN_LAST_DETAILS_PAGE, false);
    }

    public static void setOpenLastDetailsPage(final boolean openLastPage) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_OPEN_LAST_DETAILS_PAGE, openLastPage);
            }
        });
    }

    public static int getLastDetailsPage() {
        return sharedPrefs.getInt(KEY_LAST_DETAILS_PAGE, 1);
    }

    public static void setLastDetailsPage(final int index) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putInt(KEY_LAST_DETAILS_PAGE, index);
            }
        });
    }

    public static int getDefaultNavigationTool() {
        return sharedPrefs.getInt(KEY_DEFAULT_NAVIGATION_TOOL, NavigationAppsEnum.COMPASS.id);
    }

    public static void setDefaultNavigationTool(final int defaultNavigationTool) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putInt(KEY_DEFAULT_NAVIGATION_TOOL, defaultNavigationTool);
            }
        });
    }

    public static int getDefaultNavigationTool2() {
        return sharedPrefs.getInt(KEY_DEFAULT_NAVIGATION_TOOL_2, NavigationAppsEnum.INTERNAL_MAP.id);
    }

    public static void setDefaultNavigationTool2(final int defaultNavigationTool) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putInt(KEY_DEFAULT_NAVIGATION_TOOL_2, defaultNavigationTool);
            }
        });
    }

    public static Strategy getLiveMapStrategy() {
        return Strategy.getById(sharedPrefs.getInt(KEY_LIVE_MAP_STRATEGY, Strategy.AUTO.id));
    }

    public static void setLiveMapStrategy(final Strategy strategy) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putInt(KEY_LIVE_MAP_STRATEGY, strategy.id);
            }
        });
    }

    public static boolean isDebug() {
        return Log.isDebug();
    }

    public static void setDebug(final boolean debug) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_DEBUG, debug);
            }
        });
        Log.setDebugUnsaved(debug);
    }

    public static boolean getHideLiveMapHint() {
        return sharedPrefs.getBoolean(KEY_HIDE_LIVE_MAP_HINT, false);
    }

    public static void setHideLiveHint(final boolean hide) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_HIDE_LIVE_MAP_HINT, hide);
            }
        });
    }

    public static int getLiveMapHintShowCount() {
        return sharedPrefs.getInt(KEY_LIVE_MAP_HINT_SHOW_COUNT, 0);
    }

    public static void setLiveMapHintShowCount(final int showCount) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putInt(KEY_LIVE_MAP_HINT_SHOW_COUNT, showCount);
            }
        });
    }

    public static boolean isDbOnSDCard() {
        return sharedPrefs.getBoolean(KEY_DB_ON_SDCARD, false);
    }

    public static void setDbOnSDCard(final boolean dbOnSDCard) {
        editSharedSettings(new PrefRunnable() {
            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_DB_ON_SDCARD, dbOnSDCard);
            }
        });
    }

    public static String getGpxExportDir() {
        return sharedPrefs.getString(KEY_GPX_EXPORT_DIR, "/sdcard/gpx");
    }

    public static void setGpxExportDir(final String gpxExportDir) {
        editSharedSettings(new PrefRunnable() {
            @Override
            public void edit(Editor edit) {
                edit.putString(KEY_GPX_EXPORT_DIR, gpxExportDir);
            }
        });
    }

    public static boolean getShareAfterExport() {
        return sharedPrefs.getBoolean(KEY_SHARE_AFTER_EXPORT, true);
    }

    public static void setShareAfterExport(final boolean shareAfterExport) {
        editSharedSettings(new PrefRunnable() {
            @Override
            public void edit(Editor edit) {
                edit.putBoolean(KEY_SHARE_AFTER_EXPORT, shareAfterExport);
            }
        });
    }

    public static int getTrackableAction() {
        return sharedPrefs.getInt(KEY_LAST_TRACKABLE_ACTION, LogType.RETRIEVED_IT.id);
    }

    public static void setTrackableAction(final int trackableAction) {
        editSharedSettings(new PrefRunnable() {

            @Override
            public void edit(Editor edit) {
                edit.putInt(KEY_LAST_TRACKABLE_ACTION, trackableAction);
            }
        });
	}

    public static String getPreferencesName() {
        // there is currently no Android API to get the file name of the shared preferences
        return cgeoapplication.getInstance().getPackageName() + "_preferences";
    }

}