2 * Copyright (C) 2010 Felix Bechstein
4 * This file is part of WebSMS.
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
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
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
;
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";
45 private static String mail
;
47 private static String pw
;
49 /** Need to bootstrap? */
50 private static boolean needBootstrap
= false;
56 protected void onCreate(final Bundle savedInstanceState
) {
57 super.onCreate(savedInstanceState
);
58 this.addPreferencesFromResource(R
.xml
.connector_gmx_prefs
);
65 protected void 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
, ""));
79 * @return true if bootstrap is needed
81 static boolean needBootstrap(final Context context
) {
85 final SharedPreferences p
= PreferenceManager
86 .getDefaultSharedPreferences(context
);
88 return p
.getString(PREFS_USER
, "").length() == 0;