Update background color for two-pane mode

Update background color for status bar and
homepage background programically.
Also, we update the backgroud color for highlight items.

Test: Rebuilt apk and see the screen.
Bug: 195293058
Change-Id: Id100f8c9c7fc02c43420afcca07a703a14ec2312
This commit is contained in:
Tsung-Mao Fang
2021-11-18 14:05:29 +08:00
parent 1df187a439
commit 395ea90b83
4 changed files with 213 additions and 305 deletions

View File

@@ -32,6 +32,8 @@ import android.util.ArraySet;
import android.util.FeatureFlagUtils;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.Toolbar;
@@ -53,6 +55,7 @@ import com.android.settings.core.CategoryMixin;
import com.android.settings.core.FeatureFlags;
import com.android.settings.homepage.contextualcards.ContextualCardsFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.Utils;
import com.android.settingslib.core.lifecycle.HideNonSystemOverlayMixin;
import java.net.URISyntaxException;
@@ -151,6 +154,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements
appBar.setMinimumHeight(getSearchBoxHeight());
initHomepageContainer();
updateHomepageAppBar();
updateHomepageBackground();
mLoadedListeners = new ArraySet<>();
initSearchBarView();
@@ -207,6 +211,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements
if (mIsTwoPaneLastTime != isTwoPane) {
mIsTwoPaneLastTime = isTwoPane;
updateHomepageAppBar();
updateHomepageBackground();
}
}
@@ -237,6 +242,23 @@ public class SettingsHomepageActivity extends FragmentActivity implements
}
}
private void updateHomepageBackground() {
if (!mIsEmbeddingActivityEnabled) {
return;
}
final Window window = getWindow();
final int color = ActivityEmbeddingUtils.isTwoPaneResolution(this)
? Utils.getColorAttrDefaultColor(this, com.android.internal.R.attr.colorSurface)
: Utils.getColorAttrDefaultColor(this, android.R.attr.colorBackground);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
// Update status bar color
window.setStatusBarColor(color);
// Update content background.
findViewById(R.id.settings_homepage_container).setBackgroundColor(color);
}
private void showSuggestionFragment() {
final Class<? extends Fragment> fragment = FeatureFactory.getFactory(this)
.getSuggestionFeatureProvider(this).getContextualSuggestionFragment();