mirror of
https://github.com/bitwarden/mobile
synced 2025-12-21 18:53:29 +00:00
Added support for Yandex browser. Turned push sevrice back on
This commit is contained in:
@@ -20,35 +20,36 @@ namespace Bit.Android
|
|||||||
private const string BitwardenWebsite = "bitwarden.com";
|
private const string BitwardenWebsite = "bitwarden.com";
|
||||||
|
|
||||||
public static bool Enabled { get; set; } = false;
|
public static bool Enabled { get; set; } = false;
|
||||||
private static Dictionary<string, string[]> BrowserPackages => new Dictionary<string, string[]>
|
private static Dictionary<string, Browser> SupportedBrowsers => new List<Browser>
|
||||||
{
|
{
|
||||||
{ "com.android.chrome", new string[] { "url_bar" } },
|
new Browser("com.android.chrome", "url_bar"),
|
||||||
{ "com.chrome.beta", new string[] { "url_bar" } },
|
new Browser("com.chrome.beta", "url_bar"),
|
||||||
{ "com.android.browser", new string[] { "url" } },
|
new Browser("com.android.browser", "url"),
|
||||||
{ "com.brave.browser", new string[] { "url_bar" } },
|
new Browser("com.brave.browser", "url_bar"),
|
||||||
{ "com.opera.browser", new string[] { "url_field" } },
|
new Browser("com.opera.browser", "url_field"),
|
||||||
{ "com.opera.browser.beta", new string[] { "url_field" } },
|
new Browser("com.opera.browser.beta", "url_field"),
|
||||||
{ "com.opera.mini.native", new string[] { "url_field" } },
|
new Browser("com.opera.mini.native", "url_field"),
|
||||||
{ "com.chrome.dev", new string[] { "url_bar" } },
|
new Browser("com.chrome.dev", "url_bar"),
|
||||||
{ "com.chrome.canary", new string[] { "url_bar" } },
|
new Browser("com.chrome.canary", "url_bar"),
|
||||||
{ "com.google.android.apps.chrome", new string[] { "url_bar" } },
|
new Browser("com.google.android.apps.chrome", "url_bar"),
|
||||||
{ "com.google.android.apps.chrome_dev", new string[] { "url_bar" } },
|
new Browser("com.google.android.apps.chrome_dev", "url_bar"),
|
||||||
{ "org.iron.srware", new string[] { "url_bar" } },
|
new Browser("org.iron.srware", "url_bar"),
|
||||||
{ "com.sec.android.app.sbrowser", new string[] { "sbrowser_url_bar" } },
|
new Browser("com.sec.android.app.sbrowser", "sbrowser_url_bar"),
|
||||||
{ "com.yandex.browser", new string[] { "bro_common_omnibox_host", "bro_common_omnibox_edit_text" } },
|
new Browser("com.yandex.browser", "bro_omnibar_address_title_text",
|
||||||
{ "org.mozilla.firefox", new string[] { "url_bar_title" } },
|
(s) => s.Split(' ').FirstOrDefault()),
|
||||||
{ "org.mozilla.firefox_beta", new string[] { "url_bar_title" } },
|
new Browser("org.mozilla.firefox", "url_bar_title"),
|
||||||
{ "com.ghostery.android.ghostery",new string[] { "search_field" } },
|
new Browser("org.mozilla.firefox_beta", "url_bar_title"),
|
||||||
{ "org.adblockplus.browser", new string[] { "url_bar_title" } },
|
new Browser("com.ghostery.android.ghostery", "search_field"),
|
||||||
{ "com.htc.sense.browser", new string[] { "title" } },
|
new Browser("org.adblockplus.browser", "url_bar_title"),
|
||||||
{ "com.amazon.cloud9", new string[] { "url" } },
|
new Browser("com.htc.sense.browser", "title"),
|
||||||
{ "mobi.mgeek.TunnyBrowser", new string[] { "title" } },
|
new Browser("com.amazon.cloud9", "url"),
|
||||||
{ "com.nubelacorp.javelin", new string[] { "enterUrl" } },
|
new Browser("mobi.mgeek.TunnyBrowser", "title"),
|
||||||
{ "com.jerky.browser2", new string[] { "enterUrl" } },
|
new Browser("com.nubelacorp.javelin", "enterUrl"),
|
||||||
{ "com.mx.browser", new string[] { "address_editor_with_progress" } },
|
new Browser("com.jerky.browser2", "enterUrl"),
|
||||||
{ "com.mx.browser.tablet", new string[] { "address_editor_with_progress"} },
|
new Browser("com.mx.browser", "address_editor_with_progress"),
|
||||||
{ "com.linkbubble.playstore", new string[] { "url_text" }}
|
new Browser("com.mx.browser.tablet", "address_editor_with_progress"),
|
||||||
};
|
new Browser("com.linkbubble.playstore", "url_text")
|
||||||
|
}.ToDictionary(n => n.PackageName);
|
||||||
|
|
||||||
public override void OnAccessibilityEvent(AccessibilityEvent e)
|
public override void OnAccessibilityEvent(AccessibilityEvent e)
|
||||||
{
|
{
|
||||||
@@ -76,6 +77,8 @@ namespace Bit.Android
|
|||||||
if(passwordNodes.Any())
|
if(passwordNodes.Any())
|
||||||
{
|
{
|
||||||
var uri = GetUri(root);
|
var uri = GetUri(root);
|
||||||
|
if(uri != null)
|
||||||
|
{
|
||||||
if(uri.Contains(BitwardenWebsite))
|
if(uri.Contains(BitwardenWebsite))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@@ -92,6 +95,7 @@ namespace Bit.Android
|
|||||||
NotifyToAutofill(uri);
|
NotifyToAutofill(uri);
|
||||||
cancelNotification = false;
|
cancelNotification = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AutofillActivity.LastCredentials = null;
|
AutofillActivity.LastCredentials = null;
|
||||||
}
|
}
|
||||||
@@ -132,30 +136,26 @@ namespace Bit.Android
|
|||||||
private string GetUri(AccessibilityNodeInfo root)
|
private string GetUri(AccessibilityNodeInfo root)
|
||||||
{
|
{
|
||||||
var uri = string.Concat(App.Constants.AndroidAppProtocol, root.PackageName);
|
var uri = string.Concat(App.Constants.AndroidAppProtocol, root.PackageName);
|
||||||
if(BrowserPackages.ContainsKey(root.PackageName))
|
if(SupportedBrowsers.ContainsKey(root.PackageName))
|
||||||
{
|
|
||||||
foreach(var addressViewId in BrowserPackages[root.PackageName])
|
|
||||||
{
|
{
|
||||||
var addressNode = root.FindAccessibilityNodeInfosByViewId(
|
var addressNode = root.FindAccessibilityNodeInfosByViewId(
|
||||||
$"{root.PackageName}:id/{addressViewId}").FirstOrDefault();
|
$"{root.PackageName}:id/{SupportedBrowsers[root.PackageName].UriViewId}").FirstOrDefault();
|
||||||
if(addressNode == null)
|
if(addressNode != null)
|
||||||
{
|
{
|
||||||
continue;
|
uri = ExtractUri(uri, addressNode, SupportedBrowsers[root.PackageName]);
|
||||||
}
|
|
||||||
|
|
||||||
uri = ExtractUri(uri, addressNode);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return uri;
|
return uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string ExtractUri(string uri, AccessibilityNodeInfo addressNode)
|
private string ExtractUri(string uri, AccessibilityNodeInfo addressNode, Browser browser)
|
||||||
{
|
{
|
||||||
if(addressNode?.Text != null)
|
if(addressNode?.Text != null)
|
||||||
{
|
{
|
||||||
uri = addressNode.Text;
|
uri = browser.GetUriFunction(addressNode.Text);
|
||||||
|
if(uri != null && uri.Contains("."))
|
||||||
|
{
|
||||||
if(!uri.Contains("://"))
|
if(!uri.Contains("://"))
|
||||||
{
|
{
|
||||||
uri = string.Concat("http://", uri);
|
uri = string.Concat("http://", uri);
|
||||||
@@ -173,6 +173,7 @@ namespace Bit.Android
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return uri;
|
return uri;
|
||||||
}
|
}
|
||||||
@@ -269,5 +270,24 @@ namespace Bit.Android
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class Browser
|
||||||
|
{
|
||||||
|
public Browser(string packageName, string uriViewId)
|
||||||
|
{
|
||||||
|
PackageName = packageName;
|
||||||
|
UriViewId = uriViewId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Browser(string packageName, string uriViewId, Func<string, string> getUriFunction)
|
||||||
|
: this(packageName, uriViewId)
|
||||||
|
{
|
||||||
|
GetUriFunction = getUriFunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string PackageName { get; set; }
|
||||||
|
public string UriViewId { get; set; }
|
||||||
|
public Func<string, string> GetUriFunction { get; set; } = (s) => s;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ namespace Bit.Android
|
|||||||
|
|
||||||
RegisterActivityLifecycleCallbacks(this);
|
RegisterActivityLifecycleCallbacks(this);
|
||||||
AppContext = ApplicationContext;
|
AppContext = ApplicationContext;
|
||||||
//StartPushService();
|
StartPushService();
|
||||||
//HandlePushReregistration();
|
HandlePushReregistration();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandlePushReregistration()
|
private void HandlePushReregistration()
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
android:description="@string/AutoFillServiceDescription"
|
android:description="@string/AutoFillServiceDescription"
|
||||||
android:accessibilityEventTypes="typeWindowStateChanged|typeWindowContentChanged"
|
android:accessibilityEventTypes="typeWindowStateChanged|typeWindowContentChanged"
|
||||||
android:accessibilityFeedbackType="feedbackGeneric"
|
android:accessibilityFeedbackType="feedbackGeneric"
|
||||||
android:accessibilityFlags="flagDefault"
|
android:accessibilityFlags="flagReportViewIds"
|
||||||
android:notificationTimeout="100"
|
android:notificationTimeout="100"
|
||||||
android:canRetrieveWindowContent="true"/>
|
android:canRetrieveWindowContent="true"/>
|
||||||
Reference in New Issue
Block a user