Skip to content

Commit 0e0098f

Browse files
feat: update dependencies in the demo apps #25
Migrate the latest version of Google Mobile Ads. Rewrite PublisherAdView to new AdManagerAdView. Import the latest version of the Optable SDK in the demo apps. Add testing application ID.
1 parent 7276108 commit 0e0098f

File tree

11 files changed

+81
-77
lines changed

11 files changed

+81
-77
lines changed

DemoApp/DemoAppJava/app/build.gradle

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ android {
1010

1111
defaultConfig {
1212
applicationId "co.optable.demoappjava"
13-
minSdkVersion 21
13+
minSdkVersion 23
1414
targetSdkVersion 34
1515

1616
versionCode versioning.getVersionCode()
@@ -40,24 +40,24 @@ android {
4040
}
4141

4242
dependencies {
43-
implementation 'com.google.android.gms:play-services-ads:19.3.0'
44-
implementation "com.github.Optable:optable-android-sdk:" + versioning.getVersionName(false)
43+
// Optable SDK
44+
// TODO: Return to this version after release
45+
// implementation "com.github.Optable:optable-android-sdk:" + versioning.getVersionName(false)
46+
implementation "com.github.Optable:optable-android-sdk:feature~upgrade_to_new_versions-SNAPSHOT"
4547

48+
49+
// Google Mobile Ads
50+
implementation 'com.google.android.gms:play-services-ads:24.6.0'
51+
52+
// Base Android
4653
implementation "org.jetbrains.kotlin:kotlin-stdlib:2.0.21"
47-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9'
4854
implementation 'com.android.support:multidex:1.0.3'
49-
implementation 'androidx.core:core-ktx:1.1.0'
50-
implementation 'androidx.appcompat:appcompat:1.1.0'
51-
implementation 'com.google.android.material:material:1.0.0'
5255
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
53-
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
5456
implementation 'androidx.navigation:navigation-fragment:2.1.0'
5557
implementation 'androidx.navigation:navigation-ui:2.1.0'
56-
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
57-
implementation 'androidx.navigation:navigation-fragment-ktx:2.1.0'
58-
implementation 'androidx.navigation:navigation-ui-ktx:2.1.0'
5958

60-
testImplementation 'junit:junit:4.12'
59+
// Testing
60+
testImplementation 'junit:junit:4.13.1'
6161
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
6262
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
6363
}

DemoApp/DemoAppJava/app/src/main/AndroidManifest.xml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="co.optable.demoappjava">
44

5+
<uses-permission android:name="android.permission.INTERNET" />
6+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
7+
58
<application
69
android:allowBackup="true"
710
android:icon="@mipmap/ic_launcher"
@@ -10,6 +13,7 @@
1013
android:supportsRtl="true"
1114
android:theme="@style/AppTheme"
1215
android:usesCleartextTraffic="true">
16+
1317
<activity
1418
android:exported="true"
1519
android:name="co.optable.demoappjava.MainActivity"
@@ -20,11 +24,11 @@
2024
<category android:name="android.intent.category.LAUNCHER" />
2125
</intent-filter>
2226
</activity>
27+
2328
<meta-data
24-
android:name="com.google.android.gms.ads.AD_MANAGER_APP"
25-
android:value="true" />
29+
android:name="com.google.android.gms.ads.APPLICATION_ID"
30+
android:value="ca-app-pub-1875909575462531~6255590079" />
31+
2632
</application>
2733

28-
<uses-permission android:name="android.permission.INTERNET" />
29-
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
3034
</manifest>

DemoApp/DemoAppJava/app/src/main/java/co/optable/demoappjava/MainActivity.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
package co.optable.demoappjava;
22

33
import android.os.Bundle;
4-
5-
import com.google.android.material.bottomnavigation.BottomNavigationView;
6-
74
import androidx.appcompat.app.AppCompatActivity;
85
import androidx.navigation.NavController;
96
import androidx.navigation.Navigation;
107
import androidx.navigation.ui.AppBarConfiguration;
118
import androidx.navigation.ui.NavigationUI;
129
import co.optable.android_sdk.OptableSDK;
10+
import com.google.android.material.bottomnavigation.BottomNavigationView;
1311

1412
public class MainActivity extends AppCompatActivity {
1513
public static OptableSDK OPTABLE;
@@ -19,7 +17,7 @@ protected void onCreate(Bundle savedInstanceState) {
1917
super.onCreate(savedInstanceState);
2018
setContentView(R.layout.activity_main);
2119

22-
MainActivity.OPTABLE = new OptableSDK(this.getApplicationContext(), "sandbox.optable.co", "android-sdk-demo");
20+
MainActivity.OPTABLE = new OptableSDK(this.getApplicationContext(), "sandbox.optable.co", "ios-sdk-demo");
2321

2422
BottomNavigationView navView = findViewById(R.id.nav_view);
2523
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);

DemoApp/DemoAppJava/app/src/main/java/co/optable/demoappjava/ui/GAMBanner/GAMBannerFragment.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,28 @@
66
import android.view.ViewGroup;
77
import android.widget.Button;
88
import android.widget.TextView;
9-
109
import androidx.annotation.NonNull;
1110
import androidx.fragment.app.Fragment;
12-
13-
import com.google.android.gms.ads.doubleclick.PublisherAdRequest;
14-
import com.google.android.gms.ads.doubleclick.PublisherAdView;
15-
16-
import java.util.HashMap;
17-
import java.util.List;
18-
1911
import co.optable.android_sdk.OptableSDK;
2012
import co.optable.demoappjava.MainActivity;
2113
import co.optable.demoappjava.R;
14+
import com.google.android.gms.ads.AdRequest;
15+
import com.google.android.gms.ads.admanager.AdManagerAdRequest;
16+
import com.google.android.gms.ads.admanager.AdManagerAdView;
17+
18+
import java.util.HashMap;
19+
import java.util.List;
2220

2321
public class GAMBannerFragment extends Fragment {
24-
private PublisherAdView mPublisherAdView;
22+
23+
private AdManagerAdView mAdView;
2524
private TextView targetingDataView;
2625

2726
@Override
2827
public View onCreateView(@NonNull LayoutInflater inflater,
2928
ViewGroup container, Bundle savedInstanceState) {
3029
View root = inflater.inflate(R.layout.fragment_gambanner, container, false);
31-
mPublisherAdView = root.findViewById(R.id.publisherAdView);
30+
mAdView = root.findViewById(R.id.publisherAdView);
3231
targetingDataView = root.findViewById(R.id.targetingDataView);
3332

3433
// loadAdButton loads targeting data and then the GAM banner:
@@ -37,7 +36,7 @@ public View onCreateView(@NonNull LayoutInflater inflater,
3736
targetingDataView.setText("");
3837

3938
MainActivity.OPTABLE.targeting().observe(getViewLifecycleOwner(), result -> {
40-
PublisherAdRequest.Builder adRequest = new PublisherAdRequest.Builder();
39+
AdManagerAdRequest.Builder adRequest = new AdManagerAdRequest.Builder();
4140
final StringBuilder msg = new StringBuilder();
4241
msg.append(targetingDataView.getText().toString());
4342

@@ -52,7 +51,7 @@ public View onCreateView(@NonNull LayoutInflater inflater,
5251
}
5352

5453
targetingDataView.setText(msg.toString());
55-
mPublisherAdView.loadAd(adRequest.build());
54+
mAdView.loadAd(adRequest.build());
5655
profile();
5756
witness();
5857
});
@@ -62,7 +61,7 @@ public View onCreateView(@NonNull LayoutInflater inflater,
6261
btn = root.findViewById(R.id.loadAdButton2);
6362
btn.setOnClickListener(view -> {
6463
targetingDataView.setText("");
65-
PublisherAdRequest.Builder adRequest = new PublisherAdRequest.Builder();
64+
AdRequest.Builder adRequest = new AdRequest.Builder();
6665
final StringBuilder msg = new StringBuilder();
6766
HashMap<String, List<String>> data = MainActivity.OPTABLE.targetingFromCache();
6867

@@ -77,7 +76,7 @@ public View onCreateView(@NonNull LayoutInflater inflater,
7776
}
7877

7978
targetingDataView.setText(msg.toString());
80-
mPublisherAdView.loadAd(adRequest.build());
79+
mAdView.loadAd(adRequest.build());
8180
profile();
8281
witness();
8382
});

DemoApp/DemoAppJava/app/src/main/java/co/optable/demoappjava/ui/Identify/IdentifyFragment.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
import android.widget.EditText;
99
import android.widget.Switch;
1010
import android.widget.TextView;
11-
1211
import androidx.annotation.NonNull;
1312
import androidx.fragment.app.Fragment;
14-
1513
import co.optable.android_sdk.OptableSDK;
1614
import co.optable.demoappjava.MainActivity;
1715
import co.optable.demoappjava.R;
@@ -30,20 +28,22 @@ public View onCreateView(@NonNull LayoutInflater inflater,
3028
gaidSwitch = root.findViewById(R.id.gaidSwitch);
3129

3230
Button btn = root.findViewById(R.id.identifyButton);
33-
btn.setOnClickListener(view ->
31+
btn.setOnClickListener(view -> {
32+
identifyView.setText("");
3433
MainActivity.OPTABLE
35-
.identify(emailText.getText().toString(), gaidSwitch.isChecked())
36-
.observe(getViewLifecycleOwner(), result -> {
37-
String msg = "Calling identify API... ";
38-
39-
if (result.getStatus() == OptableSDK.Status.SUCCESS) {
40-
msg += "Success";
41-
} else {
42-
msg += "\n\nOptableSDK Error: " + result.getMessage();
43-
}
44-
45-
identifyView.setText(msg);
46-
})
34+
.identify(emailText.getText().toString(), gaidSwitch.isChecked())
35+
.observe(getViewLifecycleOwner(), result -> {
36+
String msg = "Calling identify API... ";
37+
38+
if (result.getStatus() == OptableSDK.Status.SUCCESS) {
39+
msg += "Success";
40+
} else {
41+
msg += "\n\nOptableSDK Error: " + result.getMessage();
42+
}
43+
44+
identifyView.setText(msg);
45+
});
46+
}
4747
);
4848

4949
return root;

DemoApp/DemoAppJava/app/src/main/res/layout/fragment_gambanner.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
android:layout_height="match_parent"
77
tools:context=".ui.GAMBanner.GAMBannerFragment">
88

9-
<com.google.android.gms.ads.doubleclick.PublisherAdView
9+
<com.google.android.gms.ads.admanager.AdManagerAdView
1010
android:id="@+id/publisherAdView"
1111
android:layout_width="wrap_content"
1212
android:layout_height="wrap_content"
@@ -18,7 +18,7 @@
1818
app:layout_constraintBottom_toBottomOf="parent"
1919
app:layout_constraintEnd_toEndOf="parent"
2020
app:layout_constraintHorizontal_bias="0.494"
21-
app:layout_constraintStart_toStartOf="parent"></com.google.android.gms.ads.doubleclick.PublisherAdView>
21+
app:layout_constraintStart_toStartOf="parent" />
2222

2323
<Button
2424
android:id="@+id/loadAdButton"
@@ -64,4 +64,5 @@
6464
app:layout_constraintEnd_toEndOf="parent"
6565
app:layout_constraintStart_toStartOf="parent"
6666
app:layout_constraintTop_toBottomOf="@+id/loadAdButton" />
67+
6768
</androidx.constraintlayout.widget.ConstraintLayout>

DemoApp/DemoAppKotlin/app/build.gradle

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ android {
99
namespace "co.optable.androidsdkdemo"
1010

1111
defaultConfig {
12-
// TODO: Change
1312
applicationId "co.optable.androidsdkdemo"
14-
minSdkVersion 21
13+
minSdkVersion 23
1514
targetSdkVersion 34
1615

1716
versionCode versioning.getVersionCode()
@@ -41,24 +40,23 @@ android {
4140
}
4241

4342
dependencies {
43+
// Optable SDK
44+
// TODO: Return to this version after release
45+
// implementation "com.github.Optable:optable-android-sdk:" + versioning.getVersionName(false)
46+
implementation "com.github.Optable:optable-android-sdk:feature~upgrade_to_new_versions-SNAPSHOT"
47+
48+
// Google Mobile Ads
49+
implementation 'com.google.android.gms:play-services-ads:24.6.0'
50+
51+
// Base Android
4452
implementation "org.jetbrains.kotlin:kotlin-stdlib:2.0.21"
45-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9'
4653
implementation 'com.android.support:multidex:1.0.3'
47-
implementation 'androidx.core:core-ktx:1.1.0'
48-
implementation 'androidx.appcompat:appcompat:1.1.0'
49-
implementation 'com.google.android.material:material:1.0.0'
5054
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
51-
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
52-
implementation 'androidx.navigation:navigation-fragment:2.1.0'
53-
implementation 'androidx.navigation:navigation-ui:2.1.0'
54-
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
5555
implementation 'androidx.navigation:navigation-fragment-ktx:2.1.0'
5656
implementation 'androidx.navigation:navigation-ui-ktx:2.1.0'
5757

58-
testImplementation 'junit:junit:4.12'
58+
// Testing
59+
testImplementation 'junit:junit:4.13.1'
5960
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
6061
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
61-
62-
implementation 'com.google.android.gms:play-services-ads:19.3.0'
63-
implementation "com.github.Optable:optable-android-sdk:" + versioning.getVersionName(false)
6462
}

DemoApp/DemoAppKotlin/app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
android:supportsRtl="true"
1414
android:theme="@style/AppTheme"
1515
android:usesCleartextTraffic="true">
16+
1617
<activity
1718
android:exported="true"
1819
android:name="co.optable.androidsdkdemo.MainActivity"
@@ -23,8 +24,10 @@
2324
<category android:name="android.intent.category.LAUNCHER" />
2425
</intent-filter>
2526
</activity>
27+
2628
<meta-data
27-
android:name="com.google.android.gms.ads.AD_MANAGER_APP"
28-
android:value="true" />
29+
android:name="com.google.android.gms.ads.APPLICATION_ID"
30+
android:value="ca-app-pub-1875909575462531~6255590079" />
31+
2932
</application>
3033
</manifest>

DemoApp/DemoAppKotlin/app/src/main/java/co/optable/androidsdkdemo/ui/GAMBanner/GAMBannerFragment.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ import androidx.lifecycle.Observer
1515
import co.optable.android_sdk.OptableSDK
1616
import co.optable.androidsdkdemo.MainActivity
1717
import co.optable.androidsdkdemo.R
18-
import com.google.android.gms.ads.doubleclick.PublisherAdRequest
19-
import com.google.android.gms.ads.doubleclick.PublisherAdView
18+
import com.google.android.gms.ads.admanager.AdManagerAdRequest
19+
import com.google.android.gms.ads.admanager.AdManagerAdView
2020

2121
class GAMBannerFragment : Fragment() {
2222

23-
private lateinit var mPublisherAdView: PublisherAdView
23+
private lateinit var mAdView: AdManagerAdView
2424
private lateinit var targetingDataView: TextView
2525

2626
override fun onCreateView(
@@ -29,7 +29,7 @@ class GAMBannerFragment : Fragment() {
2929
savedInstanceState: Bundle?
3030
): View? {
3131
val root = inflater.inflate(R.layout.fragment_gambanner, container, false)
32-
mPublisherAdView = root.findViewById(R.id.publisherAdView)
32+
mAdView = root.findViewById(R.id.publisherAdView)
3333
targetingDataView = root.findViewById(R.id.targetingDataView)
3434
targetingDataView.setText("")
3535

@@ -38,7 +38,7 @@ class GAMBannerFragment : Fragment() {
3838
btn.setOnClickListener {
3939
MainActivity.OPTABLE!!.targeting().observe(viewLifecycleOwner, Observer { result ->
4040
var msg = ""
41-
var adRequest = PublisherAdRequest.Builder()
41+
var adRequest = AdManagerAdRequest.Builder()
4242

4343
if (result.status == OptableSDK.Status.SUCCESS) {
4444
msg += "Loading GAM ad with targeting data:\n\n"
@@ -51,7 +51,7 @@ class GAMBannerFragment : Fragment() {
5151
}
5252

5353
targetingDataView.setText(msg)
54-
mPublisherAdView.loadAd(adRequest.build())
54+
mAdView.loadAd(adRequest.build())
5555
profile()
5656
witness()
5757
})
@@ -61,7 +61,7 @@ class GAMBannerFragment : Fragment() {
6161
btn = root.findViewById(R.id.loadAdButton2) as Button
6262
btn.setOnClickListener {
6363
var msg = ""
64-
var adRequest = PublisherAdRequest.Builder()
64+
var adRequest = AdManagerAdRequest.Builder()
6565
var data = MainActivity.OPTABLE!!.targetingFromCache()
6666

6767
if (data != null) {
@@ -75,7 +75,7 @@ class GAMBannerFragment : Fragment() {
7575
}
7676

7777
targetingDataView.setText(msg)
78-
mPublisherAdView.loadAd(adRequest.build())
78+
mAdView.loadAd(adRequest.build())
7979
profile()
8080
witness()
8181
}

DemoApp/DemoAppKotlin/app/src/main/java/co/optable/androidsdkdemo/ui/Identify/IdentifyFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class IdentifyFragment : Fragment() {
3535

3636
var btn = root.findViewById(R.id.identifyButton) as Button
3737
btn.setOnClickListener {
38+
identifyView.text = ""
3839
MainActivity.OPTABLE!!
3940
.identify(emailText.text.toString(), gaidSwitch.isChecked)
4041
.observe(viewLifecycleOwner, Observer

0 commit comments

Comments
 (0)