2013-04-22 14:39:30 -07:00
|
|
|
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
package org.mozilla.gecko;
|
|
|
|
|
|
|
|
import android.preference.Preference;
|
|
|
|
import android.preference.PreferenceCategory;
|
|
|
|
import android.preference.PreferenceFragment;
|
|
|
|
import android.preference.PreferenceScreen;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
/* A simple implementation of PreferenceFragment for large screen devices
|
|
|
|
* This will strip category headers (so that they aren't shown to the user twice)
|
|
|
|
* as well as initializing Gecko prefs when a fragment is shown.
|
|
|
|
*/
|
|
|
|
public class GeckoPreferenceFragment extends PreferenceFragment {
|
|
|
|
|
|
|
|
private static final String LOGTAG = "GeckoPreferenceFragment";
|
2013-05-14 23:45:51 -07:00
|
|
|
private int mPrefsRequestId = 0;
|
2013-04-22 14:39:30 -07:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
String resource = getArguments().getString("resource");
|
|
|
|
int res = getActivity().getResources().getIdentifier(resource,
|
|
|
|
"xml",
|
|
|
|
getActivity().getPackageName());
|
|
|
|
addPreferencesFromResource(res);
|
|
|
|
|
2013-05-10 21:28:17 -07:00
|
|
|
PreferenceScreen screen = getPreferenceScreen();
|
2013-04-22 14:39:30 -07:00
|
|
|
setPreferenceScreen(screen);
|
2013-05-14 23:45:51 -07:00
|
|
|
mPrefsRequestId = ((GeckoPreferences)getActivity()).setupPreferences(screen);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDestroy() {
|
|
|
|
super.onDestroy();
|
|
|
|
if (mPrefsRequestId > 0) {
|
|
|
|
PrefsHelper.removeObserver(mPrefsRequestId);
|
|
|
|
}
|
2013-04-22 14:39:30 -07:00
|
|
|
}
|
|
|
|
}
|