Release 2.0.3
This commit is contained in:
Родитель
45f136f0f6
Коммит
3c7c57dbe2
|
@ -1,15 +1,15 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "23.0.3"
|
||||
compileSdkVersion 24
|
||||
buildToolsVersion "24.0.1"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.unity3d.ads.example"
|
||||
minSdkVersion 9
|
||||
targetSdkVersion 23
|
||||
versionCode = 2002
|
||||
versionName = "2.0.2"
|
||||
targetSdkVersion 24
|
||||
versionCode = 2003
|
||||
versionName = "2.0.3"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
@ -21,7 +21,7 @@ android {
|
|||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile 'com.android.support:appcompat-v7:23.0.0'
|
||||
compile 'com.android.support:appcompat-v7:24.2.0'
|
||||
debugCompile project(path: ':lib', configuration: "debug")
|
||||
releaseCompile project(path: ':lib', configuration: "release")
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ public class UnityAdsExample extends Activity {
|
|||
private String interstitialPlacementId;
|
||||
private String incentivizedPlacementId;
|
||||
|
||||
private static int ordinal = 1;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -42,7 +44,6 @@ public class UnityAdsExample extends Activity {
|
|||
MediationMetaData mediationMetaData = new MediationMetaData(this);
|
||||
mediationMetaData.setName("mediationPartner");
|
||||
mediationMetaData.setVersion("v12345");
|
||||
mediationMetaData.setOrdinal(1);
|
||||
mediationMetaData.commit();
|
||||
|
||||
MetaData debugMetaData = new MetaData(this);
|
||||
|
@ -60,6 +61,10 @@ public class UnityAdsExample extends Activity {
|
|||
playerMetaData.setServerId("rikshot");
|
||||
playerMetaData.commit();
|
||||
|
||||
MediationMetaData ordinalMetaData = new MediationMetaData(self);
|
||||
ordinalMetaData.setOrdinal(ordinal++);
|
||||
ordinalMetaData.commit();
|
||||
|
||||
UnityAds.show(self, interstitialPlacementId);
|
||||
}
|
||||
});
|
||||
|
@ -75,6 +80,10 @@ public class UnityAdsExample extends Activity {
|
|||
playerMetaData.setServerId("rikshot");
|
||||
playerMetaData.commit();
|
||||
|
||||
MediationMetaData ordinalMetaData = new MediationMetaData(self);
|
||||
ordinalMetaData.setOrdinal(ordinal++);
|
||||
ordinalMetaData.commit();
|
||||
|
||||
UnityAds.show(self, incentivizedPlacementId);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -4,7 +4,7 @@ buildscript {
|
|||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.1.2'
|
||||
classpath 'com.android.tools.build:gradle:2.1.3'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#Thu Apr 07 11:46:35 EEST 2016
|
||||
#Mon Aug 22 16:49:01 EEST 2016
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "23.0.3"
|
||||
compileSdkVersion 24
|
||||
buildToolsVersion "24.0.1"
|
||||
com.android.ddmlib.DdmPreferences.setLogLevel("verbose")
|
||||
com.android.ddmlib.DdmPreferences.setTimeOut(10 * 60000)
|
||||
|
||||
|
@ -11,9 +11,9 @@ android {
|
|||
|
||||
defaultConfig {
|
||||
minSdkVersion 9
|
||||
targetSdkVersion 23
|
||||
versionCode = 2002
|
||||
versionName = "2.0.2"
|
||||
targetSdkVersion 24
|
||||
versionCode = 2003
|
||||
versionName = "2.0.3"
|
||||
|
||||
setProperty("archivesBaseName", "unity-ads")
|
||||
|
||||
|
|
|
@ -40,11 +40,18 @@ public class AdUnitActivity extends Activity {
|
|||
private ArrayList<Integer> _keyEventList;
|
||||
boolean _keepScreenOn;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// This error condition will trigger if activity is backgrounded while activity is in foreground,
|
||||
// app process is killed while app is in background and then app is yet again launched to foreground
|
||||
if(WebViewApp.getCurrentApp() == null) {
|
||||
DeviceLog.error("Unity Ads web app is null, closing Unity Ads activity from onCreate");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
AdUnit.setAdUnitActivity(this);
|
||||
|
||||
createLayout();
|
||||
|
@ -92,18 +99,45 @@ public class AdUnitActivity extends Activity {
|
|||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
||||
if(WebViewApp.getCurrentApp() == null) {
|
||||
if(!isFinishing()) {
|
||||
DeviceLog.error("Unity Ads web app is null, closing Unity Ads activity from onStart");
|
||||
finish();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.ADUNIT, AdUnitEvent.ON_START, _activityId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
|
||||
if(WebViewApp.getCurrentApp() == null) {
|
||||
if(!isFinishing()) {
|
||||
DeviceLog.error("Unity Ads web app is null, closing Unity Ads activity from onStop");
|
||||
finish();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.ADUNIT, AdUnitEvent.ON_STOP, _activityId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if(WebViewApp.getCurrentApp() == null) {
|
||||
if(!isFinishing()) {
|
||||
DeviceLog.error("Unity Ads web app is null, closing Unity Ads activity from onResume");
|
||||
finish();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
setViews(_views);
|
||||
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.ADUNIT, AdUnitEvent.ON_RESUME, _activityId);
|
||||
|
@ -113,6 +147,14 @@ public class AdUnitActivity extends Activity {
|
|||
protected void onPause() {
|
||||
super.onPause();
|
||||
|
||||
if(WebViewApp.getCurrentApp() == null) {
|
||||
if(!isFinishing()) {
|
||||
DeviceLog.error("Unity Ads web app is null, closing Unity Ads activity from onPause");
|
||||
finish();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (isFinishing()) {
|
||||
ViewUtilities.removeViewFromParent(WebViewApp.getCurrentApp().getWebView());
|
||||
}
|
||||
|
@ -136,6 +178,15 @@ public class AdUnitActivity extends Activity {
|
|||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
if(WebViewApp.getCurrentApp() == null) {
|
||||
if(!isFinishing()) {
|
||||
DeviceLog.error("Unity Ads web app is null, closing Unity Ads activity from onDestroy");
|
||||
finish();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
AdUnit.setAdUnitActivity(null);
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.ADUNIT, AdUnitEvent.ON_DESTROY, isFinishing(), _activityId);
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.lang.reflect.Method;
|
|||
public class AdUnitOpen {
|
||||
private static ConditionVariable _waitShowStatus;
|
||||
|
||||
public static boolean open(String placementId, JSONObject options) throws NoSuchMethodException {
|
||||
public static synchronized boolean open(String placementId, JSONObject options) throws NoSuchMethodException {
|
||||
Method showCallback = AdUnitOpen.class.getMethod("showCallback", CallbackStatus.class);
|
||||
_waitShowStatus = new ConditionVariable();
|
||||
WebViewApp.getCurrentApp().invokeMethod("webview", "show", showCallback, placementId, options);
|
||||
|
|
|
@ -6,5 +6,6 @@ public enum CacheError {
|
|||
FILE_ALREADY_CACHING,
|
||||
NOT_CACHING,
|
||||
JSON_ERROR,
|
||||
NO_INTERNET
|
||||
NO_INTERNET,
|
||||
MALFORMED_URL
|
||||
}
|
||||
|
|
|
@ -113,15 +113,23 @@ class CacheThreadHandler extends Handler {
|
|||
// Note: active must be set to false before sending end/error event back to webview to allow webview to start next download or other operation immediately after receiving the event
|
||||
_active = false;
|
||||
postProcessDownload(startTime, source, targetFile, total, _currentRequest.getContentLength(), _currentRequest.isCanceled(), _currentRequest.getResponseCode(), _currentRequest.getResponseHeaders());
|
||||
} catch (FileNotFoundException e) {
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
DeviceLog.exception("Couldn't create target file", e);
|
||||
_active = false;
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.CACHE, CacheEvent.DOWNLOAD_ERROR, CacheError.FILE_IO_ERROR, source, e.getMessage());
|
||||
} catch (IOException e) {
|
||||
}
|
||||
catch (MalformedURLException e) {
|
||||
DeviceLog.exception("Malformed URL", e);
|
||||
_active = false;
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.CACHE, CacheEvent.DOWNLOAD_ERROR, CacheError.MALFORMED_URL, source, e.getMessage());
|
||||
}
|
||||
catch (IOException e) {
|
||||
DeviceLog.exception("Couldn't request stream", e);
|
||||
_active = false;
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.CACHE, CacheEvent.DOWNLOAD_ERROR, CacheError.FILE_IO_ERROR, source, e.getMessage());
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
_currentRequest = null;
|
||||
try {
|
||||
if (fileOutput != null) {
|
||||
|
@ -152,22 +160,13 @@ class CacheThreadHandler extends Handler {
|
|||
}
|
||||
}
|
||||
|
||||
private WebRequest getWebRequest(String source, long position, int connectTimeout, int readTimeout) {
|
||||
private WebRequest getWebRequest(String source, long position, int connectTimeout, int readTimeout) throws MalformedURLException {
|
||||
HashMap<String, List<String>> headers = new HashMap<>();
|
||||
if (position > 0) {
|
||||
ArrayList list = new ArrayList(Arrays.asList(new String[]{"bytes=" + position + "-"}));
|
||||
headers.put("Range", list);
|
||||
}
|
||||
|
||||
WebRequest request = null;
|
||||
|
||||
try {
|
||||
request = new WebRequest(source, "GET", headers, connectTimeout, readTimeout);
|
||||
}
|
||||
catch (MalformedURLException e) {
|
||||
DeviceLog.exception("Malformed URL", e);
|
||||
}
|
||||
|
||||
return request;
|
||||
return new WebRequest(source, "GET", headers, connectTimeout, readTimeout);
|
||||
}
|
||||
}
|
|
@ -28,7 +28,6 @@ public class WebView extends android.webkit.WebView {
|
|||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
WebView.setWebContentsDebuggingEnabled(true);
|
||||
try {
|
||||
_evaluateJavascript = android.webkit.WebView.class.getMethod("evaluateJavascript", String.class, ValueCallback.class);
|
||||
} catch(NoSuchMethodException e) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче