Skip to content

Commit

Permalink
Added button to take user to play store
Browse files Browse the repository at this point in the history
  • Loading branch information
leahlud committed Oct 22, 2023
1 parent 05fbc51 commit 52b8f10
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package org.hackillinois.android.view

import android.animation.Animator
import android.content.DialogInterface
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.lifecycle.lifecycleScope
import kotlinx.android.synthetic.main.activity_splash_screen.*
import kotlinx.coroutines.async
Expand All @@ -22,6 +25,7 @@ class SplashScreenActivity : AppCompatActivity() {

private val countDownLatch = CountDownLatch(3)
private var needsToLogin = true
private var needsToUpdate = false

@Volatile private var hasClickedOrAnimFinish = false

Expand All @@ -44,6 +48,7 @@ class SplashScreenActivity : AppCompatActivity() {
val apiVersion = apiResponse.version
// check if user needs to update their app
if (androidVersion < apiVersion) {
needsToUpdate = true
showUpdatePopUp()
} else {
// app is up-to-date, so start animation and check if they need to log in
Expand Down Expand Up @@ -85,6 +90,13 @@ class SplashScreenActivity : AppCompatActivity() {
}
}

override fun onResume() {
super.onResume()
if (needsToUpdate) {
showUpdatePopUp()
}
}

private fun playAnimation() {
// make animation view visible and start playing it
splashAnimationView.visibility = View.VISIBLE
Expand Down Expand Up @@ -120,8 +132,14 @@ class SplashScreenActivity : AppCompatActivity() {
.setTitle(R.string.update_app_title)
.setMessage(R.string.update_app_message)
.setCancelable(false)
.setNegativeButton("Go to Play Store") { dialog, id ->
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=org.hackillinois.android.release&pcampaignid=web_share"))
startActivity(intent)
}
val alertDialog = builder.create()
val buttonColor = ContextCompat.getColor(this, R.color.seaSaltGreen)
alertDialog.show()
alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(buttonColor)
}

private fun launchMainActivity() {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<string name="login_fail_message">Failed to login. Please try again.</string>
<string name="login_fail_staff_message">You must have a valid staff account to log in.</string>
<string name="login_fail_attendee_message">You must RSVP to log in.</string>
<string name="update_app_title">Update your app</string>
<string name="update_app_title">Update Required</string>
<string name="update_app_message">To enjoy the latest features, please download the newest version of the HackIllinois app.</string>

<!-- Onboarding Fragment -->
Expand Down

0 comments on commit 52b8f10

Please sign in to comment.