Home | History | Annotate | Download | only in promote
      1 page.title=Google Play Badges
      2 @jd:body
      3 <div id="butterbar-wrapper" >
      4   <div id="butterbar" >
      5     <div id="butterbar-message">
      6 <a target="_blank" href="https://docs.google.com/a/google.com/forms/d/1EHLPGqhbxj2HungHRRN4_0K9TGpc-Izy-u46vBDgS8Q/viewform">
      7       Take the Android Developer Survey</a>
      8     </div>
      9   </div>
     10 </div>
     11 
     12 <p itemprop="description">Google Play badges allow you to promote your app with official branding
     13 in your online ads, promotional materials, or anywhere else you want a link to your app.</p>
     14 
     15 <p>In the form below,
     16 input your app's package name or publisher name, choose the badge style,
     17 click <em>Build my badge</em>, then paste the HTML into your web content.</p>
     18 
     19 <p>If you're creating a promotional web page for your app, you should also use the
     20 <a href="{@docRoot}distribute/promote/device-art.html">Device Art Generator</a>, which quickly
     21 wraps your screenshots in real device artwork.</p>
     22 
     23 <p>For guidelines when using the Google Play badge and other brand assets,
     24 see the <a href="{@docRoot}distribute/googleplay/promote/brand.html#brand-google_play">Brand
     25 Guidelines</a>.</p>
     26 
     27 <style type="text/css">
     28 
     29 form.button-form {
     30   margin-top:2em;
     31 }
     32 
     33 /* the label and input elements are blocks that float left in order to
     34    keep the left edgets of the input aligned, and IE 6/7 do not fully support "inline-block" */
     35 label.block {
     36   display: block;
     37   float: left;
     38   width: 100px;
     39   padding-right: 10px;
     40 }
     41 
     42 input.text {
     43   display: block;
     44   float: left;
     45   width: 250px;
     46 }
     47 
     48 div.button-row {
     49   white-space:nowrap;
     50   min-height:80px;
     51 }
     52 
     53 div.button-row input {
     54   vertical-align:middle;
     55   margin:0 5px 0 0;
     56 }
     57 
     58 #jd-content div.button-row img {
     59   margin: 0;
     60   vertical-align:middle;
     61 }
     62 
     63 </style>
     64 
     65 <script type="text/javascript">
     66 
     67 // locales for which we have the 'app' badge
     68 var APP_LANGS = ['it','pt-br','pt-pt','nl','ko','ja','fr','es','es-419','en','de'];
     69 
     70 // variables for creating 'try it out' demo button
     71 var imagePath = "https://developer.android.com/images/brand/"
     72 var linkStart = "<a href=\"https://play.google.com/store/";
     73 var imageStart = "\">\n"
     74         + "  <img alt=\"";
     75   // leaves opening for the alt text value
     76 var imageSrc = "\"\n       src=\"" + imagePath;
     77   // leaves opening for the image file name
     78 var imageEnd = ".png\" />\n</a>";
     79 
     80 // variables for creating code snippet
     81 var linkStartCode = "&lt;a href=\"https://play.google.com/store/";
     82 var imageStartCode = "\"&gt;\n"
     83         + "  &lt;img alt=\"";
     84   // leaves opening for the alt text value
     85 var imageSrcCode = "\"\n       src=\"" + imagePath;
     86   // leaves opening for the image file name
     87 var imageEndCode = ".png\" />\n&lt;/a>";
     88 
     89 /** Generate the HTML snippet and demo based on form values */
     90 function buildButton(form) {
     91   var lang = $('#locale option:selected').val();
     92   var selectedValue = lang + $('form input[type=radio]:checked').val();
     93   var altText = selectedValue.indexOf("generic") != -1 ? "Get it on Google Play" : "Android app on Google Play";
     94 
     95   if (form["package"].value != "com.example.android") {
     96     $("#preview").show();
     97     var packageName = escapeHTML(form["package"].value);
     98     $("#snippet").show().html(linkStartCode + "apps/details?id=" + packageName
     99             + imageStartCode + altText + imageSrcCode
    100             + selectedValue + imageEndCode);
    101     $("#button-preview").html(linkStart + "apps/details?id=" + packageName
    102             + imageStart + altText + imageSrc
    103             + selectedValue + imageEnd);
    104             
    105     // Send the event to Analytics
    106     _gaq.push(['_trackEvent', 'Distribute', 'Create Google Play Badge', 'Package ' + selectedValue]);
    107   } else if (form["publisher"].value != "Example, Inc.") {
    108     $("#preview").show();
    109     var publisherName = escapeHTML(form["publisher"].value);
    110     $("#snippet").show().html(linkStartCode + "search?q=pub:" + publisherName
    111             + imageStartCode + altText + imageSrcCode
    112             + selectedValue + imageEndCode);
    113     $("#button-preview").html(linkStart + "search?q=pub:" + publisherName
    114             + imageStart + altText + imageSrc
    115             + selectedValue + imageEnd);
    116    
    117     // Send the event to Analytics
    118     _gaq.push(['_trackEvent', 'Distribute', 'Create Google Play Badge', 'Publisher ' + selectedValue]);
    119   } else {
    120     alert("Please enter your package name or publisher name");
    121   }
    122   return false;
    123 }
    124 
    125 /** Listen for Enter key */
    126 function onTextEntered(event, form, me) {
    127   // 13 = enter
    128   if (event.keyCode == 13) {
    129     buildButton(form);
    130   }
    131 }
    132 
    133 /** When input is focused, remove example text and disable other input */
    134 function onInputFocus(object, example) {
    135   if (object.value == example) {
    136     $(object).val('').css({'color' : '#000'});
    137   }
    138   $('input[type="text"]:not(input[name='+object.name+'])',
    139           object.parentNode).attr('disabled','true');
    140   $('#'+object.name+'-clear').show();
    141 }
    142 
    143 /** When input is blured, restore example text if appropriate and enable other input */
    144 function onInputBlur(object, example) {
    145   if (object.value.length < 1) {
    146     $(object).attr('value',example).css({'color':'#ccc'});
    147     $('input[type="text"]', object.parentNode).removeAttr('disabled');
    148     $('#'+object.name+'-clear').hide();
    149   }
    150 }
    151 
    152 /** Clear the form to start over */
    153 function clearLabel(id, example) {
    154   $("#preview").hide();
    155   $('#'+id+'').html('').attr('value',example).css({'color':'#ccc'});
    156   $('input[type="text"]', $('#'+id+'').parent()).removeAttr('disabled');
    157   $('#'+id+'-clear').hide();
    158   return false;
    159 }
    160 
    161 /** Switch the badge urls for selected language */
    162 function changeBadgeLang() {
    163   var lang = $('#locale option:selected').val();
    164   
    165   // check if we have the 'app' badge for this lang and show notice if not
    166   $("div.button-row.error").remove();  // remove any existing instance of error message
    167   if ($.inArray(lang,APP_LANGS) == -1) {
    168     $("div.button-row.app").hide();
    169     $("div.button-row.app").after('<div class="button-row error"><p class="note" style="margin:1em 0 -1em">'
    170         + 'Sorry, we currently don\'t have the '
    171         + '<em>Android app on Google Play</em> badge translated for '
    172         + $("select#locale option[value="+lang+"]").attr("title")
    173         + '.<br>Please check back later or instead use the <em>Get it on Google Play</em> badge below.'
    174         + '</p></div>');
    175   } else {
    176     $("div.button-row.app").show(); // show the 'app' badge row
    177   }
    178   
    179   $('.button-row img').each(function() {
    180     var id = $(this).parent().attr('for');
    181     var imgName = lang + $('input#'+id).attr('value') + '.png';
    182     var lastSlash = $(this).attr('src').lastIndexOf('/');
    183     var imgPath = $(this).attr('src').substring(0, lastSlash+1);
    184     $(this).attr('src', imgPath + imgName);
    185   });
    186 }
    187 
    188 /** When the doc is ready, find the inputs and color the input grey if the value is the example
    189     text. This is necessary to handle back-navigation, which can auto-fill the form with previous
    190     values (and text should not be grey) */
    191 $(document).ready(function() {
    192   $(".button-form input.text").each(function(index) {
    193     if ($(this).val() == $(this).attr("default")) {
    194       $(this).css("color","#ccc");
    195     } else {
    196       /* This is necessary to handle back-navigation to the page after form was filled */
    197       $('input[type="text"]:not(input[name='+this.name+'])',
    198               this.parentNode).attr('disabled','true');
    199       $('#'+this.name+'-clear').show();
    200     }
    201   });
    202 });
    203 
    204 </script>
    205 
    206 <form class="button-form">
    207   <label class="block" for="locale">Language:</label>
    208   <select id="locale" style="display:block;float:left;margin:0"
    209           onchange="changeBadgeLang()">
    210     <option title="Afrikaans"
    211             value="af">Afrikaans</option>
    212     <option title="Arabic"
    213             value="ar"></option>
    214     <option title="Belarusian"
    215             value="be"></option>
    216     <option title="Bulgarian"
    217             value="bg"></option>
    218     <option title="Catalan"
    219             value="ca">Catal</option>
    220     <option title="Chinese (China)"
    221             value="zh-cn"> ()</option>
    222     <option title="Chinese (Hong Kong)"
    223             value="zh-hk"></option>
    224     <option title="Chinese (Taiwan)"
    225             value="zh-tw"> ()</option>
    226     <option title="Croatian"
    227             value="hr">Hrvatski</option>
    228     <option title="Czech"
    229             value="cs">esky</option>
    230     <option title="Danish"
    231             value="da">Dansk</option>
    232     <option title="Dutch"
    233             value="nl">Nederlands</option>
    234     <option title="Estonian"
    235             value="et">Eesti</option>
    236     <option title="Farsi - Persian"
    237             value="fa"></option>
    238     <option title="Filipino"
    239             value="fil">Tagalog</option>
    240     <option title="Finnish"
    241             value="fi">Suomi</option>
    242     <option title="French"
    243             value="fr">Franais</option>
    244     <option title="German"
    245             value="de">Deutsch</option>
    246     <option title="Greek"
    247             value="el"></option>
    248     <option title="English"
    249             value="en" selected="true">English</option>
    250 <!--
    251     <option title="Hebrew"
    252             value="iw-he"></option>
    253 -->
    254     <option title="Hungarian"
    255             value="hu">Magyar</option>
    256     <option title="Indonesian"
    257             value="id-in">Bahasa Indonesia</option>
    258     <option title="Italian"
    259             value="it">Italiano</option>
    260     <option title="Japanese"
    261             value="ja"></option>
    262     <option title="Korean"
    263             value="ko"></option>
    264     <option title="Latvian"
    265             value="lv">Latvieu</option>
    266     <option title="Lithuanian"
    267             value="lt">Lietuvikai</option>
    268     <option title="Malay"
    269             value="ms">Bahasa Melayu</option>
    270     <option title="Norwegian"
    271             value="no">Norsk (bokml)</option>
    272     <option title="Polish"
    273             value="pl">Polski</option>
    274     <option title="Portuguese (Brazil)"
    275             value="pt-br">Portugus (Brasil)</option>
    276     <option title="Portuguese (Portugal)"
    277             value="pt-pt">Portugus (Portugal)</option>
    278     <option title="Romanian"
    279             value="ro">Romn</option>
    280     <option title="Russian"
    281             value="ru"></option>
    282     <option title="Serbian"
    283             value="sr"> / srpski</option>
    284     <option title="Slovak"
    285             value="sk">Slovenina</option>
    286     <option title="Slovenian"
    287             value="sl">Slovenina</option>
    288     <option title="Spanish (Spain)"
    289             value="es">Espaol (Espaa)</option>
    290     <option title="Spanish (Latin America)"
    291             value="es-419">Espaol (Latinoamrica)</option>
    292     <option title="Swedish"
    293             value="sv">Svenska</option>
    294     <option title="Swahili"
    295             value="sw">Kiswahili</option>
    296     <option title="Thai"
    297             value="th"></option>
    298     <option title="Turkish"
    299             value="tr">Trke</option>
    300     <option title="Ukrainian"
    301             value="uk"></option>
    302     <option title="Vietnamese"
    303             value="vi">Ting Vit</option>
    304     <option title="Zulu"
    305             value="zu">isiZulu</option>
    306   </select>
    307   <p style="clear:both;margin:0">&nbsp;</p>
    308   <label class="block" for="package" style="clear:left">Package name:</label>
    309   <input class="text" type="text" id="package" name="package"
    310          value="com.example.android"
    311          default="com.example.android"
    312          onfocus="onInputFocus(this, 'com.example.android')"
    313          onblur="onInputBlur(this, 'com.example.android')"
    314          onkeyup="return onTextEntered(event, this.parentNode, this)"/>&nbsp;
    315          <a id="package-clear" style="display:none" href="#"
    316             onclick="return clearLabel('package','com.example.android');">clear</a>
    317   <p style="clear:both;margin:0">&nbsp;<em>or</em></p>
    318   <label class="block" style="margin-top:5px" for="publisher">Publisher&nbsp;name:</label>
    319   <input class="text" type="text" id="publisher" name="publisher"
    320          value="Example, Inc."
    321          default="Example, Inc."
    322          onfocus="onInputFocus(this, 'Example, Inc.')"
    323          onblur="onInputBlur(this, 'Example, Inc.')"
    324          onkeyup="return onTextEntered(event, this.parentNode, this)"/>&nbsp;
    325          <a id="publisher-clear" style="display:none" href="#"
    326             onclick="return clearLabel('publisher','Example, Inc.');">clear</a>
    327          <br/><br/>
    328 
    329 
    330 <div class="button-row app">
    331   <input type="radio" name="buttonStyle" value="_app_rgb_wo_45" id="ws" />
    332     <label for="ws"><img src="{@docRoot}images/brand/en_app_rgb_wo_45.png"
    333 alt="Android app on Google Play (small)" /></label>
    334     &nbsp;&nbsp;&nbsp;&nbsp;
    335   <input type="radio" name="buttonStyle" value="_app_rgb_wo_60" id="wm" />
    336     <label for="wm"><img src="{@docRoot}images/brand/en_app_rgb_wo_60.png"
    337 alt="Android app on Google Play (large)" /></label>
    338 </div>
    339 
    340 <div class="button-row">
    341   <input type="radio" name="buttonStyle" value="_generic_rgb_wo_45" id="ns" checked="checked" />
    342     <label for="ns"><img src="{@docRoot}images/brand/en_generic_rgb_wo_45.png"
    343 alt="Get it on Google Play (small)" /></label>
    344     &nbsp;&nbsp;&nbsp;&nbsp;
    345   <input type="radio" name="buttonStyle" value="_generic_rgb_wo_60" id="nm" />
    346     <label for="nm"><img src="{@docRoot}images/brand/en_generic_rgb_wo_60.png"
    347 alt="Get it on Google Play (large)" /></label>
    348 </div>
    349 
    350   <input class="button" onclick="return buildButton(this.parentNode);"
    351     type="button" value="Build my badge" style="padding:10px" />
    352   <br/>
    353 </form>
    354 
    355 <div id="preview" style="display:none">
    356   <p>Copy and paste this HTML into your web site:</p>
    357   <textarea id="snippet" cols="100" rows="5" onclick="this.select()"
    358 style="font-family:monospace;background-color:#efefef;padding:5px;display:none;margin-bottom:1em">
    359   </textarea >
    360 
    361 <p>Try it out:</p>
    362 <div id="button-preview" style="margin-top:1em"></div>
    363 </div>
    364