Created
February 13, 2013 04:38
-
-
Save DavidTPate/4942311 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LoginConfig { | |
/** | |
* Whether to hide Login functionality from the user. | |
*/ | |
private static boolean mShowSaveUsername = false; | |
public static boolean getShowSaveUsername() { | |
return mShowSaveUsername; | |
} | |
public static void init(Context context) { | |
Log.v(TAG, "LoginConfig.init()"); | |
loadLoginSettings(context); | |
} | |
private static void loadLoginSettings(Context context) { | |
XmlResourceParser parser = context.getResources().getXml(R.xml.login_config); | |
try { | |
beginDocument(parser, "login_config"); | |
while (true) { | |
nextElement(parser); | |
String tag = parser.getName(); | |
if (tag == null) { | |
break; | |
} | |
String name = parser.getAttributeName(0); | |
String value = parser.getAttributeValue(0); | |
String text = null; | |
if (parser.next() == XmlPullParser.TEXT) { | |
text = parser.getText(); | |
} | |
Log.v(TAG, "tag: " + tag + " value: " + value + " - " + text); | |
if ("name".equalsIgnoreCase(name)) { | |
if ("bool".equals(tag)) { | |
// bool config tags go here | |
if ("showSaveUsername".equalsIgnoreCase(value)) { | |
mShowSaveUsername = "true".equalsIgnoreCase(text); | |
} | |
} | |
} | |
} | |
} catch (XmlPullParserException e) { | |
Log.e(TAG, "loadLoginSettings caught ", e); | |
} catch (NumberFormatException e) { | |
Log.e(TAG, "loadLoginSettings caught ", e); | |
} catch (IOException e) { | |
Log.e(TAG, "loadLoginSettings caught ", e); | |
} finally { | |
parser.close(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment