Update input fields and buttons plus fix security gap at logout

This commit is contained in:
wiecktobi 2020-05-27 22:55:21 +02:00
parent 73187542cd
commit 1fbed97fb2
11 changed files with 69 additions and 45 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="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" 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

@ -40,7 +40,7 @@ dependencies {
implementation 'androidx.core:core-ktx:1.2.0' implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.2.0-alpha06' implementation 'com.google.android.material:material:1.1.0'
implementation "com.google.android.gms:play-services-location:17.0.0" implementation "com.google.android.gms:play-services-location:17.0.0"
implementation 'androidx.preference:preference:1.1.1' implementation 'androidx.preference:preference:1.1.1'
testImplementation 'junit:junit:4.13' testImplementation 'junit:junit:4.13'

View File

@ -19,6 +19,7 @@ import retrofit2.Callback
import retrofit2.Response import retrofit2.Response
import retrofit2.Retrofit import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory import retrofit2.converter.gson.GsonConverterFactory
import kotlinx.android.synthetic.main.activity_login.*
/** /**
* A simple [Fragment] subclass. * A simple [Fragment] subclass.
@ -70,8 +71,8 @@ class Login : AppCompatActivity() {
} }
private fun login() { private fun login() {
val name = findViewById<TextView>(R.id.setting_input_username).text.toString() val name = input_username.text.toString()
val pswd = findViewById<TextView>(R.id.input_password).text.toString() val pswd = input_password.text.toString()
val call = service.login(ValuesUserLogin(name, pswd)) val call = service.login(ValuesUserLogin(name, pswd))
call.enqueue(object : Callback<Void> { call.enqueue(object : Callback<Void> {

View File

@ -5,7 +5,6 @@ import android.app.PendingIntent
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.location.Location
import android.os.Bundle import android.os.Bundle
import android.os.Looper import android.os.Looper
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
@ -15,10 +14,6 @@ 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
import com.google.android.gms.location.* import com.google.android.gms.location.*
import com.google.android.gms.location.Geofence
import com.google.android.gms.location.GeofencingClient
import com.google.android.gms.location.GeofencingRequest
import com.google.android.gms.location.LocationServices
import de.hft.geotracker.GeofenceBroadcastReceiver import de.hft.geotracker.GeofenceBroadcastReceiver
import de.hft.geotracker.R import de.hft.geotracker.R
import de.hft.geotracker.retrofit.AuthenticationInterceptor import de.hft.geotracker.retrofit.AuthenticationInterceptor
@ -33,8 +28,6 @@ import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory import retrofit2.converter.gson.GsonConverterFactory
import java.io.BufferedReader import java.io.BufferedReader
import java.io.InputStreamReader import java.io.InputStreamReader
import java.lang.StringBuilder
import kotlin.properties.Delegates
class MainActivity : AppCompatActivity() { class MainActivity : AppCompatActivity() {
@ -150,6 +143,7 @@ class MainActivity : AppCompatActivity() {
true true
} }
R.id.logout -> { R.id.logout -> {
deleteFile("JWToken")
startActivity(Intent(this, Login::class.java)) startActivity(Intent(this, Login::class.java))
println("Logout pressed") println("Logout pressed")
true true

View File

@ -8,8 +8,6 @@
android:background="@color/background_grey" android:background="@color/background_grey"
tools:context=".activities.MainActivity"> tools:context=".activities.MainActivity">
<!-- 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"
@ -84,6 +82,7 @@
android:textOff="@string/stop" android:textOff="@string/stop"
android:textOn="@string/btn_start_text" android:textOn="@string/btn_start_text"
android:textStyle="bold" android:textStyle="bold"
app:cornerRadius="8dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent" />

View File

@ -22,70 +22,92 @@
app:title="@string/app_name" /> app:title="@string/app_name" />
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
<EditText <com.google.android.material.textfield.TextInputLayout
android:id="@+id/setting_input_username" android:id="@+id/input_username_layout"
style="@style/input_field" style="@style/LoginTextInputLayoutStyle"
android:layout_width="240dp" android:layout_width="240dp"
android:layout_height="42dp" android:layout_height="wrap_content"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
android:colorControlNormal="@color/logo_blue" android:colorControlNormal="@color/logo_blue"
android:ems="10"
android:hint="@string/username" android:hint="@string/username"
android:inputType="textPersonName" android:textColorHint="@color/logo_white"
android:textAlignment="center" app:boxBackgroundColor="@color/common_google_signin_btn_text_dark_disabled"
android:textColor="@color/logo_white" app:boxBackgroundMode="outline"
app:layout_constraintBottom_toTopOf="@+id/input_password" app:layout_constraintBottom_toTopOf="@+id/input_password_layout"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497" app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.49" app:layout_constraintVertical_bias="0.49"
app:layout_constraintVertical_chainStyle="packed" /> app:layout_constraintVertical_chainStyle="packed">
<EditText <com.google.android.material.textfield.TextInputEditText
android:id="@+id/input_password" android:id="@+id/input_username"
style="@style/input_field" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:textAppearance="@style/text_style"
android:textColor="@color/logo_white"
android:textColorHint="@color/logo_white" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/input_password_layout"
style="@style/LoginTextInputLayoutStyle"
android:layout_width="240dp" android:layout_width="240dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:layout_marginBottom="32dp" android:layout_marginBottom="32dp"
android:ems="10"
android:hint="@string/password" android:hint="@string/password"
android:inputType="textPassword" android:inputType="textPassword"
android:textAlignment="center" android:textColorHint="@color/logo_white"
app:boxBackgroundColor="@color/common_google_signin_btn_text_dark_disabled"
app:boxBackgroundMode="outline"
app:layout_constraintBottom_toTopOf="@+id/button_create_account" app:layout_constraintBottom_toTopOf="@+id/button_create_account"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/setting_input_username" app:layout_constraintTop_toBottomOf="@+id/input_username_layout"
app:layout_constraintVertical_bias="0.13" /> app:layout_constraintVertical_bias="0.13">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/input_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:textAppearance="@style/text_style"
android:textColor="@color/logo_white"
android:textColorHint="@color/logo_white" />
</com.google.android.material.textfield.TextInputLayout>
<Button <Button
android:id="@+id/button_create_account" android:id="@+id/button_create_account"
style="@style/Widget.AppCompat.Button" style="@style/Widget.MaterialComponents.Button"
android:layout_width="240dp" android:layout_width="240dp"
android:layout_height="wrap_content" android:layout_height="55dp"
android:layout_marginTop="32dp" android:layout_marginTop="32dp"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
android:background="@drawable/outlined_button_filled"
android:backgroundTint="@color/colorAccent" android:backgroundTint="@color/colorAccent"
android:text="@string/login" android:text="@string/login"
android:textAppearance="@style/text_style" android:textAppearance="@style/text_style"
android:textStyle="bold" android:textStyle="bold"
app:cornerRadius="8dp"
app:layout_constraintBottom_toTopOf="@+id/button_register" app:layout_constraintBottom_toTopOf="@+id/button_register"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.502" app:layout_constraintHorizontal_bias="0.502"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/input_password" /> app:layout_constraintTop_toBottomOf="@+id/input_password_layout" />
<Button <Button
android:id="@+id/button_register" android:id="@+id/button_register"
style="@style/Widget.MaterialComponents.Button"
android:layout_width="240dp" android:layout_width="240dp"
android:layout_height="wrap_content" android:layout_height="55dp"
android:background="@drawable/outlined_button" android:backgroundTint="@color/colorPrimaryDark"
android:text="@string/register" android:text="@string/register"
android:textAppearance="@style/text_style" android:textAppearance="@style/text_style"
android:textStyle="bold" android:textStyle="bold"
app:cornerRadius="8dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497" app:layout_constraintHorizontal_bias="0.497"

View File

@ -35,10 +35,10 @@
android:textAlignment="center" android:textAlignment="center"
app:layout_constraintBottom_toTopOf="@+id/button_create_account" app:layout_constraintBottom_toTopOf="@+id/button_create_account"
app:layout_constraintEnd_toEndOf="@+id/input_email_register" app:layout_constraintEnd_toEndOf="@+id/input_email_register"
app:layout_constraintTop_toBottomOf="@+id/input_password" /> app:layout_constraintTop_toBottomOf="@+id/input_password_layout" />
<EditText <EditText
android:id="@+id/input_password" android:id="@+id/input_password_layout"
style="@style/input_field" style="@style/input_field"
android:layout_width="240dp" android:layout_width="240dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -78,24 +78,26 @@
android:colorControlNormal="@color/logo_blue" android:colorControlNormal="@color/logo_blue"
android:ems="10" android:ems="10"
android:foregroundTint="@color/colorAccent" android:foregroundTint="@color/colorAccent"
android:hint="@string/username" android:hint="@string/choose_username"
android:inputType="textPersonName" android:inputType="textPersonName"
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/logo_white" android:textColor="@color/logo_white"
app:layout_constraintBottom_toTopOf="@+id/input_password" app:layout_constraintBottom_toTopOf="@+id/input_password_layout"
app:layout_constraintEnd_toEndOf="@+id/input_email_register" app:layout_constraintEnd_toEndOf="@+id/input_email_register"
app:layout_constraintTop_toBottomOf="@+id/input_email_register" /> app:layout_constraintTop_toBottomOf="@+id/input_email_register" />
<Button <Button
android:id="@+id/button_create_account" android:id="@+id/button_create_account"
style="@style/Widget.MaterialComponents.Button"
android:layout_width="240dp" android:layout_width="240dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin16" android:layout_marginTop="@dimen/margin16"
android:layout_marginBottom="175dp" android:layout_marginBottom="175dp"
android:background="@drawable/outlined_button_filled" android:backgroundTint="@color/logo_blue"
android:text="@string/create_account" android:text="@string/create_account"
android:textAppearance="@style/text_style" android:textAppearance="@style/text_style"
android:textStyle="bold" android:textStyle="bold"
app:cornerRadius="8dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/input_email_register" app:layout_constraintEnd_toEndOf="@+id/input_email_register"
app:layout_constraintTop_toBottomOf="@+id/input_password2" /> app:layout_constraintTop_toBottomOf="@+id/input_password2" />

View File

@ -68,7 +68,7 @@
android:background="@color/colorAccent" /> android:background="@color/colorAccent" />
<EditText <EditText
android:id="@+id/setting_input_username" android:id="@+id/input_username_layout"
style="@style/input_field" style="@style/input_field"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="42dp" android:layout_height="42dp"

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources xmlns:tools="http://schemas.android.com/tools">
<color name="colorPrimary">#272727</color> <color name="colorPrimary">#272727</color>
<color name="colorPrimaryDark">#272727</color> <color name="colorPrimaryDark">#272727</color>
<color name="colorAccent">#0096ff</color> <color name="colorAccent">#0096ff</color>
<color name="background_grey">#131313</color> <color name="background_grey">#131313</color>
<color name="logo_blue">#0096ff</color> <color name="logo_blue">#0096ff</color>
<color name="logo_white">#EBE7D9</color> <color name="logo_white">#EBE7D9</color>
<color name="mtrl_textinput_default_box_stroke_color" tools:override="true">@color/logo_white</color>
</resources> </resources>

View File

@ -9,7 +9,8 @@
<string name="pause">PAUSE</string> <string name="pause">PAUSE</string>
<string name="stop">STOP</string> <string name="stop">STOP</string>
<string name="username_email">Your Username or E-Mail</string> <string name="username_email">Your Username or E-Mail</string>
<string name="username">Choose a Username</string> <string name="username">Username</string>
<string name="choose_username">Choose a Username</string>
<string name="email">E-Mail</string> <string name="email">E-Mail</string>
<string name="password">Password</string> <string name="password">Password</string>
<string name="login">Login</string> <string name="login">Login</string>

View File

@ -20,5 +20,10 @@
<item name="android:fontFamily">@font/montserrat</item> <item name="android:fontFamily">@font/montserrat</item>
<item name="android:textSize">18sp</item> <item name="android:textSize">18sp</item>
</style> </style>
<style name="LoginTextInputLayoutStyle" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<item name="boxStrokeColor">@color/logo_blue</item>
<item name="boxStrokeWidth">2dp</item>
<item name="hintTextColor">@color/logo_white</item>
</style>
</resources> </resources>