package org.mozilla.mozstumbler;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;

public class NoticeDialog
{
    private Activity mActivity;
    private Prefs mPrefs;

    public NoticeDialog(Activity context, Prefs prefs) {
        mActivity = context;
        mPrefs = prefs;
    }

    public void show() {

        AlertDialog.Builder builder = new AlertDialog.Builder(mActivity)
            .setTitle(mActivity.getString(R.string.app_name))
            .setMessage(mActivity.getString(R.string.notice))
            .setPositiveButton(android.R.string.ok,
                               new Dialog.OnClickListener() {
                                   @Override
                                   public void onClick(DialogInterface di, int which) {
                                       mPrefs.setHasSeenNotice();
                                       di.dismiss();
                                   }
                               })
            .setNegativeButton(android.R.string.cancel,
                               new Dialog.OnClickListener() {
                                 @Override
                                 public void onClick(DialogInterface di, int which) {
                                     mActivity.finish();
                                 }
                             });
        builder.create().show();
    }
}

@@ -156,22 +156,21 @@
 rface;%0A%0A
-public
+final
  class N
@@ -180,17 +180,17 @@
 ceDialog
-%0A
+ 
 %7B%0A    pr
@@ -359,16 +359,16 @@
 %0A    %7D%0A%0A
-
     publ
@@ -383,16 +383,235 @@
 show() %7B
+%0A        final Dialog.OnCancelListener onCancel = new Dialog.OnCancelListener() %7B%0A            @Override%0A            public void onCancel(DialogInterface di) %7B%0A                mActivity.finish();%0A            %7D%0A        %7D;
 %0A%0A      
@@ -1522,33 +1522,36 @@
         
-mActivity.finish(
+onCancel.onCancel(di
 );%0A     
@@ -1611,16 +1611,59 @@
       %7D)
+%0A            .setOnCancelListener(onCancel)
 ;%0A      

Consolidate NoticeDialog's negative and cancel code paths