-
Notifications
You must be signed in to change notification settings - Fork 893
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6243 from brave/search-update-1.12.x
Search update 1.12.x (uplift to 1.12.x)
- Loading branch information
Showing
23 changed files
with
960 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...ava/org/chromium/chrome/browser/search_engines/settings/BraveBaseSearchEngineAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* Copyright (c) 2020 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/. */ | ||
|
||
package org.chromium.chrome.browser.search_engines.settings; | ||
|
||
import android.content.Context; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.BaseAdapter; | ||
|
||
import org.chromium.components.search_engines.TemplateUrl; | ||
import org.chromium.chrome.browser.search_engines.settings.SearchEngineAdapter; | ||
|
||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
public class BraveBaseSearchEngineAdapter extends BaseAdapter { | ||
public BraveBaseSearchEngineAdapter() { | ||
} | ||
|
||
// BaseAdapter: | ||
@Override | ||
public View getView(int position, View convertView, ViewGroup parent) { | ||
return convertView; | ||
} | ||
|
||
@Override | ||
public long getItemId(int position) { | ||
return position; | ||
} | ||
|
||
@Override | ||
public Object getItem(int pos) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return 0; | ||
} | ||
|
||
public static void sortAndFilterUnnecessaryTemplateUrl( | ||
List<TemplateUrl> templateUrls, TemplateUrl defaultSearchEngine) { | ||
int recentEngineNum = 0; | ||
long displayTime = System.currentTimeMillis() - SearchEngineAdapter.MAX_DISPLAY_TIME_SPAN_MS; | ||
Iterator<TemplateUrl> iterator = templateUrls.iterator(); | ||
while (iterator.hasNext()) { | ||
TemplateUrl templateUrl = iterator.next(); | ||
if (getSearchEngineSourceType(templateUrl, defaultSearchEngine) | ||
!= SearchEngineAdapter.TemplateUrlSourceType.RECENT) { | ||
continue; | ||
} | ||
if (recentEngineNum < SearchEngineAdapter.MAX_RECENT_ENGINE_NUM | ||
&& templateUrl.getLastVisitedTime() > displayTime) { | ||
recentEngineNum++; | ||
} else { | ||
iterator.remove(); | ||
} | ||
} | ||
} | ||
|
||
public static @SearchEngineAdapter.TemplateUrlSourceType int getSearchEngineSourceType( | ||
TemplateUrl templateUrl, TemplateUrl defaultSearchEngine) { | ||
if (templateUrl.getIsPrepopulated()) { | ||
return SearchEngineAdapter.TemplateUrlSourceType.PREPOPULATED; | ||
} else if (templateUrl.equals(defaultSearchEngine)) { | ||
return SearchEngineAdapter.TemplateUrlSourceType.DEFAULT; | ||
} else { | ||
return SearchEngineAdapter.TemplateUrlSourceType.RECENT; | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<vector android:height="24dp" android:viewportHeight="256" | ||
android:viewportWidth="256" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="#6001D2" android:pathData="M0,0h256v256h-256z"/> | ||
<path android:fillColor="#ffffff" android:pathData="M82,175L49,95V91.5L51,89.5H75.5L78,91.5L80,93L98,137L115,95L116.5,91.5L119.5,89.5H144.5L146.5,91.5V95L104.5,198L103,200L101,201H75.5L73.5,200V198L82,177V175Z"/> | ||
<path android:fillColor="#ffffff" android:pathData="M149.5,120L174.5,59L176.5,56L179,55H204L206,57V59.5L181,121L179,123L176.5,124.5H151.5L149.5,122.5V120Z"/> | ||
<path android:fillColor="#ffffff" android:pathData="M156,154m-19.5,0a19.5,19.5 0,1 1,39 0a19.5,19.5 0,1 1,-39 0"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.