package ti.modules.titanium.ui.android;

import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.TiApplication;
import org.appcelerator.titanium.util.TiRHelper;

import android.os.Bundle;
import android.preference.PreferenceFragment;

public class TiPreferencesFragment extends PreferenceFragment {
    
    private static final String TAG = "TiPreferencesFragment";
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        String prefsName = getArguments().getString(TiPreferencesActivity.PREFS_KEY);
        
        // Find the layout file, do nothing if not found
        try {
            getPreferenceManager().setSharedPreferencesName(TiApplication.APPLICATION_PREFERENCES_NAME);
            int resid = TiRHelper.getResource("xml." + prefsName);
            if (resid != 0) {
                addPreferencesFromResource(resid);
            } else {
                Log.e(TAG, "xml." + prefsName + " preferences not found.");
                return;
            }
        } catch (TiRHelper.ResourceNotFoundException e) {
            Log.e(TAG, "Error loading preferences: " + e.getMessage());
            return;
        }
    }
}

@@ -379,21 +379,60 @@
 gment%22;%0A
+    private CharSequence title = null;%0A
     %0A
-
     @Ove
@@ -630,25 +630,17 @@
 S_KEY);%0A
-        
 %0A
+
         
@@ -955,16 +955,146 @@
 resid);%0A
+                if (getPreferenceScreen() != null) %7B%0A                %09title = getPreferenceScreen().getTitle();%0A                %7D%0A
         
@@ -1380,16 +1380,164 @@
       %7D%0A
-
     %7D%0A
+%0A%09@Override%0A%09public void onResume() %7B%0A%09%09super.onResume();%0A%09%09if (title != null && getActivity() != null) %7B%0A%09%09%09getActivity().setTitle(title);%0A%09%09%7D%0A%09%7D%0A%0A
 %7D%0A

Allow for setting of the Title