-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
305 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'org.jetbrains.kotlin.android' | ||
} | ||
|
||
apply from: rootProject.file("$rootDir/common.gradle") | ||
|
||
android { | ||
namespace 'com.uid2.devapp' | ||
|
||
defaultConfig { | ||
applicationId "com.uid2.securesignals.gma.devapp" | ||
minSdk 21 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
} | ||
} | ||
|
||
lint { | ||
disable 'GradleDependency' | ||
} | ||
|
||
} | ||
|
||
dependencies { | ||
implementation project(path: ':securesignals-gma') | ||
compileOnly 'com.uid2:uid2-android-sdk:0.1.0' | ||
compileOnly 'com.google.android.gms:play-services-ads:22.0.0' | ||
|
||
implementation 'androidx.multidex:multidex:2.0.1' | ||
implementation 'androidx.appcompat:appcompat:1.6.1' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application | ||
android:name="com.uid2.dev.GMADevApplication" | ||
android:label="@string/app_name" | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:theme="@style/AppTheme"> | ||
|
||
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 --> | ||
<meta-data | ||
android:name="com.google.android.gms.ads.APPLICATION_ID" | ||
android:value="ca-app-pub-3940256099942544~3347511713"/> | ||
|
||
<activity | ||
android:exported="true" | ||
android:name="com.uid2.dev.BannerActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
152 changes: 152 additions & 0 deletions
152
securesignals-gma-dev-app/src/main/java/com/uid2/dev/BannerActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
package com.uid2.dev; | ||
|
||
import static com.google.ads.AdRequest.LOGTAG; | ||
|
||
import android.os.Bundle; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
import android.util.Log; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import com.google.android.gms.ads.AdRequest; | ||
import com.google.android.gms.ads.AdView; | ||
import com.google.android.gms.ads.MobileAds; | ||
import com.google.android.gms.ads.RequestConfiguration; | ||
import com.google.android.gms.ads.initialization.InitializationStatus; | ||
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener; | ||
import com.uid2.UID2Manager; | ||
import com.uid2.data.UID2Identity; | ||
import com.uid2.devapp.R; | ||
|
||
import org.json.JSONObject; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.util.Arrays; | ||
|
||
/** | ||
* Port of <a href="https://github.com/googleads/googleads-mobile-android-examples/tree/main/java/admob/BannerExample">BannerExample</a> | ||
*/ | ||
public class BannerActivity extends AppCompatActivity { | ||
|
||
private AdView adView; | ||
private static final String TAG = "MyActivity"; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.banner_activity); | ||
|
||
// Load UID2Identity to test with | ||
loadUID2Identity(); | ||
|
||
// Log the Mobile Ads SDK version. | ||
Log.d(TAG, "Google Mobile Ads SDK Version: " + MobileAds.getVersion()); | ||
|
||
// Initialize the Mobile Ads SDK. | ||
MobileAds.initialize(this, new OnInitializationCompleteListener() { | ||
@Override | ||
public void onInitializationComplete(InitializationStatus initializationStatus) {} | ||
}); | ||
|
||
// Set your test devices. Check your logcat output for the hashed device ID to | ||
// get test ads on a physical device. e.g. | ||
// "Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("ABCDEF012345")) | ||
// to get test ads on this device." | ||
MobileAds.setRequestConfiguration( | ||
new RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("ABCDEF012345")) | ||
.build()); | ||
|
||
// Gets the ad view defined in layout/ad_fragment.xml with ad unit ID set in | ||
// values/strings.xml. | ||
adView = findViewById(R.id.ad_view); | ||
|
||
// Create an ad request. | ||
AdRequest adRequest = new AdRequest.Builder().build(); | ||
|
||
// Start loading the ad in the background. | ||
adView.loadAd(adRequest); | ||
} | ||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
// Inflate the menu; this adds items to the action bar if it is present. | ||
getMenuInflater().inflate(R.menu.my, menu); | ||
return true; | ||
} | ||
|
||
private void loadUID2Identity() { | ||
|
||
InputStream is = getResources().openRawResource(R.raw.uid2identity); | ||
StringBuilder text = new StringBuilder(); | ||
|
||
try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) { | ||
String line; | ||
|
||
while ((line = br.readLine()) != null) { | ||
text.append(line); | ||
text.append('\n'); | ||
} | ||
|
||
String jsonString = text.toString(); | ||
JSONObject jsonObject = new JSONObject(jsonString); | ||
UID2Identity fromJsonIdentity = UID2Identity.Companion.fromJson(jsonObject); | ||
|
||
// Emulate A UID2Identity With Valid Times | ||
long now = System.currentTimeMillis(); | ||
long identityExpires = now * 60 * 60; | ||
long refreshFrom = now * 60 * 40; | ||
long refreshExpires = now * 60 * 80; | ||
|
||
UID2Identity identity = new UID2Identity(fromJsonIdentity.getAdvertisingToken(), | ||
fromJsonIdentity.getRefreshToken(), | ||
identityExpires, | ||
refreshFrom, | ||
refreshExpires, | ||
fromJsonIdentity.getRefreshResponseKey()); | ||
UID2Manager.getInstance().setIdentity(identity); | ||
} catch (Exception e) { | ||
Log.e(LOGTAG, "Error loading Identity: " + e); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
// Handle action bar item clicks here. The action bar will | ||
// automatically handle clicks on the Home/Up button, so long | ||
// as you specify a parent activity in AndroidManifest.xml. | ||
int id = item.getItemId(); | ||
if (id == R.id.action_settings) { | ||
return true; | ||
} | ||
return super.onOptionsItemSelected(item); | ||
} | ||
|
||
/** Called when leaving the activity */ | ||
@Override | ||
public void onPause() { | ||
if (adView != null) { | ||
adView.pause(); | ||
} | ||
super.onPause(); | ||
} | ||
|
||
/** Called when returning to the activity */ | ||
@Override | ||
public void onResume() { | ||
super.onResume(); | ||
if (adView != null) { | ||
adView.resume(); | ||
} | ||
} | ||
|
||
/** Called before the activity is destroyed */ | ||
@Override | ||
public void onDestroy() { | ||
if (adView != null) { | ||
adView.destroy(); | ||
} | ||
super.onDestroy(); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
securesignals-gma-dev-app/src/main/java/com/uid2/dev/GMADevApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.uid2.dev; | ||
|
||
import android.app.Application; | ||
import com.uid2.UID2Manager; | ||
|
||
public class GMADevApplication extends Application { | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
UID2Manager.init(getApplicationContext()); | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
securesignals-gma-dev-app/src/main/res/layout/banner_activity.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
xmlns:ads="http://schemas.android.com/apk/res-auto" | ||
android:id="@+id/container" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_marginTop="@dimen/activity_vertical_margin" | ||
tools:context="com.uid2.dev.BannerActivity" | ||
tools:ignore="MergeRootFrame"> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="@dimen/activity_horizontal_margin" | ||
android:text="@string/hello_world" /> | ||
|
||
<com.google.android.gms.ads.AdView | ||
android:id="@+id/ad_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_centerHorizontal="true" | ||
android:layout_alignParentBottom="true" | ||
ads:adSize="BANNER" | ||
ads:adUnitId="@string/banner_ad_unit_id" /> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
tools:context=".MyActivity" > | ||
<item android:id="@+id/action_settings" | ||
android:title="@string/action_settings" | ||
android:orderInCategory="100" | ||
app:showAsAction="never" /> | ||
</menu> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.78 KB
securesignals-gma-dev-app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"advertising_token": "NewAdvertisingTokenIjb6u6KcMAtd0/4ZIAYkXvFrMdlZVqfb9LNf99B+1ysE/lBzYVt64pxYxjobJMGbh5q/HsKY7KC0Xo5Rb/Vo8HC4dYOoWXyuGUaL7Jmbw4bzh+3pgokelUGyTX19DfArTeIg7n+8cxWQ=", | ||
"refresh_token": "NewRefreshTokenAAAF2c8H5dF8AAAF2c8H5dF8AAAADX393Vw94afoVLL6A+qjdSUEisEKx6t42fLgN+2dmTgUavagz0Q6Kp7ghM989hKhZDyAGjHyuAAwm+CX1cO7DWEtMeNUA9vkWDjcIc8yeDZ+jmBtEaw07x/cxoul6fpv2PQ==", | ||
"identity_expires": 1633643601000, | ||
"refresh_from": 1633643001000, | ||
"refresh_expires": 1636322000000, | ||
"refresh_response_key": "yptCUTBoZm1ffosgCrmuwg==", | ||
"status": "success" | ||
} |
6 changes: 6 additions & 0 deletions
6
securesignals-gma-dev-app/src/main/res/values-w820dp/dimens.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<resources> | ||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml | ||
(such as screen margins) for screens with more than 820dp of available width. This | ||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> | ||
<dimen name="activity_horizontal_margin">64dp</dimen> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<resources> | ||
<!-- Default screen margins, per the Android Design guidelines. --> | ||
<dimen name="activity_horizontal_margin">16dp</dimen> | ||
<dimen name="activity_vertical_margin">16dp</dimen> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
|
||
<string name="app_name">Secure Signals GMA DevApp</string> | ||
<string name="hello_world">Hello world!</string> | ||
<string name="action_settings">Settings</string> | ||
|
||
<!-- This is an ad unit ID for a test ad. Replace with your own banner ad unit id. --> | ||
<string name="banner_ad_unit_id">ca-app-pub-3940256099942544/6300978111</string> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<resources> | ||
|
||
<!-- Base application theme. --> | ||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | ||
<!-- Customize your theme here. --> | ||
</style> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters