Keep ios6 disclosure indicator apparence in ios7 - ios6

The iOS Disclosure Indicator changed appearance in ios7; it's now a faded grey.
Unfortunately, my app has a lot of pages (more than 100) with different sections and background colors. On ios6, there is no problem, but on ios7 the new disclosure indicator is not visible on the background of some sections.
I need a solution, because I don't have the time to change more than 100 page background, and even if I did, if the color disclosure indicator looks okay in ios7, it's not in ios6, and vice-versa.

Set the tintColor of the table view. This will color the disclosure indicator on the cells.
Note that the tintColor property is only available under iOS 7 so code it properly:
if ([self.tableView respondsToSelector:#selector(setTintColor:)]) {
self.tableView.tintColor = ... // the desired color
}

Will it be possible for you to create custom images for ios7, and set the accessoryView of the problem cells in a method such as the data source 'cellForRowAtIndexPath' like below?
if(UIDevice.currentDevice.systemVersion.floatValue >= 7)
{
UIImageView* customDisclosureImageView = [[UIImageView alloc] initWithImage:normalImage];
customDisclosureImageView.highlightedImage = selectedImage;
cell.accessoryView = customDisclosureImageView;
}

Related

How to get video height on mounting before rendering layout?

I'm rendering two tabs on a page. The tab content is a video player and other elements under it. The problem is that when switching tabs the layout glitches. Anyone can help me with that?
To solve this I tried with no success (on mounting height is 0):
const [videoHeight, setVideoHeight] = useState<number | null>(0);
useEffect(() => {
const { height } = videoElement.current?.getBoundingClientRect() as DOMRect;
setVideoHeight(height);
}, []);
<CardMedia
component={'video'}
src={videourl}
ref={videoElement}
height={videoHeight}
width={'100%'}
/>
Here's a codesandbox: https://codesandbox.io/s/video-player-mw4c98?file=/src/App.tsx
UPD
I tried useLayoutEffect instead of useEffect with no success as well. I believe that is because video is not fully loaded at that moment.
I think the issue is not with height jumping from 0 to the actual height. The height is correctly set. The thing is video elements have a default black poster that appears in a bit after you mount them on the page. I'm not sure if there is a native or better way to work around it, but it seems some people have found a solution by setting a white poster instead. If you don't want to rely on the body's background color (which is usually white), you could go with a transparent png as the poster. Here is the original question/answer I'm referring to:
Remove black background from html5 video. Appears for a second
I tested it here:
https://codesandbox.io/s/video-player-forked-5jxd7m

Change Device Navigation Bar Color [CODENAME ONE]

How would one go about changing device navigation bar color in Codename one? I recently learned to change the color of the status bar, and I would like to do the same for the device's navigation bar.
This isn't an editable area, I'm sure there are ways to override that but it's probably not what you want. This is a part of the device control. The device determines the colors based on light/dark theme of application.
To make it work as dark you can use the build hint android.theme=Dark otherwise it should take the color based on device mode.
I found the solution by adding a color.xml file to the native android resources folder with the following line of code:
android/src/main/resources/colors.xml
<resources>
<color name="navigationBarColor">#ff000000</color>
</resources>
With this line of code, the navigation bar is rendered "black".
Refernces:
Change the color of the status bar in codenameone
Change navigation bar color

Custom toolbar issues

I have a written a custom toolbar. And I am having tough time to make it work (design wise). I have a couple of questions regarding it.
1)The main issue I am facing is to place the menu icons in their exact positions. When I tested it in different devices the gaps betn them is different.I have used table layout and grid layout for the menu icons as well & the logo in layered layout but the result is not good.
Code:
void addTitle(Form form, Resources theme) {
Toolbar toolbar = new Toolbar();
form.setToolbar(toolbar);
Container containerTitle = new Container(new BorderLayout());
Image titleImage = theme.getImage("toolbar_bg.jpg");
containerTitle.getAllStyles().setBgImage(titleImage);
containerTitle.getAllStyles().setBackgroundType(Style.BACKGROUND_IMAGE_TILE_HORIZONTAL);
containerTitle.setPreferredH(titleImage.getHeight());
ScaleImageButton ruslanLogo = new ScaleImageButton();
toolbar.setTitleComponent(LayeredLayout.encloseIn(containerTitle,
FlowLayout.encloseCenter(ruslanLogo)));
Image ruslanLogoImage = theme.getImage("ruslanLogo.png").scaledWidth(toolbar.getPreferredH() - 180);
ruslanLogo.setIcon(ruslanLogoImage);
Image emergencyImage = theme.getImage("emergency.png");
Image receipeImage = theme.getImage("receipe.png");
Image fmImage = theme.getImage("fm.png");
Image gameImage = theme.getImage("game.png");
TableLayout tableLayout = new TableLayout(1, 5);
//GridLayout gridLayout = new GridLayout(5);
Container tableContainer = new Container(tableLayout);
Button emergencyButton = getButton(emergencyImage);
emergencyButton.getAllStyles().setAlignment(Label.CENTER);
Button fmButton = getButton(fmImage);
fmButton.getAllStyles().setAlignment(Label.CENTER);
Button gameButton = getButton(gameImage);
gameButton.getAllStyles().setAlignment(Label.CENTER);
Button receipeButton = getButton(receipeImage);
receipeButton.getAllStyles().setAlignment(Label.CENTER);
Button transparentButton = getButton(receipeImage);
transparentButton.getAllStyles().setAlignment(Label.CENTER);
transparentButton.setVisible(false);
tableContainer.addComponent(tableLayout.createConstraint().widthPercentage(20), BoxLayout.encloseY(emergencyButton));
tableContainer.addComponent(tableLayout.createConstraint().widthPercentage(20), BoxLayout.encloseY(fmButton));
tableContainer.addComponent(tableLayout.createConstraint().widthPercentage(20), BoxLayout.encloseY(transparentButton));
tableContainer.addComponent(tableLayout.createConstraint().widthPercentage(20), BoxLayout.encloseY(gameButton));
tableContainer.addComponent(tableLayout.createConstraint().widthPercentage(20), BoxLayout.encloseY(receipeButton));
containerTitle.addComponent(BorderLayout.SOUTH, tableContainer);
toolbar.revalidate();
}
2)I have checked the width and preferred width, they differs. Does it affects the design?
int width = emergencyButton.getWidth(); //60
int preferredwidth = emergencyButton.getPreferredW(); //74
3)In above code, I used the bg image height to set the height of the toolbar. "containerTitle.setPreferredH(titleImage.getHeight());" Is it the good way to set height? Because the height changes slightly in android mobiles I have tested, however it looks horribly big in tabs, and I tested it in different simulator, the height differs greatly. How have you set the toolbar height in normal toolbar?
Image titleImage = theme.getImage("toolbar_bg.jpg");
containerTitle.getAllStyles().setBgImage(titleImage);
containerTitle.getAllStyles().setBackgroundType(Style.BACKGROUND_IMAGE_TILE_HORIZONTAL);
containerTitle.setPreferredH(titleImage.getHeight());
ScaleImageButton ruslanLogo = new ScaleImageButton();
toolbar.setTitleComponent(LayeredLayout.encloseIn(containerTitle,
FlowLayout.encloseCenter(ruslanLogo)));
4)How can I set the width of icon?
Image emergencyImage = theme.getImage("emergency.png");
Button emergencyButton = getButton(emergencyImage);
if I just do this, some devices the icon is too big.If I scale it eg: emergencyImage.scaledWidth(screenwidth/8) , the image quality is bad.If I set preferredW like emergencyButton.setPreferredW(100), the img width varies vastly in different devices. PS the images in the theme are saved as multiImage
Setting the preferred width/height is problematic as it implies the inverse dimension and might have quite a few implications. I noticed you used:
Image ruslanLogoImage = theme.getImage("ruslanLogo.png").scaledWidth(toolbar.getPreferredH() - 180);
Which sets the width based on the preferred height instead of the width/5 or something like that. It also sets the value based on preferred height before the toolbar construction is done so things will behave differently.
Preferred width includes padding which might affect your design. I would suggest creating a center aligned 0 padding/margin UIID in the designer and setting it to all of your components to eliminate padding/margin differences and shorten your code.

How do I set the color of the radio button's control?

How do I set the color of the radio button's control? No matter what color I specify in the style, it draws the outer circle and inner bullet in black. I want it to draw in in white on a black background to match my theme, but it always draws in black. (I'm actually doing this in a Multi-Button, setting the color of the Emblem UIID.)
I tried the first suggestion, to define the constants. That didn't work. Here's what happened.
I tried it two ways. First I defined just the radioSelectedImage and radioUnselectedImage. When that didn't work, I added both the radio*DisImage values, but it did the same thing. The selected and unselected images worked fine, but as soon as I touched a radio button, it got the focus, and the button was drawn in black, which made it invisible against my black background.
I did find an approach that worked, but it required the use of two deprecated classes. Here's what I added to the init() method of my main class:
LookAndFeel lookAndFeel = UIManager.getInstance().getLookAndFeel();
if (lookAndFeel instanceof DefaultLookAndFeel) {
DefaultLookAndFeel defaultLookAndFeel = (DefaultLookAndFeel) lookAndFeel;
Image sel = theme.getImage("RadioButtonSelected.png");
Image unSel = theme.getImage("RadioButtonUnselected.png");
defaultLookAndFeel.setRadioButtonImages(sel, unSel, sel, unSel);
defaultLookAndFeel.setRadioButtonFocusImages(sel, unSel, sel, unSel);
}
The difference here is that I have a way to set the focus images. I can't do that using the constants, which is probably why it doesn't work. I'd really rather not use deprecated classes.
There are theme constants to allow you to add images to the radio button for unselected, selected, etc. Look here...
https://www.codenameone.com/manual/advanced-theming.html

How to change the BarButtonItem back color?

I am currently working in the C# windows application with DevExpress controls.
Now I want to change back color of bar button item while loading the form.
I've tried following code:
barButton.Appearance.BackColor = Color.Red;
but the bar button back color not changed to red.
By default, bars use the skins to draw their content. In this case, all background colors are provided by specific skin elements, which cannot be changed. The only way to change a specific item's background color is to disable skins:
put the BarAndDockingController component onto a form, and assign it to the BarManager.Controller property. Set BarAndDockingController.PaintStyleName or LookAndFeel to any non-skin style(for example "Flat"). Then use the Bar.Appearance.BackColor property to set the desired color.
Alternatively, you can create your own custom barItem in a way similar to the one described in the How to change the background color of highlighted links KB article.

Resources