Changeset 9866c0f in dispositivos_moviles for TibisayMovil/src/ve/gob/cenditel/tibisaymovil/PDFVerifyResultActivity.java
- Timestamp:
- Nov 13, 2013, 10:54:18 AM (11 years ago)
- Branches:
- master
- Children:
- 73b8c70
- Parents:
- 37c4d43 (diff), 4c4873f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TibisayMovil/src/ve/gob/cenditel/tibisaymovil/PDFVerifyResultActivity.java
rc14b8d2 r4c4873f 4 4 import java.io.File; 5 5 import java.io.InputStream; 6 7 6 8 7 import android.net.Uri; … … 17 16 import android.view.Window; 18 17 import android.view.View.OnClickListener; 18 import android.webkit.MimeTypeMap; 19 19 import android.widget.AdapterView; 20 20 import android.widget.BaseAdapter; … … 39 39 import java.util.ArrayList; 40 40 import java.util.Random; 41 42 41 import java.security.cert.X509Certificate; 43 42 import java.text.SimpleDateFormat; … … 75 74 76 75 // obtener el archivo pdf a verificar 77 Bundle bundle = getIntent().getExtras(); 78 pdfToVerify = bundle.getString("pdfToVerify"); 76 //Bundle bundle = getIntent().getExtras(); 77 //pdfToVerify = bundle.getString("pdfToVerify"); 78 79 final android.net.Uri data = getIntent().getData (); 80 81 if (data != null) { 82 Toast.makeText(getApplicationContext(), "data != null", Toast.LENGTH_SHORT).show(); 83 84 // verificar el tipo de scheme 85 String scheme = data.getScheme(); 86 87 // verificacion de un archivo que esta en el dispositivo 88 if (scheme.equals("file")) { 89 Toast.makeText(getApplicationContext(), "file: "+data.getPath(), Toast.LENGTH_SHORT).show(); 90 pdfToVerify = data.getPath(); 91 } 92 }else{ 93 // obtener el archivo pdf a verificar 94 Bundle bundle = getIntent().getExtras(); 95 pdfToVerify = bundle.getString("pdfToVerify"); 96 } 97 98 79 99 TextView pdfName = (TextView) this.findViewById(R.id.filename_text); 80 100 pdfName.setText(pdfToVerify); … … 82 102 // ejecutar el proceso de verificacion del pdf 83 103 doVerification(pdfToVerify); 104 105 LinearLayout layoutPdfFileResult = (LinearLayout) this.findViewById(R.id.layout_pdf_signed_result); 106 107 OnClickListener pdfFileListener = new OnClickListener() { 108 public void onClick(View v) { 109 110 //Toast.makeText(getApplicationContext(), "**CLICK SOBRE EL archivo***", Toast.LENGTH_LONG).show(); 111 112 openIt(pdfToVerify, getMimeType(pdfToVerify)); 113 } 114 }; 115 layoutPdfFileResult.setOnClickListener(pdfFileListener); 116 117 84 118 85 119 // habilitar opciones de botones inferiores … … 136 170 Log.d("VerificadorPDF", "af.getSignatureNames()"); 137 171 138 Toast.makeText(getApplicationContext(), "names.size: "+ Integer.toString(names.size()), Toast.LENGTH_SHORT).show();172 //Toast.makeText(getApplicationContext(), "names.size: "+ Integer.toString(names.size()), Toast.LENGTH_SHORT).show(); 139 173 Log.d("VerificadorPDF", Integer.toString(names.size())); 140 174 … … 174 208 for (int l=0; l < fields.length; l++) { 175 209 try { 176 Toast.makeText(getApplicationContext(), "PDFVerifyResultActivity - reading certificate: "+Integer.toString(l)+ " "+177 Integer.toString(fields[l].getInt(null)), Toast.LENGTH_SHORT).show();210 //Toast.makeText(getApplicationContext(), "PDFVerifyResultActivity - reading certificate: "+Integer.toString(l)+ " "+ 211 // Integer.toString(fields[l].getInt(null)), Toast.LENGTH_SHORT).show(); 178 212 179 213 caInput = new BufferedInputStream(getResources().openRawResource(fields[l].getInt(null))); … … 265 299 int position, long id) { 266 300 267 Toast.makeText(getApplicationContext(), "SE DEBE MOSTRAR INFORMACIÓN DEL FIRMANTE", Toast.LENGTH_SHORT).show();301 //Toast.makeText(getApplicationContext(), "SE DEBE MOSTRAR INFORMACIÓN DEL FIRMANTE", Toast.LENGTH_SHORT).show(); 268 302 showSignatureDetails(position, signers); 269 303 } … … 475 509 } 476 510 511 // funcion para obtener el tipo mime de un archivo 512 public static String getMimeType(String url) 513 { 514 String extension = url.substring(url.lastIndexOf(".")); 515 String mimeTypeMap = MimeTypeMap.getFileExtensionFromUrl(extension); 516 String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(mimeTypeMap); 517 return mimeType; 518 } 519 520 521 // funcion para lanzar un intent que abra un archivo 522 private void openIt(String pdfFile, String mimeType) { 523 524 Intent shareIntent = new Intent(); 525 shareIntent.setAction(Intent.ACTION_VIEW); 526 File file = new File(pdfFile); 527 Uri uri = Uri.fromFile(file); 528 Log.i("DEBUG", file.getPath()); 529 shareIntent.setDataAndType(uri, mimeType); 530 startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.open_it_using))); 531 } 477 532 478 533 }
Note: See TracChangeset
for help on using the changeset viewer.