Fix problems and finish app

This commit is contained in:
wiecktobi 2020-06-04 18:45:10 +02:00
parent c304632d6e
commit 8e73cc6e2c
7 changed files with 52 additions and 40 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View File

@ -3,15 +3,16 @@ package de.hft.geotracker.activities
import android.Manifest import android.Manifest
import android.Manifest.permission.ACCESS_COARSE_LOCATION import android.Manifest.permission.ACCESS_COARSE_LOCATION
import android.Manifest.permission.ACCESS_FINE_LOCATION import android.Manifest.permission.ACCESS_FINE_LOCATION
import android.app.AlertDialog
import android.app.PendingIntent import android.app.PendingIntent
import android.content.Context import android.content.Context
import android.content.DialogInterface
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.os.Bundle import android.os.Bundle
import android.os.Looper import android.os.Looper
import android.view.View import android.view.View
import android.widget.* import android.widget.*
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import androidx.core.app.ActivityCompat.requestPermissions import androidx.core.app.ActivityCompat.requestPermissions
@ -114,7 +115,27 @@ class MainActivity : AppCompatActivity() {
actionButton = findViewById(R.id.button_start_stop) actionButton = findViewById(R.id.button_start_stop)
actionButton.setBackgroundColor(resources.getColor(R.color.colorPrimaryDark)) actionButton.setBackgroundColor(resources.getColor(R.color.colorPrimaryDark))
actionButton.setOnClickListener { actionButton.setOnClickListener {
if (running) {
val builder: AlertDialog.Builder = AlertDialog.Builder(this)
builder.setTitle(R.string.app_name)
builder.setMessage("Do you want to stop?")
builder.setIcon(R.drawable.ic_logo)
builder.setPositiveButton("Yes", object : DialogInterface.OnClickListener {
override fun onClick(dialog: DialogInterface, id: Int) {
callStartStop() callStartStop()
dialog.dismiss()
}
})
builder.setNegativeButton("No", object : DialogInterface.OnClickListener {
override fun onClick(dialog: DialogInterface, id: Int) {
dialog.dismiss()
}
})
val alert: AlertDialog = builder.create()
alert.show()
} else {
callStartStop()
}
} }
//Toolbar listener //Toolbar listener
@ -126,6 +147,9 @@ class MainActivity : AppCompatActivity() {
true true
} }
R.id.logout -> { R.id.logout -> {
if (running) {
callStartStop()
}
deleteFile("JWToken") deleteFile("JWToken")
startActivity(Intent(this, Login::class.java)) startActivity(Intent(this, Login::class.java))
println("Logout pressed") println("Logout pressed")
@ -159,7 +183,7 @@ class MainActivity : AppCompatActivity() {
, it.duration)) , it.duration))
} }
if (running) { if (running) {
// recordList.add(RecordEntry(workingSince!!, "PENDING", -1)) recordList.add(RecordEntry(workingSince!!, "PENDING", -1))
} }
adapter.data = recordList adapter.data = recordList
recView.layoutManager = layoutManager recView.layoutManager = layoutManager
@ -193,8 +217,6 @@ class MainActivity : AppCompatActivity() {
call.enqueue(object : Callback<ValuesTracking> { call.enqueue(object : Callback<ValuesTracking> {
override fun onResponse(call: Call<ValuesTracking>, response: Response<ValuesTracking>) { override fun onResponse(call: Call<ValuesTracking>, response: Response<ValuesTracking>) {
workingSince = response.body()?.startdate?.substring(11, 16) workingSince = response.body()?.startdate?.substring(11, 16)
latitude.text = workingSince
longitude.text = response.body()?.enddate
updateRecyclerView() updateRecyclerView()
println("Tracking event successful!") println("Tracking event successful!")
} }

View File

@ -3,6 +3,7 @@ package de.hft.geotracker.activities
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.widget.TextView import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import de.hft.geotracker.R import de.hft.geotracker.R
@ -18,7 +19,8 @@ class Register : AppCompatActivity() {
} }
private fun createAccount() { private fun createAccount() {
startActivity(Intent(this, MainActivity::class.java)) Toast.makeText(this@Register, "Not yet implemented!", Toast.LENGTH_LONG)
.show()
} }

View File

@ -1,6 +1,8 @@
package de.hft.geotracker.activities package de.hft.geotracker.activities
import android.os.Bundle import android.os.Bundle
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import de.hft.geotracker.R import de.hft.geotracker.R
import kotlinx.android.synthetic.main.activity_home.* import kotlinx.android.synthetic.main.activity_home.*
@ -13,6 +15,10 @@ class Settings : AppCompatActivity() {
my_toolbar.setNavigationOnClickListener { my_toolbar.setNavigationOnClickListener {
onBackPressed() onBackPressed()
} }
findViewById<TextView>(R.id.button_submit).setOnClickListener {
Toast.makeText(this@Settings, "Not yet implemented!", Toast.LENGTH_LONG)
.show()
}
} }
} }

View File

@ -140,7 +140,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin16" android:layout_marginStart="@dimen/margin16"
android:layout_marginEnd="@dimen/margin16" android:layout_marginEnd="@dimen/margin16"
android:layout_marginBottom="16dp"
android:colorControlNormal="@color/logo_blue" android:colorControlNormal="@color/logo_blue"
android:hint="Revenue" android:hint="Revenue"
android:textColorHint="@color/logo_white" android:textColorHint="@color/logo_white"
@ -148,11 +147,9 @@
app:boxBackgroundMode="outline" app:boxBackgroundMode="outline"
app:boxCornerRadiusTopEnd="0dp" app:boxCornerRadiusTopEnd="0dp"
app:boxCornerRadiusTopStart="0dp" app:boxCornerRadiusTopStart="0dp"
app:layout_constraintBottom_toTopOf="@+id/latitude"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/display_description_layout" app:layout_constraintTop_toBottomOf="@+id/display_description_layout"
app:layout_constraintVertical_bias="0.0"
app:layout_constraintVertical_chainStyle="packed"> app:layout_constraintVertical_chainStyle="packed">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
@ -169,46 +166,30 @@
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="@+id/latitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:text="dummy"
android:textAppearance="@style/text_style"
android:textColor="@color/logo_white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/display_revenue_layout" />
<TextView
android:id="@+id/longitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:text="dummy"
android:textAppearance="@style/text_style"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/latitude" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/records_list" android:id="@+id/records_list"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginTop="16dp" android:layout_marginTop="8dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toTopOf="@+id/button_start_stop" app:layout_constraintBottom_toTopOf="@+id/button_start_stop"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/longitude" /> app:layout_constraintTop_toBottomOf="@+id/text_today" />
<TextView
android:id="@+id/text_today"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="@string/today_records"
android:textAppearance="@style/text_style"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/display_revenue_layout" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -30,7 +30,7 @@
android:layout_height="match_parent"> android:layout_height="match_parent">
<Button <Button
android:id="@+id/button" android:id="@+id/button_submit"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"

View File

@ -39,4 +39,5 @@
<string name="logout">Logout</string> <string name="logout">Logout</string>
<string name="hello">Hello</string> <string name="hello">Hello</string>
<string name="outside_place">Outside your working place</string> <string name="outside_place">Outside your working place</string>
<string name="today_records">Todays Records:</string>
</resources> </resources>