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

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

Issue 8491079: ABP/Android update service (Closed)
Patch Set: Created Oct. 5, 2012, 9:26 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
(Empty)
1 package org.adblockplus.android.updater;
2
3 import java.io.File;
4
5 import org.adblockplus.android.R;
6
7 import android.app.Activity;
8 import android.app.AlertDialog;
9 import android.content.DialogInterface;
10 import android.content.DialogInterface.OnCancelListener;
11 import android.content.DialogInterface.OnClickListener;
12 import android.content.Intent;
13 import android.net.Uri;
14 import android.os.Bundle;
15 import android.view.Window;
16
17 /**
18 * Prompts user to download update or installs downloaded update.
19 */
20 public class UpdaterActivity extends Activity
21 {
22 @Override
23 public void onCreate(Bundle savedInstanceState)
24 {
25 super.onCreate(savedInstanceState);
26
27 requestWindowFeature(Window.FEATURE_NO_TITLE);
28
29 // Prompt user to download update
30 if ("download".equals(getIntent().getAction()))
31 {
32 final Bundle extras = getIntent().getExtras();
33 if (extras == null || extras.getString("url") == null)
34 {
35 finish();
36 return;
37 }
38
39 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)
40 .setPositiveButton(R.string.ok, new OnClickListener() {
41 @Override
42 public void onClick(DialogInterface arg0, int arg1)
43 {
44 // Start download service
45 startService(new Intent(UpdaterActivity.this, UpdaterService.class ).putExtras(extras));
46 finish();
47 }
48 }).setNegativeButton(R.string.cancel, new OnClickListener() {
49 @Override
50 public void onClick(DialogInterface dialog, int which)
51 {
52 finish();
53 }
54 }).setOnCancelListener(new OnCancelListener() {
55 @Override
56 public void onCancel(DialogInterface dialog)
57 {
58 finish();
59 }
60 }).create().show();
61 }
62 // Install downloaded update
63 else
64 {
65 String file = getIntent().getStringExtra("path");
66 File updateFile = new File(file);
67 try
68 {
69 Intent installerIntent = new Intent();
70 installerIntent.setAction(Intent.ACTION_VIEW);
71 installerIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
72 installerIntent.setDataAndType(Uri.fromFile(updateFile), "application/vn d.android.package-archive");
73 startActivity(installerIntent);
74 android.os.Process.killProcess(android.os.Process.myPid());
75 }
76 catch (Exception e)
77 {
78 e.printStackTrace();
79 }
80 }
81 }
82
83 }
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