EMMA Coverage Report (generated Tue Jun 26 14:54:12 CEST 2012)
[all classes][org.tomdroid.util]

COVERAGE SUMMARY FOR SOURCE FILE [Preferences.java]

nameclass, %method, %block, %line, %
Preferences.java100% (2/2)60%  (9/15)82%  (263/319)76%  (35,9/47)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Preferences100% (1/1)56%  (5/9)47%  (41/88)48%  (11/23)
Preferences (): void 0%   (0/1)0%   (0/3)0%   (0/2)
getLong (Preferences$Key): long 0%   (0/1)0%   (0/9)0%   (0/1)
putLong (Preferences$Key, long): void 0%   (0/1)0%   (0/10)0%   (0/3)
putString (Preferences$Key, String): void 0%   (0/1)0%   (0/21)0%   (0/5)
init (Context, boolean): void 100% (1/1)69%  (9/13)80%  (4/5)
<static initializer> 100% (1/1)100% (5/5)100% (2/2)
getBoolean (Preferences$Key): boolean 100% (1/1)100% (9/9)100% (1/1)
getString (Preferences$Key): String 100% (1/1)100% (8/8)100% (1/1)
putBoolean (Preferences$Key, boolean): void 100% (1/1)100% (10/10)100% (3/3)
     
class Preferences$Key100% (1/1)67%  (4/6)96%  (222/231)100% (25/25)
valueOf (String): Preferences$Key 0%   (0/1)0%   (0/5)0%   (0/1)
values (): Preferences$Key [] 0%   (0/1)0%   (0/4)0%   (0/1)
<static initializer> 100% (1/1)100% (199/199)100% (17/17)
Preferences$Key (String, int, String, Object): void 100% (1/1)100% (17/17)100% (6/6)
getDefault (): Object 100% (1/1)100% (3/3)100% (1/1)
getName (): String 100% (1/1)100% (3/3)100% (1/1)

1/*
2 * Tomdroid
3 * Tomboy on Android
4 * http://www.launchpad.net/tomdroid
5 * 
6 * Copyright 2011, Olivier Bilodeau <olivier@bottomlesspit.org>
7 * Copyright 2009, Benoit Garret <benoit.garret_launchpad@gadz.org>
8 * 
9 * This file is part of Tomdroid.
10 * 
11 * Tomdroid is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 * 
16 * Tomdroid is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 * GNU General Public License for more details.
20 * 
21 * You should have received a copy of the GNU General Public License
22 * along with Tomdroid.  If not, see <http://www.gnu.org/licenses/>.
23 */
24package org.tomdroid.util;
25 
26import android.content.Context;
27import android.content.SharedPreferences;
28import android.preference.PreferenceManager;
29 
30public class Preferences {
31        
32        public enum Key {
33                SYNC_SERVICE ("sync_service", "sdcard"),
34                SYNC_SERVER_ROOT_API ("sync_server_root_api", ""),
35                SYNC_SERVER_USER_API ("sync_server_user_api", ""),
36                SYNC_SERVER ("sync_server", "https://one.ubuntu.com/notes"),
37                CLEAR_SEARCH_HISTORY ("clearSearchHistory", ""),
38                ACCESS_TOKEN ("access_token", ""),
39                ACCESS_TOKEN_SECRET ("access_token_secret", ""),
40                REQUEST_TOKEN ("request_token", ""),
41                REQUEST_TOKEN_SECRET ("request_token_secret", ""),
42                OAUTH_10A ("oauth_10a", false),
43                AUTHORIZE_URL ("authorize_url", ""),
44                ACCESS_TOKEN_URL ("access_token_url", ""),
45                REQUEST_TOKEN_URL ("request_token_url", ""),
46                LATEST_SYNC_REVISION ("latest_sync_revision", 0L),
47                SORT_ORDER ("sort_order", "sort_date"),
48                FIRST_RUN ("first_run", true);
49                
50                private String name = "";
51                private Object defaultValue = "";
52                
53                Key(String name, Object defaultValue) {
54                        this.name = name;
55                        this.defaultValue = defaultValue;
56                }
57                
58                public String getName() {
59                        return name;
60                }
61                
62                public Object getDefault() {
63                        return defaultValue;
64                }
65        }
66        
67        private static SharedPreferences client = null;
68        private static SharedPreferences.Editor editor = null;
69        
70        public static void init(Context context, boolean clean) {
71                
72                client = PreferenceManager.getDefaultSharedPreferences(context);
73                editor = client.edit();
74                
75                if (clean)
76                        editor.clear().commit();
77        }
78        
79        public static String getString(Key key) {
80                
81                return client.getString(key.getName(), (String) key.getDefault());
82        }
83        
84        public static void putString(Key key, String value) {
85                
86                if (value == null)
87                        editor.putString(key.getName(), (String)key.getDefault());
88                else
89                        editor.putString(key.getName(), value);
90                editor.commit();
91        }
92        
93        public static long getLong(Key key) {
94                
95                return client.getLong(key.getName(), (Long)key.getDefault());
96        }
97        
98        public static void putLong(Key key, long value) {
99                
100                editor.putLong(key.getName(), value);
101                editor.commit();
102        }
103        
104        public static boolean getBoolean(Key key) {
105                
106                return client.getBoolean(key.getName(), (Boolean)key.getDefault());
107        }
108        
109        public static void putBoolean(Key key, boolean value) {
110                
111                editor.putBoolean(key.getName(), value);
112                editor.commit();
113        }
114}

[all classes][org.tomdroid.util]
EMMA 0.0.0 (unsupported private build) (C) Vladimir Roubtsov