package mozilla.org.webmaker;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.JavascriptInterface;
import android.widget.RelativeLayout;

import mozilla.org.webmaker.view.WebmakerWebView;
import org.json.JSONException;
import org.json.JSONObject;

public class WebmakerActivity extends Activity {

    protected WebmakerWebView view;
    protected JSONObject routeParams;
    protected String pageName;
    protected int id, layoutResID, menuResId;

    public WebmakerActivity(String pageName, int id, int layoutResID, int menuResId) {
        this.pageName = pageName;
        this.id = id;
        this.layoutResID = layoutResID;
        this.menuResId = menuResId;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Extract route information from intent extras
        routeParams = new JSONObject();

        Bundle intentExtras = getIntent().getExtras();
        if (intentExtras != null) {
            try {
                routeParams.put("project", intentExtras.get("project"));
                routeParams.put("page", intentExtras.get("page"));
                routeParams.put("element", intentExtras.get("element"));
                routeParams.put("attribute", intentExtras.get("attribute"));
                routeParams.put("editor", intentExtras.get("editor"));
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        // Add webview to layout
        setContentView(layoutResID);
        view = new WebmakerWebView(this, pageName, routeParams);
        RelativeLayout layout = (RelativeLayout) findViewById(id);
        layout.addView(view);
    }

    @Override
    public void onDestroy() {
        Log.v("wm", "onDestroy");
        if (view == null) return;
        view.destroy();
        view = null;
        super.onDestroy();
    }
}

@@ -1993,11 +1993,283 @@
 );%0A    %7D
+%0A%0A    @Override%0A    public boolean onOptionsItemSelected(MenuItem item) %7B%0A        switch(item.getItemId()) %7B%0A            case android.R.id.home:%0A                onBackPressed();%0A                return true;%0A        %7D%0A        return super.onOptionsItemSelected(item);%0A    %7D
 %0A%7D%0A

Assign 'home' button to back button behavior. Resolves GH-1695