Skip to content

Commit 0885aed

Browse files
author
Unity Ads Travis
committed
Release 3.0.1
1 parent edbffc8 commit 0885aed

File tree

26 files changed

+2215
-95
lines changed

26 files changed

+2215
-95
lines changed

Diff for: .editorconfig

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[*]
2+
charset=utf-8
3+
end_of_line=lf
4+
insert_final_newline=false
5+
indent_style=space
6+
indent_size=4
7+
8+
[*.java]
9+
indent_style=tab
10+
tab_width=4
11+
12+
[{*.yml,*.yaml}]
13+
indent_style=space
14+
indent_size=2

Diff for: Jenkinsfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@Library('applifier-shared-libs@master') _
2+
3+
Script {
4+
extraSteps = ['scripts/extra.groovy']
5+
disable_registry = true
6+
}

Diff for: Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ zip: release
5656
rm unity-ads.aar
5757

5858
use-local-webview:
59-
sed -i '' 's/return "https:\/\/config.unityads.unity3d.com\/webview\/" + getWebViewBranch() + "\/" + flavor + "\/config.json";/return "new-ip";/' "lib/src/main/java/com/unity3d/ads/properties/SdkProperties.java"
60-
sed -i '' 's/return ".*";/return "http:\/\/$(shell ifconfig |grep "inet" |grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" |grep -v -E "^0|^127" -m 1):8000\/build\/dev\/config.json";/' "lib/src/main/java/com/unity3d/ads/properties/SdkProperties.java"
59+
sed -i '' 's/return "https:\/\/config.unityads.unity3d.com\/webview\/" + getWebViewBranch() + "\/" + flavor + "\/config.json";/return "new-ip";/' "lib/src/main/java/com/unity3d/services/core/properties/SdkProperties.java"
60+
sed -i '' 's/return ".*";/return "http:\/\/$(shell ifconfig |grep "inet" |grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" |grep -v -E "^0|^127" -m 1):8000\/build\/" + flavor + "\/config.json";/' "lib/src/main/java/com/unity3d/services/core/properties/SdkProperties.java"
6161

6262
use-public-webview:
63-
sed -i '' 's/return ".*";/return "https:\/\/config.unityads.unity3d.com\/webview\/" + getWebViewBranch() + "\/" + flavor + "\/config.json";/' "lib/src/main/java/com/unity3d/ads/properties/SdkProperties.java"
63+
sed -i '' 's/return ".*";/return "https:\/\/config.unityads.unity3d.com\/webview\/" + getWebViewBranch() + "\/" + flavor + "\/config.json";/' "lib/src/main/java/com/unity3d/services/core/properties/SdkProperties.java"

Diff for: app/src/main/java/com/unity3d/ads/example/UnityAdsExample.java

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class UnityAdsExample extends Activity {
2929

3030
private String interstitialPlacementId;
3131
private String incentivizedPlacementId;
32+
private Button bannerButton;
3233

3334
private static int ordinal = 1;
3435

@@ -93,6 +94,9 @@ public void onClick(View v) {
9394
}
9495
});
9596

97+
bannerButton = (Button) findViewById(R.id.unityads_example_banner_button);
98+
disableButton(bannerButton);
99+
96100
final Button initializeButton = (Button) findViewById(R.id.unityads_example_initialize_button);
97101
final EditText gameIdEdit = (EditText) findViewById(R.id.unityads_example_gameid_edit);
98102
final CheckBox testModeCheckbox = (CheckBox) findViewById(R.id.unityads_example_testmode_checkbox);

Diff for: app/src/main/java/com/unity3d/ads/example/UnityMonetizationExample.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.unity3d.services.UnityServices;
2525
import com.unity3d.services.banners.IUnityBannerListener;
2626
import com.unity3d.services.banners.UnityBanners;
27+
import com.unity3d.services.banners.view.BannerPosition;
2728
import com.unity3d.services.core.log.DeviceLog;
2829
import com.unity3d.services.core.properties.SdkProperties;
2930
import com.unity3d.services.core.webview.WebView;
@@ -155,11 +156,12 @@ public void onAdFinished(String placementId, UnityAds.FinishState withState) {
155156
});
156157

157158
bannerButton = (Button) findViewById(R.id.unityads_example_banner_button);
158-
enableButton(bannerButton);
159+
disableButton(bannerButton);
159160
bannerButton.setOnClickListener(new View.OnClickListener() {
160161
@Override
161162
public void onClick(View v) {
162163
if (bannerView == null) {
164+
UnityBanners.setBannerPosition(BannerPosition.BOTTOM_CENTER);
163165
UnityBanners.loadBanner(thisActivity, bannerPlacementId);
164166
} else {
165167
UnityBanners.destroy();
@@ -196,6 +198,8 @@ public void onClick(View v) {
196198
SharedPreferences.Editor preferencesEdit = preferences.edit();
197199
preferencesEdit.putString("gameId", gameId);
198200
preferencesEdit.commit();
201+
202+
enableButton(bannerButton);
199203
}
200204
});
201205

@@ -230,6 +234,8 @@ protected void onResume() {
230234
else {
231235
disableButton((Button) findViewById(R.id.unityads_example_incentivized_button));
232236
}
237+
238+
enableButton(bannerButton);
233239
}
234240
}
235241

Diff for: lib/build.gradle

+13-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,18 @@ android {
1111
defaultConfig {
1212
minSdkVersion 9
1313
targetSdkVersion 26
14-
versionCode = 3000
15-
versionName = "3.0.0"
14+
/*
15+
Please ensure that the last two digits of version number does not exceed 50 unless
16+
it is a China SDK. This is because adding 50 to the version number is a one-to-one
17+
mapping between normal SDK and China SDK.
18+
19+
Example : version number 2350 corresponds to China version of 2300.
20+
21+
All SDK with version numbers with last two digits >= 50 will be treated
22+
as China SDK for filtering in the backend.
23+
*/
24+
versionCode = 3001
25+
versionName = "3.0.1"
1626

1727
setProperty("archivesBaseName", "unity-ads")
1828

@@ -77,6 +87,7 @@ android.libraryVariants.all { variant ->
7787
linksOffline "http://developer.android.com/reference","${android.sdkDirectory}/docs/reference"
7888
}
7989
exclude '**/R.java'
90+
exclude 'com/unity3d/services/ar/view/GLSurfaceView.java'
8091
destinationDir = file("../javadoc/")
8192
}
8293
}

Diff for: lib/src/main/java/com/unity3d/services/ads/api/Placement.java

+6
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,10 @@ public static void setPlacementState(String placement, String placementState, We
1818

1919
callback.invoke();
2020
}
21+
22+
@WebViewExposed
23+
public static void setDefaultBannerPlacement(String placement, WebViewCallback callback) {
24+
com.unity3d.services.ads.placement.Placement.setDefaultBannerPlacement(placement);
25+
callback.invoke();
26+
}
2127
}

Diff for: lib/src/main/java/com/unity3d/services/ar/api/AR.java

+27
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,33 @@ public static void advanceFrame(WebViewCallback callback) {
135135
}
136136
}
137137

138+
@WebViewExposed
139+
public static void swapBuffers(WebViewCallback callback) {
140+
AdUnitActivity activity = AdUnit.getAdUnitActivity();
141+
if (activity != null && AR.getARView() != null) {
142+
AR.getARView().swapBuffers();
143+
callback.invoke();
144+
} else {
145+
callback.error(ARError.ARVIEW_NULL);
146+
}
147+
}
148+
149+
@WebViewExposed
150+
public static void setViewRenderMode(Integer mode, WebViewCallback callback) {
151+
final AdUnitActivity activity = AdUnit.getAdUnitActivity();
152+
if (activity != null && AR.getARView() != null) {
153+
try {
154+
AR.getARView().setRenderMode(mode);
155+
} catch (IllegalArgumentException e) {
156+
callback.error(ARError.INVALID_VALUE);
157+
return;
158+
}
159+
callback.invoke();
160+
} else {
161+
callback.error(ARError.ARVIEW_NULL);
162+
}
163+
}
164+
138165
// Android doesn't support video format selection at the moment and it's not possible to get the
139166
// image size before session starts. This is here for API compatibility with iOS.
140167
@WebViewExposed

Diff for: lib/src/main/java/com/unity3d/services/ar/view/ARView.java

+17-15
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import android.annotation.TargetApi;
44
import android.content.Context;
55
import android.opengl.GLES20;
6-
import android.opengl.GLSurfaceView;
76
import android.os.Build;
87
import android.util.SparseArray;
98

@@ -79,7 +78,8 @@ public ARView(Context context) {
7978
setEGLContextClientVersion(2);
8079
setEGLConfigChooser(8, 8, 8, 8, 16, 0); // Alpha used for plane blending.
8180
setRenderer(this);
82-
setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
81+
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
82+
setPreserveEGLContextOnPause(true);
8383

8484
_displayRotationHelper = new DisplayRotationHelper(context);
8585
}
@@ -144,8 +144,6 @@ public void onSurfaceChanged(GL10 gl, int width, int height) {
144144

145145
@Override
146146
public void onDrawFrame(GL10 gl) {
147-
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
148-
149147
if (_shouldSendResize) {
150148
// Fix for Samsung devices (S7-S9, manually send AR_WINDOW_RESIZED)
151149
WebViewApp webViewApp = WebViewApp.getCurrentApp();
@@ -176,22 +174,12 @@ public void onDrawFrame(GL10 gl) {
176174
return;
177175
}
178176

179-
if (!_showCameraFrame) {
180-
return;
181-
}
182-
_backgroundRenderer.draw(frame);
183-
184177
long currentTime = System.currentTimeMillis();
185178
if (_timeOfLastDrawnCameraFrame == 0) {
186179
_timeOfLastDrawnCameraFrame = currentTime;
187180
}
188-
long timeSinceLastDrawnCameraFrame = currentTime - _timeOfLastDrawnCameraFrame;
189-
if (timeSinceLastDrawnCameraFrame < FRAME_UPDATE_TIMEOUT && !_drawNextCameraFrame) {
190-
return;
191-
}
192181

193182
_timeOfLastDrawnCameraFrame = currentTime;
194-
_drawNextCameraFrame = false;
195183

196184
camera.getProjectionMatrix(_projectionMatrixArray, 0, _arNear, _arFar);
197185
camera.getViewMatrix(_viewMatrixArray, 0);
@@ -234,6 +222,13 @@ public void onDrawFrame(GL10 gl) {
234222
updatePlanes(updatedTrackables);
235223

236224
DeviceLog.debug(frame.toString());
225+
226+
if (!_showCameraFrame) {
227+
return;
228+
}
229+
230+
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
231+
_backgroundRenderer.draw(frame);
237232
}
238233
}
239234

@@ -325,6 +320,13 @@ public void restartSession(JSONObject properties) throws JSONException {
325320
_sessionRunning = true;
326321

327322
_displayRotationHelper.onResume();
323+
324+
postDelayed(new Runnable() {
325+
@Override
326+
public void run() {
327+
requestRender();
328+
}
329+
}, 200);
328330
}
329331

330332
public void pauseSession() {
@@ -334,7 +336,7 @@ public void pauseSession() {
334336
}
335337

336338
public void setDrawNextCameraFrame() {
337-
_drawNextCameraFrame = true;
339+
requestRender();
338340
}
339341

340342
public boolean getShowCameraFrame() {

0 commit comments

Comments
 (0)