Advertisement
Guest User

6

a guest
Mar 15th, 2016
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 13.96 KB | None | 0 0
  1. public class AuthActivity
  2.   extends Activity
  3. {
  4.   private static final int FILE_SELECT_CODE = 0;
  5.   String path = "";
  6.  
  7.   private void showFileChooser()
  8.   {
  9.     Intent localIntent = new Intent("android.intent.action.GET_CONTENT");
  10.     localIntent.setType("image/jpg");
  11.     localIntent.addCategory("android.intent.category.OPENABLE");
  12.     try
  13.     {
  14.       startActivityForResult(Intent.createChooser(localIntent, "Select a File to Upload"), 0);
  15.       return;
  16.     }
  17.     catch (ActivityNotFoundException localActivityNotFoundException)
  18.     {
  19.       Toast.makeText(this, "Please install a File Manager.", 0).show();
  20.     }
  21.   }
  22.  
  23.   private void showToken(final String paramString)
  24.   {
  25.     runOnUiThread(new Runnable()
  26.     {
  27.       public void run()
  28.       {
  29.         Toast.makeText(AuthActivity.this.getApplicationContext(), "Your token - " + paramString, 1).show();
  30.       }
  31.     });
  32.   }
  33.  
  34.   public String getPath(Context paramContext, Uri paramUri)
  35.     throws URISyntaxException
  36.   {
  37.     if ("content".equalsIgnoreCase(paramUri.getScheme())) {}
  38.     try
  39.     {
  40.       paramContext = paramContext.getContentResolver().query(paramUri, new String[] { "_data" }, null, null, null);
  41.       int i = paramContext.getColumnIndexOrThrow("_data");
  42.       if (!paramContext.moveToFirst()) {
  43.         break label79;
  44.       }
  45.       paramContext = paramContext.getString(i);
  46.       return paramContext;
  47.     }
  48.     catch (Exception paramContext) {}
  49.     if ("file".equalsIgnoreCase(paramUri.getScheme())) {
  50.       return paramUri.getPath();
  51.     }
  52.     label79:
  53.     return null;
  54.   }
  55.  
  56.   protected void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
  57.   {
  58.     switch (paramInt1)
  59.     {
  60.     }
  61.     for (;;)
  62.     {
  63.       super.onActivityResult(paramInt1, paramInt2, paramIntent);
  64.       return;
  65.       if (paramInt2 == -1) {
  66.         try
  67.         {
  68.           Uri localUri = paramIntent.getData();
  69.           try
  70.           {
  71.             this.path = getPath(this, localUri);
  72.             ((Button)findViewById(2131034115)).setText(this.path.substring(this.path.lastIndexOf("/") + 1));
  73.           }
  74.           catch (URISyntaxException localURISyntaxException)
  75.           {
  76.             localURISyntaxException.printStackTrace();
  77.           }
  78.         }
  79.         catch (Exception localException)
  80.         {
  81.           localException.printStackTrace();
  82.         }
  83.       }
  84.     }
  85.   }
  86.  
  87.   public void onCreate(final Bundle paramBundle)
  88.   {
  89.     super.onCreate(paramBundle);
  90.     setContentView(2130903040);
  91.     paramBundle = (TextView)findViewById(2131034117);
  92.     paramBundle.setClickable(true);
  93.     paramBundle.setOnClickListener(new View.OnClickListener()
  94.     {
  95.       public void onClick(View paramAnonymousView)
  96.       {
  97.         paramAnonymousView = new Intent(AuthActivity.this, MyActivity.class);
  98.         AuthActivity.this.startActivity(paramAnonymousView);
  99.       }
  100.     });
  101.     ((Button)findViewById(2131034115)).setOnClickListener(new View.OnClickListener()
  102.     {
  103.       public void onClick(View paramAnonymousView)
  104.       {
  105.         AuthActivity.this.showFileChooser();
  106.       }
  107.     });
  108.     paramBundle = (EditText)findViewById(2131034112);
  109.     final EditText localEditText1 = (EditText)findViewById(2131034113);
  110.     final EditText localEditText2 = (EditText)findViewById(2131034114);
  111.     ((Button)findViewById(2131034116)).setOnClickListener(new View.OnClickListener()
  112.     {
  113.       public void onClick(View paramAnonymousView)
  114.       {
  115.         new Thread(new Runnable()
  116.         {
  117.           public void run()
  118.           {
  119.             //   curl -X POST "http://213.170.91.83/authentication" -H "username: username" -H "password: N6@I5XrbCq" -H "phone: +79522714833"
  120.             Object localObject = new DefaultHttpClient(new BasicHttpParams());
  121.             HttpPost localHttpPost = new HttpPost("http://213.170.91.83/authentication");
  122.             localHttpPost.setHeader("username", AuthActivity.3.this.val$nameField.getText().toString());
  123.             localHttpPost.setHeader("password", AuthActivity.3.this.val$passwordField.getText().toString());
  124.             localHttpPost.setHeader("phone", AuthActivity.3.this.val$phoneField.getText().toString());
  125.             try
  126.             {
  127.               localHttpPost.setEntity(new FileEntity(new File(AuthActivity.this.path), "image/jpg"));
  128.               localObject = Globals.convertStreamToString(((DefaultHttpClient)localObject).execute(localHttpPost).getEntity().getContent());
  129.               AuthActivity.this.showToken(((String)localObject).substring(((String)localObject).indexOf("{\n  ") + 4, ((String)localObject).indexOf("\n}")));
  130.               return;
  131.             }
  132.             catch (Throwable localThrowable)
  133.             {
  134.               localThrowable.printStackTrace();
  135.             }
  136.           }
  137.         }).start();
  138.       }
  139.     });
  140.   }
  141.  
  142.   public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent)
  143.   {
  144.     return false;
  145.   }
  146. }
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156. public class Globals
  157. {
  158.   static final String host_address = "http://213.170.91.83/";
  159.   static final String myPhoneNumber = "+79522714833";
  160.   static final String password = "N6@I5XrbCq";
  161.  
  162.   public static String convertStreamToString(InputStream paramInputStream)
  163.   {
  164.     BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(paramInputStream));
  165.     StringBuilder localStringBuilder = new StringBuilder();
  166.     try
  167.     {
  168.       for (;;)
  169.       {
  170.         String str = localBufferedReader.readLine();
  171.         if (str == null) {
  172.           break;
  173.         }
  174.         localStringBuilder.append(str + "\n");
  175.       }
  176.       try
  177.       {
  178.         paramInputStream.close();
  179.         throw ((Throwable)localObject);
  180.       }
  181.       catch (IOException paramInputStream)
  182.       {
  183.         for (;;)
  184.         {
  185.           paramInputStream.printStackTrace();
  186.         }
  187.       }
  188.     }
  189.     catch (IOException localIOException)
  190.     {
  191.       localIOException = localIOException;
  192.       localIOException.printStackTrace();
  193.       try
  194.       {
  195.         paramInputStream.close();
  196.         for (;;)
  197.         {
  198.           return localStringBuilder.toString();
  199.           try
  200.           {
  201.             paramInputStream.close();
  202.           }
  203.           catch (IOException paramInputStream)
  204.           {
  205.             paramInputStream.printStackTrace();
  206.           }
  207.         }
  208.       }
  209.       catch (IOException paramInputStream)
  210.       {
  211.         for (;;)
  212.         {
  213.           paramInputStream.printStackTrace();
  214.         }
  215.       }
  216.     }
  217.     finally {}
  218.   }
  219. }
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230. public class MyActivity
  231.   extends Activity
  232. {
  233.   public void onCreate(final Bundle paramBundle)
  234.   {
  235.     super.onCreate(paramBundle);
  236.     setContentView(2130903041);
  237.     final TextView localTextView = (TextView)findViewById(2131034123);
  238.     localTextView.setClickable(true);
  239.     localTextView.setOnClickListener(new View.OnClickListener()
  240.     {
  241.       public void onClick(View paramAnonymousView)
  242.       {
  243.         paramAnonymousView = new Intent(MyActivity.this, AuthActivity.class);
  244.         MyActivity.this.startActivity(paramAnonymousView);
  245.       }
  246.     });
  247.     paramBundle = (EditText)findViewById(2131034120);
  248.     localTextView.setClickable(true);
  249.     localTextView = (TextView)findViewById(2131034122);
  250.     localTextView.setVisibility(4);
  251.     ((Button)findViewById(2131034121)).setOnClickListener(new View.OnClickListener()
  252.     {
  253.       public void onClick(View paramAnonymousView)
  254.       {
  255.         new Thread(new Runnable()
  256.         {
  257.           public void run()
  258.           {
  259.             try
  260.             {
  261.               Object localObject2 = (HttpURLConnection)new URL("http://213.170.91.83/language_test?token=" + MyActivity.2.this.val$tokenField.getText()).openConnection();
  262.               Object localObject1 = ((HttpURLConnection)localObject2).getHeaderField("hash");
  263.               if ((localObject1 == null) || (((String)localObject1).isEmpty()))
  264.               {
  265.                 MyActivity.2.this.val$wrongToken.setVisibility(0);
  266.                 return;
  267.               }
  268.               Bitmap localBitmap = BitmapFactory.decodeStream(((HttpURLConnection)localObject2).getInputStream());
  269.               localObject2 = new Bundle();
  270.               ((Bundle)localObject2).putParcelable("image", localBitmap);
  271.               ((Bundle)localObject2).putString("hash", (String)localObject1);
  272.               ((Bundle)localObject2).putString("token", String.valueOf(MyActivity.2.this.val$tokenField.getText()));
  273.               localObject1 = new Intent(MyActivity.this, TaskActivity.class);
  274.               ((Intent)localObject1).putExtras((Bundle)localObject2);
  275.               MyActivity.this.startActivity((Intent)localObject1);
  276.               return;
  277.             }
  278.             catch (Exception localException)
  279.             {
  280.               localException.printStackTrace();
  281.             }
  282.           }
  283.         }).start();
  284.       }
  285.     });
  286.   }
  287.  
  288.   public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent)
  289.   {
  290.     return false;
  291.   }
  292. }
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309. public static final class id
  310. {
  311.   public static final int extractEditText = 2131034118;
  312.   public static final int extractEditText2 = 2131034119;
  313.   public static final int imageView = 2131034124;
  314.   public static final int loginButton = 2131034116;
  315.   public static final int nameField = 2131034112;
  316.   public static final int passwordField = 2131034113;
  317.   public static final int phoneField = 2131034114;
  318.   public static final int photoChooseButton = 2131034115;
  319.   public static final int registrateButton = 2131034123;
  320.   public static final int registratedButton = 2131034117;
  321.   public static final int startButton = 2131034121;
  322.   public static final int timerString = 2131034127;
  323.   public static final int tokenTextField = 2131034120;
  324.   public static final int translateButton = 2131034126;
  325.   public static final int translateField = 2131034125;
  326.   public static final int wrongToken = 2131034122;
  327. }
  328.  
  329. public static final class layout
  330. {
  331.   public static final int auth_layout = 2130903040;
  332.   public static final int main = 2130903041;
  333.   public static final int task_layout = 2130903042;
  334. }
  335.  
  336. public static final class string
  337. {
  338.   public static final int app_name = 2130968576;
  339. }
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351. public class TaskActivity
  352.   extends Activity
  353. {
  354.   volatile int clock;
  355.   Handler myHandler = new Handler();
  356.  
  357.   private void show(final String paramString)
  358.   {
  359.     runOnUiThread(new Runnable()
  360.     {
  361.       public void run()
  362.       {
  363.         Toast.makeText(TaskActivity.this.getApplicationContext(), paramString, 1).show();
  364.       }
  365.     });
  366.   }
  367.  
  368.   public void onCreate(final Bundle paramBundle)
  369.   {
  370.     super.onCreate(paramBundle);
  371.     setContentView(2130903042);
  372.     paramBundle = getIntent().getExtras();
  373.     final Object localObject = (Bitmap)paramBundle.getParcelable("image");
  374.     ((ImageView)findViewById(2131034124)).setImageBitmap((Bitmap)localObject);
  375.     new Thread(new Runnable()
  376.     {
  377.       public void run()
  378.       {
  379.         TaskActivity.this.clock = 5;
  380.         for (;;)
  381.         {
  382.           if (TaskActivity.this.clock > -1)
  383.           {
  384.             TaskActivity.this.myHandler.post(new Runnable()
  385.             {
  386.               public void run()
  387.               {
  388.                 TaskActivity.1.this.val$timer.setText("���������������� " + TaskActivity.this.clock + " ������������");
  389.                 if (TaskActivity.this.clock == 0)
  390.                 {
  391.                   Intent localIntent = new Intent(TaskActivity.this, MyActivity.class);
  392.                   TaskActivity.this.startActivity(localIntent);
  393.                 }
  394.               }
  395.             });
  396.             try
  397.             {
  398.               Thread.sleep(1000L);
  399.               TaskActivity localTaskActivity = TaskActivity.this;
  400.               localTaskActivity.clock -= 1;
  401.             }
  402.             catch (InterruptedException localInterruptedException)
  403.             {
  404.               for (;;)
  405.               {
  406.                 localInterruptedException.printStackTrace();
  407.               }
  408.             }
  409.           }
  410.         }
  411.       }
  412.     }).start();
  413.     localObject = (EditText)findViewById(2131034125);
  414.     ((Button)findViewById(2131034126)).setOnClickListener(new View.OnClickListener()
  415.     {
  416.       public void onClick(final View paramAnonymousView)
  417.       {
  418.         paramAnonymousView = paramBundle.getString("hash");
  419.         new Thread(new Runnable()
  420.         {
  421.           public void run()
  422.           {
  423.             try
  424.             {
  425.               Object localObject2 = (HttpURLConnection)new URL("http://213.170.91.83/language_test?token=" + this.val$token + "&hash=" + paramAnonymousView + "&answer=" + TaskActivity.2.this.val$answer.getText()).openConnection();
  426.               Object localObject1 = ((HttpURLConnection)localObject2).getHeaderField("hash");
  427.               if ((localObject1 != null) && (!((String)localObject1).isEmpty()))
  428.               {
  429.                 Bitmap localBitmap = BitmapFactory.decodeStream(((HttpURLConnection)localObject2).getInputStream());
  430.                 localObject2 = new Bundle();
  431.                 ((Bundle)localObject2).putParcelable("image", localBitmap);
  432.                 ((Bundle)localObject2).putString("hash", (String)localObject1);
  433.                 localObject1 = new Intent(TaskActivity.this, TaskActivity.class);
  434.                 ((Intent)localObject1).putExtras((Bundle)localObject2);
  435.                 TaskActivity.this.startActivity((Intent)localObject1);
  436.                 return;
  437.               }
  438.               localObject1 = Globals.convertStreamToString(((HttpURLConnection)localObject2).getInputStream());
  439.               localObject1 = ((String)localObject1).substring(((String)localObject1).indexOf("{\n  \"") + 5, ((String)localObject1).indexOf("\n}"));
  440.               TaskActivity.this.show((String)localObject1);
  441.               return;
  442.             }
  443.             catch (Exception localException)
  444.             {
  445.               localException.printStackTrace();
  446.             }
  447.           }
  448.         }).start();
  449.       }
  450.     });
  451.   }
  452.  
  453.   public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent)
  454.   {
  455.     return false;
  456.   }
  457. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement