Skip to content

Commit 891b2cf

Browse files
authored
Merge pull request #70 from JLindemann42/development
Development
2 parents b937dcf + a5d8356 commit 891b2cf

21 files changed

Lines changed: 445 additions & 54 deletions

.kotlin/sessions/kotlin-compiler-8074986006442862257.salive

Whitespace-only changes.

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ android {
2121
applicationId "com.jlindemann.science"
2222
minSdkVersion 24
2323
targetSdkVersion 36
24-
versionCode 144
25-
versionName "4.0.0m"
24+
versionCode 150
25+
versionName "4.0.1m"
2626
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2727
}
2828
buildTypes {

app/release/app-release.aab

1.63 KB
Binary file not shown.

app/src/main/assets/astatine.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"description": "Astatine is a chemical element with the symbol At and atomic number 85. It is the rarest naturally occurring element in the Earth's crust, occurring only as the decay product of various heavier elements. All of astatine's isotopes are short-lived; the most stable is astatine-210, with a half-life of 8.1 hours. A sample of the pure element has never been assembled, because any macroscopic specimen would be immediately vaporized by the heat of its own radioactivity.",
77
"element": "Astatine",
88
"short": "At",
9-
"element_year": "Dale R. Corson",
10-
"element_discovered_name": "1940",
9+
"element_year": "1940",
10+
"element_discovered_name": "Dale R. Corson",
1111
"element_group": "Halogens",
1212
"element_appearance": "unknown, probably metallic",
1313
"element_electrons": "85",

app/src/main/assets/francium.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"description": "Francium is a chemical element with the symbol Fr and atomic number 87. Prior to its discovery, it was referred to as eka-caesium. It is extremely radioactive; its most stable isotope, francium-223 (originally called actinium K after the natural decay chain it appears in), has a half-life of only 22 minutes. It is the second-most electropositive element, behind only caesium, and is the second rarest naturally occurring element (after astatine). The isotopes of francium decay quickly into astatine, radium, and radon. The electronic structure of a francium atom is [Rn] 7s^1, and so the element is classed as an alkali metal.",
77
"element": "Francium",
88
"short": "Fr",
9-
"element_year": "Marguerite Perey",
10-
"element_discovered_name": "1939",
9+
"element_year": "1939",
10+
"element_discovered_name": "Marguerite Perey",
1111
"element_group": "Alkali metals",
1212
"element_appearance": "---",
1313
"element_electrons": "87",

app/src/main/java/com/jlindemann/science/activities/BaseActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ abstract class BaseActivity : AppCompatActivity(), View.OnApplyWindowInsetsListe
3030

3131
override fun onResume() {
3232
super.onResume()
33-
//checkAchievements()
33+
checkAchievements()
3434
}
3535

3636
override fun onStart() {

app/src/main/java/com/jlindemann/science/activities/MainActivity.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,23 @@ class MainActivity : TableExtension(), ElementAdapter.OnElementClickListener2 {
521521
findViewById<FloatingActionButton>(R.id.pro_fab).visibility = View.GONE
522522
}
523523

524+
//For updating when user purschases PRO Version in ProActivity
525+
private fun setProFabVisibilityGoneIfProValue100() {
526+
val proPref = ProVersion(this)
527+
val value = proPref.getValue()
528+
val proFab = findViewById<View>(R.id.pro_fab)
529+
if (value == 100) {
530+
proFab?.visibility = View.GONE
531+
} else {
532+
proFab?.visibility = View.VISIBLE
533+
}
534+
}
535+
536+
override fun onResume() {
537+
super.onResume()
538+
setProFabVisibilityGoneIfProValue100()
539+
}
540+
524541
override fun onApplySystemInsets(top: Int, bottom: Int, left: Int, right: Int) {
525542
findViewById<LinearLayout>(R.id.navLin).setPadding(left, 0, right, 0)
526543

app/src/main/java/com/jlindemann/science/activities/UserActivity.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import com.jlindemann.science.model.AchievementModel
2929
import com.jlindemann.science.model.ConstantsModel
3030
import com.jlindemann.science.model.Statistics
3131
import com.jlindemann.science.model.StatisticsModel
32+
import com.jlindemann.science.preferences.ProPlusVersion
3233
import com.jlindemann.science.preferences.ProVersion
3334
import com.jlindemann.science.preferences.ThemePreference
3435

@@ -65,13 +66,18 @@ class UserActivity : BaseActivity(), AchievementAdapter.OnAchievementClickListen
6566
shareSetup()
6667

6768
val proPref = ProVersion(this).getValue()
69+
val proPlusPref = ProPlusVersion(this).getValue()
6870
// Update depending on PRO or Not:
6971
if (proPref == 1) {
7072
findViewById<TextView>(R.id.pro_badge).text = "NON-PRO"
7173
}
7274
if (proPref == 100) {
7375
findViewById<TextView>(R.id.pro_badge).text = "PRO-USER"
7476
}
77+
if (proPlusPref == 100) {
78+
findViewById<TextView>(R.id.pro_badge).text = "PRO+-USER"
79+
80+
}
7581

7682
val sharedPref = getSharedPreferences("UserActivityPrefs", Context.MODE_PRIVATE)
7783
val userTitle = sharedPref.getString("user_title", "User Page")

app/src/main/java/com/jlindemann/science/activities/settings/ProActivity.kt

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import kotlinx.coroutines.Dispatchers
2020
import kotlinx.coroutines.launch
2121
import kotlinx.coroutines.withContext
2222
import org.json.JSONObject
23+
import java.util.logging.Handler
2324

2425
class ProActivity : BaseActivity(), BillingClientStateListener {
2526

@@ -84,6 +85,8 @@ class ProActivity : BaseActivity(), BillingClientStateListener {
8485
updateProOptionsUI()
8586
updatePurchaseCardsUI()
8687
}
88+
updateProOptionsUI()
89+
updatePurchaseCardsUI()
8790
}
8891
}
8992
}
@@ -224,38 +227,50 @@ class ProActivity : BaseActivity(), BillingClientStateListener {
224227
withContext(Dispatchers.IO) {
225228
billingClient?.acknowledgePurchase(params) { result ->
226229
if (result.responseCode == BillingClient.BillingResponseCode.OK) {
227-
ToastUtil.showToast(this@ProActivity, "Purchase successful!")
228-
if (productId == PRO_VERSION_ID) {
229-
ownsProVersion = true
230-
proPref.setValue(100)
231-
proPlusPref.setValue(1)
232-
}
233-
if (productId == PRO_PLUS_VERSION_ID || productId == PRO_PLUS_UPGRADE_ID) {
234-
ownsProPlusVersion = true
235-
proPref.setValue(100)
236-
proPlusPref.setValue(100)
230+
lifecycleScope.launch(Dispatchers.Main) {
231+
Toast.makeText(this@ProActivity, "Purchase complete!", Toast.LENGTH_SHORT).show()
232+
if (productId == PRO_VERSION_ID) {
233+
ownsProVersion = true
234+
proPref.setValue(100)
235+
proPlusPref.setValue(1)
236+
android.os.Handler().postDelayed({
237+
updateProOptionsUI()
238+
updatePurchaseCardsUI() }, 5000)
239+
}
240+
if (productId == PRO_PLUS_VERSION_ID || productId == PRO_PLUS_UPGRADE_ID) {
241+
ownsProPlusVersion = true
242+
proPref.setValue(100)
243+
proPlusPref.setValue(100)
244+
android.os.Handler().postDelayed({
245+
updateProOptionsUI()
246+
updatePurchaseCardsUI() }, 5000)
247+
}
248+
updateProOptionsUI()
249+
updatePurchaseCardsUI()
237250
}
238-
updateProOptionsUI()
239-
updatePurchaseCardsUI()
240251
}
241252
}
242253
}
243254
} else {
244-
if (productId == PRO_VERSION_ID) {
245-
ownsProVersion = true
246-
proPref.setValue(100)
247-
proPlusPref.setValue(1)
248-
}
249-
if (productId == PRO_PLUS_VERSION_ID || productId == PRO_PLUS_UPGRADE_ID) {
250-
ownsProPlusVersion = true
251-
proPref.setValue(100)
252-
proPlusPref.setValue(100)
255+
lifecycleScope.launch(Dispatchers.Main) {
256+
Toast.makeText(this@ProActivity, "Purchase complete!", Toast.LENGTH_SHORT).show()
257+
if (productId == PRO_VERSION_ID) {
258+
ownsProVersion = true
259+
proPref.setValue(100)
260+
proPlusPref.setValue(1)
261+
}
262+
if (productId == PRO_PLUS_VERSION_ID || productId == PRO_PLUS_UPGRADE_ID) {
263+
ownsProPlusVersion = true
264+
proPref.setValue(100)
265+
proPlusPref.setValue(100)
266+
}
267+
updateProOptionsUI()
268+
updatePurchaseCardsUI()
253269
}
254-
updateProOptionsUI()
255-
updatePurchaseCardsUI()
256270
}
257271
}
258272

273+
259274
private fun getFormattedPrice(productDetails: ProductDetails?): String {
260275
val formattedPrice = productDetails?.oneTimePurchaseOfferDetails?.formattedPrice
261276
return formattedPrice ?: "Price not available"

app/src/main/java/com/jlindemann/science/activities/tools/FlashCardActivity.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ import android.os.Handler
2424
import android.os.Looper
2525
import android.view.WindowManager
2626
import android.widget.PopupWindow
27+
import androidx.appcompat.widget.AppCompatButton
28+
import com.jlindemann.science.activities.UserActivity
2729
import com.jlindemann.science.activities.settings.ProActivity
30+
import com.jlindemann.science.activities.settings.SubmitActivity
2831
import com.jlindemann.science.preferences.MostUsedToolPreference
2932
import com.jlindemann.science.preferences.ProPlusVersion
3033
import com.jlindemann.science.preferences.ProVersion
@@ -101,6 +104,11 @@ class FlashCardActivity : BaseActivity() {
101104
onBackPressed()
102105
}
103106

107+
findViewById<ImageButton>(R.id.achievements_btn).setOnClickListener {
108+
val intent = Intent(this, UserActivity::class.java)
109+
startActivity(intent)
110+
}
111+
104112
//Add value to most used:
105113
val mostUsedPreference = MostUsedToolPreference(this)
106114
val mostUsedPrefValue = mostUsedPreference.getValue()
@@ -139,12 +147,24 @@ class FlashCardActivity : BaseActivity() {
139147
}
140148
}
141149

150+
//For updating when user purschases PRO Version in ProActivity
151+
private fun setProFabVisibilityGoneIfProValue100() {
152+
val proPlusPref = ProPlusVersion(this)
153+
val value = proPlusPref.getValue()
154+
if (value == 100) {
155+
findViewById<FrameLayout>(R.id.pro_box).visibility = View.GONE
156+
} else {
157+
findViewById<FrameLayout>(R.id.pro_box).visibility = View.VISIBLE
158+
}
159+
}
160+
142161
override fun onResume() {
143162
super.onResume()
144163
updateLivesCount()
145164
updateLivesInfo()
146165
updateCategoryBoxes()
147166
updateXpAndLevelStats()
167+
setProFabVisibilityGoneIfProValue100()
148168
val gameFinished = intent.getBooleanExtra("game_finished", false)
149169
val results = intent.getParcelableArrayListExtra<GameResultItem>("game_results")
150170
val totalQuestions = intent.getIntExtra("total_questions", results?.size ?: 0)

0 commit comments

Comments
 (0)