Skip to content

Commit

Permalink
Fix zip db import field selection
Browse files Browse the repository at this point in the history
  • Loading branch information
kamathprasad9 committed Jul 18, 2024
1 parent 493f0fb commit 5be89c5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2457,15 +2457,6 @@ public void importDatabase(DocumentFile file) {

}

SharedPreferences.Editor edit = preferences.edit();

edit.putInt(GeneralKeys.SELECTED_FIELD_ID, -1);
edit.putString(GeneralKeys.UNIQUE_NAME, "");
edit.putString(GeneralKeys.PRIMARY_NAME, "");
edit.putString(GeneralKeys.SECONDARY_NAME, "");
edit.putBoolean(GeneralKeys.IMPORT_FIELD_FINISHED, false);
edit.apply();

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ protected Integer doInBackground(Integer... params) {

database.importDatabase(file);

if (file.getName().equals("sample_db.zip")){
if (file.getName().equals("sample_db.zip") || file.getName().equals("sample.db")){
selectFirstField();
}

Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/fieldbook/tracker/utilities/ZipUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class ZipUtil {
//the expected zip file format contains two files
//1. fieldbook.db this can be directly copied to the data dir
//2. preferences_backup needs to:
// a. read and converted to a map <string to any (which is only boolean or string)>
// a. read and converted to a map <string to any (which is int, boolean or string)>
// b. preferences should be cleared of the old values
// c. iterate over the converted map and populate the preferences
@Throws(IOException::class)
Expand Down Expand Up @@ -247,6 +247,8 @@ class ZipUtil {

is String -> putString(key, x)

is Int -> putInt(key, x)

is Set<*> -> {

val newStringSet = hashSetOf<String>()
Expand Down

0 comments on commit 5be89c5

Please sign in to comment.