Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make custom private page with DDG switch #3509

Merged
merged 1 commit into from
Oct 16, 2019
Merged

Conversation

emerick
Copy link
Contributor

@emerick emerick commented Sep 23, 2019

Fix brave/brave-browser#4824

Submitter Checklist:

Test Plan:

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

@emerick emerick self-assigned this Sep 23, 2019
@emerick emerick force-pushed the ddg-private-page-android branch 6 times, most recently from 7c10e06 to 74d5599 Compare September 27, 2019 14:08
@emerick emerick force-pushed the ddg-private-page-android branch 7 times, most recently from f75b9a0 to 56efdf3 Compare October 7, 2019 16:23
@emerick emerick marked this pull request as ready for review October 7, 2019 20:06
@emerick emerick requested a review from bridiver as a code owner October 7, 2019 20:06
Comment on lines 18 to 15
+ <TextView
+ android:id="@+id/ddg_offer_link"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:text="@string/ddg_offer_link"
+ android:textColor="@color/modern_grey_400"
+ android:drawableStart="@drawable/duckduckgo"
+ android:drawablePadding="15dp"
+ android:layout_marginTop="15dp"
+ android:textSize="28sp"
+ android:scaleX="0.5"
+ android:scaleY="0.5" />
+
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hoping there's a better approach I can take here to avoid such a large patch...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, done.

Comment on lines 18 to 15
+ <TextView
+ android:id="@+id/ddg_offer_link"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:text="@string/ddg_offer_link"
+ android:textColor="@color/modern_grey_400"
+ android:drawableStart="@drawable/duckduckgo"
+ android:drawablePadding="15dp"
+ android:layout_marginTop="15dp"
+ android:textSize="28sp"
+ android:scaleX="0.5"
+ android:scaleY="0.5" />
+
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<item name="android:textAlignment">viewStart</item>
<item name="android:textAppearance">@style/TextAppearance.BlackTitle1</item>
</style>
+ <style name="BraveSwitchTheme"> <item name="colorControlActivated">#fb542b</item> </style>
+ <style name="BraveDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert"> <item name="windowNoTitle">true</item> </style>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just put that string to the end of previous string to make the patch one line. We don't care that it looks ugly, we want to have as less lines as we can in patches.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do!

@emerick emerick force-pushed the ddg-private-page-android branch 2 times, most recently from f523331 to a246b91 Compare October 8, 2019 15:12
SergeyZhukovsky
SergeyZhukovsky previously approved these changes Oct 8, 2019
Copy link
Member

@SergeyZhukovsky SergeyZhukovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

simonhong
simonhong previously approved these changes Oct 8, 2019
Copy link
Member

@simonhong simonhong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with BraveSearchEngineUtils usage :)

android:textAppearance="@style/TextAppearance.IncognitoNewTabLearnMoreLinkModern"
android:lineSpacingExtra="@dimen/md_incognito_ntp_line_spacing" />

+ <include layout="@layout/brave_ddg_offer_link" android:layout_height="wrap_content" android:layout_width="match_parent" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious we can do this by programatically instead of using layout xml. If so we can minimize patch?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we implement BraveIncognitoNewTabPageView as a super class of IncognitoNewTabPageView?
If we can, I think it can also reduce more patch files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simonhong It doesn't seem like a super class would work here, since I need to override a function. But maybe I'm misunderstanding?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IncognitoNewTabPageView onFinishInflate calls super.onFinishInflate so I think a superclass would work and would only be a single patch to IncognitoNewTabPageView to change the superclass

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually I think maybe we can simplify this by not overriding IncognitoNewTabPageView at all and just adding a view class here in the xml file for ddg

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, good idea - fixed.

@emerick emerick force-pushed the ddg-private-page-android branch 2 times, most recently from 51eeb52 to 590ff65 Compare October 10, 2019 23:26
@emerick emerick added the CI/skip Do not run CI builds (except noplatform) label Oct 11, 2019
@emerick emerick force-pushed the ddg-private-page-android branch 2 times, most recently from 841ec78 to 1194f66 Compare October 11, 2019 18:15
--- a/chrome/android/java/res/values/styles.xml
+++ b/chrome/android/java/res/values/styles.xml
@@ -972,4 +972,5 @@
<style name="DarkModeCompatibleVerticalScrolling">
<item name="android:scrollbarThumbVertical">@color/default_scroll_thumb</item>
</style>
+ <style name="BraveSwitchTheme"> <item name="colorControlActivated">#fb542b</item> </style>
+ <style name="BraveSwitchTheme"> <item name="colorControlActivated">#fb542b</item> </style> <style name="BraveDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert"> <item name="windowNoTitle">true</item> </style>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continuing to add things here doesn't seem like the right approach to me. Where is this file loaded?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just create our own brave/android/java/res/values/styles.xml like we have for strings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

private Activity mActivity;

private String mTitle;
- protected IncognitoNewTabPageView mIncognitoNewTabPageView;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually are these changes even necessary? BraveIncognitoNewTabPageView is a subclass of IncognitoNewTabPageView and inflate will create the correct class based on https://github.com/brave/brave-core/pull/3509/files#diff-ea88c09faf6ae0fc5fb51f009c05d03eR10

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you're right these aren't necessary at all - good catch!

@emerick emerick force-pushed the ddg-private-page-android branch 3 times, most recently from b11b9d5 to e2fce4b Compare October 15, 2019 20:42
@emerick emerick requested a review from bridiver October 15, 2019 20:44
@emerick
Copy link
Contributor Author

emerick commented Oct 15, 2019

@bridiver Ready for review again, thanks!

@emerick emerick removed the CI/skip Do not run CI builds (except noplatform) label Oct 15, 2019
@emerick
Copy link
Contributor Author

emerick commented Oct 16, 2019

CI tests successful.

@emerick emerick merged commit 5f9e4d4 into master Oct 16, 2019
@emerick emerick deleted the ddg-private-page-android branch October 16, 2019 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make custom private page with DDG switch
4 participants