Skip to content

Commit

Permalink
Add top sites error state
Browse files Browse the repository at this point in the history
Fix UI
  • Loading branch information
deeppandya committed Oct 15, 2020
1 parent b0c3661 commit ad2987f
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 13 deletions.
1 change: 1 addition & 0 deletions android/brave_java_resources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ brave_java_resources = [
"java/res/drawable-nodpi/ben_karpinski.jpg",
"java/res/drawable-nodpi/bnb.png",
"java/res/drawable-nodpi/btc.png",
"java/res/drawable-nodpi/busd.png",
"java/res/drawable-nodpi/dash.png",
"java/res/drawable-nodpi/dc_cavalleri.jpg",
"java/res/drawable-nodpi/doge.png",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ public void onClick(View v) {
View mTopSitesLayout = inflater.inflate(R.layout.top_sites_layout, null);
FrameLayout mTopSitesGridLayout =
mTopSitesLayout.findViewById(R.id.top_sites_grid_layout);
TextView topsiteErrorMessage = mTopSitesLayout.findViewById(R.id.widget_error_title);

if (shouldShowSuperReferral() && superReferralSitesLayout != null) {
if (superReferralSitesLayout.getParent() != null) {
Expand All @@ -228,6 +229,7 @@ public void onClick(View v) {
boolean showPlaceholder =
getTileGroup().hasReceivedData() && getTileGroup().isEmpty();
if (mSiteSectionView != null && !showPlaceholder) {
topsiteErrorMessage.setVisibility(View.GONE);
if (mSiteSectionView.getParent() != null) {
((ViewGroup) mSiteSectionView.getParent()).removeView(mSiteSectionView);
}
Expand All @@ -237,9 +239,11 @@ public void onClick(View v) {
mSiteSectionView.requestLayout();
}
mTopSitesGridLayout.addView(mSiteSectionView);
ntpWidgetItem.setWidgetView(mTopSitesLayout);
ntpWidgetMap.put(ntpWidgetManager.getFavoritesWidget(), ntpWidgetItem);
} else {
topsiteErrorMessage.setVisibility(View.VISIBLE);
}
ntpWidgetItem.setWidgetView(mTopSitesLayout);
ntpWidgetMap.put(ntpWidgetManager.getFavoritesWidget(), ntpWidgetItem);
}
} else if (widget.equals(NTPWidgetManager.PREF_BINANCE)) {
View binanceWidgetView = inflater.inflate(R.layout.crypto_widget_layout, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ public static void updateOrientedUI(Context context, ViewGroup view, Point size)
LinearLayout.LayoutParams imageCreditLayoutParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
imageCreditLayout.setLayoutParams(imageCreditLayoutParams);

layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;

layoutParams.setMargins(dpToPx(context, 32), 0, 0, 0);
layoutParams.gravity = Gravity.BOTTOM | Gravity.START;
sponsoredLogo.setLayoutParams(layoutParams);
} else {
if (ConfigurationUtils.isLandscape(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class BinanceWidgetManager {
put("BNB", new CoinNetworkModel("BNB", "Binance Coin", R.drawable.bnb));
put("BCH", new CoinNetworkModel("BCH", "Bitcoin Cash", R.drawable.bch));
put("XRP", new CoinNetworkModel("XRP", "Ripple", R.drawable.xrp));
put("BUSD", new CoinNetworkModel("BUSD", "US Dollar", 0));
put("BUSD", new CoinNetworkModel("BUSD", "US Dollar", R.drawable.busd));
put("BAT",
new CoinNetworkModel("BAT", "Basic Attention Token", R.drawable.bat));
put("XTZ", new CoinNetworkModel("XTZ", "", R.drawable.xtz));
Expand Down Expand Up @@ -94,7 +94,7 @@ public class BinanceWidgetManager {
put("NANO", new CoinNetworkModel("NANO", "", R.drawable.nano));
put("PAX", new CoinNetworkModel("PAX", "", R.drawable.pax));
put("TRX", new CoinNetworkModel("TRX", "", R.drawable.trx));
put("BUSD", new CoinNetworkModel("BUSD", "US Dollar", 0));
put("BUSD", new CoinNetworkModel("BUSD", "US Dollar", R.drawable.busd));
put("TUSD", new CoinNetworkModel("TUSD", "", R.drawable.tusd));
put("USDT", new CoinNetworkModel("USDT", "", R.drawable.usdt));
}
Expand Down
Binary file added android/java/res/drawable-nodpi/busd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions android/java/res/layout/brave_stats_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/widget_more_option"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_width="24dp"
android:layout_height="24dp"
android:contentDescription="@null"
app:srcCompat="@drawable/ic_more_horiz"/>

Expand Down
4 changes: 2 additions & 2 deletions android/java/res/layout/crypto_widget_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/widget_more_option"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_width="24dp"
android:layout_height="24dp"
android:contentDescription="@null"
app:srcCompat="@drawable/ic_more_horiz"/>

Expand Down
2 changes: 1 addition & 1 deletion android/java/res/layout/fragment_binance_convert.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="16dp"
android:text="@string/convert"
android:text="@string/price"
android:textColor="@android:color/white"/>

<TextView
Expand Down
17 changes: 15 additions & 2 deletions android/java/res/layout/top_sites_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,27 @@

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/widget_more_option"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_width="24dp"
android:layout_height="24dp"
android:contentDescription="@null"
android:tint="@android:color/black"
app:srcCompat="@drawable/ic_more_horiz"/>

</LinearLayout>

<TextView
android:id="@+id/widget_error_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_margin="16dp"
android:maxLines="2"
android:ellipsize="end"
android:visibility="gone"
android:text="@string/theres_nothing"
android:textColor="@android:color/black"
android:textSize="16sp"/>

<FrameLayout
android:id="@+id/top_sites_grid_layout"
android:layout_width="match_parent"
Expand Down
6 changes: 6 additions & 0 deletions browser/ui/android/strings/android_brave_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,12 @@ until they verify, or until 90 days have passed.
<message name="IDS_CONFIRM_CONVERSION" desc="Binance text">
Confirm Conversion
</message>
<message name="IDS_THERES_NOTHING" desc="Top sites error message">
There's nothing here yet on the top sites.
</message>
<message name="IDS_PRICE" desc="Binance convert item text">
Price
</message>
</messages>
</release>
</grit>

0 comments on commit ad2987f

Please sign in to comment.