Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: src/org/adblockplus/android/updater/UpdaterActivity.java

Issue 5697499218051072: Usage of new API, cleanups (reduced) (Closed)
Left Patch Set: Fixed leftover first-batch review issues. Created April 16, 2014, 5:51 p.m.
Right Patch Set: Even more review issues fixed. Created April 28, 2014, 10:18 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // Prompt user to download update 46 // Prompt user to download update
47 if ("download".equals(getIntent().getAction())) 47 if ("download".equals(getIntent().getAction()))
48 { 48 {
49 final Bundle extras = 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 finish(); 52 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)) 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 startService(new Intent(UpdaterActivity.this, UpdaterService.class ).putExtras(extras)); 62 startService(new Intent(UpdaterActivity.this, UpdaterService.class ).putExtras(extras));
65 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 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 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 = 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 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 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld