mirror of
https://github.com/Corewala/Buran
synced 2025-01-02 21:24:19 +00:00
Updater
This commit is contained in:
parent
8d70218d23
commit
d7a2cdeb9f
4 changed files with 32 additions and 2 deletions
|
@ -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 -> {
|
||||
|
|
|
@ -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 --------------------------------------------
|
||||
|
|
|
@ -65,6 +65,8 @@
|
|||
<string name="no_password">Pas de mot de passe</string>
|
||||
<string name="use_client_certificate">Utiliser un Certificat Client</string>
|
||||
<string name="set_home_capsule">Choisir comme capsule d\'accueil</string>
|
||||
<string name="check_for_updates">Rechercher des nouvelles versions</string>
|
||||
<string name="new_version_available">Nouvelle version disponible</string>
|
||||
<string name="history_cleared">Historique vidé</string>
|
||||
<string name="runtime_cache_cleared">Cache d\'exécution vidé</string>
|
||||
<string name="show_inline_icons">Icônes de lien en ligne</string>
|
||||
|
|
|
@ -65,6 +65,8 @@
|
|||
<string name="no_password">No Password</string>
|
||||
<string name="use_client_certificate">Use Client Certificate</string>
|
||||
<string name="set_home_capsule">Set home capsule</string>
|
||||
<string name="check_for_updates">Check for updates</string>
|
||||
<string name="new_version_available">New version available</string>
|
||||
<string name="history_cleared">History cleared</string>
|
||||
<string name="runtime_cache_cleared">Runtime cache cleared</string>
|
||||
<string name="show_inline_icons">Inline link icons</string>
|
||||
|
|
Loading…
Reference in a new issue