Switch from GPLv2 to GPLv2+
[fw/altos] / altosdroid / src / org / altusmetrum / AltosDroid / MapTypeActivity.java
1 /*
2  * Copyright © 2015 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18
19 package org.altusmetrum.AltosDroid;
20
21 import java.util.*;
22 import org.altusmetrum.AltosDroid.R;
23
24 import android.app.Activity;
25 import android.bluetooth.BluetoothAdapter;
26 import android.bluetooth.BluetoothDevice;
27 import android.content.BroadcastReceiver;
28 import android.content.Context;
29 import android.content.Intent;
30 import android.content.IntentFilter;
31 import android.os.Bundle;
32 import android.view.View;
33 import android.view.Window;
34 import android.view.View.OnClickListener;
35 import android.widget.*;
36 import android.widget.AdapterView.*;
37
38 import org.altusmetrum.altoslib_11.*;
39
40 public class MapTypeActivity extends Activity {
41         private Button hybrid;
42         private Button satellite;
43         private Button roadmap;
44         private Button terrain;
45         private int selected_type;
46
47         public static final String EXTRA_MAP_TYPE = "map_type";
48
49         private void done(int type) {
50
51                 Intent intent = new Intent();
52                 intent.putExtra(EXTRA_MAP_TYPE, type);
53                 setResult(Activity.RESULT_OK, intent);
54                 finish();
55         }
56
57         public void selectType(View view) {
58                 AltosDebug.debug("selectType %s", view.toString());
59                 if (view == hybrid)
60                         done(AltosMap.maptype_hybrid);
61                 if (view == satellite)
62                         done(AltosMap.maptype_satellite);
63                 if (view == roadmap)
64                         done(AltosMap.maptype_roadmap);
65                 if (view == terrain)
66                         done(AltosMap.maptype_terrain);
67         }
68
69         @Override
70         protected void onCreate(Bundle savedInstanceState) {
71                 super.onCreate(savedInstanceState);
72
73                 // Setup the window
74                 requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
75                 setContentView(R.layout.map_type);
76
77                 hybrid = (Button) findViewById(R.id.map_type_hybrid);
78                 satellite = (Button) findViewById(R.id.map_type_satellite);
79                 roadmap = (Button) findViewById(R.id.map_type_roadmap);
80                 terrain = (Button) findViewById(R.id.map_type_terrain);
81
82                 // Set result CANCELED incase the user backs out
83                 setResult(Activity.RESULT_CANCELED);
84         }
85 }