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