release 0.1 #30

Manually merged
noemi3 merged 150 commits from release/0.1 into master 2020-01-18 14:59:02 +00:00
6 changed files with 155 additions and 0 deletions
Showing only changes of commit 6c3139b891 - Show all commits

View File

@ -32,4 +32,6 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation "com.squareup.retrofit2:retrofit:2.6.2"
implementation "com.squareup.retrofit2:converter-gson:2.6.2"
}

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="it.unisannio.ding.ids.wedroid.app">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
@ -9,6 +10,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".LoginActivity"></activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View File

@ -0,0 +1,75 @@
package it.unisannio.ding.ids.wedroid.app
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Toast
import it.unisannio.ding.ids.wedroid.wrapper.api.LoginService
import it.unisannio.ding.ids.wedroid.wrapper.entity.UserPrototype
import kotlinx.android.synthetic.main.activity_login.*
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
class LoginActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)
}
fun loginButton(v: View) {
if (username.text.isBlank() || istanceServer.text.isBlank() || password.text.isBlank()) {
Toast.makeText(this, "Riempire tutti i campi", Toast.LENGTH_LONG)
.show()
return
}
val userNameText = username.text.toString()
val passwordText = password.text.toString()
val service = Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create())
.baseUrl(istanceServer.text.toString())
.build()
.create(LoginService::class.java)
service.login(userNameText, passwordText).enqueue(object : Callback<UserPrototype> {
override fun onFailure(call: Call<UserPrototype>, t: Throwable) {
Toast.makeText(
applicationContext,
"Controlla la tua connessione internet",
Toast.LENGTH_LONG
).show()
}
override fun onResponse(call: Call<UserPrototype>, response: Response<UserPrototype>) {
if (response.code() != 200) {
Toast.makeText(
applicationContext,
"Credenziali non corrette",
Toast.LENGTH_LONG
).show()
return
}
Toast.makeText(
applicationContext,
"Login effettuato con successo",
Toast.LENGTH_LONG
).show()
}
})
}
}

View File

@ -1,7 +1,9 @@
package it.unisannio.ding.ids.wedroid.app
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import it.unisannio.ding.ids.wedroid.wrapper.api.BoardService
class MainActivity : AppCompatActivity() {
@ -10,5 +12,12 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val service : BoardService? = null
}
fun login(v: View) {
startActivity(
Intent(this, LoginActivity::class.java)
)
}
}

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".LoginActivity">
<EditText
android:id="@+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="100dp"
android:ems="10"
android:hint="UserName"
android:inputType="textPersonName"
app:layout_constraintBottom_toTopOf="@+id/password"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<EditText
android:id="@+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
app:layout_constraintBottom_toTopOf="@+id/button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="200dp"
android:onClick="loginButton"
android:text="LOGIN"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<EditText
android:id="@+id/istanceServer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:ems="10"
android:hint="Istance Server"
android:inputType="textPersonName"
app:layout_constraintBottom_toTopOf="@+id/username"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -7,6 +7,7 @@
tools:context=".MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
@ -15,4 +16,14 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="login"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView"
tools:layout_editor_absoluteX="168dp" />
</androidx.constraintlayout.widget.ConstraintLayout>