Fix some bugs related to custom themes.

This commit is contained in:
Alex Ning 2020-03-27 14:40:48 +08:00
parent 6ad725762b
commit f40b9cbde0
4 changed files with 10 additions and 23 deletions

View File

@ -169,11 +169,11 @@ public class CustomThemeListingActivity extends BaseActivity implements CustomTh
} }
if (isDarkTheme) { if (isDarkTheme) {
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences( CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(
CustomThemeWrapper.getIndigo(CustomThemeListingActivity.this), darkThemeSharedPreferences); CustomThemeWrapper.getIndigoDark(CustomThemeListingActivity.this), darkThemeSharedPreferences);
} }
if (isAmoledTheme) { if (isAmoledTheme) {
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences( CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(
CustomThemeWrapper.getIndigo(CustomThemeListingActivity.this), amoledThemeSharedPreferences); CustomThemeWrapper.getIndigoAmoled(CustomThemeListingActivity.this), amoledThemeSharedPreferences);
} }
EventBus.getDefault().post(new RecreateActivityEvent()); EventBus.getDefault().post(new RecreateActivityEvent());
}).execute()) }).execute())

View File

@ -250,13 +250,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams(); params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
//Get status bar height
int statusBarHeight = 0;
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
statusBarHeight = getResources().getDimensionPixelSize(resourceId);
}
String title = "r/" + subredditName; String title = "r/" + subredditName;
subredditNameTextView.setText(title); subredditNameTextView.setText(title);
@ -346,6 +339,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
protected void applyCustomTheme() { protected void applyCustomTheme() {
int backgroundColor = mCustomThemeWrapper.getBackgroundColor(); int backgroundColor = mCustomThemeWrapper.getBackgroundColor();
coordinatorLayout.setBackgroundColor(backgroundColor); coordinatorLayout.setBackgroundColor(backgroundColor);
collapsingToolbarLayout.setContentScrimColor(mCustomThemeWrapper.getColorPrimary());
applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
linearLayout.setBackgroundColor(backgroundColor); linearLayout.setBackgroundColor(backgroundColor);
subredditNameTextView.setTextColor(mCustomThemeWrapper.getSubreddit()); subredditNameTextView.setTextColor(mCustomThemeWrapper.getSubreddit());

View File

@ -410,6 +410,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
@Override @Override
protected void applyCustomTheme() { protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
collapsingToolbarLayout.setContentScrimColor(mCustomThemeWrapper.getColorPrimary());
applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
expandedTabTextColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTextColor(); expandedTabTextColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTextColor();
expandedTabIndicatorColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabIndicator(); expandedTabIndicatorColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabIndicator();
@ -546,7 +547,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.view_user_detail_activity, menu); getMenuInflater().inflate(R.menu.view_user_detail_activity, menu);
applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); applyMenuItemTheme(menu);
mMenu = menu; mMenu = menu;
MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_user_detail_activity); MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_user_detail_activity);
if (isInLazyMode) { if (isInLazyMode) {

View File

@ -14,20 +14,12 @@
android:background="?attr/toolbarAndTabBackgroundColor" android:background="?attr/toolbarAndTabBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
app:titleEnabled="false"
app:toolbarId="@+id/toolbar_search_result_activity">
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar_search_result_activity" android:id="@+id/toolbar_search_result_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/AppTheme.PopupOverlay" /> app:popupTheme="@style/AppTheme.PopupOverlay"
app:navigationIcon="?attr/homeAsUpIndicator" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
<com.google.android.material.tabs.TabLayout <com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout_search_result_activity" android:id="@+id/tab_layout_search_result_activity"