Create login activity

This commit is contained in:
Reimar 2025-04-23 12:42:22 +02:00
parent d9cc16e3d7
commit 9fd62f9565
Signed by: Reimar
GPG Key ID: 93549FA07F0AE268
8 changed files with 120 additions and 5 deletions

View File

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="FrameworkDetectionExcludesConfiguration">

View File

@ -30,6 +30,10 @@
<activity
android:name=".WelcomeActivity"
android:exported="false" />
<activity
android:name=".LoginActivity"
android:exported="false" />
</application>
</manifest>
</manifest>

View File

@ -0,0 +1,29 @@
package tech.mercantec.easyeat
import android.content.Intent
import android.os.Bundle
import android.widget.Button
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
class LoginActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)
findViewById<Button>(R.id.login).setOnClickListener {
// TODO authenticate
val intent = Intent(this, MainActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK // Prevent going back to login screen
startActivity(intent)
}
findViewById<Button>(R.id.back).setOnClickListener {
finish()
}
}
}

View File

@ -1,10 +1,10 @@
package tech.mercantec.easyeat
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
class SplashActivity : AppCompatActivity() {
class SplashActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

View File

@ -1,6 +1,8 @@
package tech.mercantec.easyeat
import android.content.Intent
import android.os.Bundle
import android.widget.Button
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
@ -13,5 +15,13 @@ class WelcomeActivity : AppCompatActivity() {
supportActionBar?.hide()
setContentView(R.layout.activity_welcome)
findViewById<Button>(R.id.login).setOnClickListener {
startActivity(Intent(this, LoginActivity::class.java))
}
findViewById<Button>(R.id.register).setOnClickListener {
startActivity(Intent(this, LoginActivity::class.java))
}
}
}
}

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingStart="30sp"
android:paddingEnd="30sp"
android:gravity="center">
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textAlignment="center"
android:textSize="24sp"
android:text="@string/login_heading"
/>
<TextView
android:layout_marginTop="50sp"
android:layout_marginLeft="2sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/email_label"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/email_hint"
android:autofillHints="emailAddress"
/>
<TextView
android:layout_marginTop="20sp"
android:layout_marginLeft="2sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/password_label"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/password_hint"
android:autofillHints="password"
android:inputType="textPassword"
/>
<Button
android:id="@+id/login"
android:layout_marginTop="20sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/login_label"
/>
<Button
android:id="@+id/back"
android:layout_marginTop="20sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/back_label"
style="@style/Widget.MaterialComponents.Button.TextButton"
/>
</LinearLayout>

View File

@ -24,6 +24,7 @@
/>
<Button
android:id="@+id/login"
android:layout_marginTop="80sp"
android:backgroundTint="@color/dark_gray"
android:layout_width="match_parent"
@ -32,6 +33,7 @@
/>
<Button
android:id="@+id/register"
android:layout_marginTop="10sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -6,5 +6,11 @@
<string name="title_notifications">Notifications</string>
<string name="welcome_heading">Welcome to <font color="#0099BA">EasyEat</font></string>
<string name="login_label">Login</string>
<string name="login_heading">Login to EasyEat</string>
<string name="register_label">Register</string>
<string name="email_label">Email</string>
<string name="email_hint">john@doe.com</string>
<string name="password_label">Password</string>
<string name="password_hint">&#8226;&#8226;&#8226;&#8226;&#8226;&#8226;&#8226;&#8226;</string>
<string name="back_label">Back</string>
</resources>