diff --git a/README.md b/README.md index ee791ea..e6456c8 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ This work is licensed under GPLv3 - At first start it downloads the BirdNet TFLite library from [whoBird-TFlite](https://github.com/woheller69/whoBIRD-TFlite), which is published under CC BY NC SA 4.0 license - Label files from BirdNET are used under GPL 3.0 with [permission from the author](https://github.com/woheller69/whoBIRD/issues/1) - It uses code from [Tensorflow](https://www.tensorflow.org/lite/examples) examples, published under [Apache 2.0 license](https://www.apache.org/licenses/LICENSE-2.0.html) +- It uses Zip4j (https://github.com/srikanth-lingala/zip4j) which is licensed under Apache License Version 2.0 # OTHER APPS diff --git a/app/build.gradle b/app/build.gradle index af3da34..fe03aaf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "org.woheller69.whobird" minSdk 30 targetSdk 33 - versionCode 28 - versionName "2.8" + versionCode 29 + versionName "2.9" } aaptOptions { @@ -52,4 +52,5 @@ dependencies { implementation "org.tensorflow:tensorflow-lite:2.6.0" implementation 'androidx.preference:preference:1.2.0' implementation 'com.squareup.okhttp3:okhttp:4.12.0' + implementation 'net.lingala.zip4j:zip4j:2.9.1' } \ No newline at end of file diff --git a/app/src/main/java/org/tensorflow/lite/examples/soundclassifier/MainActivity.kt b/app/src/main/java/org/tensorflow/lite/examples/soundclassifier/MainActivity.kt index 225fb88..32d8b2a 100644 --- a/app/src/main/java/org/tensorflow/lite/examples/soundclassifier/MainActivity.kt +++ b/app/src/main/java/org/tensorflow/lite/examples/soundclassifier/MainActivity.kt @@ -22,6 +22,8 @@ import android.content.Intent import android.content.pm.PackageManager import android.net.Uri import android.os.Bundle +import android.os.Environment +import android.view.Gravity import android.view.Menu import android.view.MenuItem import android.view.View @@ -29,10 +31,15 @@ import android.view.ViewGroup import android.view.WindowManager import android.webkit.WebSettings import android.widget.Toast +import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat import com.google.android.material.snackbar.Snackbar +import net.lingala.zip4j.ZipFile +import net.lingala.zip4j.exception.ZipException import org.tensorflow.lite.examples.soundclassifier.databinding.ActivityMainBinding +import java.io.File +import java.util.Objects class MainActivity : AppCompatActivity() { @@ -173,7 +180,41 @@ class MainActivity : AppCompatActivity() { startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/woheller69/whobird"))) return true } + R.id.action_backup -> { + performBackup() + return true + } else -> return super.onOptionsItemSelected(item) } } + + fun performBackup() { + val extStorage: File + val intData: File + intData = File( + Environment.getDataDirectory().toString() + "//data//" + this.packageName + "//databases//" + ) + extStorage = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + val filesBackup = resources.getString(R.string.app_name) + ".zip" + val dbBackup = File(extStorage, filesBackup) + val builder = AlertDialog.Builder(this) + builder.setMessage(resources.getString(R.string.backup_database) + " -> " + dbBackup.toString()) + builder.setPositiveButton(R.string.dialog_OK_button) { dialog, whichButton -> + if (dbBackup.exists()) { + if (!dbBackup.delete()) { + Toast.makeText(this, resources.getString(R.string.toast_delete), Toast.LENGTH_LONG) + .show() + } + } + try { + ZipFile(dbBackup).addFolder(intData) + } catch (e: ZipException) { + Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show() + } + } + builder.setNegativeButton(R.string.dialog_NO_button) { dialog, whichButton -> dialog.cancel() } + val dialog = builder.create() + dialog.show() + Objects.requireNonNull(dialog.window)?.setGravity(Gravity.BOTTOM) + } } diff --git a/app/src/main/res/menu/main.xml b/app/src/main/res/menu/main.xml index 8eb4d70..c0944bd 100644 --- a/app/src/main/res/menu/main.xml +++ b/app/src/main/res/menu/main.xml @@ -7,4 +7,8 @@ android:icon="@drawable/ic_info_24dp" app:showAsAction="always" tools:ignore="MenuTitle" /> + + diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index dadd664..1ef47e3 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -17,4 +17,6 @@ Pozorování smazána Podrobný seznam Vymazat? + Backup + Please delete file and try again \ No newline at end of file diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index c8ee5b6..7d5f678 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -17,5 +17,6 @@ Beobachtungen gelöscht Detaillierte Liste Löschen? - + Sichern + Bitte die Datei zuerst löschen und erneut versuchen \ No newline at end of file diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 9c4c943..aea9a56 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -18,5 +18,6 @@ Observaciones borradas Lista detallada ¿Borrar? - + Backup + Please delete file and try again \ No newline at end of file diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index f928efb..922ea06 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -18,4 +18,6 @@ Les observations ont été supprimées Liste détaillée Supprimer? + Backup + Please delete file and try again \ No newline at end of file diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 08e871d..09ffd13 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -17,4 +17,6 @@ Obserwacje usunięte Szczegółowa lista Usuwać? + Backup + Please delete file and try again diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index fa50712..e98882b 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -18,5 +18,6 @@ Observationer borttagna Detaljerad lista Radera? - + Backup + Please delete file and try again \ No newline at end of file diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 4132292..ff30fd8 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -17,5 +17,6 @@ Gözlemler silindi Ayrıntılı liste Silmek? - + Yedekleme + Lütfen dosyayı silin ve tekrar deneyin diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f6883ca..6f34840 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -18,5 +18,6 @@ Observations deleted Detailed list Delete? - + Backup + Please delete file and try again \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index d199649..f0a42f3 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -7,5 +7,6 @@ @color/gray700 @color/gray400 @color/gray800 + @color/gray400 \ No newline at end of file diff --git a/fastlane/metadata/android/en-US/changelogs/29.txt b/fastlane/metadata/android/en-US/changelogs/29.txt new file mode 100644 index 0000000..9b2e702 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/29.txt @@ -0,0 +1 @@ +Option for database backup \ No newline at end of file