improved window background

This commit is contained in:
Mariotaku Lee 2015-05-05 13:55:57 +08:00
parent 507f9c6188
commit 411ebf8e26
6 changed files with 39 additions and 12 deletions

View File

@ -249,8 +249,10 @@ public abstract class BasePreferenceActivity extends AppCompatPreferenceActivity
mCurrentThemeBackgroundOption = getThemeBackgroundOption(); mCurrentThemeBackgroundOption = getThemeBackgroundOption();
mCurrentThemeFontFamily = getThemeFontFamily(); mCurrentThemeFontFamily = getThemeFontFamily();
super.onApplyThemeResource(theme, resid, first); super.onApplyThemeResource(theme, resid, first);
ThemeUtils.applyWindowBackground(this, getWindow(), mCurrentThemeResource, if (shouldApplyWindowBackground()) {
mCurrentThemeBackgroundOption, mCurrentThemeBackgroundAlpha); ThemeUtils.applyWindowBackground(this, getWindow(), mCurrentThemeResource,
mCurrentThemeBackgroundOption, mCurrentThemeBackgroundAlpha);
}
} }
@Override @Override
@ -264,6 +266,10 @@ public abstract class BasePreferenceActivity extends AppCompatPreferenceActivity
setupActionBar(); setupActionBar();
} }
protected boolean shouldApplyWindowBackground() {
return true;
}
private void setupActionBar() { private void setupActionBar() {
final ActionBar actionBar = getSupportActionBar(); final ActionBar actionBar = getSupportActionBar();
if (actionBar == null) return; if (actionBar == null) return;

View File

@ -119,8 +119,14 @@ public abstract class BaseThemedActivity extends Activity implements IThemedActi
mCurrentThemeBackgroundOption = getThemeBackgroundOption(); mCurrentThemeBackgroundOption = getThemeBackgroundOption();
mProfileImageStyle = Utils.getProfileImageStyle(this); mProfileImageStyle = Utils.getProfileImageStyle(this);
super.onApplyThemeResource(theme, resId, first); super.onApplyThemeResource(theme, resId, first);
ThemeUtils.applyWindowBackground(this, getWindow(), mCurrentThemeResource, if (shouldApplyWindowBackground()) {
mCurrentThemeBackgroundOption, mCurrentThemeBackgroundAlpha); ThemeUtils.applyWindowBackground(this, getWindow(), mCurrentThemeResource,
mCurrentThemeBackgroundOption, mCurrentThemeBackgroundAlpha);
}
}
protected boolean shouldApplyWindowBackground() {
return true;
} }
} }

View File

@ -873,9 +873,8 @@ public class HomeActivity extends BaseAppCompatActivity implements OnClickListen
mRightDrawerContainer.setScrollScale(mSlidingMenu.getBehindScrollScale()); mRightDrawerContainer.setScrollScale(mSlidingMenu.getBehindScrollScale());
mSlidingMenu.setBehindCanvasTransformer(new ListenerCanvasTransformer(this)); mSlidingMenu.setBehindCanvasTransformer(new ListenerCanvasTransformer(this));
final Window window = getWindow(); final Window window = getWindow();
ThemeUtils.applyWindowBackground(this, mSlidingMenu.getContent(), ThemeUtils.applyWindowBackground(this, mSlidingMenu.getContent(), getCurrentThemeResourceId(),
getCurrentThemeResourceId(), getThemeBackgroundOption(), getThemeBackgroundOption(), getCurrentThemeBackgroundAlpha());
getCurrentThemeBackgroundAlpha());
window.setBackgroundDrawable(new EmptyDrawable()); window.setBackgroundDrawable(new EmptyDrawable());
} }

View File

@ -217,6 +217,11 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
return super.handleKeyboardShortcutSingle(handler, keyCode, event); return super.handleKeyboardShortcutSingle(handler, keyCode, event);
} }
@Override
protected boolean shouldApplyWindowBackground() {
return false;
}
private ParcelableStatus getStatus() { private ParcelableStatus getStatus() {
return getIntent().getParcelableExtra(EXTRA_STATUS); return getIntent().getParcelableExtra(EXTRA_STATUS);
} }
@ -821,6 +826,5 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
super.onPause(); super.onPause();
} }
} }
} }

View File

@ -132,8 +132,10 @@ public abstract class ThemedAppCompatActivity extends AppCompatActivity implemen
mCurrentThemeBackgroundOption = getThemeBackgroundOption(); mCurrentThemeBackgroundOption = getThemeBackgroundOption();
mCurrentThemeFontFamily = getThemeFontFamily(); mCurrentThemeFontFamily = getThemeFontFamily();
super.onApplyThemeResource(theme, resid, first); super.onApplyThemeResource(theme, resid, first);
ThemeUtils.applyWindowBackground(this, getWindow(), resid, if (shouldApplyWindowBackground()) {
mCurrentThemeBackgroundOption, mCurrentThemeBackgroundAlpha); ThemeUtils.applyWindowBackground(this, getWindow(), resid, mCurrentThemeBackgroundOption,
mCurrentThemeBackgroundAlpha);
}
} }
@Override @Override
@ -157,4 +159,8 @@ public abstract class ThemedAppCompatActivity extends AppCompatActivity implemen
return null; return null;
} }
protected boolean shouldApplyWindowBackground() {
return true;
}
} }

View File

@ -144,8 +144,10 @@ public abstract class ThemedFragmentActivity extends FragmentActivity implements
mCurrentThemeBackgroundOption = getThemeBackgroundOption(); mCurrentThemeBackgroundOption = getThemeBackgroundOption();
mProfileImageStyle = Utils.getProfileImageStyle(this); mProfileImageStyle = Utils.getProfileImageStyle(this);
super.onApplyThemeResource(theme, resId, first); super.onApplyThemeResource(theme, resId, first);
ThemeUtils.applyWindowBackground(this, getWindow(), mCurrentThemeResource, if (shouldApplyWindowBackground()) {
mCurrentThemeBackgroundOption, mCurrentThemeBackgroundAlpha); ThemeUtils.applyWindowBackground(this, getWindow(), mCurrentThemeResource,
mCurrentThemeBackgroundOption, mCurrentThemeBackgroundAlpha);
}
} }
@Override @Override
@ -175,4 +177,8 @@ public abstract class ThemedFragmentActivity extends FragmentActivity implements
public int getThemeResourceId() { public int getThemeResourceId() {
return 0; return 0;
} }
protected boolean shouldApplyWindowBackground() {
return true;
}
} }