Fixes an Add Widget button on Android 8 devices

This commit is contained in:
Serg
2023-01-30 14:26:50 -05:00
parent 82a7c559dc
commit 0197745233
5 changed files with 66 additions and 49 deletions
+3 -2
View File
@@ -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",
@@ -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",
@@ -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",
@@ -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;
@@ -13,8 +13,6 @@ import android.widget.LinearLayout;
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;
@@ -24,10 +22,8 @@ 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);
@@ -35,7 +31,7 @@ public class SearchWidgetPromoPanel implements View.OnClickListener {
@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);
@@ -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>
@@ -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"
@@ -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.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.AppCompatButton
android:id="@+id/btAddWidget"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
app:cardBackgroundColor="@color/brave_action_color"
app:cardCornerRadius="60dp">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="wrap_content"
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>
+2 -1
View File
@@ -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">
@@ -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> -->