Ignore:
Timestamp:
Nov 13, 2013, 10:54:18 AM (11 years ago)
Author:
Jose Ruiz <joseruiz@…>
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.
Message:

nada

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TibisayMovil/src/ve/gob/cenditel/tibisaymovil/PDFVerifyResultActivity.java

    rc14b8d2 r4c4873f  
    44import java.io.File;
    55import java.io.InputStream;
    6 
    76
    87import android.net.Uri;
     
    1716import android.view.Window;
    1817import android.view.View.OnClickListener;
     18import android.webkit.MimeTypeMap;
    1919import android.widget.AdapterView;
    2020import android.widget.BaseAdapter;
     
    3939import java.util.ArrayList;
    4040import java.util.Random;
    41 
    4241import java.security.cert.X509Certificate;
    4342import java.text.SimpleDateFormat;
     
    7574               
    7675                // 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               
    7999                TextView pdfName = (TextView) this.findViewById(R.id.filename_text);
    80100                pdfName.setText(pdfToVerify);
     
    82102                // ejecutar el proceso de verificacion del pdf
    83103                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               
    84118               
    85119                // habilitar opciones de botones inferiores
     
    136170                Log.d("VerificadorPDF", "af.getSignatureNames()");
    137171               
    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();
    139173                Log.d("VerificadorPDF", Integer.toString(names.size()));
    140174               
     
    174208                        for (int l=0; l < fields.length; l++) {
    175209                                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();
    178212
    179213                                        caInput = new BufferedInputStream(getResources().openRawResource(fields[l].getInt(null)));
     
    265299                                                int position, long id) {
    266300                                                                               
    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();
    268302                                        showSignatureDetails(position, signers);
    269303                                }
     
    475509        }
    476510       
     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        }
    477532       
    478533}
Note: See TracChangeset for help on using the changeset viewer.