update brave news v2 search hint and suggested text

This commit is contained in:
tapanmodh
2023-01-24 14:49:52 +05:30
parent 6447277333
commit 1781237009
9 changed files with 43 additions and 43 deletions
@@ -45,7 +45,7 @@ public class BraveNewsUtils {
private static List<Publisher> mPublisherList;
private static List<Channel> mFollowingChannelList;
private static List<Publisher> mFollowingPublisherList;
private static List<String> mSuggestedList;
private static List<String> mSuggestionsList;
private static HashMap<String, Integer> mChannelIcons = new HashMap<>();
public static String getPromotionIdItem(FeedItemsCard items) {
@@ -192,20 +192,20 @@ public class BraveNewsUtils {
return mPublisherList;
}
private static void setSuggestedIds(List<String> suggestedList) {
mSuggestedList = suggestedList;
private static void setSuggestionsIds(List<String> suggestionsList) {
mSuggestionsList = suggestionsList;
}
public static List<Publisher> getSuggestedPublisherList() {
List<Publisher> suggestedPublisherList = new ArrayList<>();
if (mSuggestedList != null && mSuggestedList.size() > 0) {
public static List<Publisher> getSuggestionsPublisherList() {
List<Publisher> suggestionsPublisherList = new ArrayList<>();
if (mSuggestionsList != null && mSuggestionsList.size() > 0) {
for (Publisher publisher : mPublisherList) {
if (mSuggestedList.contains(publisher.publisherId)) {
suggestedPublisherList.add(publisher);
if (mSuggestionsList.contains(publisher.publisherId)) {
suggestionsPublisherList.add(publisher);
}
}
}
return suggestedPublisherList;
return suggestionsPublisherList;
}
public static void updatePublishers(String publisherId, int userEnabled) {
@@ -293,7 +293,7 @@ public class BraveNewsUtils {
setLocale(locale);
getChannels(braveNewsController, braveNewsPreferencesDataListener);
getPublishers(braveNewsController, braveNewsPreferencesDataListener);
getSuggestedSources(braveNewsController, braveNewsPreferencesDataListener);
getSuggestionsSources(braveNewsController, braveNewsPreferencesDataListener);
});
}
});
@@ -365,10 +365,10 @@ public class BraveNewsUtils {
setPopularSources(publisherList);
}
public static void getSuggestedSources(BraveNewsController braveNewsController,
public static void getSuggestionsSources(BraveNewsController braveNewsController,
BraveNewsPreferencesDataListener braveNewsPreferencesDataListener) {
braveNewsController.getSuggestedPublisherIds((publisherIds) -> {
setSuggestedIds(Arrays.asList(publisherIds));
setSuggestionsIds(Arrays.asList(publisherIds));
if (braveNewsPreferencesDataListener != null) {
braveNewsPreferencesDataListener.onSuggestionsReceived();
}
@@ -84,9 +84,9 @@ public class BraveNewsPreferencesDetails extends BravePreferenceFragment
publisherList = BraveNewsUtils.getPopularSources();
getActivity().setTitle(R.string.popular);
} else if (mBraveNewsPreferencesType.equalsIgnoreCase(
BraveNewsPreferencesType.Suggested.toString())) {
publisherList = BraveNewsUtils.getSuggestedPublisherList();
getActivity().setTitle(R.string.suggested);
BraveNewsPreferencesType.Suggestions.toString())) {
publisherList = BraveNewsUtils.getSuggestionsPublisherList();
getActivity().setTitle(R.string.suggestions);
} else if (mBraveNewsPreferencesType.equalsIgnoreCase(
BraveNewsPreferencesType.Channels.toString())) {
getActivity().setTitle(R.string.channels);
@@ -5,4 +5,4 @@
package org.chromium.chrome.browser.settings;
enum BraveNewsPreferencesType { Channels, PopularSources, Suggested, Following, Search }
enum BraveNewsPreferencesType { Channels, PopularSources, Suggestions, Following, Search }
@@ -93,7 +93,7 @@ public class BraveNewsPreferencesTypeAdapter extends RecyclerView.Adapter<Recycl
if ((mBraveNewsPreferencesType.equalsIgnoreCase(
BraveNewsPreferencesType.PopularSources.toString())
|| mBraveNewsPreferencesType.equalsIgnoreCase(
BraveNewsPreferencesType.Suggested.toString()))
BraveNewsPreferencesType.Suggestions.toString()))
&& position < mPublisherList.size()) {
setSource(position, viewHolder, mPublisherList.get(position));
@@ -389,7 +389,7 @@ public class BraveNewsPreferencesTypeAdapter extends RecyclerView.Adapter<Recycl
if (mBraveNewsPreferencesType.equalsIgnoreCase(
BraveNewsPreferencesType.PopularSources.toString())
|| mBraveNewsPreferencesType.equalsIgnoreCase(
BraveNewsPreferencesType.Suggested.toString())) {
BraveNewsPreferencesType.Suggestions.toString())) {
return mPublisherList.size();
} else if (mBraveNewsPreferencesType.equalsIgnoreCase(
@@ -62,7 +62,7 @@ public class BraveNewsPreferencesV2 extends BravePreferenceFragment
private View mLayoutSwitch;
private View mDivider;
private View mLayoutPopularSources;
private View mLayoutSuggested;
private View mLayoutSuggestions;
private View mLayoutChannels;
private View mLayoutFollowing;
@@ -102,7 +102,7 @@ public class BraveNewsPreferencesV2 extends BravePreferenceFragment
mTvSearch = (TextView) view.findViewById(R.id.tv_search);
mTvFollowingCount = (TextView) view.findViewById(R.id.tv_following_count);
mLayoutPopularSources = (View) view.findViewById(R.id.layout_popular_sources);
mLayoutSuggested = (View) view.findViewById(R.id.layout_suggested);
mLayoutSuggestions = (View) view.findViewById(R.id.layout_suggestions);
mLayoutChannels = (View) view.findViewById(R.id.layout_channels);
mLayoutFollowing = (View) view.findViewById(R.id.layout_following);
@@ -130,7 +130,7 @@ public class BraveNewsPreferencesV2 extends BravePreferenceFragment
}
if (BraveNewsUtils.getLocale() != null
&& BraveNewsUtils.getSuggestedPublisherList().size() > 0) {
&& BraveNewsUtils.getSuggestionsPublisherList().size() > 0) {
mIsSuggestionAvailable = true;
}
@@ -149,7 +149,7 @@ public class BraveNewsPreferencesV2 extends BravePreferenceFragment
if (!mIsSuggestionAvailable) {
PostTask.postTask(TaskTraits.THREAD_POOL_BEST_EFFORT, () -> {
if (mBraveNewsController != null) {
BraveNewsUtils.getSuggestedSources(mBraveNewsController, this);
BraveNewsUtils.getSuggestionsSources(mBraveNewsController, this);
}
});
}
@@ -172,8 +172,8 @@ public class BraveNewsPreferencesV2 extends BravePreferenceFragment
openBraveNewsPreferencesDetails(BraveNewsPreferencesType.PopularSources);
});
mLayoutSuggested.setOnClickListener(
view -> { openBraveNewsPreferencesDetails(BraveNewsPreferencesType.Suggested); });
mLayoutSuggestions.setOnClickListener(
view -> { openBraveNewsPreferencesDetails(BraveNewsPreferencesType.Suggestions); });
mLayoutChannels.setOnClickListener(
view -> { openBraveNewsPreferencesDetails(BraveNewsPreferencesType.Channels); });
@@ -221,7 +221,7 @@ public class BraveNewsPreferencesV2 extends BravePreferenceFragment
sharedPreferencesEditor.apply();
if (mIsSuggestionAvailable) {
mLayoutSuggested.setVisibility(View.VISIBLE);
mLayoutSuggestions.setVisibility(View.VISIBLE);
}
} else {
@@ -232,7 +232,7 @@ public class BraveNewsPreferencesV2 extends BravePreferenceFragment
mDivider.setVisibility(View.GONE);
mTvSearch.setVisibility(View.GONE);
mLayoutPopularSources.setVisibility(View.GONE);
mLayoutSuggested.setVisibility(View.GONE);
mLayoutSuggestions.setVisibility(View.GONE);
mLayoutChannels.setVisibility(View.GONE);
mLayoutFollowing.setVisibility(View.GONE);
}
@@ -302,9 +302,9 @@ public class BraveNewsPreferencesV2 extends BravePreferenceFragment
@Override
public void onSuggestionsReceived() {
if (mSwitchShowNews != null && mSwitchShowNews.isChecked()
&& BraveNewsUtils.getSuggestedPublisherList().size() > 0) {
if (mLayoutSuggested != null) {
mLayoutSuggested.setVisibility(View.VISIBLE);
&& BraveNewsUtils.getSuggestionsPublisherList().size() > 0) {
if (mLayoutSuggestions != null) {
mLayoutSuggestions.setVisibility(View.VISIBLE);
}
}
}
@@ -187,7 +187,7 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_suggested"
android:id="@+id/layout_suggestions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
@@ -195,39 +195,39 @@
android:visibility="gone">
<ImageView
android:id="@+id/iv_suggested"
android:id="@+id/iv_suggestions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:padding="8dp"
app:srcCompat="@drawable/ic_suggested"
app:srcCompat="@drawable/ic_suggestions"
android:background="@drawable/ic_circle_news_settings"
android:contentDescription="@null"/>
<TextView
android:id="@+id/tv_suggested"
android:id="@+id/tv_suggestions"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/suggested"
android:text="@string/suggestions"
android:textSize="16sp"
android:textColor="@color/news_settings_title_color"
android:layout_marginStart="12dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/iv_suggested"
app:layout_constraintStart_toEndOf="@id/iv_suggestions"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/suggested_subtitle"
android:text="@string/suggestions_subtitle"
android:textSize="14sp"
android:textColor="@color/news_settings_subtitle_color"
android:layout_marginStart="12dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/iv_suggested"
app:layout_constraintTop_toBottomOf="@id/tv_suggested"/>
app:layout_constraintStart_toEndOf="@id/iv_suggestions"
app:layout_constraintTop_toBottomOf="@id/tv_suggestions"/>
</androidx.constraintlayout.widget.ConstraintLayout>