diff --git a/app/build.gradle b/app/build.gradle
index ddf104da3..0e795adb7 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -15,8 +15,8 @@ android {
applicationId "software.mdev.bookstracker"
minSdkVersion 24
targetSdkVersion 30
- versionCode 1
- versionName "1.2.0"
+ versionCode 2
+ versionName "1.2.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@@ -75,4 +75,7 @@ dependencies {
// PREFERENCES
implementation "androidx.preference:preference-ktx:1.1.1"
+
+ // https://github.com/javiersantos/AppUpdater
+ implementation 'com.github.javiersantos:AppUpdater:2.7'
}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 87cac8a00..721e5e70f 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -2,6 +2,8 @@
+
+
-
\ No newline at end of file
diff --git a/app/src/main/java/software/mdev/bookstracker/other/Constants.kt b/app/src/main/java/software/mdev/bookstracker/other/Constants.kt
index a00eea7e9..e96dd93df 100644
--- a/app/src/main/java/software/mdev/bookstracker/other/Constants.kt
+++ b/app/src/main/java/software/mdev/bookstracker/other/Constants.kt
@@ -40,6 +40,7 @@ object Constants {
const val SHARED_PREFERENCES_KEY_ACCENT = "KEY_ACCENT"
const val SHARED_PREFERENCES_KEY_RECOMMENDATIONS = "KEY_RECOMMENDATIONS"
const val SHARED_PREFERENCES_REFRESHED = "refreshed"
+ const val KEY_CHECK_FOR_UPDATES = "KEY_CHECK_FOR_UPDATES"
const val EMPTY_STRING = ""
@@ -55,4 +56,7 @@ object Constants {
const val THEME_ACCENT_YELLOW_500 = "accent_yellow"
const val THEME_ACCENT_DEFAULT = THEME_ACCENT_GREEN_500
+
+ const val GITHUB_USER = "mateusz-bak"
+ const val GITHUB_REPO = "books-tracker-android"
}
\ No newline at end of file
diff --git a/app/src/main/java/software/mdev/bookstracker/ui/bookslist/ListActivity.kt b/app/src/main/java/software/mdev/bookstracker/ui/bookslist/ListActivity.kt
index 4d161b655..5e32b138c 100644
--- a/app/src/main/java/software/mdev/bookstracker/ui/bookslist/ListActivity.kt
+++ b/app/src/main/java/software/mdev/bookstracker/ui/bookslist/ListActivity.kt
@@ -8,7 +8,13 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.fragment.findNavController
import androidx.navigation.ui.setupWithNavController
+import com.github.javiersantos.appupdater.AppUpdater
+import com.github.javiersantos.appupdater.enums.Display
+import com.github.javiersantos.appupdater.enums.UpdateFrom
import kotlinx.android.synthetic.main.activity_list.*
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
import software.mdev.bookstracker.R
import software.mdev.bookstracker.data.db.BooksDatabase
import software.mdev.bookstracker.data.repositories.BooksRepository
@@ -29,7 +35,7 @@ class ListActivity : AppCompatActivity() {
setAppTheme()
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_list)
-
+ checkForAppUpdate(this)
bottomNavigationView.setupWithNavController(booksNavHostFragment.findNavController())
booksNavHostFragment.findNavController()
@@ -68,4 +74,18 @@ class ListActivity : AppCompatActivity() {
}
}
+ fun checkForAppUpdate(context: Context) = CoroutineScope(Dispatchers.Main).launch {
+ var appUpdater = AppUpdater(context)
+ appUpdater
+ .setTitleOnUpdateAvailable(getString(R.string.setTitleOnUpdateAvailable))
+ .setContentOnUpdateAvailable(getString(R.string.setContentOnUpdateAvailable))
+ .setButtonUpdate(getString(R.string.setButtonUpdate))
+ .setButtonDismiss(getString(R.string.setButtonDismiss))
+ .setButtonDoNotShowAgain(getString(R.string.setButtonDoNotShowAgain))
+ .setUpdateFrom(UpdateFrom.GITHUB)
+ .setGitHubUserAndRepo(Constants.GITHUB_USER, Constants.GITHUB_REPO)
+ .setDisplay(Display.DIALOG)
+ .showAppUpdated(false)
+ .start()
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/software/mdev/bookstracker/ui/bookslist/fragments/InProgressFragment.kt b/app/src/main/java/software/mdev/bookstracker/ui/bookslist/fragments/InProgressFragment.kt
index b1ed0e7c8..4e42da96a 100644
--- a/app/src/main/java/software/mdev/bookstracker/ui/bookslist/fragments/InProgressFragment.kt
+++ b/app/src/main/java/software/mdev/bookstracker/ui/bookslist/fragments/InProgressFragment.kt
@@ -37,6 +37,8 @@ import software.mdev.bookstracker.other.Constants.SERIALIZABLE_BUNDLE_BOOK
import software.mdev.bookstracker.other.Constants.SHARED_PREFERENCES_NAME
import software.mdev.bookstracker.other.Constants.SORT_ORDER_AUTHOR_ASC
import software.mdev.bookstracker.other.Constants.SORT_ORDER_AUTHOR_DESC
+import software.mdev.bookstracker.other.Constants.SORT_ORDER_DATE_ASC
+import software.mdev.bookstracker.other.Constants.SORT_ORDER_DATE_DESC
import software.mdev.bookstracker.other.Constants.SORT_ORDER_PAGES_ASC
import software.mdev.bookstracker.other.Constants.SORT_ORDER_PAGES_DESC
import software.mdev.bookstracker.other.Constants.SORT_ORDER_RATING_ASC
@@ -130,6 +132,7 @@ class InProgressFragment : Fragment(R.layout.fragment_in_progress) {
bookAdapter.setOnBookClickListener {
etSearch.setText(EMPTY_STRING)
+ fabAddBook.visibility = View.GONE
val bundle = Bundle().apply {
putSerializable(SERIALIZABLE_BUNDLE_BOOK, it)
}
@@ -236,6 +239,8 @@ class InProgressFragment : Fragment(R.layout.fragment_in_progress) {
SORT_ORDER_RATING_ASC -> viewModel.getSortedBooksByRatingAsc(currentFragment).observe(viewLifecycleOwner, Observer { some_books -> bookAdapter.differ.submitList(some_books)})
SORT_ORDER_PAGES_DESC -> viewModel.getSortedBooksByPagesDesc(currentFragment).observe(viewLifecycleOwner, Observer { some_books -> bookAdapter.differ.submitList(some_books)})
SORT_ORDER_PAGES_ASC -> viewModel.getSortedBooksByPagesAsc(currentFragment).observe(viewLifecycleOwner, Observer { some_books -> bookAdapter.differ.submitList(some_books)})
+ SORT_ORDER_DATE_DESC -> viewModel.getSortedBooksByDateDesc(currentFragment).observe(viewLifecycleOwner, Observer { some_books -> bookAdapter.differ.submitList(some_books)})
+ SORT_ORDER_DATE_ASC -> viewModel.getSortedBooksByDateAsc(currentFragment).observe(viewLifecycleOwner, Observer { some_books -> bookAdapter.differ.submitList(some_books)})
}
}
}
\ No newline at end of file
diff --git a/app/src/main/java/software/mdev/bookstracker/ui/bookslist/fragments/SettingsFragment.kt b/app/src/main/java/software/mdev/bookstracker/ui/bookslist/fragments/SettingsFragment.kt
index e384af692..4d792dfe8 100644
--- a/app/src/main/java/software/mdev/bookstracker/ui/bookslist/fragments/SettingsFragment.kt
+++ b/app/src/main/java/software/mdev/bookstracker/ui/bookslist/fragments/SettingsFragment.kt
@@ -1,15 +1,25 @@
package software.mdev.bookstracker.ui.bookslist.fragments
import android.app.Activity
+import android.content.Context
import android.content.SharedPreferences
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
import android.os.Bundle
import android.widget.Toast
import androidx.fragment.app.FragmentActivity
import androidx.navigation.fragment.findNavController
+import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceManager
+import com.github.javiersantos.appupdater.AppUpdater
+import com.github.javiersantos.appupdater.enums.Display
+import com.github.javiersantos.appupdater.enums.UpdateFrom
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
import software.mdev.bookstracker.R
+import software.mdev.bookstracker.other.Constants
+import software.mdev.bookstracker.other.Constants.KEY_CHECK_FOR_UPDATES
import software.mdev.bookstracker.other.Constants.SHARED_PREFERENCES_KEY_ACCENT
import software.mdev.bookstracker.other.Constants.SHARED_PREFERENCES_KEY_RECOMMENDATIONS
import software.mdev.bookstracker.other.Constants.SHARED_PREFERENCES_REFRESHED
@@ -24,6 +34,15 @@ class SettingsFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeLis
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.preferences, rootKey)
viewModel = (activity as ListActivity).booksViewModel
+
+ var preferenceCheckForUpdates = findPreference(KEY_CHECK_FOR_UPDATES)
+
+ if (preferenceCheckForUpdates != null) {
+ preferenceCheckForUpdates.onPreferenceClickListener = Preference.OnPreferenceClickListener {
+ context?.let { it1 -> checkForAppUpdate(it1) }
+ true
+ }
+ }
}
override fun onResume() {
@@ -57,4 +76,21 @@ class SettingsFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeLis
findNavController().navigate(R.id.readFragment, null)
(activity as FragmentActivity).recreate()
}
+
+ fun checkForAppUpdate(context: Context) = CoroutineScope(Dispatchers.Main).launch {
+ var appUpdater = AppUpdater(context)
+ appUpdater
+ .setTitleOnUpdateAvailable(getString(R.string.setTitleOnUpdateAvailable))
+ .setContentOnUpdateAvailable(getString(R.string.setContentOnUpdateAvailable))
+ .setButtonUpdate(getString(R.string.setButtonUpdate))
+ .setButtonDismiss(getString(R.string.setButtonDismiss))
+ .setButtonDoNotShowAgain(getString(R.string.setButtonDoNotShowAgain))
+ .setContentOnUpdateNotAvailable(getString(R.string.setContentOnUpdateNotAvailable))
+ .setTitleOnUpdateNotAvailable(getString(R.string.setTitleOnUpdateNotAvailable))
+ .setUpdateFrom(UpdateFrom.GITHUB)
+ .setGitHubUserAndRepo(Constants.GITHUB_USER, Constants.GITHUB_REPO)
+ .setDisplay(Display.DIALOG)
+ .showAppUpdated(true)
+ .start()
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/software/mdev/bookstracker/ui/bookslist/fragments/ToReadFragment.kt b/app/src/main/java/software/mdev/bookstracker/ui/bookslist/fragments/ToReadFragment.kt
index c9fa03fb4..4f4065e46 100644
--- a/app/src/main/java/software/mdev/bookstracker/ui/bookslist/fragments/ToReadFragment.kt
+++ b/app/src/main/java/software/mdev/bookstracker/ui/bookslist/fragments/ToReadFragment.kt
@@ -37,6 +37,8 @@ import software.mdev.bookstracker.other.Constants.SERIALIZABLE_BUNDLE_BOOK
import software.mdev.bookstracker.other.Constants.SHARED_PREFERENCES_NAME
import software.mdev.bookstracker.other.Constants.SORT_ORDER_AUTHOR_ASC
import software.mdev.bookstracker.other.Constants.SORT_ORDER_AUTHOR_DESC
+import software.mdev.bookstracker.other.Constants.SORT_ORDER_DATE_ASC
+import software.mdev.bookstracker.other.Constants.SORT_ORDER_DATE_DESC
import software.mdev.bookstracker.other.Constants.SORT_ORDER_PAGES_ASC
import software.mdev.bookstracker.other.Constants.SORT_ORDER_PAGES_DESC
import software.mdev.bookstracker.other.Constants.SORT_ORDER_RATING_ASC
@@ -130,6 +132,7 @@ class ToReadFragment : Fragment(R.layout.fragment_to_read) {
bookAdapter.setOnBookClickListener {
etSearch.setText(EMPTY_STRING)
+ fabAddBook.visibility = View.GONE
val bundle = Bundle().apply {
putSerializable(SERIALIZABLE_BUNDLE_BOOK, it)
}
@@ -236,6 +239,8 @@ class ToReadFragment : Fragment(R.layout.fragment_to_read) {
SORT_ORDER_RATING_ASC -> viewModel.getSortedBooksByRatingAsc(currentFragment).observe(viewLifecycleOwner, Observer { some_books -> bookAdapter.differ.submitList(some_books)})
SORT_ORDER_PAGES_DESC -> viewModel.getSortedBooksByPagesDesc(currentFragment).observe(viewLifecycleOwner, Observer { some_books -> bookAdapter.differ.submitList(some_books)})
SORT_ORDER_PAGES_ASC -> viewModel.getSortedBooksByPagesAsc(currentFragment).observe(viewLifecycleOwner, Observer { some_books -> bookAdapter.differ.submitList(some_books)})
+ SORT_ORDER_DATE_DESC -> viewModel.getSortedBooksByDateDesc(currentFragment).observe(viewLifecycleOwner, Observer { some_books -> bookAdapter.differ.submitList(some_books)})
+ SORT_ORDER_DATE_ASC -> viewModel.getSortedBooksByDateAsc(currentFragment).observe(viewLifecycleOwner, Observer { some_books -> bookAdapter.differ.submitList(some_books)})
}
}
}
\ No newline at end of file
diff --git a/app/src/main/res/values-pl-rPL/strings.xml b/app/src/main/res/values-pl-rPL/strings.xml
index 1a4481c10..d426eeb86 100644
--- a/app/src/main/res/values-pl-rPL/strings.xml
+++ b/app/src/main/res/values-pl-rPL/strings.xml
@@ -97,4 +97,11 @@
Ustaw
Nie ustawiono
Data
+ Aktualizacja!
+ "Nowsza wersja aplikacji Books Tracker jest dostępna.\n\nKliknij \"aktualizuj\", żeby przejść na stronę pobierania."
+ Aktualizuj
+ Później
+ Ignoruj
+ Masz zainstalowaną najnowszą wersję aplikacji Books Tracker!
+ Brak dostępnych aktualizacji
\ 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 96761eeba..60f3d773d 100644
--- a/app/src/main/res/values-pl/strings.xml
+++ b/app/src/main/res/values-pl/strings.xml
@@ -97,4 +97,11 @@
Ustaw
Nie ustawiono
Data
+ Aktualizacja!
+ "Nowsza wersja aplikacji Books Tracker jest dostępna.\n\nKliknij \"aktualizuj\", żeby przejść na stronę pobierania."
+ Aktualizuj
+ Później
+ Ignoruj
+ Masz zainstalowaną najnowszą wersję aplikacji Books Tracker!
+ Brak dostępnych aktualizacji
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index ee4f84ca8..5c4267d35 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -56,8 +56,7 @@
booktitle
bookauthor
booksearch
-
-nomn v1.2.0
+ v1.2.1
Not yet implemented
Dismiss
Book deleted
@@ -123,5 +122,12 @@ nomn v1.2.0
Date
101 pages
13 Jun 2021
+ New update!
+ "Newer version of the Books Tracker app is available.\n\nClick \"update\" to go to the downloading page."
+ Update
+ Dismiss
+ Ignore
+ You\'ve got the latest version available of Books Tracker app!
+ No updates available
\ No newline at end of file
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml
index 735e6bfdf..12429d967 100644
--- a/app/src/main/res/xml/preferences.xml
+++ b/app/src/main/res/xml/preferences.xml
@@ -43,6 +43,7 @@
diff --git a/build.gradle b/build.gradle
index 705e5d667..b48821d9e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -20,6 +20,9 @@ allprojects {
repositories {
google()
jcenter()
+ maven {
+ url "https://jitpack.io"
+ }
}
}