/*
 * JBoss, Home of Professional Open Source
 * Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
 * contributors by the @authors tag. See the copyright.txt in the
 * distribution for a full listing of 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 org.jboss.aerogear.unifiedpush.helloworld.activities;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

import org.jboss.aerogear.android.core.Callback;
import org.jboss.aerogear.android.unifiedpush.MessageHandler;
import org.jboss.aerogear.android.unifiedpush.RegistrarManager;
import org.jboss.aerogear.android.unifiedpush.gcm.AeroGearGCMPushRegistrar;
import org.jboss.aerogear.android.unifiedpush.gcm.UnifiedPushMessage;
import org.jboss.aerogear.android.unifiedpush.metrics.UnifiedPushMetricsMessage;
import org.jboss.aerogear.unifiedpush.helloworld.Constants;
import org.jboss.aerogear.unifiedpush.helloworld.HelloWorldApplication;
import org.jboss.aerogear.unifiedpush.helloworld.R;
import org.jboss.aerogear.unifiedpush.helloworld.callback.MetricsCallback;
import org.jboss.aerogear.unifiedpush.helloworld.handler.NotificationBarMessageHandler;

import static org.jboss.aerogear.unifiedpush.helloworld.Constants.PUSH_REGISTER_NAME;

public class MessagesActivity extends ActionBarActivity implements MessageHandler {

    private HelloWorldApplication application;
    private ListView listView;
    private static final String IGNORE_EXTRAS = "MessageActivity.ignore_extras";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.messages);

        application = (HelloWorldApplication) getApplication();

        if(getIntent().getBooleanExtra(Constants.PUSH_MESSAGE_FROM_BACKGROUND, false)) {
            UnifiedPushMetricsMessage metricsMessage = new UnifiedPushMetricsMessage(getIntent().getExtras());
            application.sendMetric(metricsMessage, new MetricsCallback());
        }

        View emptyView = findViewById(R.id.empty);
        listView = (ListView) findViewById(R.id.messages);
        listView.setEmptyView(emptyView);
    }

    @Override
    protected void onResume() {
        super.onResume();
        RegistrarManager.registerMainThreadHandler(this);
        RegistrarManager.unregisterBackgroundThreadHandler(NotificationBarMessageHandler.instance);

        displayMessages();
    }

    @Override
    protected void onPause() {
        super.onPause();
        RegistrarManager.unregisterMainThreadHandler(this);
        RegistrarManager.registerBackgroundThreadHandler(NotificationBarMessageHandler.instance);
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putBoolean(IGNORE_EXTRAS, true);
    }

    @Override
    public void onMessage(Context context, Bundle bundle) {
        addNewMessage(bundle);

        UnifiedPushMetricsMessage metricsMessage = new UnifiedPushMetricsMessage(bundle);
        application.sendMetric(metricsMessage, new MetricsCallback());
    }

    @Override
    public void onDeleteMessage(Context context, Bundle message) {
    }

    @Override
    public void onError() {
    }

    private void addNewMessage(Bundle bundle) {
        String message = bundle.getString(UnifiedPushMessage.ALERT_KEY);
        application.addMessage(message);
        displayMessages();
    }

    private void displayMessages() {
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(),
            R.layout.message_item, application.getMessages());
        listView.setAdapter(adapter);
    }
}

@@ -2088,89 +2088,8 @@
 iew;
-%0A    private static final String IGNORE_EXTRAS = %22MessageActivity.ignore_extras%22;
 %0A%0A  
@@ -3259,182 +3259,8 @@
  %7D%0A%0A
-    @Override%0A    protected void onSaveInstanceState(Bundle outState) %7B%0A        super.onSaveInstanceState(outState);%0A        outState.putBoolean(IGNORE_EXTRAS, true);%0A    %7D%0A%0A
     

Remove unnecessary flag