Trigger.io ui enhancement on Android doesn't apply to datetime-local - android

I've got a HTML5 hybrid app that I want to wrap in trigger.io for deployment. On iOS, I've been able to use
<input type="datetime-local" ... />
To get an actual string for the date and time that I want, and to give my users the native date time picker. Doing this in Android, however, just renders the field as a text box with the ISO formatted time in it.
If I use
<input type="datetime" ... />
I'm given the native date picker, followed by the time picker (I can live with that) but when "OK" is pressed, the value of the text box is what the time would be in GMT. I don't want to see GMT, I want (basically) a string of the date and time that was entered.
I've had a look in the all.js file for trigger.io, which has a line like this:
var q=function(t){if(t.getAttribute("data-forge-fixed")!="yes"&&(t.type=="date"||t.type=="datetime"||t.type=="time")){
Note, it's missing the "datetime-local", like so:
var q=function(t){if(t.getAttribute("data-forge-fixed")!="yes"&&(t.type=="date"||t.type=="datetime-local"||t.type=="datetime"||t.type=="time")){
If I edit the file, and save this change, then re-compile my app, all of the changes to all.js are overwritten back to the most recently downloaded version of trigger.io.
Does anyone have a way around this, or is this a bug that I have to wait for them to fix before I can do any more?

This is a bug in our code, sorry about that. We'll make sure a fix is deployed by the end of the week.
I wouldn't recommend this in general, but if you want to work around it now you could edit all.js in .template/android/assets/forge/all.js within your app folder, this only gets replaced when a full server side build is run.

Related

Unable to select date in month_view in android date picker in detox

Writing ui automation tests using detox. The following date picker view is being used for android.
enter image description here
I can select the current date by selecting the "OK" button, but I don't seem to be able to select a specific value in the month_view. Research on interacting with android calendar pickers has not born any fruit, so looking for someone to point me in the right direction.
Thanks.
#TopLuddite I can advise on 2 things:
As a first step, try to inspect the layout when the date picker shows (*), using Android Studio's Layout Inspector tool (under the Tools menu). In the captured layout, look up values in methods > getTag() associated with the views you wish to tap on. These are equivalent to what Detox sees as test-IDs, which means that if the value is not null, it is applicable for usage in Detox' by.id(<value>) view-matching API. That's one straightforward way to solve your issue.
As an alternative, consider using Android's UIAutomator (UIDevice) API, available via Detox using the device.getUiDevice() call. In particular, API's such as UiDevice.pressDPadDown can come in handy, or, as a last resort - UiDevice.click(x, y).
(*) Note: you must run the app in Debug mode for that to work.

input date picker on android shows wrong picker on WebView

I've got an HTML5 INPUT (type="datetime-local") in a WebView, but when I select it, it shows a date-time field that looks like this:
But the same identical element in Chrome looks like this:
This is under Android 7.1, with Chrome v55 installed, so Chrome is being used the WebView component. So, both should show the same thing, right?
I need the latter picker to show up in the WebView, it is much more user friendly (to scroll you can just flick up and down rather than having to repeatedly press the plus or minute buttons.
How do I accomplish this?
Update: I have tried creating this natively using a DatePickerDialog and it does the same thing! I'm targeting minSdkVersion=22, targetSdkVersion=25 (although I have also tried minSdkVersion=25). How do I force Android to display the correct picker for my app?
Update 2: I downloaded a sample app using the native DatePickerDialog and it displays the dialog ok. I don't like the idea of having to try to find the difference between the two projects which is causing the behavioral difference as it could be anything and take an excessive amount of time to find.
Update 3: Using the answer provided by Oleg, I was able to reproduce the second picker using android:Theme.Holo.Light.DarkActionBar. But if I use android:Theme.DeviceDefault.Light I can get a calendar view for input type="date". But the corresponding time picker in the Default theme (the round clock) does not show up for input type="time" and ``input type="datetime-local"` doesn't use the calendar view either.
As discussed in comments, you are likely missing the proper theme. Given that you have access to working app, please apply the same theme, it should solve it

How Change Date and Time inside my App (not via settings), best way to do it?

I'm building an app that will be bundled with an equipment. I want to block all access to Android settings, there is not physical button to go back, only touchscreen. So this won't help: startActivity(new Intent(android.provider.Settings.ACTION_DATE_SETTINGS));
I want to change time and date of the device through the Application. I researched a lot and every solution I've found to change time and date programatically in Android seems to be over complicated (putting the app inside system/app or something).
As I've come to know, having superuser access and declaring SET_TIME on AndroidManifest only doesn't help.
The application must display hh:mm dd/mm/yyyy
In my App settings, the user may set the date as being 13/01/2014 (dd-mm-yyyy), but let's say today is 10/01/2013. In my app I would do something like this today+offset (3 days). The same goes for the clock.
I was thinking in creating a thread that keeps track of the current time to update the text field with the current time (+offset defined by the user) every minute and another to update the date (the machine may work for a very long time), where I format it using the offset the user configured in the App. I don't like this solution, however I'm not sure if Android has another more efficient way to do this kind of task.
So the question: Is there a better way to do it other than using threads?
I was thinking in using a thread with postAtTime(), I guess it's more efficient than being inside a loop and checking if the time/date has changed from time to time.
I found out the answer I needed here: Setting system time of ROOTED phone
My Android device is rooted and using CrazyCoder solution worked. Although it will not work on Android emulator, but with rooted device.

HTML5 attribute type "time" in phonegap android app hangs the app

I have a phonegap - android app (built with jqueryMobile), with Jquery version 1.9.1 and there is a time field (taken as input) in one of the screens. Following is the code used.
<td><input type="time" name="fromTime_2" value="" placeholder="Time" /></td>
<td><input type="time" name="toTime_2" value="" placeholder="Time" /></td>
I have 6 of these time fields in the same screens.. in a <table>. On my app (Android V 4.1), when I select my first time field, it works well i.e. it shows the Android Clock and I am able to select the time.
The problem starts when I select any of the other time fields. It shows the Android clock and when the "Set" button is tapped, the app hangs from there and won't respond. I have to manually "Force Stop" the app and restart.
UPDATED:- "I need only the time field here. DateTime is not required" But the problem is same even when I tried the Datetime field. It only works for one Datetime field.
NEW UPDATE:- It's showing a simple keyboard (not android clock) on my emulator - so nothing is being tracked as "time" field in the logs.
Can anyone let me know how to fix/debug this issue?
I doubt HTML5 supported time input type will be supported in all android platforms.
jQuery Mobile states
In jQuery Mobile, you can use existing and new HTML5 input types such as password, email, tel, number, and more. Some type values are rendered differently across browsers
I suggest you use jquery plugins for date/time picking.
Eg: Datebox plugin
Fairly simple and easy to use.

Using the HTML5 date input element with android

The element <input type="date" /> cannot be activated.
When I click on the fields on the emulator it doesn't show me the entrance date but the android keyboard.
Take a look at this: http://www.quirksmode.org/html5/inputs_mobile.html
It tells you which html5 input types and attributes work on each browser. It looks like the datepicker isn't working for most Androids, and thus it would show as a simple text input.
You could use Trigger.io's UI module to use the native Android date / time picker with a regular HTML5 input. Doing that does require using the overall framework though (so won't work as a regular mobile web page).
You can see before and after screenshots in this blog post:
http://trigger.io/cross-platform-application-development-blog/2012/11/16/new-feature-roundup-native-date-time-picker-analytics-with-flurry-android-events/
Have a look here: How to make the HTML5 input type 'date' trigger the native datepicker on Android?
mobiscroll.com offers a nice polyfill.

Categories

Resources