author | dag10 |
Mon, 21 Jan 2013 14:14:56 -0500 | |
changeset 8420 | 98e3cc0418f9 |
parent 7584 | 7831c84cc644 |
child 10017 | de822cd3df3a |
permissions | -rw-r--r-- |
7584
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
6566
diff
changeset
|
1 |
/* |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
6566
diff
changeset
|
2 |
* Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
6566
diff
changeset
|
3 |
* Copyright (c) 2011-2012 Richard Deurwaarder <xeli@xelification.com> |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
6566
diff
changeset
|
4 |
* |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
6566
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
6566
diff
changeset
|
6 |
* modify it under the terms of the GNU General Public License |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
6566
diff
changeset
|
7 |
* as published by the Free Software Foundation; either version 2 |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
6566
diff
changeset
|
8 |
* of the License, or (at your option) any later version. |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
6566
diff
changeset
|
9 |
* |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
6566
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
6566
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
6566
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
6566
diff
changeset
|
13 |
* GNU General Public License for more details. |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
6566
diff
changeset
|
14 |
* |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
6566
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
6566
diff
changeset
|
16 |
* along with this program; if not, write to the Free Software |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
6566
diff
changeset
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
6566
diff
changeset
|
18 |
*/ |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
6566
diff
changeset
|
19 |
|
6350 | 20 |
package org.hedgewars.hedgeroid.Downloader; |
21 |
||
22 |
import org.hedgewars.hedgeroid.R; |
|
23 |
||
24 |
import android.app.AlertDialog; |
|
25 |
import android.app.AlertDialog.Builder; |
|
26 |
import android.app.Dialog; |
|
27 |
import android.content.DialogInterface; |
|
28 |
import android.content.DialogInterface.OnClickListener; |
|
29 |
import android.content.Intent; |
|
30 |
import android.os.Bundle; |
|
31 |
import android.support.v4.app.DialogFragment; |
|
32 |
||
33 |
public class DownloadDialogFragment extends DialogFragment { |
|
34 |
||
35 |
public static final int NUM_ALREADYDOWNLOADED = 0; |
|
36 |
public static final int NUM_AREYOUSURE = 1; |
|
37 |
||
38 |
private final static String BUNDLE_TASK = "task"; |
|
39 |
||
40 |
static DownloadDialogFragment newInstance(DownloadPackage task){ |
|
41 |
DownloadDialogFragment dialog = new DownloadDialogFragment(); |
|
42 |
||
43 |
Bundle args = new Bundle(); |
|
44 |
args.putParcelable(DownloadDialogFragment.BUNDLE_TASK, task); |
|
45 |
dialog.setArguments(args); |
|
46 |
||
47 |
return dialog; |
|
48 |
} |
|
49 |
||
50 |
public Dialog onCreateDialog(Bundle savedInstanceState){ |
|
51 |
DownloadPackage task = (DownloadPackage)getArguments().getParcelable(DownloadDialogFragment.BUNDLE_TASK); |
|
52 |
||
53 |
Builder builder = new AlertDialog.Builder(getActivity()); |
|
54 |
||
55 |
switch(task.getStatus()){ |
|
56 |
case CURRENTVERSION: |
|
57 |
case NEWERVERSION: |
|
58 |
builder.setMessage(R.string.download_areyousure); |
|
59 |
break; |
|
60 |
case OLDERVERSION: |
|
61 |
builder.setMessage(R.string.download_alreadydownloaded); |
|
62 |
break; |
|
63 |
} |
|
64 |
||
65 |
DownloadClicker clicker = new DownloadClicker(task); |
|
66 |
builder.setPositiveButton(android.R.string.yes, clicker); |
|
67 |
builder.setNegativeButton(android.R.string.no, clicker); |
|
68 |
||
69 |
return builder.create(); |
|
70 |
} |
|
71 |
||
72 |
class DownloadClicker implements OnClickListener{ |
|
73 |
||
74 |
DownloadPackage task = null; |
|
75 |
||
76 |
public DownloadClicker(DownloadPackage _task){ |
|
77 |
task = _task; |
|
78 |
} |
|
79 |
||
80 |
public void onClick(DialogInterface dialog, int which) { |
|
81 |
if(which == Dialog.BUTTON_POSITIVE){ |
|
6566 | 82 |
Intent i = new Intent(getActivity(), DownloadListActivity.class); |
6350 | 83 |
i.putExtra(DownloadFragment.EXTRA_TASK, task); |
84 |
getActivity().startActivity(i); |
|
85 |
} |
|
86 |
} |
|
87 |
} |
|
88 |
} |