Guest User

Untitled

a guest
Oct 17th, 2017
560
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.96 KB | None | 0 0
  1. using Android.App;
  2. using Android.Content.PM;
  3. using Android.Content.Res;
  4. using Android.OS;
  5. using Android.Support.V4.Widget;
  6. using Android.Views;
  7. using Android.Widget;
  8. using System.Collections;
  9. using Android.Support.V7.App;
  10. using Android.Support.V4.View;
  11. using Android.Support.Design.Widget;
  12. using Auth0.OidcClient;
  13. using Android.Content;
  14. using IdentityModel.OidcClient;
  15. using Android.Graphics;
  16. using System.Net;
  17. using System;
  18. using Android.Runtime;
  19. using Android.Text.Method;
  20. using System.Text;
  21. namespace whirlpoolapp
  22. {
  23. [Activity(Label = "whirlpoolapp", MainLauncher = true)]
  24. [IntentFilter(
  25. new[] { Intent.ActionView },
  26. Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
  27. DataScheme = "whirlpoolapp.whirlpoolapp",
  28. DataHost = "lucasmoreira.auth0.com",
  29. DataPathPrefix = "/android/whirlpoolapp.whirlpoolapp/callback")]
  30. public class MainActivity : Activity
  31. {
  32. private ArrayList enderecos;
  33. TextView queroreconhecer;
  34. TextView crie;
  35. TextView conquiste;
  36. TextView entregue;
  37. TextView viva;
  38. TextView comentar;
  39. EditText comentário;
  40. Spinner spinner;
  41. ArrayAdapter adapter;
  42. RadioGroup rdgcrie;
  43. RadioGroup rdgconquiste;
  44. RadioGroup rdgentregue;
  45. RadioGroup rdgviva;
  46. Button enviar;
  47. private Auth0Client client;
  48. private AuthorizeState authorizeState;
  49. ProgressDialog progress;
  50.  
  51. protected override void OnResume()
  52. {
  53. base.OnResume();
  54.  
  55. if (progress != null)
  56. {
  57. progress.Dismiss();
  58.  
  59. progress.Dispose();
  60. progress = null;
  61. }
  62. }
  63.  
  64. protected override async void OnNewIntent(Intent intent)
  65. {
  66. base.OnNewIntent(intent);
  67.  
  68. var loginResult = await client.ProcessResponseAsync(intent.DataString, authorizeState);
  69.  
  70. var sb = new StringBuilder();
  71. if (loginResult.IsError)
  72. {
  73. sb.AppendLine($"An error occurred during login: {loginResult.Error}");
  74. }
  75. else
  76. {
  77. sb.AppendLine($"ID Token: {loginResult.IdentityToken}");
  78. sb.AppendLine($"Access Token: {loginResult.AccessToken}");
  79. sb.AppendLine($"Refresh Token: {loginResult.RefreshToken}");
  80.  
  81. sb.AppendLine();
  82.  
  83. sb.AppendLine("-- Claims --");
  84. foreach (var claim in loginResult.User.Claims)
  85. {
  86. sb.AppendLine($"{claim.Type} = {claim.Value}");
  87. }
  88. }
  89.  
  90.  
  91. }
  92.  
  93. private async void LoginButtonOnClick(object sender, EventArgs eventArgs)
  94. {
  95.  
  96.  
  97. progress = new ProgressDialog(this);
  98. progress.SetTitle("Log In");
  99. progress.SetMessage("Please wait while redirecting to login screen...");
  100. progress.SetCancelable(false); // disable dismiss by tapping outside of the dialog
  101. progress.Show();
  102.  
  103. // Prepare for the login
  104. authorizeState = await client.PrepareLoginAsync();
  105.  
  106. // Send the user off to the authorization endpoint
  107. var uri = Android.Net.Uri.Parse(authorizeState.StartUrl);
  108. var intent = new Intent(Intent.ActionView, uri);
  109. intent.AddFlags(ActivityFlags.NoHistory);
  110. StartActivity(intent);
  111. }
  112.  
  113. protected override void OnCreate(Bundle bundle)
  114. {
  115. base.OnCreate(bundle);
  116.  
  117. SetContentView(Resource.Layout.Main);
  118. client = new Auth0Client(new Auth0ClientOptions
  119. {
  120. Domain = Resources.GetString(Resource.String.auth0_domain),
  121. ClientId = Resources.GetString(Resource.String.auth0_client_id),
  122. Activity = this
  123. });
  124. //preenche o arraylist com os dados
  125. GetEmails();
  126. //cria a instância do spinner declarado no arquivo Main
  127. spinner = FindViewById<Spinner>(Resource.Id.spnDados);
  128. //cria textview
  129. queroreconhecer = FindViewById<TextView>(Resource.Id.txtReconhecer);
  130. crie = FindViewById<TextView>(Resource.Id.txtCrie);
  131. conquiste = FindViewById<TextView>(Resource.Id.txtConquiste);
  132. entregue = FindViewById<TextView>(Resource.Id.txtEntregue);
  133. viva = FindViewById<TextView>(Resource.Id.txtViva);
  134. comentar = FindViewById<TextView>(Resource.Id.txtComentário);
  135. comentário = FindViewById<EditText>(Resource.Id.edtComentario);
  136. rdgcrie = FindViewById<RadioGroup>(Resource.Id.rdgCrie);
  137. rdgconquiste = FindViewById<RadioGroup>(Resource.Id.rdgConquiste);
  138. rdgentregue = FindViewById<RadioGroup>(Resource.Id.rdgEntregue);
  139. rdgviva = FindViewById<RadioGroup>(Resource.Id.rdgViva);
  140. adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, enderecos);
  141. spinner.Adapter = adapter;
  142. spinner.ItemSelected += Spinner_ItemSelected;
  143. enviar = FindViewById<Button>(Resource.Id.button1);
  144. enviar.Click += enviar_Click;
  145. void GetEmails()
  146. {
  147. enderecos = new ArrayList();
  148. enderecos.Add("Escolha um colaborador abaixo");
  149. enderecos.Add("alexandre_bonfim@whirlpool.com");
  150. enderecos.Add("alexandre_t_pires@whirlpool.com");
  151. enderecos.Add("ana_carolina_simoes @whirlpool.com");
  152. enderecos.Add("ana_claudia_s_belarmino@whirlpool.com");
  153. enderecos.Add("andre_costa@whirlpool.com");
  154. enderecos.Add("andre_l_teixeira@whirlpool.com");
  155. enderecos.Add("andreza_a_valle@whirlpool.com");
  156. enderecos.Add("anna_carolina_b_ferreira@whirlpool.com");
  157. enderecos.Add("bruno_b_souza@whirlpool.com");
  158. enderecos.Add("bruno_c_castanho@whirlpool.com");
  159. enderecos.Add("bruno_s_lombardero@whirlpool.com");
  160. enderecos.Add("caio_c_sacoman@whirlpool.com");
  161. enderecos.Add("carla_sedin@whirlpool.com");
  162. enderecos.Add("cassia_r_nascimento@whirlpool.com");
  163. enderecos.Add("celia_r_araujo@whirlpool.com");
  164. enderecos.Add("cesar_leandro_de_oliveira@whirlpool.com");
  165. enderecos.Add("daniel_b_szortyka@whirlpool.com");
  166. enderecos.Add("denis_caciatori@whirlpool.com");
  167. enderecos.Add("elisabete_c_ferreira@whirlpool.com");
  168. enderecos.Add("erick_c_senzaki@whirlpool.com");
  169. enderecos.Add("erika_g_souza@whirlpool.com");
  170. enderecos.Add("fabiana_monteiro@whirlpool.com");
  171. enderecos.Add("fernando_v_santos@whirlpool.com");
  172. enderecos.Add("gabriel_roveda@whirlpool.com");
  173. enderecos.Add("herivelto_alves_jr@whirlpool.com");
  174. enderecos.Add("jefferson_s_pecanha@whirlpool.com");
  175. enderecos.Add("josiane_a_teles@whirlpool.com");
  176. enderecos.Add("juliana_g_saito@whirlpool.com");
  177. enderecos.Add("juliano_ventola@whirlpool.com");
  178. enderecos.Add("leonardo_l_costa@whirlpool.com");
  179. enderecos.Add("leonardo_r_silva@whirlpool.com");
  180. enderecos.Add("lucas_m_santos@whirlpool.com");
  181. enderecos.Add("luiz_perea@whirlpool.com");
  182. enderecos.Add("norma_raphaeli@whirlpool.com");
  183. enderecos.Add("patricia_f_prates@whirlpool.com");
  184. enderecos.Add("priscila_l_dattilo@whirlpool.com");
  185. enderecos.Add("priscila_m_konte@whirlpool.com");
  186. enderecos.Add("reider_a_bernucio@whirlpool.com");
  187. enderecos.Add("renato_occhiuto@whirlpool.com");
  188. enderecos.Add("ricardo_a_fernandes@whirlpool.com");
  189. enderecos.Add("ricardo_matos_campaneruti @whirlpool.com");
  190. enderecos.Add("rogerio_pagotto@whirlpool.com");
  191. enderecos.Add("ruben_c_anacleto@whirlpool.com");
  192. enderecos.Add("taise_azevedo@whirlpool.com");
  193. enderecos.Add("vinicius_marques_assis@whirlpool.com");
  194. enderecos.Add("wanderly_t_limeira@whirlpool.com");
  195. }// fim getEmails
  196.  
  197. void Spinner_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
  198. {
  199. Spinner spinner = (Spinner)sender;
  200. string toast = string.Format("Colaborador selecionado: {0}", spinner.GetItemAtPosition(e.Position));
  201. Toast.MakeText(this, toast, ToastLength.Long).Show();
  202. string texto = toast;
  203.  
  204.  
  205. }
  206.  
  207.  
  208. }
  209. void enviar_Click(object sender, EventArgs e)
  210. { try {
  211. RadioButton rdbgrupo1 = FindViewById<RadioButton>(rdgconquiste.CheckedRadioButtonId);
  212. RadioButton rdbgrupo2 = FindViewById<RadioButton>(rdgcrie.CheckedRadioButtonId);
  213. RadioButton rdbgrupo3 = FindViewById<RadioButton>(rdgviva.CheckedRadioButtonId);
  214. RadioButton rdbgrupo4 = FindViewById<RadioButton>(rdgentregue.CheckedRadioButtonId);
  215. if (rdbgrupo1.Selected == false || rdbgrupo2.Selected == false || rdbgrupo3.Selected == false || rdbgrupo4.Selected == false)
  216. {
  217. string excecao = "Ao menos um botão de cada campo deve ser selecionado e o comentário deve ser preenchido";
  218. Toast.MakeText(this, excecao, ToastLength.Long).Show();
  219. }
  220. else
  221. {
  222. String emailescolhido = spinner.SelectedItem.ToString();
  223. String campocomentario = comentário.Text;
  224. string message = "Ao menos um botão de cada campo deve ser selecionado";
  225. Toast.MakeText(ApplicationContext, message, ToastLength.Long).Show();
  226. var email = new Intent(Android.Content.Intent.ActionSend);
  227. //send to
  228. email.PutExtra(Android.Content.Intent.ExtraEmail,
  229. new string[] { "" + emailescolhido });
  230. //cc to
  231. email.PutExtra(Android.Content.Intent.ExtraCc,
  232. new string[] { "comite_clima_ti@whirlpool.com" });
  233. //subject
  234. email.PutExtra(Android.Content.Intent.ExtraSubject, "SABIA QUE VOCÊ FOI RECONHECIDO?");
  235. //content
  236. email.PutExtra(Android.Content.Intent.ExtraText,
  237. "Você foi reconhecido pelo(s) valor(es) de: " + rdbgrupo1.Text + " , " + rdbgrupo2.Text + " , " + rdbgrupo3.Text + " e " + rdbgrupo4.Text);
  238. email.PutExtra(Android.Content.Intent.ExtraText, "" + campocomentario);
  239. email.SetType("message/rfc822");
  240. StartActivity(email);
  241. }
  242.  
  243. }
  244. catch (Java.Lang.Exception ex)
  245. {
  246. string excecao = "Ao menos um botão de cada campo deve ser selecionado e o comentário deve ser preenchido";
  247. Toast.MakeText(this, excecao, ToastLength.Long).Show();
  248.  
  249. }
  250.  
  251.  
  252. }
  253.  
  254.  
  255.  
  256.  
  257. }
  258. }
Add Comment
Please, Sign In to add comment