Skip to content

Commit

Permalink
Merge pull request #474 from PhenoApps/v5.2/hotfix_sort_quotes
Browse files Browse the repository at this point in the history
fix for #473
  • Loading branch information
trife authored Aug 1, 2022
2 parents 41e3918 + 6c8b5e2 commit 2d28c4c
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 33 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ android {
applicationId "com.fieldbook.tracker"
minSdkVersion 21
targetSdkVersion 31
versionCode = 523
versionCode = 524
versionName = '5.2.0'
multiDexEnabled true
}
Expand Down
46 changes: 17 additions & 29 deletions app/src/main/java/com/fieldbook/tracker/database/DataHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2149,7 +2149,6 @@ public void deleteDatabase() {

public void importDatabase(DocumentFile file) {
String internalDbPath = getDatabasePath(this.context);
String internalSpPath = "/data/data/com.fieldbook.tracker/shared_prefs/Settings.xml";

close();

Expand All @@ -2159,46 +2158,35 @@ public void importDatabase(DocumentFile file) {

Log.w("File to copy", file.getName());

int extIndex = fileName.indexOf(".");
String stemName = fileName.substring(0, extIndex);
DocumentFile parent = file.getParentFile();

if (parent != null && parent.exists()) {

DocumentFile newSharedPrefsFile = parent.createFile("*/*", stemName + "_sharedpref.xml");
File oldDb = new File(internalDbPath);

File oldDb = new File(internalDbPath);
File oldSp = new File(internalSpPath);
try {

try {
BaseDocumentTreeUtil.Companion.copy(context, file, DocumentFile.fromFile(oldDb));

BaseDocumentTreeUtil.Companion.copy(context, file, DocumentFile.fromFile(oldDb));
} catch (Exception e) {

BaseDocumentTreeUtil.Companion.copy(context, newSharedPrefsFile, DocumentFile.fromFile(oldSp));
Log.d("Database", e.toString());

} catch (Exception e) {

Log.d("Database", e.toString());
}

}
open();

open();
if (!isTableExists(Migrator.Study.tableName)) {

if (!isTableExists(Migrator.Study.tableName)) {
Migrator.Companion.migrateSchema(db, getAllTraitObjects());

Migrator.Companion.migrateSchema(db, getAllTraitObjects());
}

}
SharedPreferences.Editor edit = ep.edit();

SharedPreferences.Editor edit = ep.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();

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 @@ -38,7 +38,7 @@ class ObservationUnitPropertyDao {

sortCols = if(sortCols != null && sortCols != "") {
val sortColsSplit = sortCols.split(',')
val sortColsList = sortColsSplit.map{ "cast($it as integer),$it" }.toList()
val sortColsList = sortColsSplit.map{ "cast(`$it` as integer),`$it`" }.toList()
"${sortColsList.joinToString ( "," )}, id"
} else {
"id"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ protected Integer doInBackground(Integer... params) {

if (file != null && file.getName() != null) {

dt.close();

//first check if the file to import is just a .db file
if (file.getName().endsWith(".db")) { //if it is import it old-style

Expand Down Expand Up @@ -200,7 +202,9 @@ protected void onPostExecute(Integer result) {
dialog.dismiss();

if (fail) {

Utils.makeToast(getContext(), getString(R.string.import_error_general));

}

CollectActivity.reloadData = true;
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed May 04 16:02:28 CDT 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

0 comments on commit 2d28c4c

Please sign in to comment.