POS_Sprint_2 #4

Merged
s426229 merged 12 commits from POS_Sprint_2 into develop 2020-12-14 19:27:10 +01:00
3 changed files with 183 additions and 173 deletions
Showing only changes of commit 827b522c65 - Show all commits

View File

@ -18,6 +18,7 @@ namespace Klient.Droid
[Activity(Label = "Klient", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
public static int PickImageId = 1000;
private static readonly HttpClient client = new HttpClient();
protected override void OnCreate(Bundle savedInstanceState)
@ -40,7 +41,7 @@ namespace Klient.Droid
{
SetContentView(Resource.Layout.ekranLogowania);
}
if(string.IsNullOrWhiteSpace(new NetworkCredential("", Password).Password))
if (string.IsNullOrWhiteSpace(new NetworkCredential("", Password).Password))
{
SetContentView(Resource.Layout.ekranLogowania);
}
@ -56,13 +57,13 @@ namespace Klient.Droid
var response = await client.PostAsync("http://10.0.2.2:5001/api/User/SignIn", content);
if (response.StatusCode == HttpStatusCode.InternalServerError) SetContentView(Resource.Layout.ekranPoLogowaniu);
if (response.StatusCode == HttpStatusCode.OK) SetContentView(Resource.Layout.ekranPoLogowaniu);
}
[Java.Interop.Export("ResetPassword")]
async public void ResetPassword()
{
SetContentView(Resource.Layout.ekranLogowania);
}
[Java.Interop.Export("SignUp")]
@ -75,7 +76,7 @@ namespace Klient.Droid
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 (new NetworkCredential("", Password).Password != new NetworkCredential("", Password2).Password)
{
SetContentView(Resource.Layout.ekranRejestracji);
}
@ -95,7 +96,7 @@ namespace Klient.Droid
var responseString = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode) SetContentView(Resource.Layout.ekranLogowania);
if (response.StatusCode == HttpStatusCode.OK) SetContentView(Resource.Layout.ekranLogowania);
}
[Java.Interop.Export("HelpLoginScreen")]
@ -119,12 +120,24 @@ namespace Klient.Droid
[Java.Interop.Export("about")]
public void MainScreenAbout(View v)
{
SetContentView(Resource.Layout.ekranStartowy);
}
[Java.Interop.Export("LoadFromCamera")]
async public void TakePhoto(View v)
[Java.Interop.Export("LoadFromFolder")]
public void LoadFile(View v)
{
Intent = new Android.Content.Intent();
Intent.SetType("image/*");
Intent.SetAction(Android.Content.Intent.ActionGetContent);
StartActivityForResult(Android.Content.Intent.CreateChooser(Intent, "Select Picture"), PickImageId);
}
protected override void OnActivityResult(int requestCode, Result resultCode, Android.Content.Intent data)
{
SetContentView(Resource.Layout.ekranPoZdjeciu);
Android.Net.Uri uri = data.Data;
FindViewById<ImageView>(Resource.Id.Preview).SetImageURI(uri);