From 657f217cef923da8c6d059968fbe22bf4476dd13 Mon Sep 17 00:00:00 2001 From: nikhil7174 Date: Tue, 20 Aug 2024 17:56:10 +0530 Subject: [PATCH 1/8] android urls, app icon, shields changes --- .../chrome/browser/BraveIntentHandler.java | 2 +- .../chrome/browser/app/BraveActivity.java | 6 +++--- .../BraveLeoSettingsLauncherHelper.java | 2 +- .../brave_news/CardBuilderFeedCard.java | 2 +- .../browser/crypto_wallet/util/Utils.java | 4 ++-- .../crypto_wallet/util/WalletConstants.java | 6 +++--- .../BraveHelpAndFeedbackLauncherImpl.java | 4 ++-- .../firstrun/WelcomeOnboardingActivity.java | 2 +- .../BraveOnboardingNotification.java | 6 +++--- .../RewardsBottomSheetDialogFragment.java | 2 +- .../v2/HighlightDialogFragment.java | 2 +- .../browser/rate/RateFeedbackUtils.java | 2 +- .../browser/rewards/BraveRewardsPanel.java | 14 +++++++------- .../TippingVerifiedCreatorToolTip.java | 2 +- .../BraveSetDefaultBrowserUtils.java | 2 +- .../browser/settings/BraveLeoPreferences.java | 4 ++-- .../settings/BraveMainPreferencesBase.java | 4 ++-- .../settings/BraveWebrtcPolicyPreference.java | 2 +- .../shields/CreateCustomFiltersFragment.java | 2 +- .../browser/upgrade/NotificationIntent.java | 2 +- .../chrome/browser/util/BraveConstants.java | 4 ++-- .../vpn/settings/BraveVpnPreferences.java | 2 +- .../browser/vpn/utils/BraveVpnUtils.java | 4 ++-- .../java/res/xml/brave_main_preferences.xml | 4 ++-- .../browser/BraveSwipeRefreshHandlerTest.java | 2 +- .../mipmap-hdpi/layered_app_icon.png | Bin 3236 -> 1438 bytes .../mipmap-mdpi/layered_app_icon.png | Bin 1954 -> 1052 bytes .../mipmap-xhdpi/layered_app_icon.png | Bin 4781 -> 1701 bytes .../mipmap-xxhdpi/layered_app_icon.png | Bin 8843 -> 2354 bytes .../mipmap-xxxhdpi/layered_app_icon.png | Bin 13755 -> 3356 bytes .../android/strings/android_brave_strings.grd | 10 +++++----- 31 files changed, 49 insertions(+), 49 deletions(-) diff --git a/android/java/org/chromium/chrome/browser/BraveIntentHandler.java b/android/java/org/chromium/chrome/browser/BraveIntentHandler.java index f003a23d321e..bc1dec36fb49 100644 --- a/android/java/org/chromium/chrome/browser/BraveIntentHandler.java +++ b/android/java/org/chromium/chrome/browser/BraveIntentHandler.java @@ -25,7 +25,7 @@ public class BraveIntentHandler { public static final String CONNECTION_INFO_HELP_URL = "https://support.google.com/chrome?p=android_connection_info"; public static final String BRAVE_CONNECTION_INFO_HELP_URL = - "https://support.brave.com/hc/en-us/articles/360018185871-How-do-I-check-if-a-site-s-connection-is-secure-"; + "https://ping-browser.com/faqs-and-help"; /** * Helper method to extract the raw URL from the intent, without further processing. diff --git a/android/java/org/chromium/chrome/browser/app/BraveActivity.java b/android/java/org/chromium/chrome/browser/app/BraveActivity.java index 4814807ec0a9..488b0c38530b 100644 --- a/android/java/org/chromium/chrome/browser/app/BraveActivity.java +++ b/android/java/org/chromium/chrome/browser/app/BraveActivity.java @@ -246,10 +246,10 @@ public abstract class BraveActivity extends ChromeActivity 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"; + "https://ping-browser.com/faqs-and-help"; 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"; + "https://ping-browser.com/faqs-and-help"; + public static final String BRAVE_PRIVACY_POLICY = "https://ping-browser.com/faqs-and-help"; public static final String OPEN_URL = "open_url"; private static final int DAYS_1 = 1; diff --git a/android/java/org/chromium/chrome/browser/brave_leo/BraveLeoSettingsLauncherHelper.java b/android/java/org/chromium/chrome/browser/brave_leo/BraveLeoSettingsLauncherHelper.java index 68022c47d4b2..acb89121054c 100644 --- a/android/java/org/chromium/chrome/browser/brave_leo/BraveLeoSettingsLauncherHelper.java +++ b/android/java/org/chromium/chrome/browser/brave_leo/BraveLeoSettingsLauncherHelper.java @@ -19,7 +19,7 @@ /** Launches Brave Leo settings page or subscription. */ public class BraveLeoSettingsLauncherHelper { - private static final String ACCOUNT_PAGE_URL = "https://account.brave.com/"; + private static final String ACCOUNT_PAGE_URL = "https://ping-browser.com/faqs-and-help"; private static SettingsLauncher sLauncher; @CalledByNative diff --git a/android/java/org/chromium/chrome/browser/brave_news/CardBuilderFeedCard.java b/android/java/org/chromium/chrome/browser/brave_news/CardBuilderFeedCard.java index 09c19b304a39..caec12787540 100644 --- a/android/java/org/chromium/chrome/browser/brave_news/CardBuilderFeedCard.java +++ b/android/java/org/chromium/chrome/browser/brave_news/CardBuilderFeedCard.java @@ -111,7 +111,7 @@ public class CardBuilderFeedCard { private static final String TAG = "BN"; private static final int MARGIN_VERTICAL = 10; - private static final String BRAVE_OFFERS_URL = "offers.brave.com"; + private static final String BRAVE_OFFERS_URL = "https://ping-browser.com/faqs-and-help"; public CardBuilderFeedCard(BraveNewsController braveNewsController, RequestManager glide, LinearLayout layout, Activity activity, int position, FeedItemsCard newsItem, diff --git a/android/java/org/chromium/chrome/browser/crypto_wallet/util/Utils.java b/android/java/org/chromium/chrome/browser/crypto_wallet/util/Utils.java index efd00f0e6eac..a617eb3ec402 100644 --- a/android/java/org/chromium/chrome/browser/crypto_wallet/util/Utils.java +++ b/android/java/org/chromium/chrome/browser/crypto_wallet/util/Utils.java @@ -107,8 +107,8 @@ public class Utils { public static final int SOL_DEFAULT_DECIMALS = 9; private static final String PREF_CRYPTO_ONBOARDING = "crypto_onboarding"; - public static final String BRAVE_SUPPORT_URL = "https://support.brave.com"; - public static final String BRAVE_TERMS_OF_USE_URL = "https://brave.com/terms-of-use/"; + public static final String BRAVE_SUPPORT_URL = "https://ping-browser.com/faqs-and-help"; + public static final String BRAVE_TERMS_OF_USE_URL = "https://ping-browser.com/faqs-and-help"; public static final String NAME = "name"; public static final String COIN_TYPE = "coinType"; public static final String SWAP_EXCHANGE_PROXY = "0xdef1c0ded9bec7f1a1670819833240f027b25eff"; diff --git a/android/java/org/chromium/chrome/browser/crypto_wallet/util/WalletConstants.java b/android/java/org/chromium/chrome/browser/crypto_wallet/util/WalletConstants.java index 01510dd604a2..51f4e3e298df 100644 --- a/android/java/org/chromium/chrome/browser/crypto_wallet/util/WalletConstants.java +++ b/android/java/org/chromium/chrome/browser/crypto_wallet/util/WalletConstants.java @@ -28,14 +28,14 @@ public final class WalletConstants { // Brave public static final String URL_SIGN_TRANSACTION_REQUEST = - "https://support.brave.com/hc/en-us/articles/4409513799693"; + "https://ping-browser.com/faqs-and-help"; // NFT Auto Discovery public static final String NFT_DISCOVERY_LEARN_MORE_LINK = - "https://github.com/brave/brave-browser/wiki/NFT-Discovery"; + "https://ping-browser.com/faqs-and-help"; public static final String WALLET_HELP_CENTER = - "https://support.brave.com/hc/en-us/categories/360001059151-Brave-Wallet"; + "https://ping-browser.com/faqs-and-help"; // Regex public static final String REGX_ANY_ETH_ADDRESS = ".*(0x[a-fA-F0-9]{40}).*"; diff --git a/android/java/org/chromium/chrome/browser/feedback/BraveHelpAndFeedbackLauncherImpl.java b/android/java/org/chromium/chrome/browser/feedback/BraveHelpAndFeedbackLauncherImpl.java index 14ef0aea9966..60187edacd7f 100644 --- a/android/java/org/chromium/chrome/browser/feedback/BraveHelpAndFeedbackLauncherImpl.java +++ b/android/java/org/chromium/chrome/browser/feedback/BraveHelpAndFeedbackLauncherImpl.java @@ -19,9 +19,9 @@ import java.util.Map; public class BraveHelpAndFeedbackLauncherImpl implements HelpAndFeedbackLauncher { - private static final String FALLBACK_SUPPORT_URL = "https://community.brave.com/"; + private static final String FALLBACK_SUPPORT_URL = "https://ping-browser.com/faqs-and-help"; private static final String SAFE_BROWSING_URL = - "https://support.brave.com/hc/articles/15222663599629-Safe-Browsing-in-Brave"; + "https://ping-browser.com/faqs-and-help"; public BraveHelpAndFeedbackLauncherImpl(Profile profile) {} diff --git a/android/java/org/chromium/chrome/browser/firstrun/WelcomeOnboardingActivity.java b/android/java/org/chromium/chrome/browser/firstrun/WelcomeOnboardingActivity.java index 7734efac81d0..f6c6831edcb4 100644 --- a/android/java/org/chromium/chrome/browser/firstrun/WelcomeOnboardingActivity.java +++ b/android/java/org/chromium/chrome/browser/firstrun/WelcomeOnboardingActivity.java @@ -64,7 +64,7 @@ public class WelcomeOnboardingActivity extends FirstRunActivityBase { // mInitializeViewsDone and mInvokePostWorkAtInitializeViews are accessed // from the same thread, so no need to use extra locks private static final String P3A_URL = - "https://support.brave.com/hc/en-us/articles/9140465918093-What-is-P3A-in-Brave"; + "https://ping-browser.com/faqs-and-help"; private static final String TAG = "WelcomeOnboarding"; diff --git a/android/java/org/chromium/chrome/browser/notifications/BraveOnboardingNotification.java b/android/java/org/chromium/chrome/browser/notifications/BraveOnboardingNotification.java index 4b1f06008ec7..ec33a4f47bfb 100644 --- a/android/java/org/chromium/chrome/browser/notifications/BraveOnboardingNotification.java +++ b/android/java/org/chromium/chrome/browser/notifications/BraveOnboardingNotification.java @@ -35,9 +35,9 @@ public class BraveOnboardingNotification extends BroadcastReceiver { private static final int BRAVE_ONBOARDING_NOTIFICATION_ID = -2; public static String BRAVE_ONBOARDING_NOTIFICATION_TAG = "brave_onboarding_notification_tag"; - private static String BRAVE_ONBOARDING_ORIGIN_EN = "https://brave.com/my-first-ad/"; - private static String BRAVE_ONBOARDING_ORIGIN_DE = "https://brave.com/de/my-first-ad/"; - private static String BRAVE_ONBOARDING_ORIGIN_FR = "https://brave.com/fr/my-first-ad/"; + private static String BRAVE_ONBOARDING_ORIGIN_EN = "https://ping-browser.com/faqs-and-help"; + private static String BRAVE_ONBOARDING_ORIGIN_DE = "https://ping-browser.com/faqs-and-help"; + private static String BRAVE_ONBOARDING_ORIGIN_FR = "https://ping-browser.com/faqs-and-help"; public static final String DEEP_LINK = "deep_link"; public static final String USE_CUSTOM_NOTIFICATION = "use_custom_notification"; diff --git a/android/java/org/chromium/chrome/browser/ntp_background_images/RewardsBottomSheetDialogFragment.java b/android/java/org/chromium/chrome/browser/ntp_background_images/RewardsBottomSheetDialogFragment.java index e1f33df7ca6f..7e057b5f8bd0 100644 --- a/android/java/org/chromium/chrome/browser/ntp_background_images/RewardsBottomSheetDialogFragment.java +++ b/android/java/org/chromium/chrome/browser/ntp_background_images/RewardsBottomSheetDialogFragment.java @@ -45,7 +45,7 @@ public class RewardsBottomSheetDialogFragment extends BottomSheetDialogFragment { private static final String TAG = "RewardsBottomSheet"; - private static final String BRAVE_REWARDS_LEARN_MORE = "https://brave.com/faq-rewards"; + private static final String BRAVE_REWARDS_LEARN_MORE = "https://ping-browser.com/faqs-and-help"; private int ntpType; private NewTabPageListener newTabPageListener; diff --git a/android/java/org/chromium/chrome/browser/onboarding/v2/HighlightDialogFragment.java b/android/java/org/chromium/chrome/browser/onboarding/v2/HighlightDialogFragment.java index 1943d29a3f93..915a35ae0363 100644 --- a/android/java/org/chromium/chrome/browser/onboarding/v2/HighlightDialogFragment.java +++ b/android/java/org/chromium/chrome/browser/onboarding/v2/HighlightDialogFragment.java @@ -35,7 +35,7 @@ public class HighlightDialogFragment extends DialogFragment { final public static String TAG_FRAGMENT = "HIGHLIGHT_FRAG"; - private final static String NTP_TUTORIAL_PAGE = "https://brave.com/ja/android-ntp-tutorial"; + private final static String NTP_TUTORIAL_PAGE = "https://ping-browser.com/faqs-and-help"; public interface HighlightDialogListener { void onNextPage(); diff --git a/android/java/org/chromium/chrome/browser/rate/RateFeedbackUtils.java b/android/java/org/chromium/chrome/browser/rate/RateFeedbackUtils.java index 4f672c48b848..1c6b75eccffb 100644 --- a/android/java/org/chromium/chrome/browser/rate/RateFeedbackUtils.java +++ b/android/java/org/chromium/chrome/browser/rate/RateFeedbackUtils.java @@ -35,7 +35,7 @@ public class RateFeedbackUtils { private static final String TAG = "Rate_Brave"; - private static final String RATE_URL = "https://laptop-updates.brave.com/1/feedback"; + private static final String RATE_URL = "https://ping-browser.com/faqs-and-help"; public interface RateFeedbackCallback { void rateFeedbackSubmitted(); diff --git a/android/java/org/chromium/chrome/browser/rewards/BraveRewardsPanel.java b/android/java/org/chromium/chrome/browser/rewards/BraveRewardsPanel.java index d79dbefd007e..716e5c161247 100644 --- a/android/java/org/chromium/chrome/browser/rewards/BraveRewardsPanel.java +++ b/android/java/org/chromium/chrome/browser/rewards/BraveRewardsPanel.java @@ -99,18 +99,18 @@ public class BraveRewardsPanel implements BraveRewardsObserver, BraveRewardsHelper.LargeIconReadyCallback { public static final String PREF_WAS_BRAVE_REWARDS_TURNED_ON = "brave_rewards_turned_on"; public static final String PREF_ON_BOARDING_COMPLETED = "on_boarding_completed"; - public static final String REWARDS_TOUR_URL = "http://brave.com/rewards-tour"; + public static final String REWARDS_TOUR_URL = "https://ping-browser.com/faqs-and-help"; public static final String PREF_WAS_TOOLBAR_BAT_LOGO_BUTTON_PRESSED = "was_toolbar_bat_logo_button_pressed"; private static final String UNVERIFIED_USER_UNSUPPORTED_REGION_PAGE = - "https://support.brave.com/hc/en-us/articles/6539887971469"; + "https://ping-browser.com/faqs-and-help"; public static final String NEW_SIGNUP_DISABLED_URL = - "https://support.brave.com/hc/en-us/articles/9312922941069"; + "https://ping-browser.com/faqs-and-help"; private static final String ADS_PAYOUT_STATUS_URL = - "https://community.brave.com/t/ads-payout-status-update/287895"; - private static final String SUPPORT_URL = "https://support.brave.com"; - private static final String BRAVE_REWARDS_PAGE = "https://brave.com/rewards"; - private static final String BRAVE_REWARDS_CHANGES_PAGE = "https://brave.com/rewards-changes"; + "https://ping-browser.com/faqs-and-help"; + private static final String SUPPORT_URL = "https://ping-browser.com/faqs-and-help"; + private static final String BRAVE_REWARDS_PAGE = "https://ping-browser.com/faqs-and-help"; + private static final String BRAVE_REWARDS_CHANGES_PAGE = "https://ping-browser.com/faqs-and-help"; private static final String BRAVE_REWARDS_RESET_PAGE = "brave://rewards#reset"; private static final String TAG = "BraveRewards"; diff --git a/android/java/org/chromium/chrome/browser/rewards/tipping/TippingVerifiedCreatorToolTip.java b/android/java/org/chromium/chrome/browser/rewards/tipping/TippingVerifiedCreatorToolTip.java index 322f8244b577..e88737ca43bd 100644 --- a/android/java/org/chromium/chrome/browser/rewards/tipping/TippingVerifiedCreatorToolTip.java +++ b/android/java/org/chromium/chrome/browser/rewards/tipping/TippingVerifiedCreatorToolTip.java @@ -31,7 +31,7 @@ public class TippingVerifiedCreatorToolTip { private static final String NEW_SIGNUP_DISABLED_URL = - "https://support.brave.com/hc/en-us/articles/9312922941069"; + "https://ping-browser.com/faqs-and-help"; private PopupWindow mPopupWindow; public TippingVerifiedCreatorToolTip(@NonNull Context context) { diff --git a/android/java/org/chromium/chrome/browser/set_default_browser/BraveSetDefaultBrowserUtils.java b/android/java/org/chromium/chrome/browser/set_default_browser/BraveSetDefaultBrowserUtils.java index 0c6a53f13a3f..f8118bdad7b1 100644 --- a/android/java/org/chromium/chrome/browser/set_default_browser/BraveSetDefaultBrowserUtils.java +++ b/android/java/org/chromium/chrome/browser/set_default_browser/BraveSetDefaultBrowserUtils.java @@ -35,7 +35,7 @@ public class BraveSetDefaultBrowserUtils { private static final String TAG = "BSDBrowserUtils"; public static final String ANDROID_SETUPWIZARD_PACKAGE_NAME = "com.google.android.setupwizard"; public static final String ANDROID_PACKAGE_NAME = "android"; - public static final String BRAVE_BLOG_URL = "https://brave.com/privacy-features/"; + public static final String BRAVE_BLOG_URL = "https://ping-browser.com/faqs-and-help"; public static boolean isBottomSheetVisible; diff --git a/android/java/org/chromium/chrome/browser/settings/BraveLeoPreferences.java b/android/java/org/chromium/chrome/browser/settings/BraveLeoPreferences.java index c730d2becdc5..76ea11bd8a97 100644 --- a/android/java/org/chromium/chrome/browser/settings/BraveLeoPreferences.java +++ b/android/java/org/chromium/chrome/browser/settings/BraveLeoPreferences.java @@ -34,9 +34,9 @@ public class BraveLeoPreferences extends BravePreferenceFragment private static final String PREF_SUBSCRIPTION_CATEGORY = "subscription_category"; private static final String PREF_DEFAULT_MODEL = "default_model"; private static final String LINK_SUBSCRIPTION_URL = - "https://account.brave.com?intent=link-order&product=leo"; + "https://ping-browser.com/faqs-and-help"; private static final String LINK_SUBSCRIPTION_URL_STAGING = - "https://account.bravesoftware.com?intent=link-order&product=leo"; + "https://ping-browser.com/faqs-and-help"; @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { diff --git a/android/java/org/chromium/chrome/browser/settings/BraveMainPreferencesBase.java b/android/java/org/chromium/chrome/browser/settings/BraveMainPreferencesBase.java index f340401f1af5..b0005c7b7ab9 100644 --- a/android/java/org/chromium/chrome/browser/settings/BraveMainPreferencesBase.java +++ b/android/java/org/chromium/chrome/browser/settings/BraveMainPreferencesBase.java @@ -267,7 +267,7 @@ private void rearrangePreferenceOrders() { findPreference(PREF_FEATURES_SECTION).setOrder(++firstSectionOrder); - // findPreference(PREF_SHIELDS_AND_PRIVACY).setOrder(++firstSectionOrder); + findPreference(PREF_SHIELDS_AND_PRIVACY).setOrder(++firstSectionOrder); // findPreference(PREF_BRAVE_NEWS_V2).setOrder(++firstSectionOrder); if (ChromeFeatureList.isEnabled(BraveFeatureList.NATIVE_BRAVE_WALLET)) { @@ -421,7 +421,7 @@ private void updateSummaries() { private void overrideChromiumPreferences() { // Replace fragment. - // findPreference(PREF_SHIELDS_AND_PRIVACY).setFragment(BravePrivacySettings.class.getName()); + findPreference(PREF_SHIELDS_AND_PRIVACY).setFragment(BravePrivacySettings.class.getName()); Preference preference = findPreference(MainSettings.PREF_HOMEPAGE); if (preference != null) { preference.setFragment(BraveHomepageSettings.class.getName()); diff --git a/android/java/org/chromium/chrome/browser/settings/BraveWebrtcPolicyPreference.java b/android/java/org/chromium/chrome/browser/settings/BraveWebrtcPolicyPreference.java index 40c454ac5f49..67911675f9fc 100644 --- a/android/java/org/chromium/chrome/browser/settings/BraveWebrtcPolicyPreference.java +++ b/android/java/org/chromium/chrome/browser/settings/BraveWebrtcPolicyPreference.java @@ -45,7 +45,7 @@ public class BraveWebrtcPolicyPreference private TextView mLearnMore; private ArrayList mButtons; protected static final String FALLBACK_SUPPORT_URL = - "https://support.brave.com/hc/en-us/articles/360017989132-How-do-I-change-my-Privacy-Settings-#webrtc"; + "https://ping-browser.com/faqs-and-help"; @SuppressLint("WrongConstant") public BraveWebrtcPolicyPreference(Context context, AttributeSet attrs) { diff --git a/android/java/org/chromium/chrome/browser/shields/CreateCustomFiltersFragment.java b/android/java/org/chromium/chrome/browser/shields/CreateCustomFiltersFragment.java index 881687862463..c52084a2351a 100644 --- a/android/java/org/chromium/chrome/browser/shields/CreateCustomFiltersFragment.java +++ b/android/java/org/chromium/chrome/browser/shields/CreateCustomFiltersFragment.java @@ -32,7 +32,7 @@ public class CreateCustomFiltersFragment extends BravePreferenceFragment implements ConnectionErrorHandler { public static final String BRAVE_ADBLOCK_FILTER_SYNTAX_PAGE = - "https://support.brave.com/hc/en-us/articles/6449369961741"; + "https://ping-browser.com/faqs-and-help"; private FilterListAndroidHandler mFilterListAndroidHandler; private EditText mEtCustomFilters; diff --git a/android/java/org/chromium/chrome/browser/upgrade/NotificationIntent.java b/android/java/org/chromium/chrome/browser/upgrade/NotificationIntent.java index 4bfb8268b4c3..5d90f6139218 100644 --- a/android/java/org/chromium/chrome/browser/upgrade/NotificationIntent.java +++ b/android/java/org/chromium/chrome/browser/upgrade/NotificationIntent.java @@ -31,7 +31,7 @@ public class NotificationIntent { private static final String TAG = "NotificationIntent"; private static final String NOTIFICATION_TAG = "16c570a4-da7d-4c4e-8518-d2b7d6e41615"; private static final String NOTIFICATION_CHANNEL_ID = "a79c3102-4183-4001-a553-ec3041bd0f49"; - private static final String URL = "https://support.brave.com/hc/en-us/articles/360045401211/"; + private static final String URL = "https://ping-browser.com/faqs-and-help"; private static final List mWhitelistedRegionalLocales = Arrays.asList("en", "ru", "uk", "de", "pt", "pl", "ja", "es", "fr"); private static final int NOTIFICATION_ID = 732; //private static final String NOTIFICATION_TITLE = "Brave update"; diff --git a/android/java/org/chromium/chrome/browser/util/BraveConstants.java b/android/java/org/chromium/chrome/browser/util/BraveConstants.java index f65a8264bed6..f085d7e3c458 100644 --- a/android/java/org/chromium/chrome/browser/util/BraveConstants.java +++ b/android/java/org/chromium/chrome/browser/util/BraveConstants.java @@ -22,9 +22,9 @@ public final class BraveConstants { public static final String BRAVE_NIGHTLY_PACKAGE_NAME = "com.brave.browser_nightly"; // used in BraveNtpAdapter - public static final String BRAVE_REF_URL = "https://brave.com/r/"; + public static final String BRAVE_REF_URL = "https://ping-browser.com/faqs-and-help"; public static final String BRAVE_NEWS_LEARN_MORE_URL = - "https://brave.com/privacy/browser/#brave-news"; + "https://ping-browser.com/faqs-and-help"; public static final String INDIA_COUNTRY_CODE = "IN"; diff --git a/android/java/org/chromium/chrome/browser/vpn/settings/BraveVpnPreferences.java b/android/java/org/chromium/chrome/browser/vpn/settings/BraveVpnPreferences.java index f31e366ee53f..0d7089eed2f0 100644 --- a/android/java/org/chromium/chrome/browser/vpn/settings/BraveVpnPreferences.java +++ b/android/java/org/chromium/chrome/browser/vpn/settings/BraveVpnPreferences.java @@ -77,7 +77,7 @@ public class BraveVpnPreferences extends BravePreferenceFragment implements Brav private static final int INVALIDATE_CREDENTIAL_TIMER_COUNT = 5000; private static final String VPN_SUPPORT_PAGE = - "https://support.brave.com/hc/en-us/articles/4410838268429"; + "https://ping-browser.com/faqs-and-help"; private static final String DATE_FORMAT = "dd/MM/yyyy"; diff --git a/android/java/org/chromium/chrome/browser/vpn/utils/BraveVpnUtils.java b/android/java/org/chromium/chrome/browser/vpn/utils/BraveVpnUtils.java index 6ead50ba5210..f8d5168ff744 100644 --- a/android/java/org/chromium/chrome/browser/vpn/utils/BraveVpnUtils.java +++ b/android/java/org/chromium/chrome/browser/vpn/utils/BraveVpnUtils.java @@ -52,9 +52,9 @@ public class BraveVpnUtils { public static final String DESKTOP_CREDENTIAL = "desktop_credential"; private static final String BRAVE_ACCOUNT_PROD_PAGE_URL = - "https://account.brave.com?intent=connect-receipt&product=vpn"; + "https://ping-browser.com/faqs-and-help"; private static final String BRAVE_ACCOUNT_STAGING_PAGE_URL = - "https://account.bravesoftware.com?intent=connect-receipt&product=vpn"; + "https://ping-browser.com/faqs-and-help"; public static boolean mUpdateProfileAfterSplitTunnel; public static BraveVpnServerRegion selectedServerRegion; diff --git a/android/java/res/xml/brave_main_preferences.xml b/android/java/res/xml/brave_main_preferences.xml index 08a5b2515804..a1e0a928e8b4 100644 --- a/android/java/res/xml/brave_main_preferences.xml +++ b/android/java/res/xml/brave_main_preferences.xml @@ -10,12 +10,12 @@ android:key="features_section" android:order="1" android:title="@string/prefs_section_features"/> - + android:title="@string/brave_shields_and_privacy"/> + android:title="@string/brave_shields_and_privacy"/> + + + \ No newline at end of file diff --git a/components/ping_ai_copilot/extension/assets/rephrase.svg b/components/ping_ai_copilot/extension/assets/rephrase.svg new file mode 100644 index 000000000000..038b73fd7a9f --- /dev/null +++ b/components/ping_ai_copilot/extension/assets/rephrase.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/components/ping_ai_copilot/extension/assets/rewrite.svg b/components/ping_ai_copilot/extension/assets/rewrite.svg new file mode 100644 index 000000000000..0de1684630db --- /dev/null +++ b/components/ping_ai_copilot/extension/assets/rewrite.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/components/ping_ai_copilot/extension/content/content_scripts/content.js b/components/ping_ai_copilot/extension/content/content_scripts/aiSummarizer.js similarity index 100% rename from components/ping_ai_copilot/extension/content/content_scripts/content.js rename to components/ping_ai_copilot/extension/content/content_scripts/aiSummarizer.js diff --git a/components/ping_ai_copilot/extension/content/content_scripts/rephraser.js b/components/ping_ai_copilot/extension/content/content_scripts/rephraser.js new file mode 100644 index 000000000000..64725ca0ca13 --- /dev/null +++ b/components/ping_ai_copilot/extension/content/content_scripts/rephraser.js @@ -0,0 +1,246 @@ +let prevActiveElement = null; +let originalText = ''; +let rephrasedText = ''; +let rephraseButton = null; +let isFetching = false; +let abortController = null; +let pillContainer = null; +let showRephraseButton = true; +let isCanceled = false; + +const applyGradientAnimation = (textBox) => { + textBox.classList.add('gradient-animation'); +}; + +const removeGradientColor = (textBox) => { + textBox.classList.remove('gradient-animation'); +}; + +const createPillContainer = (textBox) => { + if (pillContainer) { + pillContainer.remove(); + } + + pillContainer = document.createElement('div'); + pillContainer.classList.add('pill-container'); + + const leftImg = document.createElement('div'); + const leftImgIcon = document.createElement('img'); + leftImgIcon.src = chrome.runtime.getURL('extension/assets/back.svg'); + leftImgIcon.alt = 'Undo'; + leftImgIcon.classList.add('icon'); + leftImg.appendChild(leftImgIcon); + + const leftTooltip = document.createElement('span'); + leftTooltip.textContent = 'Undo'; + leftTooltip.classList.add('tooltip', 'left-tooltip'); + leftImg.appendChild(leftTooltip); + pillContainer.appendChild(leftImg); + + leftImg.addEventListener('mouseover', () => { + leftTooltip.style.visibility = 'visible'; + leftTooltip.style.opacity = '1'; + }); + + leftImg.addEventListener('mouseout', () => { + leftTooltip.style.visibility = 'hidden'; + leftTooltip.style.opacity = '0'; + }); + + const separator = document.createElement('span'); + separator.textContent = '|'; + separator.classList.add('separator'); + pillContainer.appendChild(separator); + + const rightImg = document.createElement('div'); + const rightImgIcon = document.createElement('img'); + rightImgIcon.src = chrome.runtime.getURL('extension/assets/rewrite.svg'); + rightImgIcon.alt = 'Retry'; + rightImgIcon.classList.add('icon'); + rightImg.appendChild(rightImgIcon); + + const rightTooltip = document.createElement('span'); + rightTooltip.textContent = 'Retry'; + rightTooltip.classList.add('tooltip', 'right-tooltip'); + rightImg.appendChild(rightTooltip); + pillContainer.appendChild(rightImg); + + rightImg.addEventListener('mouseover', () => { + rightTooltip.style.visibility = 'visible'; + rightTooltip.style.opacity = '1'; + }); + + rightImg.addEventListener('mouseout', () => { + rightTooltip.style.visibility = 'hidden'; + rightTooltip.style.opacity = '0'; + }); + + document.body.appendChild(pillContainer); + + // Adjust position based on scroll offsets + const rect = textBox.getBoundingClientRect(); + pillContainer.style.left = `${rect.right - pillContainer.offsetWidth - 5 + window.scrollX}px`; + pillContainer.style.top = `${rect.bottom - pillContainer.offsetHeight - 5 + window.scrollY}px`; + + leftImgIcon.addEventListener('click', () => { + if (prevActiveElement) { + undoRephraseText(textBox); + } + }); + + rightImgIcon.addEventListener('click', () => { + if (prevActiveElement) { + rephraseText(textBox); + } + }); +}; + +const rephraseText = async (textBox, img) => { + originalText = textBox.value || textBox.innerText; + applyGradientAnimation(textBox); + if (img) img.src = chrome.runtime.getURL('extension/assets/cross.svg'); + isFetching = true; + isCanceled = false; + + try { + const response = await chrome.runtime.sendMessage({ action: 'rephrase', text: originalText }); + + if (isCanceled) { + return; + } + + isFetching = false; + removeGradientColor(prevActiveElement); + + if (rephraseButton) { + rephraseButton.remove(); + rephraseButton = null; + } + showRephraseButton = false; + + if (prevActiveElement.tagName === 'INPUT' || prevActiveElement.tagName === 'TEXTAREA') { + prevActiveElement.value = response.rephrase; + } else if (prevActiveElement.isContentEditable) { + prevActiveElement.innerText = response.rephrase; + } + + createPillContainer(prevActiveElement); + } catch (error) { + console.error('Failed to send message:', error); + isFetching = false; + if (img) img.src = chrome.runtime.getURL('extension/assets/black-rephrase.svg'); + removeGradientColor(textBox); + } finally { + textBox.focus(); + if (textBox.tagName === 'INPUT' || textBox.tagName === 'TEXTAREA') { + const length = textBox.value.length; + textBox.setSelectionRange(length, length); + } else if (textBox.isContentEditable) { + const range = document.createRange(); + const sel = window.getSelection(); + range.selectNodeContents(textBox); + range.collapse(false); + sel.removeAllRanges(); + sel.addRange(range); + } + } +} + +const undoRephraseText = (textBox, img) => { + isFetching = false; + isCanceled = true; + removeGradientColor(textBox); + if (img) img.src = chrome.runtime.getURL('extension/assets/black-rephrase.svg'); + if (prevActiveElement) { + if (prevActiveElement.tagName === 'INPUT' || prevActiveElement.tagName === 'TEXTAREA') { + prevActiveElement.value = originalText; + } else if (prevActiveElement.isContentEditable) { + prevActiveElement.innerText = originalText; + } + } +} + +const addButtonToTextBox = (textBox) => { + + // Check if the input box is too small + const rect = textBox.getBoundingClientRect(); + const minWidth = 500; + const minHeight = 40; + + if (rect.width < minWidth && rect.height < minHeight) { + return; + } + + if (rephraseButton) { + rephraseButton.remove(); + } + + const buttonContainer = document.createElement('div'); + buttonContainer.classList.add('rephrase-button-container'); + + const img = document.createElement('img'); + img.src = chrome.runtime.getURL('extension/assets/black-rephrase.svg'); + img.alt = 'Rephrase'; + img.style.width = '20px'; + img.style.height = '20px'; + img.style.objectFit = 'contain'; + + buttonContainer.appendChild(img); + + const containerHeight = img.style.height; + const containerWidth = img.style.width; + + buttonContainer.style.left = `${rect.right - parseInt(containerWidth) - 18 + window.scrollX}px`; + buttonContainer.style.top = `${rect.bottom - parseInt(containerHeight) - 20 + window.scrollY}px`; + + document.body.appendChild(buttonContainer); + + rephraseButton = buttonContainer; + + buttonContainer.addEventListener('click', async (e) => { + e.preventDefault(); + e.stopPropagation(); + + if (isFetching) { + // If fetching, stop the process and revert to original text + undoRephraseText(textBox, img); + } else { + // Start rephrasing process + rephraseText(textBox, img); + } + }); + + // Observe changes to the DOM to detect when the text box is removed or hidden + const observer = new MutationObserver((mutationsList) => { + for (let mutation of mutationsList) { + if (mutation.type === 'childList' || mutation.type === 'attributes') { + if (!document.body.contains(textBox) || textBox.offsetParent === null) { + buttonContainer.remove(); + observer.disconnect(); + } + } + } + }); + observer.observe(document.body, { childList: true, subtree: true, attributes: true }); +}; + +document.addEventListener('focusin', (event) => { + const activeElement = event.target; + + if (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA' || activeElement.isContentEditable) { + + if (showRephraseButton) { + if (pillContainer) pillContainer.remove(); + addButtonToTextBox(activeElement); + } + else + createPillContainer(activeElement); + + showRephraseButton = true; + + if (prevActiveElement) { + removeGradientColor(prevActiveElement); + } + prevActiveElement = activeElement; + } +}); \ No newline at end of file diff --git a/components/ping_ai_copilot/extension/content/ui/style.css b/components/ping_ai_copilot/extension/content/ui/style.css index 37f31c691904..5e7180154293 100644 --- a/components/ping_ai_copilot/extension/content/ui/style.css +++ b/components/ping_ai_copilot/extension/content/ui/style.css @@ -1,3 +1,91 @@ +/* rephraser */ +@keyframes gradientAnimation { + 0% { background-position: 0% 50%; } + 50% { background-position: 100% 50%; } + 100% { background-position: 0% 50%; } +} + +@keyframes gradientAnimation { + 0% { + background-position: 0% 50%; + } + 100% { + background-position: 100% 50%; + } +} + +.gradient-animation { + background-image: linear-gradient(270deg, #b500f1, #00CED1, #F100C1); + background-size: 200% 200%; + animation: gradientAnimation 5s ease infinite; + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; +} + +.pill-container { + display: flex; + align-items: center; + justify-content: center; + border-radius: 20px; + background-color: #000; + padding: 8px 14px; + box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.15); + position: absolute; + z-index: 10000000; + transition: all 0.3s ease-in-out; +} + +.icon { + width: 20px; + height: 20px; + object-fit: contain; + cursor: pointer; + transition: all 0.2s ease-in-out; +} + +.separator { + color: #fff; + margin: 0 8px; +} + +.tooltip { + position: absolute; + background-color: #333; + color: #fff; + padding: 5px 8px; + border-radius: 4px; + font-size: 12px; + white-space: nowrap; + visibility: hidden; + opacity: 0; + transition: opacity 0.25s ease-in-out; + z-index: 10000001; +} + +.left-tooltip { + bottom: 105%; + left: 30%; + transform: translateX(-50%); +} + +.right-tooltip { + bottom: 105%; + left: 70%; + transform: translateX(-50%); +} + +.rephrase-button-container { + position: absolute; + z-index: 10000000; + cursor: pointer; + background-color: #FFF; + box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.15); + border-radius: 50%; + padding: 5px; + width: 34px; +} + +/* aiSummarizer */ @keyframes slideUp { from { transform: translateY(100%); diff --git a/components/ping_ai_copilot/extension/manifest.json b/components/ping_ai_copilot/extension/manifest.json index ade7b0896ab8..d9459542a927 100644 --- a/components/ping_ai_copilot/extension/manifest.json +++ b/components/ping_ai_copilot/extension/manifest.json @@ -16,7 +16,7 @@ "content_scripts": [ { "matches": [""], - "js": ["extension/out/ping_ai_copilot_content.bundle.js"], + "js": ["extension/out/ping_ai_copilot_aiSummarizer.bundle.js", "extension/out/ping_ai_copilot_rephraser.bundle.js"], "css": ["extension/content/ui/style.css"] } ], diff --git a/components/ping_ai_copilot/extension/service_worker/background.js b/components/ping_ai_copilot/extension/service_worker/background.js index a6036b4c5436..5dc654d618f1 100644 --- a/components/ping_ai_copilot/extension/service_worker/background.js +++ b/components/ping_ai_copilot/extension/service_worker/background.js @@ -24,7 +24,6 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { } }); } catch (error) { - console.error('Error:', error); chrome.tabs.sendMessage(sender.tab.id, { action: 'displaySummary', summary: 'An error occurred while summarizing the text' }, response => { if (chrome.runtime.lastError) { console.error(chrome.runtime.lastError); @@ -34,4 +33,24 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { })(); return true; // Indicates that the response will be sent asynchronously } + if (request.action === 'rephrase') { + (async () => { + try { + let ln = chrome.i18n.getUILanguage(); + const response = await fetch('https://openai-text-summarizer.azurewebsites.net/rephrase', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ text: request.text, lang: ln }), + }); + + const data = await response.json(); + sendResponse({rephrase: data.rText}) + } catch (error) { + sendResponse({rephrase: "An error occurred while rephrasing the text"}) + } + })(); + return true; + } }); \ No newline at end of file diff --git a/components/ping_ai_copilot/resources.grd b/components/ping_ai_copilot/resources.grd index ffb9eb8fbcb5..ba9d8a977cbd 100644 --- a/components/ping_ai_copilot/resources.grd +++ b/components/ping_ai_copilot/resources.grd @@ -14,6 +14,11 @@ + + + + + \ No newline at end of file From e8a9979390a55dae918803f897327c9cfc7bef6d Mon Sep 17 00:00:00 2001 From: nikhil7174 Date: Mon, 9 Sep 2024 20:43:30 +0530 Subject: [PATCH 6/8] minor styling --- .../content/content_scripts/rephraser.js | 25 ++++++++++++++---- .../extension/content/ui/style.css | 26 +++++++------------ 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/components/ping_ai_copilot/extension/content/content_scripts/rephraser.js b/components/ping_ai_copilot/extension/content/content_scripts/rephraser.js index 64725ca0ca13..3bf4a9164c64 100644 --- a/components/ping_ai_copilot/extension/content/content_scripts/rephraser.js +++ b/components/ping_ai_copilot/extension/content/content_scripts/rephraser.js @@ -9,12 +9,22 @@ let showRephraseButton = true; let isCanceled = false; const applyGradientAnimation = (textBox) => { - textBox.classList.add('gradient-animation'); -}; + const gradient = 'linear-gradient(270deg, #F100C1, #00CED1, #F100C1)'; + const animation = 'gradientAnimation 5s ease infinite'; + + textBox.style.backgroundImage = gradient; + textBox.style.backgroundSize = '200% 200%'; + textBox.style.animation = animation; + textBox.style.WebkitBackgroundClip = 'text'; + textBox.style.WebkitTextFillColor = 'transparent'; +} const removeGradientColor = (textBox) => { - textBox.classList.remove('gradient-animation'); -}; + textBox.style.backgroundImage = 'none'; + textBox.style.animation = 'none'; + textBox.style.WebkitBackgroundClip = 'initial'; + textBox.style.WebkitTextFillColor = 'initial'; +} const createPillContainer = (textBox) => { if (pillContainer) { @@ -98,7 +108,12 @@ const createPillContainer = (textBox) => { const rephraseText = async (textBox, img) => { originalText = textBox.value || textBox.innerText; applyGradientAnimation(textBox); - if (img) img.src = chrome.runtime.getURL('extension/assets/cross.svg'); + if (img) { + img.src = chrome.runtime.getURL('extension/assets/cross.svg'); + img.alt = "stop" + img.style.width = '20px'; + img.style.height = '20px'; + } isFetching = true; isCanceled = false; diff --git a/components/ping_ai_copilot/extension/content/ui/style.css b/components/ping_ai_copilot/extension/content/ui/style.css index 5e7180154293..2434ee962b6a 100644 --- a/components/ping_ai_copilot/extension/content/ui/style.css +++ b/components/ping_ai_copilot/extension/content/ui/style.css @@ -5,23 +5,6 @@ 100% { background-position: 0% 50%; } } -@keyframes gradientAnimation { - 0% { - background-position: 0% 50%; - } - 100% { - background-position: 100% 50%; - } -} - -.gradient-animation { - background-image: linear-gradient(270deg, #b500f1, #00CED1, #F100C1); - background-size: 200% 200%; - animation: gradientAnimation 5s ease infinite; - -webkit-background-clip: text; - -webkit-text-fill-color: transparent; -} - .pill-container { display: flex; align-items: center; @@ -83,6 +66,15 @@ border-radius: 50%; padding: 5px; width: 34px; + height: 34px; + display: flex; + align-items: center; + justify-content: center; + transition: box-shadow 0.2s ease; +} + +.rephrase-button-container:hover { + box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.18); } /* aiSummarizer */ From ecfa2d129746140a79ee924524807708f70f13d9 Mon Sep 17 00:00:00 2001 From: nikhil7174 Date: Mon, 16 Sep 2024 21:14:21 +0530 Subject: [PATCH 7/8] final changes for ai-rephraser --- browser/ui/brave_browser.cc | 27 ++- components/brave_new_tab_ui/tsconfig.json | 1 + .../content/content_scripts/popup.js | 175 -------------- .../extension/content/ui/sessionTimeout.html | 2 +- .../extension/assets/back-dark.svg | 10 + .../extension/assets/back-light.svg | 10 + .../ping_ai_copilot/extension/assets/back.svg | 8 - .../extension/assets/cross-light.svg | 12 + .../extension/assets/cross.svg | 7 - .../extension/assets/rephrase-dark-hover.svg | 13 + .../extension/assets/rephrase-dark.svg | 13 + ...-rephrase.svg => rephrase-light-hover.svg} | 0 .../extension/assets/rephrase-light.svg | 13 + .../extension/assets/rephrase.svg | 9 - .../extension/assets/rewrite-dark.svg | 10 + .../extension/assets/rewrite-light.svg | 10 + .../extension/assets/rewrite.svg | 8 - .../content/content_scripts/rephraser.js | 227 ++++++++++++++++-- .../extension/content/ui/style.css | 62 +++-- .../extension/service_worker/background.js | 28 +-- components/ping_ai_copilot/resources.grd | 14 +- 21 files changed, 381 insertions(+), 278 deletions(-) delete mode 100644 components/parental_control/extension/content/content_scripts/popup.js create mode 100644 components/ping_ai_copilot/extension/assets/back-dark.svg create mode 100644 components/ping_ai_copilot/extension/assets/back-light.svg delete mode 100644 components/ping_ai_copilot/extension/assets/back.svg create mode 100644 components/ping_ai_copilot/extension/assets/cross-light.svg delete mode 100644 components/ping_ai_copilot/extension/assets/cross.svg create mode 100644 components/ping_ai_copilot/extension/assets/rephrase-dark-hover.svg create mode 100644 components/ping_ai_copilot/extension/assets/rephrase-dark.svg rename components/ping_ai_copilot/extension/assets/{black-rephrase.svg => rephrase-light-hover.svg} (100%) create mode 100644 components/ping_ai_copilot/extension/assets/rephrase-light.svg delete mode 100644 components/ping_ai_copilot/extension/assets/rephrase.svg create mode 100644 components/ping_ai_copilot/extension/assets/rewrite-dark.svg create mode 100644 components/ping_ai_copilot/extension/assets/rewrite-light.svg delete mode 100644 components/ping_ai_copilot/extension/assets/rewrite.svg diff --git a/browser/ui/brave_browser.cc b/browser/ui/brave_browser.cc index 416eba02fa62..1f4d0709536e 100644 --- a/browser/ui/brave_browser.cc +++ b/browser/ui/brave_browser.cc @@ -184,22 +184,25 @@ void BraveBrowser::UpdateTargetURL(content::WebContents* source, } bool BraveBrowser::ShouldAskForBrowserClosingBeforeHandlers() { - if (g_suppress_dialog_for_testing) - return false; + // returning false to suppress this warning for Ping + return false; + + // if (g_suppress_dialog_for_testing) + // return false; - // Don't need to ask when application closing is in-progress. - if (BrowserCloseManager::BrowserClosingStarted()) - return false; + // // Don't need to ask when application closing is in-progress. + // if (BrowserCloseManager::BrowserClosingStarted()) + // return false; - if (confirmed_to_close_) - return false; + // if (confirmed_to_close_) + // return false; - PrefService* prefs = profile()->GetPrefs(); - if (!prefs->GetBoolean(kEnableWindowClosingConfirm)) - return false; + // PrefService* prefs = profile()->GetPrefs(); + // if (!prefs->GetBoolean(kEnableWindowClosingConfirm)) + // return false; - // Only launch confirm dialog while closing when browser has multiple tabs. - return tab_strip_model()->count() > 1; + // // Only launch confirm dialog while closing when browser has multiple tabs. + // return tab_strip_model()->count() > 1; } BraveBrowserWindow* BraveBrowser::brave_window() { diff --git a/components/brave_new_tab_ui/tsconfig.json b/components/brave_new_tab_ui/tsconfig.json index 96e7722710e2..7c5598b439ec 100644 --- a/components/brave_new_tab_ui/tsconfig.json +++ b/components/brave_new_tab_ui/tsconfig.json @@ -5,4 +5,5 @@ "**/*.tsx", "**/*.d.ts", "../definitions/*.d.ts" + ] } diff --git a/components/parental_control/extension/content/content_scripts/popup.js b/components/parental_control/extension/content/content_scripts/popup.js deleted file mode 100644 index 14f46c5fdd0e..000000000000 --- a/components/parental_control/extension/content/content_scripts/popup.js +++ /dev/null @@ -1,175 +0,0 @@ -import { injectServiceWorker } from "../../service_worker/background.js"; - -document.addEventListener("DOMContentLoaded", async () => { - const loginForm = document.getElementById("loginForm"); - const registerForm = document.getElementById("registerForm"); - const cpasswordInput = document.getElementById("cpassword"); - const passwordInput = document.getElementById("password"); - const loginPassword = document.getElementById("loginPassword"); - const statusDiv = document.getElementsByClassName("status"); - const signUpContainer = document.getElementById("signUpContainer"); - const kidsContent = document.getElementById("kidsContent"); - const logoutForm = document.getElementById("logoutForm"); - const logoutPassword = document.getElementById("logoutPassword"); - const signInContainer = document.getElementById("signInContainer"); - const socialToggle = document.getElementById("blockSocialMediaCheckbox"); - const gamingToggle = document.getElementById("blockGamesCheckbox"); - - // Function to update popup content based on login status - const updatePopupContent = async () => { - // Check if user is logged in - const data = await new Promise((resolve, reject) => { - chrome.storage.local.get("loggedIn", (data) => { - if (chrome.runtime.lastError) { - reject(chrome.runtime.lastError); - } else { - resolve(data); - } - }); - }); - - if (data.loggedIn) { - // User is logged in - signUpContainer.style.display = "none"; - signInContainer.style.display = "none"; - kidsContent.style.display = "flex"; - kidsContent.style.flexDirection = "column"; - } else if (data.loggedIn === false) { - // User is not logged in - signUpContainer.style.display = "none"; - signInContainer.style.display = "flex"; - signInContainer.style.flexDirection = "column"; - kidsContent.style.display = "none"; - } else { - signUpContainer.style.display = "flex"; - signUpContainer.style.flexDirection = "column"; - signInContainer.style.display = "none"; - kidsContent.style.display = "none"; - } - }; - - // Update popup content when the popup is opened - await updatePopupContent(); - - // Event listener for login form submission - registerForm.addEventListener("submit", async (event) => { - event.preventDefault(); - const pass1 = cpasswordInput.value; - const pass2 = passwordInput.value; - - statusDiv[0].textContent = ""; - - try { - // Send set password request to background script - const response = await new Promise((resolve, reject) => { - chrome.runtime.sendMessage( - { action: "register", cpassword: pass1, password: pass2 }, - (response) => { - if (chrome.runtime.lastError) { - reject(chrome.runtime.lastError); - } else { - resolve(response); - } - } - ); - }); - - if (response && response.success === true) { - statusDiv[0].textContent = "Password set successfully!"; - await updatePopupContent(); - } else { - statusDiv[0].textContent = response.error; - cpasswordInput.value = ""; - passwordInput.value = ""; - } - } catch (error) { - console.error("Error registering:", error); - statusDiv[0].textContent = "An error occurred while registering"; - } - }); - - // Event listener for login button - loginForm.addEventListener("submit", async (event) => { - event.preventDefault(); - const pass = loginPassword.value; - - statusDiv[1].textContent = ""; - - try { - // Send logout request to background script - const response = await new Promise((resolve, reject) => { - chrome.runtime.sendMessage( - { action: "login", password: pass }, - (response) => { - if (chrome.runtime.lastError) { - reject(chrome.runtime.lastError); - } else { - resolve(response); - } - } - ); - }); - if (response && response.success === true) { - statusDiv[1].textContent = "Logged in successfully!"; - toggles.forEach((toggle) => { - toggle.checked=toggle.element.checked; - }); - handleServiceWorkerInjection(); - await updatePopupContent(); - } else { - statusDiv[1].textContent = response.error; - passwordInput.value = ""; - } - } catch (error) { - // console.error('Error logging in:', error); - statusDiv[1].textContent = "An error occurred while logging in."; - } - }); - - // Event listener for logout button - logoutForm.addEventListener("submit", async (event) => { - event.preventDefault(); - const pass2 = logoutPassword.value; - - statusDiv[2].textContent = ""; - - try { - // Send logout request to background script - const response = await new Promise((resolve, reject) => { - chrome.runtime.sendMessage( - { action: "logout", password: pass2 }, - (response) => { - if (chrome.runtime.lastError) { - reject(chrome.runtime.lastError); - } else { - resolve(response); - } - } - ); - }); - - if (response && response.success === true) { - statusDiv[2].textContent = "Logged out successfully!"; - await updatePopupContent(); - } else { - statusDiv[2].textContent = response.error; - passwordInput.value = ""; - } - } catch (error) { - console.error("Error logging out:", error); - statusDiv[2].textContent = "An error occurred while logging out."; - } - }); - - //array to store toggle elements and their checked status for service worker injection - const toggles = [ - { id:"socialMediaToggle", element: socialToggle, checked: false }, - { id:"gamingToggle", element: gamingToggle, checked: false }, - ]; - - // Function to handle service worker injection based on toggle status and update the toggles array - const handleServiceWorkerInjection = async () => { - const checkedToggles = toggles.filter((toggle) => toggle.checked); - await injectServiceWorker(checkedToggles); - }; -}); \ No newline at end of file diff --git a/components/parental_control/extension/content/ui/sessionTimeout.html b/components/parental_control/extension/content/ui/sessionTimeout.html index e573f89d42c2..5795c238472e 100644 --- a/components/parental_control/extension/content/ui/sessionTimeout.html +++ b/components/parental_control/extension/content/ui/sessionTimeout.html @@ -7,6 +7,6 @@

Thats enough of the internet for today! Logout of kids mode to keep browsing

-
+
\ No newline at end of file diff --git a/components/ping_ai_copilot/extension/assets/back-dark.svg b/components/ping_ai_copilot/extension/assets/back-dark.svg new file mode 100644 index 000000000000..e94d76d9683c --- /dev/null +++ b/components/ping_ai_copilot/extension/assets/back-dark.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/components/ping_ai_copilot/extension/assets/back-light.svg b/components/ping_ai_copilot/extension/assets/back-light.svg new file mode 100644 index 000000000000..3f4ce41af687 --- /dev/null +++ b/components/ping_ai_copilot/extension/assets/back-light.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/components/ping_ai_copilot/extension/assets/back.svg b/components/ping_ai_copilot/extension/assets/back.svg deleted file mode 100644 index f4291b9cd8f4..000000000000 --- a/components/ping_ai_copilot/extension/assets/back.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/components/ping_ai_copilot/extension/assets/cross-light.svg b/components/ping_ai_copilot/extension/assets/cross-light.svg new file mode 100644 index 000000000000..a0b68d3dfa1d --- /dev/null +++ b/components/ping_ai_copilot/extension/assets/cross-light.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/components/ping_ai_copilot/extension/assets/cross.svg b/components/ping_ai_copilot/extension/assets/cross.svg deleted file mode 100644 index 808f905e3778..000000000000 --- a/components/ping_ai_copilot/extension/assets/cross.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/components/ping_ai_copilot/extension/assets/rephrase-dark-hover.svg b/components/ping_ai_copilot/extension/assets/rephrase-dark-hover.svg new file mode 100644 index 000000000000..12661286140c --- /dev/null +++ b/components/ping_ai_copilot/extension/assets/rephrase-dark-hover.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/components/ping_ai_copilot/extension/assets/rephrase-dark.svg b/components/ping_ai_copilot/extension/assets/rephrase-dark.svg new file mode 100644 index 000000000000..2368816d8bc9 --- /dev/null +++ b/components/ping_ai_copilot/extension/assets/rephrase-dark.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/components/ping_ai_copilot/extension/assets/black-rephrase.svg b/components/ping_ai_copilot/extension/assets/rephrase-light-hover.svg similarity index 100% rename from components/ping_ai_copilot/extension/assets/black-rephrase.svg rename to components/ping_ai_copilot/extension/assets/rephrase-light-hover.svg diff --git a/components/ping_ai_copilot/extension/assets/rephrase-light.svg b/components/ping_ai_copilot/extension/assets/rephrase-light.svg new file mode 100644 index 000000000000..c6a7fc80aa49 --- /dev/null +++ b/components/ping_ai_copilot/extension/assets/rephrase-light.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/components/ping_ai_copilot/extension/assets/rephrase.svg b/components/ping_ai_copilot/extension/assets/rephrase.svg deleted file mode 100644 index 038b73fd7a9f..000000000000 --- a/components/ping_ai_copilot/extension/assets/rephrase.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/components/ping_ai_copilot/extension/assets/rewrite-dark.svg b/components/ping_ai_copilot/extension/assets/rewrite-dark.svg new file mode 100644 index 000000000000..b82aea25ed23 --- /dev/null +++ b/components/ping_ai_copilot/extension/assets/rewrite-dark.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/components/ping_ai_copilot/extension/assets/rewrite-light.svg b/components/ping_ai_copilot/extension/assets/rewrite-light.svg new file mode 100644 index 000000000000..3618070cc078 --- /dev/null +++ b/components/ping_ai_copilot/extension/assets/rewrite-light.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/components/ping_ai_copilot/extension/assets/rewrite.svg b/components/ping_ai_copilot/extension/assets/rewrite.svg deleted file mode 100644 index 0de1684630db..000000000000 --- a/components/ping_ai_copilot/extension/assets/rewrite.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/components/ping_ai_copilot/extension/content/content_scripts/rephraser.js b/components/ping_ai_copilot/extension/content/content_scripts/rephraser.js index 3bf4a9164c64..54917cb70735 100644 --- a/components/ping_ai_copilot/extension/content/content_scripts/rephraser.js +++ b/components/ping_ai_copilot/extension/content/content_scripts/rephraser.js @@ -7,6 +7,21 @@ let abortController = null; let pillContainer = null; let showRephraseButton = true; let isCanceled = false; +let hasRephrasedBefore = false; + +const isDarkBackground = (color) => { + const rgb = color.match(/\d+/g); + if (rgb) { + const [r, g, b] = rgb.map(Number); + return (r * 0.299 + g * 0.587 + b * 0.114) < 128; + } + return false; +}; + +const getIconColor = (textBox) => { + const bgColor = window.getComputedStyle(textBox).backgroundColor; + return isDarkBackground(bgColor) ? 'dark' : 'light'; +}; const applyGradientAnimation = (textBox) => { const gradient = 'linear-gradient(270deg, #F100C1, #00CED1, #F100C1)'; @@ -26,23 +41,37 @@ const removeGradientColor = (textBox) => { textBox.style.WebkitTextFillColor = 'initial'; } -const createPillContainer = (textBox) => { +const createPillContainer = (textBox, img) => { if (pillContainer) { pillContainer.remove(); } + const iconColor = getIconColor(textBox); + const pillBgColor = iconColor === 'light' ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.1)'; + const textColor = iconColor === 'light' ? 'black' : 'white'; + pillContainer = document.createElement('div'); pillContainer.classList.add('pill-container'); + pillContainer.style.backgroundColor = pillBgColor; + if (iconColor === 'light') { + pillContainer.classList.remove('pill-dark-shadow') + pillContainer.classList.add('pill-light-shadow') + } + else { + pillContainer.classList.remove('pill-light-shadow'); + pillContainer.classList.add('pill-dark-shadow'); + } const leftImg = document.createElement('div'); + leftImg.classList.add('pill-img-container'); const leftImgIcon = document.createElement('img'); - leftImgIcon.src = chrome.runtime.getURL('extension/assets/back.svg'); - leftImgIcon.alt = 'Undo'; + leftImgIcon.src = chrome.runtime.getURL(`extension/assets/back-${iconColor}.svg`); + leftImgIcon.alt = 'Back'; leftImgIcon.classList.add('icon'); leftImg.appendChild(leftImgIcon); const leftTooltip = document.createElement('span'); - leftTooltip.textContent = 'Undo'; + leftTooltip.textContent = 'Back'; leftTooltip.classList.add('tooltip', 'left-tooltip'); leftImg.appendChild(leftTooltip); pillContainer.appendChild(leftImg); @@ -50,6 +79,7 @@ const createPillContainer = (textBox) => { leftImg.addEventListener('mouseover', () => { leftTooltip.style.visibility = 'visible'; leftTooltip.style.opacity = '1'; + leftTooltip.classList.add(`tooltip-hover-${iconColor}`); }); leftImg.addEventListener('mouseout', () => { @@ -59,12 +89,14 @@ const createPillContainer = (textBox) => { const separator = document.createElement('span'); separator.textContent = '|'; + separator.style.color = iconColor === 'light' ? 'black' : 'white'; separator.classList.add('separator'); pillContainer.appendChild(separator); const rightImg = document.createElement('div'); + rightImg.classList.add('pill-img-container'); const rightImgIcon = document.createElement('img'); - rightImgIcon.src = chrome.runtime.getURL('extension/assets/rewrite.svg'); + rightImgIcon.src = chrome.runtime.getURL(`extension/assets/rewrite-${iconColor}.svg`); rightImgIcon.alt = 'Retry'; rightImgIcon.classList.add('icon'); rightImg.appendChild(rightImgIcon); @@ -78,6 +110,7 @@ const createPillContainer = (textBox) => { rightImg.addEventListener('mouseover', () => { rightTooltip.style.visibility = 'visible'; rightTooltip.style.opacity = '1'; + rightTooltip.classList.add(`tooltip-hover-${iconColor}`); }); rightImg.addEventListener('mouseout', () => { @@ -103,17 +136,69 @@ const createPillContainer = (textBox) => { rephraseText(textBox); } }); + + pillContainer.addEventListener('mouseleave', (event) => { + // Check if the mouse is moving back to the rephrase button + const buttonRect = rephraseButton ? rephraseButton.getBoundingClientRect() : null; + if (!buttonRect || + event.clientX < buttonRect.left || + event.clientX > buttonRect.right || + event.clientY < buttonRect.top || + event.clientY > buttonRect.bottom) { + pillContainer.remove(); + pillContainer = null; + if (isFetching && rephraseButton) { + img.src = chrome.runtime.getURL(`extension/assets/cross-light.svg`); + rephraseButton.style.display = 'flex'; + rephraseButton.style.justifyContent = 'center'; + rephraseButton.style.alignItems = 'center'; + rephraseButton.onClick = () => { + undoRephraseText(textBox, img); + } + } + else if (rephraseButton) { + rephraseButton.style.display = 'flex'; + rephraseButton.style.justifyContent = 'center'; + rephraseButton.style.alignItems = 'center'; + } + } + }); }; +const typeText = async (textBox, text, delay = 16) => { + let index = 0; + while (index < text.length) { + if (isCanceled) return; + if (textBox.tagName === 'INPUT' || textBox.tagName === 'TEXTAREA') { + text[index] == ' ' ? textBox.value += '\u00A0' : textBox.value += text[index]; + } else if (textBox.isContentEditable) { + text[index] == ' ' ? textBox.innerText += '\u00A0' : textBox.innerText += text[index]; + } + index++; + await new Promise(resolve => setTimeout(resolve, delay)); + } +} + const rephraseText = async (textBox, img) => { originalText = textBox.value || textBox.innerText; applyGradientAnimation(textBox); if (img) { - img.src = chrome.runtime.getURL('extension/assets/cross.svg'); + const iconColor = getIconColor(textBox); + img.src = chrome.runtime.getURL(`extension/assets/cross-light.svg`); img.alt = "stop" img.style.width = '20px'; img.style.height = '20px'; - } + const buttonContainer = img.parentElement; + + if (iconColor === 'light') { + buttonContainer.classList.remove('dark-shadow') + buttonContainer.classList.add('light-shadow') + } + else { + buttonContainer.classList.remove('light-shadow'); + buttonContainer.classList.add('dark-shadow'); + } + } isFetching = true; isCanceled = false; @@ -124,6 +209,17 @@ const rephraseText = async (textBox, img) => { return; } + // Clear the textBox before typing the new text + if (prevActiveElement.tagName === 'INPUT' || prevActiveElement.tagName === 'TEXTAREA') { + prevActiveElement.value = ''; + } else if (prevActiveElement.isContentEditable) { + prevActiveElement.innerText = ''; + } + + removeGradientColor(textBox); + // Type the rephrased text with a smooth effect + await typeText(prevActiveElement, response.rephrase); + isFetching = false; removeGradientColor(prevActiveElement); @@ -132,18 +228,25 @@ const rephraseText = async (textBox, img) => { rephraseButton = null; } showRephraseButton = false; - - if (prevActiveElement.tagName === 'INPUT' || prevActiveElement.tagName === 'TEXTAREA') { - prevActiveElement.value = response.rephrase; - } else if (prevActiveElement.isContentEditable) { - prevActiveElement.innerText = response.rephrase; - } - - createPillContainer(prevActiveElement); + hasRephrasedBefore = true; + + // Show pill for 3 seconds + createPillContainer(prevActiveElement, img); + setTimeout(() => { + if (pillContainer) { + pillContainer.remove(); + pillContainer = null; + } + showRephraseButton = true; + addButtonToTextBox(prevActiveElement); + }, 2000); } catch (error) { console.error('Failed to send message:', error); isFetching = false; - if (img) img.src = chrome.runtime.getURL('extension/assets/black-rephrase.svg'); + if (img) { + const iconColor = getIconColor(textBox); + img.src = chrome.runtime.getURL(`extension/assets/rephrase-${iconColor}.svg`); + } removeGradientColor(textBox); } finally { textBox.focus(); @@ -165,7 +268,10 @@ const undoRephraseText = (textBox, img) => { isFetching = false; isCanceled = true; removeGradientColor(textBox); - if (img) img.src = chrome.runtime.getURL('extension/assets/black-rephrase.svg'); + if (img) { + const iconColor = getIconColor(textBox); + img.src = chrome.runtime.getURL(`extension/assets/rephrase-${iconColor}.svg`); + } if (prevActiveElement) { if (prevActiveElement.tagName === 'INPUT' || prevActiveElement.tagName === 'TEXTAREA') { prevActiveElement.value = originalText; @@ -175,37 +281,103 @@ const undoRephraseText = (textBox, img) => { } } +const shouldShowRephraseButton = (text) => { + const words = text.trim().split(/\s+/); + return words.length >= 10; +}; + const addButtonToTextBox = (textBox) => { // Check if the input box is too small const rect = textBox.getBoundingClientRect(); - const minWidth = 500; - const minHeight = 40; + const minWidth = 600; + const minHeight = 50; if (rect.width < minWidth && rect.height < minHeight) { return; } + const text = textBox.value || textBox.innerText; + if (!shouldShowRephraseButton(text)) { + if (rephraseButton) { + rephraseButton.remove(); + rephraseButton = null; + } + return; + } if (rephraseButton) { rephraseButton.remove(); } const buttonContainer = document.createElement('div'); buttonContainer.classList.add('rephrase-button-container'); - + const iconColor = getIconColor(textBox); + if (iconColor === 'light') { + buttonContainer.classList.remove('dark-shadow') + buttonContainer.classList.add('light-shadow') + } + else { + buttonContainer.classList.remove('light-shadow'); + buttonContainer.classList.add('dark-shadow'); + } const img = document.createElement('img'); - img.src = chrome.runtime.getURL('extension/assets/black-rephrase.svg'); + img.src = chrome.runtime.getURL(`extension/assets/rephrase-${iconColor}.svg`); img.alt = 'Rephrase'; - img.style.width = '20px'; - img.style.height = '20px'; + img.style.width = '17px'; + img.style.height = '17px'; img.style.objectFit = 'contain'; buttonContainer.appendChild(img); + const showPill = () => { + if (hasRephrasedBefore) { + buttonContainer.style.display = 'none'; + createPillContainer(textBox, img); + } + }; + + const hidePill = () => { + if (pillContainer) { + pillContainer.remove(); + pillContainer = null; + } + buttonContainer.style.display = 'flex'; + buttonContainer.style.justifyContent = 'center'; + buttonContainer.style.alignItems = 'center'; + }; + + buttonContainer.addEventListener('mouseenter', () => { + if (!isFetching) { + if (hasRephrasedBefore) { + showPill(); + } else { + img.src = chrome.runtime.getURL(`extension/assets/rephrase-${iconColor}-hover.svg`); + } + } + }); + + buttonContainer.addEventListener('mouseleave', (event) => { + if (!isFetching) { + if (hasRephrasedBefore) { + // Check if the mouse is moving to the pill + const pillRect = pillContainer ? pillContainer.getBoundingClientRect() : null; + if (!pillRect || + event.clientX < pillRect.left || + event.clientX > pillRect.right || + event.clientY < pillRect.top || + event.clientY > pillRect.bottom) { + hidePill(); + } + } else { + img.src = chrome.runtime.getURL(`extension/assets/rephrase-${iconColor}.svg`); + } + } + }); + const containerHeight = img.style.height; const containerWidth = img.style.width; - buttonContainer.style.left = `${rect.right - parseInt(containerWidth) - 18 + window.scrollX}px`; + buttonContainer.style.left = `${rect.right - parseInt(containerWidth) - 32 + window.scrollX}px`; buttonContainer.style.top = `${rect.bottom - parseInt(containerHeight) - 20 + window.scrollY}px`; document.body.appendChild(buttonContainer); @@ -258,4 +430,11 @@ document.addEventListener('focusin', (event) => { } prevActiveElement = activeElement; } +}); + +document.addEventListener('input', (event) => { + const activeElement = event.target; + if (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA' || activeElement.isContentEditable) { + addButtonToTextBox(activeElement); + } }); \ No newline at end of file diff --git a/components/ping_ai_copilot/extension/content/ui/style.css b/components/ping_ai_copilot/extension/content/ui/style.css index 2434ee962b6a..2d79fd8f504e 100644 --- a/components/ping_ai_copilot/extension/content/ui/style.css +++ b/components/ping_ai_copilot/extension/content/ui/style.css @@ -10,14 +10,20 @@ align-items: center; justify-content: center; border-radius: 20px; - background-color: #000; - padding: 8px 14px; - box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.15); + padding: 7px 16px; + border-radius: 94.42px; + backdrop-filter: blur(16.56488609313965px); position: absolute; z-index: 10000000; transition: all 0.3s ease-in-out; } +.pill-img-container { + display: flex; + align-items: center; + justify-content: center; +} + .icon { width: 20px; height: 20px; @@ -27,7 +33,7 @@ } .separator { - color: #fff; + color: #000; margin: 0 8px; } @@ -35,7 +41,7 @@ position: absolute; background-color: #333; color: #fff; - padding: 5px 8px; + padding: 5.5px 8px; border-radius: 4px; font-size: 12px; white-space: nowrap; @@ -46,35 +52,61 @@ } .left-tooltip { - bottom: 105%; + bottom: 106%; left: 30%; transform: translateX(-50%); } .right-tooltip { - bottom: 105%; + bottom: 106%; left: 70%; transform: translateX(-50%); } +.tooltip-hover-light { + color: #000; + background-color: #fff; + box-shadow: 2px 4px 4px 0px rgba(0, 0, 0, 0.25); +} + +.tooltip-hover-dark { + color: #fff; + background-color: #000; + box-shadow: 2px 4px 4px 0px rgba(255, 255, 255, 0.25); +} + .rephrase-button-container { position: absolute; z-index: 10000000; cursor: pointer; - background-color: #FFF; - box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.15); - border-radius: 50%; - padding: 5px; - width: 34px; - height: 34px; + background-color: rgba(255, 255, 255, 0.10); + box-shadow: 6.16px 6.16px 14.784px rgba(0, 0, 0, 0.30); border-radius: 50%; + padding: 4.5px; + width: 27px; + height: 27px; display: flex; align-items: center; justify-content: center; transition: box-shadow 0.2s ease; } -.rephrase-button-container:hover { - box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.18); +.light-shadow { + background-color: rgba(255, 255, 255, 0.10); + box-shadow: 6.16px 6.16px 14.784px rgba(0, 0, 0, 0.30); border-radius: 50%; +} + +.dark-shadow { + background-color: rgba(0, 0, 0, 0.10); + box-shadow: 2px 2px 4.8px rgba(255, 255, 255, 0.30); border-radius: 50%; +} + +.pill-light-shadow { + background-color: rgba(255, 255, 255, 0.01); + box-shadow: 3.313px 4.969px 8.117px 0px rgba(0, 0, 0, 0.25); +} +.pill-dark-shadow { + background-color: #fff; + box-shadow: 3.313px 4.969px 8.117px 0px rgba(255, 255, 255, 0.25); } /* aiSummarizer */ diff --git a/components/ping_ai_copilot/extension/service_worker/background.js b/components/ping_ai_copilot/extension/service_worker/background.js index 5dc654d618f1..f64a51f142eb 100644 --- a/components/ping_ai_copilot/extension/service_worker/background.js +++ b/components/ping_ai_copilot/extension/service_worker/background.js @@ -35,21 +35,21 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { } if (request.action === 'rephrase') { (async () => { - try { - let ln = chrome.i18n.getUILanguage(); - const response = await fetch('https://openai-text-summarizer.azurewebsites.net/rephrase', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ text: request.text, lang: ln }), - }); + try { + let ln = chrome.i18n.getUILanguage(); + const response = await fetch('https://openai-text-summarizer.azurewebsites.net/rephrase', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ text: request.text, lang: ln }), + }); - const data = await response.json(); - sendResponse({rephrase: data.rText}) - } catch (error) { - sendResponse({rephrase: "An error occurred while rephrasing the text"}) - } + const data = await response.json(); + sendResponse({ rephrase: data.rText }) + } catch (error) { + sendResponse({ rephrase: "An error occurred while rephrasing the text" }) + } })(); return true; } diff --git a/components/ping_ai_copilot/resources.grd b/components/ping_ai_copilot/resources.grd index ba9d8a977cbd..ea25aac9d62d 100644 --- a/components/ping_ai_copilot/resources.grd +++ b/components/ping_ai_copilot/resources.grd @@ -14,11 +14,15 @@ - - - - - + + + + + + + + + \ No newline at end of file From 822ab70513c18a5f9b19959665d6a7124621773c Mon Sep 17 00:00:00 2001 From: nikhil7174 Date: Fri, 20 Sep 2024 05:13:45 +0530 Subject: [PATCH 8/8] resolved all issues regarding rephraser --- .../content/content_scripts/rephraser.js | 32 +++---------------- .../extension/content/ui/style.css | 5 +++ 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/components/ping_ai_copilot/extension/content/content_scripts/rephraser.js b/components/ping_ai_copilot/extension/content/content_scripts/rephraser.js index 54917cb70735..d95d8e2d61eb 100644 --- a/components/ping_ai_copilot/extension/content/content_scripts/rephraser.js +++ b/components/ping_ai_copilot/extension/content/content_scripts/rephraser.js @@ -72,21 +72,10 @@ const createPillContainer = (textBox, img) => { const leftTooltip = document.createElement('span'); leftTooltip.textContent = 'Back'; - leftTooltip.classList.add('tooltip', 'left-tooltip'); + leftTooltip.classList.add('tooltip', 'left-tooltip', `tooltip-hover-${iconColor}`); leftImg.appendChild(leftTooltip); pillContainer.appendChild(leftImg); - leftImg.addEventListener('mouseover', () => { - leftTooltip.style.visibility = 'visible'; - leftTooltip.style.opacity = '1'; - leftTooltip.classList.add(`tooltip-hover-${iconColor}`); - }); - - leftImg.addEventListener('mouseout', () => { - leftTooltip.style.visibility = 'hidden'; - leftTooltip.style.opacity = '0'; - }); - const separator = document.createElement('span'); separator.textContent = '|'; separator.style.color = iconColor === 'light' ? 'black' : 'white'; @@ -103,27 +92,16 @@ const createPillContainer = (textBox, img) => { const rightTooltip = document.createElement('span'); rightTooltip.textContent = 'Retry'; - rightTooltip.classList.add('tooltip', 'right-tooltip'); + rightTooltip.classList.add('tooltip', 'right-tooltip', `tooltip-hover-${iconColor}`); rightImg.appendChild(rightTooltip); pillContainer.appendChild(rightImg); - rightImg.addEventListener('mouseover', () => { - rightTooltip.style.visibility = 'visible'; - rightTooltip.style.opacity = '1'; - rightTooltip.classList.add(`tooltip-hover-${iconColor}`); - }); - - rightImg.addEventListener('mouseout', () => { - rightTooltip.style.visibility = 'hidden'; - rightTooltip.style.opacity = '0'; - }); - document.body.appendChild(pillContainer); // Adjust position based on scroll offsets const rect = textBox.getBoundingClientRect(); pillContainer.style.left = `${rect.right - pillContainer.offsetWidth - 5 + window.scrollX}px`; - pillContainer.style.top = `${rect.bottom - pillContainer.offsetHeight - 5 + window.scrollY}px`; + pillContainer.style.top = `${rect.bottom - pillContainer.offsetHeight + window.scrollY}px`; leftImgIcon.addEventListener('click', () => { if (prevActiveElement) { @@ -377,8 +355,8 @@ const addButtonToTextBox = (textBox) => { const containerHeight = img.style.height; const containerWidth = img.style.width; - buttonContainer.style.left = `${rect.right - parseInt(containerWidth) - 32 + window.scrollX}px`; - buttonContainer.style.top = `${rect.bottom - parseInt(containerHeight) - 20 + window.scrollY}px`; + buttonContainer.style.left = `${rect.right - parseInt(containerWidth) - 30 + window.scrollX}px`; + buttonContainer.style.top = `${rect.bottom - parseInt(containerHeight) - 10 + window.scrollY}px`; document.body.appendChild(buttonContainer); diff --git a/components/ping_ai_copilot/extension/content/ui/style.css b/components/ping_ai_copilot/extension/content/ui/style.css index 2d79fd8f504e..df082315d3d7 100644 --- a/components/ping_ai_copilot/extension/content/ui/style.css +++ b/components/ping_ai_copilot/extension/content/ui/style.css @@ -24,6 +24,11 @@ justify-content: center; } +.pill-img-container:hover .tooltip { + visibility: visible; + opacity: 1; +} + .icon { width: 20px; height: 20px;