Skip to content

Commit

Permalink
[AI Chat]: Update Android UI to open AI Chat in a tab (#26823)
Browse files Browse the repository at this point in the history
  • Loading branch information
fallaciousreasoning authored Dec 12, 2024
1 parent 73b6be9 commit 3b00894
Show file tree
Hide file tree
Showing 22 changed files with 161 additions and 311 deletions.
2 changes: 0 additions & 2 deletions android/brave_java_sources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ brave_java_sources = [
"../../brave/android/java/org/chromium/chrome/browser/bookmarks/BraveBookmarkToolbarCoordinator.java",
"../../brave/android/java/org/chromium/chrome/browser/bookmarks/BraveBookmarkUiPrefs.java",
"../../brave/android/java/org/chromium/chrome/browser/bookmarks/BraveBookmarkUtils.java",
"../../brave/android/java/org/chromium/chrome/browser/brave_leo/BraveLeoActivity.java",
"../../brave/android/java/org/chromium/chrome/browser/brave_leo/BraveLeoCustomTabRootUiCoordinator.java",
"../../brave/android/java/org/chromium/chrome/browser/brave_leo/BraveLeoMojomHelper.java",
"../../brave/android/java/org/chromium/chrome/browser/brave_leo/BraveLeoPlansActivity.java",
"../../brave/android/java/org/chromium/chrome/browser/brave_leo/BraveLeoPrefUtils.java",
Expand Down
8 changes: 1 addition & 7 deletions android/java/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,6 @@
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize"/>

<activity
android:name="org.chromium.chrome.browser.brave_leo.BraveLeoActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize|uiMode|navigation"
android:theme="@style/Theme.Chromium.Activity.FakeTranslucent"
android:exported="false"/>

<activity
android:name="org.chromium.chrome.browser.brave_leo.BraveLeoPlansActivity"
android:theme="@style/Theme.Chromium.Activity"
Expand Down Expand Up @@ -224,4 +218,4 @@
<!-- This activity is used for search provider widget -->
<activity android:name="org.chromium.chrome.browser.searchwidget.SearchWidgetProviderActivity"
android:theme="@style/Theme.Chromium.SearchActivity"
android:exported="true"/>
android:exported="true"/>
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
import org.chromium.chrome.browser.billing.InAppPurchaseWrapper;
import org.chromium.chrome.browser.billing.PurchaseModel;
import org.chromium.chrome.browser.bookmarks.TabBookmarker;
import org.chromium.chrome.browser.brave_leo.BraveLeoActivity;
import org.chromium.chrome.browser.brave_leo.BraveLeoUtils;
import org.chromium.chrome.browser.brave_news.BraveNewsConnectionErrorHandler;
import org.chromium.chrome.browser.brave_news.BraveNewsControllerFactory;
Expand Down Expand Up @@ -2101,7 +2100,7 @@ private void enableSpeedreaderMode() {

public void openBraveLeo() {
BraveLeoUtils.verifySubscription(null);
BraveLeoActivity.showPage(this, BRAVE_AI_CHAT_URL);
BraveLeoUtils.openLeoUrlForTab(getActivityTab().getWebContents());
}

public static ChromeTabbedActivity getChromeTabbedActivity() {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,11 @@ public static void openLeoQuery(
String conversationUuid,
String query,
boolean openLeoChatWindow) {
try {
BraveLeoUtilsJni.get().openLeoQuery(webContents, conversationUuid, query);
if (openLeoChatWindow) {
BraveActivity activity = BraveActivity.getBraveActivity();
activity.openBraveLeo();
}
} catch (BraveActivity.BraveActivityNotFoundException e) {
Log.e(TAG, "get BraveActivity exception", e);
}
BraveLeoUtilsJni.get().openLeoQuery(webContents, conversationUuid, query);
}

public static void openLeoUrlForTab(WebContents webContents) {
BraveLeoUtilsJni.get().openLeoUrlForTab(webContents);
}

public static String getDefaultModelName(ModelWithSubtitle[] models, String defaultModelKey) {
Expand Down Expand Up @@ -110,5 +106,7 @@ public static void bringMainActivityOnTop() {
@NativeMethods
public interface Natives {
void openLeoQuery(WebContents webContents, String conversationUuid, String query);

void openLeoUrlForTab(WebContents webContents);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.back_press.BackPressManager;
import org.chromium.chrome.browser.bookmarks.BookmarkModel;
import org.chromium.chrome.browser.brave_leo.BraveLeoActivity;
import org.chromium.chrome.browser.browser_controls.BottomControlsStacker;
import org.chromium.chrome.browser.browser_controls.BrowserControlsSizer;
import org.chromium.chrome.browser.browser_controls.BrowserStateBrowserControlsVisibilityDelegate;
Expand Down Expand Up @@ -450,12 +449,6 @@ protected void onOrientationChange(int newOrientation) {
setBottomToolbarVisible(isBottomToolbarVisible);
}

if (mActivity instanceof BraveLeoActivity) {
// When Leo panel is shown on rotated screen we don't care about
// the toolbar.
return;
}

if (mActivity instanceof BraveActivity) {
((BraveActivity) mActivity).updateBottomSheetPosition(newOrientation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
import org.chromium.chrome.browser.BraveRewardsNativeWorker;
import org.chromium.chrome.browser.BraveRewardsObserver;
import org.chromium.chrome.browser.app.BraveActivity;
import org.chromium.chrome.browser.brave_leo.BraveLeoActivity;
import org.chromium.chrome.browser.brave_stats.BraveStatsUtil;
import org.chromium.chrome.browser.crypto_wallet.controller.DAppsWalletController;
import org.chromium.chrome.browser.custom_layout.popup_window_tooltip.PopupWindowTooltip;
Expand Down Expand Up @@ -105,7 +104,6 @@
import org.chromium.chrome.browser.toolbar.ToolbarDataProvider;
import org.chromium.chrome.browser.toolbar.ToolbarProgressBar;
import org.chromium.chrome.browser.toolbar.ToolbarTabController;
import org.chromium.chrome.browser.toolbar.bottom.BottomToolbarConfiguration;
import org.chromium.chrome.browser.toolbar.bottom.BottomToolbarVariationManager;
import org.chromium.chrome.browser.toolbar.home_button.HomeButton;
import org.chromium.chrome.browser.toolbar.menu_button.BraveMenuButtonCoordinator;
Expand Down Expand Up @@ -217,13 +215,6 @@ private enum BigtechCompany { Google, Facebook, Amazon }

public BraveToolbarLayoutImpl(Context context, AttributeSet attrs) {
super(context, attrs);

if (context instanceof BraveLeoActivity) {
// Make sure initial state matches previously set flags.
mIsBottomToolbarVisible =
BottomToolbarConfiguration.isBottomToolbarEnabled()
&& BraveMenuButtonCoordinator.isMenuFromBottom();
}
}

@Override
Expand Down
2 changes: 0 additions & 2 deletions android/java/res/values/brave_dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
<dimen name="shields_tooltip_arrow_width">30dp</dimen>
<dimen name="shields_tooltip_arrow_height">15dp</dimen>

<dimen name="custom_tabs_control_container_leo_height">0dp</dimen>

<dimen name="vpn_plan_margin">32dp</dimen>

<dimen name="onboarding_network_selection_item_width">103dp</dimen>
Expand Down
2 changes: 1 addition & 1 deletion browser/about_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@
"brave-ai-chat-history", \
"Brave AI Chat History", \
"Enables AI Chat History persistence and management", \
kOsWin | kOsMac | kOsLinux, \
kOsWin | kOsMac | kOsLinux | kOsAndroid, \
FEATURE_VALUE_TYPE(ai_chat::features::kAIChatHistory), \
}, \
{ \
Expand Down
Loading

0 comments on commit 3b00894

Please sign in to comment.