diff --git a/app/.idea/compiler.xml b/app/.idea/compiler.xml index b86273d..b589d56 100644 --- a/app/.idea/compiler.xml +++ b/app/.idea/compiler.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/app/.idea/misc.xml b/app/.idea/misc.xml index 2731899..ec453bb 100644 --- a/app/.idea/misc.xml +++ b/app/.idea/misc.xml @@ -1,9 +1,10 @@ + - + diff --git a/app/app/build.gradle.kts b/app/app/build.gradle.kts index 160f3f0..b51531c 100644 --- a/app/app/build.gradle.kts +++ b/app/app/build.gradle.kts @@ -1,6 +1,9 @@ +import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties + plugins { alias(libs.plugins.android.application) alias(libs.plugins.kotlin.android) + id("org.jetbrains.kotlin.plugin.serialization") } android { @@ -15,6 +18,8 @@ android { versionName = "1.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + + buildConfigField("String", "API_BASE_URL", project.property("API_BASE_URL").toString()) } buildTypes { @@ -36,7 +41,6 @@ android { } dependencies { - implementation(libs.androidx.core.ktx) implementation(libs.androidx.appcompat) implementation(libs.material) @@ -48,7 +52,5 @@ dependencies { implementation(libs.navigation.fragment.ktx) implementation(libs.navigation.ui.ktx) implementation(libs.androidx.activity) - testImplementation(libs.junit) - androidTestImplementation(libs.androidx.junit) - androidTestImplementation(libs.androidx.espresso.core) + implementation(libs.kotlinx.serialization.json) } \ No newline at end of file diff --git a/app/app/gradle.properties b/app/app/gradle.properties new file mode 100644 index 0000000..7cf66d1 --- /dev/null +++ b/app/app/gradle.properties @@ -0,0 +1 @@ +API_BASE_URL="https://easyeat.mercantec.tech" diff --git a/app/app/src/main/AndroidManifest.xml b/app/app/src/main/AndroidManifest.xml index 830e77d..215816d 100644 --- a/app/app/src/main/AndroidManifest.xml +++ b/app/app/src/main/AndroidManifest.xml @@ -1,6 +1,7 @@ + (R.id.login).setOnClickListener { - // TODO authenticate + val email = findViewById(R.id.email).text.toString() + val password = findViewById(R.id.password).text.toString() - 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) + thread { + try { + login(email, password) + } catch (e: ApiRequestException) { + runOnUiThread { + Toast.makeText(this, e.message, Toast.LENGTH_LONG).show() + } + + return@thread + } + + 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