@@ -1167,47 +1167,8 @@ public void OnPublisherInfo(int tabId) {
1167
1167
btAutoContribute .setOnCheckedChangeListener (autoContributeSwitchListener );
1168
1168
}
1169
1169
1170
- // set publisher verified/unverified status
1171
- String verified_text = "" ;
1172
- TextView tvVerified = (TextView )root .findViewById (R .id .publisher_verified );
1173
- @ PublisherStatus int pubStatus =
1174
- thisObject .mBraveRewardsNativeWorker .GetPublisherStatus (currentTabId );
1175
- if (pubStatus == BraveRewardsPublisher .CONNECTED ||
1176
- pubStatus == BraveRewardsPublisher .VERIFIED ) {
1177
- verified_text = root .getResources ().getString (R .string .brave_ui_verified_publisher );
1178
- } else {
1179
- verified_text = root .getResources ().getString (R .string .brave_ui_not_verified_publisher );
1180
- tvVerified .setCompoundDrawablesWithIntrinsicBounds (R .drawable .bat_unverified , 0 , 0 , 0 );
1181
- }
1182
- tvVerified .setText (verified_text );
1183
- tvVerified .setVisibility (View .VISIBLE );
1184
-
1185
- // show |brave_ui_panel_connected_text| text if
1186
- // publisher is CONNECTED and user doesn't have any Brave funds (anonymous or
1187
- // blinded wallets)
1188
- String verified_description = "" ;
1189
- if (pubStatus == BraveRewardsPublisher .CONNECTED ) {
1190
- BraveRewardsBalance balance_obj = mBraveRewardsNativeWorker .GetWalletBalance ();
1191
- if (balance_obj != null ) {
1192
- double braveFunds = ((balance_obj .mWallets .containsKey (BraveRewardsBalance .WALLET_ANONYMOUS ) && balance_obj .mWallets .get (BraveRewardsBalance .WALLET_ANONYMOUS ) != null ) ? balance_obj .mWallets .get (BraveRewardsBalance .WALLET_ANONYMOUS ) : .0 ) +
1193
- ((balance_obj .mWallets .containsKey (BraveRewardsBalance .WALLET_BLINDED ) && balance_obj .mWallets .get (BraveRewardsBalance .WALLET_BLINDED ) != null ) ? balance_obj .mWallets .get (BraveRewardsBalance .WALLET_BLINDED ) : .0 );
1194
- if (braveFunds <= 0 ) {
1195
- verified_description = root .getResources ().getString (R .string .brave_ui_panel_connected_text );
1196
- }
1197
- }
1198
- } else if (pubStatus == BraveRewardsPublisher .NOT_VERIFIED ) {
1199
- verified_description = root .getResources ().getString (
1200
- R .string .brave_ui_not_verified_publisher_description );
1201
- }
1202
-
1203
- if (!TextUtils .isEmpty (verified_description )) {
1204
- verified_description += "<br/><font color=#73CBFF>" +
1205
- root .getResources ().getString (R .string .learn_more ) + ".</font>" ;
1206
- Spanned toInsert = BraveRewardsHelper .spannedFromHtmlString (verified_description );
1207
- TextView tv_note = (TextView )root .findViewById (R .id .publisher_not_verified );
1208
- tv_note .setText (toInsert );
1209
- tv_note .setVisibility (View .VISIBLE );
1210
- }
1170
+ UpdatePublisherStatus (
1171
+ thisObject .mBraveRewardsNativeWorker .GetPublisherStatus (currentTabId ));
1211
1172
1212
1173
tv = (TextView )root .findViewById (R .id .br_no_activities_yet );
1213
1174
gl = (GridLayout )thisObject .root .findViewById (R .id .br_activities );
@@ -1678,4 +1639,94 @@ public void OnClaimPromotion(int error_code) {
1678
1639
ShowNotification (REWARDS_PROMOTION_CLAIM_ERROR_ID , REWARDS_PROMOTION_CLAIM_ERROR , 0 , args );
1679
1640
}
1680
1641
}
1642
+
1643
+ private void UpdatePublisherStatus (int pubStatus ) {
1644
+ // Set publisher verified/unverified status
1645
+ String verified_text = "" ;
1646
+ TextView publisherVerified = (TextView ) root .findViewById (R .id .publisher_verified );
1647
+ publisherVerified .setAlpha (1f );
1648
+ TextView publisherDelimiter = (TextView ) root .findViewById (R .id .publisher_delimiter );
1649
+ publisherDelimiter .setAlpha (1f );
1650
+ publisherDelimiter .setText (" | " );
1651
+ TextView refreshPublisher = (TextView ) root .findViewById (R .id .refresh_publisher );
1652
+ refreshPublisher .setAlpha (1f );
1653
+ refreshPublisher .setEnabled (true );
1654
+ View refreshStatusProgress = root .findViewById (R .id .progress_refresh_status );
1655
+ refreshStatusProgress .setVisibility (View .GONE );
1656
+ refreshPublisher .setOnClickListener ((new View .OnClickListener () {
1657
+ @ Override
1658
+ public void onClick (View v ) {
1659
+ String pubId = thisObject .mBraveRewardsNativeWorker .GetPublisherId (currentTabId );
1660
+ refreshStatusProgress .setVisibility (View .VISIBLE );
1661
+ refreshPublisher .setEnabled (false );
1662
+ publisherVerified .setAlpha (.3f );
1663
+ publisherDelimiter .setAlpha (.3f );
1664
+ refreshPublisher .setAlpha (.3f );
1665
+ mBraveRewardsNativeWorker .RefreshPublisher (pubId );
1666
+ }
1667
+ }));
1668
+ if (pubStatus == BraveRewardsPublisher .CONNECTED
1669
+ || pubStatus == BraveRewardsPublisher .VERIFIED ) {
1670
+ verified_text = root .getResources ().getString (R .string .brave_ui_verified_publisher );
1671
+ publisherVerified .setCompoundDrawablesWithIntrinsicBounds (
1672
+ R .drawable .bat_verified , 0 , 0 , 0 );
1673
+ publisherDelimiter .setVisibility (View .GONE );
1674
+ refreshPublisher .setVisibility (View .GONE );
1675
+ } else {
1676
+ verified_text = root .getResources ().getString (R .string .brave_ui_not_verified_publisher );
1677
+ publisherVerified .setCompoundDrawablesWithIntrinsicBounds (
1678
+ R .drawable .bat_unverified , 0 , 0 , 0 );
1679
+ publisherDelimiter .setVisibility (View .VISIBLE );
1680
+ refreshPublisher .setVisibility (View .VISIBLE );
1681
+ }
1682
+ publisherVerified .setText (verified_text );
1683
+ publisherVerified .setVisibility (View .VISIBLE );
1684
+
1685
+ // show |brave_ui_panel_connected_text| text if
1686
+ // publisher is CONNECTED and user doesn't have any Brave funds (anonymous or
1687
+ // blinded wallets)
1688
+ String verified_description = "" ;
1689
+ if (pubStatus == BraveRewardsPublisher .CONNECTED ) {
1690
+ BraveRewardsBalance balance_obj = mBraveRewardsNativeWorker .GetWalletBalance ();
1691
+ if (balance_obj != null ) {
1692
+ double braveFunds =
1693
+ ((balance_obj .mWallets .containsKey (BraveRewardsBalance .WALLET_ANONYMOUS )
1694
+ && balance_obj .mWallets .get (BraveRewardsBalance .WALLET_ANONYMOUS )
1695
+ != null )
1696
+ ? balance_obj .mWallets .get (
1697
+ BraveRewardsBalance .WALLET_ANONYMOUS )
1698
+ : .0 )
1699
+ + ((balance_obj .mWallets .containsKey (BraveRewardsBalance .WALLET_BLINDED )
1700
+ && balance_obj .mWallets .get (BraveRewardsBalance .WALLET_BLINDED )
1701
+ != null )
1702
+ ? balance_obj .mWallets .get (
1703
+ BraveRewardsBalance .WALLET_BLINDED )
1704
+ : .0 );
1705
+ if (braveFunds <= 0 ) {
1706
+ verified_description =
1707
+ root .getResources ().getString (R .string .brave_ui_panel_connected_text );
1708
+ }
1709
+ }
1710
+ } else if (pubStatus == BraveRewardsPublisher .NOT_VERIFIED ) {
1711
+ verified_description = root .getResources ().getString (
1712
+ R .string .brave_ui_not_verified_publisher_description );
1713
+ }
1714
+
1715
+ if (!TextUtils .isEmpty (verified_description )) {
1716
+ verified_description += "<br/><font color=#73CBFF>"
1717
+ + root .getResources ().getString (R .string .learn_more ) + ".</font>" ;
1718
+ Spanned toInsert = BraveRewardsHelper .spannedFromHtmlString (verified_description );
1719
+ TextView tv_note = (TextView ) root .findViewById (R .id .publisher_not_verified );
1720
+ tv_note .setText (toInsert );
1721
+ tv_note .setVisibility (View .VISIBLE );
1722
+ }
1723
+ }
1724
+
1725
+ @ Override
1726
+ public void OnRefreshPublisher (int status , String publisherKey ) {
1727
+ String pubName = thisObject .mBraveRewardsNativeWorker .GetPublisherName (currentTabId );
1728
+ if (pubName .equals (publisherKey )) {
1729
+ UpdatePublisherStatus (status );
1730
+ }
1731
+ };
1681
1732
}
0 commit comments