1 | /* |
---|
2 | Tibisay Movil |
---|
3 | |
---|
4 | Copyright (C) 2013 Antonio Araujo (aaraujo@cenditel.gob.ve), Jose Ruiz |
---|
5 | (jruiz@cenditel.gob.ve), Fundacion Centro Nacional de Desarrollo e |
---|
6 | Investigacion en Tecnologias Libres - CENDITEL. |
---|
7 | |
---|
8 | La Fundación CENDITEL concede permiso para usar, copiar, distribuir y/o |
---|
9 | modificar este programa, reconociendo el derecho que la humanidad posee al |
---|
10 | libre acceso al conocimiento, bajo los términos de la licencia de software |
---|
11 | GPL versión 2.0 de la Free Software Foundation. |
---|
12 | |
---|
13 | Este programa se distribuye con la esperanza de que sea util, pero SIN |
---|
14 | NINGUNA GARANTIA; tampoco las implicitas garantias de MERCANTILIDAD o |
---|
15 | ADECUACION A UN PROPOSITO PARTICULAR. |
---|
16 | |
---|
17 | Para mayor información sobre los términos de la licencia ver el archivo |
---|
18 | llamado "gpl-2.0.txt" en ingles. |
---|
19 | */ |
---|
20 | |
---|
21 | package ve.gob.cenditel.tibisaymovil; |
---|
22 | |
---|
23 | import java.util.ArrayList; |
---|
24 | import java.util.List; |
---|
25 | |
---|
26 | import android.app.Activity; |
---|
27 | import android.content.Intent; |
---|
28 | import android.os.Bundle; |
---|
29 | import android.util.SparseBooleanArray; |
---|
30 | import android.view.View; |
---|
31 | import android.view.Window; |
---|
32 | import android.view.View.OnClickListener; |
---|
33 | import android.widget.AdapterView; |
---|
34 | import android.widget.AdapterView.OnItemClickListener; |
---|
35 | import android.widget.ArrayAdapter; |
---|
36 | import android.widget.Button; |
---|
37 | import android.widget.LinearLayout; |
---|
38 | import android.widget.ListView; |
---|
39 | |
---|
40 | public class FilesToPKCS7SignConfirmationActivity extends Activity implements OnClickListener, OnItemClickListener { |
---|
41 | |
---|
42 | private List<String> uris; |
---|
43 | private ListView listView; |
---|
44 | private LinearLayout next; |
---|
45 | private LinearLayout back; |
---|
46 | private ArrayAdapter<String> listAdapter; |
---|
47 | |
---|
48 | public void onCreate(Bundle savedInstanceState) { |
---|
49 | super.onCreate(savedInstanceState); |
---|
50 | |
---|
51 | final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); |
---|
52 | this.setContentView(R.layout.confirmationlist); |
---|
53 | if(customTitleSupported) |
---|
54 | getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar); |
---|
55 | |
---|
56 | |
---|
57 | this.next = (LinearLayout) this.findViewById(R.id.button_next_zone); |
---|
58 | this.next.setOnClickListener(this); |
---|
59 | |
---|
60 | this.back = (LinearLayout) this.findViewById(R.id.button_back_zone); |
---|
61 | this.back.setOnClickListener(this); |
---|
62 | |
---|
63 | |
---|
64 | this.uris = getIntent().getStringArrayListExtra(IntentExtraField.FILES); |
---|
65 | this.listAdapter = new ArrayAdapter<String>(this,R.layout.confirmation_item, this.uris); |
---|
66 | |
---|
67 | |
---|
68 | this.listView = (ListView) this.findViewById(R.id.confirmation_list); |
---|
69 | this.listView.setAdapter(this.listAdapter); |
---|
70 | this.listView.setOnItemClickListener(this); |
---|
71 | |
---|
72 | this.listAdapter.notifyDataSetChanged(); |
---|
73 | |
---|
74 | //Estilando Barra de titulo |
---|
75 | if(customTitleSupported) |
---|
76 | getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar); |
---|
77 | |
---|
78 | |
---|
79 | } |
---|
80 | |
---|
81 | |
---|
82 | @Override |
---|
83 | public void onStart(){ |
---|
84 | super.onStart(); |
---|
85 | |
---|
86 | for (int i=0;i<this.listView.getCount();i++) |
---|
87 | this.listView.setItemChecked(i, true); |
---|
88 | } |
---|
89 | |
---|
90 | |
---|
91 | @Override |
---|
92 | public void onClick(View v) { |
---|
93 | switch (v.getId()) |
---|
94 | { |
---|
95 | case R.id.button_back_zone: |
---|
96 | finish(); |
---|
97 | break; |
---|
98 | case R.id.button_next_zone: |
---|
99 | |
---|
100 | Intent intent = new Intent(); |
---|
101 | SparseBooleanArray sparse = this.listView.getCheckedItemPositions(); |
---|
102 | ArrayList<String> sublist = new ArrayList<String>(); |
---|
103 | |
---|
104 | for (int i = 0; i < sparse.size(); i++) { |
---|
105 | if( sparse.valueAt(i)== true){ |
---|
106 | sublist.add((String)this.listAdapter.getItem(sparse.keyAt(i))); |
---|
107 | } |
---|
108 | } |
---|
109 | |
---|
110 | if (sublist.size()>0){ |
---|
111 | intent.putStringArrayListExtra(IntentExtraField.FILES, sublist); |
---|
112 | this.setResult(RESULT_OK, intent); |
---|
113 | finish(); |
---|
114 | }else{} |
---|
115 | |
---|
116 | break; |
---|
117 | |
---|
118 | |
---|
119 | } |
---|
120 | |
---|
121 | |
---|
122 | |
---|
123 | |
---|
124 | } |
---|
125 | |
---|
126 | |
---|
127 | @Override |
---|
128 | public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { |
---|
129 | |
---|
130 | |
---|
131 | SparseBooleanArray checked = this.listView.getCheckedItemPositions(); |
---|
132 | boolean found=false; |
---|
133 | |
---|
134 | for (int i=0; i<checked.size() && found == false; i++) { |
---|
135 | if (checked.valueAt(i)) |
---|
136 | found=true; |
---|
137 | |
---|
138 | } |
---|
139 | |
---|
140 | |
---|
141 | if (found==false) |
---|
142 | this.next.setEnabled(false); |
---|
143 | else |
---|
144 | this.next.setEnabled(true); |
---|
145 | |
---|
146 | } |
---|
147 | |
---|
148 | |
---|
149 | |
---|
150 | |
---|
151 | |
---|
152 | |
---|
153 | |
---|
154 | } |
---|
155 | |
---|