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

Fixes an Add Widget button on Android 8 devices #16923

Merged
merged 1 commit into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions android/brave_java_resources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,8 @@ brave_java_resources = [
"java/res/drawable-xxxhdpi/uphold_white.png",
"java/res/drawable-xxxhdpi/verified_creator_large.png",
"java/res/drawable-xxxhdpi/yandex.png",
"java/res/drawable//ic_circle_down.xml",
"java/res/drawable//ic_warning.xml",
"java/res/drawable/ad_free_card_bg.xml",
"java/res/drawable/add_widget_button.xml",
"java/res/drawable/ads_custom_notification_border.xml",
"java/res/drawable/ads_custom_notification_border_dark.xml",
"java/res/drawable/bat_ads_logo_button.xml",
Expand Down Expand Up @@ -544,6 +543,7 @@ brave_java_resources = [
"java/res/drawable/ic_checkbox_filled.xml",
"java/res/drawable/ic_checkbox_outline.xml",
"java/res/drawable/ic_chevron_right.xml",
"java/res/drawable/ic_circle_down.xml",
"java/res/drawable/ic_circle_news_settings.xml",
"java/res/drawable/ic_clock.xml",
"java/res/drawable/ic_close.xml",
Expand Down Expand Up @@ -666,6 +666,7 @@ brave_java_resources = [
"java/res/drawable/ic_vpn_shield.xml",
"java/res/drawable/ic_wallet_lock.xml",
"java/res/drawable/ic_wallet_settings.xml",
"java/res/drawable/ic_warning.xml",
"java/res/drawable/ic_warning_circle.xml",
"java/res/drawable/ic_warning_circle_filled.xml",
"java/res/drawable/ic_warning_red.xml",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Copyright (c) 2022 The Brave Authors. All rights reserved.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this file,
You can obtain one at http://mozilla.org/MPL/2.0/.
You can obtain one at https://mozilla.org/MPL/2.0/.
*/

package org.chromium.chrome.browser.widget.quickactionsearchandbookmark.promo;
Expand All @@ -13,8 +13,6 @@
import android.widget.PopupWindow;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.cardview.widget.CardView;

import org.chromium.chrome.R;
import org.chromium.chrome.browser.widget.quickactionsearchandbookmark.utils.BraveSearchWidgetUtils;
Expand All @@ -24,18 +22,16 @@ public class SearchWidgetPromoPanel implements View.OnClickListener {

public SearchWidgetPromoPanel(@NonNull Context context) {
View view = View.inflate(context, R.layout.layout_search_widget_promo, null);
CardView cvAddWidget = view.findViewById(R.id.cvAddWidget);
AppCompatTextView tvNotNow = view.findViewById(R.id.tvNotNow);
cvAddWidget.setOnClickListener(this);
tvNotNow.setOnClickListener(this);
view.findViewById(R.id.btAddWidget).setOnClickListener(this);
view.findViewById(R.id.tvNotNow).setOnClickListener(this);
int width = LinearLayout.LayoutParams.MATCH_PARENT;
int height = LinearLayout.LayoutParams.WRAP_CONTENT;
mPopupWindow = new PopupWindow(view, width, height, true);
}

@Override
public void onClick(@NonNull View view) {
if (view.getId() == R.id.cvAddWidget)
if (view.getId() == R.id.btAddWidget)
BraveSearchWidgetUtils.requestPinAppWidget();
else if (view.getId() == R.id.tvNotNow)
BraveSearchWidgetUtils.setShouldShowWidgetPromo(false);
Expand Down
32 changes: 32 additions & 0 deletions android/java/res/drawable/add_widget_button.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 The Brave Authors. All rights reserved.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this file,
You can obtain one at https://mozilla.org/MPL/2.0/.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:state_pressed="false">
<shape android:padding="12dp" android:shape="rectangle">
<solid android:color="@color/modern_grey_700" />
<corners android:radius="48dp" />
</shape>
</item>
<item android:state_enabled="true" android:state_pressed="false">
<shape android:padding="12dp" android:shape="rectangle">
<solid android:color="@color/brave_action_color" />
<corners android:radius="48dp" />
</shape>
</item>
<item android:state_focused="false" android:state_pressed="true">
<shape android:padding="12dp" android:shape="rectangle">
<solid android:color="@color/brave_add_widget_button_pressed" />
<corners android:radius="48dp" />
</shape>
</item>
<item android:state_enabled="true">
<shape android:padding="12dp" android:shape="rectangle">
<solid android:color="@color/brave_action_color" />
<corners android:radius="48dp" />
</shape>
</item>
</selector>
63 changes: 25 additions & 38 deletions android/java/res/layout/layout_search_widget_promo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- Copyright (c) 2022 The Brave Authors. All rights reserved.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this file,
You can obtain one at http://mozilla.org/MPL/2.0/.
You can obtain one at https://mozilla.org/MPL/2.0/.
-->

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
Expand Down Expand Up @@ -78,47 +78,34 @@
android:layout_height="wrap_content"
android:orientation="horizontal">

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tvNotNow"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:text="@string/not_now"
android:gravity="center"
android:ellipsize="end"
android:textColor="@color/search_widget_promo_not_now_text_color"
android:fontFamily="sans-serif-medium" />

<androidx.cardview.widget.CardView
android:id="@+id/cvAddWidget"
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tvNotNow"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.5"
app:cardBackgroundColor="@color/brave_action_color"
app:cardCornerRadius="60dp">

<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="wrap_content"
android:text="@string/not_now"
android:gravity="center"
android:ellipsize="end"
android:textColor="@color/search_widget_promo_not_now_text_color"
android:fontFamily="sans-serif-medium" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btAddWidget"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center"
android:paddingStart="16dp"
android:paddingTop="10dp"
android:paddingEnd="16dp"
android:paddingBottom="10dp">

<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_plus_add_widget"
android:drawablePadding="8dp"
android:fontFamily="sans-serif-medium"
android:ellipsize="end"
android:gravity="center"
android:text="@string/add_widget"
android:textColor="@color/search_widget_promo_add_widget_text_color" />
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.cardview.widget.CardView>
android:layout_weight="0.5"
android:gravity="center"
android:background="@drawable/add_widget_button"
android:text="@string/add_widget"
android:textAllCaps="false"
android:paddingHorizontal="16dp"
android:paddingVertical="10dp"
android:textColor="@color/search_widget_promo_add_widget_text_color"
android:fontFamily="sans-serif-medium"
app:drawableStartCompat="@drawable/ic_plus_add_widget"
android:drawablePadding="2dp"
style="?android:attr/borderlessButtonStyle"/>

</LinearLayout>

Expand Down
3 changes: 2 additions & 1 deletion android/java/res/values/brave_colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- Copyright (c) 2019 The Brave Authors. All rights reserved.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this file,
You can obtain one at http://mozilla.org/MPL/2.0/.
You can obtain one at https://mozilla.org/MPL/2.0/.
-->

<resources xmlns:tools="http://schemas.android.com/tools">
Expand Down Expand Up @@ -92,6 +92,7 @@
<color name="brave_theme_color">#fb542b</color>
<color name="brave_tab_view_card_selected_bg">@color/baseline_primary_200</color>
<color name="brave_wallet_button_pressed">#737ADE</color>
<color name="brave_add_widget_button_pressed">#737ADE</color>

<!-- Brave news colors -->
<!-- <color name="card_background">#DC353535</color> -->
Expand Down