Skip to content
This repository was archived by the owner on Jun 27, 2020. It is now read-only.

Commit ceb70cf

Browse files
Added Vungle video ads
1 parent 7a713aa commit ceb70cf

File tree

9 files changed

+176
-78
lines changed

9 files changed

+176
-78
lines changed

app/build.gradle

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,28 @@ apply plugin: 'com.android.application'
22

33
android {
44
compileSdkVersion 19
5-
buildToolsVersion "19.1.0"
6-
5+
buildToolsVersion '19.1.0'
76
defaultConfig {
8-
applicationId "com.blogspot.e_kanivets.moneytracker"
7+
applicationId 'com.blogspot.e_kanivets.moneytracker'
98
minSdkVersion 10
109
targetSdkVersion 19
1110
versionCode 1
12-
versionName "1.0"
11+
versionName '1.0'
1312
}
14-
1513
buildTypes {
1614
release {
1715
runProguard false
1816
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
1917
}
2018
}
21-
2219
signingConfigs {
2320
releaseConfig {
24-
storeFile file("mt_keystore.jks");
25-
storePassword ("moneytracker");
26-
keyAlias "moneytracker"
27-
keyPassword "moneytracker";
21+
storeFile file('mt_keystore.jks');
22+
storePassword('moneytracker');
23+
keyAlias 'moneytracker'
24+
keyPassword 'moneytracker';
2825
}
2926
}
30-
3127
buildTypes {
3228
release {
3329
debuggable false
@@ -41,18 +37,19 @@ android {
4137
signingConfig signingConfigs.releaseConfig
4238
}
4339
}
44-
4540
lintOptions {
4641
checkReleaseBuilds false
4742
abortOnError false
4843
}
49-
5044
dexOptions {
5145
preDexLibraries = false
5246
}
47+
productFlavors {
48+
}
5349
}
5450

5551
dependencies {
5652
compile fileTree(dir: 'libs', include: ['*.jar'])
5753
compile 'com.android.support:appcompat-v7:20.0.0'
54+
compile 'com.google.android.gms:play-services:+'
5855
}

app/libs/dagger-1.2.2.jar

59.1 KB
Binary file not shown.

app/libs/javax.inject-1.jar

2.44 KB
Binary file not shown.

app/libs/nineoldandroids-2.4.0.jar

108 KB
Binary file not shown.

app/libs/support-v4-18.0.0.jar

550 KB
Binary file not shown.
708 KB
Binary file not shown.

app/src/main/AndroidManifest.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
android:versionName="1.0"
66
>
77

8+
<!-- permissions to download and cache video ads for playback -->
9+
<uses-permission android:name="android.permission.INTERNET" />
10+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
11+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
12+
813
<application
914
android:name=".util.MTApp"
1015
android:allowBackup="true"
@@ -21,6 +26,19 @@
2126
</activity>
2227
<activity android:name=".activity.ReportActivity"/>
2328
<activity android:name=".activity.ThankAuthorActivity"/>
29+
30+
<activity
31+
android:name="com.vungle.publisher.FullScreenAdActivity"
32+
android:configChanges="keyboardHidden|orientation|screenSize"
33+
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
34+
35+
36+
<service android:name="com.vungle.publisher.VungleService"
37+
android:exported="false"/>
38+
39+
<meta-data android:name="com.google.android.gms.version"
40+
android:value="@integer/google_play_services_version" />
41+
2442
</application>
2543

2644
</manifest>

app/src/main/java/com/blogspot/e_kanivets/moneytracker/activity/ThankAuthorActivity.java

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,100 @@
55
import android.view.View;
66
import android.view.Window;
77
import android.widget.Button;
8+
import android.widget.ProgressBar;
9+
import android.widget.TextView;
810

911
import com.blogspot.e_kanivets.moneytracker.R;
12+
import com.blogspot.e_kanivets.moneytracker.util.AppUtils;
13+
import com.vungle.publisher.EventListener;
14+
import com.vungle.publisher.VunglePub;
1015

1116
/**
1217
* Created by fess on 16.11.2014.
1318
*/
1419
public class ThankAuthorActivity extends Activity {
1520

21+
// get the VunglePub instance
22+
final VunglePub vunglePub = VunglePub.getInstance();
23+
24+
private ProgressBar progressBar;
25+
1626
private Activity activity;
1727

28+
private boolean shouldPlay;
29+
1830
@Override
1931
protected void onCreate(Bundle savedInstanceState) {
2032
super.onCreate(savedInstanceState);
2133
requestWindowFeature(Window.FEATURE_NO_TITLE);
2234
setContentView(R.layout.activity_thank_author);
2335

2436
activity = this;
37+
shouldPlay = false;
38+
39+
// initialize the Publisher SDK
40+
final String app_id = "com.blogspot.e_kanivets.moneytracker";
41+
vunglePub.init(this, app_id);
2542

43+
final TextView tvContribution = (TextView) findViewById(R.id.tv_contribution);
2644
Button btnWatchVideoAd = (Button) findViewById(R.id.btn_watch_video_ad);
45+
progressBar = (ProgressBar) findViewById(R.id.progressBar);
46+
47+
tvContribution.setText(Integer.toString(AppUtils.getContribution(activity)));
2748

2849
btnWatchVideoAd.setOnClickListener(new View.OnClickListener() {
2950
@Override
3051
public void onClick(View view) {
31-
52+
if(vunglePub.isCachedAdAvailable()) {
53+
vunglePub.playAd();
54+
} else {
55+
progressBar.setVisibility(View.VISIBLE);
56+
shouldPlay = true;
57+
}
58+
}
59+
});
60+
61+
vunglePub.setEventListener(new EventListener() {
62+
@Override
63+
public void onAdEnd(boolean b) {
64+
AppUtils.addContribution(activity);
65+
tvContribution.setText(Integer.toString(AppUtils.getContribution(activity)));
66+
}
67+
68+
@Override
69+
public void onAdStart() {
70+
71+
}
72+
73+
@Override
74+
public void onAdUnavailable(String s) {
75+
76+
}
77+
78+
@Override
79+
public void onCachedAdAvailable() {
80+
if(shouldPlay) {
81+
vunglePub.playAd();
82+
shouldPlay = false;
83+
}
84+
}
85+
86+
@Override
87+
public void onVideoView(boolean b, int i, int i2) {
88+
3289
}
3390
});
3491
}
92+
93+
@Override
94+
protected void onPause() {
95+
super.onPause();
96+
vunglePub.onPause();
97+
}
98+
99+
@Override
100+
protected void onResume() {
101+
super.onResume();
102+
vunglePub.onResume();
103+
}
35104
}

app/src/main/res/layout/activity_thank_author.xml

Lines changed: 78 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,90 @@
1-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2-
android:orientation="vertical" android:layout_width="match_parent"
3-
android:layout_height="match_parent"
4-
android:background="@color/white">
5-
6-
<LinearLayout
7-
android:orientation="horizontal"
1+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
82
android:layout_width="fill_parent"
9-
android:layout_height="wrap_content"
10-
android:background="@color/yellow_light">
11-
12-
<Button
13-
android:layout_width="0dp"
14-
android:layout_height="wrap_content"
15-
android:background="@drawable/selector_report"
16-
android:padding="15dp" />
3+
android:layout_height="fill_parent">
174

18-
<TextView
19-
android:layout_width="0dp"
5+
<LinearLayout
6+
android:orientation="vertical" android:layout_width="match_parent"
207
android:layout_height="match_parent"
21-
android:textAppearance="?android:attr/textAppearanceLarge"
22-
android:text="@string/thank_author_caps"
23-
android:background="@color/yellow_light"
24-
android:textColor="@color/white"
25-
android:gravity="center"
26-
android:id="@+id/tv_title"
27-
android:layout_weight="1" />
28-
</LinearLayout>
8+
android:background="@color/light_grey">
9+
<LinearLayout
10+
android:orientation="horizontal"
11+
android:layout_width="fill_parent"
12+
android:layout_height="wrap_content"
13+
android:background="@color/yellow_light">
2914

30-
<TextView
31-
android:layout_width="wrap_content"
32-
android:layout_height="wrap_content"
33-
android:text="@string/this_is_free_app"
34-
android:id="@+id/textView"
35-
android:layout_gravity="center_horizontal"
36-
android:layout_margin="10dp"
37-
android:gravity="center" />
15+
<Button
16+
android:layout_width="0dp"
17+
android:layout_height="wrap_content"
18+
android:background="@drawable/selector_report"
19+
android:padding="15dp" />
3820

39-
<Button
40-
android:layout_width="wrap_content"
41-
android:layout_height="wrap_content"
42-
android:text="@string/watch_video"
43-
android:id="@+id/btn_watch_video_ad"
44-
android:layout_gravity="center_horizontal"
45-
android:layout_margin="10dp" />
21+
<TextView
22+
android:layout_width="0dp"
23+
android:layout_height="match_parent"
24+
android:textAppearance="?android:attr/textAppearanceLarge"
25+
android:text="@string/thank_author_caps"
26+
android:background="@color/yellow_light"
27+
android:textColor="@color/white"
28+
android:gravity="center"
29+
android:id="@+id/tv_title"
30+
android:layout_weight="1" />
31+
</LinearLayout>
4632

47-
<View
48-
android:layout_width="match_parent"
49-
android:layout_height="match_parent"
50-
android:layout_gravity="center_horizontal"
51-
android:layout_weight="1" />
33+
<TextView
34+
android:layout_width="wrap_content"
35+
android:layout_height="wrap_content"
36+
android:text="@string/this_is_free_app"
37+
android:id="@+id/textView"
38+
android:layout_gravity="center_horizontal"
39+
android:layout_margin="10dp"
40+
android:gravity="center" />
5241

53-
<LinearLayout
54-
android:orientation="horizontal"
55-
android:layout_width="fill_parent"
56-
android:layout_height="wrap_content"
57-
android:gravity="center"
58-
android:padding="10dp">
42+
<Button
43+
android:layout_width="wrap_content"
44+
android:layout_height="wrap_content"
45+
android:text="@string/watch_video"
46+
android:id="@+id/btn_watch_video_ad"
47+
android:layout_gravity="center_horizontal"
48+
android:layout_margin="10dp" />
5949

60-
<TextView
61-
android:layout_width="wrap_content"
62-
android:layout_height="wrap_content"
63-
android:textAppearance="?android:attr/textAppearanceLarge"
64-
android:text="@string/your_contribution"
65-
android:layout_gravity="center_horizontal"
66-
android:layout_marginRight="10dp" />
50+
<View
51+
android:layout_width="match_parent"
52+
android:layout_height="match_parent"
53+
android:layout_gravity="center_horizontal"
54+
android:layout_weight="1" />
6755

68-
<TextView
56+
<LinearLayout
57+
android:orientation="horizontal"
58+
android:layout_width="fill_parent"
59+
android:layout_height="wrap_content"
60+
android:gravity="center"
61+
android:padding="10dp">
62+
63+
<TextView
64+
android:layout_width="wrap_content"
65+
android:layout_height="wrap_content"
66+
android:textAppearance="?android:attr/textAppearanceLarge"
67+
android:text="@string/your_contribution"
68+
android:layout_gravity="center_horizontal"
69+
android:layout_marginRight="10dp" />
70+
71+
<TextView
72+
android:layout_width="wrap_content"
73+
android:layout_height="wrap_content"
74+
android:textAppearance="?android:attr/textAppearanceLarge"
75+
android:text="0"
76+
android:id="@+id/tv_contribution" />
77+
</LinearLayout>
78+
79+
</LinearLayout>
80+
81+
<ProgressBar
82+
style="?android:attr/progressBarStyleLarge"
6983
android:layout_width="wrap_content"
7084
android:layout_height="wrap_content"
71-
android:textAppearance="?android:attr/textAppearanceLarge"
72-
android:text="0"
73-
android:id="@+id/tv_contribution" />
74-
</LinearLayout>
85+
android:id="@+id/progressBar"
86+
android:layout_gravity="center"
87+
android:visibility="invisible" />
88+
89+
</FrameLayout>
7590

76-
</LinearLayout>

0 commit comments

Comments
 (0)