/*
 * Copyright 2014 Hauke Lampe
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */


package org.openchaos.android.fooping;

import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.view.Menu;
import android.view.MenuItem;


public class SettingsFragment extends PreferenceFragment {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setHasOptionsMenu(true);
		addPreferencesFromResource(R.xml.preferences);
	}

	@Override
	public void onPrepareOptionsMenu(Menu menu) {
		super.onPrepareOptionsMenu(menu);
		// TODO: is this really the right way to
		// prevent multiple stacked preference fragments?
		MenuItem item = menu.findItem(R.id.Settings);
		if (item != null) {
			item.setVisible(false);
		}
	}
}

@@ -843,16 +843,50 @@
 w.Menu;%0A
+import android.view.MenuInflater;%0A
 import a
@@ -1068,16 +1068,115 @@
 State);%0A
+%09%09if (savedInstanceState == null) %7B%0A%09%09%09// setMenuVisibility(false); // Call requires API level 14%0A%09
 %09%09setHas
@@ -1194,16 +1194,17 @@
 (true);%0A
+%09
 %09%09addPre
@@ -1244,16 +1244,20 @@
 ences);%0A
+%09%09%7D%0A
 %09%7D%0A%0A%09@Ov
@@ -1278,22 +1278,21 @@
  void on
-Prepar
+Creat
 eOptions
@@ -1305,16 +1305,39 @@
 enu menu
+, MenuInflater inflater
 ) %7B%0A%09%09su
@@ -1346,14 +1346,13 @@
 r.on
-Prepar
+Creat
 eOpt
@@ -1364,16 +1364,26 @@
 enu(menu
+, inflater
 );%0A%09%09// 

disable button in onCreateOptionsMenu() instead of onPrepare...