/**
 * Copyright 2015 Red Hat, Inc., and individual contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.feedhenry.helloworld;

import android.os.*;
import android.support.v4.app.*;
import android.util.*;
import android.view.*;
import android.widget.*;

import com.feedhenry.sdk.*;
import com.feedhenry.sdk.api.*;
import com.feedhenry.sdk.exceptions.*;

import org.json.fh.*;

public class HelloFragment extends Fragment {

    private static final String TAG = InitFragment.class.getName();

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        final View view = View.inflate(getActivity(), R.layout.hello_fragment, null);

        final TextView mResponse = (TextView) view.findViewById(R.id.cloud_response);
        final EditText mName = (EditText) view.findViewById(R.id.name);
        final Button mCloudButton = (Button) view.findViewById(R.id.button);
        mCloudButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                mResponse.setText("");
                mCloudButton.setEnabled(false);
                cloudCall(v, mName.getText().toString(), mResponse);
                mName.setText("");
            }
        });

        return view;
    }

    private void cloudCall(final View button, final String name, final TextView response) {
        try {
            JSONObject params = new JSONObject();
            params.put("hello", name);  // { 'hello': $name }

            FHCloudRequest request = FH.buildCloudRequest("hello", "POST", null, params);
            request.executeAsync(new FHActCallback() {
                @Override
                public void success(FHResponse fhResponse) {
                    Log.d(TAG, "cloudCall - success");
                    button.setEnabled(true);
                    response.setText(fhResponse.getJson().getString("text"));
                }

                @Override
                public void fail(FHResponse fhResponse) {
                    Log.d(TAG, "cloudCall - fail");
                    Log.e(TAG, fhResponse.getErrorMessage(), fhResponse.getError());
                    button.setEnabled(true);
                    response.setText(fhResponse.getErrorMessage());
                }
            });
        } catch (FHNotReadyException e) {
            Log.e(TAG, e.getMessage(), e.getCause());
            button.setEnabled(true);
            response.setText(e.getMessage());
        }
    }

}

@@ -2469,12 +2469,11 @@
 ng(%22
-text
+msg
 %22));

Fix cloud response message