Google has changed Linkify implementation with custom links in Android 5 - android

We've got some custom links in our application that look like that bar.foo://var?parameter=value
Prior Android 5.0.0 bar.foo was not recognised as a link. However in Android 5.0.0 it is recognized as a link and Android will try to open it in the default browser if you click anywhere on bar.foo:. If you however click on //var?parameter=value it will treat it as a customized link and do the stuff that is intended.
Is there any way to prevent this?
This is our Linkify related code:
Linkify.addLinks(this, Linkify.WEB_URLS); // This one is causing the issue. Unfortunately we can't disable it
for (final Pattern pattern : linkPatterns) {
Linkify.addLinks(this, pattern, linkPrefix);
}

Related

Insert icon in a tabbed page(Android) on xamarin form

I'm new to StackOverflow community!
I need help with one problem with android in Xamarin Forms. To be precise... I tried with some friends to build our first app. We choose(with the help of our University professor) Xamarin for the cross-platform development of Android and iOS for both systems using the Xamarin Forms. I created the interface part of the app and now I am stuck in a fort with big walls. When I try to add a Tabbed Page the icon for the functional bar, the app crashes(Android) but in iOS, the problem doesn't appear...
I'd try with some solution... like :
-Render in the NameApp.Droid adds different renderer only for the android part but no result...
-Try another way to insert the icon in the .xaml file directly but no result...
-Try to follow another way to modify the .axam file for the "Theme" part
but no result...
I want to integrate all the stuff on time only in the "Main Project". I don't want for now touch the "nameProject.Droid" or "nameProject.iOS" part, But try to make in one shoot both(Andriod & iOS). I've found a different bug in Android (è.é) but for this, I am going crazy...
But I need to modify the ".Droid" no problem I accept the challenge!
This is the result I aspire to create.
"https://storage.googleapis.com/material-design/publish/material_v_12/assets/0B6Okdz75tqQsbHJuWi04N0ZIc0E/components-tabs-usage-mobile7.png"
This is the way I add the Icon in the Tabbed Page. An assumption I add all the stuff in the "Resource" in ".Droid" and ".iOS :
var MainPageTabbed = new MPageTabbed();
var Profile = new Profile();
var ListChat = new ListChat();
if (Device.RuntimePlatform == Device.Android)
{
MainPageTabbed.Icon = "ldpi.png";
Profile.Icon = "ldpi2.png";
Chat.Icon = "ldpi1.png";
}
if (Device.RuntimePlatform == Device.iOS)
{
MainPageTabbed.Icon = "ldpi.png";
Profile.Icon = "ldpi2.png";
ListChat.Icon = "ldpi1.png";
}
NavigationPage.SetHasNavigationBar(this, false);
Children.Add(MainPageTabbed);
Children.Add(Profile);
Children.Add(ListChat);
Someone can help me please to find a solution?
Here you have an example of how to use the TabbedPage in xamarin forms:
https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/navigation/tabbed-page/
... Xamarin.forms renders Android tabbed-pages as something called a viewpager combined with a TabPagerStrib, and it looks like the example in the link above.
You might read about BottomNavigationBar for Android instead, or look at this link for a TabPagerStrip with an image:
https://forums.xamarin.com/discussion/39937/adding-icons-to-a-pagertabstrip-instead-of-text
If anyone is interested in a FontAwesome custom icon implementation I followed this tutorial to begin with: FontAwesome with Xamarin Forms
Unfortunately he doesn't give an example of integrating with tabbed pages but after some experimenting I finally figured out a simplified Xaml way to render it without a custom tabbed renderer:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:IBMobile.Views"
xmlns:local2="clr-namespace:FontAwesome"
x:Class="IBMobile.Views.HomePage"
Visual="Material">
<ContentPage.IconImageSource>
<FontImageSource FontFamily="{StaticResource FontAwesomeSolid}" Glyph="{x:Static local2:IconFont.Home}" />
</ContentPage.IconImageSource>

Mobile Web - Disable long-touch/taphold text selection

I've seen/heard all about disabling text selection with the variations of user-select, but none of those are working for the problem I'm having. On Android (and I presume on iPhone), if you tap-and-hold on text, it highlights it and brings up little flags to drag and select text. I need to disable those (see image):
I've tried -webkit-touch-callout to no avail, and even tried things like $('body').on('select',function(e){e.preventDefault();return;}); to no avail. And the cheap tricks like ::selection:rgba(0,0,0,0); won't work either, as hiding these won't help - selection still happens and it disrupts the UI. Plus I'm guessing those flags would still be there.
Any thoughts would be great. Thanks!
-webkit-touch-callout:none;
-webkit-user-select:none;
-khtml-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;
-webkit-tap-highlight-color:rgba(0,0,0,0);
This will disable it for every browser going.
Reference:
jsFiddle Demo with Plugin
The above jsFiddle Demo I made uses a Plugin to allow you to prevent any block of text from being selected in Android or iOS devices (along with desktop browsers too).
It's easy to use and here is the sample markup once the jQuery plugin is installed.
Sample HTML:
<p class="notSelectable">This text is not selectable</p>
<p> This text is selectable</p>
Sample jQuery:
$(document).ready(function(){
$('.notSelectable').disableSelection();
});
Plugin code:
$.fn.extend({
disableSelection: function() {
this.each(function() {
this.onselectstart = function() {
return false;
};
this.unselectable = "on";
$(this).css('-moz-user-select', 'none');
$(this).css('-webkit-user-select', 'none');
});
return this;
}
});
Per your message comment: I still need to be able to trigger events (notably, touchstart, touchmove, and touchend) on the elements.
I would simply would use a wrapper that is not affected by this plugin, yet it's text-contents are protected using this plugin.
To allow interaction with a link in a block of text, you can use span tags for all but the link and add class name .notSelected for those span tags only, thus preserving selection and interaction of the anchors link.
Status Update: This updated jsFiddle confirms you concern that perhaps other functions may not work when text-selection is disabled. Shown in this updated jsFiddle is jQuery Click Event listener that will fire a Browser Alert for when the Bold Text is clicked on, even if that Bold Text is not text-selectable.
-webkit-user-select:none; wasn't supported on Android until 4.1 (sorry).

Android:cannot make a selection after WebView search with highlight

Hello I have a bug in my app and I cannot figure it out.
I want to search for text in my WebView and get the found Text highlighted
for Android 1.5-2.3 this works quite well
public void onClick(View v){
webView1.findNext(true);
int i = webView1.findAll(findBox.getText().toString());
try{
Method m = WebView.class.getMethod("setFindIsUp", Boolean.TYPE);
m.invoke(webView1, true);
}catch(Exception ignored){}
}
}
for Android 3.0+ I have to use the JavaScript workaround from here, because Google doesn't support the highlighting of searched text for incomprehensible reasons
And now my Bug: After the search on my WebView I get the highlighted Text, and I can't select the Text anymore. The only fix I could use is the JavaScript workaround in older Android versions, too. But the function runs very slow and it takes about 10 seconds until the text gets highlighted. I Hope someone has a better solution/fix :)
Thank you
I use the same for 3.x then it did not work on 4.0.x.
Yesterday I updated to 4.0.4 and now highlight works again.
So the solution can be found in the 4.0.4 sources.
OK I have found a quite good solution.
Here is a JavaScript code for Highlighting, that runs really fast :) http://4umi.com/web/javascript/hilite.php#thescript
Anyway I don't understand, why I can't selecting text after the of the official Webview search
For Android 3.x I used webview.showFindDialog(stringtofind, true);
use findAllAsync() instead , finAll() is deprecated in API 16;

HttpUnit/HtmlUnit equivalent for android

I'm looking for a browser-simulating library on android, which handles things like
loading a website (http/https)
Redirections: HTTP (3xx Status Codes), JavaScript, HMTL tags
filling out html-forms
easy html parsing (could fall back to JSoup for that one)
HttpUnit or HtmlUnit would do just fine, but both of them are a pain to get running on android.
Is there any other option other than (Android)HttpClient (and therefore doing lots of the above on my own)? Or can I somehow get use of the android webkit/browser?
Thanks in advance!
I would recommend you to have a look at AndroidDriver for selenium. It seems to be a straightforward approach to easy test WebApplications with the Android Testing Framework.
You must use an Activity that includes a WebView in order to test HTTP/HTTPs websites.
The Driver is instanciated with this Activity:
WebDriver driver = new AndroidWebDriver(getActivity());
Here is a sample test, quoted from the link above:
public void testGoogleWorks()
// Loads www.google.com
driver.get("http://www.google.com");
// Lookup the search box on the page by it's HTML name property
WebElement searchBox = driver.findElement(By.name("q"));
// Enter keys in the search box
searchBox.sendKeys("Android Rocks!");
// Hit enter
searchBox.submit();
// Ensure the title contains "Google"
assertTrue(driver.getTitle().contains("Google"));
// Ensure that there is at least one link with the keyword "Android"
assertTrue(driver.findElements(By.partialLinkText("Android")).size() > 1);
}

Titanium Appcelerator Android - Open default soft keyboard in number view

I have an address search field in my app. When this field gets focus I want to open the keyboard as in the following image.
It works fine for iOS when the keyboard type is set to Titanium.UI.KEYBOARD_NUMBERS_PUNCTUATION as in the following code
var search = Titanium.UI.createSearchBar({
barColor:'#c8c8c8',
autocorrect:true,
hintText:'enter address',
height:'43dp',
top:'75dp',
autocapitalization: Titanium.UI.TEXT_AUTOCAPITALIZATION_WORDS,
keyboardType:Titanium.UI.KEYBOARD_NUMBERS_PUNCTUATION
});
However on Android it appears as in the following image.
I am using Titanium mobile SDK 1.7.5
You should probably add :
softKeyboardOnFocus : Titanium.UI.Android.SOFT_KEYBOARD_SHOW_ON_FOCUS
Unfortunately, it may be overridden by the system. Try it on another Android system (3.0 for example) if the problem persist.

Categories

Resources