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

Side by Side Diff: src/org/adblockplus/android/updater/UpdaterActivity.java

Issue 5697499218051072: Usage of new API, cleanups (reduced) (Closed)
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:
View unified diff | Download patch
OLDNEW
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
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 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(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)).setIcon(android.R.drawable.ic _dialog_info) 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 .setPositiveButton(R.string.ok, new OnClickListener() { 57 .setPositiveButton(R.string.ok, new OnClickListener() {
58 @Override 58 @Override
59 public void onClick(DialogInterface arg0, int arg1) 59 public void onClick(final DialogInterface arg0, final int arg1)
60 { 60 {
61 // Start download service 61 // Start download service
62 startService(new Intent(UpdaterActivity.this, UpdaterService.class ).putExtras(extras)); 62 startService(new Intent(UpdaterActivity.this, UpdaterService.class ).putExtras(extras));
63 finish(); 63 finish();
64 } 64 }
65 }).setNegativeButton(R.string.cancel, new OnClickListener() { 65 }).setNegativeButton(R.string.cancel, new OnClickListener() {
66 @Override 66 @Override
67 public void onClick(DialogInterface dialog, int which) 67 public void onClick(final DialogInterface dialog, final int which)
68 { 68 {
69 finish(); 69 finish();
70 } 70 }
71 }).setOnCancelListener(new OnCancelListener() { 71 }).setOnCancelListener(new OnCancelListener() {
72 @Override 72 @Override
73 public void onCancel(DialogInterface dialog) 73 public void onCancel(final DialogInterface dialog)
74 { 74 {
75 finish(); 75 finish();
76 } 76 }
77 }).create().show(); 77 }).create().show();
78 } 78 }
79 // Install downloaded update 79 // Install downloaded update
80 else 80 else
81 { 81 {
82 String file = getIntent().getStringExtra("path"); 82 final String file = getIntent().getStringExtra("path");
83 File updateFile = new File(file); 83 final File updateFile = new File(file);
84 try 84 try
85 { 85 {
86 Intent installerIntent = new Intent(); 86 final Intent installerIntent = new Intent();
87 installerIntent.setAction(Intent.ACTION_VIEW); 87 installerIntent.setAction(Intent.ACTION_VIEW);
88 installerIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 88 installerIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
89 installerIntent.setDataAndType(Uri.fromFile(updateFile), "application/vn d.android.package-archive"); 89 installerIntent.setDataAndType(Uri.fromFile(updateFile), "application/vn d.android.package-archive");
90 startActivity(installerIntent); 90 startActivity(installerIntent);
91 android.os.Process.killProcess(android.os.Process.myPid()); 91 android.os.Process.killProcess(android.os.Process.myPid());
92 } 92 }
93 catch (Exception e) 93 catch (final Exception e)
94 { 94 {
95 e.printStackTrace(); 95 e.printStackTrace();
96 } 96 }
97 } 97 }
98 } 98 }
99 99
100 } 100 }
OLDNEW
« no previous file with comments | « src/org/adblockplus/android/updater/AlarmReceiver.java ('k') | src/org/adblockplus/android/updater/UpdaterService.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld