Skip to content

Commit

Permalink
WIP: [Android] NTPUtil.shouldEnableNTPFeature change.
Browse files Browse the repository at this point in the history
This may not be needed if we uplift #5969
  • Loading branch information
mkarolin committed Jul 3, 2020
1 parent c1e7ab9 commit 28f1e20
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,19 @@ protected void insertSiteSectionView() {
mainLayout.addView(mSiteSectionView, insertionPoint);
}

protected int getMaxRowsForMostVisitedTiles() {
protected boolean getIsMoreTabs() {
boolean isMoreTabs = false;
ChromeTabbedActivity chromeTabbedActivity = BraveRewardsHelper.getChromeTabbedActivity();
if (chromeTabbedActivity != null) {
TabModel tabModel = chromeTabbedActivity.getCurrentTabModel();
isMoreTabs = tabModel.getCount() >= SponsoredImageUtil.MAX_TABS ? true : false;
}
return isMoreTabs;
}

protected int getMaxRowsForMostVisitedTiles() {
if (BravePrefServiceBridge.getInstance().getBoolean(BravePref.NTP_SHOW_BACKGROUND_IMAGE)
&& NTPUtil.shouldEnableNTPFeature(isMoreTabs)) {
&& NTPUtil.shouldEnableNTPFeature(getIsMoreTabs())) {
return 1;
} else {
return 2;
Expand Down Expand Up @@ -211,7 +214,7 @@ protected void onDetachedFromWindow() {

@Override
public void onConfigurationChanged(Configuration newConfig) {
if (sponsoredTab != null && NTPUtil.shouldEnableNTPFeature()) {
if (sponsoredTab != null && NTPUtil.shouldEnableNTPFeature(getIsMoreTabs())) {
if (bgImageView != null) {
// We need to redraw image to fit parent properly
bgImageView.setImageResource(android.R.color.transparent);
Expand Down Expand Up @@ -273,7 +276,7 @@ private void updateBraveStats() {
if ((BravePrefServiceBridge.getInstance().getBoolean(BravePref.NTP_SHOW_BACKGROUND_IMAGE)
|| NTPUtil.isReferralEnabled())
&& sponsoredTab != null
&& NTPUtil.shouldEnableNTPFeature()) {
&& NTPUtil.shouldEnableNTPFeature(getIsMoreTabs())) {
mAdsBlockedTextView.setTextColor(
getResources().getColor(android.R.color.white));
mDataSavedTextView.setTextColor(
Expand Down Expand Up @@ -368,7 +371,7 @@ public void onClick(View view) {
} else if (BravePrefServiceBridge.getInstance().getBoolean(
BravePref.NTP_SHOW_BACKGROUND_IMAGE)
&& sponsoredTab != null
&& NTPUtil.shouldEnableNTPFeature()) {
&& NTPUtil.shouldEnableNTPFeature(getIsMoreTabs())) {
setBackgroundImage(ntpImage);
if (ntpImage instanceof BackgroundImage) {
BackgroundImage backgroundImage = (BackgroundImage) ntpImage;
Expand Down

0 comments on commit 28f1e20

Please sign in to comment.