1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 package org
.libreoffice
;
11 import android
.app
.Activity
;
12 import android
.content
.SharedPreferences
;
13 import android
.os
.Bundle
;
14 import android
.preference
.PreferenceFragment
;
15 import android
.preference
.PreferenceGroup
;
17 public class SettingsActivity
extends Activity
{
19 protected void onCreate(Bundle savedInstanceState
) {
20 super.onCreate(savedInstanceState
);
22 // Display the fragment as the main content.
23 getFragmentManager().beginTransaction()
24 .replace(android
.R
.id
.content
, new SettingsFragment())
28 public static class SettingsFragment
extends PreferenceFragment
implements SharedPreferences
.OnSharedPreferenceChangeListener
{
30 public void onCreate(Bundle savedInstanceState
) {
31 super.onCreate(savedInstanceState
);
32 addPreferencesFromResource(R
.xml
.libreoffice_preferences
);
33 if(!BuildConfig
.ALLOW_EDITING
) {
34 PreferenceGroup generalGroup
= (PreferenceGroup
) findPreference("PREF_CATEGORY_GENERAL");
35 generalGroup
.removePreference(generalGroup
.findPreference("ENABLE_EXPERIMENTAL"));
36 generalGroup
.removePreference(generalGroup
.findPreference("ENABLE_DEVELOPER"));
41 public void onResume() {
43 getPreferenceScreen().getSharedPreferences()
44 .registerOnSharedPreferenceChangeListener(this);
48 public void onPause() {
50 getPreferenceScreen().getSharedPreferences()
51 .unregisterOnSharedPreferenceChangeListener(this);
55 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences
, String key
) {
56 SettingsListenerModel
.getInstance().changePreferenceState(sharedPreferences
, key
);
57 if(key
.equals("DISPLAY_LANGUAGE")){
58 getActivity().recreate();
63 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */