Logout functionality and small changes

This commit is contained in:
wiecktobi 2020-05-26 10:51:27 +02:00
parent 5908de5650
commit 6bd11577e0
3 changed files with 20 additions and 25 deletions

View File

@ -115,18 +115,16 @@ class MainActivity : AppCompatActivity() {
actionButton.setOnClickListener { actionButton.setOnClickListener {
callStartStop() callStartStop()
} }
my_toolbar.setNavigationOnClickListener {
altitude.text = "Pressed"
}
my_toolbar.setOnMenuItemClickListener { menuItem -> my_toolbar.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) { when (menuItem.itemId) {
R.id.settings -> { R.id.settings -> {
val intent = Intent(this, Settings::class.java) startActivity(Intent(this, Settings::class.java))
startActivity(intent)
println("Settings pressed") println("Settings pressed")
true true
} }
R.id.logout -> { R.id.logout -> {
startActivity(Intent(this, Login::class.java))
println("Logout pressed") println("Logout pressed")
true true
} }
@ -136,7 +134,6 @@ class MainActivity : AppCompatActivity() {
} }
private fun callStartStop() { private fun callStartStop() {
running = !running running = !running
println("StartStop pressed: $running") println("StartStop pressed: $running")
//ToDO call /track Endpoint //ToDO call /track Endpoint
@ -148,7 +145,7 @@ class MainActivity : AppCompatActivity() {
override fun onResponse(call: Call<ValuesUser>, response: Response<ValuesUser>) { override fun onResponse(call: Call<ValuesUser>, response: Response<ValuesUser>) {
if (response.isSuccessful) { if (response.isSuccessful) {
val firstname = response.body()?.firstname val firstname = response.body()?.firstname
lbl_username.text = firstname lbl_username.text = "Hello " + firstname
println("Body: " + firstname) println("Body: " + firstname)
} else { } else {
println("Response not successful: ${response.code()}") println("Response not successful: ${response.code()}")

View File

@ -9,6 +9,7 @@
tools:context=".activities.MainActivity"> tools:context=".activities.MainActivity">
<!-- TODO: Update blank fragment layout --> <!-- TODO: Update blank fragment layout -->
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout" android:id="@+id/appBarLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -29,29 +30,27 @@
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
<TextView
android:id="@+id/hello"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin16"
android:layout_marginTop="@dimen/margin16"
android:text="@string/hello"
android:textAppearance="@style/text_style"
android:textSize="24sp"
app:layout_constraintBottom_toTopOf="@+id/selected_acc"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appBarLayout"
app:layout_constraintVertical_bias="0.0" />
<TextView <TextView
android:id="@+id/lbl_username" android:id="@+id/lbl_username"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginStart="@dimen/margin16"
android:layout_marginTop="8dp"
android:layout_marginEnd="@dimen/margin16"
android:textAlignment="center"
android:textAppearance="@style/text_style" android:textAppearance="@style/text_style"
android:textSize="24sp" android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="@+id/hello" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/hello" /> app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appBarLayout" />
<View
android:id="@+id/divider2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="8dp"
android:background="@color/colorAccent"
app:layout_constraintTop_toBottomOf="@+id/lbl_username" />
<TextView <TextView
android:id="@+id/selected_acc" android:id="@+id/selected_acc"

View File

@ -19,7 +19,6 @@
style="@style/Widget.MaterialComponents.Toolbar.Primary" style="@style/Widget.MaterialComponents.Toolbar.Primary"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
app:menu="@menu/menu"
app:navigationIcon="@drawable/abc_vector_test" app:navigationIcon="@drawable/abc_vector_test"
app:title="@string/app_name" /> app:title="@string/app_name" />