/*
Copyright 2009-2014 Urban Airship Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE URBAN AIRSHIP INC ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL URBAN AIRSHIP INC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package com.urbanairship.push.sample.preference;

import android.os.Bundle;
import android.preference.PreferenceActivity;

import com.urbanairship.AirshipConfigOptions;
import com.urbanairship.UAirship;
import com.urbanairship.preference.UAPreferenceAdapter;
import com.urbanairship.push.sample.R;

public class PreferencesActivity extends PreferenceActivity {

    private UAPreferenceAdapter preferenceAdapter;

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

        AirshipConfigOptions options = UAirship.shared().getAirshipConfigOptions();

        // Display the push preferences
        this.addPreferencesFromResource(R.xml.push_preferences);

        this.addPreferencesFromResource(R.xml.location_preferences);


        // Display the advanced settings
        this.addPreferencesFromResource(R.xml.advanced_preferences);

        // Creates the UAPreferenceAdapter with the entire preference screen
        preferenceAdapter = new UAPreferenceAdapter(getPreferenceScreen());
    }

    @Override
    protected void onStart() {
        super.onStart();

        // Activity instrumentation for analytic tracking
        UAirship.shared().getAnalytics().activityStarted(this);
    }

    @Override
    protected void onStop() {
        super.onStop();

        // Activity instrumentation for analytic tracking
        UAirship.shared().getAnalytics().activityStopped(this);

        // Apply any changed UA preferences from the preference screen
        preferenceAdapter.applyUrbanAirshipPreferences();
    }
}

@@ -1330,16 +1330,71 @@
 rence;%0A%0A
+import android.app.ActionBar;%0Aimport android.os.Build;%0A
 import a
@@ -1411,16 +1411,16 @@
 Bundle;%0A
-
 import a
@@ -1456,16 +1456,46 @@
 ctivity;
+%0Aimport android.view.MenuItem;
 %0A%0Aimport
@@ -2421,21 +2421,840 @@
 een());%0A
-    %7D
+%0A%0A%0A        // Set the actionBar to have up navigation if HoneyComb or higher.%0A        // PreferenceFragment or PreferenceActivity is not available in the support%0A        // library.  ActionBarSherlock provides a PreferenceActivity if you absolutely%0A        // need an action bar in the preferences on older devices.%0A        if (Build.VERSION.SDK_INT %3E= 11) %7B%0A            ActionBar actionBar = getActionBar();%0A            if (actionBar != null) %7B%0A                actionBar.setDisplayOptions(%0A                        ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP);%0A            %7D%0A        %7D%0A    %7D%0A%0A    @Override%0A    public boolean onOptionsItemSelected(MenuItem item) %7B%0A        if (item.getItemId() == android.R.id.home) %7B%0A            onBackPressed();%0A            return true;%0A        %7D%0A        return false;%0A    %7D%0A
 %0A%0A    @O

Fix preference activity not having an up action