Avoid potential negative array index access to cached text.
[LibreOffice.git] / android / source / src / java / org / libreoffice / SettingsActivity.java
blob5623abc2e597c57e323c6baa5faf5c29bf31978e
1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
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 {
18 @Override
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())
25 .commit();
28 public static class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
29 @Override
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"));
40 @Override
41 public void onResume() {
42 super.onResume();
43 getPreferenceScreen().getSharedPreferences()
44 .registerOnSharedPreferenceChangeListener(this);
47 @Override
48 public void onPause() {
49 super.onPause();
50 getPreferenceScreen().getSharedPreferences()
51 .unregisterOnSharedPreferenceChangeListener(this);
54 @Override
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: */