mirror of
https://github.com/apache/cordova-android.git
synced 2026-05-11 00:00:05 +08:00
making preference reading code more robust
This commit is contained in:
@@ -329,7 +329,7 @@ public class DroidGap extends PhonegapActivity {
|
||||
|
||||
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
if (preferences.pref("fullscreen").equals("true")) {
|
||||
if (preferences.prefMatches("fullscreen","true")) {
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
} else {
|
||||
@@ -1901,7 +1901,8 @@ public class DroidGap extends PhonegapActivity {
|
||||
String value = xml.getAttributeValue(null, "value");
|
||||
String readonlyString = xml.getAttributeValue(null, "readonly");
|
||||
|
||||
boolean readonly = (readonlyString.equals("true"));
|
||||
boolean readonly = (readonlyString != null &&
|
||||
readonlyString.equals("true"));
|
||||
|
||||
LOG.i("PhoneGapLog", "Found preference for %s", name);
|
||||
|
||||
|
||||
@@ -30,4 +30,14 @@ public class PreferenceSet {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean prefMatches(String prefName, String prefValue) {
|
||||
String value = pref(prefName);
|
||||
|
||||
if (value == null) {
|
||||
return false;
|
||||
} else {
|
||||
return value.equals(prefValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user