Skip to content

Commit

Permalink
Add animations for open yt in brave dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
deeppandya committed Nov 15, 2024
1 parent b2c75f6 commit dcfec64
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 16 deletions.
2 changes: 2 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ if (is_android) {
android_assets("brave_file_assets") {
sources = [
"//brave/LICENSE.html",
"//brave/android/java/org/chromium/chrome/browser/lottie_animations/moving_ads_dark.json",
"//brave/android/java/org/chromium/chrome/browser/lottie_animations/moving_ads_light.json",
"//brave/android/java/org/chromium/chrome/browser/ntp/ntp_news_optin_icon_animation.json",
"//brave/android/java/org/chromium/chrome/browser/onboarding/animations/onboarding_ads.json",
"//brave/android/java/org/chromium/chrome/browser/onboarding/animations/onboarding_ads_notification.json",
Expand Down
1 change: 0 additions & 1 deletion android/brave_java_resources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ brave_java_resources = [
"java/res/drawable-nodpi/eth.png",
"java/res/drawable-nodpi/ic_quick_action_search_and_bookmark_widget_preview.png",
"java/res/drawable-nodpi/loader0_orange.png",
"java/res/drawable-nodpi/open_yt_in_brave.png",
"java/res/drawable-sw600dp/bottomsheet_rewards_tipping_success_background.xml",
"java/res/drawable-xhdpi/brave_ads_launch_graphic.png",
"java/res/drawable-xhdpi/brave_sync_btn_laptop.png",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
HostUrl=https://files.slack.com/files-pri/T04PX1BU8-F07UYK9A807/download/en_movingads__darkmode.json?origin_team=T04PX1BU8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
HostUrl=https://files.slack.com/files-pri/T04PX1BU8-F0801LMPMRS/download/en_movingads__lightmode.json?origin_team=T04PX1BU8
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Copyright (c) 2024 The Brave Authors. All rights reserved. This Source Code Form is subject to
* the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
* this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
/* Copyright (c) 2024 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at https://mozilla.org/MPL/2.0/. */

package org.chromium.chrome.browser;

import android.os.Bundle;
Expand All @@ -12,13 +12,19 @@
import android.widget.Button;
import android.widget.TextView;

import com.airbnb.lottie.LottieAnimationView;

import org.chromium.chrome.R;
import org.chromium.chrome.browser.night_mode.GlobalNightModeStateProviderHolder;
import org.chromium.chrome.browser.preferences.BravePrefServiceBridge;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.content_public.browser.LoadUrlParams;

public class OpenYtInBraveDialogFragment extends BraveDialogFragment
implements View.OnClickListener {

public static final String YOUTUBE_URL = "https://youtube.com";

@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Expand All @@ -32,6 +38,14 @@ public void onViewCreated(View view, Bundle savedInstanceState) {

TextView mIgnoreButton = view.findViewById(R.id.btn_ignore);
mIgnoreButton.setOnClickListener(this);

LottieAnimationView mAnimatedView = view.findViewById(R.id.animation_view);
String animationFile =
GlobalNightModeStateProviderHolder.getInstance().isInNightMode()
? "moving_ads_dark.json"
: "moving_ads_light.json";
mAnimatedView.setAnimation(animationFile);
mAnimatedView.playAnimation();
}

@Override
Expand All @@ -40,7 +54,7 @@ public void onClick(View view) {
BravePrefServiceBridge.getInstance().setPlayYTVideoInBrowserEnabled(true);
Tab activityTab = BraveRewardsHelper.currentActiveChromeTabbedActivityTab();
if (activityTab != null) {
LoadUrlParams loadUrlParams = new LoadUrlParams("https://youtube.com");
LoadUrlParams loadUrlParams = new LoadUrlParams(YOUTUBE_URL);
activityTab.loadUrl(loadUrlParams);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1278,11 +1278,12 @@ && getActivityTab().getUrl().getSpec() != null
}

if (!isFirstInstall
&& !BravePrefServiceBridge.getInstance().getPlayYTVideoInBrowserEnabled() && ChromeSharedPreferences.getInstance()
&& !BravePrefServiceBridge.getInstance().getPlayYTVideoInBrowserEnabled()
&& ChromeSharedPreferences.getInstance()
.readBoolean(BravePreferenceKeys.OPEN_YT_IN_BRAVE_DIALOG, true)) {
openYtInBraveDialog();
ChromeSharedPreferences.getInstance()
.writeBoolean(BravePreferenceKeys.OPEN_YT_IN_BRAVE_DIALOG, false);
.writeBoolean(BravePreferenceKeys.OPEN_YT_IN_BRAVE_DIALOG, false);
}

new KeyboardVisibilityHelper(BraveActivity.this, BraveActivity.this);
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Binary file removed android/java/res/drawable-nodpi/open_yt_in_brave.png
Binary file not shown.
15 changes: 8 additions & 7 deletions android/java/res/layout/fragment_open_yt_in_brave_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="32dp"
android:paddingBottom="16dp"
android:paddingHorizontal="24dp"
android:orientation="vertical">

<ImageView
android:layout_width="130dp"
android:layout_height="92dp"
android:gravity="center_horizontal"
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/animation_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:contentDescription="@null"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="16dp"
android:src="@drawable/open_yt_in_brave"
android:contentDescription="@null"/>
app:lottie_loop="true" />

<TextView
android:layout_width="match_parent"
Expand Down

0 comments on commit dcfec64

Please sign in to comment.