CodenameOne - Importing set of images in the theme - java

My CodenameOne app is mainly intended to be the iOS counterpart of an existing Android app. It is for older devices, in fact, as soon as possible, or in the future, a Swift app is going to replace it for OS 14>.
I need some customised icons and I have the svg code for it.
Initially I had to use the Flamingo tool, that converts svg files in Java classes.
I used it like
ScaleImageButton appButton=new ScaleImageButton(new AppIcon().scaled(doubleButtonSize,doubleButtonSize).toImage());
It is cumbersome but it does not even work on iOS.
So now I resorted to create png images for every icon in every dpi level, as it can also be done on Android.
I renamed the files so they follow the standard I think it is proposed in CodenameOne.
The possible names are:
verylow.png
low.png
medium.png
high.png
veryhigh.png
560.png
hd.png
2hd.png
4k.png
In the end it has to be used like
Image icon = theme.getImage("icon.png");
It seems that the images can be imported in the project in more than one way.
I was said to include them in the theme.
According to the CN1 developer guide I have to set the size for each.
If I import them as a whole (selecting the folder or selecting all images and hitting the "Open" button) in the theme editor a dialog appears with all wrong sizes (but they resemble a particular set of choice, although very unlikely).
They are not always the same sizes but neither they are defaulted according to the provided set of images.
I provide images as 24px, 36px, 48px, 72px, 96px, 144px, 192px, 288px, 384px for normal size icons, and also I provide double sized images for double size icons in my app (the values are not doubled as expected).
I also have to check "Square image" and "Preserve aspect ratio" options (my images are already square).
Then the strangest part is that there is a percentage, I see it is 20 for example.
The caption reads "will affect all entries". I understood that it is to scale images, that is what a developer just do not want, unless the developer has wrong sizes, but still proportioned among themselves, that cannot be the case I think.
However I do not need any scaling, the images are right as they are. I created them on purpose.
The developer guide is not enough clear to me.
So I am asking
is it right to tweak the wrong size to match the right ones, and what about the percentage?

This specific UI is a bit out of date by now and wasn't used much even when it was added. Most users opted to do desktop scaling for multi images.
The scale option is designed to scale down from a high resolution image on the desktop. You don't want/need that.
You don't need to edit the file. Just make sure to turn on the XML team mode and make sure your images use the right file names. Then once you save the images will appear in the resource file.
I suggest adding a multi-image using the standard method of add in the menu. Then replacing all the generated images with your copies and reopening the file, then saving again (the last save is important as it will override the res file).

Related

CodenameOne - accessing images from nested folder hierarchy in app bundled resources

My CodenameOne app needs that some buttons have special icons.
ScaleImageButton is the component that is suitable.
The icons to be used are from the material icons repository, but some are modified, so the CN font is not suitable.
I created the icon images with the Flamingo tool that converts svg to java classes.
It is cumbersome but it can be useful and practical, but at present time the resulting Java classes are not working on iOS.
It works on the CN simulator and Android although the button size is not exact: if state-changes reflect on some icon-changes, the layout would be rearranging and uneven.
On iOS, in addition to that, the drawing is huge or tiny in its viewport, depending of the button size that is assigned to the Flamingo image.
saveIconImage=new SaveIcon().scaled(normalButtonSize,normalButtonSize).toImage();
saveButton=new ScaleImageButton(saveIconImage);
There is an opened issue but the solution can take months or forever to come, if any, at least for such a niche issue.
So I decided to exploit the icon sets from the native Swift XCode version of my app I wisely created in parallel.
They are organized in nested subfolders (like in Assets.xcassets of XCode project), and when it comes to load resources files from the app bundle in CodenameOne, the path are special flat ones that do not like '/' or '.' chars.
Now they have a new maven building system but I do not know if something is changed about that.
So I ask whether it is possible or not to load images from folder hierarchy in the bundle and how it is achieved in terms of method calls and path strings.
The "right way" to do this is to add the images to the res file as that's the most portable way. You can do that via the theme or by including the images in your CSS, both options are discussed in the developer guide.
You can also create a separate resource file for each icon set and you can give any name you want to the icons within.
We don't support hierarchy for assets in Codename One. There's a special case for HTML which uses TAR to workaround platform differences but overall we don't allow that to avoid different behaviors between platforms.

xml editing (CandyBar dashboard for icon pack)

I have been working on some icon packs for months & will be completed within a few days and I came across CandyBar dashboard.
I'm new learner for android and java. Still studying java & So not enough knowledge of programming but I read the tutorial on CandyBar's wiki page and understood about I guess 80%.
I understood how to configure that app according to my needs.
but I'm little bit confused regarding certain xml files.Tutorial didn't clearly explained which xml needs to be edited & which to be ignored & how to be edited to make my icons pasted in drawable folders to work on different launchers.
From this xda tutorial I understood, three xmls:-
/res/xml/drawable.xml ...........to make icon appear on app to let user select icons
/res/xml/appfilter.xml..................need to add activities in it of various apps
/res/values/iconpack.xml _________(Not available in CandyBar)...... why ?
so by editing 1 & 2 xml I'm able to make my icon pack work on nova launcher and few similar launchers but not on "go launcher", so I'm confused if I'm doing something wrong.
Same xml which are in assets folder too ! :( should I edit them ?
Just want some clarification regarding xmls anybody used it ? or know about it ?
all xml files picture
You can create your icons, right click and right click> New Asset Vector at the top Type of resource: vocaloisa two options Clip Art and Local File (SVG, PSD) by clicking the clip art icon You can do download your own computer with SVG or PSD in case you want a standard that android requires.
You can also import a PNG vector directly into the drawable mass if you can not generate the SVG or PSG, as it is a graph of one and not an image that needs several dimensions you can choose to import only 1 size and work in your By while the default is already 24dp x 24, but when the default is already being erased, 24dp x 24, when you have some impression at some point of view you leave these dimensions, but it is recommended to use the Android icons or whatever you want stay in a more elegant standard. so the icons come in xml and you can edit them if you know how to mechanize with pure xml

Creating Usable Toolbar for High Resolution Screen

High resolution screens are old news, but for some reason we (and the Eclipse guys) ignored them until now. Well, we can't any longer.
What we want to do is create Eclipse applications that work for "normal" displays, but for high resolution ones, too. Right now the icons are way to small to see or click.
This bug links to this (rather sparse) documentation states we only need to use a new constructor for Image. Okay, so we need to create our own implementation of ImageDataProvider.
While that might work for the images we created ourselves, it does not work for the main tool bar icons.
So let's say we'll start a completely new application from scratch: how would we set up everything to make the toolbar work with the new API and so with all kinds of screens?
(There is a similar question, but it's from the perspective of an Eclipse user, while this question is from the perspective of a developer of an Eclipse application.)
When HiDPI mode scaling is in use anything using ImageDescriptor.createFromURL to load images will look for a image with #2x or #1.5x appended to the name depending on the current scaling (so, for example, remove.png and remove#2x.png). This is used to create an ImageDataProvider.
Eclipse will use this for the tool bar images and many other things.

Create icons for multiple versions of drawable in Android

My problem is in Eclipse - Android SDK
I have collected a set of icon for my application. However, these icons are really big, and I don't know how to reduce the size as well as quality(for smaller size in hard disk).
Recently, I have tried to use PAINT but I fail.
You could try uploading the large icons and this will shrink them down to multiple sizes for the different screen variants on Android while also keeping the size at a minimum. It is pretty self explanatory from there. You download the .zip file and copy the contents of each folder inside to your project.
If your asking how to actually design the icon, Photoshop or Gimp are good for advanced editing but that is considered an off-topic question on this forum.

Screen optimization for tablets

I have optimized my app for just about all Android phones. The way my app is set up, I have a 16dp padding on the left and right side of it and a 65dp padding on top and bottom (see screenshot below). On a phone it looks beautiful.
But on a tablet, it looks terrible. 65dp on a phone is a whole lot different that 65dp on a tablet. On a tablet, the black border around the question runs off the side of the scroll background and stuff is on the roll at the top and bottom of the scroll background.
What are my options to fix this? Is there a percentage/weight option for padding? I think that would solve it completely but there is nothing like that that I know of.
You can create multiple resource files tailored for different display sizes. Android will automatically choose the correct resource file for you. Using this technique, you can specify padding values for any screen size, or even completely unique layouts, to be automatically selected for you by Android.
Please refer to Designing for Multiple Screens.
Using multiple dimension resource files would make the task of changing the padding based on screen size very simple. See More Resource Types.

Categories

Resources