\r
\r
import java.lang.reflect.Field;\r
+import java.util.Arrays;
+import java.util.Comparator;
import java.util.Locale;\r
\r
-import android.R.color;\r
import android.app.Activity;\r
import android.app.AlertDialog;\r
import android.content.DialogInterface;\r
import android.content.Intent;\r
import android.content.SharedPreferences;\r
import android.os.Bundle;\r
-import android.os.Message;\r
import android.util.Log;\r
import android.util.TypedValue;\r
import android.view.Gravity;\r
import android.view.View;\r
-import android.view.WindowManager;\r
import android.view.View.OnClickListener;\r
-import android.widget.ArrayAdapter;\r
+import android.view.WindowManager;
import android.widget.Button;\r
import android.widget.CheckBox;\r
import android.widget.EditText;\r
import android.widget.ImageButton;\r
import android.widget.LinearLayout;\r
import android.widget.RelativeLayout;\r
-import android.widget.Spinner;\r
-import android.widget.TextView;\r
import android.widget.RelativeLayout.LayoutParams;\r
+import android.widget.TextView;
\r
\r
public class NavitAddressSearchActivity extends Activity\r
catch (Exception e) {\r
Log.e("NavitAddressSearch", "Failure to get drawable id.", e);\r
}\r
- \r
- \r
return drawableId;\r
}\r
- \r
- \r
+\r
@Override\r
protected void onCreate(Bundle savedInstanceState)\r
{\r
// address: label and text field\r
SharedPreferences settings = getSharedPreferences(Navit.NAVIT_PREFS, MODE_PRIVATE);\r
mCountry = settings.getString("DefaultCountry", null);\r
- \r
+\r
if (mCountry == null)\r
{\r
Locale defaultLocale = Locale.getDefault();\r
edit_settings.putString("DefaultCountry", mCountry);\r
edit_settings.commit();\r
}\r
- \r
+\r
mCountryButton = new ImageButton(this);\r
- \r
+\r
mCountryButton.setImageResource(getDrawableID("country_" + mCountry + "_32_32"));\r
- \r
+\r
mCountryButton.setOnClickListener(new OnClickListener()\r
{\r
public void onClick(View v)\r
pm_checkbox = new CheckBox(this);\r
pm_checkbox.setText(Navit.get_text("partial match")); //TRANS\r
pm_checkbox.setChecked(false);\r
-// pm_checkbox.setLayoutParams(new LayoutParams(LayoutParams,\r
-// LayoutParams.WRAP_CONTENT));\r
pm_checkbox.setGravity(Gravity.CENTER);\r
\r
- \r
\r
// search button\r
final Button btnSearch = new Button(this);\r
});\r
\r
Bundle extras = getIntent().getExtras();\r
- \r
+\r
if ( extras != null )\r
{\r
String title = extras.getString("title");\r
String partial = extras.getString("partial_match");\r
String address = extras.getString("address_string");\r
- \r
+\r
if ( title != null && title.length() > 0)\r
this.setTitle(title);\r
- \r
+\r
if (partial != null && partial.length() > 0)\r
pm_checkbox.setChecked(partial.equals("1"));\r
\r
address_string = new EditText(this);\r
if (address != null)\r
address_string.setText(address);\r
- \r
}\r
\r
LinearLayout searchSettingsLayout = new LinearLayout(this);\r
panel.addView(btnSearch);\r
\r
setContentView(panel);\r
-\r
}\r
\r
private void requestCountryDialog()\r
{\r
- //Message msg = Message.obtain(Navit.N_NavitGraphics.callback_handler, NavitGraphics.msg_type.CLB_COUNTRY_CHOOSER.ordinal());\r
- //msg.sendToTarget();\r
final String [][]all_countries = NavitGraphics.GetAllCountries();\r
+
+ Comparator<String[]> country_comperator = new Comparator<String[]>(){
+ @Override
+ public int compare(String[] object1, String[] object2) {
+ return object1[1].compareTo(object2[1]);
+ }};
+
+ Arrays.sort(all_countries, country_comperator );
\r
AlertDialog.Builder mapModeChooser = new AlertDialog.Builder(this);\r
// ToDo also show icons and country code\r
String []country_name = new String[all_countries.length];\r
- \r
+\r
for (int country_index = 0; country_index < all_countries.length; country_index++)\r
{\r
country_name[country_index] = all_countries[country_index][1];\r
}\r
- \r
+\r
mapModeChooser.setItems(country_name, new DialogInterface.OnClickListener() {\r
public void onClick(DialogInterface dialog, int item) {\r
SharedPreferences settings = getSharedPreferences(Navit.NAVIT_PREFS, MODE_PRIVATE);\r
SharedPreferences.Editor edit_settings = settings.edit();\r
edit_settings.putString("DefaultCountry", mCountry);\r
edit_settings.commit();\r
- \r
+\r
mCountryButton.setImageResource(getDrawableID("country_" + mCountry + "_32_32"));\r
}\r
- \r
});\r
\r
- \r
mapModeChooser.show();\r
-\r
-\r
}\r
\r
private void executeDone()\r