author | Medo <smaxein@googlemail.com> |
Mon, 23 Jul 2012 00:17:06 +0200 | |
changeset 7352 | 641f11cdd319 |
parent 7349 | 12fdfd2038d4 |
child 7355 | 5673e95ef647 |
permissions | -rw-r--r-- |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
1 |
/* |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
2 |
* Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game |
6700 | 3 |
* Copyright (c) 2011-2012 Richard Deurwaarder <xeli@xelification.com> |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
4 |
* |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
8 |
* |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
13 |
* |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
17 |
*/ |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
18 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
19 |
package org.hedgewars.hedgeroid; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
20 |
|
7344
25b8906f901a
Hedgeroid: Modified detection of assets on SD card (should be more reliable)
Medo <smaxein@googlemail.com>
parents:
7330
diff
changeset
|
21 |
import java.io.File; |
25b8906f901a
Hedgeroid: Modified detection of assets on SD card (should be more reliable)
Medo <smaxein@googlemail.com>
parents:
7330
diff
changeset
|
22 |
import java.io.FileInputStream; |
25b8906f901a
Hedgeroid: Modified detection of assets on SD card (should be more reliable)
Medo <smaxein@googlemail.com>
parents:
7330
diff
changeset
|
23 |
import java.io.IOException; |
25b8906f901a
Hedgeroid: Modified detection of assets on SD card (should be more reliable)
Medo <smaxein@googlemail.com>
parents:
7330
diff
changeset
|
24 |
|
6350 | 25 |
import org.hedgewars.hedgeroid.Downloader.DownloadAssets; |
6343 | 26 |
import org.hedgewars.hedgeroid.Downloader.DownloadListActivity; |
7328
cd919a2ead4e
Hedgeroid: Added experimental lobby chat
Medo <smaxein@googlemail.com>
parents:
7318
diff
changeset
|
27 |
import org.hedgewars.hedgeroid.netplay.LobbyActivity; |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
28 |
|
6456
fed715edc3ee
android: check if the sdcard directory is writable, if it isn't close the app
Xeli
parents:
6350
diff
changeset
|
29 |
import android.app.AlertDialog; |
fed715edc3ee
android: check if the sdcard directory is writable, if it isn't close the app
Xeli
parents:
6350
diff
changeset
|
30 |
import android.app.Dialog; |
6350 | 31 |
import android.app.ProgressDialog; |
6456
fed715edc3ee
android: check if the sdcard directory is writable, if it isn't close the app
Xeli
parents:
6350
diff
changeset
|
32 |
import android.content.DialogInterface; |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
33 |
import android.content.Intent; |
7352
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
34 |
import android.content.SharedPreferences; |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
35 |
import android.content.SharedPreferences.Editor; |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
36 |
import android.os.Bundle; |
6350 | 37 |
import android.support.v4.app.FragmentActivity; |
7352
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
38 |
import android.util.Log; |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
39 |
import android.view.View; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
40 |
import android.view.View.OnClickListener; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
41 |
import android.widget.Button; |
7352
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
42 |
import android.widget.EditText; |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
43 |
import android.widget.Toast; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
44 |
|
6350 | 45 |
public class MainActivity extends FragmentActivity { |
7352
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
46 |
private static final int DIALOG_NO_SDCARD = 0; |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
47 |
private static final int DIALOG_START_NETGAME = 1; |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
48 |
|
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
49 |
private static final String PREF_PLAYERNAME = "playerName"; |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
50 |
|
6350 | 51 |
private Button downloader, startGame; |
52 |
private ProgressDialog assetsDialog; |
|
53 |
||
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
54 |
public void onCreate(Bundle sis){ |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
55 |
super.onCreate(sis); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
56 |
setContentView(R.layout.main); |
6350 | 57 |
|
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
58 |
downloader = (Button)findViewById(R.id.downloader); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
59 |
startGame = (Button)findViewById(R.id.startGame); |
7328
cd919a2ead4e
Hedgeroid: Added experimental lobby chat
Medo <smaxein@googlemail.com>
parents:
7318
diff
changeset
|
60 |
Button joinLobby = (Button)findViewById(R.id.joinLobby); |
6350 | 61 |
|
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
62 |
downloader.setOnClickListener(downloadClicker); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
63 |
startGame.setOnClickListener(startGameClicker); |
7328
cd919a2ead4e
Hedgeroid: Added experimental lobby chat
Medo <smaxein@googlemail.com>
parents:
7318
diff
changeset
|
64 |
joinLobby.setOnClickListener(new OnClickListener() { |
cd919a2ead4e
Hedgeroid: Added experimental lobby chat
Medo <smaxein@googlemail.com>
parents:
7318
diff
changeset
|
65 |
public void onClick(View v) { |
7352
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
66 |
showDialog(DIALOG_START_NETGAME); |
7328
cd919a2ead4e
Hedgeroid: Added experimental lobby chat
Medo <smaxein@googlemail.com>
parents:
7318
diff
changeset
|
67 |
} |
cd919a2ead4e
Hedgeroid: Added experimental lobby chat
Medo <smaxein@googlemail.com>
parents:
7318
diff
changeset
|
68 |
}); |
6350 | 69 |
|
7318
a446eafcddeb
Improved asset moving time by an order of magnitude (3s vs. 25s on my device)
Medo <smaxein@googlemail.com>
parents:
6842
diff
changeset
|
70 |
if(!Utils.isDataPathAvailable()){ |
7352
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
71 |
showDialog(DIALOG_NO_SDCARD); |
7318
a446eafcddeb
Improved asset moving time by an order of magnitude (3s vs. 25s on my device)
Medo <smaxein@googlemail.com>
parents:
6842
diff
changeset
|
72 |
} else { |
7344
25b8906f901a
Hedgeroid: Modified detection of assets on SD card (should be more reliable)
Medo <smaxein@googlemail.com>
parents:
7330
diff
changeset
|
73 |
String existingVersion = ""; |
6623
6bf169f1e97c
check if the latest assets have been moved to the sdcard (compare with versionCode)
Xeli
parents:
6456
diff
changeset
|
74 |
try { |
7344
25b8906f901a
Hedgeroid: Modified detection of assets on SD card (should be more reliable)
Medo <smaxein@googlemail.com>
parents:
7330
diff
changeset
|
75 |
File versionFile = new File(Utils.getCachePath(this), "assetsversion.txt"); |
25b8906f901a
Hedgeroid: Modified detection of assets on SD card (should be more reliable)
Medo <smaxein@googlemail.com>
parents:
7330
diff
changeset
|
76 |
existingVersion = Utils.readToString(new FileInputStream(versionFile)); |
25b8906f901a
Hedgeroid: Modified detection of assets on SD card (should be more reliable)
Medo <smaxein@googlemail.com>
parents:
7330
diff
changeset
|
77 |
} catch(IOException e) { |
6623
6bf169f1e97c
check if the latest assets have been moved to the sdcard (compare with versionCode)
Xeli
parents:
6456
diff
changeset
|
78 |
} |
7344
25b8906f901a
Hedgeroid: Modified detection of assets on SD card (should be more reliable)
Medo <smaxein@googlemail.com>
parents:
7330
diff
changeset
|
79 |
|
25b8906f901a
Hedgeroid: Modified detection of assets on SD card (should be more reliable)
Medo <smaxein@googlemail.com>
parents:
7330
diff
changeset
|
80 |
String newVersion = ""; |
25b8906f901a
Hedgeroid: Modified detection of assets on SD card (should be more reliable)
Medo <smaxein@googlemail.com>
parents:
7330
diff
changeset
|
81 |
try { |
25b8906f901a
Hedgeroid: Modified detection of assets on SD card (should be more reliable)
Medo <smaxein@googlemail.com>
parents:
7330
diff
changeset
|
82 |
newVersion = Utils.readToString(getAssets().open("assetsversion.txt")); |
25b8906f901a
Hedgeroid: Modified detection of assets on SD card (should be more reliable)
Medo <smaxein@googlemail.com>
parents:
7330
diff
changeset
|
83 |
} catch(IOException e) { |
25b8906f901a
Hedgeroid: Modified detection of assets on SD card (should be more reliable)
Medo <smaxein@googlemail.com>
parents:
7330
diff
changeset
|
84 |
} |
25b8906f901a
Hedgeroid: Modified detection of assets on SD card (should be more reliable)
Medo <smaxein@googlemail.com>
parents:
7330
diff
changeset
|
85 |
|
25b8906f901a
Hedgeroid: Modified detection of assets on SD card (should be more reliable)
Medo <smaxein@googlemail.com>
parents:
7330
diff
changeset
|
86 |
if(!existingVersion.equals(newVersion)) { |
6456
fed715edc3ee
android: check if the sdcard directory is writable, if it isn't close the app
Xeli
parents:
6350
diff
changeset
|
87 |
DownloadAssets assetsAsyncTask = new DownloadAssets(this); |
7330
867e4fda496e
Hedgeroid: Layout experiments for the lobby page
Medo <smaxein@googlemail.com>
parents:
7328
diff
changeset
|
88 |
assetsDialog = ProgressDialog.show(this, "Please wait a moment", "Moving assets to SD card..."); |
867e4fda496e
Hedgeroid: Layout experiments for the lobby page
Medo <smaxein@googlemail.com>
parents:
7328
diff
changeset
|
89 |
assetsAsyncTask.execute(); |
6456
fed715edc3ee
android: check if the sdcard directory is writable, if it isn't close the app
Xeli
parents:
6350
diff
changeset
|
90 |
} |
6350 | 91 |
} |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
92 |
} |
6350 | 93 |
|
6456
fed715edc3ee
android: check if the sdcard directory is writable, if it isn't close the app
Xeli
parents:
6350
diff
changeset
|
94 |
public Dialog onCreateDialog(int id, Bundle args){ |
7352
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
95 |
switch(id) { |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
96 |
case DIALOG_NO_SDCARD: |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
97 |
return createNoSdcardDialog(); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
98 |
case DIALOG_START_NETGAME: |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
99 |
return createStartNetgameDialog(); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
100 |
default: |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
101 |
throw new IndexOutOfBoundsException(); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
102 |
} |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
103 |
} |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
104 |
|
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
105 |
private Dialog createNoSdcardDialog() { |
6456
fed715edc3ee
android: check if the sdcard directory is writable, if it isn't close the app
Xeli
parents:
6350
diff
changeset
|
106 |
AlertDialog.Builder builder = new AlertDialog.Builder(this); |
fed715edc3ee
android: check if the sdcard directory is writable, if it isn't close the app
Xeli
parents:
6350
diff
changeset
|
107 |
builder.setTitle(R.string.sdcard_not_mounted_title); |
fed715edc3ee
android: check if the sdcard directory is writable, if it isn't close the app
Xeli
parents:
6350
diff
changeset
|
108 |
builder.setMessage(R.string.sdcard_not_mounted); |
fed715edc3ee
android: check if the sdcard directory is writable, if it isn't close the app
Xeli
parents:
6350
diff
changeset
|
109 |
builder.setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener(){ |
fed715edc3ee
android: check if the sdcard directory is writable, if it isn't close the app
Xeli
parents:
6350
diff
changeset
|
110 |
public void onClick(DialogInterface dialog, int which) { |
fed715edc3ee
android: check if the sdcard directory is writable, if it isn't close the app
Xeli
parents:
6350
diff
changeset
|
111 |
finish(); |
fed715edc3ee
android: check if the sdcard directory is writable, if it isn't close the app
Xeli
parents:
6350
diff
changeset
|
112 |
} |
fed715edc3ee
android: check if the sdcard directory is writable, if it isn't close the app
Xeli
parents:
6350
diff
changeset
|
113 |
}); |
fed715edc3ee
android: check if the sdcard directory is writable, if it isn't close the app
Xeli
parents:
6350
diff
changeset
|
114 |
|
fed715edc3ee
android: check if the sdcard directory is writable, if it isn't close the app
Xeli
parents:
6350
diff
changeset
|
115 |
return builder.create(); |
fed715edc3ee
android: check if the sdcard directory is writable, if it isn't close the app
Xeli
parents:
6350
diff
changeset
|
116 |
} |
fed715edc3ee
android: check if the sdcard directory is writable, if it isn't close the app
Xeli
parents:
6350
diff
changeset
|
117 |
|
7352
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
118 |
private Dialog createStartNetgameDialog() { |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
119 |
final SharedPreferences prefs = getPreferences(MODE_PRIVATE); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
120 |
final String playerName = prefs.getString(PREF_PLAYERNAME, "Player"); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
121 |
final EditText editText = new EditText(this); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
122 |
final AlertDialog.Builder builder = new AlertDialog.Builder(this); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
123 |
|
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
124 |
editText.setText(playerName); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
125 |
editText.setHint(R.string.start_netgame_dialog_playername_hint); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
126 |
editText.setId(android.R.id.text1); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
127 |
|
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
128 |
builder.setTitle(R.string.start_netgame_dialog_title); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
129 |
builder.setMessage(R.string.start_netgame_dialog_message); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
130 |
builder.setView(editText); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
131 |
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
132 |
public void onClick(DialogInterface dialog, int which) { |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
133 |
editText.setText(playerName); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
134 |
} |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
135 |
}); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
136 |
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
137 |
public void onClick(DialogInterface dialog, int which) { |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
138 |
String playerName = editText.getText().toString(); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
139 |
if(playerName.length() > 0) { |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
140 |
Editor edit = prefs.edit(); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
141 |
edit.putString(PREF_PLAYERNAME, playerName); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
142 |
edit.commit(); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
143 |
|
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
144 |
// TODO actually use that name |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
145 |
Intent netplayIntent = new Intent(getApplicationContext(), LobbyActivity.class); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
146 |
netplayIntent.putExtra("playerName", playerName); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
147 |
startActivity(netplayIntent); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
148 |
} |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
149 |
} |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
150 |
}); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
151 |
|
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
152 |
return builder.create(); |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
153 |
} |
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
154 |
|
6350 | 155 |
public void onAssetsDownloaded(boolean result){ |
7344
25b8906f901a
Hedgeroid: Modified detection of assets on SD card (should be more reliable)
Medo <smaxein@googlemail.com>
parents:
7330
diff
changeset
|
156 |
if(!result){ |
25b8906f901a
Hedgeroid: Modified detection of assets on SD card (should be more reliable)
Medo <smaxein@googlemail.com>
parents:
7330
diff
changeset
|
157 |
Toast.makeText(this, R.string.download_failed, Toast.LENGTH_LONG).show(); |
6350 | 158 |
} |
159 |
assetsDialog.dismiss(); |
|
160 |
} |
|
161 |
||
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
162 |
private OnClickListener downloadClicker = new OnClickListener(){ |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
163 |
public void onClick(View v){ |
6343 | 164 |
startActivityForResult(new Intent(getApplicationContext(), DownloadListActivity.class), 0); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
165 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
166 |
}; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
167 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
168 |
private OnClickListener startGameClicker = new OnClickListener(){ |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
169 |
public void onClick(View v){ |
6350 | 170 |
startActivity(new Intent(getApplicationContext(), StartGameActivity.class)); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
171 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
172 |
}; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
173 |
} |