package com.herxlabs.cryptobrain;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends AppCompatActivity {
    @BindView(R.id.txtToCrypt)TextView toCrypt;
    @BindView(R.id.txtCrypted)TextView crypted;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);

    }
    @OnClick(R.id.btnCrypt)
    public void crypt() {
        // TODO encript ;-D
    }
    @OnClick(R.id.btnClear)
    public void clear() {
        toCrypt.setText("");
        crypted.setText("");
    }
    @OnClick(R.id.btnCopy)
    public void copy() {
        Context context = getApplicationContext();
        String copyCrypt = crypted.getText().toString();
        if (copyCrypt.length() > 0) {
            ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("CryptoBrain", copyCrypt);
            clipboard.setPrimaryClip(clip);
            Toast toastMessage = Toast.makeText(context, "Text copied", Toast.LENGTH_LONG);
            toastMessage.show();
        } else {
            Toast toastMessage = Toast.makeText(context, "Nothing to copy", Toast.LENGTH_SHORT);
            toastMessage.show();
        }
    }
    @OnClick(R.id.btnShare)
    public void share() {
        String shareCrypt = crypted.getText().toString();
        if (shareCrypt.length() > 0) {
            Intent sendIntent = new Intent();
            sendIntent.setAction(Intent.ACTION_SEND);
            sendIntent.putExtra(Intent.EXTRA_TEXT, shareCrypt);
            sendIntent.setType("text/plain");
            startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));
        } else {
            Context context = getApplicationContext();
            Toast toastMessage = Toast.makeText(context, "Nothing to share", Toast.LENGTH_SHORT);
            toastMessage.show();
        }
    }
}

@@ -240,16 +240,94 @@
 tivity;%0A
+import android.view.View;%0Aimport android.view.inputmethod.InputMethodManager;%0A
 import a
@@ -346,24 +346,24 @@
 t.TextView;%0A
-
 import andro
@@ -888,27 +888,1081 @@
     
-// TODO encript ;-D
+String crypto = toCrypt.getText().toString().toUpperCase();%0A        crypto = crypto.replace(%22A%22, %224%22);%0A        crypto = crypto.replace(%22B%22, %228%22);%0A        crypto = crypto.replace(%22E%22, %223%22);%0A        crypto = crypto.replace(%22G%22, %226%22);%0A        crypto = crypto.replace(%22I%22, %221%22);%0A        crypto = crypto.replace(%22O%22, %220%22);%0A        crypto = crypto.replace(%22P%22, %229%22);%0A        crypto = crypto.replace(%22S%22, %225%22);%0A        crypto = crypto.replace(%22T%22, %227%22);%0A        crypto = crypto.replace(%22Z%22, %222%22);%0A        crypto = crypto.replace(%22-%22, %22--%22);%0A        crypto = crypto.replace(%22 %22, %22-%22);%0A        crypted.setText(crypto);%0A        //Oculta teclado%0A        View view = getCurrentFocus();%0A        if (view != null) %7B%0A            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);%0A            imm.hideSoftInputFromWindow(view.getWindowToken(), 0);%0A        %7D%0A        //Mensaje%0A        Context context = getApplicationContext();%0A        Toast toastMessage = Toast.makeText(context, %22CryptoBrained%22, Toast.LENGTH_SHORT);%0A        toastMessage.show();
 %0A   

Se agrego la función principal