package se.blunden.donotdisturbsync;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;

public class SettingsActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Display the fragment as the main content.
        getFragmentManager().beginTransaction()
                .replace(android.R.id.content, new SettingsFragment())
                .commit();
    }

    private void sendUseRingerModeSetting(boolean useRingerMode) {
        // Build the Intent needed to start the WearMessageSenderService
        Intent wearMessageSenderServiceIntent = new Intent(this, WearMessageSenderService.class);
        wearMessageSenderServiceIntent.setAction(WearMessageSenderService.ACTION_SEND_MESSAGE);
        wearMessageSenderServiceIntent.putExtra(WearMessageSenderService.EXTRA_SETTING_USE_RINGER_MODE,
                String.valueOf(useRingerMode));

        startService(wearMessageSenderServiceIntent);
    }

    public static class SettingsFragment extends PreferenceFragment {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            // Load the preferences from XML
            addPreferencesFromResource(R.xml.preferences);

            final Preference useRingerMode = findPreference("use_ringer_mode");
            useRingerMode.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
                @Override
                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    Activity parentActivity = getActivity();
                    if (parentActivity instanceof SettingsActivity) {
                        ((SettingsActivity) parentActivity).sendUseRingerModeSetting((Boolean) newValue);
                    }

                    return true;
                }
            });
        }
    }
}

@@ -200,16 +200,135 @@
 ragment;
+%0Aimport android.support.v4.app.NavUtils;%0Aimport android.support.v7.app.AppCompatActivity;%0Aimport android.view.MenuItem;
 %0A%0Apublic
@@ -359,16 +359,25 @@
 extends 
+AppCompat
 Activity
@@ -693,16 +693,420 @@
 ommit();
+%0A%0A        if (getActionBar() != null) %7B%0A            getActionBar().setDisplayHomeAsUpEnabled(true);%0A        %7D%0A    %7D%0A%0A    @Override%0A    public boolean onOptionsItemSelected(MenuItem item) %7B%0A        switch (item.getItemId()) %7B%0A            case android.R.id.home:%0A                NavUtils.navigateUpFromSameTask(this);%0A                return true;%0A        %7D%0A        return super.onOptionsItemSelected(item);
 %0A    %7D%0A%0A

Fix actionbar and add up navigation