Categories
discuss

Default Alpha value of navigation bar in Lollipop

If you set android:windowTranslucentNavigation to true in your theme in Lollipop the navigation bar won’t be fully translucent like in KitKat. Instead it’s a dark semi-transparant background. Does anyone here know what the alpha value is of that background?

Answer

I’ve made some test with navigation bar and found that alpha of navBar when android:windowTranslucentNavigation = true is 40% of black color.

So color in hex would be: #66000000

Here is steps how I calculated this value:

  1. I made screenshot as presented below
  2. Then I open it in Gimp image editor and take RGB values of each color
  3. White is (255,255,255), white under navBar (153,153,153)
  4. Grey is (150,150,150), grey under navBar (90,90,90)

Then I calculate as next:
255 is 100%
153 is x
x = 153 * 100 / 255 = 60%

So I calculated invert value of alpha channel, the true value of alpha channel is 100 – 60 = 40%

ARGB value of 40% is (102,0,0,0) in hex it’s #66000000

enter image description here

Categories
discuss

libGDX : Multi-color text in one label

I saw this post Multi-colored text in libgdx but it’s not useful specially in new API.

For example: I want to color “libGDX” text like this: enter image description here

BitmapFont font = new BitmapFont(Gdx.files.internal("fonts/CarterOne.fnt"));
LabelStyle style = new LabelStyle(font, null);
Label label = new Label("libGDX", style);
stage.addActor(label);

How can I do this ?

Answer

You can do this easily with the color markup language that Label supports as well.

Make sure to read that article completely, as there are a few little obstacles involved to get it working.

Categories
discuss

How to handle daylight saving time properly in Java 7 without Joda Time?

Before marking it duplicate read it thoroughly Plus Can’t use Joda Time and Java 8 time.util*.

I’m Trying to get the current date of Country with DST Enabled. Since with time zone it get [local-millis] = [UTC-millis] + [offset-millis] so i added the DST_OFFSET to it to get the time in the DST enabled country, as done on the Linux machine GMT_TIME + LOCAL_TIME_ZONE_OFFSET + DST_OFFSET to get the current local time.

The code to print the current Time of Istanbul Which has currently DST Enabled by 1 hour.

public class DstInstanbul {

    public static void main(String...args){

        Calendar calendar = Calendar.getInstance();

        TimeZone timeZone = TimeZone.getTimeZone("Europe/Istanbul");

        calendar.setTimeZone(timeZone);

        calendar.add(Calendar.MILLISECOND, timeZone.getDSTSavings());


        SimpleDateFormat simpleDateFormatLocal = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        simpleDateFormatLocal.setTimeZone(TimeZone.getTimeZone("Europe/Istanbul"));

        System.out.println("Current date and time : " + simpleDateFormatLocal.format(calendar.getTime()));


       System.out.println("Current date and time : " + simpleDateFormatLocal.format(calendar.getTime()));
       System.out.println("The TimeZone is : " + calendar.getTimeZone().getID());

    }
}

Which Gave me the Correct output

Current date and time : 2015-11-01 20:49:54
The Hour of the Day is : 20
The TimeZone is : Europe/Istanbul

But since the above code is not so much of generic so i tried to add following line, so that if only the daylight is enabled then only add the dstSaving So i changed the following calendar.add(Calendar.MILLISECOND, timeZone.getDSTSavings()); with

if (timeZone.inDaylightTime(new Date())){
            calendar.add(Calendar.MILLISECOND, timeZone.getDSTSavings());
       }

But the Problem is if i do so i get the output without any DST. and printing System.out.println(timeZone.inDaylightTime(new Date())); gives me false and hence the result but the daylight saving is there as you can see in this link Istanbul clock

Current date and time : 2015-11-01 19:54:49
The TimeZone is : Europe/Istanbul.

The same logic for the time zone Brazil gives me true for inDaylightTime but displays a result one hour ahead now

Ideone link for all the code ordered in a way discussed 1. https://ideone.com/4NR5Ym 2.https://ideone.com/xH7vhp 3.https://ideone.com/tQenb5

My question is what is the problem with timeZone.inDaylightTime(new Date()) with Istanbul Time Zone. Why it’s showing false. Why for Brazil i’m not getting current DST time even when the inDaylightTime is true. What is the proper way to handle such situation ?

Answer

There seems to be a few questions about time zones and daylight savings in Turkey today.

This is likely because Turkey has changed the date for the daylight savings switch from November 1 to November 8.

The timezone data in your JVM may not be current with the change. Oracle has an update for their JVM.

The timezone data updater that you download from the link above is an executable jar file. To update your JVM on a unix host:

sudo java -jar tzupdater.jar --update --location http://www.iana.org/time-zones/repository/tzdata-latest.tar.gz

The tool doesn’t seem to output anything on updates, so to verify run:

java -jar tzupdater.jar --version 

The version of the timezone data with the Turkey update is tzdata2015g

Categories
discuss

Why jQuery submits this form?

I don’t understand why pressing on either the button add or remove, the form is automatically submitted. I would like to be able to add/remove text inputs dynamically, by pressing on the above mentioned buttons, and my code is working. But as soon as I added the form, I get this weird auto-submit behaviour…

This is the jQuery script:

var counter = 3;
$("#add").click(function() {
    counter = counter + 1;
    $("#ingredienti").append('<input type="text" name="'+counter+'" class="form-control" placeholder="Inserisci ingrediente '+counter+' e quantit&agrave;" style="margin-bottom:.5em;">');
    $("input[name='numero_ingredienti']").value(counter);
});
$("#remove").click(function() {
    $("input[name="+counter+"]").remove();
    counter = counter - 1;
    if(counter<0){counter=0;};
    $("input[name='numero_ingredienti']").value(counter);
});

This the form:

<form action='salva_ricetta.php' method='post'>
    <div class="row" style="margin-top:2em;margin-bottom:5em;">
        <div class="col-sm-10 col-sm-offset-1">
            <input type="text" name='nome' class="form-control" placeholder="Nome della ricetta" style="margin-bottom:1em;">
        </div>
        <div class="col-sm-3 col-sm-offset-1">
            <div class="form-group">
                <div class="input-group">
                    <div class="input-group-addon"><span class='glyphicon glyphicon-star'></span> </div>
                    <select class="selectpicker" name='diff' data-width="8em">
                        <option selected disabled>Difficolt&agrave;</option>
                        <option value='1'>1</option>
                        <option value='2'>2</option>
                        <option value='3'>3</option>
                        <option value='4'>4</option>
                        <option value='5'>5</option>
                    </select>
                </div>
            </div>
        </div>
        <div class="col-sm-3">
            <div class="form-group">
                <div class="input-group">
                    <div class="input-group-addon"><span class='glyphicon glyphicon-time'></span> </div>
                    <input type="text" name='durata' class="form-control" id="exampleInputAmount" placeholder="Durata (in minuti)">
                </div>
            </div>
        </div>
        <div class="col-sm-4">
            <input type="text" class="form-control" name='foto' placeholder="Link ad una foto" style="margin-bottom:1em;">
        </div>
        <div class="col-sm-10 col-sm-offset-1">
            <p><img src="img/grattuggia.png" style="max-height:3em;"> Lista ingredienti <span class="glyphicon glyphicon-info-sign" data-container="body" data-toggle="tooltip" data-placement="top" title="Inserisci anche i quantitativi in grammi (g), cucchiai o cucchiaini, tazze o quello che &egrave;!"></span>
                <button class="btn btn-warning pull-right" id='add'><span class='glyphicon glyphicon-plus-sign'></span></button>
                <button class="btn btn-warning pull-right" style="margin-right:.5em;" id='remove'><span class='glyphicon glyphicon-minus-sign'></span></button>
            </p>
            <div id='ingredienti'>
                <input type="text" class="form-control" name='1' placeholder="Inserisci ingrediente 1 e quantit&agrave;" style="margin-bottom:.5em;">
                <input type="text" class="form-control" name='2' placeholder="Inserisci ingrediente 2 e quantit&agrave;" style="margin-bottom:.5em;">
                <input type="text" class="form-control" name='3' placeholder="Inserisci ingrediente 3 e quantit&agrave;" style="margin-bottom:.5em;">
            </div>
        </div>
        <div class="col-sm-10 col-sm-offset-1">
            <textarea class="form-control" name='procedimento' rows="10" placeholder="Procedimento"></textarea>
        </div>
        <div class="col-sm-10 col-sm-offset-1">
            <input type="hidden" value='3' name='numero_ingredienti' />
            <input type='submit' class="btn btn-warning pull-right" style="margin-top:.5em;" value='Salva ricetta'>
        </div>
    </div>
    </form>

Answer

Its because you define action on here

<form action='salva_ricetta.php' method='post'>

so when ever this trigger/clicked <input type='submit'

It will submit <form>.


Solution

Change this to

<input type='submit'

this

<input type='button'
Categories
discuss

phonegap build android does nothing

I have a phonegap CLI application that until recently was working fine and I was able to publish to the Google play store in alpha testing mode.

So in the www directory I did a ‘phonegap build android’ and in the platforms/android directory I did an ‘ant release’ to create a signed release apk.

I’ve been forced to upgrade my phonegap version, as the Google play store rejected my latest submission as they no longer supported the level I was using (I think it was 3… something).

So, now when I do a ‘phonegap -v’ I get 5.3.6.

When I’m in the www directory and do a ‘phonegap build android –verbose’ I get:

[phonegap] executing ‘cordova build android –verbose’…

[phonegap] completed ‘cordova build android –verbose’

With no time at all between the first line and the second line, no verbose output and no apk output!

Any idea what could be going wrong?

Thanks

Graham

Answer

Its seems related to NodeJS 5.0… In my case the Cordova Build command seems to be failling since the update.

After some investigation its look like you can by pass the problem by running the “build script” in your platform/build folder

./platforms/android/cordova/build
Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..