75
75
import org .chromium .chrome .browser .preferences .BravePref ;
76
76
import org .chromium .chrome .browser .profiles .Profile ;
77
77
import org .chromium .chrome .browser .rewards .onboarding .RewardsOnboarding ;
78
+ import org .chromium .chrome .browser .rewards .tipping .PopupWindowTippingTabletUI ;
78
79
import org .chromium .chrome .browser .rewards .tipping .RewardsTippingBannerActivity ;
79
80
import org .chromium .chrome .browser .tab .Tab ;
80
81
import org .chromium .chrome .browser .util .BraveConstants ;
@@ -162,7 +163,7 @@ public enum NotificationClickAction {
162
163
TURN_ON_ADS ;
163
164
}
164
165
165
- private boolean shouldShowOnboardingForConnectAccount ;
166
+ private boolean mShouldShowOnboardingForConnectAccount ;
166
167
167
168
private final View mAnchorView ;
168
169
private final PopupWindow mPopupWindow ;
@@ -203,7 +204,7 @@ public enum NotificationClickAction {
203
204
private View mNotificationLayout ;
204
205
private View mNotificationPermissionLayout ;
205
206
private boolean mClaimInProcess ;
206
- private boolean notificationShown ;
207
+ private boolean mNotificationShown ;
207
208
208
209
private View mBraveRewardsOnboardingModalView ;
209
210
private View mRewardsResponseModal ;
@@ -219,6 +220,8 @@ public enum NotificationClickAction {
219
220
private View mBalanceDataViewGroups ;
220
221
private View mEstimatedToolTip ;
221
222
private View mVbatUserdrainToolTip ;
223
+ private PopupWindowTippingTabletUI mPopupWindowTippingTabletUI ;
224
+ private boolean mIsTablet ;
222
225
223
226
public BraveRewardsPanel (View anchorView ) {
224
227
mCurrentNotificationId = "" ;
@@ -336,9 +339,9 @@ private void setUpViews() {
336
339
mPopupView = (ViewGroup ) inflater .inflate (R .layout .brave_rewards_panel_layout , null );
337
340
338
341
int deviceWidth = ConfigurationUtils .getDisplayMetrics (mActivity ).get ("width" );
339
- boolean isTablet = DeviceFormFactor .isNonMultiDisplayContextOnTablet (mActivity );
342
+ mIsTablet = DeviceFormFactor .isNonMultiDisplayContextOnTablet (mActivity );
340
343
341
- mPopupWindow .setWidth ((int ) (isTablet ? (deviceWidth * 0.6 ) : (deviceWidth * 0.95 )));
344
+ mPopupWindow .setWidth ((int ) (mIsTablet ? (deviceWidth * 0.6 ) : (deviceWidth * 0.95 )));
342
345
343
346
mBravePanelShadow = mPopupView .findViewById (R .id .panel_shadow );
344
347
mBraveRewardsOnboardingView =
@@ -413,10 +416,17 @@ public void onClick(View v) {
413
416
414
417
TextView btnSendTip = mPopupView .findViewById (R .id .btn_send_tip );
415
418
btnSendTip .setOnClickListener (view -> {
416
- Intent intent = new Intent (
417
- ContextUtils .getApplicationContext (), RewardsTippingBannerActivity .class );
418
- intent .putExtra (RewardsTippingBannerActivity .TAB_ID_EXTRA , mCurrentTabId );
419
- mActivity .startActivityForResult (intent , BraveConstants .SITE_BANNER_REQUEST_CODE );
419
+ if (mIsTablet ) {
420
+ mPopupWindowTippingTabletUI =
421
+ PopupWindowTippingTabletUI .newInstance (mAnchorView , mCurrentTabId );
422
+ mPopupWindowTippingTabletUI .show (mBraveActivity .getSupportFragmentManager (),
423
+ "PopupWindowTippingTabletUITag" );
424
+ } else {
425
+ Intent intent = new Intent (
426
+ ContextUtils .getApplicationContext (), RewardsTippingBannerActivity .class );
427
+ intent .putExtra (RewardsTippingBannerActivity .TAB_ID_EXTRA , mCurrentTabId );
428
+ mActivity .startActivityForResult (intent , BraveConstants .SITE_BANNER_REQUEST_CODE );
429
+ }
420
430
});
421
431
422
432
mBtnTip = mPopupView .findViewById (R .id .tip_btn );
@@ -839,7 +849,7 @@ private void showNotification(String id, int type, long timestamp, String[] args
839
849
mRewardsMainLayout .setForeground (
840
850
new ColorDrawable (ContextCompat .getColor (mActivity , foregroundColor )));
841
851
enableControls (false , mRewardsMainLayout );
842
- notificationShown = true ;
852
+ mNotificationShown = true ;
843
853
}
844
854
845
855
setNotificationButtoClickListener (notificationClickAction );
@@ -1197,8 +1207,8 @@ public void onBalance(boolean success) {
1197
1207
1198
1208
@ Override
1199
1209
public void OnRewardsParameters () {
1200
- if (shouldShowOnboardingForConnectAccount ) {
1201
- shouldShowOnboardingForConnectAccount = false ;
1210
+ if (mShouldShowOnboardingForConnectAccount ) {
1211
+ mShouldShowOnboardingForConnectAccount = false ;
1202
1212
showBraveRewardsOnboarding (true );
1203
1213
} else if (mExternalWallet != null ) {
1204
1214
if (mBraveRewardsNativeWorker .getVbatDeadline () > 0 ) {
@@ -1240,8 +1250,7 @@ private void showOnBoarding() {
1240
1250
try {
1241
1251
BraveActivity activity = BraveActivity .getBraveActivity ();
1242
1252
int deviceWidth = ConfigurationUtils .getDisplayMetrics (activity ).get ("width" );
1243
- boolean isTablet = DeviceFormFactor .isNonMultiDisplayContextOnTablet (activity );
1244
- deviceWidth = (int ) (isTablet ? (deviceWidth * 0.6 ) : (deviceWidth * 0.95 ));
1253
+ deviceWidth = (int ) (mIsTablet ? (deviceWidth * 0.6 ) : (deviceWidth * 0.95 ));
1245
1254
RewardsOnboarding panel = new RewardsOnboarding (mAnchorView , deviceWidth );
1246
1255
panel .showLikePopDownMenu ();
1247
1256
} catch (BraveActivity .BraveActivityNotFoundException e ) {
@@ -1373,7 +1382,7 @@ private void clickOnCloseButtonOfNotificationPermission() {
1373
1382
View closeButton = mNotificationPermissionLayout .findViewById (R .id .close_text_button );
1374
1383
closeButton .setOnClickListener ((v ) -> {
1375
1384
mNotificationPermissionLayout .setVisibility (View .GONE );
1376
- if (!notificationShown ) {
1385
+ if (!mNotificationShown ) {
1377
1386
mNotificationLayout .setVisibility (View .GONE );
1378
1387
}
1379
1388
});
@@ -1385,7 +1394,7 @@ private void clickOnTurnOnNotificationButton() {
1385
1394
turnOnNotification .setOnClickListener ((v ) -> {
1386
1395
mNotificationPermissionLayout .setVisibility (View .GONE );
1387
1396
BravePermissionUtils .notificationSettingPage (mAnchorView .getContext ());
1388
- if (!notificationShown ) {
1397
+ if (!mNotificationShown ) {
1389
1398
mNotificationLayout .setVisibility (View .GONE );
1390
1399
}
1391
1400
});
@@ -2171,6 +2180,11 @@ public void run() {
2171
2180
2172
2181
public void dismiss () {
2173
2182
mPopupWindow .dismiss ();
2183
+ if (mPopupWindowTippingTabletUI != null && mPopupWindowTippingTabletUI .getDialog () != null
2184
+ && mPopupWindowTippingTabletUI .getDialog ().isShowing ()
2185
+ && !mPopupWindowTippingTabletUI .isRemoving ()) {
2186
+ mPopupWindowTippingTabletUI .getDialog ().dismiss ();
2187
+ }
2174
2188
}
2175
2189
2176
2190
public boolean isShowing () {
0 commit comments