1 |
/**
|
2 |
* ZANavi, Zoff Android Navigation system.
|
3 |
* Copyright (C) 2011 Zoff <zoff@zoff.cc>
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* version 2 as published by the Free Software Foundation.
|
8 |
*
|
9 |
* This program is distributed in the hope that it will be useful,
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
* GNU General Public License for more details.
|
13 |
*
|
14 |
* You should have received a copy of the GNU General Public License
|
15 |
* along with this program; if not, write to the
|
16 |
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
17 |
* Boston, MA 02110-1301, USA.
|
18 |
*/
|
19 |
|
20 |
package com.zoffcc.applications.zanavi;
|
21 |
|
22 |
import net.technologichron.manacalc.NumberPicker;
|
23 |
import android.app.Activity;
|
24 |
import android.content.Intent;
|
25 |
import android.os.Bundle;
|
26 |
import android.view.View;
|
27 |
import android.widget.Button;
|
28 |
import android.widget.ToggleButton;
|
29 |
|
30 |
public class GeoCoordEnterDialog extends Activity
|
31 |
{
|
32 |
float lat;
|
33 |
float lon;
|
34 |
|
35 |
/** Called when the activity is first created. */
|
36 |
@Override
|
37 |
public void onCreate(Bundle savedInstanceState)
|
38 |
{
|
39 |
super.onCreate(savedInstanceState);
|
40 |
setContentView(R.layout.geocoordenter);
|
41 |
// setContentView(R.layout.numpicker2);
|
42 |
final Button ok_button = (Button) findViewById(R.id.ok01);
|
43 |
final Button destination_button = (Button) findViewById(R.id.dst01);
|
44 |
final Button cancel_button = (Button) findViewById(R.id.cancel01);
|
45 |
ok_button.setOnClickListener(new View.OnClickListener()
|
46 |
{
|
47 |
public void onClick(View v)
|
48 |
{
|
49 |
executeDone("view");
|
50 |
}
|
51 |
});
|
52 |
|
53 |
destination_button.setOnClickListener(new View.OnClickListener()
|
54 |
{
|
55 |
public void onClick(View v)
|
56 |
{
|
57 |
executeDone("dest");
|
58 |
}
|
59 |
});
|
60 |
|
61 |
cancel_button.setOnClickListener(new View.OnClickListener()
|
62 |
{
|
63 |
public void onClick(View v)
|
64 |
{
|
65 |
Intent resultIntent = new Intent();
|
66 |
setResult(Activity.RESULT_CANCELED, resultIntent);
|
67 |
finish();
|
68 |
}
|
69 |
});
|
70 |
}
|
71 |
|
72 |
private void executeDone(String what)
|
73 |
{
|
74 |
Intent resultIntent = new Intent();
|
75 |
final NumberPicker value_lat1 = (NumberPicker) findViewById(R.id.lat1);
|
76 |
final NumberPicker value_lat2 = (NumberPicker) findViewById(R.id.lat2);
|
77 |
final NumberPicker value_lat3 = (NumberPicker) findViewById(R.id.lat3);
|
78 |
lat = value_lat1.getValue() + ((float) value_lat2.getValue() / 60) + ((float) value_lat3.getValue() / 3600);
|
79 |
|
80 |
final NumberPicker value_lon1 = (NumberPicker) findViewById(R.id.lon1);
|
81 |
final NumberPicker value_lon2 = (NumberPicker) findViewById(R.id.lon2);
|
82 |
final NumberPicker value_lon3 = (NumberPicker) findViewById(R.id.lon3);
|
83 |
lon = value_lon1.getValue() + ((float) value_lon2.getValue() / 60) + ((float) value_lon3.getValue() / 3600);
|
84 |
|
85 |
resultIntent.putExtra("lat", String.valueOf(this.lat));
|
86 |
resultIntent.putExtra("lon", String.valueOf(this.lon));
|
87 |
final ToggleButton toggle_NS = (ToggleButton) findViewById(R.id.toggleButtonNS);
|
88 |
if (!toggle_NS.isSelected())
|
89 |
{
|
90 |
this.lat = -this.lat;
|
91 |
}
|
92 |
final ToggleButton toggle_WE = (ToggleButton) findViewById(R.id.toggleButtonWE);
|
93 |
if (toggle_WE.isSelected())
|
94 |
{
|
95 |
this.lon = -this.lon;
|
96 |
}
|
97 |
setResult(Activity.RESULT_OK, resultIntent);
|
98 |
if (what.equals("view"))
|
99 |
{
|
100 |
resultIntent.putExtra("what", "view");
|
101 |
}
|
102 |
else
|
103 |
{
|
104 |
resultIntent.putExtra("what", "-");
|
105 |
}
|
106 |
finish();
|
107 |
}
|
108 |
}
|