diff --git a/app/src/main/java/corewala/buran/ui/GemActivity.kt b/app/src/main/java/corewala/buran/ui/GemActivity.kt
index 071928f..a71ac2a 100644
--- a/app/src/main/java/corewala/buran/ui/GemActivity.kt
+++ b/app/src/main/java/corewala/buran/ui/GemActivity.kt
@@ -7,7 +7,6 @@ import android.content.SharedPreferences
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.net.Uri
-import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
@@ -23,6 +22,7 @@ import androidx.preference.PreferenceManager
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.snackbar.Snackbar
import corewala.*
+import corewala.buran.BuildConfig
import corewala.buran.Buran
import corewala.buran.OmniTerm
import corewala.buran.R
@@ -32,6 +32,7 @@ import corewala.buran.io.database.BuranDatabase
import corewala.buran.io.database.bookmarks.BookmarksDatasource
import corewala.buran.io.gemini.Datasource
import corewala.buran.io.gemini.GeminiResponse
+import corewala.buran.io.update.BuranUpdates
import corewala.buran.ui.bookmarks.BookmarkDialog
import corewala.buran.ui.bookmarks.BookmarksDialog
import corewala.buran.ui.content_image.ImageDialog
@@ -154,6 +155,24 @@ class GemActivity : AppCompatActivity() {
)
}
+ if(PreferenceManager.getDefaultSharedPreferences(this).getBoolean(
+ "check_for_updates",
+ false
+ )) {
+ val updates = BuranUpdates()
+ val latestVersion = updates.getLatestVersion()
+
+ if (latestVersion == BuildConfig.VERSION_NAME){
+ println("No new version available")
+ } else {
+ println("New version available")
+
+ Snackbar.make(binding.root, getString(R.string.new_version_available), Snackbar.LENGTH_LONG).setAction(getString(R.string.update)) {
+ updates.installUpdate(this, latestVersion)
+ }.show()
+ }
+ }
+
binding.addressEdit.setOnEditorActionListener { _, actionId, _ ->
when (actionId) {
EditorInfo.IME_ACTION_GO -> {
diff --git a/app/src/main/java/corewala/buran/ui/settings/SettingsFragment.kt b/app/src/main/java/corewala/buran/ui/settings/SettingsFragment.kt
index e4e6a57..e60236d 100644
--- a/app/src/main/java/corewala/buran/ui/settings/SettingsFragment.kt
+++ b/app/src/main/java/corewala/buran/ui/settings/SettingsFragment.kt
@@ -65,7 +65,14 @@ class SettingsFragment: PreferenceFragmentCompat(), Preference.OnPreferenceChang
}
appCategory.addPreference(homePreference)
- //Home - Certificates
+ //Updates ---------------------------------------------
+ val checkForUpdates = SwitchPreferenceCompat(context)
+ checkForUpdates.setDefaultValue(true)
+ checkForUpdates.key = "check_for_updates"
+ checkForUpdates.title = getString(R.string.check_for_updates)
+ appCategory.addPreference(checkForUpdates)
+
+ //Home - Certificates - Updates
buildClientCertificateSection(context, appCategory)
//Appearance --------------------------------------------
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index 7022b84..9a2299e 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -65,6 +65,8 @@
Pas de mot de passe
Utiliser un Certificat Client
Choisir comme capsule d\'accueil
+ Rechercher des nouvelles versions
+ Nouvelle version disponible
Historique vidé
Cache d\'exécution vidé
Icônes de lien en ligne
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index b90146b..0c10f11 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -65,6 +65,8 @@
No Password
Use Client Certificate
Set home capsule
+ Check for updates
+ New version available
History cleared
Runtime cache cleared
Inline link icons