Merge branch 'master' into temp_theme_refacfor
This commit is contained in:
commit
1b5708101d
|
@ -22,6 +22,7 @@ package android.support.v7.app;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.view.LayoutInflaterCompat;
|
import android.support.v4.view.LayoutInflaterCompat;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -42,7 +43,8 @@ public class ThemedAppCompatDelegateFactory implements Constants {
|
||||||
*
|
*
|
||||||
* @param callback An optional callback for AppCompat specific events
|
* @param callback An optional callback for AppCompat specific events
|
||||||
*/
|
*/
|
||||||
public static ThemedAppCompatDelegate create(IThemedActivity themed, AppCompatCallback callback) {
|
public static ThemedAppCompatDelegate create(@NonNull final IThemedActivity themed,
|
||||||
|
@NonNull final AppCompatCallback callback) {
|
||||||
final Activity activity = (Activity) themed;
|
final Activity activity = (Activity) themed;
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||||
return new ThemedAppCompatDelegate(themed, activity, activity.getWindow(), callback);
|
return new ThemedAppCompatDelegate(themed, activity, activity.getWindow(), callback);
|
||||||
|
@ -56,8 +58,8 @@ public class ThemedAppCompatDelegateFactory implements Constants {
|
||||||
private final IThemedActivity themed;
|
private final IThemedActivity themed;
|
||||||
private KeyListener keyListener;
|
private KeyListener keyListener;
|
||||||
|
|
||||||
private ThemedAppCompatDelegate(final IThemedActivity themed, final Context context,
|
private ThemedAppCompatDelegate(@NonNull final IThemedActivity themed, @NonNull final Context context,
|
||||||
Window window, AppCompatCallback callback) {
|
@NonNull final Window window, @NonNull final AppCompatCallback callback) {
|
||||||
super(context, window, callback);
|
super(context, window, callback);
|
||||||
this.themed = themed;
|
this.themed = themed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ public abstract class ThemedAppCompatActivity extends AppCompatActivity implemen
|
||||||
mProfileImageStyle = Utils.getProfileImageStyle(this);
|
mProfileImageStyle = Utils.getProfileImageStyle(this);
|
||||||
mCurrentThemeBackgroundOption = getThemeBackgroundOption();
|
mCurrentThemeBackgroundOption = getThemeBackgroundOption();
|
||||||
mCurrentThemeFontFamily = getThemeFontFamily();
|
mCurrentThemeFontFamily = getThemeFontFamily();
|
||||||
ThemeUtils.applyWindowBackground(this, getWindow(), getDelegate(), resid,
|
ThemeUtils.applyWindowBackground(this, getWindow(), resid,
|
||||||
mCurrentThemeBackgroundOption, mCurrentThemeBackgroundAlpha);
|
mCurrentThemeBackgroundOption, mCurrentThemeBackgroundAlpha);
|
||||||
super.onApplyThemeResource(theme, resid, first);
|
super.onApplyThemeResource(theme, resid, first);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,6 @@ import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v4.view.ViewCompat;
|
import android.support.v4.view.ViewCompat;
|
||||||
import android.support.v7.app.AppCompatDelegate;
|
|
||||||
import android.support.v7.app.AppCompatDelegateTrojan;
|
|
||||||
import android.support.v7.internal.app.ToolbarActionBar;
|
import android.support.v7.internal.app.ToolbarActionBar;
|
||||||
import android.support.v7.internal.app.WindowDecorActionBar;
|
import android.support.v7.internal.app.WindowDecorActionBar;
|
||||||
import android.support.v7.internal.app.WindowDecorActionBar.ActionModeImpl;
|
import android.support.v7.internal.app.WindowDecorActionBar.ActionModeImpl;
|
||||||
|
@ -268,20 +266,6 @@ public class ThemeUtils implements Constants {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void applyWindowBackground(Context context, Window window, AppCompatDelegate delegate, int theme, String option, int alpha) {
|
|
||||||
if (isWindowFloating(delegate)) return;
|
|
||||||
if (VALUE_THEME_BACKGROUND_TRANSPARENT.equals(option)) {
|
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER);
|
|
||||||
window.setBackgroundDrawable(ThemeUtils.getWindowBackgroundApplyAlpha(context, alpha));
|
|
||||||
} else if (VALUE_THEME_BACKGROUND_SOLID.equals(option)) {
|
|
||||||
window.setBackgroundDrawable(new ColorDrawable(isDarkTheme(theme) ? Color.BLACK : Color.WHITE));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isWindowFloating(AppCompatDelegate delegate) {
|
|
||||||
return AppCompatDelegateTrojan.isFloating(delegate);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void applyWindowBackground(Context context, View window, int theme, String option, int alpha) {
|
public static void applyWindowBackground(Context context, View window, int theme, String option, int alpha) {
|
||||||
if (isWindowFloating(context, theme)) return;
|
if (isWindowFloating(context, theme)) return;
|
||||||
if (VALUE_THEME_BACKGROUND_TRANSPARENT.equals(option)) {
|
if (VALUE_THEME_BACKGROUND_TRANSPARENT.equals(option)) {
|
||||||
|
|
Loading…
Reference in New Issue