Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.6 KiB

  1. package eu.faircode.email;
  2. /*
  3. This file is part of Safe email.
  4. Safe email is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. NetGuard is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with NetGuard. If not, see <http://www.gnu.org/licenses/>.
  14. Copyright 2018 by Marcel Bokhorst (M66B)
  15. */
  16. import android.content.SharedPreferences;
  17. import android.content.res.Configuration;
  18. import android.os.Bundle;
  19. import android.preference.PreferenceManager;
  20. import android.util.Log;
  21. import androidx.appcompat.app.AppCompatActivity;
  22. abstract class ActivityBase extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
  23. @Override
  24. protected void onCreate(Bundle savedInstanceState) {
  25. Log.i(Helper.TAG, "Create " + this.getClass().getName());
  26. SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
  27. String theme = prefs.getString("theme", "light");
  28. setTheme("light".equals(theme) ? R.style.AppThemeLight : R.style.AppThemeDark);
  29. PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
  30. super.onCreate(savedInstanceState);
  31. }
  32. @Override
  33. protected void onResume() {
  34. Log.i(Helper.TAG, "Resume " + this.getClass().getName());
  35. super.onResume();
  36. }
  37. @Override
  38. protected void onPause() {
  39. Log.i(Helper.TAG, "Pause " + this.getClass().getName());
  40. super.onPause();
  41. }
  42. @Override
  43. public void onConfigurationChanged(Configuration newConfig) {
  44. Log.i(Helper.TAG, "Config " + this.getClass().getName());
  45. super.onConfigurationChanged(newConfig);
  46. }
  47. @Override
  48. protected void onDestroy() {
  49. Log.i(Helper.TAG, "Destroy " + this.getClass().getName());
  50. PreferenceManager.getDefaultSharedPreferences(this).unregisterOnSharedPreferenceChangeListener(this);
  51. super.onDestroy();
  52. }
  53. @Override
  54. public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
  55. Log.i(Helper.TAG, "Preference " + key + "=" + prefs.getAll().get(key));
  56. if ("theme".equals(key))
  57. recreate();
  58. }
  59. }