Skip to content

Commit

Permalink
[Android] Fixes for the new java format
Browse files Browse the repository at this point in the history
  • Loading branch information
samartnik authored and cdesouza-chromium committed Oct 13, 2023
1 parent f0d6e67 commit cb6d2aa
Show file tree
Hide file tree
Showing 13 changed files with 773 additions and 490 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,58 @@ public class BraveFeedSurfaceCoordinator extends FeedSurfaceCoordinator {
// Own members.
private @Nullable FrameLayout mFrameLayoutForPolicy;

public BraveFeedSurfaceCoordinator(Activity activity, SnackbarManager snackbarManager,
WindowAndroid windowAndroid, @Nullable JankTracker jankTracker,
@Nullable SnapScrollHelper snapScrollHelper, @Nullable View ntpHeader,
@Px int toolbarHeight, boolean showDarkBackground, FeedSurfaceDelegate delegate,
Profile profile, boolean isPlaceholderShownInitially,
public BraveFeedSurfaceCoordinator(
Activity activity,
SnackbarManager snackbarManager,
WindowAndroid windowAndroid,
@Nullable JankTracker jankTracker,
@Nullable SnapScrollHelper snapScrollHelper,
@Nullable View ntpHeader,
@Px int toolbarHeight,
boolean showDarkBackground,
FeedSurfaceDelegate delegate,
Profile profile,
boolean isPlaceholderShownInitially,
BottomSheetController bottomSheetController,
Supplier<ShareDelegate> shareDelegateSupplier,
@Nullable ScrollableContainerDelegate externalScrollableContainerDelegate,
@NewTabPageLaunchOrigin int launchOrigin,
PrivacyPreferencesManagerImpl privacyPreferencesManager,
@NonNull Supplier<Toolbar> toolbarSupplier, @SurfaceType int surfaceType,
long embeddingSurfaceCreatedTimeNs, @Nullable FeedSwipeRefreshLayout swipeRefreshLayout,
boolean overScrollDisabled, @Nullable ViewGroup viewportView,
FeedActionDelegate actionDelegate, HelpAndFeedbackLauncher helpAndFeedbackLauncher,
@NonNull Supplier<Toolbar> toolbarSupplier,
@SurfaceType int surfaceType,
long embeddingSurfaceCreatedTimeNs,
@Nullable FeedSwipeRefreshLayout swipeRefreshLayout,
boolean overScrollDisabled,
@Nullable ViewGroup viewportView,
FeedActionDelegate actionDelegate,
HelpAndFeedbackLauncher helpAndFeedbackLauncher,
TabModelSelector tabModelSelector) {
super(activity, snackbarManager, windowAndroid, jankTracker, snapScrollHelper, ntpHeader,
toolbarHeight, showDarkBackground, delegate, profile, isPlaceholderShownInitially,
bottomSheetController, shareDelegateSupplier, externalScrollableContainerDelegate,
launchOrigin, privacyPreferencesManager, toolbarSupplier, surfaceType,
embeddingSurfaceCreatedTimeNs, swipeRefreshLayout, overScrollDisabled, viewportView,
actionDelegate, helpAndFeedbackLauncher, tabModelSelector);
super(
activity,
snackbarManager,
windowAndroid,
jankTracker,
snapScrollHelper,
ntpHeader,
toolbarHeight,
showDarkBackground,
delegate,
profile,
isPlaceholderShownInitially,
bottomSheetController,
shareDelegateSupplier,
externalScrollableContainerDelegate,
launchOrigin,
privacyPreferencesManager,
toolbarSupplier,
surfaceType,
embeddingSurfaceCreatedTimeNs,
swipeRefreshLayout,
overScrollDisabled,
viewportView,
actionDelegate,
helpAndFeedbackLauncher,
tabModelSelector);
}

public void createFrameLayoutForPolicy() {
Expand Down
49 changes: 35 additions & 14 deletions android/java/org/chromium/base/BravePreferenceKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,42 @@ public final class BravePreferenceKeys {
* Returns the list of Brave's preference keys.
*/
private static List<String> getKeysInUse() {
return Arrays.asList(BRAVE_BOTTOM_TOOLBAR_ENABLED_KEY, BRAVE_BOTTOM_TOOLBAR_SET_KEY,
BRAVE_USE_CUSTOM_TABS, BRAVE_APP_OPEN_COUNT, BRAVE_ROLE_MANAGER_DIALOG_COUNT,
BRAVE_IS_DEFAULT, BRAVE_WAS_DEFAULT_ASK_COUNT, BRAVE_SET_DEFAULT_BOTTOM_SHEET_COUNT,
BRAVE_DEFAULT_DONT_ASK, BRAVE_UPDATE_EXTRA_PARAM, BRAVE_NOTIFICATION_PREF_NAME,
BRAVE_MILLISECONDS_NAME, BRAVE_DOWNLOADS_AUTOMATICALLY_OPEN_WHEN_POSSIBLE,
BRAVE_DOWNLOADS_DOWNLOAD_PROGRESS_NOTIFICATION_BUBBLE, BRAVE_DOUBLE_RESTART,
BRAVE_TAB_GROUPS_ENABLED, BRAVE_DISABLE_SHARING_HUB, BRAVE_NEWS_CARDS_VISITED,
BRAVE_NEWS_CHANGE_SOURCE, BRAVE_NEWS_FEED_HASH, BRAVE_NEWS_PREF_SHOW_NEWS,
BRAVE_NEWS_PREF_TURN_ON_NEWS, BRAVE_USE_BIOMETRICS_FOR_WALLET,
BRAVE_BIOMETRICS_FOR_WALLET_IV, BRAVE_BIOMETRICS_FOR_WALLET_ENCRYPTED,
BRAVE_AD_FREE_CALLOUT_DIALOG, BRAVE_OPENED_YOUTUBE,
SHOULD_SHOW_COOKIE_CONSENT_NOTICE, LOADED_SITE_COUNT,
return Arrays.asList(
BRAVE_BOTTOM_TOOLBAR_ENABLED_KEY,
BRAVE_BOTTOM_TOOLBAR_SET_KEY,
BRAVE_USE_CUSTOM_TABS,
BRAVE_APP_OPEN_COUNT,
BRAVE_ROLE_MANAGER_DIALOG_COUNT,
BRAVE_IS_DEFAULT,
BRAVE_WAS_DEFAULT_ASK_COUNT,
BRAVE_SET_DEFAULT_BOTTOM_SHEET_COUNT,
BRAVE_DEFAULT_DONT_ASK,
BRAVE_UPDATE_EXTRA_PARAM,
BRAVE_NOTIFICATION_PREF_NAME,
BRAVE_MILLISECONDS_NAME,
BRAVE_DOWNLOADS_AUTOMATICALLY_OPEN_WHEN_POSSIBLE,
BRAVE_DOWNLOADS_DOWNLOAD_PROGRESS_NOTIFICATION_BUBBLE,
BRAVE_DOUBLE_RESTART,
BRAVE_TAB_GROUPS_ENABLED,
BRAVE_DISABLE_SHARING_HUB,
BRAVE_NEWS_CARDS_VISITED,
BRAVE_NEWS_CHANGE_SOURCE,
BRAVE_NEWS_FEED_HASH,
BRAVE_NEWS_PREF_SHOW_NEWS,
BRAVE_NEWS_PREF_TURN_ON_NEWS,
BRAVE_USE_BIOMETRICS_FOR_WALLET,
BRAVE_BIOMETRICS_FOR_WALLET_IV,
BRAVE_BIOMETRICS_FOR_WALLET_ENCRYPTED,
BRAVE_AD_FREE_CALLOUT_DIALOG,
BRAVE_OPENED_YOUTUBE,
SHOULD_SHOW_COOKIE_CONSENT_NOTICE,
LOADED_SITE_COUNT,
BRAVE_BACKGROUND_VIDEO_PLAYBACK_CONVERTED_TO_FEATURE,
BRAVE_APP_OPEN_COUNT_FOR_WIDGET_PROMO, BRAVE_DEFERRED_DEEPLINK_PLAYLIST,
BRAVE_DEFERRED_DEEPLINK_VPN, BRAVE_CLOSE_TABS_ON_EXIT, BRAVE_CLEAR_ON_EXIT,
BRAVE_APP_OPEN_COUNT_FOR_WIDGET_PROMO,
BRAVE_DEFERRED_DEEPLINK_PLAYLIST,
BRAVE_DEFERRED_DEEPLINK_VPN,
BRAVE_CLOSE_TABS_ON_EXIT,
BRAVE_CLEAR_ON_EXIT,
BRAVE_QUICK_ACTION_SEARCH_AND_BOOKMARK_WIDGET_TILES);
}

Expand Down
23 changes: 15 additions & 8 deletions android/java/org/chromium/chrome/browser/app/BraveActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ public abstract class BraveActivity extends ChromeActivity
public static final String BRAVE_REWARDS_SETTINGS_MONTHLY_URL = "brave://rewards/#monthly";
public static final String REWARDS_AC_SETTINGS_URL = "brave://rewards/contribute";
public static final String BRAVE_AI_CHAT_URL = "chrome-untrusted://chat";
public static final String REWARDS_LEARN_MORE_URL = "https://brave.com/faq-rewards/#unclaimed-funds";
public static final String REWARDS_LEARN_MORE_URL =
"https://brave.com/faq-rewards/#unclaimed-funds";
public static final String BRAVE_TERMS_PAGE =
"https://basicattentiontoken.org/user-terms-of-service/";
public static final String BRAVE_PRIVACY_POLICY = "https://brave.com/privacy/browser/#rewards";
Expand Down Expand Up @@ -1512,13 +1513,13 @@ private void createNotificationChannel() {
}

private boolean isNoRestoreState() {
return SharedPreferencesManager.getInstance().readBoolean(
BravePreferenceKeys.BRAVE_CLOSE_TABS_ON_EXIT, false);
return SharedPreferencesManager.getInstance()
.readBoolean(BravePreferenceKeys.BRAVE_CLOSE_TABS_ON_EXIT, false);
}

private boolean isClearBrowsingDataOnExit() {
return SharedPreferencesManager.getInstance().readBoolean(
BravePreferenceKeys.BRAVE_CLEAR_ON_EXIT, false);
return SharedPreferencesManager.getInstance()
.readBoolean(BravePreferenceKeys.BRAVE_CLEAR_ON_EXIT, false);
}

public void onRewardsPanelDismiss() {
Expand Down Expand Up @@ -1720,7 +1721,8 @@ private void showBraveRateDialog() {
private void showCrossPromotionalDialog() {
CrossPromotionalModalDialogFragment mCrossPromotionalModalDialogFragment =
new CrossPromotionalModalDialogFragment();
mCrossPromotionalModalDialogFragment.show(getSupportFragmentManager(), "CrossPromotionalModalDialogFragment");
mCrossPromotionalModalDialogFragment.show(
getSupportFragmentManager(), "CrossPromotionalModalDialogFragment");
}

public void showDormantUsersEngagementDialog(String notificationType) {
Expand Down Expand Up @@ -2120,7 +2122,12 @@ public boolean maybeHandleUrlIntent(Intent intent) {
}
}
// Call ChromeTabbedActivity's version.
return (boolean) BraveReflectionUtil.InvokeMethod(
ChromeTabbedActivity.class, this, "maybeHandleUrlIntent", Intent.class, intent);
return (boolean)
BraveReflectionUtil.InvokeMethod(
ChromeTabbedActivity.class,
this,
"maybeHandleUrlIntent",
Intent.class,
intent);
}
}
91 changes: 66 additions & 25 deletions android/java/org/chromium/chrome/browser/ntp/BraveNewTabPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,48 @@ public class BraveNewTabPage extends NewTabPage {
private TabModelSelector mTabModelSelector;
private BottomSheetController mBottomSheetController;

public BraveNewTabPage(Activity activity,
public BraveNewTabPage(
Activity activity,
BrowserControlsStateProvider browserControlsStateProvider,
Supplier<Tab> activityTabProvider, SnackbarManager snackbarManager,
ActivityLifecycleDispatcher lifecycleDispatcher, TabModelSelector tabModelSelector,
boolean isTablet, NewTabPageUma uma, boolean isInNightMode,
NativePageHost nativePageHost, Tab tab, String url,
Supplier<Tab> activityTabProvider,
SnackbarManager snackbarManager,
ActivityLifecycleDispatcher lifecycleDispatcher,
TabModelSelector tabModelSelector,
boolean isTablet,
NewTabPageUma uma,
boolean isInNightMode,
NativePageHost nativePageHost,
Tab tab,
String url,
BottomSheetController bottomSheetController,
Supplier<ShareDelegate> shareDelegateSupplier, WindowAndroid windowAndroid,
JankTracker jankTracker, Supplier<Toolbar> toolbarSupplier,
SettingsLauncher settingsLauncher, HomeSurfaceTracker homeSurfaceTracker,
Supplier<ShareDelegate> shareDelegateSupplier,
WindowAndroid windowAndroid,
JankTracker jankTracker,
Supplier<Toolbar> toolbarSupplier,
SettingsLauncher settingsLauncher,
HomeSurfaceTracker homeSurfaceTracker,
ObservableSupplier<TabContentManager> tabContentManagerSupplier) {
super(activity, browserControlsStateProvider, activityTabProvider, snackbarManager,
lifecycleDispatcher, tabModelSelector, isTablet, uma, isInNightMode, nativePageHost,
tab, url, bottomSheetController, shareDelegateSupplier, windowAndroid, jankTracker,
toolbarSupplier, settingsLauncher, homeSurfaceTracker, tabContentManagerSupplier);
super(
activity,
browserControlsStateProvider,
activityTabProvider,
snackbarManager,
lifecycleDispatcher,
tabModelSelector,
isTablet,
uma,
isInNightMode,
nativePageHost,
tab,
url,
bottomSheetController,
shareDelegateSupplier,
windowAndroid,
jankTracker,
toolbarSupplier,
settingsLauncher,
homeSurfaceTracker,
tabContentManagerSupplier);

mJankTracker = jankTracker;

Expand Down Expand Up @@ -101,19 +128,33 @@ protected void initializeMainView(Activity activity, WindowAndroid windowAndroid
mNewTabPageLayout = (NewTabPageLayout) inflater.inflate(R.layout.new_tab_page_layout, null);

assert !FeedFeatures.isFeedEnabled();
FeedSurfaceCoordinator feedSurfaceCoordinator = new BraveFeedSurfaceCoordinator(activity,
snackbarManager, windowAndroid, mJankTracker,
new SnapScrollHelperImpl(mNewTabPageManager, mNewTabPageLayout), mNewTabPageLayout,
mBrowserControlsStateProvider.getTopControlsHeight(), isInNightMode, this, profile,
/* isPlaceholderShownInitially= */ false, mBottomSheetController,
shareDelegateSupplier, /* externalScrollableContainerDelegate= */ null,
NewTabPageUtils.decodeOriginFromNtpUrl(url),
PrivacyPreferencesManagerImpl.getInstance(), mToolbarSupplier,
SurfaceType.NEW_TAB_PAGE, mConstructedTimeNs,
FeedSwipeRefreshLayout.create(activity, R.id.toolbar_container),
/* overScrollDisabled= */ false, /* viewportView= */ null,
/* actionDelegate= */ null, HelpAndFeedbackLauncherImpl.getForProfile(profile),
mTabModelSelector);
FeedSurfaceCoordinator feedSurfaceCoordinator =
new BraveFeedSurfaceCoordinator(
activity,
snackbarManager,
windowAndroid,
mJankTracker,
new SnapScrollHelperImpl(mNewTabPageManager, mNewTabPageLayout),
mNewTabPageLayout,
mBrowserControlsStateProvider.getTopControlsHeight(),
isInNightMode,
this,
profile,
/* isPlaceholderShownInitially= */ false,
mBottomSheetController,
shareDelegateSupplier,
/* externalScrollableContainerDelegate= */ null,
NewTabPageUtils.decodeOriginFromNtpUrl(url),
PrivacyPreferencesManagerImpl.getInstance(),
mToolbarSupplier,
SurfaceType.NEW_TAB_PAGE,
mConstructedTimeNs,
FeedSwipeRefreshLayout.create(activity, R.id.toolbar_container),
/* overScrollDisabled= */ false,
/* viewportView= */ null,
/* actionDelegate= */ null,
HelpAndFeedbackLauncherImpl.getForProfile(profile),
mTabModelSelector);

mFeedSurfaceProvider = feedSurfaceCoordinator;
}
Expand Down
Loading

0 comments on commit cb6d2aa

Please sign in to comment.