KP2ASoftKeyboard2: Fix keyboard settings theme

The rest of application activities can use both light and dark themes.
This change improves consistency (keyboard settings will also update
their theme) despite the fact that it is not exactly the same theme.
Using Afc theme would require duplicating of resources. Additionally
added missing copyright lines.
This commit is contained in:
Wiktor Lawski 2014-09-13 15:35:55 +02:00
parent 9ebbea3a20
commit 08105d98de
3 changed files with 51 additions and 3 deletions

View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2014 Wiktor Lawski <wiktor.lawski@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package keepass2android.softkeyboard;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.SharedPreferences;
public class Design {
@SuppressLint("InlinedApi")
public static void updateTheme(Activity activity, SharedPreferences prefs) {
if (android.os.Build.VERSION.SDK_INT >= 11
/* android.os.Build.VERSION_CODES.HONEYCOMB */) {
String design = prefs.getString("design_key", "Light");
if (design.equals("Light")) {
activity.setTheme(android.R.style.Theme_Holo_Light);
} else {
activity.setTheme(android.R.style.Theme_Holo);
}
}
}
}

View File

@ -1,5 +1,7 @@
/*
* Copyright (C) 2008-2009 Google Inc.
* Copyright (C) 2014 Philipp Crocoll <crocoapps@googlemail.com>
* Copyright (C) 2014 Wiktor Lawski <wiktor.lawski@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@ -75,10 +77,13 @@ public class InputLanguageSelection extends PreferenceActivity {
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.language_prefs);
// Get the settings preferences
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
Design.updateTheme(this, sp);
super.onCreate(icicle);
addPreferencesFromResource(R.xml.language_prefs);
mSelectedLanguages = sp.getString(KP2AKeyboard.PREF_SELECTED_LANGUAGES, "");
String[] languageList = mSelectedLanguages.split(",");
mAvailableLanguages = getUniqueLocales();

View File

@ -1,5 +1,7 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* Copyright (C) 2014 Philipp Crocoll <crocoapps@googlemail.com>
* Copyright (C) 2014 Wiktor Lawski <wiktor.lawski@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@ -29,6 +31,7 @@ import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceGroup;
import android.preference.PreferenceManager;
import android.speech.SpeechRecognizer;
import android.text.AutoText;
import android.util.Log;
@ -52,11 +55,14 @@ public class LatinIMESettings extends PreferenceActivity
@Override
protected void onCreate(Bundle icicle) {
SharedPreferences prefs =
PreferenceManager.getDefaultSharedPreferences(this);
Design.updateTheme(this, prefs);
super.onCreate(icicle);
addPreferencesFromResource(R.xml.prefs);
mQuickFixes = (CheckBoxPreference) findPreference(QUICK_FIXES_KEY);
mSettingsKeyPreference = (ListPreference) findPreference(PREF_SETTINGS_KEY);
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
prefs.registerOnSharedPreferenceChangeListener(this);