Merge branch 'master' into temp_theme_refacfor

This commit is contained in:
Mariotaku Lee 2015-05-02 22:29:28 +08:00
commit 1b5708101d
3 changed files with 6 additions and 20 deletions

View File

@ -22,6 +22,7 @@ package android.support.v7.app;
import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v4.view.LayoutInflaterCompat;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@ -42,7 +43,8 @@ public class ThemedAppCompatDelegateFactory implements Constants {
*
* @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;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
return new ThemedAppCompatDelegate(themed, activity, activity.getWindow(), callback);
@ -56,8 +58,8 @@ public class ThemedAppCompatDelegateFactory implements Constants {
private final IThemedActivity themed;
private KeyListener keyListener;
private ThemedAppCompatDelegate(final IThemedActivity themed, final Context context,
Window window, AppCompatCallback callback) {
private ThemedAppCompatDelegate(@NonNull final IThemedActivity themed, @NonNull final Context context,
@NonNull final Window window, @NonNull final AppCompatCallback callback) {
super(context, window, callback);
this.themed = themed;
}

View File

@ -131,7 +131,7 @@ public abstract class ThemedAppCompatActivity extends AppCompatActivity implemen
mProfileImageStyle = Utils.getProfileImageStyle(this);
mCurrentThemeBackgroundOption = getThemeBackgroundOption();
mCurrentThemeFontFamily = getThemeFontFamily();
ThemeUtils.applyWindowBackground(this, getWindow(), getDelegate(), resid,
ThemeUtils.applyWindowBackground(this, getWindow(), resid,
mCurrentThemeBackgroundOption, mCurrentThemeBackgroundAlpha);
super.onApplyThemeResource(theme, resid, first);
}

View File

@ -34,8 +34,6 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
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.WindowDecorActionBar;
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) {
if (isWindowFloating(context, theme)) return;
if (VALUE_THEME_BACKGROUND_TRANSPARENT.equals(option)) {