├── adcatalog
├── res
│ ├── drawable
│ │ ├── icon.png
│ │ ├── honeycomblogosmall.png
│ │ ├── backrepeat.xml
│ │ └── gamelevelbuttonbackground.xml
│ ├── layout
│ │ ├── tabred.xml
│ │ ├── tabblue.xml
│ │ ├── tabgreen.xml
│ │ ├── openglviewexample.xml
│ │ ├── video.xml
│ │ ├── scrollviewexample.xml
│ │ ├── videopreroll.xml
│ │ ├── videoexample.xml
│ │ ├── main.xml
│ │ ├── advancedlayouts.xml
│ │ ├── tabviewexample.xml
│ │ ├── pageswipe.xml
│ │ ├── banners.xml
│ │ ├── gamelevels.xml
│ │ └── interstitials.xml
│ ├── anim
│ │ ├── push_right_in.xml
│ │ ├── push_right_out.xml
│ │ ├── push_left_in.xml
│ │ └── push_left_out.xml
│ ├── layout-xlarge
│ │ ├── openglviewexample.xml
│ │ ├── scrollviewexample.xml
│ │ └── banners.xml
│ └── values
│ │ └── strings.xml
├── project.properties
├── src
│ └── com
│ │ └── google
│ │ └── ad
│ │ └── catalog
│ │ ├── layouts
│ │ ├── Video.java
│ │ ├── ScrollViewExample.java
│ │ ├── ListViewExample.java
│ │ ├── AdvancedLayouts.java
│ │ ├── OpenGLViewExample.java
│ │ ├── Cube.java
│ │ ├── CubeRenderer.java
│ │ ├── ListViewExampleListAdapter.java
│ │ └── TabbedViewExample.java
│ │ ├── Constants.java
│ │ ├── AdCatalogUtils.java
│ │ ├── GameLevels.java
│ │ ├── LogAndToastAdListener.java
│ │ ├── PageSwipe.java
│ │ ├── VideoPreroll.java
│ │ ├── TrackingVideoView.java
│ │ ├── Interstitials.java
│ │ ├── Banners.java
│ │ ├── AdCatalog.java
│ │ ├── VideoPlayer.java
│ │ └── VideoExample.java
├── AndroidManifest.xml
└── COPYING
└── README.md
/adcatalog/res/drawable/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/corymsmith/googleads-mobile-android-adcatalog/master/adcatalog/res/drawable/icon.png
--------------------------------------------------------------------------------
/adcatalog/res/drawable/honeycomblogosmall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/corymsmith/googleads-mobile-android-adcatalog/master/adcatalog/res/drawable/honeycomblogosmall.png
--------------------------------------------------------------------------------
/adcatalog/res/drawable/backrepeat.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/adcatalog/res/drawable/gamelevelbuttonbackground.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/adcatalog/res/layout/tabred.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/adcatalog/res/layout/tabblue.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/adcatalog/res/layout/tabgreen.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/adcatalog/res/anim/push_right_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/adcatalog/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-19
12 | android.library.reference.1=../../libproject/google-play-services_lib
13 |
--------------------------------------------------------------------------------
/adcatalog/res/layout/openglviewexample.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
15 |
16 |
--------------------------------------------------------------------------------
/adcatalog/res/layout-xlarge/openglviewexample.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
15 |
16 |
--------------------------------------------------------------------------------
/adcatalog/res/layout/video.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
13 |
17 |
20 |
21 |
--------------------------------------------------------------------------------
/adcatalog/res/anim/push_right_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/adcatalog/res/anim/push_left_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/adcatalog/res/anim/push_left_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/adcatalog/res/layout/scrollviewexample.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
13 |
16 |
17 |
18 |
24 |
25 |
--------------------------------------------------------------------------------
/adcatalog/res/layout-xlarge/scrollviewexample.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
13 |
17 |
18 |
19 |
25 |
26 |
--------------------------------------------------------------------------------
/adcatalog/res/layout/videopreroll.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
13 |
18 |
23 |
28 |
29 |
--------------------------------------------------------------------------------
/adcatalog/res/layout/videoexample.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
10 |
14 |
17 |
23 |
24 |
28 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/adcatalog/src/com/google/ad/catalog/layouts/Video.java:
--------------------------------------------------------------------------------
1 | package com.google.ad.catalog.layouts;
2 |
3 | import com.google.ad.catalog.R;
4 | import com.google.ad.catalog.VideoExample;
5 |
6 | import android.app.Activity;
7 | import android.content.Intent;
8 | import android.os.Bundle;
9 | import android.view.View;
10 | import android.widget.AdapterView;
11 | import android.widget.AdapterView.OnItemClickListener;
12 | import android.widget.ArrayAdapter;
13 | import android.widget.ListView;
14 |
15 | /**
16 | * Menu system for different video ad types.
17 | */
18 | public class Video extends Activity implements OnItemClickListener {
19 | /** Called when the activity is first created. */
20 | @Override
21 | public void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.video);
24 | ListView adList = (ListView) findViewById(R.id.adList);
25 | ArrayAdapter adListAdapter = new ArrayAdapter(this,
26 | android.R.layout.simple_list_item_1,
27 | getResources().getStringArray(R.array.video_ad_list));
28 | adList.setAdapter(adListAdapter);
29 | adList.setOnItemClickListener(this);
30 | }
31 |
32 | /** Handles the click event for the items in the list. */
33 | @Override
34 | public void onItemClick(AdapterView> parent, View v, int position, long id) {
35 | Intent intent = new Intent(Video.this, VideoExample.class);
36 | intent.putExtra("ad_tag_index", position);
37 | startActivity(intent);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/adcatalog/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
13 |
19 |
25 |
31 |
38 |
39 |
--------------------------------------------------------------------------------
/adcatalog/res/layout/advancedlayouts.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
13 |
17 |
22 |
27 |
32 |
37 |
38 |
--------------------------------------------------------------------------------
/adcatalog/res/layout/tabviewexample.xml:
--------------------------------------------------------------------------------
1 |
6 |
11 |
14 |
19 |
23 |
27 |
28 |
29 |
36 |
37 |
--------------------------------------------------------------------------------
/adcatalog/src/com/google/ad/catalog/layouts/ScrollViewExample.java:
--------------------------------------------------------------------------------
1 | // Copyright 2012 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.google.ad.catalog.layouts;
16 |
17 | import com.google.ad.catalog.AdCatalogUtils;
18 | import com.google.ad.catalog.LogAndToastAdListener;
19 | import com.google.ad.catalog.R;
20 | import com.google.android.gms.ads.AdView;
21 |
22 | import android.app.Activity;
23 | import android.os.Bundle;
24 |
25 | /**
26 | * Example of a ScrollView with an AdMob banner.
27 | *
28 | * @author api.eleichtenschl@gmail.com (Eric Leichtenschlag)
29 | */
30 | public class ScrollViewExample extends Activity {
31 | private AdView adView;
32 |
33 | /** Called when the activity is first created. */
34 | @Override
35 | public void onCreate(Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | setContentView(R.layout.scrollviewexample);
38 |
39 | adView = (AdView) findViewById(R.id.adView);
40 | adView.setAdListener(new LogAndToastAdListener(this));
41 | adView.loadAd(AdCatalogUtils.createAdRequest());
42 | }
43 |
44 | /** Overwrite the onDestroy() method to dispose of banners first. */
45 | @Override
46 | public void onDestroy() {
47 | if (adView != null) {
48 | adView.destroy();
49 | }
50 | super.onDestroy();
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/adcatalog/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
8 |
9 |
10 |
11 |
13 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/adcatalog/src/com/google/ad/catalog/Constants.java:
--------------------------------------------------------------------------------
1 | // Copyright 2011, Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.google.ad.catalog;
16 |
17 | import android.content.Context;
18 |
19 | /**
20 | * This class holds constant values for publisher ID and preferences keys.
21 | *
22 | * @author api.eleichtenschl@gmail.com (Eric Leichtenschlag)
23 | */
24 | public final class Constants {
25 | /** The AdMob publisher ID. */
26 | private static String admobId = null;
27 |
28 | /** Preferences keys. */
29 | public static final String PREFS_NAME = "AdExamplesPrefs";
30 | public static final String PREFS_SPLASH_KEY = "loadSplashInterstitial";
31 |
32 | /** Video links. */
33 | public static final String EARTHQUAKE_LINK = "http://www.youtube.com/watch?v=SZ-ZRhxAINA";
34 | public static final String FILL_IN_THE_BLANKS_LINK =
35 | "http://www.youtube.com/watch?v=24Ri7yZhRwM&NR=1";
36 | public static final String PACKAGE_TRACKING_LINK = "http://www.youtube.com/watch?v=jb5crXH2Cb8";
37 |
38 | /** Private constructor so that the class cannot be instantiated. */
39 | private Constants() {
40 | // This will never be called.
41 | }
42 |
43 | /** Gets the AdMob Id from the context resources. */
44 | public static String getAdmobId(Context context) {
45 | if (admobId == null) {
46 | admobId = context.getResources().getString(R.string.admob_id);
47 | }
48 | return admobId;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/adcatalog/res/layout/pageswipe.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
13 |
20 |
25 |
26 |
29 |
36 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/adcatalog/src/com/google/ad/catalog/layouts/ListViewExample.java:
--------------------------------------------------------------------------------
1 | // Copyright 2012 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.google.ad.catalog.layouts;
16 |
17 | import android.app.ListActivity;
18 | import android.os.Bundle;
19 | import android.view.View;
20 | import android.widget.ArrayAdapter;
21 | import android.widget.ListView;
22 | import android.widget.Toast;
23 |
24 | /**
25 | * Example of a ListView with embedded AdMob ads.
26 | *
27 | * @author api.rajpara@gmail.com (Raj Parameswaran)
28 | */
29 | public class ListViewExample extends ListActivity {
30 | public static final String[] LIST_ITEMS = {
31 | "Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7",
32 | "Item 8", "Item 9", "Item 10", "Item 11", "Item 12", "Item 13", "Item 14",
33 | "Item 15", "Item 16", "Item 17", "Item 18", "Item 19", "Item 20", "Item 21"
34 | };
35 |
36 | @Override
37 | public void onCreate(Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 |
40 | // Set list adapter to be the custom ListViewExampleListAdapter.
41 | ListViewExampleListAdapter adapter = new ListViewExampleListAdapter(
42 | this, new ArrayAdapter(this, android.R.layout.simple_list_item_1, LIST_ITEMS));
43 | setListAdapter(adapter);
44 | }
45 |
46 | @Override
47 | protected void onListItemClick(ListView listView, View view, int position, long id) {
48 | String item = (String) getListAdapter().getItem(position);
49 | // Clicking an item should bring up toast, different from clicking ad.
50 | Toast.makeText(this, item + " selected", Toast.LENGTH_LONG).show();
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/adcatalog/src/com/google/ad/catalog/layouts/AdvancedLayouts.java:
--------------------------------------------------------------------------------
1 | // Copyright 2012, Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.google.ad.catalog.layouts;
16 |
17 | import com.google.ad.catalog.R;
18 |
19 | import android.app.Activity;
20 | import android.content.Intent;
21 | import android.os.Bundle;
22 | import android.view.View;
23 | import android.view.View.OnClickListener;
24 |
25 | /**
26 | * Menu system for different ad layouts.
27 | *
28 | * @author api.eleichtenschl@gmail.com (Eric Leichtenschlag)
29 | */
30 | public class AdvancedLayouts extends Activity implements OnClickListener {
31 | /** Called when the activity is first created. */
32 | @Override
33 | public void onCreate(Bundle savedInstanceState) {
34 | super.onCreate(savedInstanceState);
35 | setContentView(R.layout.advancedlayouts);
36 | }
37 |
38 | /** Handles the on click events for each button. */
39 | @Override
40 | public void onClick(View view) {
41 | final int id = view.getId();
42 | Intent intent = null;
43 | switch (id) {
44 | // Uncomment corresponding intent when implementing an example.
45 | case R.id.tabbedView:
46 | intent = new Intent(AdvancedLayouts.this, TabbedViewExample.class);
47 | break;
48 | case R.id.listView:
49 | intent = new Intent(AdvancedLayouts.this, ListViewExample.class);
50 | break;
51 | case R.id.openGLView:
52 | intent = new Intent(AdvancedLayouts.this, OpenGLViewExample.class);
53 | break;
54 | case R.id.scrollView:
55 | intent = new Intent(AdvancedLayouts.this, ScrollViewExample.class);
56 | break;
57 | }
58 | if (intent != null) {
59 | startActivity(intent);
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/adcatalog/res/layout/banners.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
14 |
20 |
26 |
34 |
41 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/adcatalog/src/com/google/ad/catalog/AdCatalogUtils.java:
--------------------------------------------------------------------------------
1 | // Copyright 2012 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.google.ad.catalog;
16 |
17 | import com.google.android.gms.ads.AdRequest;
18 |
19 | import android.content.Context;
20 | import android.content.res.Configuration;
21 |
22 | /**
23 | * Utilities class for some common tasks within Ad Catalog.
24 | *
25 | * @author api.eleichtenschl@gmail.com (Eric Leichtenschlag)
26 | */
27 | public class AdCatalogUtils {
28 |
29 | public static final String LOG_TAG = "AdCatalog";
30 |
31 | /**
32 | * Prevent instantiation.
33 | */
34 | private AdCatalogUtils() {
35 | // Empty.
36 | }
37 |
38 | /**
39 | * Determines whether or not the device has an extra large screen.
40 | *
41 | * @param context The Android context.
42 | * @return boolean value indicating if the screen size is extra large.
43 | */
44 | public static boolean isExtraLargeScreen(Context context) {
45 | int screenSizeMask = context.getResources().getConfiguration().screenLayout
46 | & Configuration.SCREENLAYOUT_SIZE_MASK;
47 | if (screenSizeMask == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
48 | return true;
49 | } else {
50 | return false;
51 | }
52 | }
53 |
54 | /**
55 | * Creates an ad request. It will be a test request if test mode is enabled.
56 | *
57 | * @return An AdRequest to use when loading an ad.
58 | */
59 | public static AdRequest createAdRequest() {
60 | AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
61 | if (AdCatalog.isTestMode) {
62 | // This call will add the emulator as a test device. To add a physical
63 | // device for testing, pass in your hashed device ID, which can be found
64 | // in the LogCat output when loading an ad on your device.
65 | adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
66 | }
67 | return adRequestBuilder.build();
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/adcatalog/src/com/google/ad/catalog/GameLevels.java:
--------------------------------------------------------------------------------
1 | // Copyright 2011 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.google.ad.catalog;
16 |
17 | import com.google.android.gms.ads.InterstitialAd;
18 |
19 | import android.app.Activity;
20 | import android.os.Bundle;
21 | import android.view.View;
22 | import android.view.View.OnClickListener;
23 | import android.widget.ViewFlipper;
24 |
25 | /**
26 | * This activity shows an example of how to display an interstitial in between
27 | * game levels.
28 | *
29 | * @author api.eleichtenschl@gmail.com (Eric Leichtenschlag)
30 | */
31 | public class GameLevels extends Activity implements OnClickListener {
32 | private InterstitialAd interstitial;
33 |
34 | /** Called when the activity is first created. */
35 | @Override
36 | public void onCreate(Bundle savedInstanceState) {
37 | super.onCreate(savedInstanceState);
38 | setContentView(R.layout.gamelevels);
39 |
40 | // Start loading the interstitial.
41 | interstitial = new InterstitialAd(this);
42 | interstitial.setAdUnitId(Constants.getAdmobId(this));
43 | interstitial.setAdListener(new LogAndToastAdListener(this) {
44 | @Override
45 | public void onAdClosed() {
46 | super.onAdClosed();
47 | final ViewFlipper viewFlipper = (ViewFlipper) findViewById(R.id.levelFlipper);
48 | viewFlipper.showNext();
49 | }
50 | });
51 | interstitial.loadAd(AdCatalogUtils.createAdRequest());
52 | }
53 |
54 | /** Handles the on click events for each button. */
55 | @Override
56 | public void onClick(View view) {
57 | final int id = view.getId();
58 | switch (id) {
59 | case R.id.gameNextButton:
60 | if (interstitial.isLoaded()) {
61 | interstitial.show();
62 | } else {
63 | interstitial.loadAd(AdCatalogUtils.createAdRequest());
64 | final ViewFlipper viewFlipper = (ViewFlipper) findViewById(R.id.levelFlipper);
65 | viewFlipper.showNext();
66 | }
67 | break;
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/adcatalog/res/layout/gamelevels.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
14 |
23 |
24 |
28 |
37 |
38 |
39 |
47 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/adcatalog/res/layout/interstitials.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
13 |
17 |
22 |
27 |
32 |
37 |
43 |
49 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/adcatalog/src/com/google/ad/catalog/layouts/OpenGLViewExample.java:
--------------------------------------------------------------------------------
1 | // Copyright 2012, Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.google.ad.catalog.layouts;
16 |
17 | import com.google.ad.catalog.AdCatalogUtils;
18 | import com.google.ad.catalog.R;
19 | import com.google.android.gms.ads.AdView;
20 |
21 | import android.app.Activity;
22 | import android.opengl.GLSurfaceView;
23 | import android.os.Bundle;
24 | import android.view.ViewGroup.LayoutParams;
25 | import android.widget.RelativeLayout;
26 |
27 | /**
28 | * Example of an OpenGL view with an AdMob banner.
29 | *
30 | * @author api.eleichtenschl@gmail.com (Eric Leichtenschlag)
31 | */
32 | public class OpenGLViewExample extends Activity {
33 | private GLSurfaceView glSurfaceView;
34 |
35 | @Override
36 | protected void onCreate(Bundle savedInstanceState) {
37 | super.onCreate(savedInstanceState);
38 | setContentView(R.layout.openglviewexample);
39 |
40 | // Load the AdView with a request.
41 | AdView adView = (AdView) findViewById(R.id.openGLAdView);
42 | adView.loadAd(AdCatalogUtils.createAdRequest());
43 |
44 | // Initialize the GLSurfaceView and add it to the layout above the AdView.
45 | this.glSurfaceView = new GLSurfaceView(this);
46 | this.glSurfaceView.setRenderer(new CubeRenderer(true));
47 | RelativeLayout layout = (RelativeLayout) findViewById(R.id.openGLLayout);
48 | RelativeLayout.LayoutParams params =
49 | new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
50 | LayoutParams.MATCH_PARENT);
51 | params.addRule(RelativeLayout.ABOVE, R.id.openGLAdView);
52 | layout.addView(this.glSurfaceView, params);
53 | }
54 |
55 | @Override
56 | protected void onResume() {
57 | // Ideally a game should implement onResume() and onPause()
58 | // to take appropriate action when the activity looses focus.
59 | super.onResume();
60 | this.glSurfaceView.onResume();
61 | }
62 |
63 | @Override
64 | protected void onPause() {
65 | // Ideally a game should implement onResume() and onPause()
66 | // to take appropriate action when the activity looses focus.
67 | super.onPause();
68 | this.glSurfaceView.onPause();
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/adcatalog/src/com/google/ad/catalog/LogAndToastAdListener.java:
--------------------------------------------------------------------------------
1 | package com.google.ad.catalog;
2 |
3 | import static com.google.ad.catalog.AdCatalogUtils.LOG_TAG;
4 |
5 | import com.google.android.gms.ads.AdListener;
6 | import com.google.android.gms.ads.AdRequest;
7 |
8 | import android.app.Activity;
9 | import android.util.Log;
10 | import android.widget.Toast;
11 |
12 | /**
13 | * This creates a common AdListener that can be used or extended
14 | * for different uses. Uses logging and toasting for each action.
15 | */
16 | public class LogAndToastAdListener extends AdListener {
17 |
18 | Activity activity;
19 |
20 | public LogAndToastAdListener(Activity activity) {
21 | this.activity = activity;
22 | }
23 |
24 | /** Called when an ad is clicked and about to return to the application. */
25 | @Override
26 | public void onAdClosed() {
27 | Log.d(LOG_TAG, "onAdClosed");
28 | Toast.makeText(activity, "onAdClosed", Toast.LENGTH_SHORT).show();
29 | }
30 |
31 | /** Called when an ad failed to load. */
32 | @Override
33 | public void onAdFailedToLoad(int error) {
34 | String message = "onAdFailedToLoad: " + getErrorReason(error);
35 | Log.d(LOG_TAG, message);
36 | Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
37 | }
38 |
39 | /**
40 | * Called when an ad is clicked and going to start a new Activity that will
41 | * leave the application (e.g. breaking out to the Browser or Maps
42 | * application).
43 | */
44 | @Override
45 | public void onAdLeftApplication() {
46 | Log.d(LOG_TAG, "onAdLeftApplication");
47 | Toast.makeText(activity, "onAdLeftApplication", Toast.LENGTH_SHORT).show();
48 | }
49 |
50 | /**
51 | * Called when an Activity is created in front of the app (e.g. an
52 | * interstitial is shown, or an ad is clicked and launches a new Activity).
53 | */
54 | @Override
55 | public void onAdOpened() {
56 | Log.d(LOG_TAG, "onAdOpened");
57 | Toast.makeText(activity, "onAdOpened", Toast.LENGTH_SHORT).show();
58 | }
59 |
60 | /** Called when an ad is loaded. */
61 | @Override
62 | public void onAdLoaded() {
63 | Log.d(LOG_TAG, "onAdLoaded");
64 | Toast.makeText(activity, "onAdLoaded", Toast.LENGTH_SHORT).show();
65 | }
66 |
67 | private String getErrorReason(int errorCode) {
68 | String errorReason = "";
69 | switch(errorCode) {
70 | case AdRequest.ERROR_CODE_INTERNAL_ERROR:
71 | errorReason = "Internal error";
72 | break;
73 | case AdRequest.ERROR_CODE_INVALID_REQUEST:
74 | errorReason = "Invalid request";
75 | break;
76 | case AdRequest.ERROR_CODE_NETWORK_ERROR:
77 | errorReason = "Network Error";
78 | break;
79 | case AdRequest.ERROR_CODE_NO_FILL:
80 | errorReason = "No fill";
81 | break;
82 | }
83 | return errorReason;
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/adcatalog/src/com/google/ad/catalog/PageSwipe.java:
--------------------------------------------------------------------------------
1 | // Copyright 2011 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.google.ad.catalog;
16 |
17 | import com.google.android.gms.ads.InterstitialAd;
18 |
19 | import android.app.Activity;
20 | import android.os.Bundle;
21 | import android.view.MotionEvent;
22 | import android.view.View;
23 | import android.view.View.OnTouchListener;
24 | import android.widget.LinearLayout;
25 | import android.widget.ViewFlipper;
26 |
27 | /**
28 | * This activity demonstrates displaying an interstitial in between page
29 | * swipes. Use case could be displaying a gallery of photos.
30 | *
31 | * @author api.eleichtenschl@gmail.com (Eric Leichtenschlag)
32 | */
33 | public class PageSwipe extends Activity implements OnTouchListener {
34 | private InterstitialAd interstitial;
35 | private float downXValue;
36 |
37 | /** Called when the activity is first created. */
38 | @Override
39 | public void onCreate(Bundle savedInstanceState) {
40 | super.onCreate(savedInstanceState);
41 | setContentView(R.layout.pageswipe);
42 |
43 | LinearLayout layout = (LinearLayout) findViewById(R.id.swipe_main);
44 | layout.setOnTouchListener(this);
45 |
46 | interstitial = new InterstitialAd(this);
47 | interstitial.setAdUnitId(Constants.getAdmobId(this));
48 | interstitial.setAdListener(new LogAndToastAdListener(this));
49 | interstitial.loadAd(AdCatalogUtils.createAdRequest());
50 | }
51 |
52 | /** Used to detect which direction a user swiped. */
53 | @Override
54 | public boolean onTouch(View view, MotionEvent event) {
55 | switch (event.getAction()) {
56 | case MotionEvent.ACTION_DOWN:
57 | downXValue = event.getX();
58 | break;
59 | case MotionEvent.ACTION_UP:
60 | float currentX = event.getX();
61 | ViewFlipper viewFlipper = (ViewFlipper) findViewById(R.id.flipper);
62 | if (downXValue < currentX) {
63 | viewFlipper.setInAnimation(view.getContext(), R.anim.push_right_in);
64 | viewFlipper.setOutAnimation(view.getContext(), R.anim.push_right_out);
65 | viewFlipper.showPrevious();
66 | showInterstitial();
67 | } else if (downXValue > currentX) {
68 | viewFlipper.setInAnimation(view.getContext(), R.anim.push_left_in);
69 | viewFlipper.setOutAnimation(view.getContext(), R.anim.push_left_out);
70 | viewFlipper.showNext();
71 | showInterstitial();
72 | }
73 | break;
74 | }
75 | return true;
76 | }
77 |
78 | /** Shows the interstitial, or loads a new interstitial if one is not ready. */
79 | public void showInterstitial() {
80 | if (interstitial.isLoaded()) {
81 | interstitial.show();
82 | } else {
83 | interstitial.loadAd(AdCatalogUtils.createAdRequest());
84 | }
85 | }
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/adcatalog/src/com/google/ad/catalog/VideoPreroll.java:
--------------------------------------------------------------------------------
1 | // Copyright 2011 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.google.ad.catalog;
16 |
17 | import com.google.android.gms.ads.InterstitialAd;
18 |
19 | import android.app.Activity;
20 | import android.content.Intent;
21 | import android.net.Uri;
22 | import android.os.Bundle;
23 | import android.view.View;
24 | import android.view.View.OnClickListener;
25 |
26 | /**
27 | * This activity features interstitial ads before going to a youtube link.
28 | *
29 | * @author api.eleichtenschl@gmail.com (Eric Leichtenschlag)
30 | */
31 | public class VideoPreroll extends Activity implements OnClickListener {
32 | private InterstitialAd interstitial;
33 | private VideoHandler videoHandler;
34 |
35 | /** Called when the activity is first created. */
36 | @Override
37 | public void onCreate(Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 | setContentView(R.layout.videopreroll);
40 |
41 | videoHandler = new VideoHandler();
42 | interstitial = new InterstitialAd(this);
43 | interstitial.setAdUnitId(Constants.getAdmobId(this));
44 | interstitial.setAdListener(videoHandler);
45 | interstitial.loadAd(AdCatalogUtils.createAdRequest());
46 | }
47 |
48 | /** Handles the on click events for each button. */
49 | @Override
50 | public void onClick(View view) {
51 | final int id = view.getId();
52 | switch (id) {
53 | case R.id.earthquake:
54 | videoHandler.setLink(Constants.EARTHQUAKE_LINK);
55 | break;
56 | case R.id.fillInTheBlanks:
57 | videoHandler.setLink(Constants.FILL_IN_THE_BLANKS_LINK);
58 | break;
59 | case R.id.packageTracking:
60 | videoHandler.setLink(Constants.PACKAGE_TRACKING_LINK);
61 | break;
62 | }
63 | if (interstitial.isLoaded()) {
64 | interstitial.show();
65 | } else {
66 | interstitial.loadAd(AdCatalogUtils.createAdRequest());
67 | videoHandler.playVideo();
68 | }
69 | }
70 |
71 | /**
72 | * This handler supports playing a video after an interstitial is displayed.
73 | *
74 | * @author api.eleichtenschl@gmail.com (Eric Leichtenschlag)
75 | */
76 | class VideoHandler extends LogAndToastAdListener {
77 | private String youtubeLink;
78 |
79 | /** Instantiates a new VideoHandler object. */
80 | public VideoHandler() {
81 | super(VideoPreroll.this);
82 | youtubeLink = "";
83 | }
84 |
85 | /** Sets the YouTube link. */
86 | public void setLink(String link) {
87 | youtubeLink = link;
88 | }
89 |
90 | /** Plays the video. */
91 | public void playVideo() {
92 | startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(youtubeLink)));
93 | }
94 |
95 | @Override
96 | public void onAdClosed() {
97 | super.onAdClosed();
98 | playVideo();
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/adcatalog/src/com/google/ad/catalog/layouts/Cube.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2007 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.ad.catalog.layouts;
18 |
19 | import java.nio.ByteBuffer;
20 | import java.nio.ByteOrder;
21 | import java.nio.IntBuffer;
22 |
23 | import javax.microedition.khronos.opengles.GL10;
24 |
25 | /**
26 | * A vertex shaded cube.
27 | */
28 | class Cube
29 | {
30 | public Cube()
31 | {
32 | int one = 0x10000;
33 | int vertices[] = {
34 | -one, -one, -one,
35 | one, -one, -one,
36 | one, one, -one,
37 | -one, one, -one,
38 | -one, -one, one,
39 | one, -one, one,
40 | one, one, one,
41 | -one, one, one,
42 | };
43 |
44 | int colors[] = {
45 | 0, 0, 0, one,
46 | one, 0, 0, one,
47 | one, one, 0, one,
48 | 0, one, 0, one,
49 | 0, 0, one, one,
50 | one, 0, one, one,
51 | one, one, one, one,
52 | 0, one, one, one,
53 | };
54 |
55 | byte indices[] = {
56 | 0, 4, 5, 0, 5, 1,
57 | 1, 5, 6, 1, 6, 2,
58 | 2, 6, 7, 2, 7, 3,
59 | 3, 7, 4, 3, 4, 0,
60 | 4, 7, 6, 4, 6, 5,
61 | 3, 0, 1, 3, 1, 2
62 | };
63 |
64 | // Buffers to be passed to gl*Pointer() functions
65 | // must be direct, i.e., they must be placed on the
66 | // native heap where the garbage collector cannot
67 | // move them.
68 | //
69 | // Buffers with multi-byte datatypes (e.g., short, int, float)
70 | // must have their byte order set to native order
71 |
72 | ByteBuffer vbb = ByteBuffer.allocateDirect(vertices.length*4);
73 | vbb.order(ByteOrder.nativeOrder());
74 | mVertexBuffer = vbb.asIntBuffer();
75 | mVertexBuffer.put(vertices);
76 | mVertexBuffer.position(0);
77 |
78 | ByteBuffer cbb = ByteBuffer.allocateDirect(colors.length*4);
79 | cbb.order(ByteOrder.nativeOrder());
80 | mColorBuffer = cbb.asIntBuffer();
81 | mColorBuffer.put(colors);
82 | mColorBuffer.position(0);
83 |
84 | mIndexBuffer = ByteBuffer.allocateDirect(indices.length);
85 | mIndexBuffer.put(indices);
86 | mIndexBuffer.position(0);
87 | }
88 |
89 | public void draw(GL10 gl)
90 | {
91 | gl.glFrontFace(GL10.GL_CW);
92 | gl.glVertexPointer(3, GL10.GL_FIXED, 0, mVertexBuffer);
93 | gl.glColorPointer(4, GL10.GL_FIXED, 0, mColorBuffer);
94 | gl.glDrawElements(GL10.GL_TRIANGLES, 36, GL10.GL_UNSIGNED_BYTE, mIndexBuffer);
95 | }
96 |
97 | private IntBuffer mVertexBuffer;
98 | private IntBuffer mColorBuffer;
99 | private ByteBuffer mIndexBuffer;
100 | }
101 |
--------------------------------------------------------------------------------
/adcatalog/src/com/google/ad/catalog/layouts/CubeRenderer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2007 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.ad.catalog.layouts;
18 |
19 | import javax.microedition.khronos.egl.EGLConfig;
20 | import javax.microedition.khronos.opengles.GL10;
21 |
22 | import android.opengl.GLSurfaceView;
23 |
24 | /**
25 | * Render a pair of tumbling cubes.
26 | */
27 |
28 | class CubeRenderer implements GLSurfaceView.Renderer {
29 | public CubeRenderer(boolean useTranslucentBackground) {
30 | mTranslucentBackground = useTranslucentBackground;
31 | mCube = new Cube();
32 | }
33 |
34 | public void onDrawFrame(GL10 gl) {
35 | /*
36 | * Usually, the first thing one might want to do is to clear
37 | * the screen. The most efficient way of doing this is to use
38 | * glClear().
39 | */
40 |
41 | gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
42 |
43 | /*
44 | * Now we're ready to draw some 3D objects
45 | */
46 |
47 | gl.glMatrixMode(GL10.GL_MODELVIEW);
48 | gl.glLoadIdentity();
49 | gl.glTranslatef(0, 0, -3.0f);
50 | gl.glRotatef(mAngle, 0, 1, 0);
51 | gl.glRotatef(mAngle*0.25f, 1, 0, 0);
52 |
53 | gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
54 | gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
55 |
56 | mCube.draw(gl);
57 |
58 | gl.glRotatef(mAngle*2.0f, 0, 1, 1);
59 | gl.glTranslatef(0.5f, 0.5f, 0.5f);
60 |
61 | mCube.draw(gl);
62 |
63 | mAngle += 1.2f;
64 | }
65 |
66 | public void onSurfaceChanged(GL10 gl, int width, int height) {
67 | gl.glViewport(0, 0, width, height);
68 |
69 | /*
70 | * Set our projection matrix. This doesn't have to be done
71 | * each time we draw, but usually a new projection needs to
72 | * be set when the viewport is resized.
73 | */
74 |
75 | float ratio = (float) width / height;
76 | gl.glMatrixMode(GL10.GL_PROJECTION);
77 | gl.glLoadIdentity();
78 | gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10);
79 | }
80 |
81 | public void onSurfaceCreated(GL10 gl, EGLConfig config) {
82 | /*
83 | * By default, OpenGL enables features that improve quality
84 | * but reduce performance. One might want to tweak that
85 | * especially on software renderer.
86 | */
87 | gl.glDisable(GL10.GL_DITHER);
88 |
89 | /*
90 | * Some one-time OpenGL initialization can be made here
91 | * probably based on features of this particular context
92 | */
93 | gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT,
94 | GL10.GL_FASTEST);
95 |
96 | if (mTranslucentBackground) {
97 | gl.glClearColor(0,0,0,0);
98 | } else {
99 | gl.glClearColor(1,1,1,1);
100 | }
101 | gl.glEnable(GL10.GL_CULL_FACE);
102 | gl.glShadeModel(GL10.GL_SMOOTH);
103 | gl.glEnable(GL10.GL_DEPTH_TEST);
104 | }
105 | private boolean mTranslucentBackground;
106 | private Cube mCube;
107 | private float mAngle;
108 | }
109 |
--------------------------------------------------------------------------------
/adcatalog/src/com/google/ad/catalog/TrackingVideoView.java:
--------------------------------------------------------------------------------
1 | // Copyright 2011 Google Inc. All Rights Reserved.
2 |
3 | package com.google.ad.catalog;
4 |
5 | import com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback;
6 |
7 | import android.content.Context;
8 | import android.media.MediaPlayer;
9 | import android.media.MediaPlayer.OnCompletionListener;
10 | import android.media.MediaPlayer.OnErrorListener;
11 | import android.util.Log;
12 | import android.widget.VideoView;
13 |
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | /**
18 | * A VideoView that intercepts various methods and reports them back to a set of
19 | * VideoAdPlayerCallbacks.
20 | */
21 | public class TrackingVideoView extends VideoView implements OnCompletionListener, OnErrorListener {
22 | /** Interface for alerting caller of video completion. */
23 | public interface CompleteCallback {
24 | public void onComplete();
25 | }
26 |
27 | private enum PlaybackState {
28 | STOPPED, PAUSED, PLAYING
29 | }
30 |
31 | private final List adCallbacks = new ArrayList(1);
32 | private CompleteCallback completeCallback;
33 | private PlaybackState state = PlaybackState.STOPPED;
34 |
35 | public TrackingVideoView(Context context) {
36 | super(context);
37 | super.setOnCompletionListener(this);
38 | super.setOnErrorListener(this);
39 | }
40 |
41 | public void setCompleteCallback(CompleteCallback callback) {
42 | this.completeCallback = callback;
43 | }
44 |
45 | public void togglePlayback() {
46 | switch(state) {
47 | case STOPPED:
48 | case PAUSED:
49 | start();
50 | break;
51 | case PLAYING:
52 | pause();
53 | break;
54 | }
55 | }
56 |
57 | @Override
58 | public void start() {
59 | super.start();
60 | PlaybackState oldState = state;
61 | state = PlaybackState.PLAYING;
62 |
63 | switch (oldState) {
64 | case STOPPED:
65 | for (VideoAdPlayerCallback callback : adCallbacks) {
66 | callback.onPlay();
67 | }
68 | break;
69 | case PAUSED:
70 | for (VideoAdPlayerCallback callback : adCallbacks) {
71 | callback.onResume();
72 | }
73 | break;
74 | default:
75 | // Already playing; do nothing.
76 | }
77 | }
78 |
79 | @Override
80 | public void pause() {
81 | super.pause();
82 | state = PlaybackState.PAUSED;
83 |
84 | for (VideoAdPlayerCallback callback : adCallbacks) {
85 | callback.onPause();
86 | }
87 | }
88 |
89 | @Override
90 | public void stopPlayback() {
91 | super.stopPlayback();
92 | onStop();
93 | }
94 |
95 | private void onStop() {
96 | state = PlaybackState.STOPPED;
97 | }
98 |
99 | @Override
100 | public void onCompletion(MediaPlayer mp) {
101 | onStop();
102 | for (VideoAdPlayerCallback callback : adCallbacks) {
103 | callback.onEnded();
104 | }
105 | completeCallback.onComplete();
106 | }
107 |
108 | @Override
109 | public boolean onError(MediaPlayer mp, int what, int extra) {
110 | for (VideoAdPlayerCallback callback : adCallbacks) {
111 | callback.onError();
112 | }
113 | onStop();
114 | // Returning true signals to MediaPlayer that we handled the error. This will prevent the
115 | // completion handler from being called.
116 | return true;
117 | }
118 |
119 | public void addCallback(VideoAdPlayerCallback callback) {
120 | adCallbacks.add(callback);
121 | }
122 |
123 | public void removeCallback(VideoAdPlayerCallback callback) {
124 | adCallbacks.remove(callback);
125 | }
126 |
127 | @Override
128 | public void setOnCompletionListener(OnCompletionListener l) {
129 | Log.e("TrackingVideoView",
130 | "Unsupported method TrackingVideoView.setOnCompletionListener. "
131 | + "Use setCompleteCallback instead");
132 | throw new UnsupportedOperationException();
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/adcatalog/src/com/google/ad/catalog/layouts/ListViewExampleListAdapter.java:
--------------------------------------------------------------------------------
1 | // Copyright 2012 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.google.ad.catalog.layouts;
16 |
17 | import com.google.ad.catalog.AdCatalogUtils;
18 | import com.google.ad.catalog.Constants;
19 | import com.google.ad.catalog.LogAndToastAdListener;
20 | import com.google.android.gms.ads.AdSize;
21 | import com.google.android.gms.ads.AdView;
22 |
23 | import android.app.Activity;
24 | import android.util.Log;
25 | import android.view.View;
26 | import android.view.ViewGroup;
27 | import android.widget.BaseAdapter;
28 |
29 | /**
30 | * Custom list adapter to embed AdMob ads in a ListView at the top
31 | * and bottom of the screen.
32 | *
33 | * @author api.rajpara@gmail.com (Raj Parameswaran)
34 | */
35 | public class ListViewExampleListAdapter extends BaseAdapter {
36 | private static final String LOGTAG = "ListViewExampleListAdapter";
37 |
38 | private final Activity activity;
39 | private final BaseAdapter delegate;
40 |
41 | public ListViewExampleListAdapter(Activity activity, BaseAdapter delegate) {
42 | this.activity = activity;
43 | this.delegate = delegate;
44 | }
45 |
46 | @Override
47 | public int getCount() {
48 | // Total count includes list items and ads.
49 | return delegate.getCount() + 2;
50 | }
51 |
52 | @Override
53 | public Object getItem(int position) {
54 | // Return null if an item is an ad. Otherwise return the delegate item.
55 | if (isItemAnAd(position)) {
56 | return null;
57 | }
58 | return delegate.getItem(getOffsetPosition(position));
59 | }
60 |
61 | @Override
62 | public long getItemId(int position) {
63 | return position;
64 | }
65 |
66 | @Override
67 | public View getView(int position, View convertView, ViewGroup parent) {
68 | if (isItemAnAd(position)) {
69 | if (convertView instanceof AdView) {
70 | Log.d(LOGTAG, "I am reusing an ad");
71 | return convertView;
72 | } else {
73 | Log.d(LOGTAG, "I am creating a new ad");
74 | AdView adView = new AdView(activity);
75 | adView.setAdUnitId(Constants.getAdmobId(activity));
76 | adView.setAdSize(AdSize.SMART_BANNER);
77 | adView.loadAd(AdCatalogUtils.createAdRequest());
78 | adView.setAdListener(new LogAndToastAdListener(activity));
79 | return adView;
80 | }
81 | } else {
82 | return delegate.getView(getOffsetPosition(position), convertView, parent);
83 | }
84 | }
85 |
86 | @Override
87 | public int getViewTypeCount() {
88 | return delegate.getViewTypeCount() + 1;
89 | }
90 |
91 | @Override
92 | public int getItemViewType(int position) {
93 | if (isItemAnAd(position)) {
94 | return delegate.getViewTypeCount();
95 | } else {
96 | return delegate.getItemViewType(getOffsetPosition(position));
97 | }
98 | }
99 |
100 | @Override
101 | public boolean areAllItemsEnabled() {
102 | return false;
103 | }
104 |
105 | @Override
106 | public boolean isEnabled(int position) {
107 | return (!isItemAnAd(position)) && delegate.isEnabled(getOffsetPosition(position));
108 | }
109 |
110 | private boolean isItemAnAd(int position) {
111 | // Place an ad at the first and last list view positions.
112 | return (position == 0 || position == (getCount() - 1));
113 | }
114 |
115 | private int getOffsetPosition(int position) {
116 | return position - 1;
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/adcatalog/src/com/google/ad/catalog/Interstitials.java:
--------------------------------------------------------------------------------
1 | // Copyright 2011 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.google.ad.catalog;
16 |
17 | import com.google.android.gms.ads.InterstitialAd;
18 |
19 | import android.app.Activity;
20 | import android.content.Intent;
21 | import android.content.SharedPreferences;
22 | import android.os.Bundle;
23 | import android.util.Log;
24 | import android.view.View;
25 | import android.view.View.OnClickListener;
26 | import android.widget.ToggleButton;
27 |
28 | /**
29 | * Menu system for different methods of displaying interstitials. Setting the splash
30 | * toggle will load an interstitial next time the application is launched.
31 | *
32 | * @author api.eleichtenschl@gmail.com (Eric Leichtenschlag)
33 | */
34 | public class Interstitials extends Activity implements OnClickListener {
35 | private InterstitialAd interstitial;
36 |
37 | /** Called when the activity is first created. */
38 | @Override
39 | public void onCreate(Bundle savedInstanceState) {
40 | super.onCreate(savedInstanceState);
41 | setContentView(R.layout.interstitials);
42 |
43 | interstitial = new InterstitialAd(this);
44 | interstitial.setAdUnitId(Constants.getAdmobId(this));
45 | interstitial.setAdListener(new LogAndToastAdListener(this) {
46 | @Override
47 | public void onAdLoaded() {
48 | super.onAdLoaded();
49 | if (interstitial.isLoaded()) {
50 | interstitial.show();
51 | }
52 | }
53 | });
54 |
55 | final ToggleButton splashToggleButton = (ToggleButton) findViewById(R.id.toggleSplash);
56 | if (splashToggleButton != null) {
57 | // Set the default toggle value from the preferences.
58 | SharedPreferences settings = getSharedPreferences(Constants.PREFS_NAME, 0);
59 | splashToggleButton.setChecked(settings.getBoolean(Constants.PREFS_SPLASH_KEY, false));
60 | }
61 | }
62 |
63 | /** Handles the on click events for each button. */
64 | @Override
65 | public void onClick(View view) {
66 | final int id = view.getId();
67 | Intent intent;
68 | switch (id) {
69 | // Basic button click - load a basic interstitial.
70 | case R.id.basic:
71 | interstitial.loadAd(AdCatalogUtils.createAdRequest());
72 | break;
73 | // Game Levels button click - go to Game Levels Activity.
74 | case R.id.gameLevels:
75 | intent = new Intent(Interstitials.this, GameLevels.class);
76 | startActivity(intent);
77 | break;
78 | // Video Preroll button click - go to Video Preroll Activity.
79 | case R.id.videoPreroll:
80 | intent = new Intent(Interstitials.this, VideoPreroll.class);
81 | startActivity(intent);
82 | break;
83 | // Page Swipe button click - go to Page Swipe Activity.
84 | case R.id.pageSwipe:
85 | intent = new Intent(Interstitials.this, PageSwipe.class);
86 | startActivity(intent);
87 | break;
88 | // Splash button click - toggle preference to receive splash screen interstitial.
89 | case R.id.toggleSplash:
90 | ToggleButton splashToggleButton = (ToggleButton) view;
91 | boolean isChecked = splashToggleButton.isChecked();
92 | SharedPreferences settings = getSharedPreferences(Constants.PREFS_NAME, 0);
93 | settings.edit().putBoolean(Constants.PREFS_SPLASH_KEY, isChecked).commit();
94 | Log.i("Interstitials_Class", "Set splash preference to " + isChecked);
95 | break;
96 | }
97 | }
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/adcatalog/res/layout-xlarge/banners.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
14 |
20 |
26 |
32 |
38 |
44 |
50 |
57 |
64 |
71 |
78 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Google Mobile Ads SDK for Android
2 | =============================
3 | The Google Mobile Ads SDK is the latest generation in Google mobile advertising featuring refined ad formats and streamlined APIs for access to mobile ad networks and advertising solutions. The SDK enables mobile app developers to maximize their monetization in native mobile apps.
4 |
5 | This repository contains the source for the AdCatalog project, which shows a variety of ways that AdMob can be integrated into your app.
6 |
7 | Features
8 | ---------
9 | The is the Ad Catalog for Android. The catalog was written and tested with the
10 | Google Admob Ads SDK version 6.0.1, and supports Android 1.6 or higher.
11 |
12 | The catalog provides:
13 | * A simple banner example featuring a standard banner and smart banner on
14 | phones and additional formats on tablets.
15 | * Four banner layout examples:
16 | 1. TabbedView - a banner ad is persisted across tabs.
17 | 2. ListView - a banner ad is embedded into a list every k list items.
18 | 3. OpenGLView - a banner ad is docked to the bottom of the screen and sits
19 | outside an OpenGLView.
20 | 4. ScrollView - a banner ad is docked to the top of the screen and sits
21 | outside of a ScrollView.
22 | * Five interstitial examples:
23 | 1. Basic - an interstitial ads loads and displays when ready.
24 | 2. Game Levels - an interstitial is displayed before moving to level 2.
25 | 3. Video Preroll - an interstitial is displayed prior to viewing a video.
26 | 4. Page Swipe - an interstitial is displayed when swiping between screens.
27 | 5. Splash - if this option is set, an interstitial will be displayed the next
28 | time the app loads.
29 | * Test mode toggle - determines whether to request test ads.
30 | * Support for tablets.
31 |
32 | Requirements:
33 | -------------
34 | * Android SDK 3.2 or higher
35 | * Google AdMob Ads SDK for Android
36 | * AdMob publisher ID
37 | * Eclipse (recommended)
38 |
39 | Getting started with the Ad Catalog with Eclipse:
40 | --------------------------------------------------
41 | 1. Create an Android project from existing source.
42 | * Create a new Android Project in Eclipse, and select "Create project from
43 | existing source."
44 | * Browse to the base directory of the source code. The Project Name and
45 | Target name should be populated. Click Finish.
46 | 2. Add the Google AdMob Ads Jar to your Eclipse Project.
47 | * Right click on your app project in Eclipse and select "Properties.
48 | * Select "Java Build Path" and the "Libraries" tab. Then click
49 | "Add External JARs..." to add the Google AdMob Ads Jar.
50 | 3. Add the android-support-v4.jar to your Eclipse Project.
51 | * The android-support-v4.jar is included in the Android Compatibility
52 | package. For instructions on how to download this package, visit
53 | http://developer.android.com/sdk/compatibility-library.html#Downloading.
54 | * Include this jar the same way as the Google AdMob Ads jar.
55 | 4. Insert your AdMob publisher ID into the application.
56 | * In the admob_id string in res/values/strings.xml, replace the
57 | "INSERT_YOUR_ADMOB_ID_HERE" text with your publisher ID.
58 |
59 | Your application should run properly.
60 |
61 | Note:
62 | Test mode currently only gets test ads in the emulator. To get test ads in
63 | test mode on your device, call adRequest.addTestDevice("YOUR_DEVICE_ID")
64 | method before calling the loadAd method. Your device ID can be found in the
65 | LogCat output when loading an ad on your device.
66 |
67 | Downloads
68 | -----------
69 | Please check out our [releases](https://github.com/googleads/googleads-mobile-android-adcatalog/releases) for the latest downloads for the different sample apps.
70 |
71 | Documentation
72 | --------------
73 | Check out our [developers site](https://developers.google.com/mobile-ads-sdk/) for documentation on using the SDK, and join the developer community on [our forum](https://groups.google.com/forum/#!forum/google-admob-ads-sdk).
74 |
75 | Suggesting improvements
76 | -------------------------
77 | To file bugs, make feature requests, or to suggest other improvements, please use [github's issue tracker](https://github.com/googleads/googleads-mobile-android-adcatalog/issues).
78 |
79 | License
80 | --------
81 | [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0.html)
82 |
83 | Contributing
84 | -------------
85 | Pull requests are welcome! Please sign [this Google Code contributor agreement](https://developers.google.com/open-source/cla/individual?csw=1) before submitting.
86 |
--------------------------------------------------------------------------------
/adcatalog/src/com/google/ad/catalog/Banners.java:
--------------------------------------------------------------------------------
1 | // Copyright 2011 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.google.ad.catalog;
16 |
17 | import com.google.android.gms.ads.AdRequest;
18 | import com.google.android.gms.ads.AdView;
19 |
20 | import android.app.Activity;
21 | import android.os.Bundle;
22 | import android.view.View;
23 | import android.view.View.OnClickListener;
24 |
25 | /**
26 | * Showcases the different banner formats on both phones and tablets. Phones
27 | * will show a standard banner, a medium rectangle, and a smart banner. Tablets
28 | * will show full size banners and leaderboard ads in addition to the three
29 | * formats above.
30 | *
31 | * @author api.eleichtenschl@gmail.com (Eric Leichtenschlag)
32 | */
33 | public class Banners extends Activity implements OnClickListener {
34 | private AdView adViewBanner;
35 | private AdView adViewRect;
36 | private AdView adViewSmartBanner;
37 | private AdView adViewFullSizeBanner;
38 | private AdView adViewLeaderboard;
39 | /** Used to hide the last AdView that was selected. */
40 | private AdView lastVisibleAdView = null;
41 |
42 | /** Called when the activity is first created. */
43 | @Override
44 | public void onCreate(Bundle savedInstanceState) {
45 | super.onCreate(savedInstanceState);
46 | setContentView(R.layout.banners);
47 |
48 | // Set the ad listener and load an load for each AdView.
49 | AdRequest adRequest = AdCatalogUtils.createAdRequest();
50 | adViewBanner = (AdView) findViewById(R.id.adViewBanner);
51 | adViewBanner.setAdListener(new LogAndToastAdListener(this));
52 | adViewBanner.loadAd(adRequest);
53 | adViewSmartBanner = (AdView) findViewById(R.id.adViewSmart);
54 | adViewSmartBanner.setAdListener(new LogAndToastAdListener(this));
55 | adViewSmartBanner.loadAd(adRequest);
56 |
57 | if (AdCatalogUtils.isExtraLargeScreen(this)) {
58 | adViewRect = (AdView) findViewById(R.id.adViewRect);
59 | adViewRect.setAdListener(new LogAndToastAdListener(this));
60 | adViewRect.loadAd(adRequest);
61 | adViewFullSizeBanner = (AdView) findViewById(R.id.adViewFullSize);
62 | adViewFullSizeBanner.setAdListener(new LogAndToastAdListener(this));
63 | adViewFullSizeBanner.loadAd(adRequest);
64 | adViewLeaderboard = (AdView) findViewById(R.id.adViewLeaderboard);
65 | adViewLeaderboard.setAdListener(new LogAndToastAdListener(this));
66 | adViewLeaderboard.loadAd(adRequest);
67 | }
68 | }
69 |
70 | /** Handles the on click events for each button. */
71 | @Override
72 | public void onClick(View view) {
73 | if (lastVisibleAdView != null) {
74 | lastVisibleAdView.setVisibility(View.GONE);
75 | }
76 | switch (view.getId()) {
77 | case R.id.standardBanner:
78 | adViewBanner.setVisibility(View.VISIBLE);
79 | lastVisibleAdView = adViewBanner;
80 | break;
81 | case R.id.mediumRectangle:
82 | adViewRect.setVisibility(View.VISIBLE);
83 | lastVisibleAdView = adViewRect;
84 | break;
85 | case R.id.smartBanner:
86 | adViewSmartBanner.setVisibility(View.VISIBLE);
87 | lastVisibleAdView = adViewSmartBanner;
88 | break;
89 | case R.id.fullSize:
90 | adViewFullSizeBanner.setVisibility(View.VISIBLE);
91 | lastVisibleAdView = adViewFullSizeBanner;
92 | break;
93 | case R.id.leaderboard:
94 | adViewLeaderboard.setVisibility(View.VISIBLE);
95 | lastVisibleAdView = adViewLeaderboard;
96 | break;
97 | }
98 | }
99 |
100 | /** Overwrite the onDestroy() method to dispose of the banners first. */
101 | @Override
102 | public void onDestroy() {
103 | if (adViewBanner != null) {
104 | adViewBanner.destroy();
105 | }
106 | if (adViewRect != null) {
107 | adViewRect.destroy();
108 | }
109 | if (adViewSmartBanner != null) {
110 | adViewSmartBanner.destroy();
111 | }
112 | if (adViewFullSizeBanner != null) {
113 | adViewFullSizeBanner.destroy();
114 | }
115 | if (adViewLeaderboard != null) {
116 | adViewLeaderboard.destroy();
117 | }
118 | super.onDestroy();
119 | }
120 |
121 |
122 | }
123 |
--------------------------------------------------------------------------------
/adcatalog/src/com/google/ad/catalog/AdCatalog.java:
--------------------------------------------------------------------------------
1 | // Copyright 2011 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.google.ad.catalog;
16 |
17 | import com.google.ad.catalog.layouts.AdvancedLayouts;
18 | import com.google.ad.catalog.layouts.Video;
19 | import com.google.android.gms.ads.InterstitialAd;
20 |
21 | import android.app.Activity;
22 | import android.content.Intent;
23 | import android.content.SharedPreferences;
24 | import android.os.Bundle;
25 | import android.util.Log;
26 | import android.view.View;
27 | import android.view.View.OnClickListener;
28 | import android.widget.Button;
29 | import android.widget.ToggleButton;
30 |
31 | /**
32 | * This is the main activity that loads on when the app is first run. The user
33 | * will be provided with a menu to view banners or interstitials. If the user
34 | * has previously set the splash toggle button, an interstitial will be loaded
35 | * when this activity is created.
36 | *
37 | * @author api.eleichtenschl@gmail.com (Eric Leichtenschlag)
38 | */
39 | public class AdCatalog extends Activity implements OnClickListener {
40 | private InterstitialAd interstitial;
41 | private Button bannerButton;
42 | private Button interstitialButton;
43 | public static boolean isTestMode;
44 |
45 | /** Called when the activity is first created. */
46 | @Override
47 | public void onCreate(Bundle savedInstanceState) {
48 | super.onCreate(savedInstanceState);
49 | setContentView(R.layout.main);
50 |
51 | // Default to test mode on.
52 | isTestMode = true;
53 | ToggleButton testModeToggle = (ToggleButton) findViewById(R.id.toggleTestMode);
54 | testModeToggle.setChecked(isTestMode);
55 |
56 | // Load interstitial if splash interstitial preference was set.
57 | SharedPreferences settings = getSharedPreferences(Constants.PREFS_NAME, 0);
58 | boolean loadSplashInterstitial = settings.getBoolean(Constants.PREFS_SPLASH_KEY, false);
59 | if (loadSplashInterstitial) {
60 | interstitial = new InterstitialAd(this);
61 | interstitial.setAdUnitId(Constants.getAdmobId(this));
62 | interstitial.setAdListener(new LogAndToastAdListener(this) {
63 | @Override
64 | public void onAdLoaded() {
65 | super.onAdLoaded();
66 | interstitial.show();
67 | }
68 |
69 | @Override
70 | public void onAdOpened() {
71 | super.onAdOpened();
72 | // Deactivate buttons so interstitial returns before they can be clicked.
73 | if (bannerButton != null) {
74 | bannerButton.setEnabled(false);
75 | }
76 | if (interstitialButton != null) {
77 | interstitialButton.setEnabled(false);
78 | }
79 | }
80 |
81 | @Override
82 | public void onAdClosed() {
83 | super.onAdClosed();
84 | // Reactivate buttons after interstitial is dismissed.
85 | if (bannerButton != null) {
86 | bannerButton.setEnabled(true);
87 | }
88 | if (interstitialButton != null) {
89 | interstitialButton.setEnabled(true);
90 | }
91 | }
92 | });
93 | interstitial.loadAd(AdCatalogUtils.createAdRequest());
94 | }
95 | }
96 |
97 | /** Handles the on click events for each button. */
98 | @Override
99 | public void onClick(View view) {
100 | final int id = view.getId();
101 | Intent intent = null;
102 | switch (id) {
103 | // Banners button click - go to Banners Activity.
104 | case R.id.Banners:
105 | intent = new Intent(AdCatalog.this, Banners.class);
106 | break;
107 | // Interstitials button click - go to Interstitials Activity.
108 | case R.id.Interstitials:
109 | intent = new Intent(AdCatalog.this, Interstitials.class);
110 | break;
111 | // Advanced Layouts button click - go to Advanced Layouts Activity.
112 | case R.id.AdvancedLayouts:
113 | intent = new Intent(AdCatalog.this, AdvancedLayouts.class);
114 | break;
115 | // Video button click - go to video activity.
116 | case R.id.Video:
117 | intent = new Intent(AdCatalog.this, Video.class);
118 | break;
119 | // Test Ads toggle click - change Test Mode preference.
120 | case R.id.toggleTestMode:
121 | isTestMode = !isTestMode;
122 | Log.d("AdCatalog", "Test mode: " + isTestMode);
123 | break;
124 | }
125 | if (intent != null) {
126 | startActivity(intent);
127 | }
128 | }
129 |
130 | }
131 |
--------------------------------------------------------------------------------
/adcatalog/src/com/google/ad/catalog/VideoPlayer.java:
--------------------------------------------------------------------------------
1 | // Copyright 2011 Google Inc. All Rights Reserved.
2 |
3 | package com.google.ad.catalog;
4 |
5 | import com.google.ad.catalog.TrackingVideoView.CompleteCallback;
6 | import com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer;
7 | import com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate;
8 |
9 | import android.content.Context;
10 | import android.util.AttributeSet;
11 | import android.util.Log;
12 | import android.view.MotionEvent;
13 | import android.view.View;
14 | import android.view.ViewGroup;
15 | import android.widget.FrameLayout;
16 | import android.widget.MediaController;
17 | import android.widget.RelativeLayout;
18 |
19 | /**
20 | * An example video player that implements VideoAdPlayer.
21 | */
22 | public class VideoPlayer extends RelativeLayout implements VideoAdPlayer {
23 | private TrackingVideoView video;
24 | private FrameLayout adUiContainer;
25 | private MediaController mediaController;
26 |
27 | /**
28 | * Used to store the content URL during mid-rolls.
29 | */
30 | private String savedContentUrl;
31 |
32 | /**
33 | * Used to store the content position during mid-rolls.
34 | */
35 | private int savedContentPosition = 0;
36 |
37 | /**
38 | * Used to store the position of the video player when the parent activity is
39 | * paused, and seek to the correct position when the activity is resumed.
40 | */
41 | private int savedPosition = 0;
42 |
43 | private boolean contentPlaying;
44 |
45 | public VideoPlayer(Context context, AttributeSet attrs, int defStyle) {
46 | super(context, attrs, defStyle);
47 | init();
48 | }
49 |
50 | public VideoPlayer(Context context, AttributeSet attrs) {
51 | super(context, attrs);
52 | init();
53 | }
54 |
55 | public VideoPlayer(Context context) {
56 | super(context);
57 | init();
58 | }
59 |
60 | private void init() {
61 | mediaController = new MediaController(getContext());
62 | mediaController.setAnchorView(this);
63 |
64 | // Center the video in the parent layout (when video ratio doesn't match the
65 | // layout size it will by default position to the left).
66 | LayoutParams videoLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
67 | LayoutParams.MATCH_PARENT);
68 | videoLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
69 | videoLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
70 | video = new TrackingVideoView(getContext());
71 | // Adding the touch listener to allow pause/resume during an ad. This is necessary because we
72 | // remove the MediaController during ad playback to prevent seeking.
73 | video.setOnTouchListener(new OnTouchListener() {
74 | @Override
75 | public boolean onTouch(View unusedView, MotionEvent unusedEvent) {
76 | if (!contentPlaying) {
77 | // Only applies when ad is playing
78 | video.togglePlayback();
79 | }
80 | return false;
81 | }
82 | });
83 |
84 | addView(video, videoLayoutParams);
85 | adUiContainer = new FrameLayout(getContext());
86 | addView(adUiContainer, LayoutParams.MATCH_PARENT);
87 | }
88 |
89 | public ViewGroup getUiContainer() {
90 | return adUiContainer;
91 | }
92 |
93 | public void setCompletionCallback(CompleteCallback callback) {
94 | video.setCompleteCallback(callback);
95 | }
96 |
97 | /**
98 | * Play whatever is already in the video view.
99 | */
100 | public void play() {
101 | video.start();
102 | }
103 |
104 | public void playContent(String contentUrl) {
105 | contentPlaying = true;
106 | savedContentUrl = contentUrl;
107 | video.setVideoPath(contentUrl);
108 | video.setMediaController(mediaController);
109 | play();
110 | }
111 |
112 | public void pauseContent() {
113 | savedContentPosition = video.getCurrentPosition();
114 | video.stopPlayback();
115 | video.setMediaController(null); // Disables seeking during ad playback.
116 | }
117 |
118 | public void resumeContent() {
119 | contentPlaying = true;
120 | video.setVideoPath(savedContentUrl);
121 | video.seekTo(savedContentPosition);
122 | video.setMediaController(mediaController);
123 | play();
124 | }
125 |
126 | public boolean isContentPlaying() {
127 | return contentPlaying;
128 | }
129 |
130 | public void savePosition() {
131 | savedPosition = video.getCurrentPosition();
132 | }
133 |
134 | public void restorePosition() {
135 | video.seekTo(savedPosition);
136 | }
137 |
138 | // Methods implementing VideoAdPlayer interface.
139 |
140 | @Override
141 | public void playAd() {
142 | contentPlaying = false;
143 | video.start();
144 | }
145 |
146 | @Override
147 | public void stopAd() {
148 | video.stopPlayback();
149 | }
150 |
151 | @Override
152 | public void loadAd(String url) {
153 | video.setVideoPath(url);
154 | }
155 |
156 | @Override
157 | public void pauseAd() {
158 | video.pause();
159 | }
160 |
161 | @Override
162 | public void resumeAd() {
163 | video.start();
164 | }
165 |
166 | @Override
167 | public void addCallback(VideoAdPlayerCallback callback) {
168 | video.addCallback(callback);
169 | }
170 |
171 | @Override
172 | public void removeCallback(VideoAdPlayerCallback callback) {
173 | video.removeCallback(callback);
174 | }
175 |
176 | @Override
177 | public VideoProgressUpdate getProgress() {
178 | int durationMs = video.getDuration();
179 |
180 | if (durationMs <= 0) {
181 | return VideoProgressUpdate.VIDEO_TIME_NOT_READY;
182 | }
183 | VideoProgressUpdate vpu = new VideoProgressUpdate(video.getCurrentPosition(), durationMs);
184 | Log.i("PLAYER", vpu.toString());
185 | return vpu;
186 | }
187 | }
188 |
--------------------------------------------------------------------------------
/adcatalog/src/com/google/ad/catalog/VideoExample.java:
--------------------------------------------------------------------------------
1 | package com.google.ad.catalog;
2 |
3 | import com.google.ad.catalog.TrackingVideoView.CompleteCallback;
4 | import com.google.ads.interactivemedia.v3.api.AdDisplayContainer;
5 | import com.google.ads.interactivemedia.v3.api.AdErrorEvent;
6 | import com.google.ads.interactivemedia.v3.api.AdErrorEvent.AdErrorListener;
7 | import com.google.ads.interactivemedia.v3.api.AdEvent;
8 | import com.google.ads.interactivemedia.v3.api.AdEvent.AdEventListener;
9 | import com.google.ads.interactivemedia.v3.api.AdsLoader;
10 | import com.google.ads.interactivemedia.v3.api.AdsLoader.AdsLoadedListener;
11 | import com.google.ads.interactivemedia.v3.api.AdsManager;
12 | import com.google.ads.interactivemedia.v3.api.AdsManagerLoadedEvent;
13 | import com.google.ads.interactivemedia.v3.api.AdsRequest;
14 | import com.google.ads.interactivemedia.v3.api.CompanionAdSlot;
15 | import com.google.ads.interactivemedia.v3.api.ImaSdkFactory;
16 | import com.google.ads.interactivemedia.v3.api.ImaSdkSettings;
17 |
18 | import android.app.Activity;
19 | import android.os.Bundle;
20 | import android.view.View;
21 | import android.view.ViewGroup;
22 | import android.widget.FrameLayout;
23 | import android.widget.ScrollView;
24 | import android.widget.TextView;
25 |
26 | import java.util.ArrayList;
27 |
28 | /**
29 | * Activity for the IMA SDK video example.
30 | */
31 | public class VideoExample extends Activity implements CompleteCallback,
32 | AdErrorListener, AdEventListener, AdsLoadedListener {
33 |
34 | private static final String CONTENT_URL =
35 | "http://rmcdn.2mdn.net/MotifFiles/html/1248596/" + "android_1330378998288.mp4";
36 |
37 | private int tagIndex;
38 | private String[] tags;
39 | private FrameLayout videoHolder;
40 | private VideoPlayer videoPlayer;
41 | private ViewGroup companionView;
42 | private ScrollView logScroll;
43 | private TextView log;
44 | private AdsLoader adsLoader;
45 | private ImaSdkFactory sdkFactory;
46 | private ImaSdkSettings sdkSettings;
47 |
48 | private boolean contentStarted;
49 |
50 | private boolean isAdStarted;
51 |
52 | private boolean isAdPlaying;
53 |
54 | private AdDisplayContainer container;
55 |
56 | private AdsManager adsManager;
57 |
58 | @Override
59 | public void onCreate(Bundle savedInstanceState) {
60 | super.onCreate(savedInstanceState);
61 | setContentView(R.layout.videoexample);
62 | tagIndex = getIntent().getIntExtra("ad_tag_index", 0);
63 | tags = getResources().getStringArray(R.array.video_ad_tags);
64 | initUi();
65 | sdkFactory = ImaSdkFactory.getInstance();
66 | createAdsLoader();
67 | requestAd();
68 | }
69 |
70 | protected void initUi() {
71 | videoHolder = (FrameLayout) findViewById(R.id.videoHolder);
72 |
73 | videoPlayer = new VideoPlayer(this);
74 | videoPlayer.setCompletionCallback(this);
75 |
76 | videoHolder.addView(videoPlayer);
77 |
78 | companionView = (ViewGroup) findViewById(R.id.companionFrame);
79 | logScroll = (ScrollView) findViewById(R.id.scroll);
80 | log = (TextView) findViewById(R.id.log);
81 | }
82 |
83 | protected void createAdsLoader() {
84 | adsLoader = sdkFactory.createAdsLoader(this, getImaSdkSettings());
85 | adsLoader.addAdErrorListener(this);
86 | adsLoader.addAdsLoadedListener(this);
87 | }
88 |
89 | protected ImaSdkSettings getImaSdkSettings() {
90 | if (sdkSettings == null) {
91 | sdkSettings = sdkFactory.createImaSdkSettings();
92 | }
93 | return sdkSettings;
94 | }
95 |
96 | protected void playVideo() {
97 | log("Playing video");
98 | videoPlayer.playContent(CONTENT_URL);
99 | contentStarted = true;
100 | }
101 |
102 | protected void pauseResumeAd() {
103 | if (isAdStarted) {
104 | if (isAdPlaying) {
105 | log("Pausing video");
106 | videoPlayer.pauseAd();
107 | } else {
108 | log("Resuming video");
109 | videoPlayer.resumeAd();
110 | }
111 | }
112 | }
113 |
114 | protected AdsRequest buildAdsRequest() {
115 | container = sdkFactory.createAdDisplayContainer();
116 | container.setPlayer(videoPlayer);
117 | container.setAdContainer(videoPlayer.getUiContainer());
118 | log("Requesting ads");
119 | AdsRequest request = sdkFactory.createAdsRequest();
120 | request.setAdTagUrl(tags[tagIndex]);
121 |
122 | ArrayList companionAdSlots = new ArrayList();
123 |
124 | CompanionAdSlot companionAdSlot = sdkFactory.createCompanionAdSlot();
125 | companionAdSlot.setContainer(companionView);
126 | companionAdSlot.setSize(300, 50);
127 | companionAdSlots.add(companionAdSlot);
128 |
129 | container.setCompanionSlots(companionAdSlots);
130 | request.setAdDisplayContainer(container);
131 | return request;
132 | }
133 |
134 | protected void requestAd() {
135 | adsLoader.requestAds(buildAdsRequest());
136 | }
137 |
138 | @Override
139 | public void onAdError(AdErrorEvent event) {
140 | log(event.getError().getMessage() + "\n");
141 | }
142 |
143 | @Override
144 | public void onAdsManagerLoaded(AdsManagerLoadedEvent event) {
145 | log("Ads loaded!");
146 | adsManager = event.getAdsManager();
147 | adsManager.addAdErrorListener(this);
148 | adsManager.addAdEventListener(this);
149 | log("Calling init.");
150 | adsManager.init();
151 | }
152 |
153 | @Override
154 | protected void onPause() {
155 | super.onPause();
156 | if (videoPlayer != null) {
157 | videoPlayer.savePosition();
158 | }
159 | }
160 |
161 | @Override
162 | protected void onResume() {
163 | super.onResume();
164 | if (videoPlayer != null) {
165 | videoPlayer.restorePosition();
166 | }
167 | }
168 |
169 | @Override
170 | public void onComplete() {
171 | if (videoPlayer.isContentPlaying()) {
172 | adsLoader.contentComplete();
173 | }
174 | }
175 |
176 | @Override
177 | public void onAdEvent(AdEvent event) {
178 | log("Event:" + event.getType());
179 |
180 | switch (event.getType()) {
181 | case LOADED:
182 | log("Calling start.");
183 | adsManager.start();
184 | break;
185 | case CONTENT_PAUSE_REQUESTED:
186 | if (contentStarted) {
187 | videoPlayer.pauseContent();
188 | }
189 | break;
190 | case CONTENT_RESUME_REQUESTED:
191 | if (contentStarted) {
192 | videoPlayer.resumeContent();
193 | } else {
194 | playVideo();
195 | }
196 | break;
197 | case STARTED:
198 | isAdStarted = true;
199 | isAdPlaying = true;
200 | break;
201 | case COMPLETED:
202 | isAdStarted = false;
203 | isAdPlaying = false;
204 | break;
205 | case ALL_ADS_COMPLETED:
206 | isAdStarted = false;
207 | isAdPlaying = false;
208 | adsManager.destroy();
209 | break;
210 | case PAUSED:
211 | isAdPlaying = false;
212 | break;
213 | case RESUMED:
214 | isAdPlaying = true;
215 | break;
216 | default:
217 | break;
218 | }
219 | }
220 |
221 | protected void log(String message) {
222 | log.append(message + "\n");
223 | logScroll.post(new Runnable() {
224 | @Override
225 | public void run() {
226 | logScroll.fullScroll(View.FOCUS_DOWN);
227 | }
228 | });
229 | }
230 |
231 | }
232 |
--------------------------------------------------------------------------------
/adcatalog/src/com/google/ad/catalog/layouts/TabbedViewExample.java:
--------------------------------------------------------------------------------
1 | // Copyright 2012, Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.google.ad.catalog.layouts;
16 |
17 | import com.google.ad.catalog.AdCatalogUtils;
18 | import com.google.ad.catalog.R;
19 |
20 | import android.content.Context;
21 | import android.os.Bundle;
22 | import android.support.v4.app.Fragment;
23 | import android.support.v4.app.FragmentActivity;
24 | import android.support.v4.app.FragmentTransaction;
25 | import android.view.LayoutInflater;
26 | import android.view.View;
27 | import android.view.ViewGroup;
28 | import android.widget.TabHost;
29 | import android.widget.TabHost.OnTabChangeListener;
30 | import android.widget.TabHost.TabContentFactory;
31 | import android.widget.TabHost.TabSpec;
32 |
33 | import java.util.HashMap;
34 |
35 | /**
36 | * Example of including AdMob ads into a Tabbed View, which references the v4
37 | * support library for the fragment API instead of the deprecated TabActivity
38 | * class. These library classes are included in android-support-v4.jar, which
39 | * is a part of the Android Compatibility Package found in the Extras section
40 | * of the Android SDK Manager.
41 | *
42 | * @author api.eleichtenschl@gmail.com (Eric Leichtenschlag)
43 | */
44 | public class TabbedViewExample extends FragmentActivity {
45 | private TabHost tabHost;
46 | private TabManager tabManager;
47 |
48 | @Override
49 | protected void onCreate(Bundle savedInstanceState) {
50 | super.onCreate(savedInstanceState);
51 | setContentView(R.layout.tabviewexample);
52 | this.tabHost = (TabHost) findViewById(android.R.id.tabhost);
53 | this.tabHost.setup();
54 |
55 | // Initialize the tabs.
56 | this.tabManager = new TabManager(this, this.tabHost, R.id.realtabcontent);
57 | Bundle args = new Bundle();
58 | args.putInt("layoutResource", R.layout.tabblue);
59 | this.tabManager.addTab(this.tabHost.newTabSpec("Tab1").setIndicator("Tab 1"),
60 | TabFragment.class, args);
61 | args = new Bundle();
62 | args.putInt("layoutResource", R.layout.tabred);
63 | this.tabManager.addTab(this.tabHost.newTabSpec("Tab2").setIndicator("Tab 2"),
64 | TabFragment.class, args);
65 | args = new Bundle();
66 | args.putInt("layoutResource", R.layout.tabgreen);
67 | this.tabManager.addTab(this.tabHost.newTabSpec("Tab3").setIndicator("Tab 3"),
68 | TabFragment.class, args);
69 | // Set the current tab if one exists.
70 | if (savedInstanceState != null) {
71 | this.tabHost.setCurrentTabByTag(savedInstanceState.getString("tab"));
72 | }
73 | AdCatalogUtils.createAdRequest();
74 | }
75 |
76 | @Override
77 | protected void onSaveInstanceState(Bundle outState) {
78 | super.onSaveInstanceState(outState);
79 | outState.putString("tab", this.tabHost.getCurrentTabTag());
80 | }
81 |
82 | /**
83 | * This is a helper class that implements a generic mechanism for
84 | * associating fragments with the tabs in a tab host. It relies on a
85 | * trick. Normally a tab host has a simple API for supplying a View or
86 | * Intent that each tab will show. This is not sufficient for switching
87 | * between fragments. So instead we make the content part of the tab host
88 | * 0dp high (it is not shown) and the TabManager supplies its own dummy
89 | * view to show as the tab content. It listens to changes in tabs, and takes
90 | * care of switch to the correct fragment shown in a separate content area
91 | * whenever the selected tab changes.
92 | */
93 | public static class TabManager implements OnTabChangeListener {
94 | private final FragmentActivity activity;
95 | private final TabHost tabHost;
96 | private final int containerId;
97 | private final HashMap tabInfoMap = new HashMap();
98 | private TabInfo currentTab;
99 |
100 | /** Represents the information of a tab. */
101 | static final class TabInfo {
102 | private final String tag;
103 | private final Class> clss;
104 | private final Bundle args;
105 | private Fragment fragment;
106 |
107 | TabInfo(String tag, Class> clss, Bundle args) {
108 | this.tag = tag;
109 | this.clss = clss;
110 | this.args = args;
111 | }
112 | }
113 |
114 | /** Creates an empty tab. */
115 | static class DummyTabFactory implements TabContentFactory {
116 | private final Context context;
117 |
118 | public DummyTabFactory(Context context) {
119 | this.context = context;
120 | }
121 |
122 | @Override
123 | public View createTabContent(String tag) {
124 | View view = new View(this.context);
125 | view.setMinimumWidth(0);
126 | view.setMinimumHeight(0);
127 | return view;
128 | }
129 | }
130 |
131 | public TabManager(FragmentActivity activity, TabHost tabHost, int containerId) {
132 | this.activity = activity;
133 | this.tabHost = tabHost;
134 | this.containerId = containerId;
135 | this.tabHost.setOnTabChangedListener(this);
136 | }
137 |
138 | public void addTab(TabSpec tabSpec, Class> clss, Bundle args) {
139 | tabSpec.setContent(new DummyTabFactory(this.activity));
140 | String tag = tabSpec.getTag();
141 | TabInfo tabInfo = new TabInfo(tag, clss, args);
142 |
143 | // Check to see if there is already a fragment for this tab. If so,
144 | // deactivate it, because the initial state is that a tab isn't shown.
145 | tabInfo.fragment = this.activity.getSupportFragmentManager().findFragmentByTag(tag);
146 | if (tabInfo.fragment != null && !tabInfo.fragment.isDetached()) {
147 | FragmentTransaction transaction =
148 | this.activity.getSupportFragmentManager().beginTransaction();
149 | transaction.detach(tabInfo.fragment).commit();
150 | }
151 | this.tabInfoMap.put(tag, tabInfo);
152 | this.tabHost.addTab(tabSpec);
153 | }
154 |
155 | @Override
156 | public void onTabChanged(String tabId) {
157 | TabInfo newTab = this.tabInfoMap.get(tabId);
158 | if (this.currentTab != newTab) {
159 | FragmentTransaction transaction =
160 | this.activity.getSupportFragmentManager().beginTransaction();
161 | if (this.currentTab != null && this.currentTab.fragment != null) {
162 | transaction.detach(this.currentTab.fragment);
163 | }
164 | if (newTab != null) {
165 | if (newTab.fragment == null) {
166 | newTab.fragment = Fragment.instantiate(this.activity,
167 | newTab.clss.getName(), newTab.args);
168 | transaction.add(this.containerId, newTab.fragment, newTab.tag);
169 | } else {
170 | transaction.attach(newTab.fragment);
171 | }
172 | }
173 | this.currentTab = newTab;
174 | transaction.commit();
175 | this.activity.getSupportFragmentManager().executePendingTransactions();
176 | }
177 | }
178 | }
179 |
180 | /** Fragment for a tab in the Tab View example. */
181 | public static class TabFragment extends Fragment {
182 | private int layoutResource;
183 |
184 | static TabFragment newInstance(int resource) {
185 | TabFragment fragment = new TabFragment();
186 | // Supply the layout resource input as an argument.
187 | Bundle args = new Bundle();
188 | args.putInt("layoutResource", resource);
189 | fragment.setArguments(args);
190 | return fragment;
191 | }
192 |
193 | @Override
194 | public void onCreate(Bundle savedInstanceState) {
195 | super.onCreate(savedInstanceState);
196 | // Default to blue tab, if no resource is provided.
197 | this.layoutResource = R.layout.tabblue;
198 | Bundle args = getArguments();
199 | if (args != null && args.getInt("layoutResource") != 0) {
200 | this.layoutResource = args.getInt("layoutResource");
201 | }
202 |
203 | }
204 |
205 | @Override
206 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
207 | Bundle savedInstanceState) {
208 | return inflater.inflate(this.layoutResource, container, false);
209 | }
210 | }
211 | }
212 |
--------------------------------------------------------------------------------
/adcatalog/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | AdCatalog
4 | INSERT_YOUR_AD_UNIT_ID_HERE
5 | Banners
6 | Interstitials
7 | Advanced Layouts
8 | Test Mode Off
9 | Test Mode On
10 | Video
11 | Advanced Layouts
12 | Examples
13 | TabbedView
14 | ListView
15 | OpenGLView
16 | ScrollView
17 | Banners
18 | 320x50
19 | 300x250
20 | Smart Banner
21 | 468x60
22 | 728x90
23 | Interstitials
24 | Basic
25 | Game Levels
26 | Video Pre-Roll
27 | Page Swipe
28 | Use Cases
29 | Splash
30 | Video
31 | Examples
32 |
33 | Instream 1
34 | AdSense Skippable
35 | Wrapper
36 | AdsList
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | Companion Slot
45 | Video Preroll
46 | Earthquake
47 | Fill In The Blanks
48 | Package Tracking
49 | Level 1
50 | Level 2
51 | next
52 | Page 1
53 | Page 2
54 | In this example, an interstitial is
55 | loaded on activity start and page swipe. If ad is properly loaded, it
56 | will be presented directly after swiping. Try swiping to a new screen.
57 |
58 | An interstitial should have been
59 | displayed directly after the page swipe assuming the ad was loaded prior
60 | to the swipe. A new ad is loading right now and will be displayed on
61 | your next swipe if it loaded properly.
62 | Lorem ipsum dolor sit
63 | amet, consectetuer adipiscing elit. Nam cursus. Morbi ut mi. Nullam enim
64 | leo, egestas id, condimentum at, laoreet mattis, massa. Sed eleifend
65 | nonummy diam. Praesent mauris ante, elementum et, bibendum at, posuere
66 | sit amet, nibh. Duis tincidunt lectus quis dui viverra vestibulum.
67 | Suspendisse vulputate aliquam dui. Nulla elementum dui ut augue. Aliquam
68 | vehicula mi at mauris. Maecenas placerat, nisl at consequat rhoncus, sem
69 | nunc gravida justo, quis eleifend arcu velit quis lacus. Morbi magna
70 | magna, tincidunt a, mattis non, imperdiet vitae, tellus. Sed odio est,
71 | auctor ac, sollicitudin in, consequat vitae, orci. Fusce id felis.
72 | Vivamus sollicitudin metus eget eros.
73 | \n\nPellentesque habitant morbi tristique senectus et netus et malesuada
74 | fames ac turpis egestas. In posuere felis nec tortor. Pellentesque
75 | faucibus. Ut accumsan ultricies elit. Maecenas at justo id velit
76 | placerat molestie. Donec dictum lectus non odio. Cras a ante vitae enim
77 | iaculis aliquam. Mauris nunc quam, venenatis nec, euismod sit amet,
78 | egestas placerat, est. Pellentesque habitant morbi tristique senectus et
79 | netus et malesuada fames ac turpis egestas. Cras id elit. Integer quis
80 | urna. Ut ante enim, dapibus malesuada, fringilla eu, condimentum quis,
81 | tellus. Aenean porttitor eros vel dolor. Donec convallis pede venenatis
82 | nibh. Duis quam. Nam eget lacus. Aliquam erat volutpat. Quisque
83 | dignissim congue leo.
84 | \n\nMauris vel lacus vitae felis vestibulum volutpat. Etiam est nunc,
85 | venenatis in, tristique eu, imperdiet ac, nisl. Cum sociis natoque
86 | penatibus et magnis dis parturient montes, nascetur ridiculus mus. In
87 | iaculis facilisis massa. Etiam eu urna. Sed porta. Suspendisse quam leo,
88 | molestie sed, luctus quis, feugiat in, pede. Fusce tellus. Sed metus
89 | augue, convallis et, vehicula ut, pulvinar eu, ante. Integer orci
90 | tellus, tristique vitae, consequat nec, porta vel, lectus. Nulla sit
91 | amet diam. Duis non nunc. Nulla rhoncus dictum metus. Curabitur
92 | tristique mi condimentum orci. Phasellus pellentesque aliquam enim.
93 | Proin dui lectus, cursus eu, mattis laoreet, viverra sit amet, quam.
94 | Curabitur vel dolor ultrices ipsum dictum tristique. Praesent vitae
95 | lacus. Ut velit enim, vestibulum non, fermentum nec, hendrerit quis,
96 | leo. Pellentesque rutrum malesuada neque.
97 | \n\nNunc tempus felis vitae urna. Vivamus porttitor, neque at volutpat
98 | rutrum, purus nisi eleifend libero, a tempus libero lectus feugiat
99 | felis. Morbi diam mauris, viverra in, gravida eu, mattis in, ante. Morbi
100 | eget arcu. Morbi porta, libero id ullamcorper nonummy, nibh ligula
101 | pulvinar metus, eget consectetuer augue nisi quis lacus. Ut ac mi quis
102 | lacus mollis aliquam. Curabitur iaculis tempus eros. Curabitur vel mi
103 | sit amet magna malesuada ultrices. Ut nisi erat, fermentum vel, congue
104 | id, euismod in, elit. Fusce ultricies, orci ac feugiat suscipit, leo
105 | massa sodales velit, et scelerisque mi tortor at ipsum. Proin orci odio,
106 | commodo ac, gravida non, tristique vel, tellus. Pellentesque nibh
107 | libero, ultricies eu, sagittis non, mollis sed, justo. Praesent metus
108 | ipsum, pulvinar pulvinar, porta id, fringilla at, est.
109 | \n\nPhasellus felis dolor, scelerisque a, tempus eget, lobortis id,
110 | libero. Donec scelerisque leo ac risus. Praesent sit amet est. In
111 | dictum, dolor eu dictum porttitor, enim felis viverra mi, eget luctus
112 | massa purus quis odio. Etiam nulla massa, pharetra facilisis, volutpat
113 | in, imperdiet sit amet, sem. Aliquam nec erat at purus cursus interdum.
114 | Vestibulum ligula augue, bibendum accumsan, vestibulum ut, commodo a,
115 | mi. Morbi ornare gravida elit. Integer congue, augue et malesuada
116 | iaculis, ipsum dui aliquet felis, at cursus magna nisl nec elit. Donec
117 | iaculis diam a nisi accumsan viverra. Duis sed tellus et tortor
118 | vestibulum gravida. Praesent elementum elit at tellus. Curabitur metus
119 | ipsum, luctus eu, malesuada ut, tincidunt sed, diam. Donec quis mi sed
120 | magna hendrerit accumsan. Suspendisse risus nibh, ultricies eu, volutpat
121 | non, condimentum hendrerit, augue. Etiam eleifend, metus vitae
122 | adipiscing semper, mauris ipsum iaculis elit, congue gravida elit mi
123 | egestas orci. Curabitur pede.
124 | \n\nMaecenas aliquet velit vel turpis. Mauris neque metus, malesuada
125 | nec, ultricies sit amet, porttitor mattis, enim. In massa libero,
126 | interdum nec, interdum vel, blandit sed, nulla. In ullamcorper, est eget
127 | tempor cursus, neque mi consectetuer mi, a ultricies massa est sed nisl.
128 | Class aptent taciti sociosqu ad litora torquent per conubia nostra, per
129 | inceptos hymenaeos. Proin nulla arcu, nonummy luctus, dictum eget,
130 | fermentum et, lorem. Nunc porta convallis pede.
131 |
132 |
--------------------------------------------------------------------------------
/adcatalog/COPYING:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright 2011 Google Inc.
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------