Skip to content

Commit ace8e8b

Browse files
committed
Remove Brave logo for > android 9 devices and update existing chnages
Refactor the changes and add comments
1 parent 8c23d4e commit ace8e8b

File tree

3 files changed

+72
-68
lines changed

3 files changed

+72
-68
lines changed

android/java/org/chromium/chrome/browser/firstrun/WelcomeOnboardingActivity.java

+71-54
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,25 @@
5656
import java.util.Locale;
5757

5858
/**
59-
* This is on boarding activity
60-
* */
59+
* Activity that handles the first run onboarding experience for new Brave browser installations.
60+
* Extends FirstRunActivityBase to provide onboarding flows for:
61+
* - Setting Brave as default browser
62+
* - Configuring privacy and analytics preferences (P3A and crash reporting)
63+
* - Accepting terms of service
64+
* The activity guides users through a series of steps using animations and clear UI elements
65+
* to explain Brave's key features and privacy-focused approach.
66+
*/
6167
public class WelcomeOnboardingActivity extends FirstRunActivityBase {
62-
// mInitializeViewsDone and mInvokePostWorkAtInitializeViews are accessed
63-
// from the same thread, so no need to use extra locks
6468
private static final String P3A_URL =
6569
"https://support.brave.com/hc/en-us/articles/9140465918093-What-is-P3A-in-Brave";
6670

6771
private static final String TAG = "WelcomeOnboarding";
6872

73+
// mInitializeViewsDone and mInvokePostWorkAtInitializeViews are accessed
74+
// from the same thread, so no need to use extra locks
6975
private boolean mInitializeViewsDone;
7076
private boolean mInvokePostWorkAtInitializeViews;
77+
7178
private boolean mIsTablet;
7279
private BraveFirstRunFlowSequencer mFirstRunFlowSequencer;
7380
private int mCurrentStep = -1;
@@ -79,29 +86,47 @@ public class WelcomeOnboardingActivity extends FirstRunActivityBase {
7986
private ImageView mIvBrave;
8087
private ImageView mIvArrowDown;
8188
private LinearLayout mLayoutCard;
82-
private TextView mTvWelcome;
8389
private TextView mTvCard;
8490
private TextView mTvDefault;
8591
private Button mBtnPositive;
8692
private Button mBtnNegative;
8793
private CheckBox mCheckboxCrash;
8894
private CheckBox mCheckboxP3a;
8995

96+
/**
97+
* Initializes the views and sets up the onboarding activity UI.
98+
* This method handles the initial setup of the welcome onboarding screen,
99+
* including loading the layout, initializing views and click listeners,
100+
* and performing first-run setup tasks.
101+
*/
90102
private void initializeViews() {
103+
// Verify initialization hasn't happened yet
91104
assert !mInitializeViewsDone;
105+
106+
// Set the content view to the welcome onboarding layout
92107
setContentView(R.layout.activity_welcome_onboarding);
93108

109+
// Check if device is a tablet for layout adjustments
94110
mIsTablet = DeviceFormFactor.isNonMultiDisplayContextOnTablet(this);
95111

112+
// Initialize view references and setup
96113
initViews();
114+
115+
// Setup click listeners for interactive elements
97116
onClickViews();
98117

118+
// Mark initialization as complete
99119
mInitializeViewsDone = true;
120+
121+
// If post-initialization work was queued, execute it now
100122
if (mInvokePostWorkAtInitializeViews) {
101123
finishNativeInitializationPostWork();
102124
}
103125

126+
// Check install referral data
104127
checkReferral();
128+
129+
// Update any first run default values if needed
105130
maybeUpdateFirstRunDefaultValues();
106131
}
107132

@@ -162,7 +187,6 @@ private void initViews() {
162187
mIvBrave = findViewById(R.id.iv_brave);
163188
mIvArrowDown = findViewById(R.id.iv_arrow_down);
164189
mLayoutCard = findViewById(R.id.layout_card);
165-
mTvWelcome = findViewById(R.id.tv_welcome);
166190
mTvCard = findViewById(R.id.tv_card);
167191
mTvDefault = findViewById(R.id.tv_default);
168192
mCheckboxCrash = findViewById(R.id.checkbox_crash);
@@ -207,9 +231,12 @@ private void onClickViews() {
207231
if (mBtnPositive != null) {
208232
mBtnPositive.setOnClickListener(
209233
view -> {
210-
if (mCurrentStep == 1 && !isDefaultBrowser()) {
234+
// If this is the first step and Brave is not set as default browser
235+
if (mCurrentStep == 0 && !isDefaultBrowser()) {
236+
// Show default browser prompt and proceed to next step
211237
setDefaultBrowserAndProceedToNextStep();
212238
} else {
239+
// Otherwise just proceed to next onboarding step
213240
nextOnboardingStep();
214241
}
215242
});
@@ -218,9 +245,13 @@ private void onClickViews() {
218245
if (mBtnNegative != null) {
219246
mBtnNegative.setOnClickListener(
220247
view -> {
248+
// If we're on the analytics consent page, show the P3A info page
249+
// Otherwise proceed to next onboarding step
221250
if (mCurrentStep == getAnalyticsConsentPageStep()) {
251+
// Open P3A info page in a custom tab
222252
CustomTabActivity.showInfoPage(this, P3A_URL);
223253
} else {
254+
// Move to next onboarding step
224255
nextOnboardingStep();
225256
}
226257
});
@@ -254,66 +285,49 @@ private void nextOnboardingStep() {
254285
if (isActivityFinishingOrDestroyed()) return;
255286

256287
mCurrentStep++;
288+
// Step 0: Handle default browser setup
257289
if (mCurrentStep == 0) {
258-
showIntroPage();
259-
} else if (mCurrentStep == 1) {
290+
// For devices that don't support role manager API, show browser selection page
260291
if (!BraveSetDefaultBrowserUtils.supportsDefaultRoleManager()) {
292+
mIvBrave.setVisibility(View.VISIBLE);
261293
showBrowserSelectionPage();
262-
} else if (!isDefaultBrowser()) {
294+
}
295+
// If Brave is not default browser, trigger default browser prompt
296+
else if (!isDefaultBrowser()) {
263297
setDefaultBrowserAndProceedToNextStep();
264-
} else {
298+
}
299+
// If already default browser, proceed to next step
300+
else {
265301
nextOnboardingStep();
266302
}
267-
} else if (mCurrentStep == getAnalyticsConsentPageStep()) {
303+
}
304+
// Step 1: Show analytics consent page
305+
else if (mCurrentStep == getAnalyticsConsentPageStep()) {
306+
mIvBrave.setVisibility(View.VISIBLE);
268307
showAnalyticsConsentPage();
269-
} else {
308+
}
309+
// Final step: Complete onboarding
310+
else {
311+
// Set onboarding preferences
270312
OnboardingPrefManager.getInstance().setP3aOnboardingShown(true);
271313
OnboardingPrefManager.getInstance().setOnboardingSearchBoxTooltip(true);
314+
315+
// Mark first run flow as complete
272316
FirstRunStatus.setFirstRunFlowComplete(true);
317+
318+
// Accept terms of service and EULA
273319
ChromeSharedPreferences.getInstance()
274320
.writeBoolean(ChromePreferenceKeys.FIRST_RUN_CACHED_TOS_ACCEPTED, true);
275321
FirstRunUtils.setEulaAccepted();
322+
323+
// Finish activity and notify completion
276324
finish();
277325
sendFirstRunCompletePendingIntent();
278326
}
279327
}
280328

281329
private int getAnalyticsConsentPageStep() {
282-
return 2;
283-
}
284-
285-
private void showIntroPage() {
286-
int margin = mIsTablet ? 100 : 0;
287-
setLeafAnimation(mVLeafAlignTop, mIvLeafTop, 1f, margin, true);
288-
setLeafAnimation(mVLeafAlignBottom, mIvLeafBottom, 1f, margin, false);
289-
if (mTvWelcome != null) {
290-
mTvWelcome
291-
.animate()
292-
.alpha(1f)
293-
.setDuration(200)
294-
.withEndAction(() -> mTvWelcome.setVisibility(View.VISIBLE));
295-
}
296-
if (mIvBrave != null) {
297-
mIvBrave.animate().scaleX(0.8f).scaleY(0.8f).setDuration(1000);
298-
}
299-
new Handler()
300-
.postDelayed(
301-
new Runnable() {
302-
@Override
303-
public void run() {
304-
if (mTvWelcome != null) {
305-
mTvWelcome
306-
.animate()
307-
.translationYBy(
308-
-dpToPx(WelcomeOnboardingActivity.this, 20))
309-
.setDuration(3000)
310-
.start();
311-
}
312-
}
313-
},
314-
200);
315-
316-
nextOnboardingStep();
330+
return 1;
317331
}
318332

319333
private void showBrowserSelectionPage() {
@@ -329,9 +343,6 @@ private void showBrowserSelectionPage() {
329343
mBtnNegative.setVisibility(View.GONE);
330344
}
331345
}
332-
if (mTvWelcome != null) {
333-
mTvWelcome.setVisibility(View.GONE);
334-
}
335346
if (mLayoutCard != null) {
336347
mLayoutCard.setVisibility(View.VISIBLE);
337348
}
@@ -375,24 +386,30 @@ private void showAnalyticsConsentPage() {
375386
mBtnNegative.setVisibility(View.VISIBLE);
376387
}
377388

378-
if (PackageUtils.isFirstInstall(this)
389+
// Handle crash reporting consent based on installation status
390+
if (PackageUtils.isFirstInstall(this)
379391
&& !OnboardingPrefManager.getInstance().isP3aCrashReportingMessageShown()) {
392+
// For first time installs, enable crash reporting by default
380393
if (mCheckboxCrash != null) {
381394
mCheckboxCrash.setChecked(true);
382395
}
396+
// Update metrics reporting consent
383397
UmaSessionStats.changeMetricsReportingConsent(
384398
true, ChangeMetricsReportingStateCalledFrom.UI_FIRST_RUN);
399+
// Mark crash reporting message as shown
385400
OnboardingPrefManager.getInstance().setP3aCrashReportingMessageShown(true);
386401
} else {
402+
// For existing installations, restore previous crash reporting preference
387403
boolean isCrashReporting = false;
388404
try {
389-
isCrashReporting =
405+
// Get current crash reporting permission status
406+
isCrashReporting =
390407
PrivacyPreferencesManagerImpl.getInstance()
391408
.isUsageAndCrashReportingPermittedByUser();
392-
393409
} catch (Exception e) {
394410
Log.e(TAG, "isCrashReportingOnboarding: " + e.getMessage());
395411
}
412+
// Update checkbox to match current preference
396413
if (mCheckboxCrash != null) {
397414
mCheckboxCrash.setChecked(isCrashReporting);
398415
}

android/java/res/layout/activity_welcome_onboarding.xml

+1-11
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,6 @@
6767
android:layout_height="wrap_content"
6868
android:gravity="center"
6969
android:orientation="vertical">
70-
71-
<TextView
72-
android:id="@+id/tv_welcome"
73-
android:layout_width="match_parent"
74-
android:layout_height="wrap_content"
75-
android:gravity="center"
76-
android:textSize="24sp"
77-
android:alpha="0"
78-
android:visibility="gone"
79-
android:textColor="@color/onboarding_welcome_text_color"
80-
android:text="@string/welcome_to_brave"/>
8170

8271
<LinearLayout
8372
android:id="@+id/layout_card"
@@ -182,6 +171,7 @@
182171
android:adjustViewBounds="true"
183172
android:layout_gravity="center_horizontal"
184173
android:contentDescription="@null"
174+
android:visibility="gone"
185175
android:src="@drawable/ic_brave_onboarding"/>
186176

187177
</LinearLayout>

browser/ui/android/strings/android_brave_strings.grd

-3
Original file line numberDiff line numberDiff line change
@@ -881,9 +881,6 @@ This file contains all "about" strings. It is set to NOT be translated, in tran
881881
</message>
882882

883883
<!-- Onboarding strings -->
884-
<message name="IDS_WELCOME_TO_BRAVE" desc="Text for welcome onboarding">
885-
Welcome to Brave
886-
</message>
887884
<message name="IDS_PRIVACY_ONBOARDING" desc="Text for privacy onboarding">
888885
Privacy. Made simple.
889886
</message>

0 commit comments

Comments
 (0)