package com.bryanjswift.swiftnote.app;

import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.widget.Toast;
import com.bryanjswift.swiftnote.Constants;
import com.bryanjswift.swiftnote.R;

/** @author bryanjswift */
public class SwiftNoteLicenseHandler extends Handler {
    private static final String LOGGING_TAG = Constants.TAG + "SwiftNoteLicenseHandler";
    private final Context context;

    /**
     * Create a SwiftNoteLicenseHandler with the specified context
     * @param context to use when performing actions on the UI thread
     */
    public SwiftNoteLicenseHandler(final Context context) {
        this.context = context;
    }

    /**
     * Messages are received from SwiftNoteLicenseCallback when a License response is received
     * @see android.os.Handler#handleMessage(android.os.Message)
     */
    @Override
    public void handleMessage(final Message msg) {
        super.handleMessage(msg);
        switch (msg.what) {
            case Constants.MESSAGE_LICENSE_INVALID: handleInvalid(); break;
            case Constants.MESSAGE_LICENSE_VALID: handleValid(); break;
        }
    }

    /**
     * When the License is found to be valid perform these actions
     */
    private void handleValid() {
        // Don't do anything license is valid
        Log.d(LOGGING_TAG, "Valid license found");
    }

    /**
     * When the License is found to be invalid perform these actions
     */
    private void handleInvalid() {
        Log.d(LOGGING_TAG, "Invalid license found");
        Toast.makeText(context, R.string.license_invalid, Toast.LENGTH_LONG).show();
    }
}

@@ -52,23 +52,20 @@
 oid.
-content.Context
+app.Activity
 ;%0Aim
@@ -440,31 +440,33 @@
 e final 
-Context context
+Activity activity
 ;%0A%0A    /
@@ -527,23 +527,24 @@
 ecified 
-context
+activity
 %0A     * 
@@ -550,23 +550,24 @@
  @param 
-context
+activity
  to use 
@@ -660,57 +660,61 @@
 nal 
-Context context) %7B%0A        this.context = context
+Activity activity) %7B%0A        this.activity = activity
 ;%0A  
@@ -1606,15 +1606,16 @@
 ext(
-context
+activity
 , R.
@@ -1665,16 +1665,43 @@
 show();%0A
+        activity.finish();%0A
     %7D%0A%7D%0A

Make the LicenseHandler finish the current Activity if no valid license