package me.ryanpetschek.gatekeeper;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.widget.ImageView;
import android.widget.TextView;

public class BusinessActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_business);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        setTitle("Building");

        Building source = Nearby.currentBuilding;
        Bitmap image = source.getImage();
        String name = source.getName();
        String address = source.getAddress();
        String desc = source.getDescription();

        ImageView imageView = (ImageView) findViewById(R.id.buildingImage);
        TextView nameText = (TextView) findViewById(R.id.txtName);
        TextView addrText = (TextView) findViewById(R.id.txtAddress);
        TextView descText = (TextView) findViewById(R.id.txtDesc);

        imageView.setImageBitmap(image);
        nameText.setText(name);
        addrText.setText(address);
        descText.setText(desc);
    }

}

@@ -49,49 +49,165 @@
 oid.
-graphics.Bitmap;%0Aimport android.os.Bundle
+content.Intent;%0Aimport android.content.SharedPreferences;%0Aimport android.graphics.Bitmap;%0Aimport android.os.Bundle;%0Aimport android.support.v7.app.AlertDialog
 ;%0Aim
@@ -295,16 +295,72 @@
 oolbar;%0A
+import android.view.View;%0Aimport android.widget.Button;%0A
 import a
@@ -417,16 +417,313 @@
 tView;%0A%0A
+import com.loopj.android.http.AsyncHttpClient;%0Aimport com.loopj.android.http.JsonHttpResponseHandler;%0Aimport com.loopj.android.http.RequestParams;%0A%0Aimport org.json.JSONException;%0Aimport org.json.JSONObject;%0Aimport org.spongycastle.util.encoders.Hex;%0A%0Aimport cz.msebera.android.httpclient.Header;%0A%0A
 public c
@@ -884,24 +884,108 @@
 anceState);%0A
+        final SharedPreferences settings = getSharedPreferences(%22GK_settings%22, 0);%0A%0A
         setC
@@ -1254,24 +1254,30 @@
 ();%0A        
+final 
 String name 
@@ -1667,24 +1667,2267 @@
 .txtDesc);%0A%0A
+        Button requestButton = (Button) findViewById(R.id.btnRequest);%0A        final AlertDialog alertDialog = new AlertDialog.Builder(this).create();%0A        requestButton.setOnClickListener(new View.OnClickListener() %7B%0A            public void onClick(View v) %7B%0A                AsyncHttpClient client = new AsyncHttpClient();%0A                String url = %22https://gatekeeper.ryanpetschek.me/%22 + name.replace(%22 %22, %22-%22).toLowerCase() + %22/api/request%22;%0A%0A                RequestParams params = new RequestParams();%0A                params.add(%22name%22, settings.getString(%22name%22, %22%22));%0A                params.add(%22imageUrl%22, settings.getString(%22pictureURL%22, %22%22));%0A                params.add(%22publicKey%22, settings.getString(%22publicKey%22, %22%22));%0A%0A                client.post(url, params, new JsonHttpResponseHandler() %7B%0A                    @Override%0A                    public void onSuccess(int statusCode, Header%5B%5D headers, JSONObject response) %7B%0A                        if (statusCode != 200) %7B%0A                            alertDialog.setTitle(%22Error%22);%0A                            try %7B%0A                                alertDialog.setMessage(response.getString(%22error%22));%0A                            %7D%0A                            catch (JSONException err) %7B%0A                                alertDialog.setMessage(err.getMessage());%0A                            %7D%0A                            alertDialog.show();%0A                            return;%0A                        %7D%0A                        alertDialog.setTitle(%22Success%22);%0A                        alertDialog.setMessage(%22Your request for access has been submitted%22);%0A                    %7D%0A%0A                    @Override%0A                    public void onFailure(int statusCode, Header%5B%5D headers, Throwable throwable, JSONObject response) %7B%0A                        alertDialog.setTitle(%22Error%22);%0A                        try %7B%0A                            alertDialog.setMessage(response.getString(%22error%22));%0A                        %7D%0A                        catch (JSONException err) %7B%0A                            alertDialog.setMessage(err.getMessage());%0A                        %7D%0A                        alertDialog.show();%0A                    %7D%0A                %7D);%0A            %7D%0A        %7D);%0A%0A
         imag

Implement request access buttons for buildings