diff --git a/F-Droid/src/org/fdroid/fdroid/data/DBHelper.java b/F-Droid/src/org/fdroid/fdroid/data/DBHelper.java index 3d301f62e..1b89b0ab8 100644 --- a/F-Droid/src/org/fdroid/fdroid/data/DBHelper.java +++ b/F-Droid/src/org/fdroid/fdroid/data/DBHelper.java @@ -169,14 +169,12 @@ public class DBHelper extends SQLiteOpenHelper { + "maxage integer not null default 0, " + "version integer not null default 0, " + "lastetag text, " - + "lastUpdated string," - + "username string, password string" - + ");"; + + "lastUpdated string);"; db.execSQL(createTableDdl); String nonIdFields = "address, name, description, inuse, priority, " + - "pubkey, fingerprint, maxage, version, lastetag, lastUpdated, username, password"; + "pubkey, fingerprint, maxage, version, lastetag, lastUpdated"; String insertSql = "INSERT INTO " + TABLE_REPO + "(_id, " + nonIdFields + " ) " + @@ -285,11 +283,11 @@ public class DBHelper extends SQLiteOpenHelper { populateRepoNames(db, oldVersion); if (oldVersion < 43) createInstalledApp(db); addIsSwapToRepo(db, oldVersion); - addCredentialsToRepo(db, oldVersion); addChangelogToApp(db, oldVersion); addIconUrlLargeToApp(db, oldVersion); updateIconUrlLarge(db, oldVersion); recreateInstalledCache(db, oldVersion); + addCredentialsToRepo(db, oldVersion); } /** @@ -425,11 +423,16 @@ public class DBHelper extends SQLiteOpenHelper { } private void addCredentialsToRepo(SQLiteDatabase db, int oldVersion) { - if (oldVersion < 52 && !columnExists(db, TABLE_REPO, "username") && !columnExists(db, TABLE_REPO, "password")) { - Utils.debugLog(TAG, "Adding username field to " + TABLE_REPO + " table in db."); - db.execSQL("alter table " + TABLE_REPO + " add column username string;"); - Utils.debugLog(TAG, "Adding password field to " + TABLE_REPO + " table in db."); - db.execSQL("alter table " + TABLE_REPO + " add column password string;"); + if (oldVersion < 52) { + if (!columnExists(db, TABLE_REPO, "username")) { + Utils.debugLog(TAG, "Adding username field to " + TABLE_REPO + " table in db."); + db.execSQL("alter table " + TABLE_REPO + " add column username string;"); + } + + if (!columnExists(db, TABLE_REPO, "password")) { + Utils.debugLog(TAG, "Adding password field to " + TABLE_REPO + " table in db."); + db.execSQL("alter table " + TABLE_REPO + " add column password string;"); + } } } diff --git a/F-Droid/src/org/fdroid/fdroid/views/ManageReposActivity.java b/F-Droid/src/org/fdroid/fdroid/views/ManageReposActivity.java index 8f500784b..ee308107a 100644 --- a/F-Droid/src/org/fdroid/fdroid/views/ManageReposActivity.java +++ b/F-Droid/src/org/fdroid/fdroid/views/ManageReposActivity.java @@ -547,7 +547,7 @@ public class ManageReposActivity extends ActionBarActivity { } else { // create repo without username/password - createNewRepo(newAddress, fingerprint, null, null); + createNewRepo(newAddress, fingerprint); } } } @@ -564,7 +564,7 @@ public class ManageReposActivity extends ActionBarActivity { // or their internet is playing up, then you'd have to wait for several // connection timeouts before being able to proceed. - createNewRepo(originalAddress, fingerprint, null, null); + createNewRepo(originalAddress, fingerprint); checker.cancel(false); } }); @@ -600,6 +600,13 @@ public class ManageReposActivity extends ActionBarActivity { path, uri.getQuery(), uri.getFragment()).toString(); } + /** + * Create a repository without a username or password. + */ + private void createNewRepo(String address, String fingerprint) { + createNewRepo(address, fingerprint, null, null); + } + private void createNewRepo(String address, String fingerprint, final String username, final String password) { try { address = normalizeUrl(address); diff --git a/F-Droid/src/org/fdroid/fdroid/views/RepoDetailsActivity.java b/F-Droid/src/org/fdroid/fdroid/views/RepoDetailsActivity.java index e7c3d8223..dcfa63cf6 100644 --- a/F-Droid/src/org/fdroid/fdroid/views/RepoDetailsActivity.java +++ b/F-Droid/src/org/fdroid/fdroid/views/RepoDetailsActivity.java @@ -390,7 +390,7 @@ public class RepoDetailsActivity extends ActionBarActivity { final String name = nameInput.getText().toString(); final String password = passwordInput.getText().toString(); - if (name != null && !name.isEmpty()) { + if (!TextUtils.isEmpty(name)) { final ContentValues values = new ContentValues(2); values.put(RepoProvider.DataColumns.USERNAME, name);