Skip to content

Commit

Permalink
Fix a small annoyance on a contributed condition statement, check for…
Browse files Browse the repository at this point in the history
… and handle missing settings items to handle upgrade conditions
  • Loading branch information
matburt committed Apr 4, 2010
1 parent 54529fc commit d688dc5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/com/matburt/mobileorg/OrgFileParser.java
Expand Up @@ -40,7 +40,7 @@ class TitleComponents {
}

private Pattern prepareTitlePattern () {
if (null == this.titlePattern) {
if (this.titlePattern == null) {
StringBuffer pattern = new StringBuffer();
pattern.append("^(?:(");
pattern.append(TextUtils.join("|", todoKeywords));
Expand Down
18 changes: 17 additions & 1 deletion src/com/matburt/mobileorg/SettingsActivity.java
Expand Up @@ -2,6 +2,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;
Expand All @@ -28,6 +29,8 @@ public class SettingsActivity extends Activity implements OnClickListener

private SQLiteDatabase appdb;

public static String settingsList[] = {"webUrl", "webUser", "webPass", "storage"};

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -58,6 +61,19 @@ public void initializeSettings() {
this.settings.put(result.getString(0),
result.getString(1));
} while (result.moveToNext());
for (int idx = 0; idx < this.settingsList.length; idx++) {
if (!this.settings.containsKey(this.settingsList[idx])) {
if (this.settingsList[idx] == "storage") {
this.settings.put("storage", "internal");
}
else {
this.settings.put(this.settingsList[idx], "");
}
this.appdb.execSQL("INSERT INTO settings (key, val)" +
" VALUES ('" + this.settingsList[idx] +"','"+
this.settings.get(this.settingsList[idx]) + "');");
}
}
this.populateDisplay();
}
else {
Expand All @@ -68,7 +84,7 @@ public void initializeSettings() {
this.appdb.execSQL("INSERT INTO settings (key, val)" +
" VALUES ('webPass', '')");
this.appdb.execSQL("INSERT INTO settings (key, val)" +
" VALUES ('storage', '')");
" VALUES ('storage', 'internal')");
}
}
result.close();
Expand Down

0 comments on commit d688dc5

Please sign in to comment.