f5d8425261e3081bb2623bcb5902e3ee7993cc60
[fw/altos] / altosdroid / app / src / main / java / 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 android.app.Activity;
22 import android.content.Intent;
23 import android.os.Bundle;
24 import android.view.View;
25 import android.view.Window;
26 import android.widget.*;
27
28 import org.altusmetrum.altoslib_13.*;
29
30 public class MapTypeActivity extends Activity {
31         private Button hybrid;
32         private Button satellite;
33         private Button roadmap;
34         private Button terrain;
35         private int selected_type;
36
37         public static final String EXTRA_MAP_TYPE = "map_type";
38
39         private void done(int type) {
40
41                 Intent intent = new Intent();
42                 intent.putExtra(EXTRA_MAP_TYPE, type);
43                 setResult(Activity.RESULT_OK, intent);
44                 finish();
45         }
46
47         public void selectType(View view) {
48                 AltosDebug.debug("selectType %s", view.toString());
49                 if (view == hybrid)
50                         done(AltosMap.maptype_hybrid);
51                 if (view == satellite)
52                         done(AltosMap.maptype_satellite);
53                 if (view == roadmap)
54                         done(AltosMap.maptype_roadmap);
55                 if (view == terrain)
56                         done(AltosMap.maptype_terrain);
57         }
58
59         @Override
60         protected void onCreate(Bundle savedInstanceState) {
61                 setTheme(AltosDroid.dialog_themes[AltosDroidPreferences.font_size()]);
62                 super.onCreate(savedInstanceState);
63
64                 // Setup the window
65                 requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
66                 setContentView(R.layout.map_type);
67
68                 hybrid = (Button) findViewById(R.id.map_type_hybrid);
69                 satellite = (Button) findViewById(R.id.map_type_satellite);
70                 roadmap = (Button) findViewById(R.id.map_type_roadmap);
71                 terrain = (Button) findViewById(R.id.map_type_terrain);
72
73                 // Set result CANCELED incase the user backs out
74                 setResult(Activity.RESULT_CANCELED);
75         }
76 }