diff --git a/app/build.gradle b/app/build.gradle
index 37a56b2..2574cf2 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -12,8 +12,8 @@ android {
defaultConfig {
def versionMajor = 1
- def versionMinor = 1
- def versionPatch = 2
+ def versionMinor = 2
+ def versionPatch = 0
applicationId "com.github.odaridavid.designpatterns"
minSdkVersion 21
diff --git a/app/src/main/java/com/github/odaridavid/designpatterns/RatingManager.kt b/app/src/main/java/com/github/odaridavid/designpatterns/RatingManager.kt
index 9bd39b4..14a8d7e 100644
--- a/app/src/main/java/com/github/odaridavid/designpatterns/RatingManager.kt
+++ b/app/src/main/java/com/github/odaridavid/designpatterns/RatingManager.kt
@@ -28,9 +28,8 @@ internal class RatingManager(private val sharedPreferences: SharedPreferences) :
override fun hasGivenRating(): Boolean = sharedPreferences.getBoolean(RATING_PREF_KEY, false)
override fun giveRating() {
- with(sharedPreferences.edit()) {
- putBoolean(RATING_PREF_KEY, true)
- apply()
+ setPreferenceValue { editor ->
+ editor.putBoolean(RATING_PREF_KEY, true)
}
}
@@ -41,8 +40,15 @@ internal class RatingManager(private val sharedPreferences: SharedPreferences) :
override fun updatePromptForRatingCounter() {
val counter = sharedPreferences.getInt(PROMPT_COUNTER_PREF_KEY, 0) + 1
+ setPreferenceValue { editor ->
+ editor.putInt(PROMPT_COUNTER_PREF_KEY, counter)
+ }
+ }
+
+
+ private fun setPreferenceValue(block: (SharedPreferences.Editor) -> Unit) {
with(sharedPreferences.edit()) {
- putInt(PROMPT_COUNTER_PREF_KEY, counter)
+ block(this)
apply()
}
}
diff --git a/app/src/main/java/com/github/odaridavid/designpatterns/ui/AboutActivity.kt b/app/src/main/java/com/github/odaridavid/designpatterns/ui/AboutActivity.kt
index f351bb9..4f1c3ca 100644
--- a/app/src/main/java/com/github/odaridavid/designpatterns/ui/AboutActivity.kt
+++ b/app/src/main/java/com/github/odaridavid/designpatterns/ui/AboutActivity.kt
@@ -56,6 +56,18 @@ internal class AboutActivity : BaseActivity() {
openBrowser(APP_REPO_URL)
true
}
+ R.id.action_share_app -> {
+ val sendIntent = Intent().apply {
+ action = Intent.ACTION_SEND
+ putExtra(
+ Intent.EXTRA_TEXT,
+ "Checkout Kotlin Design Patterns Samples\n\n https://play.google.com/store/apps/details?id=$packageName"
+ )
+ type = "text/plain"
+ }
+ startActivity(sendIntent)
+ true
+ }
else -> super.onOptionsItemSelected(item)
}
}
diff --git a/app/src/main/res/drawable/ic_share_24dp.xml b/app/src/main/res/drawable/ic_share_24dp.xml
new file mode 100644
index 0000000..885baed
--- /dev/null
+++ b/app/src/main/res/drawable/ic_share_24dp.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/menu/about_menu.xml b/app/src/main/res/menu/about_menu.xml
index 9ec5b17..3cc9481 100644
--- a/app/src/main/res/menu/about_menu.xml
+++ b/app/src/main/res/menu/about_menu.xml
@@ -17,5 +17,11 @@
android:id="@+id/action_open_source_code"
android:icon="@drawable/ic_github_24dp"
android:title="@string/menu_view_source_code"
- app:showAsAction="always" />
+ app:showAsAction="ifRoom" />
+
+
\ 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 99d6d43..7671aba 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -180,6 +180,7 @@
App Rating
Later
Rate
+ Share App
diff --git a/whatsnew/whatsnew-en-GB b/whatsnew/whatsnew-en-GB
index 5e10703..f444c2f 100644
--- a/whatsnew/whatsnew-en-GB
+++ b/whatsnew/whatsnew-en-GB
@@ -1 +1,2 @@
-- Enable theme settings icon changing on theme changes by the system.
\ No newline at end of file
+- Added prompt for user rating
+- Added share app action
\ No newline at end of file