POS-32 Dodano ekran edycji profilu

This commit is contained in:
Wojciech Przybyła 2020-12-21 16:19:54 +01:00
parent a83d141ac2
commit 2ea2a4293f
5 changed files with 74 additions and 70 deletions

View File

@ -13,6 +13,7 @@ using System.Security;
using System.Net;
using System.Linq;
using System.IO;
using Newtonsoft.Json;
namespace Klient.Droid
{
@ -23,6 +24,9 @@ namespace Klient.Droid
private static readonly HttpClient client = new HttpClient();
public static Android.Content.Intent photo;
public string savedLogin = "";
public string savedName = "";
public string savedSurname = "";
public string savedEmail = "";
protected override void OnCreate(Bundle savedInstanceState)
{
@ -34,7 +38,7 @@ namespace Klient.Droid
}
[Java.Interop.Export("SignIn")]
async public void SignIn(View v)
async public void SignIn(Android.Views.View v)
{
var Login = FindViewById<EditText>(Resource.Id.Login).Text;
SecureString Password = new NetworkCredential("", FindViewById<EditText>(Resource.Id.Password).Text).SecurePassword;
@ -66,12 +70,6 @@ namespace Klient.Droid
}
}
[Java.Interop.Export("ResetPassword")]
async public void ResetPassword()
{
SetContentView(Resource.Layout.ekranLogowania);
}
[Java.Interop.Export("SignUp")]
async public void SignUp(View v)
{
@ -178,26 +176,28 @@ namespace Klient.Droid
var Name = FindViewById<EditText>(Resource.Id.ChangeName).Text;
var Surname = FindViewById<EditText>(Resource.Id.ChangeSurname).Text;
var Email = FindViewById<EditText>(Resource.Id.ChangeEmail).Text;
SecureString Password = new NetworkCredential("", FindViewById<EditText>(Resource.Id.ChangePassword).Text).SecurePassword;
var values = new Dictionary<string, string>
if (string.IsNullOrEmpty(Name) | string.IsNullOrEmpty(Email) | string.IsNullOrEmpty(Surname))
{
{ "email", Email },
{ "name", Name },
{ "surname", Surname },
{ "login", savedLogin },
{ "password", new NetworkCredential("", Password).Password }
};
FindViewById<TextView>(Resource.Id.NullValueProfile).Text = "Wartości nie mogą być puste!";
}
else
{
var values = new Dictionary<string, string>
{
{ "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 content = new FormUrlEncodedContent(values);
var responseString = await response.Content.ReadAsStringAsync();
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) SetContentView(Resource.Layout.ekranPoLogowaniu);
if (response.StatusCode == HttpStatusCode.OK) FindViewById<TextView>(Resource.Id.NullValueProfile).Text = "Zapisano!";
}
}
}
}

View File

@ -57,6 +57,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Essentials">
<Version>1.5.3.2</Version>
</PackageReference>

View File

@ -9193,10 +9193,7 @@ namespace Klient.Droid
public const int ChangeName = 2131230723;
// aapt resource value: 0x7F080004
public const int ChangePassword = 2131230724;
// aapt resource value: 0x7F080005
public const int ChangeSurname = 2131230725;
public const int ChangeSurname = 2131230724;
// aapt resource value: 0x7F080052
public const int checkbox = 2131230802;
@ -9261,8 +9258,8 @@ namespace Klient.Droid
// aapt resource value: 0x7F080065
public const int edit_query = 2131230821;
// aapt resource value: 0x7F080006
public const int Email = 2131230726;
// aapt resource value: 0x7F080005
public const int Email = 2131230725;
// aapt resource value: 0x7F080066
public const int end = 2131230822;
@ -9276,6 +9273,9 @@ namespace Klient.Droid
// aapt resource value: 0x7F080069
public const int enterAlwaysCollapsed = 2131230825;
// aapt resource value: 0x7F080006
public const int ErrorPhoto = 2131230726;
// aapt resource value: 0x7F08006A
public const int exitUntilCollapsed = 2131230826;
@ -9385,16 +9385,13 @@ namespace Klient.Droid
public const int LayoutNewPassword2 = 2131230736;
// aapt resource value: 0x7F080011
public const int LayoutNewPasswordC = 2131230737;
public const int LayoutPassword = 2131230737;
// aapt resource value: 0x7F080012
public const int LayoutPassword = 2131230738;
public const int LayoutSurname = 2131230738;
// aapt resource value: 0x7F080013
public const int LayoutSurname = 2131230739;
// aapt resource value: 0x7F080014
public const int LayoutSurnameC = 2131230740;
public const int LayoutSurnameC = 2131230739;
// aapt resource value: 0x7F080084
public const int left = 2131230852;
@ -9411,14 +9408,14 @@ namespace Klient.Droid
// aapt resource value: 0x7F080088
public const int list_item = 2131230856;
// aapt resource value: 0x7F080014
public const int LoadFromCamera = 2131230740;
// aapt resource value: 0x7F080015
public const int LoadFromCamera = 2131230741;
public const int LoadFromFolder = 2131230741;
// aapt resource value: 0x7F080016
public const int LoadFromFolder = 2131230742;
// aapt resource value: 0x7F080017
public const int Login = 2131230743;
public const int Login = 2131230742;
// aapt resource value: 0x7F080089
public const int main_appbar = 2131230857;
@ -9441,8 +9438,8 @@ namespace Klient.Droid
// aapt resource value: 0x7F08008F
public const int message = 2131230863;
// aapt resource value: 0x7F080018
public const int META = 2131230744;
// aapt resource value: 0x7F080017
public const int META = 2131230743;
// aapt resource value: 0x7F080090
public const int middle = 2131230864;
@ -9597,8 +9594,8 @@ namespace Klient.Droid
// aapt resource value: 0x7F0800C2
public const int multiply = 2131230914;
// aapt resource value: 0x7F080019
public const int Name = 2131230745;
// aapt resource value: 0x7F080018
public const int Name = 2131230744;
// aapt resource value: 0x7F0800C3
public const int navigation_header_container = 2131230915;
@ -9606,11 +9603,11 @@ namespace Klient.Droid
// aapt resource value: 0x7F0800C4
public const int never = 2131230916;
// aapt resource value: 0x7F08001A
public const int NewLogin = 2131230746;
// aapt resource value: 0x7F080019
public const int NewLogin = 2131230745;
// aapt resource value: 0x7F08001B
public const int NewPassword = 2131230747;
// aapt resource value: 0x7F08001A
public const int NewPassword = 2131230746;
// aapt resource value: 0x7F0800C5
public const int none = 2131230917;
@ -9627,6 +9624,9 @@ namespace Klient.Droid
// aapt resource value: 0x7F0800C9
public const int notification_main_column_container = 2131230921;
// aapt resource value: 0x7F08001B
public const int NullValueProfile = 2131230747;
// aapt resource value: 0x7F0800CA
public const int outline = 2131230922;

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -15,7 +15,17 @@
android:text="Wyślij zdjęcie"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/SendPhoto"
android:onClick="SendPhoto"/>
android:id="@+id/SendPhoto"
android:onClick="SendPhoto"
android:layout_below="@id/Preview" />
<TextView
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ErrorPhoto"
android:layout_centerHorizontal="true"
android:layout_below="@id/SendPhoto"
android:textColor="#ffd60000" />
</LinearLayout>
</RelativeLayout>

View File

@ -63,34 +63,25 @@
android:textColorHint="#ff6c6767"
android:textColor="#ff000000"
android:inputType="none|textEmailAddress" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/LayoutNewPasswordC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:passwordToggleEnabled="true"
app:passwordToggleTint="@android:color/darker_gray"
android:layout_centerHorizontal="true"
android:hint="Hasło"
android:layout_below="@id/LayoutEmailC"
android:layout_alignParentLeft="true">
<android.support.design.widget.TextInputEditText
android:layout_width="204.0dp"
android:layout_height="58.0dp"
android:minWidth="25px"
android:minHeight="25px"
android:id="@+id/ChangePassword"
android:inputType="none|textPassword" />
</android.support.design.widget.TextInputLayout>
<Button
android:text="Zapisz"
android:layout_width="100.5dp"
android:layout_height="50dp"
android:id="@+id/Save"
android:layout_below="@id/LayoutNewPasswordC"
android:layout_below="@id/LayoutEmailC"
android:layout_centerHorizontal="true"
android:foregroundGravity="center"
android:gravity="center"
android:onClick="Save"/>
<TextView
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/NullValueProfile"
android:layout_centerHorizontal="true"
android:layout_below="@id/Save"
android:textColor="#ffd60000" />
</RelativeLayout>