Rails 3 Group Mobile & Tablets w/ User Agent? - ruby-on-rails-3

I'm trying to conditionally render/hide some html in one of my views for tablets and mobile devices such as android phones & tablets, iPhone, iPad, etc. So far I have this setup:
def mobile_agent?
request.user_agent =~ /Mobile|webOS/
end
This seems to work good, but currently it only supports mobile devices and not tablets. I know mobile_fu groups both mobile devices and tablets under the mobile device category, however it also changes the request format which I don't want. My web application is utilizing a responsive theme so views are meant to work under any device with the exception of an embeded Unity webplayer which I wish to hide in a single view.
Is there any way I can extend the above method to include tablets as well as mobile devices?

I use this one
def mobile_agent?
request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(iPhone|iPad|iPod|BlackBerry|Android)/]
end

Try this: https://github.com/neighborland/mobu
Mobu provides a Rails controller concern called DetectMobile. Mobu does server-side User Agent detection to categorize requests as mobile, tablet, or default.
Mobu modifies your rails view paths based on the request type. It does not require custom MIME types or separate subdomains.

Related

Change Google Custom Search layout from mobile to desktop?

I am currently developing a website that uses Google Custom Search and need to do some heavy CSS customisations. The thing is that I need it to be consistent between desktop and mobile layouts, as currently it is working fine for desktops, but looks broken on mobile phones due to the missing page numbering (on desktop it is 1 to 10, whereas on mobile it just shows: < Page 2 >).
Is there a way to trick Google CSE to always use the desktop layout, even on phones? I tried setting the UA string using Javascript in the website, but it did not work.
You can set the "mobileLayout" Search Element attribute to "disabled"
See https://developers.google.com/custom-search/docs/element#supported_attributes
example: <div class="gcse-search" data-mobileLayout="disabled"></div>

Can I create a Whitelist for Safari using OpenUrl in Xamarin.Forms?

I am working on a project using Xamarin.Forms as a container app. This app includes several webviews that link to restricted web content. One of these links our Sharepoint site. The Sharepoint site has a link that allows our users to go to a 3rd party site(Cornerstone) to view training videos. When using the stock UIWebView, WKWebView, or SFSafariViewController the popup that displays the video is not shown. The only way that I can get this video to play in my app is to use OpenURL to open the Sharepoint site in Safari. The problem is that this is an Enterprise solution where we don't want to allow the employees free reign with the browser.
Is there a way to create a whitelist or to have some control over the searchbar or read the url that they are linking to and block it or redirect the user?
Unfortunately as it's farming out the URL Navigation external to your application there's not a lot you can do from within your app to restrict what they do after the fact, 'openURL' only returns a Boolean value as to it's success, and the only parameters that you can send to it are:
application - Reference to this application
(UIApplication.SharedApplication).
url - The NSUrl specified by the
calling application.
sourceApplication - The bundle ID of the calling
application.
annotation -Optional property-list data passed by the
calling application.
You can only access these if you override the 'openURL' method within your 'AppDelegate.cs' class, there is a set of options you can pass through as an override but again none of those allow you to restrict what the user does after the browser has opened.
If the devices are managed using something like 'meraki' or some other software to control the use of managed devices, then you would likely set up a 'group policy' styled set of restrictions however that's not really a Xamarin issue, and should be discussed with the network administrators.
That being said, I don't see any reason why you can't use the WebView1, that way you can handle it all within your application. Or alternative utilize custom renderers and pass in the direct video urls and commit to opening up the devices media player for streaming the content2.
1 Playing videos in WebView
2 Using the media manager plugin.

Windows 10 UWP APP: Is there a way to have Devicefamily specific XAML for phones and tablets?

I know, that it is possible to use different XAML for Desktop and Mobile in folders.
Is there a way do choose also Phone and Tablet in different folders?
No, you can implement different view based esclusively on the family.
https://msdn.microsoft.com/en-us/library/windows/apps/dn706137.aspx
The families supported by UWP are: desktop/mobile/IoT/XBOX. The phone is mobile. And you cannot get the tablet, because you can have an touch-screen ultrabook with or without the keyboard. You can detect the "tablet mode" and write some XAML to implement Adaptive UI.
Just refer this link
https://msdn.microsoft.com/en-us/windows/uwp/layout/screen-sizes-and-breakpoints-for-responsive-design
You have to manage all device view( Tablate ,Mobile,Desktop and etc)

Display Traffic in iOS7 app using MapKit

Is there a way I can display Traffic in an iOS7 app using Mapkit? I believe it can be achieved if Google Maps SDK for iOS is used but can it be done using iOS's Mapkit?
I'm sure you've noticed that the MKMapView's showsTraffic is only available on iOS 9+.
mapView.showsTraffic = true
In order to achieve this on a pre-iOS 9 application, you'll need to bring in a map tile from an external source to display the traffic. There are several services that do this, I'm not sure what their pricing/free products are. It looks like Here has a good api for it. Once you find the service you want to use to serve your traffic map tiles, you can integrate them into your map app using an MKTileOverlay: https://stackoverflow.com/a/38722623/12470155

How do access native APIs with Sencha Touch?

If I wanted to create a mobile app that allows the user to take pictures with their phone, record audio notes and record video, how would I do that?
I was browsing through the Sencha Touch 2 API and while I see documentation on video and audio files, it seems like it is just providing a way for me to access files stored on the phone - not actual triggers to record, or take pictures.
Am I missing something?
How would I do what I want?
In order for Sencha Touch to have access to your phone capabilities, you need to use a product like Phone Gap
Unless there is a HTML5 api for doing those sorts of things I don't think you can do that. I know on PhoneGap there are native extensions added into that platform for access to things like microphone, camera, etc. I don't know if Sencha Touch has added any of those sorts of extensions in order for you do this.
Just thinking out of the box here, but you might be able to put Sencha javascript into a Web View from within an Android Java process. Then the Java code could expose an object in its process as an extension point to the Javascript engine for access to Camera, Microphone, what not.