| OLD | NEW |
| 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 19 matching lines...) Expand all Loading... |
| 30 import android.net.Uri; | 30 import android.net.Uri; |
| 31 import android.os.Bundle; | 31 import android.os.Bundle; |
| 32 import android.view.Window; | 32 import android.view.Window; |
| 33 | 33 |
| 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(Bundle savedInstanceState) | 40 public void onCreate(final Bundle savedInstanceState) |
| 41 { | 41 { |
| 42 super.onCreate(savedInstanceState); | 42 super.onCreate(savedInstanceState); |
| 43 | 43 |
| 44 requestWindowFeature(Window.FEATURE_NO_TITLE); | 44 this.requestWindowFeature(Window.FEATURE_NO_TITLE); |
| 45 | 45 |
| 46 // Prompt user to download update | 46 // Prompt user to download update |
| 47 if ("download".equals(getIntent().getAction())) | 47 if ("download".equals(this.getIntent().getAction())) |
| 48 { | 48 { |
| 49 final Bundle extras = getIntent().getExtras(); | 49 final Bundle extras = this.getIntent().getExtras(); |
| 50 if (extras == null || extras.getString("url") == null) | 50 if (extras == null || extras.getString("url") == null) |
| 51 { | 51 { |
| 52 finish(); | 52 this.finish(); |
| 53 return; | 53 return; |
| 54 } | 54 } |
| 55 | 55 |
| 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) | 56 new AlertDialog.Builder(this).setTitle(R.string.msg_update_available).setM
essage(this.getString(R.string.msg_update_description)) |
| 57 .setPositiveButton(R.string.ok, new OnClickListener() { | 57 .setIcon(android.R.drawable.ic_dialog_info) |
| 58 .setPositiveButton(R.string.ok, new OnClickListener() |
| 59 { |
| 58 @Override | 60 @Override |
| 59 public void onClick(DialogInterface arg0, int arg1) | 61 public void onClick(final DialogInterface arg0, final int arg1) |
| 60 { | 62 { |
| 61 // Start download service | 63 // Start download service |
| 62 startService(new Intent(UpdaterActivity.this, UpdaterService.class
).putExtras(extras)); | 64 UpdaterActivity.this.startService(new Intent(UpdaterActivity.this,
UpdaterService.class).putExtras(extras)); |
| 63 finish(); | 65 UpdaterActivity.this.finish(); |
| 64 } | 66 } |
| 65 }).setNegativeButton(R.string.cancel, new OnClickListener() { | 67 }).setNegativeButton(R.string.cancel, new OnClickListener() |
| 68 { |
| 66 @Override | 69 @Override |
| 67 public void onClick(DialogInterface dialog, int which) | 70 public void onClick(final DialogInterface dialog, final int which) |
| 68 { | 71 { |
| 69 finish(); | 72 UpdaterActivity.this.finish(); |
| 70 } | 73 } |
| 71 }).setOnCancelListener(new OnCancelListener() { | 74 }).setOnCancelListener(new OnCancelListener() |
| 75 { |
| 72 @Override | 76 @Override |
| 73 public void onCancel(DialogInterface dialog) | 77 public void onCancel(final DialogInterface dialog) |
| 74 { | 78 { |
| 75 finish(); | 79 UpdaterActivity.this.finish(); |
| 76 } | 80 } |
| 77 }).create().show(); | 81 }).create().show(); |
| 78 } | 82 } |
| 79 // Install downloaded update | 83 // Install downloaded update |
| 80 else | 84 else |
| 81 { | 85 { |
| 82 String file = getIntent().getStringExtra("path"); | 86 final String file = this.getIntent().getStringExtra("path"); |
| 83 File updateFile = new File(file); | 87 final File updateFile = new File(file); |
| 84 try | 88 try |
| 85 { | 89 { |
| 86 Intent installerIntent = new Intent(); | 90 final Intent installerIntent = new Intent(); |
| 87 installerIntent.setAction(Intent.ACTION_VIEW); | 91 installerIntent.setAction(Intent.ACTION_VIEW); |
| 88 installerIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | 92 installerIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 89 installerIntent.setDataAndType(Uri.fromFile(updateFile), "application/vn
d.android.package-archive"); | 93 installerIntent.setDataAndType(Uri.fromFile(updateFile), "application/vn
d.android.package-archive"); |
| 90 startActivity(installerIntent); | 94 this.startActivity(installerIntent); |
| 91 android.os.Process.killProcess(android.os.Process.myPid()); | 95 android.os.Process.killProcess(android.os.Process.myPid()); |
| 92 } | 96 } |
| 93 catch (Exception e) | 97 catch (final Exception e) |
| 94 { | 98 { |
| 95 e.printStackTrace(); | 99 e.printStackTrace(); |
| 96 } | 100 } |
| 97 } | 101 } |
| 98 } | 102 } |
| 99 | |
| 100 } | 103 } |
| OLD | NEW |