cleanup
[andGMXsms.git] / connectors / gmx / src / de / ub0r / android / websms / connector / gmx / Preferences.java
blob33a07640de83c4f499f7fb0a19218eb89b95b06c
1 /*
2 * Copyright (C) 2010 Felix Bechstein
3 *
4 * This file is part of WebSMS.
5 *
6 * This program is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License as published by the Free Software
8 * Foundation; either version 3 of the License, or (at your option) any later
9 * version.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 * details.
16 * You should have received a copy of the GNU General Public License along with
17 * this program; If not, see <http://www.gnu.org/licenses/>.
19 package de.ub0r.android.websms.connector.gmx;
21 import android.content.Context;
22 import android.content.SharedPreferences;
23 import android.os.Bundle;
24 import android.preference.PreferenceActivity;
25 import android.preference.PreferenceManager;
27 /**
28 * Preferences.
30 * @author flx
32 public final class Preferences extends PreferenceActivity {
33 /** Preference's name: mail. */
34 static final String PREFS_MAIL = "gmx_mail";
35 /** Preference's name: username. */
36 static final String PREFS_USER = "gmx_user";
37 /** Preference's name: user's password. */
38 static final String PREFS_PASSWORD = "gmx_password";
39 /** Preference's name: gmx hostname id. */
40 static final String PREFS_GMX_HOST = "gmx_host";
41 /** Preference key: enabled. */
42 static final String PREFS_ENABLED = "enable_gmx";
44 /** mail. */
45 private static String mail;
46 /** password. */
47 private static String pw;
49 /** Need to bootstrap? */
50 private static boolean needBootstrap = false;
52 /**
53 * {@inheritDoc}
55 @Override
56 protected void onCreate(final Bundle savedInstanceState) {
57 super.onCreate(savedInstanceState);
58 this.addPreferencesFromResource(R.xml.connector_gmx_prefs);
61 /**
62 * {@inheritDoc}
64 @Override
65 protected void onPause() {
66 super.onPause();
67 // check if prefs changed
68 final SharedPreferences p = PreferenceManager
69 .getDefaultSharedPreferences(this);
70 needBootstrap |= mail != null
71 && !mail.equals(p.getString(PREFS_MAIL, ""));
72 needBootstrap |= pw != null
73 && !pw.equals(p.getString(PREFS_PASSWORD, ""));
76 /**
77 * @param context
78 * {@link Context}
79 * @return true if bootstrap is needed
81 static boolean needBootstrap(final Context context) {
82 if (needBootstrap) {
83 return true;
85 final SharedPreferences p = PreferenceManager
86 .getDefaultSharedPreferences(context);
88 return p.getString(PREFS_USER, "").length() == 0;