[a8bb2bb] | 1 | package ve.gob.cenditel.tibisaymovil; |
---|
| 2 | |
---|
| 3 | |
---|
| 4 | import java.io.File; |
---|
| 5 | |
---|
| 6 | import android.app.Activity; |
---|
| 7 | import android.content.Intent; |
---|
| 8 | import android.net.Uri; |
---|
| 9 | import android.os.Bundle; |
---|
| 10 | import android.util.Log; |
---|
| 11 | import android.view.View; |
---|
| 12 | import android.view.View.OnClickListener; |
---|
| 13 | import android.view.Window; |
---|
[67541a6] | 14 | import android.webkit.MimeTypeMap; |
---|
[a8bb2bb] | 15 | import android.widget.LinearLayout; |
---|
| 16 | import android.widget.TextView; |
---|
| 17 | import android.widget.Toast; |
---|
| 18 | |
---|
| 19 | public class SignResultHandwrittenSignatureActivity extends Activity{ |
---|
| 20 | private String fileToSign; |
---|
| 21 | private String imageCaptured; |
---|
| 22 | private String fileSigned; |
---|
| 23 | private String pathFileSigned; |
---|
| 24 | private LinearLayout button_share; |
---|
| 25 | private LinearLayout button_finish; |
---|
| 26 | |
---|
| 27 | @Override |
---|
| 28 | protected void onCreate(Bundle savedInstanceState) { |
---|
| 29 | |
---|
| 30 | //Capturando archivo que será firmado |
---|
| 31 | fileToSign = getIntent().getExtras().getString("FILE_TO_SIGN"); |
---|
| 32 | //Capturando imagen de firma |
---|
| 33 | imageCaptured = getIntent().getExtras().getString("IMAGE_CAPTURED"); |
---|
| 34 | //Capturando archivo firmado |
---|
| 35 | fileSigned = getIntent().getExtras().getString("FILE_SIGNED"); |
---|
| 36 | pathFileSigned = getIntent().getExtras().getString("PATH_FILE_SIGNED"); |
---|
| 37 | |
---|
| 38 | //Estilando la barra de titulo |
---|
| 39 | final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); |
---|
| 40 | |
---|
| 41 | super.onCreate(savedInstanceState); |
---|
| 42 | setContentView(R.layout.activity_sign_result_handwritten_signature); |
---|
| 43 | //Estilando Barra de titulo |
---|
| 44 | if(customTitleSupported) |
---|
| 45 | getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar); |
---|
| 46 | |
---|
[ca6582b] | 47 | TextView archivo_para_firm = (TextView) this.findViewById(R.id.archivo_original_a_firmar); |
---|
[fd4a5b9] | 48 | TextView imagen_utlizada= (TextView) this.findViewById(R.id.archivo_descifrado); |
---|
[ae1bcd1] | 49 | TextView archivo_firmado = (TextView) this.findViewById(R.id.destinatario); |
---|
[a8bb2bb] | 50 | |
---|
| 51 | archivo_para_firm.setText(fileToSign); |
---|
| 52 | imagen_utlizada.setText(imageCaptured); |
---|
| 53 | archivo_firmado.setText(pathFileSigned+fileSigned); |
---|
| 54 | |
---|
[4528953] | 55 | button_share = (LinearLayout) this.findViewById(R.id.button_remove_certificate_zone); |
---|
| 56 | button_finish = (LinearLayout) this.findViewById(R.id.button_add_certificate_zone); |
---|
[a8bb2bb] | 57 | |
---|
| 58 | |
---|
| 59 | |
---|
| 60 | button_finish.setOnClickListener(new OnClickListener() |
---|
| 61 | { |
---|
| 62 | public void onClick(View v) |
---|
| 63 | { |
---|
| 64 | Intent oIntent = new Intent(SignResultHandwrittenSignatureActivity.this, TibisayMovilActivity.class); |
---|
| 65 | oIntent.setAction(Intent.ACTION_VIEW); |
---|
| 66 | oIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); |
---|
| 67 | startActivity(oIntent); |
---|
| 68 | finish(); |
---|
| 69 | } |
---|
| 70 | }); |
---|
| 71 | |
---|
| 72 | button_share.setOnClickListener(new OnClickListener() |
---|
| 73 | { |
---|
| 74 | public void onClick(View v) |
---|
| 75 | { |
---|
| 76 | shareIt(); |
---|
| 77 | } |
---|
| 78 | }); |
---|
[67541a6] | 79 | |
---|
| 80 | |
---|
| 81 | LinearLayout layoutDecryptedFileAndArror = (LinearLayout) this.findViewById(R.id.layout_decrypted_file_and_arrow); |
---|
| 82 | |
---|
| 83 | OnClickListener decryptedFileListener = new OnClickListener() { |
---|
| 84 | public void onClick(View v) { |
---|
| 85 | // do something when the button is clicked |
---|
| 86 | //Toast.makeText(getApplicationContext(), "**CLICK SOBRE EL TEXTVIEW***", Toast.LENGTH_LONG).show(); |
---|
| 87 | |
---|
| 88 | openIt(pathFileSigned+fileSigned, getMimeType(pathFileSigned+fileSigned)); |
---|
| 89 | } |
---|
| 90 | }; |
---|
| 91 | layoutDecryptedFileAndArror.setOnClickListener(decryptedFileListener); |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | |
---|
| 95 | // funcion para lanzar un intent que abra un archivo |
---|
| 96 | private void openIt(String decryptedFile, String mimeType) { |
---|
| 97 | |
---|
| 98 | Intent shareIntent = new Intent(); |
---|
| 99 | shareIntent.setAction(Intent.ACTION_VIEW); |
---|
| 100 | File file = new File(decryptedFile); |
---|
| 101 | Uri uri = Uri.fromFile(file); |
---|
| 102 | Log.i("DEBUG", file.getPath()); |
---|
| 103 | shareIntent.setDataAndType(uri, mimeType); |
---|
| 104 | startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.open_it_using))); |
---|
[a8bb2bb] | 105 | } |
---|
| 106 | |
---|
| 107 | private void shareIt() { |
---|
| 108 | |
---|
| 109 | Intent shareIntent = new Intent(); |
---|
| 110 | shareIntent.setAction(Intent.ACTION_SEND); |
---|
[288126d] | 111 | Toast.makeText(SignResultHandwrittenSignatureActivity.this,pathFileSigned + fileSigned,Toast.LENGTH_LONG).show(); |
---|
[a8bb2bb] | 112 | File file = new File(pathFileSigned + fileSigned); |
---|
| 113 | Uri pdf_uri = Uri.fromFile(file); |
---|
| 114 | Log.i("DEBUG", file.getPath()); |
---|
| 115 | shareIntent.putExtra(Intent.EXTRA_STREAM, pdf_uri); |
---|
| 116 | shareIntent.setType("application/pdf "); |
---|
| 117 | startActivity(Intent.createChooser(shareIntent, "Compartir pdf usando")); |
---|
| 118 | } |
---|
[67541a6] | 119 | |
---|
| 120 | // funcion para obtener el tipo mime de un archivo |
---|
| 121 | public static String getMimeType(String url) |
---|
| 122 | { |
---|
| 123 | String extension = url.substring(url.lastIndexOf(".")); |
---|
| 124 | String mimeTypeMap = MimeTypeMap.getFileExtensionFromUrl(extension); |
---|
| 125 | String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(mimeTypeMap); |
---|
| 126 | return mimeType; |
---|
| 127 | } |
---|
[a8bb2bb] | 128 | } |
---|