author | unc0rr |
Mon, 19 Nov 2018 22:26:47 +0100 | |
changeset 14256 | fa2e3f123a09 |
parent 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 |
||
10017 | 35 |
public static final int NUM_ALREADYDOWNLOADED = 0; |
36 |
public static final int NUM_AREYOUSURE = 1; |
|
6350 | 37 |
|
10017 | 38 |
private final static String BUNDLE_TASK = "task"; |
6350 | 39 |
|
10017 | 40 |
static DownloadDialogFragment newInstance(DownloadPackage task){ |
41 |
DownloadDialogFragment dialog = new DownloadDialogFragment(); |
|
6350 | 42 |
|
10017 | 43 |
Bundle args = new Bundle(); |
44 |
args.putParcelable(DownloadDialogFragment.BUNDLE_TASK, task); |
|
45 |
dialog.setArguments(args); |
|
6350 | 46 |
|
10017 | 47 |
return dialog; |
48 |
} |
|
6350 | 49 |
|
10017 | 50 |
public Dialog onCreateDialog(Bundle savedInstanceState){ |
51 |
DownloadPackage task = (DownloadPackage)getArguments().getParcelable(DownloadDialogFragment.BUNDLE_TASK); |
|
6350 | 52 |
|
10017 | 53 |
Builder builder = new AlertDialog.Builder(getActivity()); |
6350 | 54 |
|
10017 | 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 |
} |
|
6350 | 64 |
|
10017 | 65 |
DownloadClicker clicker = new DownloadClicker(task); |
66 |
builder.setPositiveButton(android.R.string.yes, clicker); |
|
67 |
builder.setNegativeButton(android.R.string.no, clicker); |
|
6350 | 68 |
|
10017 | 69 |
return builder.create(); |
70 |
} |
|
6350 | 71 |
|
10017 | 72 |
class DownloadClicker implements OnClickListener{ |
6350 | 73 |
|
10017 | 74 |
DownloadPackage task = null; |
6350 | 75 |
|
10017 | 76 |
public DownloadClicker(DownloadPackage _task){ |
77 |
task = _task; |
|
78 |
} |
|
6350 | 79 |
|
10017 | 80 |
public void onClick(DialogInterface dialog, int which) { |
81 |
if(which == Dialog.BUTTON_POSITIVE){ |
|
82 |
Intent i = new Intent(getActivity(), DownloadListActivity.class); |
|
83 |
i.putExtra(DownloadFragment.EXTRA_TASK, task); |
|
84 |
getActivity().startActivity(i); |
|
85 |
} |
|
86 |
} |
|
87 |
} |
|
6350 | 88 |
} |