|
1 | 1 | /* |
2 | 2 | * This file is part of Android Code Editor. |
3 | 3 | * |
4 | | - * Android Code Editor. is free software: you can redistribute it and/or modify |
| 4 | + * Android Code Editor is free software: you can redistribute it and/or modify |
5 | 5 | * it under the terms of the GNU General Public License as published by |
6 | 6 | * the Free Software Foundation, either version 3 of the License, or |
7 | 7 | * (at your option) any later version. |
8 | 8 | * |
9 | | - * Android Code Editor. is distributed in the hope that it will be useful, |
| 9 | + * Android Code Editor is distributed in the hope that it will be useful, |
10 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | * GNU General Public License for more details. |
13 | 13 | * |
14 | 14 | * You should have received a copy of the GNU General Public License |
15 | 15 | * along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>. |
16 | 16 | */ |
| 17 | + |
17 | 18 | package android.code.editor.activity; |
18 | 19 |
|
19 | 20 | import android.code.editor.ui.MaterialColorHelper; |
|
23 | 24 | import com.google.android.material.color.DynamicColors; |
24 | 25 |
|
25 | 26 | public class BaseActivity extends AppCompatActivity { |
26 | | - public int theme; |
| 27 | + public int theme; |
27 | 28 |
|
28 | | - @Override |
29 | | - protected void onCreate(Bundle savedInstanceState) { |
30 | | - super.onCreate(savedInstanceState); |
31 | | - if (!DynamicColors.isDynamicColorAvailable()) { |
32 | | - theme = MaterialColorHelper.getCurrentTheme(this); |
33 | | - MaterialColorHelper.setUpTheme(this); |
| 29 | + @Override |
| 30 | + protected void onCreate(Bundle savedInstanceState) { |
| 31 | + super.onCreate(savedInstanceState); |
| 32 | + if (!DynamicColors.isDynamicColorAvailable()) { |
| 33 | + theme = MaterialColorHelper.getCurrentTheme(this); |
| 34 | + MaterialColorHelper.setUpTheme(this); |
| 35 | + } |
| 36 | + refreshThemeStatusIfRequired(); |
34 | 37 | } |
35 | | - refreshThemeStatusIfRequired(); |
36 | | - } |
37 | | - |
38 | | - @Override |
39 | | - protected void onResume() { |
40 | | - super.onResume(); |
41 | | - refreshThemeColorStatusIfRequired(); |
42 | | - refreshThemeStatusIfRequired(); |
43 | | - } |
44 | 38 |
|
45 | | - public void refreshThemeColorStatusIfRequired() { |
46 | | - if (!DynamicColors.isDynamicColorAvailable()) { |
47 | | - if (MaterialColorHelper.getCurrentTheme(this) != theme) { |
48 | | - recreate(); |
49 | | - } |
| 39 | + @Override |
| 40 | + protected void onResume() { |
| 41 | + super.onResume(); |
| 42 | + refreshThemeColorStatusIfRequired(); |
| 43 | + refreshThemeStatusIfRequired(); |
50 | 44 | } |
51 | | - } |
52 | 45 |
|
53 | | - public void refreshThemeStatusIfRequired() { |
54 | | - switch (SettingActivity.getThemeTypeInInt(this)) { |
55 | | - case 0: |
56 | | - if (AppCompatDelegate.getDefaultNightMode() != AppCompatDelegate.MODE_NIGHT_NO) { |
57 | | - AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); |
| 46 | + public void refreshThemeColorStatusIfRequired() { |
| 47 | + if (!DynamicColors.isDynamicColorAvailable()) { |
| 48 | + if (MaterialColorHelper.getCurrentTheme(this) != theme) { |
| 49 | + recreate(); |
| 50 | + } |
58 | 51 | } |
59 | | - break; |
60 | | - case 1: |
61 | | - if (AppCompatDelegate.getDefaultNightMode() != AppCompatDelegate.MODE_NIGHT_YES) { |
62 | | - AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); |
63 | | - } |
64 | | - break; |
65 | | - case 2: |
66 | | - if (AppCompatDelegate.getDefaultNightMode() != AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM) { |
67 | | - AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); |
| 52 | + } |
| 53 | + |
| 54 | + public void refreshThemeStatusIfRequired() { |
| 55 | + switch (SettingActivity.getThemeTypeInInt(this)) { |
| 56 | + case 0: |
| 57 | + if (AppCompatDelegate.getDefaultNightMode() != AppCompatDelegate.MODE_NIGHT_NO) { |
| 58 | + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); |
| 59 | + } |
| 60 | + break; |
| 61 | + case 1: |
| 62 | + if (AppCompatDelegate.getDefaultNightMode() != AppCompatDelegate.MODE_NIGHT_YES) { |
| 63 | + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); |
| 64 | + } |
| 65 | + break; |
| 66 | + case 2: |
| 67 | + if (AppCompatDelegate.getDefaultNightMode() |
| 68 | + != AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM) { |
| 69 | + AppCompatDelegate.setDefaultNightMode( |
| 70 | + AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); |
| 71 | + } |
| 72 | + break; |
68 | 73 | } |
69 | | - break; |
70 | 74 | } |
71 | | - } |
72 | 75 | } |
0 commit comments