-
Notifications
You must be signed in to change notification settings - Fork 879
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
Conversation
7c10e06
to
74d5599
Compare
f75b9a0
to
56efdf3
Compare
+ <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" /> | ||
+ |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emerick you can use include
to include a layout inside a different layout https://github.com/brave/brave-core/blob/master/patches/chrome-android-java-res-layout-toolbar_phone.xml.patch#L17
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, done.
56efdf3
to
84abcc1
Compare
+ <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" /> | ||
+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emerick you can use include
to include a layout inside a different layout https://github.com/brave/brave-core/blob/master/patches/chrome-android-java-res-layout-toolbar_phone.xml.patch#L17
<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> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do!
f523331
to
a246b91
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++
There was a problem hiding this 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" /> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, good idea - fixed.
3b19ab8
a246b91
to
3b19ab8
Compare
51eeb52
to
590ff65
Compare
841ec78
to
1194f66
Compare
--- 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> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
b11b9d5
to
e2fce4b
Compare
@bridiver Ready for review again, thanks! |
e2fce4b
to
4adecca
Compare
CI tests successful. |
Fix brave/brave-browser#4824
Submitter Checklist:
npm run lint
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
Reviewer Checklist:
After-merge Checklist:
changes has landed on.