Skip to content

Commit

Permalink
Merge pull request #27239 from brave/remove_lion_animation_onboarding
Browse files Browse the repository at this point in the history
Remove lion animation onboarding
  • Loading branch information
deeppandya authored Jan 16, 2025
2 parents 20cf651 + fe7033f commit add5e19
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@

import static org.chromium.ui.base.ViewUtils.dpToPx;

import android.Manifest;
import android.animation.LayoutTransition;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.RemoteException;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -35,15 +32,13 @@
import com.android.installreferrer.api.InstallReferrerStateListener;
import com.android.installreferrer.api.ReferrerDetails;

import org.chromium.base.BraveFeatureList;
import org.chromium.base.BravePreferenceKeys;
import org.chromium.base.Log;
import org.chromium.base.ThreadUtils;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.BraveLocalState;
import org.chromium.chrome.browser.back_press.SecondaryActivityBackPressUma.SecondaryActivity;
import org.chromium.chrome.browser.customtabs.CustomTabActivity;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.metrics.ChangeMetricsReportingStateCalledFrom;
import org.chromium.chrome.browser.metrics.UmaSessionStats;
import org.chromium.chrome.browser.onboarding.OnboardingPrefManager;
Expand All @@ -60,18 +55,23 @@
import java.util.Locale;

/**
* This is on boarding activity
* */
* Activity that handles the first run onboarding experience for new Brave browser installations.
* Extends FirstRunActivityBase to provide onboarding flows for: - Setting Brave as default browser
* - Configuring privacy and analytics preferences (P3A and crash reporting) - Accepting terms of
* service The activity guides users through a series of steps using animations and clear UI
* elements to explain Brave's key features and privacy-focused approach.
*/
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";

private static final String TAG = "WelcomeOnboarding";

// mInitializeViewsDone and mInvokePostWorkAtInitializeViews are accessed
// from the same thread, so no need to use extra locks
private boolean mInitializeViewsDone;
private boolean mInvokePostWorkAtInitializeViews;

private boolean mIsTablet;
private BraveFirstRunFlowSequencer mFirstRunFlowSequencer;
private int mCurrentStep = -1;
Expand All @@ -83,29 +83,37 @@ public class WelcomeOnboardingActivity extends FirstRunActivityBase {
private ImageView mIvBrave;
private ImageView mIvArrowDown;
private LinearLayout mLayoutCard;
private TextView mTvWelcome;
private TextView mTvCard;
private TextView mTvDefault;
private Button mBtnPositive;
private Button mBtnNegative;
private CheckBox mCheckboxCrash;
private CheckBox mCheckboxP3a;

/**
* Initializes the views and sets up the onboarding activity UI. This method handles the initial
* setup of the welcome onboarding screen, including loading the layout, initializing views and
* click listeners, and performing first-run setup tasks.
*/
private void initializeViews() {
assert !mInitializeViewsDone;

setContentView(R.layout.activity_welcome_onboarding);

mIsTablet = DeviceFormFactor.isNonMultiDisplayContextOnTablet(this);

initViews();

onClickViews();

mInitializeViewsDone = true;

if (mInvokePostWorkAtInitializeViews) {
finishNativeInitializationPostWork();
}

checkReferral();

maybeUpdateFirstRunDefaultValues();
}

Expand Down Expand Up @@ -166,7 +174,6 @@ private void initViews() {
mIvBrave = findViewById(R.id.iv_brave);
mIvArrowDown = findViewById(R.id.iv_arrow_down);
mLayoutCard = findViewById(R.id.layout_card);
mTvWelcome = findViewById(R.id.tv_welcome);
mTvCard = findViewById(R.id.tv_card);
mTvDefault = findViewById(R.id.tv_default);
mCheckboxCrash = findViewById(R.id.checkbox_crash);
Expand Down Expand Up @@ -211,7 +218,7 @@ private void onClickViews() {
if (mBtnPositive != null) {
mBtnPositive.setOnClickListener(
view -> {
if (mCurrentStep == 1 && !isDefaultBrowser()) {
if (mCurrentStep == 0 && !isDefaultBrowser()) {
setDefaultBrowserAndProceedToNextStep();
} else {
nextOnboardingStep();
Expand All @@ -232,11 +239,7 @@ private void onClickViews() {
}

private boolean shouldForceDefaultBrowserPrompt() {
return isNewOnboardingEnabled() && !isDefaultBrowser();
}

private boolean isNewOnboardingEnabled() {
return ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_NEW_ANDROID_ONBOARDING);
return !isDefaultBrowser();
}

private void setDefaultBrowserAndProceedToNextStep() {
Expand All @@ -251,82 +254,46 @@ private boolean isDefaultBrowser() {
return BraveSetDefaultBrowserUtils.isBraveSetAsDefaultBrowser(this);
}

private void startTimer(int delayMillis) {
new Handler().postDelayed(this::nextOnboardingStep, delayMillis);
}

ActivityResultLauncher<String> mRequestPermissionLauncher = registerForActivityResult(
new ActivityResultContracts.RequestPermission(), isGranted -> { startTimer(3000); });
ActivityResultLauncher<String> mRequestPermissionLauncher =
registerForActivityResult(
new ActivityResultContracts.RequestPermission(),
isGranted -> {
nextOnboardingStep();
});

private void nextOnboardingStep() {
if (isActivityFinishingOrDestroyed()) return;

mCurrentStep++;
if (mCurrentStep == 0) {
showIntroPage();
} else if (mCurrentStep == 1) {
if (!isNewOnboardingEnabled()
|| !BraveSetDefaultBrowserUtils.supportsDefaultRoleManager()) {
if (!BraveSetDefaultBrowserUtils.supportsDefaultRoleManager()) {
mIvBrave.setVisibility(View.VISIBLE);
showBrowserSelectionPage();
} else if (!isDefaultBrowser()) {
setDefaultBrowserAndProceedToNextStep();
} else {
nextOnboardingStep();
}
} else if (mCurrentStep == getAnalyticsConsentPageStep()) {
mIvBrave.setVisibility(View.VISIBLE);
showAnalyticsConsentPage();
} else {
OnboardingPrefManager.getInstance().setP3aOnboardingShown(true);
OnboardingPrefManager.getInstance().setOnboardingSearchBoxTooltip(true);

FirstRunStatus.setFirstRunFlowComplete(true);

ChromeSharedPreferences.getInstance()
.writeBoolean(ChromePreferenceKeys.FIRST_RUN_CACHED_TOS_ACCEPTED, true);
FirstRunUtils.setEulaAccepted();

finish();
sendFirstRunCompletePendingIntent();
}
}

private int getAnalyticsConsentPageStep() {
return 2;
}

private void showIntroPage() {
int margin = mIsTablet ? 100 : 0;
setLeafAnimation(mVLeafAlignTop, mIvLeafTop, 1f, margin, true);
setLeafAnimation(mVLeafAlignBottom, mIvLeafBottom, 1f, margin, false);
if (mTvWelcome != null) {
mTvWelcome
.animate()
.alpha(1f)
.setDuration(200)
.withEndAction(() -> mTvWelcome.setVisibility(View.VISIBLE));
}
if (mIvBrave != null) {
mIvBrave.animate().scaleX(0.8f).scaleY(0.8f).setDuration(1000);
}
new Handler()
.postDelayed(
new Runnable() {
@Override
public void run() {
if (mTvWelcome != null) {
mTvWelcome
.animate()
.translationYBy(
-dpToPx(WelcomeOnboardingActivity.this, 20))
.setDuration(3000)
.start();
}
}
},
200);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && !isNewOnboardingEnabled()) {
mRequestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS);
} else {
startTimer(3000);
}
return 1;
}

private void showBrowserSelectionPage() {
Expand All @@ -342,9 +309,6 @@ private void showBrowserSelectionPage() {
mBtnNegative.setVisibility(View.GONE);
}
}
if (mTvWelcome != null) {
mTvWelcome.setVisibility(View.GONE);
}
if (mLayoutCard != null) {
mLayoutCard.setVisibility(View.VISIBLE);
}
Expand Down Expand Up @@ -388,24 +352,30 @@ private void showAnalyticsConsentPage() {
mBtnNegative.setVisibility(View.VISIBLE);
}

// Handle crash reporting consent based on installation status
if (PackageUtils.isFirstInstall(this)
&& !OnboardingPrefManager.getInstance().isP3aCrashReportingMessageShown()) {
// For first time installs, enable crash reporting by default
if (mCheckboxCrash != null) {
mCheckboxCrash.setChecked(true);
}
// Update metrics reporting consent
UmaSessionStats.changeMetricsReportingConsent(
true, ChangeMetricsReportingStateCalledFrom.UI_FIRST_RUN);
// Mark crash reporting message as shown
OnboardingPrefManager.getInstance().setP3aCrashReportingMessageShown(true);
} else {
// For existing installations, restore previous crash reporting preference
boolean isCrashReporting = false;
try {
// Get current crash reporting permission status
isCrashReporting =
PrivacyPreferencesManagerImpl.getInstance()
.isUsageAndCrashReportingPermittedByUser();

} catch (Exception e) {
Log.e(TAG, "isCrashReportingOnboarding: " + e.getMessage());
}
// Update checkbox to match current preference
if (mCheckboxCrash != null) {
mCheckboxCrash.setChecked(isCrashReporting);
}
Expand Down Expand Up @@ -525,7 +495,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {

private void finishNativeInitializationPostWork() {
assert mInitializeViewsDone;
startTimer(1000);
nextOnboardingStep();
}

@Override
Expand Down
12 changes: 1 addition & 11 deletions android/java/res/layout/activity_welcome_onboarding.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,6 @@
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">

<TextView
android:id="@+id/tv_welcome"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="24sp"
android:alpha="0"
android:visibility="gone"
android:textColor="@color/onboarding_welcome_text_color"
android:text="@string/welcome_to_brave"/>

<LinearLayout
android:id="@+id/layout_card"
Expand Down Expand Up @@ -182,6 +171,7 @@
android:adjustViewBounds="true"
android:layout_gravity="center_horizontal"
android:contentDescription="@null"
android:visibility="gone"
android:src="@drawable/ic_brave_onboarding"/>

</LinearLayout>
Expand Down
3 changes: 0 additions & 3 deletions browser/ui/android/strings/android_brave_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -881,9 +881,6 @@ This file contains all "about" strings. It is set to NOT be translated, in tran
</message>

<!-- Onboarding strings -->
<message name="IDS_WELCOME_TO_BRAVE" desc="Text for welcome onboarding">
Welcome to Brave
</message>
<message name="IDS_PRIVACY_ONBOARDING" desc="Text for privacy onboarding">
Privacy. Made simple.
</message>
Expand Down

0 comments on commit add5e19

Please sign in to comment.