develop #10

Merged
s426229 merged 80 commits from develop into master 2021-01-27 18:32:19 +01:00
4 changed files with 753 additions and 688 deletions
Showing only changes of commit 6586dc6170 - Show all commits

View File

@ -47,34 +47,48 @@ namespace Klient.Droid
if (Login.Length < 3 || Login.Length > 12)
{
SetContentView(Resource.Layout.ekranLogowania);
FindViewById<TextView>(Resource.Id.ErrorLogIn).Text = "Hasło musi mieć od 3 do 12 znaków!";
FindViewById<EditText>(Resource.Id.Login).Text = "";
FindViewById<EditText>(Resource.Id.Password).Text = "";
}
if (string.IsNullOrWhiteSpace(new NetworkCredential("", Password).Password))
else if (string.IsNullOrWhiteSpace(new NetworkCredential("", Password).Password))
{
SetContentView(Resource.Layout.ekranLogowania);
FindViewById<TextView>(Resource.Id.ErrorLogIn).Text = "Hasło musi mieć od 3 do 12 znaków!";
FindViewById<EditText>(Resource.Id.Login).Text = "";
FindViewById<EditText>(Resource.Id.Password).Text = "";
}
var values = new Dictionary<string, string>
else
{
{ "login", Login },
{ "password", new NetworkCredential("", Password).Password }
};
var values = new Dictionary<string, string>
{
{ "login", Login },
{ "password", new NetworkCredential("", Password).Password }
};
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync("http://10.0.2.2:5001/api/User/SignIn", content);
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync("http://10.0.2.2:5001/api/User/SignIn", content);
if (response.StatusCode == HttpStatusCode.OK)
{
var jsonString = await response.Content.ReadAsStringAsync();
dynamic jsonObject = JsonConvert.DeserializeObject(jsonString);
SetContentView(Resource.Layout.ekranPoLogowaniu);
savedLogin = jsonObject.user.login;
savedName = jsonObject.user.name;
savedEmail = jsonObject.user.email;
savedSurname = jsonObject.user.surname;
userId = jsonObject.user.id;
userToken = jsonObject.jwt.token;
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", userToken);
if (response.StatusCode == HttpStatusCode.OK)
{
var jsonString = await response.Content.ReadAsStringAsync();
dynamic jsonObject = JsonConvert.DeserializeObject(jsonString);
SetContentView(Resource.Layout.ekranPoLogowaniu);
savedLogin = jsonObject.user.login;
savedName = jsonObject.user.name;
savedEmail = jsonObject.user.email;
savedSurname = jsonObject.user.surname;
userId = jsonObject.user.id;
userToken = jsonObject.jwt.token;
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", userToken);
}
else
{
string msg = await response.Content.ReadAsStringAsync();
FindViewById<TextView>(Resource.Id.ErrorLogIn).Text = msg;
FindViewById<EditText>(Resource.Id.Login).Text = "";
FindViewById<EditText>(Resource.Id.Password).Text = "";
}
}
}
@ -90,25 +104,38 @@ namespace Klient.Droid
if (new NetworkCredential("", Password).Password != new NetworkCredential("", Password2).Password)
{
SetContentView(Resource.Layout.ekranRejestracji);
FindViewById<TextView>(Resource.Id.ErrorRegister).Text = "Hasła muszą być identyczne!";
FindViewById<EditText>(Resource.Id.NewLogin).Text = "";
FindViewById<EditText>(Resource.Id.Password).Text = "";
FindViewById<EditText>(Resource.Id.RepeatPassword).Text = "";
}
var values = new Dictionary<string, string>
else
{
{ "email", Email },
{ "name", Name },
{ "surname", Surname },
{ "login", Login },
{ "password", new NetworkCredential("", Password).Password }
};
var values = new Dictionary<string, string>
{
{ "email", Email },
{ "name", Name },
{ "surname", Surname },
{ "login", Login },
{ "password", new NetworkCredential("", Password).Password }
};
var content = new FormUrlEncodedContent(values);
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync("http://10.0.2.2:5001/api/User/Register", content);
var response = await client.PostAsync("http://10.0.2.2:5001/api/User/Register", content);
var responseString = await response.Content.ReadAsStringAsync();
var responseString = await response.Content.ReadAsStringAsync();
if (response.StatusCode == HttpStatusCode.OK) SetContentView(Resource.Layout.ekranLogowania);
if (response.StatusCode == HttpStatusCode.OK) SetContentView(Resource.Layout.ekranLogowania);
else
{
string msg = await response.Content.ReadAsStringAsync();
FindViewById<TextView>(Resource.Id.ErrorRegister).Text = msg;
FindViewById<EditText>(Resource.Id.NewLogin).Text = "";
FindViewById<EditText>(Resource.Id.Password).Text = "";
FindViewById<EditText>(Resource.Id.RepeatPassword).Text = "";
}
}
}
[Java.Interop.Export("HelpLoginScreen")]
@ -179,6 +206,15 @@ namespace Klient.Droid
break;
}
var response = await client.PostAsync("http://10.0.2.2:5001/api/Image/Process", formDataContent);
if(response.StatusCode == HttpStatusCode.OK)
{
FindViewById<TextView>(Resource.Id.ErrorPhoto).Text = "Przesłano zdjęcie!";
}
else
{
string msg = await response.Content.ReadAsStringAsync();
FindViewById<TextView>(Resource.Id.ErrorPhoto).Text = msg;
}
}
}
@ -232,6 +268,11 @@ namespace Klient.Droid
savedEmail = jsonObject.email;
savedSurname = jsonObject.surname;
}
else
{
string msg = await response.Content.ReadAsStringAsync();
FindViewById<TextView>(Resource.Id.NullValueProfile).Text = msg;
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -82,6 +82,15 @@
android:textColor="#fffcfcfc"
android:gravity="center"
android:onClick="GoToStart"/>
<TextView
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ErrorLogIn"
android:textColor="#ffd60000"
android:layout_below="@id/In"
android:layout_centerHorizontal="true" />
<TextView
android:text="Poszukiwacz 2020"
android:textAppearance="?android:attr/textAppearanceSmall"

View File

@ -140,6 +140,15 @@
android:textColor="#ff000000"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<TextView
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ErrorRegister"
android:textColor="#ffd60000"
android:layout_below="@id/SignUp"
android:layout_centerHorizontal="true" />
<Button
android:text="?"
android:layout_width="35.0dp"