[a8ff2b6] | 1 | package ve.gob.cenditel.tibisaymovil; |
---|
| 2 | |
---|
[a8bb2bb] | 3 | import ve.gob.cenditel.tibisaymovil.R.color; |
---|
[09c6eb7] | 4 | import android.os.Build; |
---|
[a8ff2b6] | 5 | import android.os.Bundle; |
---|
| 6 | import android.app.Activity; |
---|
[37467be] | 7 | import android.app.AlertDialog; |
---|
[a8ff2b6] | 8 | import android.content.Context; |
---|
[37467be] | 9 | import android.content.DialogInterface; |
---|
[a8ff2b6] | 10 | import android.content.Intent; |
---|
| 11 | import android.util.Log; |
---|
| 12 | import android.view.Menu; |
---|
| 13 | import android.view.View; |
---|
[08c45bd] | 14 | import android.view.Window; |
---|
[a8ff2b6] | 15 | import android.widget.AdapterView; |
---|
| 16 | import android.widget.AdapterView.OnItemClickListener; |
---|
[37467be] | 17 | import android.widget.ArrayAdapter; |
---|
[a8ff2b6] | 18 | import android.widget.ListView; |
---|
| 19 | import android.widget.TextView; |
---|
| 20 | import android.widget.Toast; |
---|
| 21 | |
---|
| 22 | //public class TibisayMovilActivity extends KeyChainClientActivity { |
---|
| 23 | //implements OnItemClickListener, OnClickListener { |
---|
| 24 | public class TibisayMovilActivity extends Activity { |
---|
| 25 | |
---|
| 26 | @Override |
---|
| 27 | protected void onCreate(Bundle savedInstanceState) { |
---|
| 28 | super.onCreate(savedInstanceState); |
---|
| 29 | |
---|
[08c45bd] | 30 | final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); |
---|
| 31 | setContentView(R.layout.activity_main); |
---|
[37467be] | 32 | if(customTitleSupported) |
---|
| 33 | getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar); |
---|
[08c45bd] | 34 | |
---|
[a8ff2b6] | 35 | // listview de funciones |
---|
| 36 | final ListView listViewFunctions = (ListView) findViewById(R.id.listViewFunctions); |
---|
| 37 | |
---|
[37467be] | 38 | String[] values = new String[] {getString(R.string.firmar), |
---|
| 39 | getString(R.string.verificar), |
---|
| 40 | getString(R.string.cifrar), |
---|
| 41 | getString(R.string.descifrar), |
---|
| 42 | getString(R.string.compartir), |
---|
| 43 | getString(R.string.certificados) }; |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | FunctionListAdapter ad = new FunctionListAdapter(this, values); |
---|
| 47 | listViewFunctions.setAdapter(ad); |
---|
[a8ff2b6] | 48 | |
---|
| 49 | |
---|
[37467be] | 50 | /*************** Dialogos de submenus *******************/ |
---|
| 51 | //Crear dialogo de opciones para firmar |
---|
| 52 | final AlertDialog sign_dialog = makeSignatureOptionsDialog(); |
---|
[a8ff2b6] | 53 | |
---|
[37467be] | 54 | |
---|
[a8ff2b6] | 55 | |
---|
| 56 | listViewFunctions.setOnItemClickListener(new OnItemClickListener(){ |
---|
| 57 | |
---|
| 58 | @Override |
---|
| 59 | public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, |
---|
| 60 | long arg3) { |
---|
| 61 | // TODO Auto-generated method stub |
---|
| 62 | Context context = getApplicationContext(); |
---|
| 63 | //CharSequence text = "Click!"; |
---|
| 64 | int duration = Toast.LENGTH_SHORT; |
---|
| 65 | //Toast.makeText(context, text, duration).show(); |
---|
| 66 | |
---|
| 67 | View curr = arg0.getChildAt((int) arg3); |
---|
[08c45bd] | 68 | TextView c = (TextView)curr.findViewById(R.id.textListMainMenu); |
---|
[a8ff2b6] | 69 | String function = c.getText().toString(); |
---|
| 70 | //Toast.makeText(context, function, duration).show(); |
---|
[37467be] | 71 | |
---|
[5147e01] | 72 | // seleccion de firmar |
---|
[37467be] | 73 | if(function.equals(getString(R.string.firmar))) { |
---|
| 74 | sign_dialog.show(); |
---|
| 75 | } |
---|
[a8ff2b6] | 76 | |
---|
[5147e01] | 77 | // seleccion de verificar |
---|
| 78 | if(function.equals(getString(R.string.verificar))) { |
---|
| 79 | Toast.makeText(context, "VERIFICAR", duration).show(); |
---|
| 80 | verifyBDOCSignedFile(); |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | // seleccion de gestionar certificados |
---|
[a8ff2b6] | 84 | if (function.equals("Certificados")){ |
---|
[37467be] | 85 | Toast.makeText(context, "Gestionar repositorio", duration).show(); |
---|
[a8ff2b6] | 86 | |
---|
[09c6eb7] | 87 | // Chequeo de version del API de Android para creacion de repositorio |
---|
| 88 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH){ |
---|
| 89 | //RelativeLayout certTab = (RelativeLayout) this.findViewById(R.id.linetab2); |
---|
| 90 | //certTab.setVisibility(View.VISIBLE); |
---|
| 91 | //this.tabsListener.setKeyChainController(this.keyChainController); |
---|
| 92 | Toast.makeText(context, "API < 4.0", duration).show(); |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | //manageKeyChain(); |
---|
[a8ff2b6] | 96 | |
---|
| 97 | // lanzar activity de gestion de repositorio |
---|
[37467be] | 98 | testRepository(); |
---|
[a8ff2b6] | 99 | } |
---|
| 100 | |
---|
| 101 | } |
---|
[37467be] | 102 | }); //setOnItemClickListener |
---|
| 103 | } // end onCreate |
---|
[a8ff2b6] | 104 | |
---|
| 105 | @Override |
---|
| 106 | public boolean onCreateOptionsMenu(Menu menu) { |
---|
| 107 | // Inflate the menu; this adds items to the action bar if it is present. |
---|
| 108 | getMenuInflater().inflate(R.menu.main, menu); |
---|
| 109 | return true; |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | /* |
---|
| 113 | @Override |
---|
| 114 | public void setAlias(String alias) { |
---|
| 115 | |
---|
| 116 | if (alias == null) { |
---|
| 117 | finish(); |
---|
| 118 | return; |
---|
| 119 | } |
---|
| 120 | |
---|
| 121 | this.privateKeyAlias = alias; |
---|
| 122 | |
---|
| 123 | //Intent intent = new Intent(this, CertValidatorActivity.class); |
---|
| 124 | //intent.putExtra(IntentExtraField.ALIAS, alias); |
---|
| 125 | //intent.putParcelableArrayListExtra(IntentExtraField.FILES, TypeUtils.convertToUriArrayList(this.selected)); |
---|
| 126 | //startActivityForResult(intent, ActivityResult.CHECK_CERTIFICATE_VALIDITY); |
---|
| 127 | |
---|
| 128 | } |
---|
| 129 | */ |
---|
| 130 | |
---|
[37467be] | 131 | // private void manageKeyChain(){ |
---|
| 132 | // // |
---|
| 133 | // //Intent intent = new Intent(this, PKCS12FilePickerActivity.class); |
---|
| 134 | // //startActivityForResult(intent, ActivityResult.IMPORT_CERTIFICATE); |
---|
| 135 | // //KeyChainStrategy.getInstance().choosePrivateKeyAlias(); |
---|
| 136 | // } |
---|
[a8ff2b6] | 137 | |
---|
| 138 | private void testRepository(){ |
---|
[09c6eb7] | 139 | Intent intent = new Intent(this, CertificateRepositoryActivity.class); |
---|
| 140 | startActivity(intent); |
---|
[a8ff2b6] | 141 | } |
---|
| 142 | |
---|
[37467be] | 143 | private void fileToSignHandwrittenSignature(){ |
---|
| 144 | Intent intent = new Intent(this, FileToSignHandwrittenSignatureActivity.class); |
---|
| 145 | startActivity(intent); |
---|
| 146 | } |
---|
[5147e01] | 147 | |
---|
[a8ff2b6] | 148 | |
---|
[5147e01] | 149 | // lanza activity para verificar un documento firmado |
---|
| 150 | private void verifyBDOCSignedFile(){ |
---|
| 151 | //Intent intent = new Intent(this, FileToSignHandwrittenSignatureActivity.class); |
---|
| 152 | Intent intent = new Intent(this, FileToVerifySignatureActivity.class); |
---|
| 153 | startActivity(intent); |
---|
| 154 | } |
---|
[a8ff2b6] | 155 | |
---|
[37467be] | 156 | //Crea dialogo de opciones para firma electronica |
---|
| 157 | public AlertDialog makeSignatureOptionsDialog() { |
---|
| 158 | final String[] option = new String[] {getString(R.string.firmar_man_pdf), getString(R.string.firmar_elec_pdf), getString(R.string.firmar_pkcs7) }; |
---|
| 159 | ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, |
---|
| 160 | android.R.layout.select_dialog_item, option); |
---|
| 161 | AlertDialog.Builder builder = new AlertDialog.Builder(this); |
---|
| 162 | |
---|
| 163 | builder.setTitle(getString(R.string.seleccione_opcion)); |
---|
| 164 | builder.setAdapter(adapter, new DialogInterface.OnClickListener() { |
---|
| 165 | |
---|
| 166 | public void onClick(DialogInterface dialog, int which) { |
---|
| 167 | |
---|
| 168 | switch (which) { |
---|
| 169 | case 0: // Firma Manuscrita PDF |
---|
| 170 | Log.i("DEBUG", "antes de activity call"); |
---|
| 171 | fileToSignHandwrittenSignature(); |
---|
| 172 | break; |
---|
| 173 | case 1: // Firma Electronica PDF |
---|
| 174 | |
---|
| 175 | break; |
---|
| 176 | case 2: // Firma PKCS7 |
---|
| 177 | |
---|
| 178 | break; |
---|
| 179 | |
---|
| 180 | default: |
---|
| 181 | break; |
---|
| 182 | } |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | }); |
---|
| 186 | |
---|
| 187 | return builder.create(); |
---|
| 188 | } |
---|
[a8ff2b6] | 189 | } |
---|