1 /* |
|
2 * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game |
|
3 * Copyright (c) 2011 Richard Deurwaarder <xeli@xelification.com> |
|
4 * |
|
5 * This program is free software; you can redistribute it and/or modify |
|
6 * it under the terms of the GNU General Public License as published by |
|
7 * the Free Software Foundation; version 2 of the License |
|
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 Free Software |
|
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 */ |
|
18 |
|
19 package org.hedgewars.mobile; |
|
20 |
|
21 import org.hedgewars.mobile.Downloader.DownloadActivity; |
|
22 import org.hedgewars.mobile.Downloader.DownloadService; |
|
23 |
|
24 import android.app.Activity; |
|
25 import android.content.Intent; |
|
26 import android.os.Bundle; |
|
27 import android.preference.PreferenceManager; |
|
28 import android.view.View; |
|
29 import android.view.View.OnClickListener; |
|
30 import android.widget.Button; |
|
31 import android.widget.Toast; |
|
32 |
|
33 public class MainActivity extends Activity { |
|
34 |
|
35 Button downloader, startGame; |
|
36 |
|
37 public void onCreate(Bundle sis){ |
|
38 super.onCreate(sis); |
|
39 setContentView(R.layout.main); |
|
40 |
|
41 downloader = (Button)findViewById(R.id.downloader); |
|
42 startGame = (Button)findViewById(R.id.startGame); |
|
43 |
|
44 downloader.setOnClickListener(downloadClicker); |
|
45 startGame.setOnClickListener(startGameClicker); |
|
46 } |
|
47 |
|
48 |
|
49 |
|
50 private OnClickListener downloadClicker = new OnClickListener(){ |
|
51 public void onClick(View v){ |
|
52 startActivityForResult(new Intent(getApplicationContext(), DownloadActivity.class), 0); |
|
53 } |
|
54 }; |
|
55 |
|
56 private OnClickListener startGameClicker = new OnClickListener(){ |
|
57 public void onClick(View v){ |
|
58 if(PreferenceManager.getDefaultSharedPreferences(MainActivity.this).getBoolean(DownloadService.PREF_DOWNLOADED, false)) |
|
59 startActivity(new Intent(getApplicationContext(), StartGameActivity.class)); |
|
60 else { |
|
61 Toast.makeText(MainActivity.this, R.string.download_userexplain, Toast.LENGTH_LONG).show(); |
|
62 startActivityForResult(new Intent(getApplicationContext(), DownloadActivity.class), 0); |
|
63 } |
|
64 } |
|
65 }; |
|
66 |
|
67 } |
|