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

View File

@ -119,8 +119,14 @@ public abstract class BaseThemedActivity extends Activity implements IThemedActi
mCurrentThemeBackgroundOption = getThemeBackgroundOption();
mProfileImageStyle = Utils.getProfileImageStyle(this);
super.onApplyThemeResource(theme, resId, first);
ThemeUtils.applyWindowBackground(this, getWindow(), mCurrentThemeResource,
mCurrentThemeBackgroundOption, mCurrentThemeBackgroundAlpha);
if (shouldApplyWindowBackground()) {
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());
mSlidingMenu.setBehindCanvasTransformer(new ListenerCanvasTransformer(this));
final Window window = getWindow();
ThemeUtils.applyWindowBackground(this, mSlidingMenu.getContent(),
getCurrentThemeResourceId(), getThemeBackgroundOption(),
getCurrentThemeBackgroundAlpha());
ThemeUtils.applyWindowBackground(this, mSlidingMenu.getContent(), getCurrentThemeResourceId(),
getThemeBackgroundOption(), getCurrentThemeBackgroundAlpha());
window.setBackgroundDrawable(new EmptyDrawable());
}

View File

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

View File

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

View File

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