/[zanavi_public1]/navit/navit/android/src/com/zoffcc/applications/zanavi/NavitAddressSearchActivity.java
ZANavi

Diff of /navit/navit/android/src/com/zoffcc/applications/zanavi/NavitAddressSearchActivity.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 30 Revision 31
57import android.widget.TextView; 57import android.widget.TextView;
58 58
59public class NavitAddressSearchActivity extends Activity 59public class NavitAddressSearchActivity extends Activity
60{ 60{
61 private EditText address_string; 61 private EditText address_string;
62 private EditText hn_string;
62 private CheckBox pm_checkbox; 63 private CheckBox pm_checkbox;
63 private CheckBox hdup_checkbox; 64 private CheckBox hdup_checkbox;
64 private CheckBox ff_checkbox; 65 private CheckBox ff_checkbox;
65 private String search_type; 66 private String search_type;
66 private int search_country_id = 0; 67 private int search_country_id = 0;
89 addr_view.setText(Navit.get_text("Enter Destination")); //TRANS 90 addr_view.setText(Navit.get_text("Enter Destination")); //TRANS
90 addr_view.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20f); 91 addr_view.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20f);
91 addr_view.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); 92 addr_view.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
92 addr_view.setPadding(4, 4, 4, 4); 93 addr_view.setPadding(4, 4, 4, 4);
93 94
95 // address: label and text field
96 TextView addrhn_view = new TextView(this);
97 addrhn_view.setText(Navit.get_text("Housenumber")); //TRANS
98 addrhn_view.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20f);
99 addrhn_view.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
100 addrhn_view.setPadding(4, 4, 4, 4);
101
94 // partial match checkbox 102 // partial match checkbox
95 pm_checkbox = new CheckBox(this); 103 pm_checkbox = new CheckBox(this);
96 pm_checkbox.setText(Navit.get_text("partial match")); //TRANS 104 pm_checkbox.setText(Navit.get_text("partial match")); //TRANS
97 pm_checkbox.setChecked(false); 105 pm_checkbox.setChecked(false);
98 pm_checkbox.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); 106 pm_checkbox.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
99 pm_checkbox.setGravity(Gravity.CENTER); 107 pm_checkbox.setGravity(Gravity.CENTER);
100 108
101 // partial match checkbox 109 // partial match checkbox
102 hdup_checkbox = new CheckBox(this); 110 hdup_checkbox = new CheckBox(this);
103 hdup_checkbox.setText(Navit.get_text("hide duplicates")); //TRANS 111 hdup_checkbox.setText(Navit.get_text("hide duplicates")); //TRANS
104 hdup_checkbox.setChecked(false); 112 hdup_checkbox.setChecked(true);
105 hdup_checkbox.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); 113 hdup_checkbox.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
106 hdup_checkbox.setGravity(Gravity.CENTER); 114 hdup_checkbox.setGravity(Gravity.CENTER);
107 115
108 // full file checkbox 116 // full file checkbox
109 ff_checkbox = new CheckBox(this); 117 ff_checkbox = new CheckBox(this);
118 if (!Navit.use_index_search)
119 {
110 ff_checkbox.setText(Navit.get_text("search full mapfile [BETA]")); //TRANS 120 ff_checkbox.setText(Navit.get_text("search full mapfile [BETA]")); //TRANS
111 ff_checkbox.setChecked(false); 121 ff_checkbox.setChecked(false);
112 ff_checkbox.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); 122 ff_checkbox.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
113 ff_checkbox.setGravity(Gravity.CENTER); 123 ff_checkbox.setGravity(Gravity.CENTER);
114 124
115 ff_checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() 125 ff_checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener()
116 { 126 {
117 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) 127 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
118 { 128 {
119 if (isChecked) 129 if (isChecked)
120 {
121 try
122 { 130 {
131 try
132 {
123 search_country_select.setVisibility(View.INVISIBLE); 133 search_country_select.setVisibility(View.INVISIBLE);
124 hdup_checkbox.setVisibility(View.INVISIBLE); 134 hdup_checkbox.setVisibility(View.INVISIBLE);
135 }
136 catch (Exception e)
137 {
138
139 }
125 } 140 }
126 catch (Exception e) 141 else
127 { 142 {
143 try
144 {
145 search_country_select.setVisibility(View.VISIBLE);
146 hdup_checkbox.setVisibility(View.VISIBLE);
147 }
148 catch (Exception e)
149 {
128 150
151 }
129 } 152 }
130 } 153 }
131 else
132 {
133 try
134 {
135 search_country_select.setVisibility(View.VISIBLE);
136 hdup_checkbox.setVisibility(View.VISIBLE);
137 }
138 catch (Exception e)
139 {
140
141 }
142 }
143 }
144 }); 154 });
145 155 }
146 // search button 156 // search button
147 final Button btnSearch = new Button(this); 157 final Button btnSearch = new Button(this);
148 btnSearch.setText(Navit.get_text("Search")); //TRANS 158 btnSearch.setText(Navit.get_text("Search")); //TRANS
149 btnSearch.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); 159 btnSearch.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
150 btnSearch.setGravity(Gravity.CENTER); 160 btnSearch.setGravity(Gravity.CENTER);
162 this.search_country_id = getIntent().getExtras().getInt("search_country_id"); 172 this.search_country_id = getIntent().getExtras().getInt("search_country_id");
163 } 173 }
164 174
165 // select country button 175 // select country button
166 search_country_select = new Button(this); 176 search_country_select = new Button(this);
177 if (!Navit.use_index_search)
178 {
179
167 search_country_select.setText(NavitAddressSearchCountrySelectActivity.CountryList_Human[search_country_id][2]); 180 search_country_select.setText(NavitAddressSearchCountrySelectActivity.CountryList_Human[search_country_id][2]);
168 search_country_select.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); 181 search_country_select.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
169 search_country_select.setGravity(Gravity.CENTER); 182 search_country_select.setGravity(Gravity.CENTER);
170 search_country_select.setOnClickListener(new View.OnClickListener() 183 search_country_select.setOnClickListener(new View.OnClickListener()
171 { 184 {
172 public void onClick(View v) 185 public void onClick(View v)
173 { 186 {
174 start_country_select_form(); 187 start_country_select_form();
175 } 188 }
176 }); 189 });
190 }
177 191
178 // title 192 // title
179 try 193 try
180 { 194 {
181 String s = getIntent().getExtras().getString("title"); 195 String s = getIntent().getExtras().getString("title");
204 } 218 }
205 } 219 }
206 } 220 }
207 catch (Exception e) 221 catch (Exception e)
208 { 222 {
223 }
224
225 if (Navit.use_index_search)
226 {
227
228 // house number string
229 try
230 {
231 hn_string = new EditText(this);
232 hn_string.setText(getIntent().getExtras().getString("hn_string"));
233 }
234 catch (Exception e)
235 {
236 }
209 } 237 }
210 238
211 // address string 239 // address string
212 try 240 try
213 { 241 {
221 // actually adding the views (that have layout set on them) to the panel 249 // actually adding the views (that have layout set on them) to the panel
222 panel.addView(addr_view); 250 panel.addView(addr_view);
223 panel.addView(address_string); 251 panel.addView(address_string);
224 if (this.search_type.equals("offline")) 252 if (this.search_type.equals("offline"))
225 { 253 {
254 if (Navit.use_index_search)
255 {
256 panel.addView(addrhn_view);
257 panel.addView(hn_string);
258 }
259 if (!Navit.use_index_search)
260 {
226 panel.addView(search_country_select); 261 panel.addView(search_country_select);
262 }
227 panel.addView(pm_checkbox); 263 panel.addView(pm_checkbox);
228 panel.addView(hdup_checkbox); 264 panel.addView(hdup_checkbox);
265 if (!Navit.use_index_search)
266 {
229 panel.addView(ff_checkbox); 267 panel.addView(ff_checkbox);
268 }
230 } 269 }
231 panel.addView(btnSearch); 270 panel.addView(btnSearch);
232 271
233 sv.addView(panel); 272 sv.addView(panel);
234 273
268 Intent resultIntent = new Intent(); 307 Intent resultIntent = new Intent();
269 resultIntent.putExtra("address_string", NavitAddressSearchActivity.this.address_string.getText().toString()); 308 resultIntent.putExtra("address_string", NavitAddressSearchActivity.this.address_string.getText().toString());
270 309
271 if (this.search_type.endsWith("offline")) 310 if (this.search_type.endsWith("offline"))
272 { 311 {
312 if (Navit.use_index_search)
313 {
314 resultIntent.putExtra("hn_string", NavitAddressSearchActivity.this.hn_string.getText().toString());
315 }
316
273 if (NavitAddressSearchActivity.this.pm_checkbox.isChecked()) 317 if (NavitAddressSearchActivity.this.pm_checkbox.isChecked())
274 { 318 {
275 resultIntent.putExtra("partial_match", "1"); 319 resultIntent.putExtra("partial_match", "1");
276 } 320 }
277 else 321 else
303 { 347 {
304 // on error assume its turned off 348 // on error assume its turned off
305 resultIntent.putExtra("full_file_search", "0"); 349 resultIntent.putExtra("full_file_search", "0");
306 } 350 }
307 351
352 try
353 {
308 resultIntent.putExtra("address_country_iso2", NavitAddressSearchCountrySelectActivity.CountryList_Human[search_country_id][0]); 354 resultIntent.putExtra("address_country_iso2", NavitAddressSearchCountrySelectActivity.CountryList_Human[search_country_id][0]);
309 resultIntent.putExtra("search_country_id", search_country_id); 355 resultIntent.putExtra("search_country_id", search_country_id);
310 if (NavitAddressSearchCountrySelectActivity.CountryList_Human[search_country_id][0].equals("*D")) 356 if (NavitAddressSearchCountrySelectActivity.CountryList_Human[search_country_id][0].equals("*D"))
311 { 357 {
312 resultIntent.putExtra("address_country_flags", 1); 358 resultIntent.putExtra("address_country_flags", 1);
313 } 359 }
314 else if (NavitAddressSearchCountrySelectActivity.CountryList_Human[search_country_id][0].equals("*A")) 360 else if (NavitAddressSearchCountrySelectActivity.CountryList_Human[search_country_id][0].equals("*A"))
315 { 361 {
316 resultIntent.putExtra("address_country_flags", 3); 362 resultIntent.putExtra("address_country_flags", 3);
317 } 363 }
318 else 364 else
319 { 365 {
366 resultIntent.putExtra("address_country_flags", 2);
367 }
368 }
369 catch (Exception e)
370 {
371 // index search
372 resultIntent.putExtra("address_country_iso2", "X");
373 resultIntent.putExtra("search_country_id", 0);
320 resultIntent.putExtra("address_country_flags", 2); 374 resultIntent.putExtra("address_country_flags", 2);
321 } 375 }
322 } 376 }
323 377
324 setResult(Activity.RESULT_OK, resultIntent); 378 setResult(Activity.RESULT_OK, resultIntent);

Legend:
Removed from v.30  
changed lines
  Added in v.31

   
Visit the ZANavi Wiki