Implement iOS like time picker in Android - java

I'm looking to implement a time picker like below in Android.
I've already looked at http://tolkianaa.blogspot.mx/2012/04/how-to-use-android-wheel-part-ii.html but he has multiple xml files and multiple classes seemingly so I can't see how thats going to work. (Am I missing something?)
I have android-wheel installed so this question is useless Replicating the iOS time picker in Android
The demos from android wheel don't seem to really accommodate it.
Anyway, does anyone have a better way of implementing this is android?

You should have a look at the AOSP source code, a clock app is included I think it is the default one that is shipped with ICS & JB (but I have not compiled it to verify).
Also, the official website always have some useful info, you should try to start with this widget. The illustration seems to indicate that it uses buttons instead of swiping, which is strange but even if it is the case it will be a good start to implement a swiping version of this widget.
#Lokesh's link also seems to also fit your needs.

Related

Optimal camera focus mode android java

I have android application that use the phone camera.
First the camera opened, I want to try to use "Autofocus" mode and "Macro" mode and choose by code the best focus that I get.
I would like to ask 2 things:
Is there an internal parameter that give the focus score?
Is there a known algorithm that gives the focus score(the algorithm should not be complex, because I do it in real time on 1080p video).
I know a bunch of links is not usually helpful, but I don't have time to go through all the pages. I figure something is better than nothing :)
This is the link for the android.hardware.camera2.params package summary. I wasn't able to find anything like what you are looking for, but that's a good place to start.
Another person had a similar question on the Android Enthusiasts SE site: Can I manually focus the camera on my Android phone?
And last, but not least: There seems to be quite a bit of relevant info at the XDA Developers forum.
Good Luck! I'm a photographer myself, so this seems like an interesting project.

How to display a simple monthly calendar

I am building an Android app and I need to show a very simple monthly calendar (with next and previous month links). And, if possible, display events on some days.
I have search, high and low, for a solution but found nothing.
IsnĀ“t there a very simple way of doing this? All the widgets I find got too much features.
Check out this library:
https://github.com/derekbrameyer/android-betterpickers
I currently use it to show a monthly calendar. it looks good, clean and is extremely easy to implement in an application.
I am not sure if this helps but maybe consider using a DatePickerDialog and put it into a DialogFragment, while making sure to use the CalendarView... all of which is native to the Android SDK so it's a piece of cake to implement.
Also I have heard of a GitHub Library available called DateTimePicker, you can find more information here https://github.com/tarruda/bootstrap-datetimepicker ... it might be a little harder to configure for your exact needs but it's probably worth a look.

Rendering an Android XML layout in Java

I'm building a Java application that is some sort of Android applications (APK files) analyzer.
One of the main features that the app will offer is a "preview" of an Android layout, hence I need an API that receives an Android layout XML and a few configuration arguments such as screen resolution and theme, and returns the rendered layout as it would appear on a device running the application (graphical consistency with the real Android platform is important) along with position data of the View objects (in order to allow the user to select a view by clicking it). At the first stage, I don't expect the feature to reflect layout changes that are made programmatically, but only the View objects and resource graphics defined in the XML.
The idea I have in mind is to use the source code of a layout editor, such as ADT's editor or DroidDraw, and integrate it into my framework, but then I was wondering - maybe a better way would be to use the android API itself to render the layout for me (this is better mainly because I won't need to rewrite my code for later versions of the OS).
So my question is: does the API allows such operations? Or is there an even better way?
Any suggestions and insights are welcomed :)
does the API allows such operations?
If by "java application" you mean an app that runs on your PC, then no. There's no straightforward way to even call anything in the Android API. I'd recommend you go with the first approach of integrating some existing source code.
That said, this is not a straightforward task either. Also, if you're analyzing an APK, you'll be working with binary XML files, not the easy-to-read plain text ones that you see when developing (which assumedly are what ADT/DroidDraw use). There may be source code out there to deal with that too.
You could also consider looking at the source for Android itself, but I imagine you'd have to re-implement a bunch of rendering code, so that's no easy way out either.
At the first stage, I don't expect the feature to reflect layout changes that are made programmatically, but only the View objects and resource graphics defined in the XML.
Reflecting the layout changes made programmatically will be virtually impossible to do in a reasonable way.
This task is definitely possible, however, it's not straightforward at all. I would suggest taking a look and Android Studio's source code, more specifically there is a tool called LayoutLib.
This is the tool that the IDE's layout preview/editor uses to render layouts. You can use this to render layouts and views that you have the source code for. Unfortunately, it's not very well documented, so you have to figure out the usage from IDE's sources.
The open source Itsnat has a way to render loaded XML Android Layout files directly. it has a sample app that compares the standard (binary compiled) versions with the dynamic. My work with it shows that it does a good job reproducing all the quirks of LinearLayout/Relativelayout, etc. https://github.com/jmarranz/itsnat

Tools for rapid layout/interface creations?

Does anyone know of any tools (besides DroidDraw) that can help me create the basics of my projects a bit quicker? I'm looking for something that will allow me to very quickly generate the XML for my layouts so I don't have to sit there typing like a robot for so long.
Thanks!
However the drag and drop layout design method is not recommended for Android Applications UI designers but there is an Open Source project on Google Code: android-ui-utils , in which you might find something intersiting.
It uses a Firefox addon Pencil to draw and design android layouts and also uses an online "Android Assets Studio" where you can design your custom Icons like:
Launcher icons
List item icons
Menu Icons
Notification icons
You can give up a try here:
http://code.google.com/p/android-ui-utils/
DroidDraw is OK, but the reality is that if you are going to write for Android you are going to want to learn how to write XML layouts from scratch. I remember that XML layouts seemed bizarre when I first started working with the Android SDK, but eventually it starts to make sense.
I read a blog post from a member of the Android team at Google explaining why XML layouts are better than GUI-based layout systems (such as the one included with the iPhone SDK). I can't find the link right now, but basically XML allows for layouts that gracefully scale across devices of radically different sizes and purposes where a GUI-based layout designer often has to be tweaked at best and redone at worst for devices of different sizes.
The official Android Plugin for Eclipse comes with a GUI Editor which supports drag'n'drop of GUI Elements. Not necessarily better than DroidDraw, but maybe you didn't know yet: http://developer.android.com/sdk/eclipse-adt.html

Design a GUI for a J2ME app

How do I create a J2ME app for cellphones with a GUI similar to the menus you see in Java games? I've tried MIDlets with Netbeans but they only show you one GUI element at a time. (textbox, choice, login, etc)
And which Java IDE would you typically design these GUIs in? Netbeans or Eclipse? and is IntelliJ IDEA usable for this aswell?
Do I have to write/get a library that draws GUI controls to screen via bitmap functions .. and keeps track of the keys pressed for focus?
Try to use LWUIT - nice UI toolkit for j2me:
https://lwuit.dev.java.net/
http://lwuit.blogspot.com/
You can also use minime: http://code.google.com/p/minime/
It's an open source GUI library for j2me. miniME works on canvas level (lowest level in j2me) to draw every control so your UI will look exactly the same whatever the handset it'll be running on. Other advantage are:
- miniME uses its own event loop to manage user controlled event (botton pressed, softbar, ..), so you Application will "behave" the same whatever the handset.
- miniME support the concept of Views and stack of view, in order to make navigation between different view/screens very easy.
Here is an example: A View is what you have on the screen at a given moment (for example the main menu screen), then to go to a sub menu, you create a new view, and by calling a simple API, you push it in the stack of Views. The previous view (the main menu) is still existing, but inactive. When the sub menu view complete his work (for example, user press back, or do a selection), you can just go back to the previous view by calling a pop api.
Your question is a bit vague to give a specific aswer, but you might want to check out LWUIT or Polish, you can develop both with either Eclipse or Netbeans.
As far as designing GUIs go, neither IDE will help from a visual perspective. J2ME UI development is all done in code, beyond creating any initial graphics in a proper graphics editor you don't get to see your output until you test.
Read up on the LCDUI package documentation which explains how the UI classes work and the differences between the 'High-level' and 'low-level' APIs.
I can't comment on which IDE to use - but I do know that to create custom UI (like the ones you see in J2ME games), you have to explicitly draw the GUI controls.
Beware that you may need to customize the GUI depending on the target phones. You have to cater for different screen sizes, key pad configurations, default theme etc. This would probably mean that you need different builds for things like different screen sizes which would drive up your Java Verified certification costs (if you need it).
You may be able to find a set of nice looking UI controls that you can buy online and use (try J2ME Polish). The easy way out of course, is to use default J2ME controls :)
Links to many j2me GUI libraries: link1, link2
I know that kuix is not bad and free - watch demo.
But i prefer to make my own gui elements - this is much more flexible (but takes some time).
As for IDE - you may want to make some kind of gui-editor tool, construct interface in it, save result to some file, and read it from your app.
It's way too cumbersome to write your own GUI, especially since there are so many available these days. If you're familiar with desktop development in VB.Net and C#, you might find "J2ME GUI" easy to use. You can download it from http://www.garcer.com/. It has a similar feel and makes it easy to learn. This is the kind of GUI that I expected to come standard with MIDP2 when I started mobile development. Would have solved a lot of issues.
If you are familiar with web stuffs then you can use KUIX (kalmeo.org/home/index) framework having xml and css supports. In place of It you can use also Polish framework (www.j2mepolish.org) it's also uses the xml in easy way rather than kalmeo kuix framework.

Categories