/* * Tweetings - Twitter client for Android * * Copyright (C) 2012-2013 RBD Solutions Limited <apps@tweetings.net> * Copyright (C) 2012 Mariotaku Lee <mariotaku.lee@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.dwdesign.tweetings.activity; import com.dwdesign.tweetings.Constants; import com.dwdesign.tweetings.R; import com.dwdesign.tweetings.util.OnBackPressedAccessor; import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; import android.os.Build; import android.os.Bundle; import android.preference.PreferenceActivity; import android.view.KeyEvent; @SuppressWarnings("deprecation") public class InternalSettingsActivity extends PreferenceActivity implements Constants { @Override public void onCreate(final Bundle savedInstanceState) { setTheme(); super.onCreate(savedInstanceState); getPreferenceManager().setSharedPreferencesName(SHARED_PREFERENCES_NAME); addPreferencesFromResource(R.xml.settings); } @Override public boolean onKeyUp(final int keyCode, final KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: { final Activity activity = getParent(); if (activity instanceof SettingsActivity && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) { OnBackPressedAccessor.onBackPressed(activity); return true; } break; } } return super.onKeyUp(keyCode, event); } public void setTheme() { final SharedPreferences preferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); final boolean is_dark_theme = preferences.getBoolean(PREFERENCE_KEY_DARK_THEME, true); final boolean solid_color_background = preferences.getBoolean(PREFERENCE_KEY_SOLID_COLOR_BACKGROUND, false); setTheme(is_dark_theme ? R.style.Theme_Twidere : R.style.Theme_Twidere_Light); if (solid_color_background) { getWindow().setBackgroundDrawableResource(is_dark_theme ? android.R.color.black : android.R.color.white); } } }