Fix activity theme setting

This commit is contained in:
Moez Bhatti
2016-01-04 00:17:16 -05:00
parent 2d75fc8e11
commit 07078f5c88
3 changed files with 38 additions and 8 deletions
@@ -302,23 +302,15 @@ public class ThemeManager {
switch (theme) {
case WHITE:
mBackgroundColor = mResources.getColor(R.color.white_pure);
if (mContext != null) mContext.setTheme(mContext instanceof MainActivity ?
R.style.AppThemeWhite : R.style.AppThemeWhiteDialog);
break;
case OFFWHITE:
mBackgroundColor = mResources.getColor(R.color.grey_light_mega_ultra);
if (mContext != null) mContext.setTheme(mContext instanceof MainActivity ?
R.style.AppThemeLight : R.style.AppThemeLightDialog);
break;
case GREY:
mBackgroundColor = mResources.getColor(R.color.grey_material);
if (mContext != null) mContext.setTheme(mContext instanceof MainActivity ?
R.style.AppThemeDark : R.style.AppThemeDarkDialog);
break;
case BLACK:
mBackgroundColor = mResources.getColor(R.color.black);
if (mContext != null) mContext.setTheme(mContext instanceof MainActivity ?
R.style.AppThemeDarkAmoled : R.style.AppThemeDarkAmoledDialog);
break;
}
@@ -99,6 +99,7 @@ public abstract class QKActivity extends AppCompatActivity {
});
LiveViewManager.registerView(QKPreference.BACKGROUND, this, key -> {
setTheme(getThemeRes());
switch (ThemeManager.getTheme()) {
case WHITE:
case OFFWHITE:
@@ -260,6 +261,24 @@ public abstract class QKActivity extends AppCompatActivity {
}
}
protected int getThemeRes() {
switch (ThemeManager.getTheme()) {
case WHITE:
return R.style.AppThemeWhite;
case OFFWHITE:
return R.style.AppThemeLight;
case GREY:
return R.style.AppThemeDark;
case BLACK:
return R.style.AppThemeDarkAmoled;
}
return R.style.AppThemeLight;
}
public void makeToast(@StringRes int message) {
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
}
@@ -38,5 +38,24 @@ public abstract class QKPopupActivity extends QKActivity {
}
}
@Override
protected int getThemeRes() {
switch (ThemeManager.getTheme()) {
case WHITE:
return R.style.AppThemeWhiteDialog;
case OFFWHITE:
return R.style.AppThemeLightDialog;
case GREY:
return R.style.AppThemeDarkDialog;
case BLACK:
return R.style.AppThemeDarkAmoledDialog;
}
return R.style.AppThemeLightDialog;
}
protected abstract int getLayoutResource();
}