aboutsummaryrefslogtreecommitdiff
path: root/androidApp/src/main/java
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-01-13 00:42:49 -0600
committerIván Ávalos <avalos@disroot.org>2022-01-13 00:42:49 -0600
commit537b1553b53f79e1b0ab437ddc00b4a1fe34daa7 (patch)
treeff2c9ef257cede8ed70c999d7033a7d60e70bc4d /androidApp/src/main/java
parent430e643ec7aefd7a2bb51bc4d6dfa6c71cac42cd (diff)
downloadetbsa-trackermap-mobile-537b1553b53f79e1b0ab437ddc00b4a1fe34daa7.tar.gz
etbsa-trackermap-mobile-537b1553b53f79e1b0ab437ddc00b4a1fe34daa7.tar.bz2
etbsa-trackermap-mobile-537b1553b53f79e1b0ab437ddc00b4a1fe34daa7.zip
Finished and redesigned UserInformationActivity and added About section
Diffstat (limited to 'androidApp/src/main/java')
-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)