Mobile_Detect.php switch to desktop - mobile

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

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.

On Android, Display.getInstance().openGallery() does not allow multiple selection

The following code allows multiple image selection on iOS and the emulator. On Android the Gallery window opens but only one image can be selected - even if you long press. If you open Gallery manually (outside of the codenameone app) then multiple selection is available.
Display.getInstance().openGallery((e) -> {
if(e != null && e.getSource() != null) {
String[] files = (String[])e.getSource();
String filenames = "";
for (int i=0; i < files.length; i++) {
filenames = filenames + files[i] + "|";
}
System.out.println("selected filenames:" + filenames);
}
}, CN1Constants.GALLERY_ALL_MULTI);
A call to :
isGalleryTypeSupported(CN1Constants.GALLERY_ALL_MULTI)
returns true
This is a limitation of Androids intent system. When you pick from a gallery the first time around it should prompt you with an option to select the gallery app. Some gallery apps just don't support multi-selection.
You can clear the associations for the app from the system settings to trigger that prompt again. Then select a different application which will hopefully resolve that issue.
Unfortunately, due to the way Android works this is the only reasonable workaround.

Configuration file for browsers in Webdriver

My apologies in advance if this question is not so clear but bear with me and I'll try to explain.
I am in the process of re-jigging my personal automation framework based on recent exposure to other frameworks using a different programming language. Usually I create my automation framework using Selenium webdriver java binding but lately I've been using c#.
In the past, i create a baseDriver class that contains the following type of code -
public static String browser = System.getProperty("browser");
static {
if(browser.equalsIgnoreCase("firefox")) {
setWebDriverToFirefox();
} else if(browser.equalsIgnoreCase("chrome")) {
if(platform.equalsIgnoreCase("Mac")) {
CHROME_DRIVER = CHROME_DRIVER + "_mac";
} else if(platform.equalsIgnoreCase("LINUX")) {
CHROME_DRIVER = CHROME_DRIVER + "_linux";
} else {
CHROME_DRIVER = CHROME_DRIVER + "_win.exe";
}
setWebDriverToChrome();
} else if(browser.equalsIgnoreCase("safari")) {
setWebDriverToSafari();
} else {
if(os_arch.contains("64")){
IE_DRIVER = IE_DRIVER + "_x64.exe";
} else {
IE_DRIVER = IE_DRIVER + "_win32.exe";
}
}
This enables me to switch browsers and i run this using testng.xml file
What I want to do now is to have a config file that would enable me define these properties and then access them either using maven or testng when running the tests.
Has anyone implemented something similar?
Create a properties file which references those browsers. Read the properties file in during initialization then access the property when needed to switch.

Popup Window from Silverlight 5

I have strange problem with SL5 Pop-up.
My SL5 app works and fetch data from WCF service located on other domain. On one button click, some service method is called and returns a path of file. On return from service, result is used to open popup window. Since it is not user instantiated following code is used to achieve this
new Repository().SaveExporttoExcelData(builder.ToString(), (result) =>
{
this.Dispatcher.BeginInvoke(() =>
{
var options = new System.Windows.Browser.HtmlPopupWindowOptions();
options.Left = 0; options.Top = 0; options.Width = 80; options.Height = 60;
string servicePath= path;
if (result != null)
{
string excelPath = servicePath.Replace("\\","/") +"/"+ result.ToString();
System.Windows.Browser.HtmlPage.Window.Eval(string.Format("window.open('{0}','{1}','{2}')", excelPath, "new", options.ToString()));
}
else
{
MessageDialog.Show("Error in downloading file. Please try again.");
}
});
});
This works fine if I am running SL5 app from VS and service pointed to prod service environment. But the same SL does not work when I host xap on prod web. I am on citrix, and the same also work from same network where web is hosted. I have also closed the proxy connection, before opening the popup.
The url is generated fine, and popup appears for a while and close without downloading the file. but if I copy the URL and open in browser, I am able to download the file. I have checked the popup blocker settings and proxy connection.

galaxy s iii web browser DisplayModeProvider "MVC4"

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)
});

Resources