diff --git a/android/java/org/chromium/chrome/browser/ntp/BraveNewTabPageLayout.java b/android/java/org/chromium/chrome/browser/ntp/BraveNewTabPageLayout.java
index 0e1ea040415b..2ec0289b2750 100644
--- a/android/java/org/chromium/chrome/browser/ntp/BraveNewTabPageLayout.java
+++ b/android/java/org/chromium/chrome/browser/ntp/BraveNewTabPageLayout.java
@@ -661,6 +661,20 @@ private void initPreferenceObserver() {
}
}
refreshFeed();
+ } else if (TextUtils.equals(key, BravePreferenceKeys.BRAVE_NEWS_PREF_TURN_ON_NEWS)) {
+ mIsNewsOn = BravePrefServiceBridge.getInstance().getNewsOptIn();
+ SharedPreferences sharedPreferences = ContextUtils.getAppSharedPreferences();
+ mIsShowOptin =
+ sharedPreferences.getBoolean(BraveNewsPreferences.PREF_SHOW_OPTIN, false);
+ mIsShowNewsOn = BravePrefServiceBridge.getInstance().getShowNews();
+ if ((!mIsNewsOn && mIsShowOptin) || (mIsNewsOn && !mIsShowOptin)) {
+ SharedPreferences.Editor sharedPreferencesEditor = sharedPreferences.edit();
+ sharedPreferencesEditor.putBoolean(BraveNewsPreferences.PREF_SHOW_OPTIN, true);
+ sharedPreferencesEditor.apply();
+ mOptinLayout.setVisibility(View.VISIBLE);
+ mRecyclerView.setVisibility(View.GONE);
+ initNews();
+ }
}
};
}
@@ -880,12 +894,7 @@ public void run() {
}
private void refreshFeed() {
- mAdapterFeedCard = new BraveNewsAdapterFeedCard(
- mActivity, Glide.with(mActivity), mNewsItemsFeedCard, mBraveNewsController);
- mRecyclerView.setAdapter(mAdapterFeedCard);
mIsShowNewsOn = BravePrefServiceBridge.getInstance().getShowNews();
- mImageCreditLayout.setVisibility(View.VISIBLE);
- mImageCreditLayout.setAlpha(1.0f);
if (!mIsShowNewsOn) {
correctPosition(false);
if (mRecyclerView != null) {
@@ -897,13 +906,21 @@ private void refreshFeed() {
mImageCreditLayout.setAlpha(1.0f);
return;
} else {
+ mAdapterFeedCard = new BraveNewsAdapterFeedCard(
+ mActivity, Glide.with(mActivity), mNewsItemsFeedCard, mBraveNewsController);
+ mRecyclerView.setAdapter(mAdapterFeedCard);
+
+ mImageCreditLayout.setVisibility(View.VISIBLE);
+ mImageCreditLayout.setAlpha(1.0f);
SharedPreferencesManager.getInstance().removeObserver(mPreferenceObserver);
initPreferenceObserver();
if (mPreferenceObserver != null) {
SharedPreferencesManager.getInstance().addObserver(mPreferenceObserver);
}
}
- getFeed();
+ if (mIsShowNewsOn && BravePrefServiceBridge.getInstance().getNewsOptIn()) {
+ getFeed();
+ }
}
@SuppressLint("ClickableViewAccessibility")
@@ -973,10 +990,13 @@ private void initNews() {
SharedPreferences sharedPreferences = ContextUtils.getAppSharedPreferences();
mIsNewsOn = BravePrefServiceBridge.getInstance().getNewsOptIn();
- mIsShowOptin = sharedPreferences.getBoolean(BraveNewsPreferences.PREF_SHOW_OPTIN, true);
+ mIsShowOptin = sharedPreferences.getBoolean(BraveNewsPreferences.PREF_SHOW_OPTIN, false);
mIsShowNewsOn = BravePrefServiceBridge.getInstance().getShowNews();
- if ((!mIsNewsOn && mIsShowOptin)) {
+ if ((!mIsNewsOn && mIsShowOptin) || (mIsNewsOn && mIsShowOptin)) {
+ SharedPreferences.Editor sharedPreferencesEditor = sharedPreferences.edit();
+ sharedPreferencesEditor.putBoolean(BraveNewsPreferences.PREF_SHOW_OPTIN, true);
+ sharedPreferencesEditor.apply();
mOptinLayout.setVisibility(View.VISIBLE);
} else if (mIsShowNewsOn && mIsNewsOn) {
if (mOptinLayout != null) {
@@ -1375,7 +1395,6 @@ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
}
});
}
-
if (mOptinLayout != null) {
mOptinClose.setOnClickListener(new View.OnClickListener() {
@Override
@@ -1393,10 +1412,7 @@ public void onClick(View v) {
mOptinLearnMore.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- Intent browserIntent =
- new Intent(Intent.ACTION_VIEW, Uri.parse(BRAVE_LEARN_MORE_URL));
- browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mActivity.startActivity(browserIntent);
+ TabUtils.openUrlInSameTab(BRAVE_LEARN_MORE_URL);
}
});
diff --git a/android/java/org/chromium/chrome/browser/preferences/BravePreferenceKeys.java b/android/java/org/chromium/chrome/browser/preferences/BravePreferenceKeys.java
index 2d6f1f7f3d7e..8be2ef3160b4 100644
--- a/android/java/org/chromium/chrome/browser/preferences/BravePreferenceKeys.java
+++ b/android/java/org/chromium/chrome/browser/preferences/BravePreferenceKeys.java
@@ -35,6 +35,7 @@ public final class BravePreferenceKeys {
public static final String BRAVE_NEWS_CHANGE_SOURCE = "brave_news_change_source";
public static final String BRAVE_NEWS_FEED_HASH = "brave_news_feed_hash";
public static final String BRAVE_NEWS_PREF_SHOW_NEWS = "kNewTabPageShowToday";
+ public static final String BRAVE_NEWS_PREF_TURN_ON_NEWS = "kBraveTodayOptedIn";
public static final String BRAVE_USE_BIOMETRICS_FOR_WALLET =
"org.chromium.chrome.browser.Brave_Use_Biometrics_For_Wallet";
public static final String BRAVE_BIOMETRICS_FOR_WALLET_IV =
diff --git a/android/java/org/chromium/chrome/browser/settings/BraveNewsPreferences.java b/android/java/org/chromium/chrome/browser/settings/BraveNewsPreferences.java
index 372534c65d88..d57bab0348d9 100644
--- a/android/java/org/chromium/chrome/browser/settings/BraveNewsPreferences.java
+++ b/android/java/org/chromium/chrome/browser/settings/BraveNewsPreferences.java
@@ -200,6 +200,7 @@ public void onCreate(Bundle savedInstanceState) {
if (!isNewsOn) {
mTurnOnNews.setChecked(false);
mShowNews.setVisible(false);
+ setSourcesVisibility(BravePrefServiceBridge.getInstance().getNewsOptIn());
} else {
mTurnOnNews.setChecked(true);
mTurnOnNews.setVisible(false);
@@ -218,10 +219,10 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
String key = preference.getKey();
if (PREF_TURN_ON_NEWS.equals(key)) {
BravePrefServiceBridge.getInstance().setNewsOptIn((boolean) newValue);
+ BravePrefServiceBridge.getInstance().setShowNews(false);
if ((boolean) newValue) {
mShowNews.setVisible(true);
- mShowNews.setChecked(true);
- BravePrefServiceBridge.getInstance().setShowNews(true);
+ mShowNews.setChecked(false);
} else {
mShowNews.setVisible(false);
}
diff --git a/browser/ui/android/strings/android_brave_strings.grd b/browser/ui/android/strings/android_brave_strings.grd
index c5808b895f27..af8643d44397 100644
--- a/browser/ui/android/strings/android_brave_strings.grd
+++ b/browser/ui/android/strings/android_brave_strings.grd
@@ -271,7 +271,7 @@ This file contains all "about" strings. It is set to NOT be translated, in tran
More Brave Offers
- Show Brave News
+ Enable Brave News
Your sources