Skip to content

Commit 3dde926

Browse files
committed
Remove Brave logo for > android 9 devices and update existing chnages
Refactor the changes and add comments Improve formatting
1 parent 899d621 commit 3dde926

File tree

3 files changed

+67
-67
lines changed

3 files changed

+67
-67
lines changed

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

+66-53
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import android.animation.LayoutTransition;
1313
import android.content.Intent;
1414
import android.os.Bundle;
15-
import android.os.Handler;
1615
import android.os.RemoteException;
1716
import android.view.View;
1817
import android.view.ViewGroup;
@@ -56,18 +55,23 @@
5655
import java.util.Locale;
5756

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

6768
private static final String TAG = "WelcomeOnboarding";
6869

70+
// mInitializeViewsDone and mInvokePostWorkAtInitializeViews are accessed
71+
// from the same thread, so no need to use extra locks
6972
private boolean mInitializeViewsDone;
7073
private boolean mInvokePostWorkAtInitializeViews;
74+
7175
private boolean mIsTablet;
7276
private BraveFirstRunFlowSequencer mFirstRunFlowSequencer;
7377
private int mCurrentStep = -1;
@@ -79,29 +83,46 @@ public class WelcomeOnboardingActivity extends FirstRunActivityBase {
7983
private ImageView mIvBrave;
8084
private ImageView mIvArrowDown;
8185
private LinearLayout mLayoutCard;
82-
private TextView mTvWelcome;
8386
private TextView mTvCard;
8487
private TextView mTvDefault;
8588
private Button mBtnPositive;
8689
private Button mBtnNegative;
8790
private CheckBox mCheckboxCrash;
8891
private CheckBox mCheckboxP3a;
8992

93+
/**
94+
* Initializes the views and sets up the onboarding activity UI. This method handles the initial
95+
* setup of the welcome onboarding screen, including loading the layout, initializing views and
96+
* click listeners, and performing first-run setup tasks.
97+
*/
9098
private void initializeViews() {
99+
// Verify initialization hasn't happened yet
91100
assert !mInitializeViewsDone;
101+
102+
// Set the content view to the welcome onboarding layout
92103
setContentView(R.layout.activity_welcome_onboarding);
93104

105+
// Check if device is a tablet for layout adjustments
94106
mIsTablet = DeviceFormFactor.isNonMultiDisplayContextOnTablet(this);
95107

108+
// Initialize view references and setup
96109
initViews();
110+
111+
// Setup click listeners for interactive elements
97112
onClickViews();
98113

114+
// Mark initialization as complete
99115
mInitializeViewsDone = true;
116+
117+
// If post-initialization work was queued, execute it now
100118
if (mInvokePostWorkAtInitializeViews) {
101119
finishNativeInitializationPostWork();
102120
}
103121

122+
// Check install referral data
104123
checkReferral();
124+
125+
// Update any first run default values if needed
105126
maybeUpdateFirstRunDefaultValues();
106127
}
107128

@@ -162,7 +183,6 @@ private void initViews() {
162183
mIvBrave = findViewById(R.id.iv_brave);
163184
mIvArrowDown = findViewById(R.id.iv_arrow_down);
164185
mLayoutCard = findViewById(R.id.layout_card);
165-
mTvWelcome = findViewById(R.id.tv_welcome);
166186
mTvCard = findViewById(R.id.tv_card);
167187
mTvDefault = findViewById(R.id.tv_default);
168188
mCheckboxCrash = findViewById(R.id.checkbox_crash);
@@ -207,9 +227,12 @@ private void onClickViews() {
207227
if (mBtnPositive != null) {
208228
mBtnPositive.setOnClickListener(
209229
view -> {
210-
if (mCurrentStep == 1 && !isDefaultBrowser()) {
230+
// If this is the first step and Brave is not set as default browser
231+
if (mCurrentStep == 0 && !isDefaultBrowser()) {
232+
// Show default browser prompt and proceed to next step
211233
setDefaultBrowserAndProceedToNextStep();
212234
} else {
235+
// Otherwise just proceed to next onboarding step
213236
nextOnboardingStep();
214237
}
215238
});
@@ -218,9 +241,13 @@ private void onClickViews() {
218241
if (mBtnNegative != null) {
219242
mBtnNegative.setOnClickListener(
220243
view -> {
244+
// If we're on the analytics consent page, show the P3A info page
245+
// Otherwise proceed to next onboarding step
221246
if (mCurrentStep == getAnalyticsConsentPageStep()) {
247+
// Open P3A info page in a custom tab
222248
CustomTabActivity.showInfoPage(this, P3A_URL);
223249
} else {
250+
// Move to next onboarding step
224251
nextOnboardingStep();
225252
}
226253
});
@@ -254,66 +281,49 @@ private void nextOnboardingStep() {
254281
if (isActivityFinishingOrDestroyed()) return;
255282

256283
mCurrentStep++;
284+
// Step 0: Handle default browser setup
257285
if (mCurrentStep == 0) {
258-
showIntroPage();
259-
} else if (mCurrentStep == 1) {
286+
// For devices that don't support role manager API, show browser selection page
260287
if (!BraveSetDefaultBrowserUtils.supportsDefaultRoleManager()) {
288+
mIvBrave.setVisibility(View.VISIBLE);
261289
showBrowserSelectionPage();
262-
} else if (!isDefaultBrowser()) {
290+
}
291+
// If Brave is not default browser, trigger default browser prompt
292+
else if (!isDefaultBrowser()) {
263293
setDefaultBrowserAndProceedToNextStep();
264-
} else {
294+
}
295+
// If already default browser, proceed to next step
296+
else {
265297
nextOnboardingStep();
266298
}
267-
} else if (mCurrentStep == getAnalyticsConsentPageStep()) {
299+
}
300+
// Step 1: Show analytics consent page
301+
else if (mCurrentStep == getAnalyticsConsentPageStep()) {
302+
mIvBrave.setVisibility(View.VISIBLE);
268303
showAnalyticsConsentPage();
269-
} else {
304+
}
305+
// Final step: Complete onboarding
306+
else {
307+
// Set onboarding preferences
270308
OnboardingPrefManager.getInstance().setP3aOnboardingShown(true);
271309
OnboardingPrefManager.getInstance().setOnboardingSearchBoxTooltip(true);
310+
311+
// Mark first run flow as complete
272312
FirstRunStatus.setFirstRunFlowComplete(true);
313+
314+
// Accept terms of service and EULA
273315
ChromeSharedPreferences.getInstance()
274316
.writeBoolean(ChromePreferenceKeys.FIRST_RUN_CACHED_TOS_ACCEPTED, true);
275317
FirstRunUtils.setEulaAccepted();
318+
319+
// Finish activity and notify completion
276320
finish();
277321
sendFirstRunCompletePendingIntent();
278322
}
279323
}
280324

281325
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();
326+
return 1;
317327
}
318328

319329
private void showBrowserSelectionPage() {
@@ -329,9 +339,6 @@ private void showBrowserSelectionPage() {
329339
mBtnNegative.setVisibility(View.GONE);
330340
}
331341
}
332-
if (mTvWelcome != null) {
333-
mTvWelcome.setVisibility(View.GONE);
334-
}
335342
if (mLayoutCard != null) {
336343
mLayoutCard.setVisibility(View.VISIBLE);
337344
}
@@ -375,24 +382,30 @@ private void showAnalyticsConsentPage() {
375382
mBtnNegative.setVisibility(View.VISIBLE);
376383
}
377384

385+
// Handle crash reporting consent based on installation status
378386
if (PackageUtils.isFirstInstall(this)
379387
&& !OnboardingPrefManager.getInstance().isP3aCrashReportingMessageShown()) {
388+
// For first time installs, enable crash reporting by default
380389
if (mCheckboxCrash != null) {
381390
mCheckboxCrash.setChecked(true);
382391
}
392+
// Update metrics reporting consent
383393
UmaSessionStats.changeMetricsReportingConsent(
384394
true, ChangeMetricsReportingStateCalledFrom.UI_FIRST_RUN);
395+
// Mark crash reporting message as shown
385396
OnboardingPrefManager.getInstance().setP3aCrashReportingMessageShown(true);
386397
} else {
398+
// For existing installations, restore previous crash reporting preference
387399
boolean isCrashReporting = false;
388400
try {
401+
// Get current crash reporting permission status
389402
isCrashReporting =
390403
PrivacyPreferencesManagerImpl.getInstance()
391404
.isUsageAndCrashReportingPermittedByUser();
392-
393405
} catch (Exception e) {
394406
Log.e(TAG, "isCrashReportingOnboarding: " + e.getMessage());
395407
}
408+
// Update checkbox to match current preference
396409
if (mCheckboxCrash != null) {
397410
mCheckboxCrash.setChecked(isCrashReporting);
398411
}

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)