develop #10

Merged
s426229 merged 80 commits from develop into master 2021-01-27 18:32:19 +01:00
14 changed files with 964 additions and 724 deletions
Showing only changes of commit 08c27b3c3a - Show all commits

View File

@ -27,6 +27,8 @@ namespace Klient.Droid
public string savedName = "";
public string savedSurname = "";
public string savedEmail = "";
private string userId = "";
private string userToken = "";
protected override void OnCreate(Bundle savedInstanceState)
{
@ -43,36 +45,43 @@ namespace Klient.Droid
var Login = FindViewById<EditText>(Resource.Id.Login).Text;
SecureString Password = new NetworkCredential("", FindViewById<EditText>(Resource.Id.Password).Text).SecurePassword;
if (Login.Length < 3 || Login.Length > 12)
{
SetContentView(Resource.Layout.ekranLogowania);
}
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.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);
if (response.StatusCode == HttpStatusCode.OK)
{
savedLogin = Login;
var jsonString = await response.Content.ReadAsStringAsync();
dynamic jsonObject = JsonConvert.DeserializeObject(jsonString);
SetContentView(Resource.Layout.ekranPoLogowaniu);
savedName = jsonObject.user.name;
savedEmail = jsonObject.user.email;
savedSurname = jsonObject.user.surname;
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);
}
else
{
string msg = await response.Content.ReadAsStringAsync();
FindViewById<TextView>(Resource.Id.ErrorLogIn).Text = msg;
FindViewById<EditText>(Resource.Id.Password).Text = "";
}
}
}
@ -85,28 +94,61 @@ namespace Klient.Droid
var Login = FindViewById<EditText>(Resource.Id.NewLogin).Text;
SecureString Password = new NetworkCredential("", FindViewById<EditText>(Resource.Id.NewPassword).Text).SecurePassword;
SecureString Password2 = new NetworkCredential("", FindViewById<EditText>(Resource.Id.RepeatPassword).Text).SecurePassword;
if (new NetworkCredential("", Password).Password != new NetworkCredential("", Password2).Password)
if (Login.Length < 3 || Login.Length > 12)
{
SetContentView(Resource.Layout.ekranRejestracji);
FindViewById<TextView>(Resource.Id.ErrorRegister).Text = "Login musi mięć od 3 do 12 znaków!";
FindViewById<EditText>(Resource.Id.NewPassword).Text = "";
FindViewById<EditText>(Resource.Id.RepeatPassword).Text = "";
}
else if (new NetworkCredential("", Password).Password.Length < 8 || new NetworkCredential("", Password).Password.Length > 20)
{
FindViewById<TextView>(Resource.Id.ErrorRegister).Text = "Hasło musi mieć od 8 do 20 znaków!";
FindViewById<EditText>(Resource.Id.NewPassword).Text = "";
FindViewById<EditText>(Resource.Id.RepeatPassword).Text = "";
}
var values = new Dictionary<string, string>
else if (new NetworkCredential("", Password).Password != new NetworkCredential("", Password2).Password)
{
{ "email", Email },
{ "name", Name },
{ "surname", Surname },
{ "login", Login },
{ "password", new NetworkCredential("", Password).Password }
};
FindViewById<TextView>(Resource.Id.ErrorRegister).Text = "Hasła muszą być identyczne!";
FindViewById<EditText>(Resource.Id.NewPassword).Text = "";
FindViewById<EditText>(Resource.Id.RepeatPassword).Text = "";
}
else if(string.IsNullOrEmpty(FindViewById<EditText>(Resource.Id.NewLogin).Text) || string.IsNullOrEmpty(FindViewById<EditText>(Resource.Id.Email).Text) || string.IsNullOrEmpty(FindViewById<EditText>(Resource.Id.NewPassword).Text) || string.IsNullOrEmpty(FindViewById<EditText>(Resource.Id.RepeatPassword).Text) || string.IsNullOrEmpty(FindViewById<EditText>(Resource.Id.Name).Text) || string.IsNullOrEmpty(FindViewById<EditText>(Resource.Id.Surname).Text))
{
FindViewById<TextView>(Resource.Id.ErrorRegister).Text = "Wartości nie mogą być puste!";
FindViewById<EditText>(Resource.Id.NewPassword).Text = "";
FindViewById<EditText>(Resource.Id.RepeatPassword).Text = "";
}
var content = new FormUrlEncodedContent(values);
else
{
var values = new Dictionary<string, string>
{
{ "email", Email },
{ "name", Name },
{ "surname", Surname },
{ "login", Login },
{ "password", new NetworkCredential("", Password).Password }
};
var response = await client.PostAsync("http://10.0.2.2:5001/api/User/Register", content);
var content = new FormUrlEncodedContent(values);
var responseString = await response.Content.ReadAsStringAsync();
var response = await client.PostAsync("http://10.0.2.2:5001/api/User/Register", content);
if (response.StatusCode == HttpStatusCode.OK) SetContentView(Resource.Layout.ekranLogowania);
var responseString = await response.Content.ReadAsStringAsync();
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.Password).Text = "";
FindViewById<EditText>(Resource.Id.RepeatPassword).Text = "";
}
}
}
[Java.Interop.Export("HelpLoginScreen")]
@ -130,9 +172,13 @@ namespace Klient.Droid
[Java.Interop.Export("about")]
public void MainScreenAbout(View v)
{
SetContentView(Resource.Layout.ekranStartowy);
SetContentView(Resource.Layout.ekranInformacji);
}
[Java.Interop.Export("GoToMainScreenFromInformation")]
public void GoToMainScreenFromInformation(View v)
{
SetContentView(Resource.Layout.ekranStartowy);
}
[Java.Interop.Export("LoadFromFolder")]
public void LoadFile(View v)
{
@ -142,6 +188,16 @@ namespace Klient.Droid
StartActivityForResult(Android.Content.Intent.CreateChooser(Intent, "Select Picture"), PickImageId);
}
[Java.Interop.Export("GoToStart")]
public void GoToStart(View v)
{
SetContentView(Resource.Layout.ekranStartowy);
}
[Java.Interop.Export("GoToPoLogowaniu")]
public void GoToPoLogowaniu(View v)
{
SetContentView(Resource.Layout.ekranPoLogowaniu);
}
protected override void OnActivityResult(int requestCode, Result resultCode, Android.Content.Intent data)
{
@ -167,6 +223,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;
}
}
}
@ -174,6 +239,10 @@ namespace Klient.Droid
public void GoToProfile(View v)
{
SetContentView(Resource.Layout.ekranProfil);
FindViewById<EditText>(Resource.Id.ChangeName).Text = savedName;
FindViewById<EditText>(Resource.Id.ChangeSurname).Text = savedSurname;
FindViewById<EditText>(Resource.Id.ChangeEmail).Text = savedEmail;
FindViewById<TextView>(Resource.Id.ProfilPageLogin).Text = savedLogin;
}
[Java.Interop.Export("Save")]
@ -197,19 +266,30 @@ namespace Klient.Droid
}
var values = new Dictionary<string, string>
{
{ "id", userId },
{ "email", Email },
{ "name", Name },
{ "surname", Surname },
{ "login", savedLogin }
};
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync("http://10.0.2.2:5001/api/User/Update", content);
var responseString = await response.Content.ReadAsStringAsync();
if (response.StatusCode == HttpStatusCode.OK) FindViewById<TextView>(Resource.Id.NullValueProfile).Text = "Zapisano!";
if (response.StatusCode == HttpStatusCode.OK)
{
FindViewById<TextView>(Resource.Id.NullValueProfile).Text = "Zapisano!";
var jsonString = await response.Content.ReadAsStringAsync();
dynamic jsonObject = JsonConvert.DeserializeObject(jsonString);
savedLogin = jsonObject.login;
savedName = jsonObject.name;
savedEmail = jsonObject.email;
savedSurname = jsonObject.surname;
}
else
{
string msg = await response.Content.ReadAsStringAsync();
FindViewById<TextView>(Resource.Id.NullValueProfile).Text = msg;
}
}
}
}

View File

@ -48,6 +48,7 @@
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Mono.Android" />
<Reference Include="Mono.Android.Export" />
<Reference Include="System" />
@ -148,6 +149,11 @@
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResourceAnalysisConfig Include="Resources\layout\ekranInformacji.xml">
<SubType>Designer</SubType>
</AndroidResourceAnalysisConfig>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffbdd7f0"
android:paddingTop="30dp">
<TextView
android:text="Poszukiwacz"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="25px"
android:minHeight="25px"
android:id="@+id/title"
android:layout_centerHorizontal="true"
android:textSize="50dp"
android:textStyle="bold" />
<TextView
android:text="Poszukiwacz jest aplikacją mobilną pozwalającą na wyszukiwanie w Internece stron zawierających schematy i tutoriale na podstawie treści zadania. \n Jednocześnie pomaga w nauce, jaki i przyśpiesza proces dokonywania researchu danych. "
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView1"
android:layout_below="@id/title"
android:layout_centerInParent="true"
android:gravity="center_horizontal" />
<TextView
android:text="Poszukiwacz 2021"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/text1"
android:textColor="#ff000000"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<Button
android:text="Back"
android:layout_width="38.5dp"
android:layout_height="35.0dp"
android:id="@+id/backInformation"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#ff0b31c8"
android:textColor="#fffcfcfc"
android:gravity="center"
android:onClick="GoToMainScreenFromInformation" />
</RelativeLayout>

View File

@ -71,8 +71,28 @@
android:textColor="#fffcfcfc"
android:gravity="center"
android:onClick="HelpLoginScreen" />
<Button
android:text="Back"
android:layout_width="38.5dp"
android:layout_height="35.0dp"
android:id="@+id/backLogowanie"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#ff0b31c8"
android:textColor="#fffcfcfc"
android:gravity="center"
android:onClick="GoToStart"/>
<TextView
android:text="Poszukiwacz 2020"
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 2021"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -81,8 +101,4 @@
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>

View File

@ -21,7 +21,8 @@
android:layout_marginLeft="75dp"
android:onClick="LoadFromFolder" />
<TextView
android:text="Poszukiwacz 2020"
android:text="Poszukiwacz 2021"
android:text="Poszukiwacz 2021"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@ -27,5 +27,24 @@
android:layout_centerHorizontal="true"
android:layout_below="@id/SendPhoto"
android:textColor="#ffd60000" />
<Button
android:text="Back"
android:layout_width="38.5dp"
android:layout_height="35.0dp"
android:id="@+id/backZdjecie"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#ff0b31c8"
android:textColor="#fffcfcfc"
android:gravity="center"
android:onClick="GoToPoLogowaniu" />
<TextView
android:text="Poszukiwacz 2021"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/text1"
android:textColor="#ff000000"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>

View File

@ -7,11 +7,21 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffbdd7f0">
<TextView
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ProfilPageLogin"
android:layout_centerHorizontal="true"
android:textStyle="bold"
android:textSize="30dp" />
<android.support.design.widget.TextInputLayout
android:id="@+id/LayoutNameC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@id/ProfilPageLogin"
android:hint="Imie"
android:layout_alignParentLeft="true">
<android.support.design.widget.TextInputEditText
@ -83,5 +93,25 @@
android:layout_centerHorizontal="true"
android:layout_below="@id/Save"
android:textColor="#ffd60000" />
<TextView
android:text="Poszukiwacz 2021"
android:text="Poszukiwacz 2021"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/text3"
android:textColor="#ff000000"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<Button
android:text="Back"
android:layout_width="38.5dp"
android:layout_height="35.0dp"
android:id="@+id/backProfil"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#ff0b31c8"
android:textColor="#fffcfcfc"
android:gravity="center"
android:onClick="GoToPoLogowaniu" />
</RelativeLayout>

View File

@ -99,7 +99,6 @@
android:minWidth="25px"
android:minHeight="25px"
android:id="@+id/RepeatPassword"
android:hint="Powtórz hasło"
android:inputType="none|textPassword"
android:textColor="#ff000000" />
</android.support.design.widget.TextInputLayout>
@ -117,7 +116,6 @@
android:minWidth="25px"
android:minHeight="25px"
android:id="@+id/NewLogin"
android:hint="Login"
android:textColor="#ff000000"
android:layout_below="@+id/Surname" />
</android.support.design.widget.TextInputLayout>
@ -134,7 +132,7 @@
android:layout_centerHorizontal="true"
android:onClick="SignUp" />
<TextView
android:text="Poszukiwacz 2020"
android:text="Poszukiwacz 2021"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -142,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"
@ -153,5 +160,16 @@
android:textColor="#fffcfcfc"
android:gravity="center"
android:onClick="HelpRegisterScreen" />
<Button
android:text="Back"
android:layout_width="38.5dp"
android:layout_height="35.0dp"
android:id="@+id/backRejestracja"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#ff0b31c8"
android:textColor="#fffcfcfc"
android:gravity="center"
android:onClick="GoToStart" />
</RelativeLayout>

View File

@ -20,7 +20,7 @@
android:textSize="45dp"
android:layout_marginVertical="100dp" />
<TextView
android:text="Poszukiwacz 2020"
android:text="Poszukiwacz 2021"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -29,27 +29,16 @@
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<Button
android:text="?"
android:text="i"
android:layout_width="35.0dp"
android:layout_height="35.0dp"
android:id="@+id/help"
android:id="@+id/about"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="#ff0b31c8"
android:textColor="#fffcfcfc"
android:gravity="center"
android:onClick="HelpLoginScreen" />
<Button
android:text="I"
android:layout_width="35.0dp"
android:layout_height="35.0dp"
android:id="@+id/about"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#ff0b31c8"
android:textColor="#fffcfcfc"
android:gravity="center"
android:onClick="AboutMainScreen" />
<Button
android:text="Zaloguj"
android:layout_width="200.0dp"

View File

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Serwer.Infrastructure.Services;
using System;
@ -19,6 +20,7 @@ namespace Serwer.Api.Controllers
_imageService = imageService;
}
[Authorize]
[HttpPost("Process")]
public async Task<IActionResult> Process([FromForm]IFormFile image)
{

View File

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Serwer.Infrastructure.Services;
using System;
@ -18,6 +19,7 @@ namespace Serwer.Api.Controllers
_searchService = searchService;
}
[Authorize]
[HttpGet("{query}")]
public async Task<IActionResult> Search(string query)
{

View File

@ -69,7 +69,7 @@ namespace Serwer.Infrastructure.Services
throw new Exception("User login taken.");
}
var newUser = new User(user.Id, userModel.Email, userModel.Name, userModel.Surname, userModel.Login, userModel.Password);
var newUser = new User(user.Id, userModel.Email, userModel.Name, userModel.Surname, userModel.Login, user.Password);
await _userRepository.UpdateAsync(newUser);
newUser = await _userRepository.GetAsync(user.Id);
return _mapper.Map<UserDto>(newUser);

View File

@ -13,6 +13,5 @@ namespace Serwer.Infrastructure.ViewModels
public string Name { get; set; }
public string Surname { get; set; }
public string Login { get; set; }
public string Password { get; set; } = null;
}
}