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 android.content.Context; |
---|
24 | import android.util.Log; |
---|
25 | import android.view.LayoutInflater; |
---|
26 | import android.view.View; |
---|
27 | import android.view.ViewGroup; |
---|
28 | import android.widget.ArrayAdapter; |
---|
29 | import android.widget.GridView; |
---|
30 | import android.widget.ImageView; |
---|
31 | import android.widget.TextView; |
---|
32 | |
---|
33 | /** |
---|
34 | * Adaptador para mostrar la grid de funciones disponibles al inicio |
---|
35 | * de la aplicación. |
---|
36 | * |
---|
37 | */ |
---|
38 | public class ImageMenuAdapter extends ArrayAdapter<String> { |
---|
39 | private Context mContext; |
---|
40 | |
---|
41 | private final String[] values; |
---|
42 | |
---|
43 | public ImageMenuAdapter(Context context, String[] values) { |
---|
44 | super(context, R.layout.grid_menu_item, values); |
---|
45 | this.mContext = context; |
---|
46 | this.values = values; |
---|
47 | } |
---|
48 | |
---|
49 | |
---|
50 | |
---|
51 | public int getCount() { |
---|
52 | return mThumbIds.length; |
---|
53 | } |
---|
54 | |
---|
55 | public String getItem(int position) { |
---|
56 | return null; |
---|
57 | } |
---|
58 | |
---|
59 | public long getItemId(int position) { |
---|
60 | return 0; |
---|
61 | } |
---|
62 | |
---|
63 | |
---|
64 | // create a new ImageView for each item referenced by the Adapter |
---|
65 | public View getView(int position, View convertView, ViewGroup parent) { |
---|
66 | //ImageView imageView; |
---|
67 | |
---|
68 | LayoutInflater inflater = (LayoutInflater) mContext |
---|
69 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
---|
70 | |
---|
71 | String s = values[position]; |
---|
72 | |
---|
73 | View gridView; |
---|
74 | |
---|
75 | |
---|
76 | if (convertView == null) { // if it's not recycled, initialize some attributes |
---|
77 | |
---|
78 | gridView = new View(mContext); |
---|
79 | |
---|
80 | // get layout from mobile.xml |
---|
81 | gridView = inflater.inflate(R.layout.grid_menu_item, null); |
---|
82 | |
---|
83 | // set value into textview |
---|
84 | TextView textView = (TextView) gridView.findViewById(R.id.textGridMainMenu); |
---|
85 | textView.setText(values[position]); |
---|
86 | // ocultar el texto mientras se prueba el icono |
---|
87 | textView.setVisibility(View.GONE); |
---|
88 | |
---|
89 | // set image based on selected text |
---|
90 | ImageView imageView = (ImageView) gridView.findViewById(R.id.imageGridMainMenu); |
---|
91 | |
---|
92 | String function = values[position]; |
---|
93 | if (s.equals(mContext.getString(R.string.firmar))) { |
---|
94 | //imageView.setImageResource(R.drawable.ic_pluma); |
---|
95 | imageView.setImageResource(R.drawable.ic_firmar_new); |
---|
96 | } else if (s.equals(mContext.getString(R.string.verificar))) { |
---|
97 | //imageView.setImageResource(R.drawable.ic_verify); |
---|
98 | imageView.setImageResource(R.drawable.ic_verificar_new); |
---|
99 | } else if (s.equals(mContext.getString(R.string.cifrar))) { |
---|
100 | //imageView.setImageResource(R.drawable.ic_secure); |
---|
101 | imageView.setImageResource(R.drawable.ic_cifrar_new); |
---|
102 | } else if (s.equals(mContext.getString(R.string.descifrar))) { |
---|
103 | //imageView.setImageResource(R.drawable.ic_not_secure); |
---|
104 | imageView.setImageResource(R.drawable.ic_descifrar_new); |
---|
105 | } else if (s.equals(mContext.getString(R.string.compartir))) { |
---|
106 | //imageView.setImageResource(R.drawable.ic_share); |
---|
107 | imageView.setImageResource(R.drawable.ic_compartir_new); |
---|
108 | } else if (s.equals(mContext.getString(R.string.certificados))) { |
---|
109 | //imageView.setImageResource(R.drawable.ic_management); |
---|
110 | imageView.setImageResource(R.drawable.ic_certificados_new); |
---|
111 | } else if (s.equals(mContext.getString(R.string.preferencias))) { |
---|
112 | //imageView.setImageResource(R.drawable.ic_preferences); |
---|
113 | imageView.setImageResource(R.drawable.ic_preferencias_new); |
---|
114 | } else if (s.equals(mContext.getString(R.string.ayuda))) { |
---|
115 | //imageView.setImageResource(R.drawable.ic_action_help); |
---|
116 | imageView.setImageResource(R.drawable.ic_ayuda_new); |
---|
117 | } else if (s.equals(mContext.getString(R.string.acercade))) { |
---|
118 | //imageView.setImageResource(R.drawable.ic_action_about); |
---|
119 | imageView.setImageResource(R.drawable.ic_acerca_de_new); |
---|
120 | } |
---|
121 | |
---|
122 | |
---|
123 | imageView = new ImageView(mContext); |
---|
124 | imageView.setLayoutParams(new GridView.LayoutParams(85, 85)); |
---|
125 | imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); |
---|
126 | imageView.setPadding(8, 8, 8, 8); |
---|
127 | } else { |
---|
128 | gridView = (View) convertView; |
---|
129 | Log.d("getView: ",s); |
---|
130 | } |
---|
131 | |
---|
132 | |
---|
133 | return gridView; |
---|
134 | } |
---|
135 | |
---|
136 | // references to our images |
---|
137 | private Integer[] mThumbIds = { |
---|
138 | R.drawable.ic_pluma, R.drawable.ic_verify, |
---|
139 | R.drawable.ic_secure, R.drawable.ic_not_secure, |
---|
140 | R.drawable.ic_management, R.drawable.ic_share, |
---|
141 | R.drawable.ic_action_help, R.drawable.ic_action_about, |
---|
142 | R.drawable.ic_preferences |
---|
143 | }; |
---|
144 | |
---|
145 | |
---|
146 | |
---|
147 | } |
---|