Changeset c95e4a6 in dispositivos_moviles for TibisayMovil


Ignore:
Timestamp:
Sep 30, 2013, 9:30:23 AM (11 years ago)
Author:
Antonio Araujo Brett <aaraujo@…>
Branches:
master
Children:
9572f49
Parents:
8860b8f
Message:

*- Implementación de funcionalidad para abrir documentos BDOC y verificar firmas electrónicas al seleccionar un archivo desde el navegador de archivos.

Location:
TibisayMovil
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • TibisayMovil/AndroidManifest.xml

    r88eadd6 rc95e4a6  
    1010
    1111    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     12    <uses-permission android:name="android.permission.INTERNET" />
    1213
    1314    <application
     
    4243            android:name="ve.gob.cenditel.tibisaymovil.BDOCVerifyResultActivity"
    4344            android:label="@string/title_activity_bdocverify_result" >
     45           
     46            <intent-filter>
     47                <action android:name="android.intent.action.VIEW" />
     48
     49                <category android:name="android.intent.category.DEFAULT" />
     50
     51                <data android:scheme="file" />
     52                <data android:mimeType="*/*" />
     53                <data android:host="*" />
     54                <data android:pathPattern=".*\\.bdoc" />
     55            </intent-filter>
     56           
     57            <intent-filter>
     58                <action android:name="android.intent.action.VIEW" />
     59
     60                <category android:name="android.intent.category.DEFAULT" />
     61
     62                <data android:scheme="file" />
     63                <data android:mimeType="*/*" />
     64                <data android:host="*" />
     65                <data android:pathPattern=".*\\..*\\.bdoc" />
     66            </intent-filter>
     67           
     68           
     69            <intent-filter>
     70                <action android:name="android.intent.action.VIEW" />
     71
     72                <category android:name="android.intent.category.BROWSABLE" />
     73                <category android:name="android.intent.category.DEFAULT" />
     74
     75                <data android:scheme="https" />
     76                <data android:host="*" />
     77                <data android:pathPattern=".*\\.bdoc" />
     78            </intent-filter>
     79           
     80            <intent-filter>
     81                <action android:name="android.intent.action.VIEW" />
     82
     83                <category android:name="android.intent.category.BROWSABLE" />
     84                <category android:name="android.intent.category.DEFAULT" />
     85
     86                <data android:scheme="https" />
     87                <data android:host="*" />
     88                <data android:pathPattern=".*\\..*\\.bdoc" />
     89            </intent-filter>
     90           
     91           
    4492        </activity>
    4593        <activity
     
    5199            android:label="@string/title_activity_activity_signature_errors" >
    52100        </activity>
     101       
    53102    </application>
    54103
  • TibisayMovil/gen/ve/gob/cenditel/tibisaymovil/R.java

    r8860b8f rc95e4a6  
    232232        public static final int bdocverify_result=0x7f090002;
    233233        public static final int main=0x7f090003;
     234        public static final int tibisay_movil=0x7f090004;
    234235    }
    235236    public static final class plurals {
     
    321322        public static final int title_activity_activity_signer_info=0x7f040050;
    322323        public static final int title_activity_bdocverify_result=0x7f040049;
     324        public static final int title_activity_tibisay_movil=0x7f040059;
    323325        public static final int title_certificate_info=0x7f04004f;
    324326        public static final int title_progress_file_read=0x7f040039;
  • TibisayMovil/res/values/strings.xml

    r8860b8f rc95e4a6  
    8484    <string name="verificar_titulo_lista_docs">Documento (s) firmado (s):</string>
    8585    <string name="verificar_titulo_lista_firmantes">Firmante (s):</string>
    86     <string name="title_activity_bdocverify_result">BDOCVerifyResultActivity</string>
     86    <string name="title_activity_bdocverify_result">Tibisay Móvil</string>
    8787    <string name="extracted_dir_files">ExtractedFiles</string>
    8888    <string name="open_it_using">Abrir usando:</string>
     
    9898    <string name="label_signature_errors">Errores en firmas:</string>
    9999    <string name="title_activity_activity_signature_errors">ActivitySignatureErrors</string>
    100 
    101100    <string name="string_valid_signature">Válida</string>
    102101    <string name="string_invalid_signature">Inválida</string>
    103    
    104    
    105    
     102    <string name="title_activity_tibisay_movil">TibisayMovil</string>
     103
    106104</resources>
  • TibisayMovil/src/ve/gob/cenditel/tibisaymovil/BDOCVerifyResultActivity.java

    r8860b8f rc95e4a6  
    55import java.io.FileInputStream;
    66import java.io.FileOutputStream;
     7import java.io.IOException;
    78import java.io.InputStream;
     9import java.io.OutputStream;
     10import java.net.HttpURLConnection;
     11import java.net.MalformedURLException;
     12import java.net.URL;
     13import java.net.URLConnection;
    814import java.util.ArrayList;
     15
     16import javax.net.ssl.HttpsURLConnection;
    917
    1018
     
    1624import ee.sk.utils.ConfigManager;
    1725import android.net.Uri;
     26import android.os.AsyncTask;
    1827import android.os.Bundle;
    1928import android.os.Environment;
     29import android.os.Looper;
    2030import android.app.Activity;
     31import android.app.Dialog;
     32import android.app.ProgressDialog;
    2133import android.content.Context;
    2234import android.content.Intent;
     
    6678    private ArrayList<SignatureErrorDetail> errorList;
    6779   
     80        // Progress Dialog
     81    private ProgressDialog pDialog;
     82   
     83    // Progress dialog type (0 - for Horizontal progress bar)
     84    public static final int progress_bar_type = 0;
     85   
    6886        @Override
    6987        protected void onCreate(Bundle savedInstanceState) {
     
    86104        button_finish = (LinearLayout) this.findViewById(R.id.button_finish_zone);
    87105       
    88         Bundle bundle=getIntent().getExtras();
    89                 fileToVerify = bundle.getString("fileToVerify");
    90                 fileToVerifyExtension = bundle.getString("fileExtension");
    91                 mimeTypeFileToVerify = getMimeType(fileToVerify);
    92                
    93                 // inicializa la lista de objetos de errores de firma
     106        // inicializa la lista de objetos de errores de firma
    94107                errorList = new ArrayList<SignatureErrorDetail>();
    95 
    96                
    97                
    98                 if (fileToVerifyExtension.equals("bdoc")){
    99                         // ejecutar la verificacion             
    100                         doBdocVerification(fileToVerify);
    101                 }else{
    102                         Toast.makeText(getApplicationContext(), "¡Por Implementar!", Toast.LENGTH_SHORT).show();
    103                        
    104                 }
    105                
     108       
    106109               
    107110                // habilita el click sobre la acción de finalizar la verificacion de firma y regresar
     
    147150               
    148151        });
     152               
     153        // chequear si intent tiene data
     154        final android.content.Intent intent = getIntent();
     155
     156        final Bundle bundle = getIntent().getExtras();
     157       
     158              if (intent != null) {
     159                  Toast.makeText(getApplicationContext(), "intent != null", Toast.LENGTH_SHORT).show();
     160
     161                  final android.net.Uri data = intent.getData ();
     162                 
     163                      if (data != null) {
     164                          Toast.makeText(getApplicationContext(), "data != null", Toast.LENGTH_SHORT).show();
     165                         
     166                          // verificar el tipo de scheme
     167                          String scheme = data.getScheme();
     168                           
     169                          // verificacion de un archivo que esta en el dispositivo
     170                          if (scheme.equals("file")) {
     171                                  Toast.makeText(getApplicationContext(), "file: "+data.getPath(), Toast.LENGTH_SHORT).show();
     172                                 
     173                                  // verificar el archivo
     174                                  if (data.getPath().endsWith("bdoc")){
     175                                                        // ejecutar la verificacion             
     176                                                        doBdocVerification(data.getPath());
     177                                                }else{
     178                                                        Toast.makeText(getApplicationContext(), "¡Por Implementar!", Toast.LENGTH_SHORT).show();
     179                                                       
     180                                                }
     181                                 
     182                          }
     183                           
     184                          // verificacion de un archivo que se debe descargar
     185                          if (scheme.equals("https")) {
     186                                  Toast.makeText(getApplicationContext(), "scheme: "+data.toString(), Toast.LENGTH_SHORT).show();
     187                                 
     188                                  Toast.makeText(getApplicationContext(), "externalStorage: "+Environment.getExternalStorageDirectory().toString(), Toast.LENGTH_SHORT).show();
     189                                 
     190                                 
     191                                  new DownloadFileFromURL().execute(data.toString());
     192                                  //new DownloadFileFromURL().execute("http://farm1.static.flickr.com/114/298125983_0e4bf66782_b.jpg");
     193                                 
     194                                  //Toast.makeText(getApplicationContext(), "****despues de execute()", Toast.LENGTH_SHORT).show();
     195                                  // verificar el archivo
     196                          }
     197                         
     198                         
     199                          return;
     200                      }
     201                     
     202                      // verificacion de archivo desde la Activity principal
     203                      if (bundle != null) {
     204                        fileToVerify = bundle.getString("fileToVerify");
     205                        fileToVerifyExtension = bundle.getString("fileExtension");
     206                        mimeTypeFileToVerify = getMimeType(fileToVerify);
     207                                       
     208                        Toast.makeText(getApplicationContext(), "fileToVerify: "+fileToVerify, Toast.LENGTH_SHORT).show();
     209                       
     210                        if (fileToVerifyExtension.equals("bdoc")){
     211                                        // ejecutar la verificacion             
     212                                        doBdocVerification(fileToVerify);
     213                                }else{
     214                                        Toast.makeText(getApplicationContext(), "¡Por Implementar!", Toast.LENGTH_SHORT).show();
     215                                       
     216                                }
     217                       
     218                        //return;
     219                      }
     220                                 
     221              }else{
     222                  Toast.makeText(getApplicationContext(), "intent == null", Toast.LENGTH_SHORT).show();
     223              }
     224       
     225       
     226            //Bundle bundle=getIntent().getExtras();
     227                //fileToVerify = bundle.getString("fileToVerify");
     228                //fileToVerifyExtension = bundle.getString("fileExtension");
     229                //mimeTypeFileToVerify = getMimeType(fileToVerify);
     230                //Toast.makeText(getApplicationContext(), "fileToVerify: "+fileToVerify, Toast.LENGTH_SHORT).show();
     231               
     232               
     233                /*             
     234                if (fileToVerifyExtension.equals("bdoc")){
     235                        // ejecutar la verificacion             
     236                        doBdocVerification(fileToVerify);
     237                }else{
     238                        Toast.makeText(getApplicationContext(), "¡Por Implementar!", Toast.LENGTH_SHORT).show();
     239                       
     240                }
     241                */
     242               
     243               
    149244       
    150245        }
     
    152247       
    153248       
     249       
     250       
     251        @Override
     252        public void onStart () {
     253               
     254                android.util.Log.d ("**onStart(): ", " onStart");
     255                super.onStart ();
     256               
     257               
     258                final android.content.Intent intent = getIntent ();
     259               
     260                if (intent != null)
     261              {
     262                 android.util.Log.d ("**onStart(): ", "> Got intent : " + intent);
     263
     264                 final android.net.Uri data = intent.getData ();
     265
     266                 if (data != null)
     267                 {
     268                    android.util.Log.d ("**onStart(): ", "> Got data   : " + data);
     269
     270                    final String filePath = data.getEncodedPath ();
     271
     272                    android.util.Log.d ("**onStart(): ", "> Open file  : " + filePath);
     273
     274                    // file loading comes here.
     275                 } // if
     276              } // if
     277              android.util.Log.d ("**onStart(): ", "- saliendo onStart");
     278              return;
     279       
     280        }
    154281       
    155282       
     
    308435                    signerListView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {
    309436
    310                         String ss = "hola mundo";
     437                       
    311438                                @Override
    312439                                public void onItemClick(AdapterView<?> parent, View view,
     
    690817        }
    691818       
     819        /**
     820     * Showing Dialog for downloading file
     821     * */
     822    @Override
     823    protected Dialog onCreateDialog(int id) {
     824        switch (id) {
     825        case progress_bar_type: // we set this to 0
     826            pDialog = new ProgressDialog(this);
     827            pDialog.setMessage("Downloading file. Please wait...");
     828            pDialog.setIndeterminate(false);
     829            pDialog.setMax(100);
     830            pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
     831            pDialog.setCancelable(true);
     832            pDialog.show();
     833            return pDialog;
     834        default:
     835            return null;
     836        }
     837    }
     838       
     839        // clase para descargar archivo
     840        private class DownloadFileFromURL extends AsyncTask<String, String, String> {
     841
     842               
     843                /**
     844         * Before starting background thread
     845         * Show Progress Bar Dialog
     846         * */
     847        @Override
     848        protected void onPreExecute() {
     849            super.onPreExecute();
     850            showDialog(progress_bar_type);
     851        }
     852               
     853               
     854        /**
     855         * Downloading file in background thread
     856         * */
     857        @Override
     858        protected String doInBackground(String... f_url) {
     859           
     860                // para solventar error:
     861                // Can't create handler inside thread that has not called Looper.prepare()
     862                Looper.prepare();
     863               
     864                int count;
     865           
     866            String outputString = null;
     867            try {
     868                Toast.makeText(getApplicationContext(), "doInBackground", Toast.LENGTH_SHORT).show();
     869                Log.d("doInBackground", "log");
     870               
     871                URL url = new URL(f_url[0]);
     872                //URLConnection conection = url.openConnection();
     873                HttpURLConnection conection = (HttpURLConnection) url.openConnection();
     874                conection.connect();
     875               
     876               
     877               
     878                // this will be useful so that you can show a tipical 0-100% progress bar
     879                int lenghtOfFile = conection.getContentLength();
     880 
     881                // download the file
     882                //InputStream input = new BufferedInputStream(url.openStream(), 8192);
     883                InputStream input = new BufferedInputStream(url.openStream());
     884 
     885               
     886                File rootDir = Environment.getExternalStorageDirectory();
     887                // Output stream
     888                //OutputStream output = new FileOutputStream("/sdcard/downloaded.jpg");
     889                OutputStream output = new FileOutputStream(new File(rootDir+"/TibisayMovil/", "descarga.bdoc"));
     890 
     891                byte data[] = new byte[1024];
     892 
     893                long total = 0;
     894 
     895                while ((count = input.read(data)) != -1) {
     896                    total += count;
     897                    // publishing the progress....
     898                    // After this onProgressUpdate will be called
     899                    publishProgress(""+(int)((total*100)/lenghtOfFile));
     900 
     901                    // writing data to file
     902                    //output.write(data, 0, count);
     903                }
     904 
     905                // flushing output
     906                output.flush();
     907 
     908                // closing streams
     909                output.close();
     910               
     911                input.close();
     912               
     913 
     914            } catch (Exception e) {
     915               
     916                Log.e("Error: ", e.getMessage());
     917                outputString = e.getMessage();
     918               
     919               
     920            }
     921 
     922            //return null;
     923            return outputString;
     924           
     925        }
     926       
     927        /**
     928         * Updating progress bar
     929         * */
     930        protected void onProgressUpdate(String... progress) {
     931            // setting progress percentage
     932            pDialog.setProgress(Integer.parseInt(progress[0]));
     933        }
     934       
     935        /**
     936         * After completing background task
     937         * Dismiss the progress dialog
     938         * **/
     939        @Override
     940        protected void onPostExecute(String file_url) {
     941            // dismiss the dialog after the file was downloaded
     942            dismissDialog(progress_bar_type);
     943 
     944            // Displaying downloaded image into image view
     945            // Reading image path from sdcard
     946            //String filePath = Environment.getExternalStorageDirectory().toString() + "/TibisayMovil" +"/downloaded.bdoc";
     947            Toast.makeText(getApplicationContext(), "onPostExecute "  , Toast.LENGTH_SHORT).show();
     948            Toast.makeText(getApplicationContext(), file_url  , Toast.LENGTH_LONG).show();
     949            // setting downloaded into image view
     950            //my_image.setImageDrawable(Drawable.createFromPath(imagePath));
     951        }
     952       
     953                       
     954               
     955        }
     956       
     957
     958
     959               
    692960       
    693961}
  • TibisayMovil/src/ve/gob/cenditel/tibisaymovil/CertificateRepositoryActivity.java

    r09c6eb7 rc95e4a6  
    99import android.content.Intent;
    1010import android.os.Bundle;
     11import android.util.Log;
    1112import android.view.View;
    1213import android.view.View.OnClickListener;
     
    5051        }
    5152    };
     53
     54    @Override
     55    protected void onActivityResult(int requestCode, int resultCode,
     56            Intent data) {
     57       if (resultCode == RESULT_OK) {
     58           
     59           //startActivity(new Intent(Intent.ACTION_VIEW, data));
     60           Log.d("CertificateRepositoryActivity: ", "onActivityResult -> RESULT_OK");
     61           
     62        }
     63    }
    5264
    5365
  • TibisayMovil/src/ve/gob/cenditel/tibisaymovil/PKCS12FilePickerActivity.java

    r09c6eb7 rc95e4a6  
    160160
    161161            if (file.isDirectory()) {
    162                 image.setImageResource(R.drawable.ico_carpeta);
    163             } else {
    164                 image.setImageResource(R.drawable.ico_archivo);                 
     162                //image.setImageResource(R.drawable.ico_carpeta);
     163                image.setImageResource(R.drawable.ic_carpeta);
     164            } else {
     165                //image.setImageResource(R.drawable.ico_archivo);
     166                image.setImageResource(R.drawable.ic_archivo);
    165167            }
    166168
Note: See TracChangeset for help on using the changeset viewer.