LEFT | RIGHT |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 23 matching lines...) Expand all Loading... |
34 /** | 34 /** |
35 * Prompts user to download update or installs downloaded update. | 35 * Prompts user to download update or installs downloaded update. |
36 */ | 36 */ |
37 public class UpdaterActivity extends Activity | 37 public class UpdaterActivity extends Activity |
38 { | 38 { |
39 @Override | 39 @Override |
40 public void onCreate(final Bundle savedInstanceState) | 40 public void onCreate(final Bundle savedInstanceState) |
41 { | 41 { |
42 super.onCreate(savedInstanceState); | 42 super.onCreate(savedInstanceState); |
43 | 43 |
44 this.requestWindowFeature(Window.FEATURE_NO_TITLE); | 44 requestWindowFeature(Window.FEATURE_NO_TITLE); |
45 | 45 |
46 // Prompt user to download update | 46 // Prompt user to download update |
47 if ("download".equals(this.getIntent().getAction())) | 47 if ("download".equals(getIntent().getAction())) |
48 { | 48 { |
49 final Bundle extras = this.getIntent().getExtras(); | 49 final Bundle extras = getIntent().getExtras(); |
50 if (extras == null || extras.getString("url") == null) | 50 if (extras == null || extras.getString("url") == null) |
51 { | 51 { |
52 this.finish(); | 52 finish(); |
53 return; | 53 return; |
54 } | 54 } |
55 | 55 |
56 new AlertDialog.Builder(this).setTitle(R.string.msg_update_available).setM
essage(this.getString(R.string.msg_update_description)) | 56 new AlertDialog.Builder(this).setTitle(R.string.msg_update_available).setM
essage(getString(R.string.msg_update_description)).setIcon(android.R.drawable.ic
_dialog_info) |
57 .setIcon(android.R.drawable.ic_dialog_info) | 57 .setPositiveButton(R.string.ok, new OnClickListener() { |
58 .setPositiveButton(R.string.ok, new OnClickListener() | |
59 { | |
60 @Override | 58 @Override |
61 public void onClick(final DialogInterface arg0, final int arg1) | 59 public void onClick(final DialogInterface arg0, final int arg1) |
62 { | 60 { |
63 // Start download service | 61 // Start download service |
64 UpdaterActivity.this.startService(new Intent(UpdaterActivity.this,
UpdaterService.class).putExtras(extras)); | 62 startService(new Intent(UpdaterActivity.this, UpdaterService.class
).putExtras(extras)); |
65 UpdaterActivity.this.finish(); | 63 finish(); |
66 } | 64 } |
67 }).setNegativeButton(R.string.cancel, new OnClickListener() | 65 }).setNegativeButton(R.string.cancel, new OnClickListener() { |
68 { | |
69 @Override | 66 @Override |
70 public void onClick(final DialogInterface dialog, final int which) | 67 public void onClick(final DialogInterface dialog, final int which) |
71 { | 68 { |
72 UpdaterActivity.this.finish(); | 69 finish(); |
73 } | 70 } |
74 }).setOnCancelListener(new OnCancelListener() | 71 }).setOnCancelListener(new OnCancelListener() { |
75 { | |
76 @Override | 72 @Override |
77 public void onCancel(final DialogInterface dialog) | 73 public void onCancel(final DialogInterface dialog) |
78 { | 74 { |
79 UpdaterActivity.this.finish(); | 75 finish(); |
80 } | 76 } |
81 }).create().show(); | 77 }).create().show(); |
82 } | 78 } |
83 // Install downloaded update | 79 // Install downloaded update |
84 else | 80 else |
85 { | 81 { |
86 final String file = this.getIntent().getStringExtra("path"); | 82 final String file = getIntent().getStringExtra("path"); |
87 final File updateFile = new File(file); | 83 final File updateFile = new File(file); |
88 try | 84 try |
89 { | 85 { |
90 final Intent installerIntent = new Intent(); | 86 final Intent installerIntent = new Intent(); |
91 installerIntent.setAction(Intent.ACTION_VIEW); | 87 installerIntent.setAction(Intent.ACTION_VIEW); |
92 installerIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | 88 installerIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
93 installerIntent.setDataAndType(Uri.fromFile(updateFile), "application/vn
d.android.package-archive"); | 89 installerIntent.setDataAndType(Uri.fromFile(updateFile), "application/vn
d.android.package-archive"); |
94 this.startActivity(installerIntent); | 90 startActivity(installerIntent); |
95 android.os.Process.killProcess(android.os.Process.myPid()); | 91 android.os.Process.killProcess(android.os.Process.myPid()); |
96 } | 92 } |
97 catch (final Exception e) | 93 catch (final Exception e) |
98 { | 94 { |
99 e.printStackTrace(); | 95 e.printStackTrace(); |
100 } | 96 } |
101 } | 97 } |
102 } | 98 } |
| 99 |
103 } | 100 } |
LEFT | RIGHT |