source: dispositivos_moviles/TibisayMovil/src/ve/gob/cenditel/tibisaymovil/SignResultHandwrittenSignatureActivity.java @ 67541a6

Last change on this file since 67541a6 was 67541a6, checked in by Jose Ruiz <joseruiz@…>, 10 years ago

Agregando preferencias de imagen de firma y firma manuscrita con imagen predeterminada

  • Property mode set to 100644
File size: 4.8 KB
Line 
1package ve.gob.cenditel.tibisaymovil;
2
3
4import java.io.File;
5
6import android.app.Activity;
7import android.content.Intent;
8import android.net.Uri;
9import android.os.Bundle;
10import android.util.Log;
11import android.view.View;
12import android.view.View.OnClickListener;
13import android.view.Window;
14import android.webkit.MimeTypeMap;
15import android.widget.LinearLayout;
16import android.widget.TextView;
17import android.widget.Toast;
18
19public 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
47        TextView archivo_para_firm = (TextView) this.findViewById(R.id.archivo_original_a_firmar);
48        TextView imagen_utlizada= (TextView) this.findViewById(R.id.archivo_descifrado);
49        TextView archivo_firmado = (TextView) this.findViewById(R.id.destinatario);
50
51        archivo_para_firm.setText(fileToSign);
52        imagen_utlizada.setText(imageCaptured);
53        archivo_firmado.setText(pathFileSigned+fileSigned);
54
55        button_share = (LinearLayout) this.findViewById(R.id.button_remove_certificate_zone);
56        button_finish = (LinearLayout) this.findViewById(R.id.button_add_certificate_zone);         
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        });
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)));
105        }
106       
107        private void shareIt() {
108               
109                Intent shareIntent = new Intent();
110                shareIntent.setAction(Intent.ACTION_SEND);
111                Toast.makeText(SignResultHandwrittenSignatureActivity.this,pathFileSigned + fileSigned,Toast.LENGTH_LONG).show();
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        }
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    }
128}
Note: See TracBrowser for help on using the repository browser.