|
16 | 16 |
|
17 | 17 | package com.pranavpandey.android.dynamic.support;
|
18 | 18 |
|
| 19 | +import android.annotation.TargetApi; |
19 | 20 | import android.app.Application;
|
20 | 21 | import android.content.Context;
|
21 | 22 | import android.content.SharedPreferences;
|
22 | 23 | import android.content.pm.ActivityInfo;
|
23 | 24 | import android.content.res.Configuration;
|
| 25 | +import android.os.Build; |
24 | 26 | import android.preference.PreferenceManager;
|
25 | 27 |
|
26 | 28 | import androidx.annotation.NonNull;
|
@@ -78,20 +80,20 @@ public void onCreate() {
|
78 | 80 | setDynamicTheme();
|
79 | 81 | }
|
80 | 82 |
|
| 83 | + @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) |
81 | 84 | @Override
|
82 | 85 | public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
83 | 86 | super.onConfigurationChanged(newConfig);
|
84 | 87 |
|
85 | 88 | int diff = mConfiguration.diff(new Configuration(newConfig));
|
86 |
| - if ((diff & ActivityInfo.CONFIG_LOCALE) != 0 |
87 |
| - || (diff & ActivityInfo.CONFIG_FONT_SCALE) != 0 |
88 |
| - || (diff & ActivityInfo.CONFIG_ORIENTATION) != 0 |
89 |
| - || (diff & ActivityInfo.CONFIG_UI_MODE) != 0 |
90 |
| - || (DynamicSdkUtils.is17() |
91 |
| - && (diff & ActivityInfo.CONFIG_DENSITY) != 0)) { |
92 |
| - DynamicTheme.getInstance().onDynamicChanged(true, false); |
93 |
| - mConfiguration = new Configuration(newConfig); |
94 |
| - } |
| 89 | + DynamicTheme.getInstance().onDynamicConfigurationChanged( |
| 90 | + (diff & ActivityInfo.CONFIG_LOCALE) != 0, |
| 91 | + (diff & ActivityInfo.CONFIG_FONT_SCALE) != 0, |
| 92 | + (diff & ActivityInfo.CONFIG_ORIENTATION) != 0, |
| 93 | + (diff & ActivityInfo.CONFIG_UI_MODE) != 0, |
| 94 | + DynamicSdkUtils.is17() && (diff & ActivityInfo.CONFIG_DENSITY) != 0); |
| 95 | + |
| 96 | + mConfiguration = new Configuration(newConfig); |
95 | 97 | }
|
96 | 98 |
|
97 | 99 | /**
|
|
0 commit comments