aboutsummaryrefslogtreecommitdiff
path: root/androidApp/src/main/java/mx
diff options
context:
space:
mode:
Diffstat (limited to 'androidApp/src/main/java/mx')
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/UserInformationActivity.kt31
1 files changed, 29 insertions, 2 deletions
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/UserInformationActivity.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/UserInformationActivity.kt
index da1c0d5..cda8072 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/UserInformationActivity.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/session/UserInformationActivity.kt
@@ -1,10 +1,14 @@
package mx.trackermap.TrackerMap.android.session
import android.content.Intent
+import android.content.pm.PackageManager
+import android.net.Uri
import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
+import androidx.core.app.NavUtils
+import mx.trackermap.TrackerMap.android.R
import mx.trackermap.TrackerMap.android.databinding.UserInformationActivityBinding
import mx.trackermap.TrackerMap.client.models.User
import org.koin.androidx.viewmodel.ext.android.viewModel
@@ -28,6 +32,16 @@ class UserInformationActivity : AppCompatActivity() {
setupEvents()
userInformationViewModel.fetchUserInfo()
+
+ // Show version number
+ val pm = applicationContext.packageManager
+ val pkgName = applicationContext.packageName
+ try {
+ val pkgInfo = pm.getPackageInfo(pkgName, 0)
+ binding.appVersion.text = pkgInfo.versionName
+ } catch (e: PackageManager.NameNotFoundException) {
+ e.printStackTrace()
+ }
}
private fun setupObservers() {
@@ -36,13 +50,20 @@ class UserInformationActivity : AppCompatActivity() {
UserInformationViewModel.InformationState.Loading -> setLoading(true)
UserInformationViewModel.InformationState.Failure -> failure()
is UserInformationViewModel.InformationState.Success -> display(userInformation.user)
- UserInformationViewModel.InformationState.Signout -> signout()
+ UserInformationViewModel.InformationState.Signout -> signOut()
}
}
}
private fun setupEvents() {
+ binding.backButton.setOnClickListener { onBackPressed() }
binding.signoutButton.setOnClickListener { userInformationViewModel.signout() }
+ binding.sourceCodeButton.setOnClickListener {
+ openURL(getString(R.string.app_source_code_url))
+ }
+ binding.websiteButton.setOnClickListener {
+ openURL(getString(R.string.app_website_url))
+ }
}
private fun setLoading(isLoading: Boolean) {
@@ -68,7 +89,13 @@ class UserInformationActivity : AppCompatActivity() {
}
}
- private fun signout() {
+ private fun openURL(url: String) {
+ val uri = Uri.parse(url)
+ val intent = Intent(Intent.ACTION_VIEW, uri)
+ startActivity(intent)
+ }
+
+ private fun signOut() {
val intent = Intent(applicationContext, LoginActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
startActivity(intent)