summaryrefslogtreecommitdiffstats
path: root/docs/html/distribute/googleplay/promote/badges.jd
blob: 23a116d62b0005bcc12d45d9a7dbeb65d04dee30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
page.title=Google Play Badges
@jd:body

<p itemprop="description">Google Play badges allow you to promote your app with official branding
in your online ads, promotional materials, or anywhere else you want a link to your app.</p>

<p>In the form below,
input your app's package name or publisher name, choose the badge style,
click <em>Build my badge</em>, then paste the HTML into your web content.</p>

<p>If you're creating a promotional web page for your app, you should also use the
<a href="{@docRoot}distribute/promote/device-art.html">Device Art Generator</a>, which quickly
wraps your screenshots in real device artwork.</p>

<p>For guidelines when using the Google Play badge and other brand assets,
see the <a href="{@docRoot}distribute/googleplay/promote/brand.html#brand-google_play">Brand
Guidelines</a>.</p>

<style type="text/css">

form.button-form {
  margin-top:2em;
}

/* the label and input elements are blocks that float left in order to
   keep the left edgets of the input aligned, and IE 6/7 do not fully support "inline-block" */
label.block {
  display: block;
  float: left;
  width: 100px;
  padding-right: 10px;
}

input.text {
  display: block;
  float: left;
  width: 250px;
}

div.button-row {
  white-space:nowrap;
  min-height:80px;
}

div.button-row input {
  vertical-align:middle;
  margin:0 5px 0 0;
}

#jd-content div.button-row img {
  margin: 0;
  vertical-align:middle;
}

</style>

<script type="text/javascript">

// locales for which we have the 'app' badge
var APP_LANGS = ['it','pt-br','pt-pt','nl','ko','ja','fr','es','es-419','en','de'];

// variables for creating 'try it out' demo button
var imagePath = "https://developer.android.com/images/brand/"
var linkStart = "<a href=\"https://play.google.com/store/";
var imageStart = "\">\n"
        + "  <img alt=\"";
  // leaves opening for the alt text value
var imageSrc = "\"\n       src=\"" + imagePath;
  // leaves opening for the image file name
var imageEnd = ".png\" />\n</a>";

// variables for creating code snippet
var linkStartCode = "&lt;a href=\"https://play.google.com/store/";
var imageStartCode = "\"&gt;\n"
        + "  &lt;img alt=\"";
  // leaves opening for the alt text value
var imageSrcCode = "\"\n       src=\"" + imagePath;
  // leaves opening for the image file name
var imageEndCode = ".png\" />\n&lt;/a>";

/** Generate the HTML snippet and demo based on form values */
function buildButton(form) {
  var lang = $('#locale option:selected').val();
  var selectedValue = lang + $('form input[type=radio]:checked').val();
  var altText = selectedValue.indexOf("generic") != -1 ? "Get it on Google Play" : "Android app on Google Play";

  if (form["package"].value != "com.example.android") {
    $("#preview").show();
    $("#snippet").show().html(linkStartCode + "apps/details?id=" + form["package"].value
            + imageStartCode + altText + imageSrcCode
            + selectedValue + imageEndCode);
    $("#button-preview").html(linkStart + "apps/details?id=" + form["package"].value
            + imageStart + altText + imageSrc
            + selectedValue + imageEnd);
            
    // Send the event to Analytics
    _gaq.push(['_trackEvent', 'Distribute', 'Create Google Play Badge', 'Package ' + selectedValue]);
  } else if (form["publisher"].value != "Example, Inc.") {
    $("#preview").show();
    $("#snippet").show().html(linkStartCode + "search?q=pub:" + form["publisher"].value
            + imageStartCode + altText + imageSrcCode
            + selectedValue + imageEndCode);
    $("#button-preview").html(linkStart + "search?q=pub:" + form["publisher"].value
            + imageStart + altText + imageSrc
            + selectedValue + imageEnd);
   
    // Send the event to Analytics
    _gaq.push(['_trackEvent', 'Distribute', 'Create Google Play Badge', 'Publisher ' + selectedValue]);
  } else {
    alert("Please enter your package name or publisher name");
  }
  return false;
}

/** Listen for Enter key */
function onTextEntered(event, form, me) {
  // 13 = enter
  if (event.keyCode == 13) {
    buildButton(form);
  }
}

/** When input is focused, remove example text and disable other input */
function onInputFocus(object, example) {
  if (object.value == example) {
    $(object).val('').css({'color' : '#000'});
  }
  $('input[type="text"]:not(input[name='+object.name+'])',
          object.parentNode).attr('disabled','true');
  $('#'+object.name+'-clear').show();
}

/** When input is blured, restore example text if appropriate and enable other input */
function onInputBlur(object, example) {
  if (object.value.length < 1) {
    $(object).attr('value',example).css({'color':'#ccc'});
    $('input[type="text"]', object.parentNode).removeAttr('disabled');
    $('#'+object.name+'-clear').hide();
  }
}

/** Clear the form to start over */
function clearLabel(id, example) {
  $("#preview").hide();
  $('#'+id+'').html('').attr('value',example).css({'color':'#ccc'});
  $('input[type="text"]', $('#'+id+'').parent()).removeAttr('disabled');
  $('#'+id+'-clear').hide();
  return false;
}

/** Switch the badge urls for selected language */
function changeBadgeLang() {
  var lang = $('#locale option:selected').val();
  
  // check if we have the 'app' badge for this lang and show notice if not
  $("div.button-row.error").remove();  // remove any existing instance of error message
  if ($.inArray(lang,APP_LANGS) == -1) {
    $("div.button-row.app").hide();
    $("div.button-row.app").after('<div class="button-row error"><p class="note" style="margin:1em 0 -1em">'
        + 'Sorry, we currently don\'t have the '
        + '<em>Android app on Google Play</em> badge translated for '
        + $("select#locale option[value="+lang+"]").attr("title")
        + '.<br>Please check back later or instead use the <em>Get it on Google Play</em> badge below.'
        + '</p></div>');
  } else {
    $("div.button-row.app").show(); // show the 'app' badge row
  }
  
  $('.button-row img').each(function() {
    var id = $(this).parent().attr('for');
    var imgName = lang + $('input#'+id).attr('value') + '.png';
    var lastSlash = $(this).attr('src').lastIndexOf('/');
    var imgPath = $(this).attr('src').substring(0, lastSlash+1);
    $(this).attr('src', imgPath + imgName);
  });
}

/** When the doc is ready, find the inputs and color the input grey if the value is the example
    text. This is necessary to handle back-navigation, which can auto-fill the form with previous
    values (and text should not be grey) */
$(document).ready(function() {
  $(".button-form input.text").each(function(index) {
    if ($(this).val() == $(this).attr("default")) {
      $(this).css("color","#ccc");
    } else {
      /* This is necessary to handle back-navigation to the page after form was filled */
      $('input[type="text"]:not(input[name='+this.name+'])',
              this.parentNode).attr('disabled','true');
      $('#'+this.name+'-clear').show();
    }
  });
});

</script>

<form class="button-form">
  <label class="block" for="locale">Language:</label>
  <select id="locale" style="display:block;float:left;margin:0"
          onchange="changeBadgeLang()">
    <option title="Afrikaans"
            value="af">Afrikaans</option>
<!--
    <option title="Arabic"
            value="ar">العربية</option>
-->
    <option title="Belarusian"
            value="be">Беларуская</option>
    <option title="Bulgarian"
            value="bg">Български</option>
    <option title="Catalan"
            value="ca">Català</option>
    <option title="Chinese (China)"
            value="zh-cn">中文 (中国)</option>
    <option title="Chinese (Hong Kong)"
            value="zh-hk">中文(香港)</option>
    <option title="Chinese (Taiwan)"
            value="zh-tw">中文 (台灣)</option>
    <option title="Croatian"
            value="hr">Hrvatski</option>
    <option title="Czech"
            value="cs">Česky</option>
    <option title="Danish"
            value="da">Dansk</option>
    <option title="Dutch"
            value="nl">Nederlands</option>
    <option title="Estonian"
            value="et">Eesti</option>
    <option title="Farsi - Persian"
            value="fa">فارسی</option>
    <option title="Filipino"
            value="fil">Tagalog</option>
    <option title="Finnish"
            value="fi">Suomi</option>
    <option title="French"
            value="fr">Français</option>
    <option title="German"
            value="de">Deutsch</option>
    <option title="Greek"
            value="el">Ελληνικά</option>
    <option title="English"
            value="en" selected="true">English</option>
<!--
    <option title="Hebrew"
            value="iw-he">עברית</option>
-->
    <option title="Hungarian"
            value="hu">Magyar</option>
    <option title="Indonesian"
            value="id-in">Bahasa Indonesia</option>
    <option title="Italian"
            value="it">Italiano</option>
    <option title="Japanese"
            value="ja">日本語</option>
    <option title="Korean"
            value="ko">한국어</option>
    <option title="Latvian"
            value="lv">Latviešu</option>
    <option title="Lithuanian"
            value="lt">Lietuviškai</option>
    <option title="Malay"
            value="ms">Bahasa Melayu</option>
    <option title="Norwegian"
            value="no">Norsk (bokmål)‎</option>
    <option title="Polish"
            value="pl">Polski</option>
    <option title="Portuguese (Brazil)"
            value="pt-br">Português (Brasil)</option>
    <option title="Portuguese (Portugal)"
            value="pt-pt">Português (Portugal)</option>
    <option title="Romanian"
            value="ro">Română</option>
    <option title="Russian"
            value="ru">Русский</option>
    <option title="Serbian"
            value="sr">Српски / srpski</option>
    <option title="Slovak"
            value="sk">Slovenčina</option>
    <option title="Slovenian"
            value="sl">Slovenščina</option>
    <option title="Spanish (Spain)"
            value="es">Español (España)</option>
    <option title="Spanish (Latin America)"
            value="es-419">Español (Latinoamérica)</option>
    <option title="Swedish"
            value="sv">Svenska</option>
    <option title="Swahili"
            value="sw">Kiswahili</option>
    <option title="Thai"
            value="th">ไทย</option>
    <option title="Turkish"
            value="tr">Türkçe</option>
    <option title="Ukrainian"
            value="uk">Українська</option>
    <option title="Vietnamese"
            value="vi">Tiếng Việt</option>
    <option title="Zulu"
            value="zu">isiZulu</option>
  </select>
  <p style="clear:both;margin:0">&nbsp;</p>
  <label class="block" for="package" style="clear:left">Package name:</label>
  <input class="text" type="text" id="package" name="package"
         value="com.example.android"
         default="com.example.android"
         onfocus="onInputFocus(this, 'com.example.android')"
         onblur="onInputBlur(this, 'com.example.android')"
         onkeyup="return onTextEntered(event, this.parentNode, this)"/>&nbsp;
         <a id="package-clear" style="display:none" href="#"
            onclick="return clearLabel('package','com.example.android');">clear</a>
  <p style="clear:both;margin:0">&nbsp;<em>or</em></p>
  <label class="block" style="margin-top:5px" for="publisher">Publisher&nbsp;name:</label>
  <input class="text" type="text" id="publisher" name="publisher"
         value="Example, Inc."
         default="Example, Inc."
         onfocus="onInputFocus(this, 'Example, Inc.')"
         onblur="onInputBlur(this, 'Example, Inc.')"
         onkeyup="return onTextEntered(event, this.parentNode, this)"/>&nbsp;
         <a id="publisher-clear" style="display:none" href="#"
            onclick="return clearLabel('publisher','Example, Inc.');">clear</a>
         <br/><br/>


<div class="button-row app">
  <input type="radio" name="buttonStyle" value="_app_rgb_wo_45" id="ws" />
    <label for="ws"><img src="{@docRoot}images/brand/en_app_rgb_wo_45.png"
alt="Android app on Google Play (small)" /></label>
    &nbsp;&nbsp;&nbsp;&nbsp;
  <input type="radio" name="buttonStyle" value="_app_rgb_wo_60" id="wm" />
    <label for="wm"><img src="{@docRoot}images/brand/en_app_rgb_wo_60.png"
alt="Android app on Google Play (large)" /></label>
</div>

<div class="button-row">
  <input type="radio" name="buttonStyle" value="_generic_rgb_wo_45" id="ns" checked="checked" />
    <label for="ns"><img src="{@docRoot}images/brand/en_generic_rgb_wo_45.png"
alt="Get it on Google Play (small)" /></label>
    &nbsp;&nbsp;&nbsp;&nbsp;
  <input type="radio" name="buttonStyle" value="_generic_rgb_wo_60" id="nm" />
    <label for="nm"><img src="{@docRoot}images/brand/en_generic_rgb_wo_60.png"
alt="Get it on Google Play (large)" /></label>
</div>

  <input class="button" onclick="return buildButton(this.parentNode);"
    type="button" value="Build my badge" style="padding:10px" />
  <br/>
</form>

<div id="preview" style="display:none">
  <p>Copy and paste this HTML into your web site:</p>
  <textarea id="snippet" cols="100" rows="5" onclick="this.select()"
style="font-family:monospace;background-color:#efefef;padding:5px;display:none;margin-bottom:1em">
  </textarea >

<p>Try it out:</p>
<div id="button-preview" style="margin-top:1em"></div>
</div>