galaxy s iii web browser DisplayModeProvider "MVC4" - mobile

my application is MVC4, it works great with iPhone and Windows Phone, but did not work with Samsung Galaxy S III, it displays Desktop user interface! I tried several InexOf, for example:
DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("Mobile")
{
ContextCondition = (context => context.GetOverriddenUserAgent()
.IndexOf("Linux", StringComparison.OrdinalIgnoreCase) >= 0)
});
I also tried:
DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("Mobile")
{
ContextCondition = (context => context.GetOverriddenUserAgent()
.IndexOf("Opera Mobi", StringComparison.OrdinalIgnoreCase) >= 0)
});
I checked the Samsung III browser, using an older MVC3 application that I have developed, here are the borwser Information:
User Agent: Mozilla/5.0(Linux, U; Android 4.0.4 ....
Browser: Safari
Model SGH-1747M
I would appreciate your suggestions. Thanks in advance

Just in case someone has the same problem. I stared a new project in MVC4 (I was using the Beta version of MVC4 before) Install-Package jQuery.Mobile.MVC; It works now. The problem was not related to Samsung, becasue I tried the application on LG Android and had the same issue. Also I added in Global file the following:
DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("Linux")
{
ContextCondition = (context => context.GetOverriddenUserAgent().IndexOf
("Linux", StringComparison.OrdinalIgnoreCase) >= 0)
});

Related

Share url from Youtube iOS app to my Codename One iOS app

I need to share a video link from the Youtube app to my Codename One app on iOS.
It seems possible, according to: https://stackoverflow.com/a/38036939/1277576
With Codename One, I tried to add these build hints:
ios.plistInject=<key>CFBundleURLTypes</key><array><dict><key>CFBundleURLName</key><string>net.informaticalibera.myappname</string></dict><dict><key>CFBundleURLSchemes</key><array><string>https</string></array></dict></array>
ios.urlScheme=<string>https</string>
and I added this code to a bare bones project:
public void start() {
if (current != null) {
current.show();
return;
}
String url = Display.getInstance().getProperty("AppArg", null);
Form hi = new Form("Test case", BoxLayout.y());
if (url != null) {
hi.add(new SpanLabel("Intercepted URL:\n" + url));
} else {
hi.add(new Label("No URL was intercepted"));
}
hi.show();
}
but it doesn't work: when I share a video link, Youtube offers me several apps, but not mine.
You need to also implement it in native code and I think there are also changes required to the xcode project if I remember correctly from investigating this a while back. Currently we don't have official support for this use case but you can file an RFE for that.

How to handle Authentication pop up in Safari using Selenium?

I have been having issues with Safari 11 using WebDriver. I was able to bypass that authentication popup by using the following:
String URL = "http://" + username + ":" + password + "#" + Settings.AUT;
Driver.Navigate().GoToUrl(URL + "/");
This somehow worked with Safari 10, though I upgraded my Safari to 11 due to the maximize window is not working with Safari 10.
I am currently using webdriver 2.48 for safari.
I have no idea anymore on what to do with Safari tests. Is this a known issue? I know there is AutoIT but is there any other way to do this?
It is possible that your current web driver doesn't work with that version of browser.
SafariDriver - DEPRECATED - use Apple's SafariDriver with Safari 10+
SafariDriver now requires manual installation of the extension prior
to automation
From:
http://www.seleniumhq.org/download/
According to the RFC 3986 this format of passing the user name and password in the URL is deprecated and while it still works in Chrome and FF, Safari does not support this anymore.
You can use AppleScript and Java to handle the browser pop-up. Here is the Java code to execute AppleScript, just call this function and pass the AppleScript as String:
public static void execute(String appleScript)
{
Process process = null;
try
{
String[] args = { "osascript", "-e", appleScript };
process = Runtime.getRuntime().exec(args);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
String logs = null;
while ((logs = bufferedReader.readLine()) != null)
{
System.out.println(logs);
}
}
catch (Exception e)
{
}
finally
{
if (process != null)
process.destroy();
}
}
If you don't know how to write AppleScript go to their tutorials.
Also, to check you have given access permission to System Events; go to 'System Preferences > Security & Privacy > Privacy > Accessibility' and make sure you have 'Eclipse' and 'System Events' checked.

Codename One Geofencing

If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA
Desktop OS
Simulator
Device
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans
Desktop OS Ubuntu
Simulator Codeone Simulator
Device Galaxy Samsung 7
Using free service right now ( doing evaluation )
I am trying to implement geofencing which is the key part of development and don't have success so far , few questions and issues I am having and pls correct me if I am wrong
1) There is no support to test Geofence on simulator .I have to make the change make the build install on my device and test and when I do not see expected result I have no idea why it is failing and have to repeat the process
2) Now I am following the example
https://www.codenameone.com/javadoc/com/codename1/location/Geofence.html
I added a button with below action listener
{
Location loc = new Location();
loc.setLatitude(30.167043);
loc.setLongitude(-74.0059413);
Geofence gf = new Geofence("test", loc, 1999, 100000);
LocationManager.getLocationManager().addGeoFencing(GeofenceListenerImpl.class, gf);
});
I made sure by using fake gps itenary that I travel through this location on my device . When I click on the button Android ask permission to access the device location
public class GeofenceListenerImpl implements GeofenceListener {
#Override
public void onExit(String id) {
LocalNotification ln = new LocalNotification();
ln.setId("LnMessage1");
ln.setAlertTitle("Bye ");
ln.setAlertBody("Bye!");
Display.getInstance().scheduleLocalNotification(ln, System.currentTimeMillis() + 80 * 1000, LocalNotification.REPEAT_NONE);
}
#Override
public void onEntered(String id) {
System.out.println("com.mycompany.myapp.GeofenceListenerImpl.onEntered()");
if(Display.getInstance().isMinimized()) {
Display.getInstance().callSerially(() -> {
Dialog.show("Welcome", "Thanks for arriving", "OK", null);
});
} else {
LocalNotification ln = new LocalNotification();
ln.setId("LnMessage");
ln.setAlertTitle("Welcome");
ln.setAlertBody("Thanks for arriving!");
Display.getInstance().scheduleLocalNotification(ln, System.currentTimeMillis() + 80 * 1000, LocalNotification.REPEAT_NONE);
}
}
}
But the issue is I never see any notifications . Any help will be appreciated .
3) Do I need to minimize or close the app for geofence to work ( I have tried both and both don't work)
4) Is there any way to get the list of geofence being created ?
5) Any way to simulate the behavior on local simulator

Mobile_Detect.php switch to desktop

I have issue with switching to desktop, I`m using Mobile_Detect.php script and detection for mobile is working fine, here is the code
inc.header.php (Desktop site)
if ($_GET['v'] == 'desktop') {
$_SESSION["v1"] = 'desktop';
}
// Detect browser and redirect mobile users unless they've already opted out
if ($_SESSION["v1"] != 'desktop') {
// Place browser detection and redirection code here
require_once 'Mobile_Detect.php';
$objMobile = new Mobile_Detect;
if($objMobile ->isMobile()) {
if($_SERVER['REQUEST_URI']=="/")
{
header('Location: http://www.website.com/m/');
}
else
{
header("Location: http://www.website.com/m".$_SERVER['REQUEST_URI']);
}
exit;
}
}
Mobile setting is following
files :
**inc.footer.php**
if ($_GET['v'] == 'desktop') {
$_SESSION["v1"] = 'desktop';
}
**footer.html**
Desktop version</div>
Whats interesting switching to desktop is working when Im browsing on desktop computer but when Im trying to switch from mobile its direct me to http://website.com/m/?v=desktop but not switching to desktop
Your help will be appreciated
Thanks

Is it possible to launch a Silverlight 4 OOB application from a web page? [duplicate]

This question already has an answer here:
Launch Silverlight Out-of-Browser from browser post-installation
(1 answer)
Closed 2 years ago.
I'm planning to build a download manager application and would like to be able to launch the application when a user clicks a button the site. The application would obviously already need to be installed on the client machine.
There are a few reasons why this needs to be written using Silverlight, but they're not really relevant to the question. I only mention it so that people don't suggest that I use another technology.
Doing a bit of a mash up from two other posts [1] and [2].
But of course this will only work for Windows not Mac. There you will have to fallback to the #michael-s-scherotter style solution.
private void Button_Click(object sender, RoutedEventArgs e)
{
if (Application.Current.HasElevatedPermissions && System.Windows.Interop.ComAutomationFactory.IsAvailable)
{
string run = "\""%ProgramFiles%\\Microsoft Silverlight\\sllauncher.exe"\" /emulate:"Silverface.xap" /origin:\"http://www.silverlight.net/content/samples/apps/facebookclient/ClientBin/Silverface.xap\" /overwrite";
dynamic cmd = ComAutomationFactory.CreateObject("WScript.Shell");
cmd.Run(run, 1, true);
}
}
Yes. Here is an example:
http://www.silverlight.net/content/samples/apps/facebookclient/sfcquickinstall.aspx
I found a trick that launches the installed silverlight OOB from the silverlight app in-browser. Both applications should be singed and have the elevated trust.
When a user installs the silverlight OOB App first time, retrive the path and argument values from the shortcut file of the OOB app on desktop. (ref: How I can use Shell32.dll in Silverlight OOB) If you know the the path and argument values, you can launch the OOB app using Com Object.
Send the retrive the path and argument values to the silverlight App in-browser. (ref: http://msdn.microsoft.com/en-us/library/dd833063(v=vs.95).aspx)
Store the path and argument values in a cookie.
Now, the silverlight app in-browser is able to launch the silverlight OOB using the path and argument values in the cookie.
using (dynamic shell = AutomationFactory.CreateObject("WScript.Shell"))
{
shell.Run(launchPath);
}
I hope this trick is useful to you :)
It is possible if you agree to install the app each time the user clicks on it.
You also should set the app to require elevated trust in its OOB settings.
Just uninstall the app on startup (for example, in main window constructor):
if (Application.Current.HasElevatedPermissions && Application.Current.InstallState == InstallState.Installed)
{
string launcherPath = string.Empty;
using (dynamic shell = AutomationFactory.CreateObject("Shell.Application"))
{
string launcher64 = #"C:\Program Files (x86)\Microsoft Silverlight";
string launcher32 = #"C:\Program Files\Microsoft Silverlight";
dynamic folder64 = shell.NameSpace(launcher64);
if (folder64 != null)
{
launcherPath = launcher64;
}
else
{
dynamic folder32 = shell.NameSpace(launcher32);
if (folder32 != null)
{
launcherPath = launcher32;
}
}
}
using (dynamic shell = AutomationFactory.CreateObject("WScript.Shell"))
{
var origin = Application.Current.Host.Source.OriginalString;
var launchCmd = string.Format(#"""{0}\sllauncher.exe"" /uninstall /origin:""{1}""", launcherPath, origin);
shell.Run(launchCmd);
}
}
(the code for uninstall was taken from this post: http://www.wintellect.com/blogs/sloscialo/programmatically-uninstalling-silverlight-out-of-browser-application)

Resources