Update bookmark widget
Fix crash of searchbar and qr code scanner in widget resolve bookmarl widget UI Address year in copyright string
This commit is contained in:
@@ -610,8 +610,8 @@ brave_java_resources = [
|
||||
"java/res/drawable/ic_search.xml",
|
||||
"java/res/drawable/ic_search_21dp.xml",
|
||||
"java/res/drawable/ic_search_vector.xml",
|
||||
"java/res/drawable/ic_send_tip.xml",
|
||||
"java/res/drawable/ic_search_widget_promotion_icon.xml",
|
||||
"java/res/drawable/ic_send_tip.xml",
|
||||
"java/res/drawable/ic_server_selection_check.xml",
|
||||
"java/res/drawable/ic_settings.xml",
|
||||
"java/res/drawable/ic_settings_dapps.xml",
|
||||
@@ -735,6 +735,7 @@ brave_java_resources = [
|
||||
"java/res/layout/application_item_layout.xml",
|
||||
"java/res/layout/approve_tx_bottom_sheet.xml",
|
||||
"java/res/layout/block_cookie_consent_notices_tooltip.xml",
|
||||
"java/res/layout/bookmark_widget_item.xml",
|
||||
"java/res/layout/bottom_toolbar.xml",
|
||||
"java/res/layout/bottom_toolbar_browsing.xml",
|
||||
"java/res/layout/bottom_toolbar_menu_button.xml",
|
||||
|
||||
@@ -12,6 +12,7 @@ import android.os.Build;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import org.chromium.base.BraveReflectionUtil;
|
||||
import org.chromium.base.supplier.BooleanSupplier;
|
||||
@@ -163,12 +164,12 @@ public class BraveLocationBarMediator extends LocationBarMediator {
|
||||
}
|
||||
|
||||
private void openQRCodeDialog() {
|
||||
if (BraveActivity.getBraveActivity() != null) {
|
||||
if (mContext != null && mContext instanceof AppCompatActivity) {
|
||||
BraveLocationBarQRDialogFragment braveLocationBarQRDialogFragment =
|
||||
BraveLocationBarQRDialogFragment.newInstance(this);
|
||||
braveLocationBarQRDialogFragment.setCancelable(false);
|
||||
braveLocationBarQRDialogFragment.show(
|
||||
BraveActivity.getBraveActivity().getSupportFragmentManager(),
|
||||
((AppCompatActivity) mContext).getSupportFragmentManager(),
|
||||
"BraveLocationBarQRDialogFragment");
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ import org.chromium.chrome.browser.qrreader.BarcodeTracker;
|
||||
import org.chromium.chrome.browser.qrreader.BarcodeTrackerFactory;
|
||||
import org.chromium.chrome.browser.qrreader.CameraSource;
|
||||
import org.chromium.chrome.browser.qrreader.CameraSourcePreview;
|
||||
import org.chromium.chrome.browser.util.TabUtils;
|
||||
import org.chromium.ui.base.PageTransition;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -218,7 +218,7 @@ public class BraveLocationBarQRDialogFragment
|
||||
final String barcodeValue = barcode.displayValue;
|
||||
getActivity().runOnUiThread(() -> {
|
||||
if (URLUtil.isValidUrl(barcodeValue)) {
|
||||
TabUtils.openUrlInSameTab(barcodeValue);
|
||||
mLocationBarMediator.loadUrl(barcodeValue, PageTransition.GENERATED, 0);
|
||||
mLocationBarMediator.clearOmniboxFocus();
|
||||
} else {
|
||||
mLocationBarMediator.performSearchQuery(barcodeValue, null);
|
||||
|
||||
@@ -180,9 +180,12 @@ public class BraveShieldsHandler implements BraveRewardsHelper.LargeIconReadyCal
|
||||
}
|
||||
}
|
||||
|
||||
public void loadDisconnectEntityList() {
|
||||
public void loadDisconnectEntityList(Context context) {
|
||||
if (context == null) return;
|
||||
try {
|
||||
JSONObject obj = new JSONObject(loadDisconnectEntityJSONFromAsset());
|
||||
String jsonString = loadDisconnectEntityJSONFromAsset(context);
|
||||
if (jsonString == null) return;
|
||||
JSONObject obj = new JSONObject(jsonString);
|
||||
JSONObject entities = obj.getJSONObject("entities");
|
||||
Iterator<String> keysItr = entities.keys();
|
||||
while (keysItr.hasNext()) {
|
||||
@@ -192,8 +195,6 @@ public class BraveShieldsHandler implements BraveRewardsHelper.LargeIconReadyCal
|
||||
JSONArray jsonResources = ((JSONObject) value).getJSONArray("resources");
|
||||
|
||||
for (int i = 0; i < jsonResources.length(); i++) {
|
||||
// Pair<String, String> resourceCompanyName = new Pair<String,
|
||||
// String>(jsonResources.getString(i), key);
|
||||
mResourceToCompanyNameList.add(new Pair(jsonResources.getString(i), key));
|
||||
}
|
||||
}
|
||||
@@ -204,9 +205,10 @@ public class BraveShieldsHandler implements BraveRewardsHelper.LargeIconReadyCal
|
||||
}
|
||||
}
|
||||
|
||||
private String loadDisconnectEntityJSONFromAsset() {
|
||||
private String loadDisconnectEntityJSONFromAsset(Context context) {
|
||||
if (context == null) return null;
|
||||
String json = null;
|
||||
try (InputStream inputStream = mContext.getAssets().open("disconnect_entitylist.json")) {
|
||||
try (InputStream inputStream = context.getAssets().open("disconnect_entitylist.json")) {
|
||||
int size = inputStream.available();
|
||||
byte[] buffer = new byte[size];
|
||||
inputStream.read(buffer);
|
||||
|
||||
@@ -279,7 +279,7 @@ public abstract class BraveToolbarLayoutImpl extends ToolbarLayout
|
||||
if (!mBraveShieldsHandler.isDisconnectEntityLoaded
|
||||
&& !BraveShieldsUtils.hasShieldsTooltipShown(
|
||||
BraveShieldsUtils.PREF_SHIELDS_TOOLTIP)) {
|
||||
mBraveShieldsHandler.loadDisconnectEntityList();
|
||||
mBraveShieldsHandler.loadDisconnectEntityList(getContext());
|
||||
}
|
||||
mBraveShieldsHandler.addObserver(new BraveShieldsMenuObserver() {
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2020 The Brave Authors. All rights reserved.
|
||||
/* 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/. */
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2021 The Brave Authors. All rights reserved.
|
||||
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/.
|
||||
@@ -61,4 +61,4 @@ public class BraveSearchWidgetUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
Use of this source code is governed by a BSD-style license that can be
|
||||
found in the LICENSE file. -->
|
||||
|
||||
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/bookmarks_list"
|
||||
style="@style/DarkModeCompatibleVerticalScrolling"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="16dp"
|
||||
android:background="@drawable/quick_action_search_and_bookmark_widget_background"
|
||||
android:divider="@null"
|
||||
android:drawSelectorOnTop="true"
|
||||
android:listSelector="@drawable/bookmark_widget_list_selector"
|
||||
android:alpha="0.9" />
|
||||
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright 2022 The Chromium Authors. All rights reserved.
|
||||
Use of this source code is governed by a BSD-style license that can be
|
||||
found in the LICENSE file. -->
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:ignore="UseCompoundDrawables"
|
||||
android:id="@+id/list_item"
|
||||
android:layout_marginVertical="4dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<!-- Below textview is added to avoid unused warning for bookmark_widget_background -->
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:visibility="gone"
|
||||
android:background="@color/bookmark_widget_background" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/favicon"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
tools:ignore="ContentDescription"
|
||||
android:scaleType="fitCenter"
|
||||
android:adjustViewBounds="true"
|
||||
android:background="@drawable/quick_action_search_and_bookmark_widget_bookmark_bg" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingEnd="16dp"
|
||||
android:singleLine="true"
|
||||
android:textSize="24sp"
|
||||
android:textAlignment="viewStart"
|
||||
android:textAppearance="@style/TextAppearance.TextLarge.Primary.Baseline" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2020 The Brave Authors. All rights reserved.
|
||||
<!-- 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/.
|
||||
@@ -107,4 +107,4 @@
|
||||
app:layout_constraintTop_toTopOf="@id/cvAddWidget" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</FrameLayout>
|
||||
</FrameLayout>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--* Copyright (c) 2020 The Brave Authors. All rights reserved.
|
||||
<!--* 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/. -->
|
||||
@@ -584,4 +584,4 @@
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
Reference in New Issue
Block a user