index int64 | repo_id string | file_path string | content string |
|---|---|---|---|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/ExoPlayerView.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video;
import android.content.Context;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.widget.RelativeLayout;
import androidx.annotation.NonNull;
import androidx.annotation.OptIn;
import androidx.annotation.VisibleForTesting;
import androidx.media3.common.MediaItem;
import androidx.media3.common.PlaybackException;
import androidx.media3.common.Player;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util;
import androidx.media3.datasource.DefaultDataSourceFactory;
import androidx.media3.exoplayer.ExoPlayer;
import androidx.media3.exoplayer.source.ProgressiveMediaSource;
import androidx.media3.ui.PlayerView;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.api.rendering.VideoView;
import org.prebid.mobile.api.rendering.VisibilityTracker;
import org.prebid.mobile.configuration.AdUnitConfiguration;
import org.prebid.mobile.rendering.listeners.VideoCreativeViewListener;
import org.prebid.mobile.rendering.models.AdPosition;
import org.prebid.mobile.rendering.models.CreativeModel;
import org.prebid.mobile.rendering.video.vast.VASTErrorCodes;
import kotlin.Unit;
import kotlin.jvm.functions.Function2;
public class ExoPlayerView extends PlayerView implements VideoPlayerView {
private static final String TAG = "ExoPlayerView";
public static final float DEFAULT_INITIAL_VIDEO_VOLUME = 1.0f;
@NonNull private final VideoCreativeViewListener videoCreativeViewListener;
private AdViewProgressUpdateTask adViewProgressUpdateTask;
private ExoPlayer player;
private Uri videoUri;
private long vastVideoDuration = -1;
private Boolean playable = null;
private VisibilityTracker visibilityTracker = new VisibilityTracker(this, new Handler(Looper.getMainLooper()), new Function2<Long, Long, Unit>() {
@Override
public Unit invoke(Long visibilePixels, Long totalPixels) {
boolean playable = false;
if (totalPixels > 0 && visibilePixels * 100 / totalPixels > 95) {
playable = true;
}
updatePlayableState(playable);
return null;
}
});
private boolean isInterstitial() {
if (videoCreativeViewListener instanceof VideoCreative) {
return ((VideoCreative) videoCreativeViewListener).isInterstitial();
}
return false;
}
private void updatePlayableState(boolean playable) {
LogUtil.debug(TAG, "updatePlayableState. playable: " + playable);
if (this.playable == null || this.playable != playable) {
LogUtil.debug(TAG, "updatePlayableState. statue changed from: " + this.playable + " to: " + playable);
this.playable = playable;
if (this.playable) {
new Handler(Looper.getMainLooper()).postDelayed(() -> {
if (!isPlaying()) {
resume();
}
}, 200);
} else {
new Handler(Looper.getMainLooper()).postDelayed(() -> {
if (isPlaying()) {
pause();
}
}, 200);
}
}
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (isInterstitial()) {
visibilityTracker.startTracking();
}
}
@Override protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
if (isInterstitial()) {
visibilityTracker.stopTracking();
}
}
public ExoPlayerView(
Context context,
@NonNull VideoCreativeViewListener videoCreativeViewListener
) {
super(context);
this.videoCreativeViewListener = videoCreativeViewListener;
}
private final Player.Listener eventListener = new Player.Listener() {
@Override
public void onPlayerError(PlaybackException error) {
videoCreativeViewListener.onFailure(new AdException(
AdException.INTERNAL_ERROR,
VASTErrorCodes.MEDIA_DISPLAY_ERROR.toString()
));
}
@Override
public void onPlaybackStateChanged(int playbackState) {
if (player == null) {
LogUtil.debug(TAG, "onPlayerStateChanged(): Skipping state handling. Player is null");
return;
}
switch (playbackState) {
case Player.STATE_READY:
player.setPlayWhenReady(true);
if (!isInterstitial()) {
// Do not auto-release the player when immersive ads video duration reached.
initUpdateTask();
}
break;
case Player.STATE_ENDED:
videoCreativeViewListener.onDisplayCompleted();
break;
}
}
};
@Override
public void mute() {
setVolume(0);
}
@Override
public boolean isPlaying() {
return player != null && player.getPlayWhenReady();
}
@Override
public void unMute() {
setVolume(DEFAULT_INITIAL_VIDEO_VOLUME);
}
@Override
public void start(float initialVolume) {
LogUtil.debug(TAG, "start() called");
initLayout();
initPlayer(initialVolume);
preparePlayer(true);
trackInitialStartEvent();
}
@Override
public void setVastVideoDuration(long duration) {
vastVideoDuration = duration;
}
@Override
public long getCurrentPosition() {
if (player == null) {
return -1;
}
return player.getContentPosition();
}
@Override
public void setVideoUri(Uri uri) {
videoUri = uri;
}
@Override
public int getDuration() {
return (int) player.getDuration();
}
@Override
public float getVolume() {
return player.getVolume();
}
@Override
public void resume() {
LogUtil.debug(TAG, "resume() called");
if (!isInterstitial()) {
preparePlayer(false);
} else {
if (playable != null && !playable) {
LogUtil.debug(TAG, "playable is false. skip resume()");
return;
}
if (player != null) {
player.play();
}
}
videoCreativeViewListener.onEvent(VideoAdEvent.Event.AD_RESUME);
}
@Override
public void pause() {
LogUtil.debug(TAG, "pause() called");
if (player != null) {
if (!isInterstitial()) {
player.stop();
} else {
player.pause();
}
videoCreativeViewListener.onEvent(VideoAdEvent.Event.AD_PAUSE);
}
}
@Override
public void forceStop() {
destroy();
videoCreativeViewListener.onDisplayCompleted();
}
@Override
public void destroy() {
LogUtil.debug(TAG, "destroy() called");
killUpdateTask();
if (player != null) {
player.stop();
player.removeListener(eventListener);
setPlayer(null);
player.release();
player = null;
}
}
@VisibleForTesting
void setVolume(float volume) {
if (player != null && volume >= 0.0f) {
videoCreativeViewListener.onVolumeChanged(volume);
player.setVolume(volume);
}
}
@Override
public void stop() {
if (player != null) {
player.stop();
player.clearMediaItems();
}
}
private void initLayout() {
RelativeLayout.LayoutParams playerLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT);
playerLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
setLayoutParams(playerLayoutParams);
}
private void initPlayer(float initialVolume) {
if (player != null) {
LogUtil.debug(TAG, "Skipping initPlayer(): Player is already initialized.");
return;
}
player = new ExoPlayer.Builder(getContext()).build();
if (isInterstitial()) {
player.setRepeatMode(Player.REPEAT_MODE_ALL);
}
player.addListener(eventListener);
setPlayer(this.player);
setUseController(false);
player.setVolume(initialVolume);
}
private void initUpdateTask() {
if (adViewProgressUpdateTask != null) {
LogUtil.debug(TAG, "initUpdateTask: AdViewProgressUpdateTask is already initialized. Skipping.");
return;
}
try {
adViewProgressUpdateTask = new AdViewProgressUpdateTask(
videoCreativeViewListener,
(int) player.getDuration()
);
adViewProgressUpdateTask.setVastVideoDuration(vastVideoDuration);
adViewProgressUpdateTask.execute();
}
catch (AdException e) {
e.printStackTrace();
}
}
@OptIn(markerClass = UnstableApi.class) @VisibleForTesting
void preparePlayer(boolean resetPosition) {
ProgressiveMediaSource extractorMediaSource = buildMediaSource(videoUri);
if (extractorMediaSource == null || player == null) {
LogUtil.debug(TAG, "preparePlayer(): ExtractorMediaSource or ExoPlayer is null. Skipping prepare.");
return;
}
player.setMediaSource(extractorMediaSource, resetPosition);
player.prepare();
}
@OptIn(markerClass = UnstableApi.class) private ProgressiveMediaSource buildMediaSource(Uri uri) {
if (uri == null) {
return null;
}
MediaItem mediaItem = new MediaItem.Builder().setUri(uri).build();
return new ProgressiveMediaSource.Factory(
new DefaultDataSourceFactory(getContext(), Util.getUserAgent(getContext(), "PrebidRenderingSDK")))
.createMediaSource(mediaItem);
}
private void killUpdateTask() {
LogUtil.debug(TAG, "killUpdateTask() called");
if (adViewProgressUpdateTask != null) {
adViewProgressUpdateTask.cancel(true);
adViewProgressUpdateTask = null;
}
}
private void trackInitialStartEvent() {
if (videoUri != null && player != null && player.getCurrentPosition() == 0) {
videoCreativeViewListener.onEvent(VideoAdEvent.Event.AD_CREATIVEVIEW);
videoCreativeViewListener.onEvent(VideoAdEvent.Event.AD_START);
}
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/LruController.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video;
import android.content.Context;
import android.util.LruCache;
import androidx.annotation.NonNull;
import org.prebid.mobile.LogUtil;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
public class LruController {
private final static String TAG = LruController.class.getSimpleName();
private final static char EXTENSION_SEPARATOR = '.';
private final static String CACHE_POSTFIX = "_cache";
private static final int MAX_VIDEO_ENTRIES = 30;
private final static LruCache<String, byte[]> lruCache = new LruCache<>(MAX_VIDEO_ENTRIES);
public static void putVideoCache(String videoPath, byte[] data) {
if (getVideoCache(videoPath) == null) {
lruCache.put(videoPath, data);
}
}
public static byte[] getVideoCache(String videoPath) {
return lruCache.get(videoPath);
}
public static boolean isAlreadyCached(String videoPath) {
return lruCache.get(videoPath) != null;
}
public static boolean saveCacheToFile(
@NonNull
Context context,
@NonNull
String videoPath) {
File file = new File(context.getFilesDir(), videoPath);
if (!file.exists() && getVideoCache(videoPath) != null) {
try {
byte[] data = getVideoCache(videoPath);
OutputStream os = new FileOutputStream(file);
os.write(data);
os.close();
lruCache.remove(videoPath);
LogUtil.debug(TAG, "Cache saved to file");
return true;
}
catch (Exception e) {
LogUtil.error(TAG, "Failed to save cache to file: " + e.getMessage());
}
}
return false;
}
public static String getShortenedPath(String url) {
String shortenedPath = url.substring(url.lastIndexOf("/"));
StringBuilder builder = new StringBuilder();
int extensionIndex = shortenedPath.lastIndexOf(EXTENSION_SEPARATOR);
if (extensionIndex != -1) {
builder.append(shortenedPath.substring(0, extensionIndex));
}
else {
builder.append(shortenedPath);
}
return builder.toString();
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/OmEventTracker.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.rendering.models.TrackingEvent;
import org.prebid.mobile.rendering.models.internal.InternalPlayerState;
import org.prebid.mobile.rendering.session.manager.OmAdSessionManager;
import java.lang.ref.WeakReference;
public class OmEventTracker {
private static final String TAG = OmEventTracker.class.getSimpleName();
private WeakReference<OmAdSessionManager> weakReferenceOmAdSessionManager;
public void registerActiveAdSession(OmAdSessionManager omAdSessionManager) {
weakReferenceOmAdSessionManager = new WeakReference<>(omAdSessionManager);
}
public void trackOmVideoAdEvent(VideoAdEvent.Event event) {
if (weakReferenceOmAdSessionManager == null || weakReferenceOmAdSessionManager.get() == null) {
LogUtil.warning(TAG, "Unable to trackOmVideoAdEvent: AdSessionManager is null");
return;
}
OmAdSessionManager omAdSessionManager = weakReferenceOmAdSessionManager.get();
omAdSessionManager.trackAdVideoEvent(event);
}
public void trackOmHtmlAdEvent(TrackingEvent.Events event) {
if (weakReferenceOmAdSessionManager == null || weakReferenceOmAdSessionManager.get() == null) {
LogUtil.warning(TAG, "Unable to trackOmHtmlAdEvent: AdSessionManager is null");
return;
}
OmAdSessionManager omAdSessionManager = weakReferenceOmAdSessionManager.get();
omAdSessionManager.trackDisplayAdEvent(event);
}
public void trackOmPlayerStateChange(InternalPlayerState playerState) {
if (weakReferenceOmAdSessionManager == null || weakReferenceOmAdSessionManager.get() == null) {
LogUtil.warning(TAG, "Unable to trackOmPlayerStateChange: AdSessionManager is null");
return;
}
OmAdSessionManager omAdSessionManager = weakReferenceOmAdSessionManager.get();
omAdSessionManager.trackPlayerStateChangeEvent(playerState);
}
public void trackVideoAdStarted(float duration, float volume) {
if (weakReferenceOmAdSessionManager == null || weakReferenceOmAdSessionManager.get() == null) {
LogUtil.warning(TAG, "Unable to trackVideoAdStarted: AdSessionManager is null");
return;
}
OmAdSessionManager omAdSessionManager = weakReferenceOmAdSessionManager.get();
omAdSessionManager.videoAdStarted(duration, volume);
}
public void trackNonSkippableStandaloneVideoLoaded(boolean isAutoPlay) {
if (weakReferenceOmAdSessionManager == null || weakReferenceOmAdSessionManager.get() == null) {
LogUtil.warning(TAG, "Unable to trackVideoAdStarted: AdSessionManager is null");
return;
}
OmAdSessionManager omAdSessionManager = weakReferenceOmAdSessionManager.get();
omAdSessionManager.nonSkippableStandaloneVideoAdLoaded(isAutoPlay);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/RewardedVideoCreative.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video;
import android.content.Context;
import org.prebid.mobile.rendering.session.manager.OmAdSessionManager;
import org.prebid.mobile.rendering.views.interstitial.InterstitialManager;
public class RewardedVideoCreative extends VideoCreative {
private static final String TAG = RewardedVideoCreative.class.getSimpleName();
public RewardedVideoCreative(Context context, VideoCreativeModel model,
OmAdSessionManager omAdSessionManager,
InterstitialManager interstitialManager) throws Exception {
super(context, model, omAdSessionManager, interstitialManager);
}
@Override
public void complete() {
super.complete();
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/VideoAdEvent.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video;
import org.prebid.mobile.rendering.models.TrackingEvent;
public class VideoAdEvent extends TrackingEvent{
public enum Event {
/*
* WARNING, IMPORTANT: The first group of events corresponds one
* to one with an index in the AdResponseParserVast class for VAST
* event tracking. Any miscellaneous ones can be appended on the
* list below.
*/
AD_CREATIVEVIEW,
AD_START,
AD_FIRSTQUARTILE,
AD_MIDPOINT,
AD_THIRDQUARTILE,
AD_COMPLETE,
AD_MUTE,
AD_UNMUTE,
AD_PAUSE,
AD_REWIND,
AD_RESUME,
AD_FULLSCREEN,
AD_EXITFULLSCREEN,
AD_EXPAND,
AD_COLLAPSE,
AD_ACCEPTINVITATION,
AD_ACCEPTINVITATIONLINEAR,
AD_CLOSELINEAR,
AD_CLOSE,
AD_SKIP,
AD_ERROR,
AD_IMPRESSION,
AD_CLICK
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/VideoCreative.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video;
import android.content.Context;
import android.net.Uri;
import android.os.AsyncTask;
import android.text.TextUtils;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import org.prebid.mobile.ContentObject;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.configuration.AdUnitConfiguration;
import org.prebid.mobile.rendering.interstitial.InterstitialManagerVideoDelegate;
import org.prebid.mobile.rendering.listeners.CreativeViewListener;
import org.prebid.mobile.rendering.listeners.VideoCreativeViewListener;
import org.prebid.mobile.rendering.loading.FileDownloadListener;
import org.prebid.mobile.rendering.models.AdPosition;
import org.prebid.mobile.rendering.models.CreativeVisibilityTracker;
import org.prebid.mobile.rendering.models.internal.InternalPlayerState;
import org.prebid.mobile.rendering.models.internal.VisibilityTrackerOption;
import org.prebid.mobile.rendering.models.ntv.NativeEventTracker;
import org.prebid.mobile.rendering.networking.BaseNetworkTask;
import org.prebid.mobile.rendering.session.manager.OmAdSessionManager;
import org.prebid.mobile.rendering.utils.helpers.AppInfoManager;
import org.prebid.mobile.rendering.utils.helpers.Utils;
import org.prebid.mobile.rendering.views.interstitial.InterstitialManager;
import java.io.File;
import java.lang.ref.WeakReference;
public class VideoCreative extends VideoCreativeProtocol
implements VideoCreativeViewListener, InterstitialManagerVideoDelegate {
private static final String TAG = VideoCreative.class.getSimpleName();
@NonNull private final VideoCreativeModel model;
@VisibleForTesting VideoCreativeView videoCreativeView;
private AsyncTask videoDownloadTask;
private String preloadedVideoFilePath;
public VideoCreative(Context context,
@NonNull
VideoCreativeModel model, OmAdSessionManager omAdSessionManager, InterstitialManager interstitialManager)
throws AdException {
super(context, model, omAdSessionManager, interstitialManager);
this.model = model;
if (this.interstitialManager != null) {
this.interstitialManager.setInterstitialVideoDelegate(this);
}
}
@Override
public void load() {
//Use URLConnection to download a video file.
BaseNetworkTask.GetUrlParams params = new BaseNetworkTask.GetUrlParams();
params.url = model.getMediaUrl();
params.userAgent = AppInfoManager.getUserAgent();
params.requestType = "GET";
params.name = BaseNetworkTask.DOWNLOAD_TASK;
Context context = contextReference.get();
if (context != null) {
AdUnitConfiguration adConfiguration = model.getAdConfiguration();
String shortenedPath = LruController.getShortenedPath(params.url);
File file = new File(context.getFilesDir(), shortenedPath);
VideoDownloadTask videoDownloadTask = new VideoDownloadTask(context, file,
new VideoCreativeVideoPreloadListener(this), adConfiguration);
this.videoDownloadTask = videoDownloadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
}
}
@Override
public void display() {
if (videoCreativeView != null) {
videoCreativeView.start(model.getAdConfiguration().getVideoInitialVolume());
setStartIsMutedValue(model.getAdConfiguration().isMuted());
model.trackPlayerStateChange(InternalPlayerState.NORMAL);
startViewabilityTracker();
}
}
@Override
public void skip() {
LogUtil.debug(TAG, "Track 'skip' event");
model.trackVideoEvent(VideoAdEvent.Event.AD_SKIP);
// Send it to AdView
getCreativeViewListener().creativeDidComplete(this);
}
@Override
public void onReadyForDisplay() {
getResolutionListener().creativeReady(this);
}
@Override
public void onDisplayCompleted() {
complete();
}
@Override
public void onFailure(AdException error) {
// ad -> inline -> error
model.trackVideoEvent(VideoAdEvent.Event.AD_ERROR);
getResolutionListener().creativeFailed(error);
}
@Override
public void onEvent(VideoAdEvent.Event trackingEvent) {
model.trackVideoEvent(trackingEvent);
notifyCreativeViewListener(trackingEvent);
}
@Override
public void trackAdLoaded() {
model.trackNonSkippableStandaloneVideoLoaded(false);
}
@Override
public void onVolumeChanged(float volume) {
notifyVolumeChanged(volume);
OmAdSessionManager omAdSessionManager = weakOmAdSessionManager.get();
if (omAdSessionManager == null) {
LogUtil.error(TAG, "trackVolume failed, OmAdSessionManager is null");
return;
}
omAdSessionManager.trackVolumeChange(volume);
}
@Override
public void onPlayerStateChanged(InternalPlayerState state) {
model.trackPlayerStateChange(state);
}
@Override
public boolean isInterstitialClosed() {
return model.hasEndCard();
}
@Override
public long getMediaDuration() {
return model.getMediaDuration();
}
@Override
public void handleAdWindowFocus() {
// Resume video view
resume();
}
@Override
public void resume() {
if (videoCreativeView != null && videoCreativeView.hasVideoStarted()) {
videoCreativeView.resume();
}
}
@Override
public boolean isPlaying() {
return videoCreativeView != null && videoCreativeView.isPlaying();
}
@Override
public void handleAdWindowNoFocus() {
// Pause video view
pause();
}
@Override
public void pause() {
if (videoCreativeView != null && videoCreativeView.isPlaying()) {
videoCreativeView.pause();
}
}
@Override
public void mute() {
if (videoCreativeView != null && videoCreativeView.getVolume() != 0) {
videoCreativeView.mute();
}
}
@Override
public void unmute() {
if (videoCreativeView != null && videoCreativeView.getVolume() == 0) {
videoCreativeView.unMute();
}
}
private void setStartIsMutedValue(boolean isMuted) {
if (videoCreativeView != null && videoCreativeView.getVolume() == 0) {
videoCreativeView.setStartIsMutedProperty(isMuted);
}
}
@Override
public void createOmAdSession() {
OmAdSessionManager omAdSessionManager = weakOmAdSessionManager.get();
if (omAdSessionManager == null) {
LogUtil.error(TAG, "Error creating AdSession. OmAdSessionManager is null");
return;
}
AdUnitConfiguration adConfiguration = model.getAdConfiguration();
ContentObject contentObject = adConfiguration.getAppContent();
String contentUrl = null;
if (contentObject != null) contentUrl = contentObject.getUrl();
omAdSessionManager.initVideoAdSession(model.getAdVerifications(), contentUrl);
startOmSession();
}
@Override
public void startViewabilityTracker() {
VisibilityTrackerOption visibilityTrackerOption = new VisibilityTrackerOption(NativeEventTracker.EventType.IMPRESSION);
creativeVisibilityTracker = new CreativeVisibilityTracker(getCreativeView(), visibilityTrackerOption);
creativeVisibilityTracker.setVisibilityTrackerListener((result) -> {
if (result.isVisible() && result.shouldFireImpression()) {
model.trackVideoEvent(VideoAdEvent.Event.AD_IMPRESSION);
creativeVisibilityTracker.stopVisibilityCheck();
creativeVisibilityTracker = null;
}
});
creativeVisibilityTracker.startVisibilityCheck(contextReference.get());
}
@Override
public void destroy() {
super.destroy();
if (videoCreativeView != null) {
videoCreativeView.destroy();
}
if (videoDownloadTask != null) {
videoDownloadTask.cancel(true);
}
}
@Override
public boolean isDisplay() {
return false;
}
@Override
public boolean isVideo() {
return true;
}
/**
* @return true if {@link #preloadedVideoFilePath} is not empty and file exists in filesDir, false otherwise.
*/
@Override
public boolean isResolved() {
if (contextReference.get() != null && !TextUtils.isEmpty(preloadedVideoFilePath)) {
File file = new File(contextReference.get().getFilesDir(), preloadedVideoFilePath);
return file.exists();
}
return false;
}
@Override
public boolean isEndCard() {
return false;
}
@Override
public void onVideoInterstitialClosed() {
if (videoCreativeView != null) {
videoCreativeView.destroy();
}
if (getCreativeViewListener() != null) {
getCreativeViewListener().creativeDidComplete(this);
}
}
public long getVideoSkipOffset() {
return model.getSkipOffset();
}
@Override
public void trackVideoEvent(VideoAdEvent.Event event) {
model.trackVideoEvent(event);
}
@Override
@NonNull
public VideoCreativeModel getCreativeModel() {
return model;
}
private void loadContinued() {
try {
createCreativeView();
}
catch (AdException e) {
getResolutionListener().creativeFailed(e);
return;
}
setCreativeView(videoCreativeView);
//VideoView has been created. Send adDidLoad() to pubs
onReadyForDisplay();
}
// Helper method to reduce duplicate code in the subclass RewardedVideoCreative
private void createCreativeView() throws AdException {
Uri videoUri = null;
final Context context = contextReference.get();
if (context != null) {
final AdUnitConfiguration adConfiguration = model.getAdConfiguration();
videoCreativeView = new VideoCreativeView(context, this);
videoCreativeView.setBroadcastId(adConfiguration.getBroadcastId());
// Get the preloaded video from device file storage
videoUri = Uri.fromFile(new File(context.getFilesDir() + (model.getMediaUrl())));
}
// Show call-to-action overlay right away if click through url is available & end card is not available
if (!isInterstitial()) {
/// Click through url will shown outside of the creative view for interstitial ads)
showCallToAction();
}
videoCreativeView.setCallToActionUrl(model.getVastClickthroughUrl());
videoCreativeView.setVastVideoDuration(getMediaDuration());
videoCreativeView.setVideoUri(videoUri);
}
private void startOmSession() {
OmAdSessionManager omAdSessionManager = weakOmAdSessionManager.get();
if (omAdSessionManager == null) {
LogUtil.error(TAG, "startOmSession: Failed. omAdSessionManager is null");
return;
}
if (videoCreativeView == null) {
LogUtil.error(TAG, "startOmSession: Failed. VideoCreativeView is null");
return;
}
startOmSession(omAdSessionManager, (View) videoCreativeView.getVideoPlayerView());
model.registerActiveOmAdSession(omAdSessionManager);
}
private void trackVideoAdStart() {
if (videoCreativeView == null || videoCreativeView.getVideoPlayerView() == null) {
LogUtil.error(TAG, "trackVideoAdStart error. videoCreativeView or VideoPlayerView is null.");
return;
}
VideoPlayerView plugPlayVideoView = videoCreativeView.getVideoPlayerView();
int duration = plugPlayVideoView.getDuration();
float volume = plugPlayVideoView.getVolume();
model.trackVideoAdStarted(duration, volume);
}
protected void complete() {
LogUtil.debug(TAG, "track 'complete' event");
model.trackVideoEvent(VideoAdEvent.Event.AD_COMPLETE);
if (videoCreativeView != null) {
videoCreativeView.hideVolumeControls();
}
// Send it to AdView
getCreativeViewListener().creativeDidComplete(this);
}
protected void showCallToAction() {
if (!model.getAdConfiguration().isBuiltInVideo()
&& Utils.isNotBlank(model.getVastClickthroughUrl())
&& !model.getAdConfiguration().isRewarded()
) {
videoCreativeView.showCallToAction();
}
}
private void notifyCreativeViewListener(VideoAdEvent.Event trackingEvent) {
final CreativeViewListener creativeViewListener = getCreativeViewListener();
switch (trackingEvent) {
case AD_START:
trackVideoAdStart();
break;
case AD_CLICK:
creativeViewListener.creativeWasClicked(this, videoCreativeView.getCallToActionUrl());
break;
case AD_RESUME:
creativeViewListener.creativeResumed(this);
break;
case AD_PAUSE:
creativeViewListener.creativePaused(this);
break;
}
}
private void notifyVolumeChanged(float volume) {
final CreativeViewListener creativeViewListener = getCreativeViewListener();
if (volume == 0) {
creativeViewListener.creativeMuted(this);
}
else {
creativeViewListener.creativeUnMuted(this);
}
}
@Override
public boolean isInterstitial() {
AdUnitConfiguration adUnitConfiguration = model.getAdConfiguration();
if (adUnitConfiguration != null) {
return adUnitConfiguration.getAdPositionValue() == AdPosition.FULLSCREEN.getValue();
}
return false;
}
private static class VideoCreativeVideoPreloadListener implements FileDownloadListener {
private WeakReference<VideoCreative> weakVideoCreative;
VideoCreativeVideoPreloadListener(VideoCreative videoCreative) {
weakVideoCreative = new WeakReference<>(videoCreative);
}
@Override
public void onFileDownloaded(String shortenedPath) {
VideoCreative videoCreative = weakVideoCreative.get();
if (videoCreative == null) {
LogUtil.warning(TAG, "VideoCreative is null");
return;
}
videoCreative.preloadedVideoFilePath = shortenedPath;
videoCreative.model.setMediaUrl(shortenedPath);
videoCreative.loadContinued();
}
@Override
public void onFileDownloadError(String error) {
VideoCreative videoCreative = weakVideoCreative.get();
if (videoCreative == null) {
LogUtil.warning(TAG, "VideoCreative is null");
return;
}
videoCreative.getResolutionListener().creativeFailed(new AdException(AdException.INTERNAL_ERROR, "Preloading failed: " + error));
}
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/VideoCreativeModel.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.configuration.AdUnitConfiguration;
import org.prebid.mobile.rendering.models.CreativeModel;
import org.prebid.mobile.rendering.models.internal.InternalPlayerState;
import org.prebid.mobile.rendering.networking.tracking.TrackingManager;
import org.prebid.mobile.rendering.video.vast.AdVerifications;
import java.util.ArrayList;
import java.util.HashMap;
public class VideoCreativeModel extends CreativeModel {
private static String TAG = VideoCreativeModel.class.getSimpleName();
private HashMap<VideoAdEvent.Event, ArrayList<String>> videoEventUrls = new HashMap<>();
private String mediaUrl;
//interstitial video: media duration
private long mediaDuration;
private String auid;
private long skipOffset;
// interstitial video: click-through URL
private String vastClickthroughUrl;
private AdVerifications adVerifications;
public VideoCreativeModel(
TrackingManager trackingManager,
OmEventTracker omEventTracker,
AdUnitConfiguration adConfiguration
) {
super(trackingManager, omEventTracker, adConfiguration);
}
public void registerVideoEvent(
VideoAdEvent.Event event,
ArrayList<String> urls
) {
videoEventUrls.put(event, urls);
}
public void trackVideoEvent(VideoAdEvent.Event videoEvent) {
omEventTracker.trackOmVideoAdEvent(videoEvent);
ArrayList<String> urls = videoEventUrls.get(videoEvent);
if (urls == null) {
LogUtil.debug(TAG, "Event" + videoEvent + " not found");
return;
}
trackingManager.fireEventTrackingURLs(urls);
LogUtil.info(TAG, "Video event '" + videoEvent.name() + "' was fired with urls: " + urls.toString());
}
public void trackPlayerStateChange(InternalPlayerState changedPlayerState) {
omEventTracker.trackOmPlayerStateChange(changedPlayerState);
}
public void trackVideoAdStarted(float duration, float volume) {
omEventTracker.trackVideoAdStarted(duration, volume);
}
public void trackNonSkippableStandaloneVideoLoaded(boolean isAutoPlay) {
omEventTracker.trackNonSkippableStandaloneVideoLoaded(isAutoPlay);
}
public HashMap<VideoAdEvent.Event, ArrayList<String>> getVideoEventUrls() {
return videoEventUrls;
}
public String getMediaUrl() {
return mediaUrl;
}
public void setMediaUrl(String mediaUrl) {
this.mediaUrl = mediaUrl;
}
public long getMediaDuration() {
return mediaDuration;
}
public void setMediaDuration(long mediaDuration) {
this.mediaDuration = mediaDuration;
}
public long getSkipOffset() {
return skipOffset;
}
public void setSkipOffset(long skipOffset) {
this.skipOffset = skipOffset;
}
public String getAuid() {
return auid;
}
public void setAuid(String auid) {
this.auid = auid;
}
public String getVastClickthroughUrl() {
return vastClickthroughUrl;
}
public void setVastClickthroughUrl(String vastClickthroughUrl) {
this.vastClickthroughUrl = vastClickthroughUrl;
}
public AdVerifications getAdVerifications() {
return adVerifications;
}
public void setAdVerifications(AdVerifications adVerifications) {
this.adVerifications = adVerifications;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/VideoCreativeProtocol.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video;
import android.content.Context;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.rendering.models.AbstractCreative;
import org.prebid.mobile.rendering.models.CreativeModel;
import org.prebid.mobile.rendering.session.manager.OmAdSessionManager;
import org.prebid.mobile.rendering.video.vast.VASTInterface;
import org.prebid.mobile.rendering.views.interstitial.InterstitialManager;
public abstract class VideoCreativeProtocol extends AbstractCreative implements VASTInterface {
public VideoCreativeProtocol(Context context, CreativeModel model, OmAdSessionManager omAdSessionManager, InterstitialManager interstitialManager)
throws AdException {
super(context, model, omAdSessionManager, interstitialManager);
}
@Override
public void display() {
//This eliminates start()
}
@Override
public void resume() {
}
@Override
public void pause() {
}
@Override
public void expand() {
}
@Override
public void fullScreen() {
}
@Override
public void collapse() {
}
@Override
public void exitFullScreen() {
}
@Override
public void mute() {
}
@Override
public void unmute() {
}
@Override
public void close() {
}
@Override
public void closeLinear() {
}
@Override
public void skip() {
}
@Override
public void rewind() {
}
@Override
public void touch() {
}
@Override
public void orientationChanged(int orientation) {
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/VideoCreativeView.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video;
import android.content.Context;
import android.net.Uri;
import android.view.View;
import android.widget.RelativeLayout;
import androidx.annotation.Nullable;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.api.data.AdFormat;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.core.R;
import org.prebid.mobile.rendering.listeners.VideoCreativeViewListener;
import org.prebid.mobile.rendering.models.ViewPool;
import org.prebid.mobile.rendering.utils.helpers.Dips;
import org.prebid.mobile.rendering.utils.helpers.InsetsUtils;
import org.prebid.mobile.rendering.utils.url.UrlHandler;
import org.prebid.mobile.rendering.utils.url.action.BrowserAction;
import org.prebid.mobile.rendering.utils.url.action.DeepLinkAction;
import org.prebid.mobile.rendering.utils.url.action.DeepLinkPlusAction;
import org.prebid.mobile.rendering.utils.url.action.UrlAction;
import org.prebid.mobile.rendering.views.VolumeControlView;
import static android.widget.RelativeLayout.LayoutParams.MATCH_PARENT;
import static android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT;
public class VideoCreativeView extends RelativeLayout {
private static final String TAG = VideoCreativeView.class.getSimpleName();
private final VideoCreativeViewListener videoCreativeViewListener;
@Nullable private View callToActionView;
private ExoPlayerView exoPlayerView;
private VolumeControlView volumeControlView;
private String callToActionUrl;
private boolean urlHandleInProgress;
private int broadcastId;
private boolean isFirstRunOfCreative = true;
private boolean isMuted = false;
public VideoCreativeView(
Context context,
VideoCreativeViewListener videoCreativeViewListener
) throws AdException {
super(context);
this.videoCreativeViewListener = videoCreativeViewListener;
init();
}
public void setVideoUri(Uri videoUri) {
if (videoUri == null) {
LogUtil.error(TAG, "setVideoUri: Failed. Provided uri is null.");
return;
}
exoPlayerView.setVideoUri(videoUri);
}
public void setVastVideoDuration(long duration) {
exoPlayerView.setVastVideoDuration(duration);
}
public void setBroadcastId(int broadcastId) {
this.broadcastId = broadcastId;
}
public void setCallToActionUrl(String callToActionUrl) {
this.callToActionUrl = callToActionUrl;
}
public String getCallToActionUrl() {
return callToActionUrl;
}
public void start(float initialVolume) {
exoPlayerView.start(initialVolume);
}
public void stop() {
exoPlayerView.stop();
}
public void pause() {
exoPlayerView.pause();
}
public void resume() {
exoPlayerView.resume();
}
public void setStartIsMutedProperty(boolean isMuted) {
if (isFirstRunOfCreative) {
isFirstRunOfCreative = false;
if (isMuted) {
mute();
} else {
unMute();
}
}
}
public void mute() {
isMuted = true;
exoPlayerView.mute();
updateVolumeControlView(VolumeControlView.VolumeState.MUTED);
}
public void unMute() {
isMuted = false;
exoPlayerView.unMute();
updateVolumeControlView(VolumeControlView.VolumeState.UN_MUTED);
}
public void showCallToAction() {
addCallToActionView();
}
public void hideCallToAction() {
if (callToActionView != null) {
removeView(callToActionView);
callToActionView = null;
}
}
public void showVolumeControls() {
addVolumeControlView();
}
public VolumeControlView getVolumeControlView() {
return volumeControlView;
}
public void hideVolumeControls() {
if (volumeControlView != null) {
removeView(volumeControlView);
volumeControlView = null;
}
}
public void enableVideoPlayerClick() {
setOnClickListener(view -> handleCallToActionClick());
}
public boolean isPlaying() {
return exoPlayerView.isPlaying();
}
public boolean hasVideoStarted() {
return exoPlayerView.getCurrentPosition() != -1;
}
public VideoPlayerView getVideoPlayerView() {
return exoPlayerView;
}
public float getVolume() {
return exoPlayerView.getVolume();
}
public void destroy() {
exoPlayerView.destroy();
ViewPool.getInstance().clear();
}
private void init() throws AdException {
LayoutParams layoutParams = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
setLayoutParams(layoutParams);
exoPlayerView = (ExoPlayerView) ViewPool.getInstance()
.getUnoccupiedView(getContext(),
videoCreativeViewListener,
AdFormat.VAST,
null
);
addView(exoPlayerView);
}
private void addCallToActionView() {
callToActionView = inflate(getContext(), R.layout.lyt_call_to_action, null);
callToActionView.setOnClickListener(v -> handleCallToActionClick());
final int width = Dips.dipsToIntPixels(128, getContext());
final int height = Dips.dipsToIntPixels(36, getContext());
final int margin = Dips.dipsToIntPixels(25, getContext());
LayoutParams layoutParams = new LayoutParams(width, height);
layoutParams.addRule(ALIGN_PARENT_BOTTOM);
layoutParams.addRule(ALIGN_PARENT_RIGHT);
layoutParams.setMargins(margin, margin, margin, margin);
addView(callToActionView, layoutParams);
InsetsUtils.addCutoutAndNavigationInsets(callToActionView);
}
private void addVolumeControlView() {
boolean notContainsVolumeControl = indexOfChild(volumeControlView) == -1;
if (notContainsVolumeControl) {
LayoutParams layoutParams = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
volumeControlView = new VolumeControlView(getContext(), isMuted ? VolumeControlView.VolumeState.MUTED : VolumeControlView.VolumeState.UN_MUTED);
volumeControlView.setVolumeControlListener(state -> {
if (state == VolumeControlView.VolumeState.MUTED) {
mute();
} else {
unMute();
}
});
final int margin = Dips.dipsToIntPixels(10, getContext());
layoutParams.addRule(ALIGN_PARENT_BOTTOM);
layoutParams.addRule(ALIGN_PARENT_LEFT);
layoutParams.setMargins(margin, margin, margin, margin);
addView(volumeControlView, layoutParams);
}
}
public void handleCallToActionClick() {
if (urlHandleInProgress) {
LogUtil.debug(TAG, "handleCallToActionClick: Skipping. Url handle in progress");
return;
}
urlHandleInProgress = true;
createUrlHandler().handleUrl(getContext(), callToActionUrl, null, true);
videoCreativeViewListener.onEvent(VideoAdEvent.Event.AD_CLICK);
}
private void updateVolumeControlView(VolumeControlView.VolumeState unMuted) {
if (volumeControlView != null) {
volumeControlView.updateIcon(unMuted);
}
}
UrlHandler createUrlHandler() {
return new UrlHandler.Builder().withDeepLinkPlusAction(new DeepLinkPlusAction())
.withDeepLinkAction(new DeepLinkAction())
.withBrowserAction(new BrowserAction(broadcastId, null))
.withResultListener(new UrlHandler.UrlHandlerResultListener() {
@Override
public void onSuccess(String url, UrlAction urlAction) {
urlHandleInProgress = false;
}
@Override
public void onFailure(String url) {
urlHandleInProgress = false;
LogUtil.debug(TAG, "Failed to handleUrl: " + url + ". Handling fallback");
}
})
.build();
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/VideoDownloadTask.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video;
import android.annotation.SuppressLint;
import android.content.Context;
import android.media.MediaMetadataRetriever;
import android.net.Uri;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.configuration.AdUnitConfiguration;
import org.prebid.mobile.rendering.loading.FileDownloadListener;
import org.prebid.mobile.rendering.loading.FileDownloadTask;
import java.io.*;
import java.net.URLConnection;
import java.util.Calendar;
import java.util.Date;
import java.util.concurrent.TimeUnit;
@SuppressLint("StaticFieldLeak")
public class VideoDownloadTask extends FileDownloadTask {
private static final String TAG = VideoDownloadTask.class.getSimpleName();
private Context applicationContext;
private AdUnitConfiguration adConfiguration;
public VideoDownloadTask(
Context context,
File file,
FileDownloadListener fileDownloadListener,
AdUnitConfiguration adConfiguration
) {
super(fileDownloadListener, file);
if (context == null) {
String contextIsNull = "Context is null";
fileDownloadListener.onFileDownloadError(contextIsNull);
throw new NullPointerException(contextIsNull);
}
this.adConfiguration = adConfiguration;
applicationContext = context.getApplicationContext();
}
@Override
public GetUrlResult sendRequest(GetUrlParams param) throws Exception {
LogUtil.debug(TAG, "url: " + param.url);
LogUtil.debug(TAG, "queryParams: " + param.queryParams);
return createResult(param);
}
private String getShortenedPath() {
String path = file.getPath();
int beginIndex = path.lastIndexOf("/");
return beginIndex != -1 ? path.substring(beginIndex) : path;
}
@Override
protected void processData(URLConnection connection, GetUrlResult result) throws IOException {
String shortenedPath = getShortenedPath();
if (file.exists() && !LruController.isAlreadyCached(shortenedPath)) {
LogUtil.debug(TAG, "Video saved to cache");
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
readAndWriteData(connection, result, outputStream, false);
LruController.putVideoCache(shortenedPath, outputStream.toByteArray());
} else {
LogUtil.debug(TAG, "Video saved to file: " + shortenedPath);
readAndWriteData(connection, result, new FileOutputStream(file), true);
}
}
private void readAndWriteData(URLConnection in, GetUrlResult result, OutputStream out,
boolean deleteOnAbort) throws IOException {
int length = in.getContentLength();
InputStream is = in.getInputStream();
byte[] data = new byte[16384];
long total = 0;
int count;
try {
while ((count = is.read(data)) != -1) {
// allow canceling with back button
if (isCancelled()) {
if (deleteOnAbort) {
if (file.exists()) {
file.delete();
}
}
result.setException(null);
return;
}
total += count;
// publishing the progress....
if (length > 0) // only if total length is known
{
publishProgress((int) (total * 100 / length));
}
out.write(data, 0, count);
}
}
catch (IOException e) {
throw e;
}
finally {
try {
if (is != null) {
is.close();
}
if (out != null) {
out.close();
}
}
catch (Exception ignored) {
}
}
}
private GetUrlResult createResult(GetUrlParams param)
throws Exception {
result = new GetUrlResult();
String shortenedPath = getShortenedPath();
if (file.exists()) {
LogUtil.debug(TAG, "File exists: " + shortenedPath);
if (isVideoFileExpired(file) || !isVideoFileValid(applicationContext, file)) {
LogUtil.debug(TAG, "File " + shortenedPath + " is expired or broken. Downloading a new one");
file.delete();
result = super.sendRequest(param);
} else if (!LruController.isAlreadyCached(shortenedPath)) {
result = super.sendRequest(param);
}
}
else {
result = super.sendRequest(param);
}
return result;
}
private boolean isVideoFileExpired(File file) {
Date lastModDate = new Date(file.lastModified());
Date currentDate = Calendar.getInstance().getTime();
long diff = currentDate.getTime() - lastModDate.getTime();
return diff > TimeUnit.HOURS.toMillis(1);
}
private boolean isVideoFileValid(Context context, File file) {
try {
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
retriever.setDataSource(context, Uri.fromFile(file));
String hasVideo = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_HAS_VIDEO);
return hasVideo.equals("yes");
}
catch (Exception e) {
return false;
}
}
} |
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/VideoPlayerView.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video;
import android.net.Uri;
public interface VideoPlayerView {
void forceStop();
void stop();
void resume();
void pause();
void start(float initialVolume);
void setVastVideoDuration(long duration);
long getCurrentPosition();
void destroy();
void setVideoUri(Uri videoUri);
int getDuration();
float getVolume();
void mute();
void unMute();
boolean isPlaying();
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/Ad.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class Ad extends VASTParserBase {
private final static String VAST_AD = "Ad";
private final static String VAST_INLINE = "InLine";
private final static String VAST_WRAPPER = "Wrapper";
private InLine inline;
private Wrapper wrapper;
private String id;
private String sequence;
public Ad(XmlPullParser p) throws XmlPullParserException, IOException {
p.require(XmlPullParser.START_TAG, null, VAST_AD);
id = p.getAttributeValue(null, "id");
sequence = p.getAttributeValue(null, "sequence");
while (p.next() != XmlPullParser.END_TAG) {
if (p.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String name = p.getName();
if (name != null && name.equals(VAST_INLINE)) {
p.require(XmlPullParser.START_TAG, null, VAST_INLINE);
inline = new InLine(p);
p.require(XmlPullParser.END_TAG, null, VAST_INLINE);
}
else if (name != null && name.equals(VAST_WRAPPER))
{
p.require(XmlPullParser.START_TAG, null, VAST_WRAPPER);
wrapper = new Wrapper(p);
p.require(XmlPullParser.END_TAG, null, VAST_WRAPPER);
}
else
{
skip(p);
}
}
}
public InLine getInline() {
return inline;
}
public Wrapper getWrapper() {
return wrapper;
}
public String getId() {
return id;
}
public String getSequence() {
return sequence;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/AdParameters.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class AdParameters extends VASTParserBase {
private final String xmlEncoded;
private String value;
public AdParameters(XmlPullParser p) throws XmlPullParserException, IOException {
xmlEncoded = p.getAttributeValue(null, "xmlEncoded");
value = readText(p);
}
public String getXmlEncoded() {
return xmlEncoded;
}
public String getValue() {
return value;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/AdSystem.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class AdSystem extends VASTParserBase {
private String version;
private String value;
public AdSystem(XmlPullParser p) throws XmlPullParserException, IOException {
version = p.getAttributeValue(null, "version");
value = readText(p);
}
public String getVersion() {
return version;
}
public String getValue() {
return value;
}
} |
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/AdTitle.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class AdTitle extends BaseValue
{
public AdTitle(XmlPullParser p) throws XmlPullParserException, IOException
{
super(p);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/AdVerifications.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
public class AdVerifications extends VASTParserBase {
private static final String VAST_VERIFICATION = "Verification";
private final ArrayList<Verification> verifications;
public AdVerifications(XmlPullParser p) throws IOException, XmlPullParserException {
verifications = new ArrayList<>();
while (p.next() != XmlPullParser.END_TAG) {
if (p.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String name = p.getName();
if (name != null && name.equals(VAST_VERIFICATION)) {
p.require(XmlPullParser.START_TAG, null, VAST_VERIFICATION);
Verification verification = new Verification(p);
verifications.add(verification);
p.require(XmlPullParser.END_TAG, null, VAST_VERIFICATION);
}
else {
skip(p);
}
}
}
public ArrayList<Verification> getVerifications() {
return verifications;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/Advertiser.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class Advertiser extends BaseValue
{
public Advertiser(XmlPullParser p) throws XmlPullParserException, IOException
{
super(p);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/AltText.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class AltText extends BaseValue
{
public AltText(XmlPullParser p) throws XmlPullParserException, IOException
{
super(p);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/BaseId.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class BaseId extends VASTParserBase {
private String id;
private String value;
public BaseId(XmlPullParser p) throws XmlPullParserException, IOException {
id = p.getAttributeValue(null, "id");
value = readText(p);
}
public String getId() {
return id;
}
public String getValue() {
return value;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/BaseValue.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class BaseValue extends VASTParserBase
{
private String value;
public BaseValue(XmlPullParser p) throws XmlPullParserException, IOException
{
value = readText(p);
}
public String getValue() {
return value;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/ClickThrough.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class ClickThrough extends BaseId
{
public ClickThrough(XmlPullParser p) throws XmlPullParserException, IOException
{
super(p);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/ClickTracking.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class ClickTracking extends BaseId
{
public ClickTracking(XmlPullParser p) throws XmlPullParserException, IOException
{
super(p);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/Companion.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
public class Companion extends VASTParserBase
{
private final static String VAST_COMPANION = "Companion";
private final static String VAST_STATICRESOURCE = "StaticResource";
private final static String VAST_IFRAMERESOUCE = "IFrameResource";
private final static String VAST_HTMLRESOURCE = "HTMLResource";
private final static String VAST_ADPARAMETERS = "AdParameters";
private final static String VAST_ALTTEXT = "AltText";
private final static String VAST_COMPANIONCLICKTHROUGH = "CompanionClickThrough";
private final static String VAST_COMPANIONCLICKTRACKING = "CompanionClickTracking";
private final static String VAST_TRACKINGEVENTS = "TrackingEvents";
private String id;
private String width;
private String height;
private String assetWidth;
private String assetHeight;
private String expandedWidth;
private String expandedHeight;
private String apiFramework;
private String adSlotID;
private StaticResource staticResource;
private IFrameResource iFrameResource;
private HTMLResource HTMLResource;
private AdParameters adParameters;
private AltText altText;
private CompanionClickThrough companionClickThrough;
private CompanionClickTracking companionClickTracking;
private ArrayList<Tracking> trackingEvents;
public Companion(XmlPullParser p) throws XmlPullParserException, IOException {
p.require(XmlPullParser.START_TAG, null, VAST_COMPANION);
id = p.getAttributeValue(null, "id");
width = p.getAttributeValue(null, "width");
height = p.getAttributeValue(null, "height");
assetWidth = p.getAttributeValue(null, "assetWidth");
assetHeight = p.getAttributeValue(null, "assetHeight");
expandedWidth = p.getAttributeValue(null, "expandedWidth");
expandedHeight = p.getAttributeValue(null, "expandedHeight");
apiFramework = p.getAttributeValue(null, "apiFramework");
adSlotID = p.getAttributeValue(null, "adSlotID");
while (p.next() != XmlPullParser.END_TAG) {
if (p.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String name = p.getName();
if (name != null && name.equals(VAST_STATICRESOURCE)) {
p.require(XmlPullParser.START_TAG, null, VAST_STATICRESOURCE);
staticResource = new StaticResource(p);
p.require(XmlPullParser.END_TAG, null, VAST_STATICRESOURCE);
}
else if (name != null && name.equals(VAST_IFRAMERESOUCE))
{
p.require(XmlPullParser.START_TAG, null, VAST_IFRAMERESOUCE);
iFrameResource = new IFrameResource(p);
p.require(XmlPullParser.END_TAG, null, VAST_IFRAMERESOUCE);
}
else if (name != null && name.equals(VAST_HTMLRESOURCE))
{
p.require(XmlPullParser.START_TAG, null, VAST_HTMLRESOURCE);
HTMLResource = new HTMLResource(p);
p.require(XmlPullParser.END_TAG, null, VAST_HTMLRESOURCE);
}
else if (name != null && name.equals(VAST_ADPARAMETERS))
{
p.require(XmlPullParser.START_TAG, null, VAST_ADPARAMETERS);
adParameters = new AdParameters(p);
p.require(XmlPullParser.END_TAG, null, VAST_ADPARAMETERS);
}
else if (name != null && name.equals(VAST_ALTTEXT))
{
p.require(XmlPullParser.START_TAG, null, VAST_ALTTEXT);
altText = new AltText(p);
p.require(XmlPullParser.END_TAG, null, VAST_ALTTEXT);
}
else if (name != null && name.equals(VAST_COMPANIONCLICKTHROUGH))
{
p.require(XmlPullParser.START_TAG, null, VAST_COMPANIONCLICKTHROUGH);
companionClickThrough = new CompanionClickThrough(p);
p.require(XmlPullParser.END_TAG, null, VAST_COMPANIONCLICKTHROUGH);
}
else if (name != null && name.equals(VAST_COMPANIONCLICKTRACKING))
{
p.require(XmlPullParser.START_TAG, null, VAST_COMPANIONCLICKTRACKING);
companionClickTracking = new CompanionClickTracking(p);
p.require(XmlPullParser.END_TAG, null, VAST_COMPANIONCLICKTRACKING);
}
else if (name != null && name.equals(VAST_TRACKINGEVENTS))
{
p.require(XmlPullParser.START_TAG, null, VAST_TRACKINGEVENTS);
trackingEvents = (new TrackingEvents(p)).getTrackingEvents();
p.require(XmlPullParser.END_TAG, null, VAST_TRACKINGEVENTS);
}
else
{
skip(p);
}
}
}
public String getId() {
return id;
}
public String getWidth() {
return width;
}
public String getHeight() {
return height;
}
public String getAssetWidth() {
return assetWidth;
}
public String getAssetHeight() {
return assetHeight;
}
public String getExpandedWidth() {
return expandedWidth;
}
public String getExpandedHeight() {
return expandedHeight;
}
public String getApiFramework() {
return apiFramework;
}
public String getAdSlotID() {
return adSlotID;
}
public StaticResource getStaticResource() {
return staticResource;
}
public IFrameResource getIFrameResource() {
return iFrameResource;
}
public HTMLResource getHtmlResource() {
return HTMLResource;
}
public AdParameters getAdParameters() {
return adParameters;
}
public AltText getAltText() {
return altText;
}
public CompanionClickThrough getCompanionClickThrough() {
return companionClickThrough;
}
public CompanionClickTracking getCompanionClickTracking() {
return companionClickTracking;
}
public ArrayList<Tracking> getTrackingEvents() {
return trackingEvents;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/CompanionAds.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
public class CompanionAds extends VASTParserBase
{
private final static String VAST_COMPANIONADS = "CompanionAds";
private final static String VAST_COMPANION = "Companion";
private ArrayList<Companion> companionAds;
public CompanionAds(XmlPullParser p) throws XmlPullParserException, IOException
{
companionAds = new ArrayList<>();
p.require(XmlPullParser.START_TAG, null, VAST_COMPANIONADS);
while (p.next() != XmlPullParser.END_TAG)
{
if (p.getEventType() != XmlPullParser.START_TAG)
{
continue;
}
String name = p.getName();
if (name != null && name.equals(VAST_COMPANION))
{
p.require(XmlPullParser.START_TAG, null, VAST_COMPANION);
companionAds.add(new Companion(p));
p.require(XmlPullParser.END_TAG, null, VAST_COMPANION);
}
else
{
skip(p);
}
}
}
public ArrayList<Companion> getCompanionAds() {
return companionAds;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/CompanionClickThrough.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class CompanionClickThrough extends BaseId
{
public CompanionClickThrough(XmlPullParser p) throws XmlPullParserException, IOException
{
super(p);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/CompanionClickTracking.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class CompanionClickTracking extends BaseId
{
public CompanionClickTracking(XmlPullParser p) throws XmlPullParserException, IOException
{
super(p);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/Creative.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
public class Creative extends VASTParserBase {
private final static String VAST_CREATIVE = "Creative";
private final static String VAST_CREATIVEEXTENSTONS = "CreativeExtensions";
private final static String VAST_LINEAR = "Linear";
private final static String VAST_COMPANIONADS = "CompanionAds";
private final static String VAST_NONLINEARADS = "NonLinearAds";
private String id;
private String sequence;
private String adID;
private String apiFramework;
private ArrayList<CreativeExtension> creativeExtensions;
private Linear linear;
private ArrayList<Companion> companionAds;
private NonLinearAds nonLinearAds;
public Creative(XmlPullParser p) throws XmlPullParserException, IOException {
p.require(XmlPullParser.START_TAG, null, VAST_CREATIVE);
id = p.getAttributeValue(null, "id");
sequence = p.getAttributeValue(null, "sequence");
adID = p.getAttributeValue(null, "adID");
apiFramework = p.getAttributeValue(null, "apiFramework");
while (p.next() != XmlPullParser.END_TAG) {
if (p.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String name = p.getName();
if (name != null && name.equals(VAST_CREATIVEEXTENSTONS)) {
p.require(XmlPullParser.START_TAG, null, VAST_CREATIVEEXTENSTONS);
creativeExtensions = (new CreativeExtensions(p)).getCreativeExtenstions();
p.require(XmlPullParser.END_TAG, null, VAST_CREATIVEEXTENSTONS);
}
else if (name != null && name.equals(VAST_LINEAR)) {
p.require(XmlPullParser.START_TAG, null, VAST_LINEAR);
linear = new Linear(p);
p.require(XmlPullParser.END_TAG, null, VAST_LINEAR);
}
else if (name != null && name.equals(VAST_COMPANIONADS)) {
p.require(XmlPullParser.START_TAG, null, VAST_COMPANIONADS);
companionAds = (new CompanionAds(p)).getCompanionAds();
p.require(XmlPullParser.END_TAG, null, VAST_COMPANIONADS);
}
else if (name != null && name.equals(VAST_NONLINEARADS)) {
p.require(XmlPullParser.START_TAG, null, VAST_NONLINEARADS);
nonLinearAds = new NonLinearAds(p);
p.require(XmlPullParser.END_TAG, null, VAST_NONLINEARADS);
}
else {
skip(p);
}
}
}
public String getId() {
return id;
}
public String getSequence() {
return sequence;
}
public String getAdID() {
return adID;
}
public String getApiFramework() {
return apiFramework;
}
public ArrayList<CreativeExtension> getCreativeExtensions() {
return creativeExtensions;
}
public Linear getLinear() {
return linear;
}
public ArrayList<Companion> getCompanionAds() {
return companionAds;
}
public void setCompanionAds(ArrayList<Companion> companionAds) {
this.companionAds = companionAds;
}
public NonLinearAds getNonLinearAds() {
return nonLinearAds;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/CreativeExtension.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class CreativeExtension extends BaseValue
{
public CreativeExtension(XmlPullParser p) throws XmlPullParserException, IOException
{
super(p);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/CreativeExtensions.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
public class CreativeExtensions extends VASTParserBase
{
private final static String VAST_CREATIVEEXTENSIONS = "CreativeExtensions";
private final static String VAST_CREATIVEEXTENSION = "CreativeExtension";
private ArrayList<CreativeExtension> creativeExtenstions;
public CreativeExtensions(XmlPullParser p) throws XmlPullParserException, IOException
{
creativeExtenstions = new ArrayList<>();
p.require(XmlPullParser.START_TAG, null, VAST_CREATIVEEXTENSIONS);
while (p.next() != XmlPullParser.END_TAG)
{
if (p.getEventType() != XmlPullParser.START_TAG)
{
continue;
}
String name = p.getName();
if (name != null && name.equals(VAST_CREATIVEEXTENSION))
{
p.require(XmlPullParser.START_TAG, null, VAST_CREATIVEEXTENSION);
creativeExtenstions.add(new CreativeExtension(p));
p.require(XmlPullParser.END_TAG, null, VAST_CREATIVEEXTENSION);
}
else
{
skip(p);
}
}
}
public ArrayList<CreativeExtension> getCreativeExtenstions() {
return creativeExtenstions;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/Creatives.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
public class Creatives extends VASTParserBase
{
private final static String VAST_CREATIVES = "Creatives";
private final static String VAST_CREATIVE = "Creative";
private ArrayList<Creative> creatives;
public Creatives(XmlPullParser p) throws XmlPullParserException, IOException
{
creatives = new ArrayList<>();
p.require(XmlPullParser.START_TAG, null, VAST_CREATIVES);
while (p.next() != XmlPullParser.END_TAG)
{
if (p.getEventType() != XmlPullParser.START_TAG)
{
continue;
}
String name = p.getName();
if (name != null && name.equals(VAST_CREATIVE))
{
p.require(XmlPullParser.START_TAG, null, VAST_CREATIVE);
creatives.add(new Creative(p));
p.require(XmlPullParser.END_TAG, null, VAST_CREATIVE);
}
else
{
skip(p);
}
}
}
public ArrayList<Creative> getCreatives() {
return creatives;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/CustomClick.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class CustomClick extends BaseId
{
public CustomClick(XmlPullParser p) throws XmlPullParserException, IOException
{
super(p);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/Description.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class Description extends BaseValue
{
public Description(XmlPullParser p) throws XmlPullParserException, IOException
{
super(p);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/Duration.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class Duration extends BaseValue
{
public Duration(XmlPullParser p) throws XmlPullParserException, IOException
{
super(p);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/Error.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class Error extends BaseValue
{
public Error(XmlPullParser p) throws XmlPullParserException, IOException
{
super(p);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/Extension.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class Extension extends VASTParserBase {
private String type;
private AdVerifications adVerifications;
private final static String VAST_AD_VERIFICATIONS = "AdVerifications";
private final static String VAST_EXTENSION = "Extension";
public Extension(XmlPullParser p) throws XmlPullParserException, IOException {
type = p.getAttributeValue(null, "type");
p.require(XmlPullParser.START_TAG, null, VAST_EXTENSION);
while (p.next() != XmlPullParser.END_TAG) {
if (p.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String name = p.getName();
if (name != null && name.equals(VAST_AD_VERIFICATIONS)) {
p.require(XmlPullParser.START_TAG, null, VAST_AD_VERIFICATIONS);
adVerifications = new AdVerifications(p);
p.require(XmlPullParser.END_TAG, null, VAST_AD_VERIFICATIONS);
} else {
skip(p);
}
}
}
public String getType() {
return type;
}
public AdVerifications getAdVerifications() {
return adVerifications;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/Extensions.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
public class Extensions extends VASTParserBase
{
private final static String VAST_EXTENSIONS = "Extensions";
private final static String VAST_EXTENSION = "Extension";
private ArrayList<Extension> extensions;
public Extensions(XmlPullParser p) throws XmlPullParserException, IOException
{
extensions = new ArrayList<>();
p.require(XmlPullParser.START_TAG, null, VAST_EXTENSIONS);
while (p.next() != XmlPullParser.END_TAG)
{
if (p.getEventType() != XmlPullParser.START_TAG)
{
continue;
}
String name = p.getName();
if (name != null && name.equals(VAST_EXTENSION))
{
p.require(XmlPullParser.START_TAG, null, VAST_EXTENSION);
extensions.add(new Extension(p));
p.require(XmlPullParser.END_TAG, null, VAST_EXTENSION);
}
else
{
skip(p);
}
}
}
public ArrayList<Extension> getExtensions() {
return extensions;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/HTMLResource.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class HTMLResource extends BaseValue
{
public HTMLResource(XmlPullParser p) throws XmlPullParserException, IOException
{
super(p);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/IFrameResource.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class IFrameResource extends BaseValue
{
public IFrameResource(XmlPullParser p) throws XmlPullParserException, IOException
{
super(p);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/Icon.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class Icon extends VASTParserBase {
private final static String VAST_ICON = "Icon";
private final static String VAST_STATICRESOURCE = "StaticResource";
private final static String VAST_IFRAMERESOURCE = "IFrameResource";
private final static String VAST_HTMLRESOURCE = "HTMLResource";
private final static String VAST_ICONCLICKS = "IconClicks";
private final static String VAST_ICONVIEWTRACKING = "IconViewTracking";
private String program;
private String width;
private String height;
private String xPosition;
private String yPosition;
private String duration;
private String offset;
private String apiFramework;
private StaticResource staticResource;
private IFrameResource iFrameResource;
private HTMLResource htmlResource;
private IconClicks iconClicks;
private IconViewTracking iconViewTracking;
public Icon(XmlPullParser p) throws XmlPullParserException, IOException {
p.require(XmlPullParser.START_TAG, null, VAST_ICON);
program = p.getAttributeValue(null, "program");
width = p.getAttributeValue(null, "width");
height = p.getAttributeValue(null, "height");
xPosition = p.getAttributeValue(null, "xPosition");
yPosition = p.getAttributeValue(null, "yPosition");
duration = p.getAttributeValue(null, "duration");
offset = p.getAttributeValue(null, "offset");
apiFramework = p.getAttributeValue(null, "apiFramework");
while (p.next() != XmlPullParser.END_TAG) {
if (p.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String name = p.getName();
if (name != null && name.equals(VAST_STATICRESOURCE)) {
p.require(XmlPullParser.START_TAG, null, VAST_STATICRESOURCE);
staticResource = new StaticResource(p);
p.require(XmlPullParser.END_TAG, null, VAST_STATICRESOURCE);
}
else if (name != null && name.equals(VAST_IFRAMERESOURCE))
{
p.require(XmlPullParser.START_TAG, null, VAST_IFRAMERESOURCE);
iFrameResource = new IFrameResource(p);
p.require(XmlPullParser.END_TAG, null, VAST_IFRAMERESOURCE);
}
else if (name != null && name.equals(VAST_HTMLRESOURCE))
{
p.require(XmlPullParser.START_TAG, null, VAST_HTMLRESOURCE);
htmlResource = new HTMLResource(p);
p.require(XmlPullParser.END_TAG, null, VAST_HTMLRESOURCE);
}
else if (name != null && name.equals(VAST_ICONCLICKS))
{
p.require(XmlPullParser.START_TAG, null, VAST_ICONCLICKS);
iconClicks = new IconClicks(p);
p.require(XmlPullParser.END_TAG, null, VAST_ICONCLICKS);
}
else if (name != null && name.equals(VAST_ICONVIEWTRACKING))
{
p.require(XmlPullParser.START_TAG, null, VAST_ICONVIEWTRACKING);
iconViewTracking = new IconViewTracking(p);
p.require(XmlPullParser.END_TAG, null, VAST_ICONVIEWTRACKING);
}
else
{
skip(p);
}
}
}
public String getProgram() {
return program;
}
public String getWidth() {
return width;
}
public String getHeight() {
return height;
}
public String getXPosition() {
return xPosition;
}
public String getYPosition() {
return yPosition;
}
public String getDuration() {
return duration;
}
public String getOffset() {
return offset;
}
public String getApiFramework() {
return apiFramework;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/IconClickThrough.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class IconClickThrough extends BaseValue
{
public IconClickThrough(XmlPullParser p) throws XmlPullParserException, IOException
{
super(p);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/IconClickTracking.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class IconClickTracking extends BaseId
{
public IconClickTracking(XmlPullParser p) throws XmlPullParserException, IOException
{
super(p);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/IconClicks.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class IconClicks extends VASTParserBase {
private final static String VAST_ICONCLICKS = "IconClicks";
private final static String VAST_ICONCLICKTHROUGH = "IconClickThrough";
private final static String VAST_ICONCLICKTRACKING = "IconClickTracking";
private IconClickThrough iconClickThrough;
private IconClickTracking iconClickTracking;
public IconClicks(XmlPullParser p) throws XmlPullParserException, IOException {
p.require(XmlPullParser.START_TAG, null, VAST_ICONCLICKS);
while (p.next() != XmlPullParser.END_TAG) {
if (p.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String name = p.getName();
if (name != null && name.equals(VAST_ICONCLICKTHROUGH))
{
p.require(XmlPullParser.START_TAG, null, VAST_ICONCLICKTHROUGH);
iconClickThrough = new IconClickThrough(p);
p.require(XmlPullParser.END_TAG, null, VAST_ICONCLICKTHROUGH);
}
else if (name != null && name.equals(VAST_ICONCLICKTRACKING))
{
p.require(XmlPullParser.START_TAG, null, VAST_ICONCLICKTRACKING);
iconClickTracking = new IconClickTracking(p);
p.require(XmlPullParser.END_TAG, null, VAST_ICONCLICKTRACKING);
}
else
{
skip(p);
}
}
}
public IconClickThrough getIconClickThrough() {
return iconClickThrough;
}
public IconClickTracking getIconClickTracking() {
return iconClickTracking;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/IconViewTracking.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class IconViewTracking extends BaseValue
{
public IconViewTracking(XmlPullParser p) throws XmlPullParserException, IOException
{
super(p);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/Icons.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
public class Icons extends VASTParserBase
{
private final static String VAST_ICONS = "Icons";
private final static String VAST_ICON = "Icon";
private ArrayList<Icon> icons;
public Icons(XmlPullParser p) throws XmlPullParserException, IOException
{
icons = new ArrayList<>();
p.require(XmlPullParser.START_TAG, null, VAST_ICONS);
while (p.next() != XmlPullParser.END_TAG)
{
if (p.getEventType() != XmlPullParser.START_TAG)
{
continue;
}
String name = p.getName();
if (name != null && name.equals(VAST_ICON))
{
p.require(XmlPullParser.START_TAG, null, VAST_ICON);
icons.add(new Icon(p));
p.require(XmlPullParser.END_TAG, null, VAST_ICON);
}
else
{
skip(p);
}
}
}
public ArrayList<Icon> getIcons() {
return icons;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/Impression.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class Impression extends BaseId
{
public Impression(XmlPullParser p) throws XmlPullParserException, IOException
{
super(p);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/InLine.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
public class InLine extends VASTParserBase
{
private final static String VAST_INLINE = "InLine";
private final static String VAST_ADSYSTEM = "AdSystem";
private final static String VAST_ADTITLE = "AdTitle";
private final static String VAST_DESCRIPTION = "Description";
private final static String VAST_ADVERTISER = "Advertiser";
private final static String VAST_PRICING = "Pricing";
private final static String VAST_SURVEY = "Survey";
private final static String VAST_ERROR = "Error";
private final static String VAST_IMPRESSION = "Impression";
private final static String VAST_CREATIVES = "Creatives";
private final static String VAST_EXTENSIONS = "Extensions";
private final static String VAST_AD_VERIFICATIONS = "AdVerifications";
private AdSystem adSystem;
private AdTitle adTitle;
private Description description;
private Advertiser advertiser;
private Pricing pricing;
private Survey survey;
private Error error;
private ArrayList<Impression> impressions;
private ArrayList<Creative> creatives;
private Extensions extensions;
private AdVerifications adVerifications;
public InLine(XmlPullParser p) throws XmlPullParserException, IOException {
p.require(XmlPullParser.START_TAG, null, VAST_INLINE);
while (p.next() != XmlPullParser.END_TAG) {
if (p.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String name = p.getName();
if (name != null && name.equals(VAST_ADSYSTEM))
{
p.require(XmlPullParser.START_TAG, null, VAST_ADSYSTEM);
adSystem = new AdSystem(p);
p.require(XmlPullParser.END_TAG, null, VAST_ADSYSTEM);
}
else if (name != null && name.equals(VAST_ADTITLE))
{
p.require(XmlPullParser.START_TAG, null, VAST_ADTITLE);
adTitle = new AdTitle(p);
p.require(XmlPullParser.END_TAG, null, VAST_ADTITLE);
}
else if (name != null && name.equals(VAST_DESCRIPTION))
{
p.require(XmlPullParser.START_TAG, null, VAST_DESCRIPTION);
description = new Description(p);
p.require(XmlPullParser.END_TAG, null, VAST_DESCRIPTION);
}
else if (name != null && name.equals(VAST_ADVERTISER))
{
p.require(XmlPullParser.START_TAG, null, VAST_ADVERTISER);
advertiser = new Advertiser(p);
p.require(XmlPullParser.END_TAG, null, VAST_ADVERTISER);
}
else if (name != null && name.equals(VAST_PRICING))
{
p.require(XmlPullParser.START_TAG, null, VAST_PRICING);
pricing = new Pricing(p);
p.require(XmlPullParser.END_TAG, null, VAST_PRICING);
}
else if (name != null && name.equals(VAST_SURVEY))
{
p.require(XmlPullParser.START_TAG, null, VAST_SURVEY);
survey = new Survey(p);
p.require(XmlPullParser.END_TAG, null, VAST_SURVEY);
}
else if (name != null && name.equals(VAST_ERROR))
{
p.require(XmlPullParser.START_TAG, null, VAST_ERROR);
error = new Error(p);
p.require(XmlPullParser.END_TAG, null, VAST_ERROR);
}
else if (name != null && name.equals(VAST_IMPRESSION))
{
if (impressions == null) {
impressions = new ArrayList<>();
}
p.require(XmlPullParser.START_TAG, null, VAST_IMPRESSION);
impressions.add(new Impression(p));
p.require(XmlPullParser.END_TAG, null, VAST_IMPRESSION);
}
else if (name != null && name.equals(VAST_CREATIVES))
{
p.require(XmlPullParser.START_TAG, null, VAST_CREATIVES);
creatives = (new Creatives(p)).getCreatives();
p.require(XmlPullParser.END_TAG, null, VAST_CREATIVES);
}
else if (name != null && name.equals(VAST_EXTENSIONS))
{
p.require(XmlPullParser.START_TAG, null, VAST_EXTENSIONS);
extensions = new Extensions(p);
p.require(XmlPullParser.END_TAG, null, VAST_EXTENSIONS);
}
else if (name != null && name.equals(VAST_AD_VERIFICATIONS)) {
p.require(XmlPullParser.START_TAG, null, VAST_AD_VERIFICATIONS);
adVerifications = new AdVerifications(p);
p.require(XmlPullParser.END_TAG, null, VAST_AD_VERIFICATIONS);
}
else
{
skip(p);
}
}
}
public AdSystem getAdSystem() {
return adSystem;
}
public AdTitle getAdTitle() {
return adTitle;
}
public Description getDescription() {
return description;
}
public Advertiser getAdvertiser() {
return advertiser;
}
public Pricing getPricing() {
return pricing;
}
public Survey getSurvey() {
return survey;
}
public Error getError() {
return error;
}
public ArrayList<Impression> getImpressions() {
return impressions;
}
public ArrayList<Creative> getCreatives() {
return creatives;
}
public void setCreatives(ArrayList<Creative> creatives) {
this.creatives = creatives;
}
public Extensions getExtensions() {
return extensions;
}
public AdVerifications getAdVerifications() {
return adVerifications;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/Linear.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
public class Linear extends VASTParserBase
{
private final static String VAST_LINEAR = "Linear";
private final static String VAST_ADPARAMETERS = "AdParameters";
private final static String VAST_DURATION = "Duration";
private final static String VAST_MEDIAFILES = "MediaFiles";
private final static String VAST_TRACKINGEVENTS = "TrackingEvents";
private final static String VAST_VIDEOCLICKS = "VideoClicks";
private final static String VAST_ICONS = "Icons";
private String skipOffset;
private AdParameters adParameters;
private Duration duration;
private ArrayList<MediaFile> mediaFiles;
private ArrayList<Tracking> trackingEvents;
private VideoClicks videoClicks;
private ArrayList<Icon> icons;
public Linear(XmlPullParser p) throws XmlPullParserException, IOException {
p.require(XmlPullParser.START_TAG, null, VAST_LINEAR);
skipOffset = p.getAttributeValue(null, "skipoffset");
while (p.next() != XmlPullParser.END_TAG) {
if (p.getEventType() != XmlPullParser.START_TAG)
{
continue;
}
String name = p.getName();
if (name != null && name.equals(VAST_ADPARAMETERS))
{
p.require(XmlPullParser.START_TAG, null, VAST_ADPARAMETERS);
adParameters = new AdParameters(p);
p.require(XmlPullParser.END_TAG, null, VAST_ADPARAMETERS);
}
else if (name != null && name.equals(VAST_DURATION))
{
p.require(XmlPullParser.START_TAG, null, VAST_DURATION);
duration = new Duration(p);
p.require(XmlPullParser.END_TAG, null, VAST_DURATION);
}
else if (name != null && name.equals(VAST_MEDIAFILES))
{
p.require(XmlPullParser.START_TAG, null, VAST_MEDIAFILES);
mediaFiles = (new MediaFiles(p)).getMediaFiles();
p.require(XmlPullParser.END_TAG, null, VAST_MEDIAFILES);
}
else if (name != null && name.equals(VAST_TRACKINGEVENTS))
{
p.require(XmlPullParser.START_TAG, null, VAST_TRACKINGEVENTS);
trackingEvents = (new TrackingEvents(p)).getTrackingEvents();
p.require(XmlPullParser.END_TAG, null, VAST_TRACKINGEVENTS);
}
else if (name != null && name.equals(VAST_VIDEOCLICKS))
{
p.require(XmlPullParser.START_TAG, null, VAST_VIDEOCLICKS);
videoClicks = new VideoClicks(p);
p.require(XmlPullParser.END_TAG, null, VAST_VIDEOCLICKS);
}
else if (name != null && name.equals(VAST_ICONS))
{
p.require(XmlPullParser.START_TAG, null, VAST_ICONS);
icons = (new Icons(p)).getIcons();
p.require(XmlPullParser.END_TAG, null, VAST_ICONS);
}
else
{
skip(p);
}
}
}
public String getSkipOffset() {
return skipOffset;
}
public AdParameters getAdParameters() {
return adParameters;
}
public Duration getDuration() {
return duration;
}
public ArrayList<MediaFile> getMediaFiles() {
return mediaFiles;
}
public ArrayList<Tracking> getTrackingEvents() {
return trackingEvents;
}
public VideoClicks getVideoClicks() {
return videoClicks;
}
public ArrayList<Icon> getIcons() {
return icons;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/MediaFile.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class MediaFile extends VASTParserBase {
private String id;
private String value;
private String delivery;
private String type;
private String bitrate;
private String minBitrate;
private String maxBitrate;
private String width;
private String height;
private String xPosition;
private String yPosition;
private String duration;
private String offset;
private String apiFramework;
public MediaFile(XmlPullParser p) throws XmlPullParserException, IOException {
id = p.getAttributeValue(null, "id");
delivery = p.getAttributeValue(null, "delivery");
type = p.getAttributeValue(null, "type");
bitrate = p.getAttributeValue(null, "bitrate");
minBitrate = p.getAttributeValue(null, "minBitrate");
maxBitrate = p.getAttributeValue(null, "maxBitrate");
width = p.getAttributeValue(null, "width");
height = p.getAttributeValue(null, "height");
xPosition = p.getAttributeValue(null, "xPosition");
yPosition = p.getAttributeValue(null, "yPosition");
duration = p.getAttributeValue(null, "duration");
offset = p.getAttributeValue(null, "offset");
apiFramework = p.getAttributeValue(null, "apiFramework");
value = readText(p);
}
public String getId() {
return id;
}
public String getValue() {
return value;
}
public String getDelivery() {
return delivery;
}
public String getType() {
return type;
}
public String getBitrate() {
return bitrate;
}
public String getMinBitrate() {
return minBitrate;
}
public String getMaxBitrate() {
return maxBitrate;
}
public String getWidth() {
return width;
}
public String getHeight() {
return height;
}
public String getXPosition() {
return xPosition;
}
public String getYPosition() {
return yPosition;
}
public String getDuration() {
return duration;
}
public String getOffset() {
return offset;
}
public String getApiFramework() {
return apiFramework;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/MediaFiles.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
public class MediaFiles extends VASTParserBase
{
private final static String VAST_MEDIAFILES = "MediaFiles";
private final static String VAST_MEDIAFILE = "MediaFile";
private ArrayList<MediaFile> mediaFiles;
public MediaFiles(XmlPullParser p) throws XmlPullParserException, IOException
{
mediaFiles = new ArrayList<>();
p.require(XmlPullParser.START_TAG, null, VAST_MEDIAFILES);
while (p.next() != XmlPullParser.END_TAG)
{
if (p.getEventType() != XmlPullParser.START_TAG)
{
continue;
}
String name = p.getName();
if (name != null && name.equals(VAST_MEDIAFILE))
{
p.require(XmlPullParser.START_TAG, null, VAST_MEDIAFILE);
mediaFiles.add(new MediaFile(p));
p.require(XmlPullParser.END_TAG, null, VAST_MEDIAFILE);
}
else
{
skip(p);
}
}
}
public ArrayList<MediaFile> getMediaFiles() {
return mediaFiles;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/NonLinear.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class NonLinear extends VASTParserBase {
private final static String VAST_NONLINEAR = "NonLinear";
private final static String VAST_STATICRESOURCE = "StaticResource";
private final static String VAST_IFRAMERESOUCE = "IFrameResource";
private final static String VAST_HTMLRESOURCE = "HTMLResource";
private final static String VAST_ADPARAMETERS = "AdParameters";
private final static String VAST_NONLINEARCLICKTHROUGH = "NonLinearClickThrough";
private final static String VAST_NONLINEARCLICKTRACKING = "NonLinearClickTracking";
private String id;
private String width;
private String height;
private String expandedWidth;
private String expandedHeight;
private String scalable;
private String maintainAspectRatio;
private String minSuggestedDuration;
private String apiFramework;
private StaticResource staticResource;
private IFrameResource iFrameResource;
private HTMLResource HTMLResource;
private AdParameters adParameters;
private NonLinearClickThrough nonLinearClickThrough;
private NonLinearClickTracking nonLinearClickTracking;
public NonLinear(XmlPullParser p) throws XmlPullParserException, IOException {
p.require(XmlPullParser.START_TAG, null, VAST_NONLINEAR);
id = p.getAttributeValue(null, "id");
width = p.getAttributeValue(null, "width");
height = p.getAttributeValue(null, "height");
expandedWidth = p.getAttributeValue(null, "expandedWidth");
expandedHeight = p.getAttributeValue(null, "expandedHeight");
scalable = p.getAttributeValue(null, "scalable");
maintainAspectRatio = p.getAttributeValue(null, "maintainAspectRatio");
minSuggestedDuration = p.getAttributeValue(null, "minSuggestedDuration");
apiFramework = p.getAttributeValue(null, "apiFramework");
while (p.next() != XmlPullParser.END_TAG) {
if (p.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String name = p.getName();
if (name != null && name.equals(VAST_STATICRESOURCE)) {
p.require(XmlPullParser.START_TAG, null, VAST_STATICRESOURCE);
staticResource = new StaticResource(p);
p.require(XmlPullParser.END_TAG, null, VAST_STATICRESOURCE);
}
else if (name != null && name.equals(VAST_IFRAMERESOUCE))
{
p.require(XmlPullParser.START_TAG, null, VAST_IFRAMERESOUCE);
iFrameResource = new IFrameResource(p);
p.require(XmlPullParser.END_TAG, null, VAST_IFRAMERESOUCE);
}
else if (name != null && name.equals(VAST_HTMLRESOURCE))
{
p.require(XmlPullParser.START_TAG, null, VAST_HTMLRESOURCE);
HTMLResource = new HTMLResource(p);
p.require(XmlPullParser.END_TAG, null, VAST_HTMLRESOURCE);
}
else if (name != null && name.equals(VAST_ADPARAMETERS))
{
p.require(XmlPullParser.START_TAG, null, VAST_ADPARAMETERS);
adParameters = new AdParameters(p);
p.require(XmlPullParser.END_TAG, null, VAST_ADPARAMETERS);
}
else if (name != null && name.equals(VAST_NONLINEARCLICKTHROUGH))
{
p.require(XmlPullParser.START_TAG, null, VAST_NONLINEARCLICKTHROUGH);
nonLinearClickThrough = new NonLinearClickThrough(p);
p.require(XmlPullParser.END_TAG, null, VAST_NONLINEARCLICKTHROUGH);
}
else if (name != null && name.equals(VAST_NONLINEARCLICKTRACKING))
{
p.require(XmlPullParser.START_TAG, null, VAST_NONLINEARCLICKTRACKING);
nonLinearClickTracking = new NonLinearClickTracking(p);
p.require(XmlPullParser.END_TAG, null, VAST_NONLINEARCLICKTRACKING);
}
else
{
skip(p);
}
}
}
public String getId() {
return id;
}
public String getWidth() {
return width;
}
public String getHeight() {
return height;
}
public String getExpandedWidth() {
return expandedWidth;
}
public String getExpandedHeight() {
return expandedHeight;
}
public String getScalable() {
return scalable;
}
public String getMaintainAspectRatio() {
return maintainAspectRatio;
}
public String getMinSuggestedDuration() {
return minSuggestedDuration;
}
public String getApiFramework() {
return apiFramework;
}
public StaticResource getStaticResource() {
return staticResource;
}
public IFrameResource getIFrameResource() {
return iFrameResource;
}
public HTMLResource getHTMLResource() {
return HTMLResource;
}
public AdParameters getAdParameters() {
return adParameters;
}
public NonLinearClickThrough getNonLinearClickThrough() {
return nonLinearClickThrough;
}
public NonLinearClickTracking getNonLinearClickTracking() {
return nonLinearClickTracking;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/NonLinearAds.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
public class NonLinearAds extends VASTParserBase {
private final static String VAST_NONLINEAERADS = "NonLinearAds";
private final static String VAST_NONLINEAR = "NonLinear";
private final static String VAST_TRACKINGEVENTS = "TrackingEvents";
private ArrayList<NonLinear> nonLinearAds;
private ArrayList<Tracking> trackingEvents;
public NonLinearAds(XmlPullParser p) throws XmlPullParserException, IOException {
nonLinearAds = new ArrayList<>();
p.require(XmlPullParser.START_TAG, null, VAST_NONLINEAERADS);
while (p.next() != XmlPullParser.END_TAG) {
if (p.getEventType() != XmlPullParser.START_TAG)
{
continue;
}
String name = p.getName();
if (name != null && name.equals(VAST_NONLINEAR))
{
p.require(XmlPullParser.START_TAG, null, VAST_NONLINEAR);
nonLinearAds.add(new NonLinear(p));
p.require(XmlPullParser.END_TAG, null, VAST_NONLINEAR);
}
else if (name != null && name.equals(VAST_TRACKINGEVENTS))
{
p.require(XmlPullParser.START_TAG, null, VAST_TRACKINGEVENTS);
trackingEvents = (new TrackingEvents(p)).getTrackingEvents();
p.require(XmlPullParser.END_TAG, null, VAST_TRACKINGEVENTS);
}
else
{
skip(p);
}
}
}
public ArrayList<NonLinear> getNonLinearAds() {
return nonLinearAds;
}
public ArrayList<Tracking> getTrackingEvents() {
return trackingEvents;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/NonLinearClickThrough.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class NonLinearClickThrough extends BaseId
{
public NonLinearClickThrough(XmlPullParser p) throws XmlPullParserException, IOException
{
super(p);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/NonLinearClickTracking.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class NonLinearClickTracking extends BaseId
{
public NonLinearClickTracking(XmlPullParser p) throws XmlPullParserException, IOException
{
super(p);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/Pricing.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class Pricing extends VASTParserBase {
private String model;
private String currency;
private String value;
public Pricing(XmlPullParser p) throws XmlPullParserException, IOException {
model = p.getAttributeValue(null, "model");
currency = p.getAttributeValue(null, "currency");
value = readText(p);
}
public String getModel() {
return model;
}
public String getCurrency() {
return currency;
}
public String getValue() {
return value;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/StaticResource.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class StaticResource extends VASTParserBase {
private String creativeType;
private String value;
public StaticResource(XmlPullParser p) throws XmlPullParserException, IOException {
creativeType = p.getAttributeValue(null, "creativeType");
value = readText(p);
}
public String getCreativeType() {
return creativeType;
}
public String getValue() {
return value;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/Survey.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class Survey extends BaseValue
{
public Survey(XmlPullParser p) throws XmlPullParserException, IOException
{
super(p);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/Tracking.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class Tracking extends VASTParserBase {
private String event;
private String value;
public Tracking(XmlPullParser p) throws XmlPullParserException, IOException {
event = p.getAttributeValue(null, "event");
value = readText(p);
}
public String getEvent() {
return event;
}
public void setEvent(String event) {
this.event = event;
}
public String getValue() {
return value;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/TrackingEvents.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
public class TrackingEvents extends VASTParserBase
{
private final static String VAST_TRACKINGEVENTS = "TrackingEvents";
private final static String VAST_TRACKING = "Tracking";
private ArrayList<Tracking> trackingEvents;
public TrackingEvents(XmlPullParser p) throws XmlPullParserException, IOException {
trackingEvents = new ArrayList<>();
p.require(XmlPullParser.START_TAG, null, VAST_TRACKINGEVENTS);
while (p.next() != XmlPullParser.END_TAG) {
if (p.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String name = p.getName();
if (name != null && name.equals(VAST_TRACKING)) {
p.require(XmlPullParser.START_TAG, null, VAST_TRACKING);
trackingEvents.add(new Tracking(p));
p.require(XmlPullParser.END_TAG, null, VAST_TRACKING);
}
else {
skip(p);
}
}
}
public ArrayList<Tracking> getTrackingEvents() {
return trackingEvents;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/VAST.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
public class VAST extends VASTParserBase {
private final static String VAST_START = "VAST";
private final static String VAST_ERROR = "Error";
private final static String VAST_AD = "Ad";
private Error error;
private ArrayList<Ad> ads;
private String version;
public VAST(XmlPullParser p) throws XmlPullParserException, IOException {
p.require(XmlPullParser.START_TAG, null, VAST_START);
version = p.getAttributeValue(null, "version");
while (p.next() != XmlPullParser.END_TAG)
{
if (p.getEventType() != XmlPullParser.START_TAG)
{
continue;
}
String name = p.getName();
if (name != null && name.equals(VAST_ERROR))
{
p.require(XmlPullParser.START_TAG, null, VAST_ERROR);
error = new Error(p);
p.require(XmlPullParser.END_TAG, null, VAST_ERROR);
}
else if (name != null && name.equals(VAST_AD))
{
if (ads == null) {
ads = new ArrayList<>();
}
p.require(XmlPullParser.START_TAG, null, VAST_AD);
ads.add(new Ad(p));
p.require(XmlPullParser.END_TAG, null, VAST_AD);
}
else
{
skip(p);
}
}
}
public Error getError() {
return error;
}
public ArrayList<Ad> getAds() {
return ads;
}
public String getVersion() {
return version;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/VASTErrorCodes.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import androidx.annotation.NonNull;
public enum VASTErrorCodes {
XML_PARSE_ERROR("XML parsing error."),
VAST_SCHEMA_ERROR("VAST schema validation error."),
VAST_UNSUPPORTED_VERSION("VAST version of response not supported."),
TRAFFICK_ERROR("Trafficking error. Video player received an Ad type that it was not expecting and/or cannot display."),
LINEARITY_ERROR("Video player expecting different linearity."),
DURATION_ERROR("Video player expecting different duration."),
SIZE_ERROR("Video player expecting different size."),
GENERAL_WRAPPER_ERROR("General Wrapper error."),
VASTTAG_TIMEOUT_ERROR("Timeout of VAST URI provided in Wrapper element, or of VAST URI provided in a subsequent Wrapper element. (URI was either unavailable or reached a timeout as defined by the video player.)"),
WRAPPER_LIMIT_REACH_ERROR("Wrapper limit reached, as defined by the video player. Too many Wrapper responses have been received with no InLine response."),
NO_AD_IN_WRAPPER_ERROR("No Ads VAST response after one or more Wrappers."),
GENERAL_LINEAR_ERROR("General Linear error. Video player is unable to display the Linear Ad."),
MEDIA_NOT_FOUND_ERROR("File not found. Unable to find Linear/MediaFile from URI."),
MEDIA_TIMEOUT_ERROR("Timeout of MediaFile URI."),
NO_SUPPORTED_MEDIA_ERROR("Could not find MediaFile that is supported by this video player, based on the attributes of the MediaFile element."),
MEDIA_DISPLAY_ERROR("Problem displaying MediaFile. Video player found a MediaFile with supported type but couldn't display it. MediaFile may include: unsupported codecs, different MIME type than MediaFile@type, unsupported delivery method, etc."),
//TODO: linear, vpaid & companion error codes
UNDEFINED_ERROR("Undefined Error.");
private final String message;
VASTErrorCodes(String message) {
this.message = message;
}
@NonNull
@Override
public final String toString() {
return message;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/VASTInterface.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
public interface VASTInterface {
/* These are handled by the SDK:
/**
* Per IAB: this event is used to indicate that an individual creative within the ad was loaded and playback
* began. As with creativeView, this event is another way of tracking creative playback.
public void creativeView();
public void firstQuartile();
public void midPoint();
public void thirdQuartile();
public void complete();
*/
/**
* this event is used to indicate that an individual creative within the ad was loaded and playback
* began. As with creativeView, this event is another way of tracking creative playback.
*
*/
//public void start();
/**
* Per IAB: the user activated the resume control after the creative had been stopped or paused.
*/
void resume();
/**
* Per IAB: the user clicked the pause control and stopped the creative.
*/
void pause();
/**
* Per IAB: the user activated a control to expand the creative.
*/
void expand();
/**
* Per IAB: the user activated a control to extend the video player to the edges of the viewer’s
* screen.
*/
void fullScreen();
/**
* the user activated a control to reduce the creative to its original dimensions.
*/
void collapse();
/**
* the user activated the control to reduce video player size to original dimensions.
*/
void exitFullScreen();
/**
* the user activated the mute control and muted the creative.
*/
void mute();
/**
* the user activated the mute control and unmuted the creative.
*/
void unmute();
/**
* the user clicked the close button on the creative.
*/
void close();
/**
* the user clicked the close button on the creative. The name of this event distinguishes it
* from the existing “close” event described in the 2008 IAB Digital Video In-Stream Ad Metrics
* Definitions, which defines the “close” metric as applying to non-linear ads only. The “closeLinear” event
* extends the “close” event for use in Linear creative.
*/
void closeLinear();
/**
* the user activated a skip control to skip the creative, which is a different control than the one
* used to close the creative.
*/
void skip();
/**
* the user activated the rewind control to access a previous point in the creative timeline.
*/
void rewind();
/**
* the user simply touched the video player in a non-specific region of the player (touched an empty area of the video, not a widget or button).
*/
void touch();
/**
* the user made an orientation change by rotating the device. The orientation of Configuration.ORIENTATION_LANDSCAPE or Configuration.ORIENTATION_PORTRAIT is passed in.
*/
void orientationChanged(int orientation);
/**
* the user made a window focus change, such as leaving the activity, pressing back, invoking Recents, or returning from one of these states back to the video player.
* This will allow for internal threads to pause and resume correctly.
*/
void onWindowFocusChanged(boolean hasFocus);
/* Not supported yet, 3.0, Ad Server would have to support it
/**
* the creative played for a duration at normal speed that is equal to or greater than the
* value provided in an additional attribute for offset. Offset values can be time in the format
* HH:MM:SS or HH:MM:SS.mmm or a percentage value in the format n%. Multiple progress events with
* different values can be used to track multiple progress points in the Linear creative timeline.
*
public void progress();
*/
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/VASTParserBase.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class VASTParserBase
{
public String readText(XmlPullParser parser) throws IOException, XmlPullParserException
{
String result = "";
if (parser.next() == XmlPullParser.TEXT)
{
result = parser.getText();
parser.nextTag();
}
return result.trim();
}
public void skip(XmlPullParser p) throws XmlPullParserException, IOException
{
if (p.getEventType() != XmlPullParser.START_TAG)
{
throw new IllegalStateException();
}
int depth = 1;
while (depth != 0)
{
switch (p.next())
{
case XmlPullParser.END_TAG:
depth--;
break;
case XmlPullParser.START_TAG:
depth++;
break;
}
}
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/VastUrl.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class VastUrl extends BaseValue
{
public VastUrl(XmlPullParser p) throws XmlPullParserException, IOException
{
super(p);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/Verification.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class Verification extends VASTParserBase {
private static final String VAST_JS_RESOURCE = "JavaScriptResource";
private static final String VAST_VERIFICATION_PARAMETERS = "VerificationParameters";
private String vendor;
private String jsResource;
private String verificationParameters;
private String apiFramework;
public Verification(XmlPullParser p) throws IOException, XmlPullParserException {
this.vendor = p.getAttributeValue(null, "vendor");
while (p.next() != XmlPullParser.END_TAG) {
if (p.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String name = p.getName();
if (name != null && name.equals(VAST_JS_RESOURCE)) {
p.require(XmlPullParser.START_TAG, null, VAST_JS_RESOURCE);
this.apiFramework = p.getAttributeValue(null, "apiFramework");
this.jsResource = readText(p);
p.require(XmlPullParser.END_TAG, null, VAST_JS_RESOURCE);
}
else if (name != null && name.equals(VAST_VERIFICATION_PARAMETERS)) {
p.require(XmlPullParser.START_TAG, null, VAST_VERIFICATION_PARAMETERS);
this.verificationParameters = readText(p);
p.require(XmlPullParser.END_TAG, null, VAST_VERIFICATION_PARAMETERS);
}
else {
skip(p);
}
}
}
public String getVendor() {
return vendor;
}
public String getJsResource() {
return jsResource;
}
public String getVerificationParameters() {
return verificationParameters;
}
public String getApiFramework() {
return apiFramework;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/VideoClicks.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
public class VideoClicks extends VASTParserBase {
private final static String VAST_VIDEOCLICKS = "VideoClicks";
private final static String VAST_CLICKTHROUGH = "ClickThrough";
private final static String VAST_CLICKTRACKING = "ClickTracking";
private final static String VAST_CUSTOMCLICK = "CustomClick";
private ClickThrough clickThrough;
private ArrayList<ClickTracking> clickTrackings;
private ArrayList<CustomClick> customClicks;
public VideoClicks(XmlPullParser p) throws XmlPullParserException, IOException {
clickTrackings = new ArrayList<>();
customClicks = new ArrayList<>();
p.require(XmlPullParser.START_TAG, null, VAST_VIDEOCLICKS);
while (p.next() != XmlPullParser.END_TAG) {
if (p.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String name = p.getName();
if (name != null && name.equals(VAST_CLICKTHROUGH))
{
p.require(XmlPullParser.START_TAG, null, VAST_CLICKTHROUGH);
clickThrough = new ClickThrough(p);
p.require(XmlPullParser.END_TAG, null, VAST_CLICKTHROUGH);
}
else if (name != null && name.equals(VAST_CLICKTRACKING))
{
p.require(XmlPullParser.START_TAG, null, VAST_CLICKTRACKING);
clickTrackings.add(new ClickTracking(p));
p.require(XmlPullParser.END_TAG, null, VAST_CLICKTRACKING);
}
else if (name != null && name.equals(VAST_CUSTOMCLICK))
{
p.require(XmlPullParser.START_TAG, null, VAST_CUSTOMCLICK);
customClicks.add(new CustomClick(p));
p.require(XmlPullParser.END_TAG, null, VAST_CUSTOMCLICK);
}
else
{
skip(p);
}
}
}
public ClickThrough getClickThrough() {
return clickThrough;
}
public ArrayList<ClickTracking> getClickTrackings() {
return clickTrackings;
}
public ArrayList<CustomClick> getCustomClicks() {
return customClicks;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/video/vast/Wrapper.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.video.vast;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
public class Wrapper extends VASTParserBase {
private final static String VAST_WRAPPER = "Wrapper";
private final static String VAST_ADSYSTEM = "AdSystem";
private final static String VAST_IMPRESSION = "Impression";
//per Vast2.0, it's "VASTAdTagURI" always
private final static String VAST_VASTADTAGURI = "VASTAdTagURI";
private final static String VAST_ERROR = "Error";
private final static String VAST_CREATIVES = "Creatives";
private final static String VAST_EXTENSIONS = "Extensions";
private String followAdditionalWrappers;
private String allowMultipleAds;
private String fallbackOnNoAd;
private AdSystem adSystem;
private VastUrl vastUrl;
private Error error;
private ArrayList<Impression> impressions;
//SDK considers this to be an "optional" param in the video creative, right now.
//https://github.com/InteractiveAdvertisingBureau/vast/blob/master/vast4.xsd#L1411
private ArrayList<Creative> creatives;
private Extensions extensions;
public Wrapper(XmlPullParser p) throws XmlPullParserException, IOException {
p.require(XmlPullParser.START_TAG, null, VAST_WRAPPER);
followAdditionalWrappers = p.getAttributeValue(null, "followAdditionalWrappers");
allowMultipleAds = p.getAttributeValue(null, "allowMultipleAds");
fallbackOnNoAd = p.getAttributeValue(null, "fallbackOnNoAd");
while (p.next() != XmlPullParser.END_TAG) {
if (p.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String name = p.getName();
if (name != null && name.equals(VAST_ADSYSTEM)) {
p.require(XmlPullParser.START_TAG, null, VAST_ADSYSTEM);
adSystem = new AdSystem(p);
p.require(XmlPullParser.END_TAG, null, VAST_ADSYSTEM);
}
else if (name != null && name.equals(VAST_ERROR)) {
p.require(XmlPullParser.START_TAG, null, VAST_ERROR);
error = new Error(p);
p.require(XmlPullParser.END_TAG, null, VAST_ERROR);
}
else if (name != null && name.equals(VAST_VASTADTAGURI)) {
p.require(XmlPullParser.START_TAG, null, VAST_VASTADTAGURI);
vastUrl = new VastUrl(p);
p.require(XmlPullParser.END_TAG, null, VAST_VASTADTAGURI);
}
else if (name != null && name.equals(VAST_IMPRESSION)) {
if (impressions == null) {
impressions = new ArrayList<>();
}
p.require(XmlPullParser.START_TAG, null, VAST_IMPRESSION);
impressions.add(new Impression(p));
p.require(XmlPullParser.END_TAG, null, VAST_IMPRESSION);
}
else if (name != null && name.equals(VAST_CREATIVES)) {
p.require(XmlPullParser.START_TAG, null, VAST_CREATIVES);
creatives = (new Creatives(p)).getCreatives();
p.require(XmlPullParser.END_TAG, null, VAST_CREATIVES);
}
else if (name != null && name.equals(VAST_EXTENSIONS)) {
p.require(XmlPullParser.START_TAG, null, VAST_EXTENSIONS);
extensions = new Extensions(p);
p.require(XmlPullParser.END_TAG, null, VAST_EXTENSIONS);
}
else {
skip(p);
}
}
}
public String getAllowMultipleAds() {
return allowMultipleAds;
}
public String getFallbackOnNoAd() {
return fallbackOnNoAd;
}
public AdSystem getAdSystem() {
return adSystem;
}
public VastUrl getVastUrl() {
return vastUrl;
}
public Error getError() {
return error;
}
public ArrayList<Impression> getImpressions() {
return impressions;
}
public ArrayList<Creative> getCreatives() {
return creatives;
}
public Extensions getExtensions() {
return extensions;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/AdViewManager.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.api.data.AdFormat;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.api.rendering.InterstitialView;
import org.prebid.mobile.configuration.AdUnitConfiguration;
import org.prebid.mobile.core.R;
import org.prebid.mobile.rendering.bidding.data.bid.BidResponse;
import org.prebid.mobile.rendering.listeners.CreativeViewListener;
import org.prebid.mobile.rendering.loading.CreativeFactory;
import org.prebid.mobile.rendering.loading.Transaction;
import org.prebid.mobile.rendering.loading.TransactionManager;
import org.prebid.mobile.rendering.loading.TransactionManagerListener;
import org.prebid.mobile.rendering.models.AbstractCreative;
import org.prebid.mobile.rendering.models.AdDetails;
import org.prebid.mobile.rendering.models.HTMLCreative;
import org.prebid.mobile.rendering.models.internal.InternalFriendlyObstruction;
import org.prebid.mobile.rendering.models.internal.InternalPlayerState;
import org.prebid.mobile.rendering.utils.helpers.Utils;
import org.prebid.mobile.rendering.video.VideoAdEvent;
import org.prebid.mobile.rendering.video.VideoCreative;
import org.prebid.mobile.rendering.video.VideoCreativeView;
import org.prebid.mobile.rendering.views.interstitial.InterstitialManager;
import java.lang.ref.WeakReference;
import java.util.List;
public class AdViewManager implements CreativeViewListener, TransactionManagerListener {
private static final String TAG = AdViewManager.class.getSimpleName();
private final InterstitialManager interstitialManager;
private AdUnitConfiguration adConfiguration = new AdUnitConfiguration();
private TransactionManager transactionManager;
private WeakReference<Context> contextReference;
private ViewGroup adView;
private AdViewManagerListener adViewListener;
private AbstractCreative currentCreative;
private AbstractCreative lastCreativeShown;
private AdViewManagerInterstitialDelegate delegate = this::show;
private boolean hasShownOnce = false;
public AdViewManager(
Context context,
AdViewManagerListener adViewListener,
ViewGroup adView,
InterstitialManager interstitialManager
) throws AdException {
if (context == null) {
throw new AdException(AdException.INTERNAL_ERROR, "Context is null");
}
if (adViewListener == null) {
throw new AdException(AdException.INTERNAL_ERROR, "AdViewManagerListener is null");
}
contextReference = new WeakReference<>(context);
this.adView = adView;
this.adViewListener = adViewListener;
transactionManager = new TransactionManager(context, this, interstitialManager);
this.interstitialManager = interstitialManager;
this.interstitialManager.setAdViewManagerInterstitialDelegate(delegate);
}
@Override
public void onFetchingCompleted(Transaction transaction) {
processTransaction(transaction);
}
@Override
public void onFetchingFailed(AdException exception) {
LogUtil.error(TAG, "There was an error fetching an ad " + exception.toString());
adViewListener.failedToLoad(exception);
}
@Override
public void creativeWasClicked(AbstractCreative creative, String url) {
adViewListener.creativeClicked(url);
}
@Override
public void creativeInterstitialDidClose(AbstractCreative creative) {
LogUtil.debug(TAG, "creativeInterstitialDidClose");
Transaction currentTransaction = transactionManager.getCurrentTransaction();
if (creative.isDisplay() && creative.isEndCard()) {
// Call ad close event for video tracking event
currentTransaction.getCreativeFactories().get(0)
.getCreative().trackVideoEvent(VideoAdEvent.Event.AD_CLOSE);
}
// Transaction is complete
resetTransactionState();
adViewListener.creativeInterstitialClosed();
}
@Override
public void creativeDidExpand(AbstractCreative creative) {
adViewListener.creativeExpanded();
}
@Override
public void creativeDidCollapse(AbstractCreative creative) {
adViewListener.creativeCollapsed();
}
@Override
public void creativeInterstitialDialogShown(ViewGroup rootViewGroup) {
addHtmlInterstitialObstructions(rootViewGroup);
}
@Override
public void creativeMuted(AbstractCreative creative) {
adViewListener.creativeMuted();
}
@Override
public void creativeUnMuted(AbstractCreative creative) {
adViewListener.creativeUnMuted();
}
@Override
public void creativePaused(AbstractCreative creative) {
adViewListener.creativePaused();
}
@Override
public void creativeResumed(AbstractCreative creative) {
adViewListener.creativeResumed();
}
@Override
public void creativeDidComplete(AbstractCreative creative) {
LogUtil.debug(TAG, "creativeDidComplete");
// NOTE: This is currently hard-wired to work for video + end card only
// To truly support continuous ads in a queue, there would need to be significant changes
// in the display layer logic
if (creative.isVideo()) {
handleVideoCreativeComplete(creative);
}
// Clean up on refresh
if (creative.isDisplay()) {
resetTransactionState();
}
adViewListener.adCompleted();
// If banner refresh enabled and another ad is available, show that ad
if (isAutoDisplayOnLoad() && transactionManager.hasTransaction()) {
show();
}
}
public void resetTransactionState() {
hide();
transactionManager.resetState();
}
public void hide() {
if (currentCreative == null) {
LogUtil.warning(TAG, "Can not hide a null creative");
return;
}
if (adView != null && adView.indexOfChild(currentCreative.getCreativeView()) != -1) {
adView.removeView(currentCreative.getCreativeView());
currentCreative = null;
}
}
public void setAdVisibility(int visibility) {
if (currentCreative == null) {
LogUtil.debug(
TAG,
"setAdVisibility(): Skipping creative window focus notification. currentCreative is null"
);
return;
}
if (Utils.isScreenVisible(visibility)) {
//handles resuming of show timer for auid ads & video resume for video ads
currentCreative.handleAdWindowFocus();
} else {
//handles pausing of show timer for auid ads & video pause for video ads
currentCreative.handleAdWindowNoFocus();
}
}
public AdUnitConfiguration getAdConfiguration() {
return adConfiguration;
}
public boolean isAutoDisplayOnLoad() {
return adConfiguration.isAdType(AdFormat.BANNER);
}
public void destroy() {
if (transactionManager != null) {
transactionManager.destroy();
}
if (interstitialManager != null) {
interstitialManager.destroy();
}
if (currentCreative != null) {
currentCreative.destroy();
}
}
public void pause() {
if (currentCreative != null) {
currentCreative.pause();
}
}
public void resume() {
if (currentCreative != null) {
currentCreative.resume();
}
}
public void mute() {
if (currentCreative != null) {
currentCreative.mute();
}
}
public void unmute() {
if (currentCreative != null) {
currentCreative.unmute();
}
}
public boolean isNotShowingEndCard() {
return currentCreative != null && (!(currentCreative.isDisplay()) || !currentCreative.isEndCard());
}
public boolean hasEndCard() {
return currentCreative != null && currentCreative.isDisplay();
}
public boolean hasNextCreative() {
return transactionManager.hasNextCreative();
}
public void updateAdView(View view) {
currentCreative.updateAdView(view);
}
public void trackVideoStateChange(InternalPlayerState state) {
currentCreative.trackVideoStateChange(state);
}
public boolean canShowFullScreen() {
return currentCreative != null && currentCreative.isBuiltInVideo();
}
public void returnFromVideo(View callingView) {
if (currentCreative != null && currentCreative.isBuiltInVideo()) {
View creativeView = currentCreative.getCreativeView();
if (creativeView instanceof VideoCreativeView && currentCreative.isVideo()) {
VideoCreativeView videoCreativeView = (VideoCreativeView) creativeView;
VideoCreative videoCreative = (VideoCreative) currentCreative;
videoCreativeView.hideCallToAction();
videoCreativeView.mute();
videoCreative.updateAdView(callingView);
videoCreative.onPlayerStateChanged(InternalPlayerState.NORMAL);
}
}
}
public boolean isPlaying() {
return currentCreative != null && currentCreative.isPlaying();
}
public boolean isInterstitialClosed() {
return currentCreative != null && currentCreative.isInterstitialClosed();
}
public void trackCloseEvent() {
if (currentCreative != null) {
currentCreative.trackVideoEvent(VideoAdEvent.Event.AD_CLOSE);
}
}
public long getMediaDuration() {
return currentCreative != null ? currentCreative.getMediaDuration() : 0;
}
public long getSkipOffset() {
int sscOffset = adConfiguration.getVideoSkipOffset();
if (sscOffset >= 0) {
return sscOffset;
}
return currentCreative != null ? currentCreative.getVideoSkipOffset() : AdUnitConfiguration.SKIP_OFFSET_NOT_ASSIGNED;
}
public void addObstructions(InternalFriendlyObstruction... friendlyObstructions) {
if (friendlyObstructions == null || friendlyObstructions.length == 0) {
LogUtil.debug(TAG, "addObstructions(): Failed. Obstructions list is empty or null");
return;
}
if (currentCreative == null) {
LogUtil.debug(TAG, "addObstructions(): Failed. Current creative is null.");
return;
}
for (InternalFriendlyObstruction friendlyObstruction : friendlyObstructions) {
currentCreative.addOmFriendlyObstruction(friendlyObstruction);
}
}
public void show() {
if (isInterstitial()) {
if (hasShownOnce) {
LogUtil.debug(TAG, "show() already called: call resume() instead.");
resume();
return;
}
hasShownOnce = true;
}
if (!isCreativeResolved()) {
LogUtil.debug(TAG, "Couldn't proceed show(): Video or HTML is not resolved.");
return;
}
AbstractCreative creative = transactionManager.getCurrentCreative();
if (creative == null) {
LogUtil.error(TAG, "Show called with no ad");
return;
}
// Display current creative
currentCreative = creative;
currentCreative.setCreativeViewListener(this);
handleCreativeDisplay();
}
public void loadBidTransaction(AdUnitConfiguration adConfiguration, BidResponse bidResponse) {
this.adConfiguration = adConfiguration;
resetTransactionState();
transactionManager.fetchBidTransaction(adConfiguration, bidResponse);
}
public void loadVideoTransaction(AdUnitConfiguration adConfiguration, String vastXml) {
this.adConfiguration = adConfiguration;
resetTransactionState();
transactionManager.fetchVideoTransaction(adConfiguration, vastXml);
}
private void handleVideoCreativeComplete(AbstractCreative creative) {
Transaction transaction = transactionManager.getCurrentTransaction();
boolean isBuiltInVideo = creative.isBuiltInVideo();
//for immersive video, we do not need to close when complete. user can swipe to next video.
if (!isInterstitial()) {
closeInterstitial();
}
if (transactionManager.hasNextCreative() && adView != null) {
transactionManager.incrementCreativesCounter();
// Assuming the next creative is an HTMLCreative
HTMLCreative endCardCreative = (HTMLCreative) transaction.getCreativeFactories().get(1).getCreative();
if (isBuiltInVideo) {
interstitialManager.displayVideoAdViewInInterstitial(contextReference.get(), adView);
} else {
interstitialManager.setInterstitialDisplayDelegate(endCardCreative);
interstitialManager.displayAdViewInInterstitial(contextReference.get(), adView);
}
}
adViewListener.videoCreativePlaybackFinished();
}
private void handleCreativeDisplay() {
View creativeView = currentCreative.getCreativeView();
if (creativeView == null) {
LogUtil.error(TAG, "Creative has no view");
return;
}
if (adConfiguration.isAdType(AdFormat.BANNER)) {
if (!currentCreative.equals(lastCreativeShown)) {
displayCreative(creativeView);
}
lastCreativeShown = currentCreative;
return;
}
displayCreative(creativeView);
}
private void displayCreative(View creativeView) {
currentCreative.display();
adViewListener.viewReadyForImmediateDisplay(creativeView);
}
private boolean isCreativeResolved() {
if (currentCreative != null && !currentCreative.isResolved()) {
adViewListener.failedToLoad(new AdException(
AdException.INTERNAL_ERROR,
"Creative has not been resolved yet"
));
return false;
}
return true;
}
// TODO: 13.08.2020 Remove casts
private void closeInterstitial() {
if (adView instanceof InterstitialView) {
((InterstitialView) adView).closeInterstitialVideo();
}
}
private void handleAutoDisplay() {
// This should cover all cases. If we don't have a delegate we're in a bad state.
// If an ad is displaying or we are not to autodisplay, don't show. Otherwise do.
if (adViewListener != null && (currentCreative != null && isAutoDisplayOnLoad())) {
show();
} else {
LogUtil.info(TAG, "AdViewManager - Ad will be displayed when show is called");
}
}
private void addHtmlInterstitialObstructions(ViewGroup rootViewGroup) {
if (rootViewGroup == null) {
LogUtil.debug(TAG, "addHtmlInterstitialObstructions(): rootViewGroup is null.");
return;
}
View closeButtonView = rootViewGroup.findViewById(R.id.iv_close_interstitial);
InternalFriendlyObstruction[] obstructionArray = new InternalFriendlyObstruction[2];
obstructionArray[0] = new InternalFriendlyObstruction(closeButtonView, InternalFriendlyObstruction.Purpose.CLOSE_AD, null);
View dialogRoot = closeButtonView.getRootView();
View navigationBarView = dialogRoot.findViewById(android.R.id.navigationBarBackground);
InternalFriendlyObstruction obstruction = new InternalFriendlyObstruction(navigationBarView, InternalFriendlyObstruction.Purpose.OTHER, "Bottom navigation bar");
obstructionArray[1] = obstruction;
addObstructions(obstructionArray);
}
private void processTransaction(Transaction transaction) {
List<CreativeFactory> creativeFactories = transaction.getCreativeFactories();
if (!creativeFactories.isEmpty()) {
currentCreative = creativeFactories.get(0).getCreative();
currentCreative.createOmAdSession();
}
try {
final AdDetails adDetails = new AdDetails();
adDetails.setTransactionId(transaction.getTransactionState());
adViewListener.adLoaded(adDetails);
trackAdLoaded();
}
catch (Exception e) {
LogUtil.error(TAG, "adLoaded failed: " + Log.getStackTraceString(e));
}
handleAutoDisplay();
}
private void trackAdLoaded() {
if (currentCreative != null) {
currentCreative.trackAdLoaded();
}
}
public void startTrackViewability() {
if (currentCreative instanceof HTMLCreative) {
((HTMLCreative)currentCreative).startViewabilityTrackerV2();
}
}
public interface AdViewManagerInterstitialDelegate {
void showInterstitial();
}
public AbstractCreative getCurrentCreative() {
return currentCreative;
}
private boolean isInterstitial() {
if (currentCreative != null) {
return currentCreative.isInterstitial();
}
return false;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/AdViewManagerListener.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views;
import android.view.View;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.rendering.models.AdDetails;
public abstract class AdViewManagerListener {
/**
* A successful load of an ad
*/
public void adLoaded(AdDetails adDetails) { }
/**
* Attach creativeview to AdView
*
* @param creative which is ready for display
*/
public void viewReadyForImmediateDisplay(View creative) { }
/**
* Callback for a failure in loading an ad
*
* @param error which occurred while loading
*/
public void failedToLoad(AdException error) { }
/**
* When an ad has finished refreshing.
*/
public void adCompleted() { }
/**
* Handle click of a creative
*/
public void creativeClicked(String url) { }
/**
* Handle close of an interstitial ad
*/
public void creativeInterstitialClosed() { }
//mraidAdExpanded
public void creativeExpanded() { }
//mraidAdCollapsed
public void creativeCollapsed() { }
public void creativeMuted() { }
public void creativeUnMuted() { }
public void creativePaused() { }
public void creativeResumed() { }
public void videoCreativePlaybackFinished() {}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/VolumeControlView.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
import androidx.annotation.Nullable;
import org.prebid.mobile.core.R;
public class VolumeControlView extends ImageView {
private VolumeState volumeState = VolumeState.MUTED;
private VolumeControlListener volumeControlListener;
public VolumeControlView(
Context context,
VolumeState initialState
) {
super(context);
updateVolumeState(initialState);
init();
}
public VolumeControlView(
Context context,
@Nullable AttributeSet attrs
) {
super(context, attrs);
init();
}
public VolumeControlView(Context context,
@Nullable
AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
public void setVolumeControlListener(VolumeControlListener volumeControlListener) {
this.volumeControlListener = volumeControlListener;
}
public void mute() {
updateVolumeState(VolumeState.MUTED);
}
public void unMute() {
updateVolumeState(VolumeState.UN_MUTED);
}
public void updateIcon(VolumeState volumeState) {
if (volumeState == VolumeState.MUTED) {
setImageResource(R.drawable.ic_volume_off);
}
else {
setImageResource(R.drawable.ic_volume_on);
}
}
private void init() {
setOnClickListener(view -> {
if (volumeState == VolumeState.MUTED) {
unMute();
} else {
mute();
}
});
}
private void updateVolumeState(VolumeState volumeState) {
this.volumeState = volumeState;
updateIcon(this.volumeState);
if (volumeControlListener != null) {
volumeControlListener.onStateChange(this.volumeState);
}
}
public enum VolumeState {
MUTED,
UN_MUTED
}
public interface VolumeControlListener {
void onStateChange(VolumeState volumeState);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/base/BaseAdView.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.base;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import org.prebid.mobile.ContentObject;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.PrebidMobile;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.configuration.AdUnitConfiguration;
import org.prebid.mobile.rendering.utils.broadcast.local.EventForwardingLocalBroadcastReceiver;
import org.prebid.mobile.rendering.utils.helpers.Utils;
import org.prebid.mobile.rendering.views.AdViewManager;
import org.prebid.mobile.rendering.views.interstitial.InterstitialManager;
/**
* This class provides common functionality for Interstitial and Banner ads.
*/
public abstract class BaseAdView extends FrameLayout {
private static final String TAG = BaseAdView.class.getSimpleName();
protected AdViewManager adViewManager;
protected InterstitialManager interstitialManager = new InterstitialManager();
private EventForwardingLocalBroadcastReceiver eventForwardingReceiver;
private final EventForwardingLocalBroadcastReceiver.EventForwardingBroadcastListener broadcastListener = this::handleBroadcastAction;
private int screenVisibility;
public BaseAdView(Context context) {
super(context);
}
public BaseAdView(
Context context,
AttributeSet attrs
) {
super(context, attrs);
}
@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
super.onWindowFocusChanged(hasWindowFocus);
handleWindowFocusChange(hasWindowFocus);
}
public long getMediaDuration() {
if (adViewManager != null) {
return adViewManager.getMediaDuration();
}
return 0;
}
public long getMediaOffset() {
if (adViewManager != null) {
return adViewManager.getSkipOffset();
}
return AdUnitConfiguration.SKIP_OFFSET_NOT_ASSIGNED;
}
public void setAppContent(ContentObject contentObject) {
if (adViewManager == null) {
LogUtil.error(TAG, "setContentUrl: Failed. AdViewManager is null. Can't set content object. ");
return;
}
adViewManager.getAdConfiguration().setAppContent(contentObject);
}
/**
* @return a creative view associated with the displayed ad
*/
public View getCreativeView() {
return getChildAt(0);
}
protected void init() throws AdException {
int visibility = getVisibility();
setScreenVisibility(visibility);
PrebidMobile.initializeSdk(getContext(), null);
}
protected void registerEventBroadcast() {
final int broadcastId = adViewManager.getAdConfiguration().getBroadcastId();
eventForwardingReceiver = new EventForwardingLocalBroadcastReceiver(broadcastId, broadcastListener);
eventForwardingReceiver.register(getContext(), eventForwardingReceiver);
}
protected void setScreenVisibility(int screenVisibility) {
this.screenVisibility = screenVisibility;
}
protected void handleBroadcastAction(String action) {
LogUtil.debug(TAG, "handleBroadcastAction: parent method executed. No default action handling. " + action);
}
protected void handleWindowFocusChange(boolean hasWindowFocus) {
int visibility = (!hasWindowFocus ? View.INVISIBLE : View.VISIBLE);
if (Utils.hasScreenVisibilityChanged(screenVisibility, visibility) && adViewManager != null) {
screenVisibility = visibility;
adViewManager.setAdVisibility(screenVisibility);
}
}
protected abstract void notifyErrorListeners(final AdException adException);
public void destroy() {
if (adViewManager != null) {
adViewManager.destroy();
}
if (eventForwardingReceiver != null) {
eventForwardingReceiver.unregister(eventForwardingReceiver);
eventForwardingReceiver = null;
}
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/browser/AdBrowserActivity.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.browser;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.EditorInfo;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.MediaController;
import android.widget.RelativeLayout;
import android.widget.VideoView;
import org.prebid.mobile.rendering.utils.broadcast.local.BaseLocalBroadcastReceiver;
import org.prebid.mobile.rendering.utils.constants.IntentActions;
/**
* Custom browser for internal usage. Responsible for modal advertisement
* showing.
*/
@SuppressLint("NewApi")
public final class AdBrowserActivity extends Activity
implements AdBrowserActivityWebViewClient.AdBrowserWebViewClientListener {
private static final String TAG = AdBrowserActivity.class.getSimpleName();
public static final String EXTRA_DENSITY_SCALING_ENABLED = "densityScalingEnabled";
public static final String EXTRA_IS_VIDEO = "EXTRA_IS_VIDEO";
public static final String EXTRA_BROADCAST_ID = "EXTRA_BROADCAST_ID";
public static final String EXTRA_URL = "EXTRA_URL";
public static final String EXTRA_SHOULD_FIRE_EVENTS = "EXTRA_SHOULD_FIRE_EVENTS";
public static final String EXTRA_ALLOW_ORIENTATION_CHANGES = "EXTRA_ALLOW_ORIENTATION_CHANGES";
private static final int BROWSER_CONTROLS_ID = 235799;
private WebView webView;
private VideoView videoView;
private BrowserControls browserControls;
private boolean isVideo;
private boolean shouldFireEvents;
private int broadcastId;
private String url;
//jira/browse/MOBILE-1222 - Enable physical BACK button of the device in the in-app browser in Android
@Override
public boolean onKeyDown(
int keyCode,
KeyEvent event
) {
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
if (webView != null) {
webView.goBack();
}
finish();
}
return super.onKeyDown(keyCode, event);
}
@Override
protected void onPause() {
super.onPause();
if (videoView != null) {
videoView.suspend();
}
}
@Override
protected void onResume() {
super.onResume();
if (videoView != null) {
videoView.resume();
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initWindow();
final Bundle extras = getIntent().getExtras();
claimExtras(extras);
if (isVideo) {
handleVideoDisplay();
} else {
handleWebViewDisplay();
}
}
@Override
protected void onDestroy() {
super.onDestroy();
// Solves memory leak
if (webView != null) {
webView.destroy();
}
if (videoView != null) {
videoView.suspend();
}
}
// Ignore back press on ad browser, except on video since there is no close
@Override
public void onBackPressed() {
if (isVideo) {
super.onBackPressed();
}
}
@Override
public void onPageFinished() {
if (browserControls != null) {
browserControls.updateNavigationButtonsState();
}
}
@Override
public void onUrlHandleSuccess() {
finish();
}
private void initWindow() {
final Window window = getWindow();
window.setBackgroundDrawable(new ColorDrawable(0xFFFFFFFF));
window.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
window.setSoftInputMode(EditorInfo.IME_ACTION_DONE);
}
@SuppressLint("SetJavaScriptEnabled")
private void claimExtras(Bundle extras) {
if (extras == null) {
return;
}
url = extras.getString(EXTRA_URL, null);
shouldFireEvents = extras.getBoolean(EXTRA_SHOULD_FIRE_EVENTS, true);
isVideo = extras.getBoolean(EXTRA_IS_VIDEO, false);
broadcastId = extras.getInt(EXTRA_BROADCAST_ID, -1);
}
private void handleWebViewDisplay() {
initBrowserControls();
RelativeLayout contentLayout = new RelativeLayout(this);
RelativeLayout.LayoutParams barLayoutParams = null;
RelativeLayout.LayoutParams webViewLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT
);
if (!TextUtils.isEmpty(url)) {
webView = new WebView(this);
setWebViewSettings();
webView.setWebViewClient(new AdBrowserActivityWebViewClient(AdBrowserActivity.this));
webView.loadUrl(url);
barLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
if (browserControls != null) {
browserControls.showNavigationControls();
}
webViewLayoutParams.addRule(RelativeLayout.BELOW, BROWSER_CONTROLS_ID);
}
if (webView != null) {
contentLayout.addView(webView, webViewLayoutParams);
}
if (browserControls != null) {
contentLayout.addView(browserControls, barLayoutParams);
}
setContentView(contentLayout);
}
private void handleVideoDisplay() {
videoView = new VideoView(this);
RelativeLayout content = new RelativeLayout(this);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT
);
lp.addRule(RelativeLayout.CENTER_IN_PARENT);
content.addView(videoView, lp);
setContentView(content);
MediaController mc = new MediaController(this);
videoView.setMediaController(mc);
videoView.setVideoURI(Uri.parse(url));
videoView.start();
}
@SuppressLint("SetJavaScriptEnabled")
private void setWebViewSettings() {
if (webView != null) {
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
webView.getSettings().setPluginState(WebSettings.PluginState.OFF);
webView.setHorizontalScrollBarEnabled(false);
webView.setVerticalScrollBarEnabled(false);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.getSettings().setBuiltInZoomControls(true);
//MOB-2160 - Ad Browser: Leaking memory on zoom.(Though it looks like a chromiun webview problem)
//Activity browser.AdBrowserActivity has leaked window android.widget.ZoomButtonsController$Container
webView.getSettings().setDisplayZoomControls(false);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
}
}
private void initBrowserControls() {
BrowserControls controls = new BrowserControls(this, new BrowserControlsEventsListener() {
@Override
public void onRelaod() {
if (webView != null) {
webView.reload();
}
}
@Override
public void onGoForward() {
if (webView != null) {
webView.goForward();
}
}
@Override
public void onGoBack() {
if (webView != null) {
webView.goBack();
}
}
@Override
public String getCurrentURL() {
if (webView != null) {
return webView.getUrl();
}
return null;
}
@Override
public void closeBrowser() {
finish();
sendLocalBroadcast(IntentActions.ACTION_BROWSER_CLOSE);
}
@Override
public boolean canGoForward() {
if (webView != null) {
return webView.canGoForward();
}
return false;
}
@Override
public boolean canGoBack() {
if (webView != null) {
return webView.canGoBack();
}
return false;
}
});
controls.setId(BROWSER_CONTROLS_ID);
browserControls = controls;
}
private void sendLocalBroadcast(String action) {
if (!shouldFireEvents) {
return;
}
BaseLocalBroadcastReceiver.sendLocalBroadcast(getApplicationContext(), broadcastId, action);
}
} |
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/browser/AdBrowserActivityWebViewClient.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.browser;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.rendering.utils.url.UrlHandler;
import org.prebid.mobile.rendering.utils.url.action.DeepLinkAction;
import org.prebid.mobile.rendering.utils.url.action.DeepLinkPlusAction;
import org.prebid.mobile.rendering.utils.url.action.UrlAction;
class AdBrowserActivityWebViewClient extends WebViewClient {
private static final String TAG = AdBrowserActivityWebViewClient.class.getSimpleName();
private AdBrowserWebViewClientListener adBrowserWebViewClientListener;
private boolean urlHandleInProgress;
AdBrowserActivityWebViewClient(AdBrowserWebViewClientListener adBrowserWebViewClientListener) {
this.adBrowserWebViewClientListener = adBrowserWebViewClientListener;
}
@Override
public void onPageFinished(WebView view, String url) {
if (adBrowserWebViewClientListener != null) {
adBrowserWebViewClientListener.onPageFinished();
}
super.onPageFinished(view, url);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
UrlHandler urlHandler = createUrlHandler();
if (urlHandleInProgress) {
return false;
} else {
urlHandleInProgress = true;
return urlHandler.handleResolvedUrl(view.getContext(), url, null, true); // navigation is performed by user
}
}
private UrlHandler createUrlHandler() {
return new UrlHandler.Builder()
.withDeepLinkPlusAction(new DeepLinkPlusAction())
.withDeepLinkAction(new DeepLinkAction())
.withResultListener(new UrlHandler.UrlHandlerResultListener() {
@Override
public void onSuccess(String url, UrlAction urlAction) {
urlHandleInProgress = false;
if (adBrowserWebViewClientListener != null) {
adBrowserWebViewClientListener.onUrlHandleSuccess();
}
}
@Override
public void onFailure(String url) {
LogUtil.debug(TAG, "Failed to handleUrl: " + url);
urlHandleInProgress = false;
}
})
.build();
}
public interface AdBrowserWebViewClientListener {
void onPageFinished();
void onUrlHandleSuccess();
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/browser/BrowserControls.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.browser;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Handler;
import android.util.Log;
import android.view.Gravity;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TableLayout;
import android.widget.TableRow;
import androidx.annotation.VisibleForTesting;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.core.R;
import org.prebid.mobile.rendering.utils.helpers.ExternalViewerUtils;
import org.prebid.mobile.rendering.utils.helpers.Utils;
final class BrowserControls extends TableLayout {
private static String TAG = BrowserControls.class.getSimpleName();
private final static int BROWSER_CONTROLS_PANEL_COLOR = Color.rgb(43, 47, 50);
private Button closeBtn;
private Button backBtn;
private Button forthBtn;
private Button refreshBtn;
private Button openInExternalBrowserBtn;
private LinearLayout leftPart;
private LinearLayout rightPart;
private Handler UIHandler;
private BrowserControlsEventsListener browserControlsEventsListener;
/**
* Create browser controls
*
* @param context for which controls will be created
* @param listener responsible for callbacks
*/
public BrowserControls(
Context context,
BrowserControlsEventsListener listener
) {
super(context);
init(listener);
}
/**
* Update navigation controls (back and forth buttons)
*/
public void updateNavigationButtonsState() {
UIHandler.post(() -> {
if (browserControlsEventsListener == null) {
LogUtil.error(
TAG,
"updateNavigationButtonsState: Unable to update state. browserControlsEventsListener is null"
);
return;
}
if (browserControlsEventsListener.canGoBack()) {
backBtn.setBackgroundResource(R.drawable.prebid_ic_back_active);
} else {
backBtn.setBackgroundResource(R.drawable.prebid_ic_back_inactive);
}
if (browserControlsEventsListener.canGoForward()) {
forthBtn.setBackgroundResource(R.drawable.prebid_ic_forth_active);
} else {
forthBtn.setBackgroundResource(R.drawable.prebid_ic_forth_inactive);
}
});
}
private void bindEventListeners() {
closeBtn.setOnClickListener(v -> {
if (browserControlsEventsListener == null) {
LogUtil.error(TAG, "Close button click failed: browserControlsEventsListener is null");
return;
}
browserControlsEventsListener.closeBrowser();
});
backBtn.setOnClickListener(v -> {
if (browserControlsEventsListener == null) {
LogUtil.error(TAG, "Back button click failed: browserControlsEventsListener is null");
return;
}
browserControlsEventsListener.onGoBack();
});
forthBtn.setOnClickListener(v -> {
if (browserControlsEventsListener == null) {
LogUtil.error(TAG, "Forward button click failed: browserControlsEventsListener is null");
return;
}
browserControlsEventsListener.onGoForward();
});
refreshBtn.setOnClickListener(v -> {
if (browserControlsEventsListener == null) {
LogUtil.error(TAG, "Refresh button click failed: browserControlsEventsListener is null");
return;
}
browserControlsEventsListener.onRelaod();
});
openInExternalBrowserBtn.setOnClickListener(v -> {
String url = null;
if (browserControlsEventsListener != null) {
url = browserControlsEventsListener.getCurrentURL();
}
if (url == null) {
LogUtil.error(TAG, "Open external link failed. url is null");
return;
}
openURLInExternalBrowser(url);
});
}
public void openURLInExternalBrowser(String url) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
ExternalViewerUtils.startActivity(getContext(), intent);
}
catch (Exception e) {
LogUtil.error(TAG, "Could not handle intent: " + url + " : " + Log.getStackTraceString(e));
}
}
private void setButtonDefaultSize(Button button) {
button.setHeight((int) (50 * Utils.DENSITY));
button.setWidth((int) (50 * Utils.DENSITY));
}
private void init(BrowserControlsEventsListener listener) {
UIHandler = new Handler();
browserControlsEventsListener = listener;
if (getContext() != null) {
TableRow controlsSet = new TableRow(getContext());
leftPart = new LinearLayout(getContext());
rightPart = new LinearLayout(getContext());
leftPart.setVisibility(GONE);
rightPart.setGravity(Gravity.RIGHT);
setBackgroundColor(BROWSER_CONTROLS_PANEL_COLOR);
setAllButtons();
bindEventListeners();
leftPart.addView(backBtn);
leftPart.addView(forthBtn);
leftPart.addView(refreshBtn);
leftPart.addView(openInExternalBrowserBtn);
rightPart.addView(closeBtn);
controlsSet.addView(
leftPart,
new TableRow.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, Gravity.LEFT)
);
controlsSet.addView(
rightPart,
new TableRow.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, Gravity.RIGHT)
);
BrowserControls.this.addView(controlsSet);
}
}
private void setAllButtons() {
closeBtn = new Button(getContext());
closeBtn.setContentDescription("close");
setButtonDefaultSize(closeBtn);
closeBtn.setBackgroundResource(R.drawable.prebid_ic_close_browser);
backBtn = new Button(getContext());
backBtn.setContentDescription("back");
setButtonDefaultSize(backBtn);
backBtn.setBackgroundResource(R.drawable.prebid_ic_back_inactive);
forthBtn = new Button(getContext());
forthBtn.setContentDescription("forth");
setButtonDefaultSize(forthBtn);
forthBtn.setBackgroundResource(R.drawable.prebid_ic_forth_inactive);
refreshBtn = new Button(getContext());
refreshBtn.setContentDescription("refresh");
setButtonDefaultSize(refreshBtn);
refreshBtn.setBackgroundResource(R.drawable.prebid_ic_refresh);
openInExternalBrowserBtn = new Button(getContext());
openInExternalBrowserBtn.setContentDescription("openInExternalBrowser");
setButtonDefaultSize(openInExternalBrowserBtn);
openInExternalBrowserBtn.setBackgroundResource(R.drawable.prebid_ic_open_in_browser);
}
public void showNavigationControls() {
leftPart.setVisibility(VISIBLE);
}
public void hideNavigationControls() {
leftPart.setVisibility(GONE);
}
@VisibleForTesting
public BrowserControlsEventsListener getBrowserControlsEventsListener() {
return browserControlsEventsListener;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/browser/BrowserControlsEventsListener.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.browser;
/**
* The listener interface for receiving browser controls events. The class that
* is interested in processing a browser controls events implements this
* interface, and pass this object into constructor of that class. When the
* browser controls event occurs, that object's appropriate method is invoked.
*
*/
public interface BrowserControlsEventsListener
{
/**
* Close browser.
*/
void closeBrowser();
/**
* Perform browser "back" operation.
*/
void onGoBack();
/**
* Perform browser "forward" operation.
*/
void onGoForward();
/**
* Perform browser "relaod" operation.
*/
void onRelaod();
/**
* Check state if browser can navigate back.
*
* @return true, if successful
*/
boolean canGoBack();
/**
* Check state if browser can navigate forward.
*
* @return true, if successful
*/
boolean canGoForward();
/**
* Get the current browser URL.
*
* @return the current URL
*/
String getCurrentURL();
} |
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/interstitial/InterstitialManager.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.interstitial;
import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.VisibleForTesting;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.api.rendering.InterstitialView;
import org.prebid.mobile.api.rendering.VideoView;
import org.prebid.mobile.configuration.AdUnitConfiguration;
import org.prebid.mobile.rendering.interstitial.*;
import org.prebid.mobile.rendering.models.HTMLCreative;
import org.prebid.mobile.rendering.models.InterstitialDisplayPropertiesInternal;
import org.prebid.mobile.rendering.mraid.methods.InterstitialManagerMraidDelegate;
import org.prebid.mobile.rendering.views.AdViewManager;
import org.prebid.mobile.rendering.views.webview.PrebidWebViewInterstitial;
import org.prebid.mobile.rendering.views.webview.WebViewBanner;
import org.prebid.mobile.rendering.views.webview.WebViewBase;
import java.util.Stack;
public class InterstitialManager implements InterstitialManagerInterface {
private static String TAG = InterstitialManager.class.getSimpleName();
private static final int INTERSTITIAL_WEBVIEW_ID = 123456789;
private InterstitialDisplayPropertiesInternal interstitialDisplayProperties = new InterstitialDisplayPropertiesInternal();
private AdInterstitialDialog interstitialDialog;
private InterstitialManagerDisplayDelegate interstitialDisplayDelegate;
private InterstitialManagerVideoDelegate interstitialVideoDelegate;
private InterstitialManagerMraidDelegate mraidDelegate;
private AdViewManager.AdViewManagerInterstitialDelegate adViewManagerInterstitialDelegate;
private final Stack<View> viewStack = new Stack<>();
public void setMraidDelegate(InterstitialManagerMraidDelegate mraidDelegate) {
this.mraidDelegate = mraidDelegate;
}
public void configureInterstitialProperties(AdUnitConfiguration adConfiguration) {
InterstitialLayoutConfigurator.configureDisplayProperties(adConfiguration, interstitialDisplayProperties);
}
public InterstitialDisplayPropertiesInternal getInterstitialDisplayProperties() {
return interstitialDisplayProperties;
}
public void setInterstitialDisplayDelegate(InterstitialManagerDisplayDelegate interstitialDisplayDelegate) {
this.interstitialDisplayDelegate = interstitialDisplayDelegate;
}
public void setInterstitialVideoDelegate(InterstitialManagerVideoDelegate interstitialVideoDelegate) {
this.interstitialVideoDelegate = interstitialVideoDelegate;
}
@VisibleForTesting
public InterstitialManagerDisplayDelegate getInterstitialDisplayDelegate() {
return interstitialDisplayDelegate;
}
public void setAdViewManagerInterstitialDelegate(AdViewManager.AdViewManagerInterstitialDelegate adViewManagerInterstitialDelegate) {
this.adViewManagerInterstitialDelegate = adViewManagerInterstitialDelegate;
}
public void displayPrebidWebViewForMraid(final WebViewBase adBaseView,
final boolean isNewlyLoaded) {
//if it has come from htmlcreative, then nothing in stack. send closed() callback to pubs
if (mraidDelegate != null) {
mraidDelegate.displayPrebidWebViewForMraid(
adBaseView,
isNewlyLoaded,
((WebViewBanner) adBaseView).getMraidEvent()
);
}
}
// Note: The context should be the Activity this view will display on top of
public void displayAdViewInInterstitial(Context context, View view) {
if (!(context instanceof Activity)) {
LogUtil.error(TAG, "displayAdViewInInterstitial(): Can not display interstitial without activity context");
return;
}
if (view instanceof InterstitialView) {
// TODO: 13.08.2020 Remove casts to specific view
InterstitialView interstitialView = ((InterstitialView) view);
show();
showInterstitialDialog(context, interstitialView);
}
}
public void displayVideoAdViewInInterstitial(Context context, View adView) {
if (!(context instanceof Activity && adView instanceof VideoView)) {
LogUtil.error(TAG, "displayAdViewInInterstitial(): Can not display interstitial. "
+ "Context is not activity or adView is not an instance of VideoAdView");
return;
}
show();
}
public void destroy() {
if (interstitialDisplayProperties != null) {
//reset all these for new ads to honour their own creative details
interstitialDisplayProperties.resetExpandValues();
}
if (mraidDelegate != null) {
mraidDelegate.destroyMraidExpand();
mraidDelegate = null;
}
viewStack.clear();
interstitialDisplayDelegate = null;
}
@Override
public void interstitialAdClosed() {
if (interstitialDisplayDelegate != null) {
interstitialDisplayDelegate.interstitialAdClosed();
}
if (interstitialVideoDelegate != null) {
interstitialVideoDelegate.onVideoInterstitialClosed();
}
}
@Override
public void interstitialClosed(View viewToClose) {
LogUtil.debug(TAG, "interstitialClosed");
try {
if (!viewStack.isEmpty() && mraidDelegate != null) {
View poppedViewState = viewStack.pop();
//take the old one & display(ex: close of a video inside of an expanded ad
//should take it back to the defaultview of the ad.
mraidDelegate.displayViewInInterstitial(poppedViewState, false, null, null);
return;
}
//check to see if there's something on the backstack we should return to
//if so, go back or else call interstitialAdClosed
//IMPORTANT: HAS to be there inspite of calling close above.
if ((mraidDelegate == null || !mraidDelegate.collapseMraid()) && interstitialDialog != null) {
interstitialDialog.nullifyDialog();
interstitialDialog = null;
}
if (mraidDelegate != null) {
mraidDelegate.closeThroughJs((WebViewBase) viewToClose);
}
//let adview know when an interstitial ad was closed(1part expand or 2part expand are not interstitials)
//resize->click->expandedview->click on playvideo->pressback->goes back to the expanded state. We should not send clickthrough event to pub, for this case.
if (interstitialDisplayDelegate != null && !(viewToClose instanceof WebViewBanner)) {
interstitialDisplayDelegate.interstitialAdClosed();
}
}
catch (Exception e) {
LogUtil.error(TAG, "InterstitialClosed failed: " + Log.getStackTraceString(e));
}
}
@Override
public void interstitialDialogShown(ViewGroup rootViewGroup) {
if (interstitialDisplayDelegate == null) {
LogUtil.debug(TAG, "interstitialDialogShown(): Failed. interstitialDelegate == null");
return;
}
interstitialDisplayDelegate.interstitialDialogShown(rootViewGroup);
}
private void showInterstitialDialog(Context context, InterstitialView interstitialView) {
WebViewBase webViewBase = ((PrebidWebViewInterstitial) interstitialView.getCreativeView()).getWebView();
webViewBase.setId(INTERSTITIAL_WEBVIEW_ID);
interstitialDialog = new AdInterstitialDialog(context, webViewBase, interstitialView, this);
interstitialDialog.show();
}
public void addOldViewToBackStack(WebViewBase adBaseView, String expandUrl, AdBaseDialog interstitialViewController) {
View oldWebView = null;
if (interstitialViewController != null) {
//at the moment the only case we reach this point is Video opened from expanded MRAID
adBaseView.sendClickCallBack(expandUrl);
oldWebView = interstitialViewController.getDisplayView();
}
if (oldWebView != null) {
viewStack.push(oldWebView);
}
}
public void show() {
if (adViewManagerInterstitialDelegate != null) {
adViewManagerInterstitialDelegate.showInterstitial();
}
}
public HTMLCreative getHtmlCreative() {
return (HTMLCreative) interstitialDisplayDelegate;
}
} |
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/interstitial/InterstitialVideo.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.interstitial;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.CountDownTimer;
import android.os.Handler;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.configuration.AdUnitConfiguration;
import org.prebid.mobile.core.R;
import org.prebid.mobile.rendering.interstitial.AdBaseDialog;
import org.prebid.mobile.rendering.models.InterstitialDisplayPropertiesInternal;
import org.prebid.mobile.rendering.utils.helpers.InsetsUtils;
import org.prebid.mobile.rendering.utils.helpers.Utils;
import org.prebid.mobile.rendering.views.base.BaseAdView;
import org.prebid.mobile.rendering.views.webview.mraid.Views;
import java.lang.ref.WeakReference;
import java.util.Locale;
import java.util.Timer;
import java.util.TimerTask;
@SuppressLint("NewApi")
//Interstitial video
public class InterstitialVideo extends AdBaseDialog {
private static final String TAG = InterstitialVideo.class.getSimpleName();
private static final int CLOSE_DELAY_DEFAULT_IN_MS = 10 * 1000;
private static final int CLOSE_DELAY_MAX_IN_MS = 30 * 1000;
private boolean useSkipButton = false;
private boolean hasEndCard = false;
private boolean isRewarded = false;
//Leaving context here for testing
//Reason:
// "If these are pure JVM unit tests (i.e. run on your computer's JVM and not on an Android emulator/device), then you have no real implementations of methods on any Android classes.
// You are using a mockable jar which just contains empty classes and methods with "final" removed so you can mock them, but they don't really work like when running normal Android."
private final WeakReference<Context> contextReference;
private final AdUnitConfiguration adConfiguration;
private Handler handler;
private Timer timer;
private TimerTask currentTimerTask = null;
private int currentTimerTaskHash = 0;
// Flag used by caller to close manually; More intuitive and reliable way to show
// close button at the end of the video versus trusting the duration from VAST
private boolean showCloseBtnOnComplete;
private CountDownTimer countDownTimer;
@Nullable private RelativeLayout lytCountDownCircle;
private int remainingTimeInMs = -1;
private boolean videoPaused = true;
public InterstitialVideo(
Context context,
FrameLayout adView,
InterstitialManager interstitialManager,
AdUnitConfiguration adConfiguration
) {
super(context, interstitialManager);
contextReference = new WeakReference<>(context);
this.adConfiguration = adConfiguration;
isRewarded = adConfiguration.isRewarded();
adViewContainer = adView;
init();
}
@Override
public void onDetachedFromWindow() {
super.onDetachedFromWindow();
if (timer != null) {
timer.cancel();
timer = null;
}
}
@Override
protected void handleCloseClick() {
close();
}
@Override
protected void handleDialogShow() {
handleAdViewShow();
scheduleShowButtonTask();
}
public boolean shouldShowCloseButtonOnComplete() {
return showCloseBtnOnComplete;
}
public void setShowButtonOnComplete(boolean isEnabled) {
showCloseBtnOnComplete = isEnabled;
}
public void setHasEndCard(boolean hasEndCard) {
this.hasEndCard = hasEndCard;
}
public boolean isVideoPaused() {
return videoPaused;
}
public void scheduleShowCloseBtnTask(View adView) {
scheduleShowCloseBtnTask(adView, AdUnitConfiguration.SKIP_OFFSET_NOT_ASSIGNED);
}
public void scheduleShowButtonTask() {
if (hasEndCard) useSkipButton = true;
int skipDelay = getSkipDelayMs();
long videoLength = getDuration(adViewContainer);
if (videoLength <= skipDelay) {
scheduleTimer(videoLength);
showCloseBtnOnComplete = true;
} else {
scheduleTimer(skipDelay);
}
}
public void scheduleShowCloseBtnTask(
View adView,
int closeDelayInMs
) {
long delayInMs = getCloseDelayInMs(adView, closeDelayInMs);
if (delayInMs == 0) {
LogUtil.debug(TAG, "Delay is 0. Not scheduling skip button show.");
return;
}
long videoLength = getDuration(adView);
LogUtil.debug(TAG, "Video length: " + videoLength);
if (videoLength <= delayInMs) {
// Short video, show close at the end
showCloseBtnOnComplete = true;
} else {
// Clamp close delay value
long upperBound = Math.min(videoLength, CLOSE_DELAY_MAX_IN_MS);
long closeDelayTimeInMs = Utils.clampInMillis((int) delayInMs, 0, (int) upperBound);
scheduleTimer(closeDelayTimeInMs);
}
}
public void pauseVideo() {
LogUtil.debug(TAG, "pauseVideo");
videoPaused = true;
stopTimer();
stopCountDownTimer();
}
public void resumeVideo() {
LogUtil.debug(TAG, "resumeVideo");
videoPaused = false;
if (getRemainingTimerTimeInMs() != AdUnitConfiguration.SKIP_OFFSET_NOT_ASSIGNED && getRemainingTimerTimeInMs() > 500L) {
scheduleShowCloseBtnTask(adViewContainer, getRemainingTimerTimeInMs());
}
}
/**
* Remove all views
*/
public void removeViews() {
if (adViewContainer != null) {
adViewContainer.removeAllViews();
}
}
/**
* Queue new task that should be performed in UI thread.
*
* @param task that will perform in UI thread
*/
public void queueUIThreadTask(Runnable task) {
if (task != null && handler != null) {
handler.post(task);
}
}
public void close() {
LogUtil.debug(TAG, "closeableAdContainer - onClose()");
cancel();
//IMPORTANT: call interstitialClosed() so it sends back to the adViewContainer to reimplant after closing an ad.
interstitialManager.interstitialAdClosed();
}
protected void init() {
handler = new Handler();
timer = new Timer();
Context context = contextReference.get();
if (context == null) {
return;
}
if (isRewarded) {
lytCountDownCircle = (RelativeLayout) LayoutInflater.from(context)
.inflate(R.layout.lyt_countdown_circle_overlay, null);
}
//remove it from parent, if any, before adding it to the new view
Views.removeFromParent(adViewContainer);
addContentView(
adViewContainer,
new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT
)
);
// interstitialManager.setCountDownTimerView(lytCountDownCircle);
setOnKeyListener((dialog, keyCode, event) -> keyCode == KeyEvent.KEYCODE_BACK);
}
private long getOffsetLong(View view) {
return (view instanceof BaseAdView) ? ((BaseAdView) view).getMediaOffset() : AdUnitConfiguration.SKIP_OFFSET_NOT_ASSIGNED;
}
private long getCloseDelayInMs(
View adView,
int closeDelayInMs
) {
long delayInMs = AdUnitConfiguration.SKIP_OFFSET_NOT_ASSIGNED;
long offsetLong = getOffsetLong(adView);
if (offsetLong >= 0) {
delayInMs = offsetLong;
}
int remainingTime = getRemainingTimerTimeInMs();
if (closeDelayInMs == remainingTime && remainingTime >= 0) {
delayInMs = closeDelayInMs;
}
if (delayInMs == AdUnitConfiguration.SKIP_OFFSET_NOT_ASSIGNED) {
delayInMs = CLOSE_DELAY_DEFAULT_IN_MS;
}
LogUtil.debug(TAG, "Picked skip offset: " + delayInMs + " ms.");
return delayInMs;
}
private void createCurrentTimerTask() {
currentTimerTask = new TimerTask() {
@Override
public void run() {
if (currentTimerTaskHash != this.hashCode()) {
cancel();
return;
}
queueUIThreadTask(() -> {
try {
if (useSkipButton) {
skipView.setVisibility(View.VISIBLE);
} else {
changeCloseViewVisibility(View.VISIBLE);
}
} catch (Exception e) {
LogUtil.error(TAG, "Failed to render custom close icon: " + Log.getStackTraceString(e));
}
});
}
};
currentTimerTaskHash = currentTimerTask.hashCode();
}
protected long getDuration(View view) {
return (view instanceof BaseAdView) ? ((BaseAdView) view).getMediaDuration() : 0;
}
private void stopTimer() {
if (timer != null) {
if (currentTimerTask != null) {
currentTimerTask.cancel();
currentTimerTask = null;
}
timer.cancel();
timer.purge();
timer = null;
}
}
private void stopCountDownTimer() {
if (countDownTimer != null) {
countDownTimer.cancel();
countDownTimer.onFinish();
countDownTimer = null;
}
}
private int getRemainingTimerTimeInMs() {
return remainingTimeInMs;
}
private void handleAdViewShow() {
if (interstitialManager != null) {
interstitialManager.show();
}
}
@VisibleForTesting
protected void scheduleTimer(long delayInMs) {
LogUtil.debug(TAG, "Scheduling timer at: " + delayInMs);
stopTimer();
timer = new Timer();
createCurrentTimerTask();
if (delayInMs >= 0) {
// we should convert it to milliseconds, so timer.schedule properly gets the delay in millisconds?
timer.schedule(currentTimerTask, (delayInMs));
}
// Show timer until close
if (isRewarded) {
showDurationTimer(delayInMs);
} else {
startTimer(delayInMs);
}
}
protected void startTimer(long durationInMillis) {
if (countDownTimer != null) {
countDownTimer.cancel();
}
countDownTimer = new CountDownTimer(durationInMillis, 100) {
@Override
public void onTick(long millisUntilFinished) {
int roundedMillis = Math.round((float) millisUntilFinished / 1000f);
remainingTimeInMs = (int) millisUntilFinished;
}
@Override
public void onFinish() {}
};
countDownTimer.start();
}
/**
* @param durationInMillis - duration to count down
*/
@VisibleForTesting
protected void showDurationTimer(long durationInMillis) {
if (durationInMillis == 0) {
return;
}
final ProgressBar pbProgress = lytCountDownCircle.findViewById(R.id.Progress);
pbProgress.setMax((int) durationInMillis);
// Turns progress bar ccw 90 degrees so progress starts from the top
final Animation animation = new RotateAnimation(0.0f,
-90.0f,
Animation.RELATIVE_TO_PARENT,
0.5f,
Animation.RELATIVE_TO_PARENT,
0.5f
);
animation.setFillAfter(true);
pbProgress.startAnimation(animation);
final TextView lblCountdown = lytCountDownCircle.findViewById(R.id.lblCountdown);
final WeakReference<FrameLayout> weakAdViewContainer = new WeakReference<>(adViewContainer);
if (countDownTimer != null) {
countDownTimer.cancel();
}
countDownTimer = new CountDownTimer(durationInMillis, 100) {
@Override
public void onTick(long millisUntilFinished) {
int roundedMillis = Math.round((float) millisUntilFinished / 1000f);
remainingTimeInMs = (int) millisUntilFinished;
pbProgress.setProgress((int) millisUntilFinished);
lblCountdown.setText(String.format(Locale.US, "%d", roundedMillis));
}
@Override
public void onFinish() {
FrameLayout adViewContainer = weakAdViewContainer.get();
if (adViewContainer == null) {
return;
}
adViewContainer.removeView(lytCountDownCircle);
}
};
countDownTimer.start();
if (lytCountDownCircle.getParent() != null) {
Views.removeFromParent(lytCountDownCircle);
}
adViewContainer.addView(lytCountDownCircle);
InsetsUtils.addCutoutAndNavigationInsets(lytCountDownCircle);
}
@VisibleForTesting
protected void setRemainingTimeInMs(int value) {
remainingTimeInMs = value;
}
protected int getSkipDelayMs() {
InterstitialDisplayPropertiesInternal properties = interstitialManager.getInterstitialDisplayProperties();
if (properties != null) {
long videoDuration = getDuration(adViewContainer);
long upperBound = Math.min(videoDuration, CLOSE_DELAY_MAX_IN_MS);
int delay = properties.skipDelay * 1000;
return Utils.clampInMillis(delay, 0, (int) upperBound);
}
return CLOSE_DELAY_DEFAULT_IN_MS;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/video/VideoDialog.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.video;
import android.content.Context;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import org.prebid.mobile.rendering.interstitial.AdBaseDialog;
import org.prebid.mobile.rendering.listeners.VideoDialogListener;
import org.prebid.mobile.rendering.models.internal.InternalPlayerState;
import org.prebid.mobile.rendering.video.VideoCreativeView;
import org.prebid.mobile.rendering.views.AdViewManager;
import org.prebid.mobile.rendering.views.interstitial.InterstitialManager;
public class VideoDialog extends AdBaseDialog {
private static final String TAG = "VideoDialog";
private final AdViewManager adViewManager;
private VideoCreativeView adView;
private VideoDialogListener videoDialogListener;
public VideoDialog(
Context context,
VideoCreativeView videoCreativeView,
AdViewManager adViewManager,
InterstitialManager interstitialManager,
FrameLayout adViewContainer
) {
super(context, interstitialManager);
this.adViewContainer = adViewContainer;
this.adViewManager = adViewManager;
this.adViewContainer.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
));
adView = videoCreativeView;
setContentView(this.adViewContainer);
initListeners();
}
public void setVideoDialogListener(VideoDialogListener videoDialogListener) {
this.videoDialogListener = videoDialogListener;
}
@Override
protected void handleCloseClick() {
dismiss();
unApplyOrientation();
if (videoDialogListener != null) {
videoDialogListener.onVideoDialogClosed();
}
}
@Override
protected void handleDialogShow() {
handleShowAction();
}
public void showBannerCreative(View creativeView) {
adViewContainer.removeAllViews();
creativeView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
));
lockOrientation();
adViewContainer.addView(creativeView);
displayView = creativeView;
addCloseView();
adView = null;
}
private void initListeners() {
setOnKeyListener((dialog, keyCode, event) -> keyCode == KeyEvent.KEYCODE_BACK);
}
private void handleShowAction() {
adViewManager.trackVideoStateChange(InternalPlayerState.EXPANDED);
adView.unMute();
changeCloseViewVisibility(View.VISIBLE);
adView.showCallToAction();
adViewManager.updateAdView(adViewContainer);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/video/VideoViewListener.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.video;
import androidx.annotation.NonNull;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.api.rendering.VideoView;
import org.prebid.mobile.rendering.models.AdDetails;
public abstract class VideoViewListener {
public void onLoaded(
@NonNull
VideoView videoAdView, AdDetails adDetails) {}
public void onLoadFailed(
@NonNull
VideoView videoAdView, AdException error) {}
public void onDisplayed(
@NonNull
VideoView videoAdView) {}
public void onPlayBackCompleted(
@NonNull
VideoView videoAdView) {}
public void onClickThroughOpened(
@NonNull
VideoView videoAdView) {}
public void onClickThroughClosed(
@NonNull
VideoView videoAdView) {}
public void onPlaybackPaused() {}
public void onPlaybackResumed() {}
public void onVideoUnMuted() {}
public void onVideoMuted() {}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview/AdWebView.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.webview;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.Log;
import android.view.WindowManager;
import android.webkit.WebSettings;
import android.webkit.WebSettings.LayoutAlgorithm;
import android.webkit.WebView;
import org.prebid.mobile.rendering.utils.helpers.Utils;
import org.prebid.mobile.rendering.views.webview.AdWebViewClient.AdAssetsLoadedListener;
import org.prebid.mobile.rendering.views.webview.mraid.MraidWebViewClient;
public class AdWebView extends WebView {
private static final String TAG = AdWebView.class.getSimpleName();
protected Integer scale;
private AdWebViewClient adWebViewClient;
protected int width, height;
protected String domain;
public AdWebView(Context context) {
super(context);
//This sets the jsinterface listener to handle open for both mraid & nonmraid ads.
init();
}
@Override
public void setInitialScale(int scaleInPercent) {
scale = scaleInPercent;
}
public String getInitialScaleValue() {
if (scale != null) {
return String.valueOf((float) scale / 100f);
}
return null;
}
public void setMraidAdAssetsLoadListener(AdAssetsLoadedListener adAssetsLoadedListener,
String mraidScript) {
if (adWebViewClient == null) {
adWebViewClient = new MraidWebViewClient(adAssetsLoadedListener, mraidScript);
}
setWebViewClient(adWebViewClient);
}
protected void init() {
initializeWebView();
initializeWebSettings();
}
protected void initializeWebView() {
setScrollBarStyle(SCROLLBARS_INSIDE_OVERLAY);
setFocusable(true);
setHorizontalScrollBarEnabled(false);
setVerticalScrollBarEnabled(false);
}
protected void initializeWebSettings() {
WebSettings webSettings = getSettings();
int screenWidth = 0;
int screenHeight = 0;
if (getContext() != null) {
WindowManager windowManager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
screenWidth = Utils.getScreenWidth(windowManager);
screenHeight = Utils.getScreenHeight(windowManager);
}
if (this instanceof WebViewInterstitial) {
calculateScaleForResize(screenWidth, screenHeight, width, height);
} else {
webSettings.setLoadWithOverviewMode(true);
}
initBaseWebSettings(webSettings);
getSettings().setSupportZoom(false);
webSettings.setUseWideViewPort(true);
webSettings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
}
private void calculateScaleForResize(
int screenWidth,
int screenHeight,
int creativeWidth,
int creativeHeight
) {
double screenRatio = ((double) screenWidth) / screenHeight;
double creativeRatio = ((double) creativeWidth) / creativeHeight;
double scaledScreenWidth = screenWidth / densityScalingFactor();
double scaledScreenHeight = screenHeight / densityScalingFactor();
double initialScale;
double factor;
boolean creativeRatioIsLess = creativeRatio <= screenRatio;
if (scaledScreenWidth >= creativeWidth && scaledScreenHeight >= creativeHeight) {
setInitialScale(100);
} else {
if (creativeRatioIsLess) {
initialScale = scaledScreenWidth / creativeWidth;
double newCreativeHeight = creativeHeight * initialScale;
factor = newCreativeHeight / scaledScreenHeight;
} else {
initialScale = scaledScreenHeight / creativeHeight;
double newCreativeWidth = creativeWidth * initialScale;
factor = newCreativeWidth / scaledScreenWidth;
}
int scaleInPercent = (int) (initialScale / factor * 100);
setInitialScale(scaleInPercent);
Log.d(TAG, "Using custom WebView scale: " + scaleInPercent);
}
}
@SuppressLint("SetJavaScriptEnabled")
private void initBaseWebSettings(WebSettings webSettings) {
webSettings.setJavaScriptEnabled(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(false);
webSettings.setPluginState(WebSettings.PluginState.OFF);
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
webSettings.setUseWideViewPort(true);
}
public double densityScalingFactor() {
double densityScaleFactor = 0;
if (getContext() != null) {
densityScaleFactor = getContext().getResources().getDisplayMetrics().density;
}
return densityScaleFactor;
}
public void setDomain(String domain) {
this.domain = domain;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview/AdWebViewClient.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.webview;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.webkit.RenderProcessGoneDetail;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.LogUtil;
import java.util.HashSet;
import static android.webkit.WebView.HitTestResult.SRC_ANCHOR_TYPE;
import static android.webkit.WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE;
import static org.prebid.mobile.rendering.views.webview.PrebidWebViewBanner.appEventLogger;
public class AdWebViewClient extends WebViewClient {
private static final String TAG = AdWebViewClient.class.getSimpleName();
private static final String JS__GET_RENDERED_HTML = "javascript:window.HtmlViewer.showHTML" + "('<html>'+document.getElementsByTagName('html')[0].innerHTML+'</html>');";
protected AdAssetsLoadedListener adAssetsLoadedListener;
private boolean loadingFinished = true;
private HashSet<String> urls = new HashSet<>();
private String pageUrl;
public interface AdAssetsLoadedListener {
void startLoadingAssets();
void adAssetsLoaded();
void notifyMraidScriptInjected();
}
public AdWebViewClient(AdAssetsLoadedListener adAssetsLoadedListener) {
this.adAssetsLoadedListener = adAssetsLoadedListener;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
if (view == null) {
LogUtil.error(TAG, "onPageStarted failed, WebView is null");
return;
}
try {
super.onPageStarted(view, url, favicon);
pageUrl = url;
loadingFinished = false;
adAssetsLoadedListener.startLoadingAssets();
}
catch (Exception e) {
LogUtil.error(TAG, "onPageStarted failed for url: " + url + " : " + Log.getStackTraceString(e));
}
}
@Override
public void onPageFinished(WebView view, String url) {
if (view == null) {
LogUtil.error(TAG, "onPageFinished failed, WebView is null");
return;
}
LogUtil.debug(TAG, "onPageFinished: " + view);
try {
adAssetsLoadedListener.adAssetsLoaded();
view.setBackgroundColor(Color.TRANSPARENT);
}
catch (Exception e) {
LogUtil.error(TAG, "onPageFinished failed for url: " + url + " : " + Log.getStackTraceString(e));
}
}
@Override
public void onLoadResource(WebView view, String url) {
if (view == null) {
LogUtil.error(TAG, "onPageStarted failed, WebView is null");
return;
}
if (url != null && url.equals(pageUrl)) {
return;
}
try {
WebViewBase webViewBase = (WebViewBase) view;
// IMPORTANT: The code below should be performed only to the iframe of the raw ad (without SDK injections).
// Need to check webViewBase.containsIFrame() because displayed ad could contain another
// injected script (for example OpenMeasurement) that initializes own resources.
// Otherwise, we could get an error: jira/browse/MOBILE-5100
if (webViewBase.containsIFrame() && webViewBase.isClicked() && !urls.contains(url) && view.getHitTestResult() != null && (view.getHitTestResult()
.getType() == SRC_ANCHOR_TYPE || view.getHitTestResult()
.getType() == SRC_IMAGE_ANCHOR_TYPE)) {
// stop loading the iframe or whatever
// instead simply change the location of the webview - this will
// trigger our shouldOverrideUrlLoading
reloadUrl(view, url);
}
urls.add(url);
super.onLoadResource(view, url);
}
catch (Exception e) {
LogUtil.error(TAG, "onLoadResource failed for url: " + url + " : " + Log.getStackTraceString(e));
}
}
//gets called when an ad is clicked by user. Takes user to the browser or such
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
LogUtil.debug(TAG, "shouldOverrideUrlLoading, url: " + url);
if (view == null) {
LogUtil.error(TAG, "onPageStarted failed, WebView is null");
return false;
}
try {
WebViewBase webViewBase = ((WebViewBase) view);
if (!webViewBase.isClicked()) {
// Get the rendered HTML
reloadUrl(view, JS__GET_RENDERED_HTML);
return true;
}
handleWebViewClick(url, webViewBase);
}
catch (Exception e) {
LogUtil.error(TAG, "shouldOverrideUrlLoading failed for url: " + url + " : " + Log.getStackTraceString(e));
}
return true;
}
boolean isLoadingFinished() {
return loadingFinished;
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
super.onReceivedError(view, errorCode, description, failingUrl);
}
@Override
public boolean shouldOverrideKeyEvent(WebView view, KeyEvent event) {
return super.shouldOverrideKeyEvent(view, event);
}
@Override
public boolean onRenderProcessGone(WebView view, RenderProcessGoneDetail detail) {
if (view instanceof WebViewBase) {
JSONObject logData = ((WebViewBase) view).adLogData;
if (appEventLogger != null) {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
logData.put("didCrash", detail.didCrash());
}
} catch (JSONException ignored){}
appEventLogger.logAppEvent("Web Render Gone", logData);
}
view.destroy();
}
return true;
}
private void reloadUrl(WebView view, String s) {
view.stopLoading();
// Get the rendered HTML
view.loadUrl(s);
}
private void handleWebViewClick(String url, WebViewBase webViewBase) {
urls.clear();
loadingFinished = false;
String targetUrl = webViewBase.getTargetUrl();
url = TextUtils.isEmpty(targetUrl) ? url : targetUrl;
if (webViewBase.canHandleClick()) {
loadingFinished = true;
urls.clear();
//all(generally non-mraid) comes here - open/click here
webViewBase.mraidListener.openExternalLink(url);
}
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview/MraidEventsManager.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.webview;
public class MraidEventsManager {
public interface MraidListener {
void openExternalLink(String url);
void openMraidExternalLink(String url);
void onAdWebViewWindowFocusChanged(boolean hasFocus);
void loadMraidExpandProperties();
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview/PrebidWebViewBanner.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.webview;
import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.util.Log;
import android.view.animation.AnimationUtils;
import android.webkit.WebView;
import android.webkit.WebViewRenderProcess;
import android.webkit.WebViewRenderProcessClient;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.json.JSONObject;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.core.R;
import org.prebid.mobile.rendering.models.CreativeModel;
import org.prebid.mobile.rendering.models.HTMLCreative;
import org.prebid.mobile.rendering.models.internal.MraidVariableContainer;
import org.prebid.mobile.rendering.mraid.handler.FetchPropertiesHandler;
import org.prebid.mobile.rendering.sdk.JSLibraryManager;
import org.prebid.mobile.rendering.views.interstitial.InterstitialManager;
import org.prebid.mobile.rendering.views.webview.mraid.Views;
public class PrebidWebViewBanner extends PrebidWebViewBase
implements PreloadManager.PreloadedListener, MraidEventsManager.MraidListener {
public interface AppEventLogger {
void logAppEvent(String event, JSONObject properties);
}
public static AppEventLogger appEventLogger;
private static final String TAG = PrebidWebViewBanner.class.getSimpleName();
private final FetchPropertiesHandler.FetchPropertyCallback expandPropertiesCallback = new FetchPropertiesHandler.FetchPropertyCallback() {
@Override
public void onResult(String propertyJson) {
handleExpandPropertiesResult(propertyJson);
}
@Override
public void onError(Throwable throwable) {
LogUtil.error(TAG, "executeGetExpandProperties failed: " + Log.getStackTraceString(throwable));
}
};
public PrebidWebViewBanner(Context context, InterstitialManager interstitialManager) {
super(context, interstitialManager);
setId(R.id.web_view_banner);
}
//gets expand properties & also a close view(irrespective of usecustomclose is false)
public void loadMraidExpandProperties() {
Context context = getContext();
if (!(context instanceof Activity)) {
LogUtil.warning(TAG, "Context is null or is not activity context");
return;
}
/*
* If it's MRAID, we have to check the Ad designer's request to launch
* the ad in a particular expanded size by checking the ad's
* ExpandProperties per the MRAID spec. So we go to the js and extract these
* properties and then the layout gets built based on these things.
*/
//Fix MOBILE-2944 App crash navigating MRAID ad
final WebViewBase currentWebView = (webView != null) ? webView : mraidWebView;
if (currentWebView != null) {
currentWebView.getMRAIDInterface()
.getJsExecutor()
.executeGetExpandProperties(new FetchPropertiesHandler(expandPropertiesCallback));
}
else {
LogUtil.warning(TAG, "Error getting expand properties");
}
}
@Override
public void initTwoPartAndLoad(String url) {
LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
setLayoutParams(layoutParams);
//A null context can crash with an exception in webView creation through WebViewBanner. Catch it
mraidWebView = new WebViewBanner(context, this, this);
mraidWebView.setJSName("twopart");
String script = JSLibraryManager.getInstance(mraidWebView.getContext()).getMRAIDScript();
//inject mraid.js
mraidWebView.setMraidAdAssetsLoadListener(mraidWebView, script);
mraidWebView.loadUrl(url);
}
private JSONObject getAdLogData() {
JSONObject logData = new JSONObject();
HTMLCreative htmlCreative = getCreative();
if (htmlCreative != null) {
CreativeModel creativeModel = htmlCreative.getCreativeModel();
if (creativeModel != null) {
logData = creativeModel.getLogData();
}
}
return logData;
}
@Override
public void loadHTML(String html, int width, int height) {
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT
);
setLayoutParams(layoutParams);
this.width = width;
this.height = height;
//A null context can crash with an exception in webView creation through WebViewBanner. Catch it
webView = new WebViewBanner(context, html, width, height, this, this);
webView.setJSName("1part");
webView.initContainsIFrame(creative.getCreativeModel().getHtml());
webView.setTargetUrl(creative.getCreativeModel().getTargetUrl());
webView.adLogData = getAdLogData();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
webView.setWebViewRenderProcessClient(new WebViewRenderProcessClient() {
@Override
public void onRenderProcessUnresponsive(@NonNull WebView webView, @Nullable WebViewRenderProcess webViewRenderProcess) {
if (appEventLogger != null) {
appEventLogger.logAppEvent("Web Render Terminate", getAdLogData());
}
}
@Override
public void onRenderProcessResponsive(@NonNull WebView webView, @Nullable WebViewRenderProcess webViewRenderProcess) {}
});
}
webView.loadAd();
}
@Override
public void preloaded(WebViewBase adBaseView) {
if (adBaseView == null) {
//This should never happen.
LogUtil.error(TAG, "Failed to preload a banner ad. Webview is null.");
if (webViewDelegate != null) {
webViewDelegate.webViewFailedToLoad(new AdException(
AdException.INTERNAL_ERROR,
"Preloaded adview is null!"
));
}
return;
}
currentWebViewBase = adBaseView;
if (currentWebViewBase.MRAIDBridgeName.equals("twopart")) {
//SHould have expanded url here, as last param
interstitialManager.displayPrebidWebViewForMraid(mraidWebView, true);
} else {
if (adBaseView.getParent() == null) {
if (getChildCount() >= 1) {
LogUtil.debug(TAG, "Adding second view");
//safe removal from parent before adding
Views.removeFromParent(adBaseView);
addView(adBaseView, 1);
adBaseView.bringToFront();
swapWebViews();
}
else {
LogUtil.debug(TAG, "Adding first view");
//safe removal from parent before adding
Views.removeFromParent(adBaseView);
addView(adBaseView, 0);
renderAdView(adBaseView);
}
}
else {
LogUtil.debug(TAG, "Adding the only view");
adBaseView.bringToFront();
swapWebViews();
}
}
/*
* This postInvalidate fixes the cosmetic issue that KitKat created with the white banner
* fragment/remnant showing up at the bottom of the screen.
*/
if (context instanceof Activity) {
((Activity) context).getWindow().getDecorView().findViewById(android.R.id.content).postInvalidate();
((Activity) context).getWindow()
.getDecorView()
.findViewById(android.R.id.content)
.postInvalidateDelayed(100);
}
if (webViewDelegate != null) {
webViewDelegate.webViewReadyToDisplay();
}
}
protected void swapWebViews() {
if (getContext() != null) {
fadeOutAnimation = AnimationUtils.loadAnimation(getContext(), android.R.anim.fade_out);
}
final WebViewBase frontAdView = (WebViewBase) getChildAt(0);
WebViewBase backAdView = (WebViewBase) getChildAt(1);
if (frontAdView != null) {
frontAdView.startAnimation(fadeOutAnimation);
frontAdView.setVisibility(GONE);
}
if (backAdView != null) {
renderAdView(backAdView);
backAdView.bringToFront();
}
}
private void handleExpandPropertiesResult(String expandProperties) {
JSONObject jsonExpandProperties;
WebViewBase currentWebView = (webView != null) ? webView : mraidWebView;
final MraidVariableContainer mraidVariableContainer = currentWebView.getMRAIDInterface()
.getMraidVariableContainer();
mraidVariableContainer.setExpandProperties(expandProperties);
try {
jsonExpandProperties = new JSONObject(expandProperties);
definedWidthForExpand = jsonExpandProperties.optInt("width", 0);
definedHeightForExpand = jsonExpandProperties.optInt("height", 0);
if (interstitialManager.getInterstitialDisplayProperties() != null) {
interstitialManager.getInterstitialDisplayProperties().expandWidth = definedWidthForExpand;
interstitialManager.getInterstitialDisplayProperties().expandHeight = definedHeightForExpand;
}
}
catch (Exception e) {
LogUtil.error(TAG, "handleExpandPropertiesResult: Failed. Reason: " + Log.getStackTraceString(e));
}
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview/PrebidWebViewBase.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.webview;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.webkit.WebView;
import android.widget.FrameLayout;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.PrebidMobile;
import org.prebid.mobile.rendering.listeners.WebViewDelegate;
import org.prebid.mobile.rendering.models.HTMLCreative;
import org.prebid.mobile.rendering.sdk.ManagersResolver;
import org.prebid.mobile.rendering.sdk.deviceData.managers.DeviceInfoManager;
import org.prebid.mobile.rendering.utils.exposure.ViewExposure;
import org.prebid.mobile.rendering.utils.helpers.Utils;
import org.prebid.mobile.rendering.views.interstitial.InterstitialManager;
import org.prebid.mobile.rendering.views.webview.mraid.Views;
import java.lang.ref.WeakReference;
//Equivalent of adBase
public class PrebidWebViewBase extends FrameLayout implements PreloadManager.PreloadedListener, MraidEventsManager.MraidListener {
private final String TAG = PrebidWebViewBase.class.getSimpleName();
public static final int WEBVIEW_DESTROY_DELAY_MS = 1000;
protected Context context;
private final Handler handler;
protected WebViewBase oldWebViewBase;
protected WebViewDelegate webViewDelegate;
protected HTMLCreative creative;
protected WebViewBase webView;
protected WebViewBanner mraidWebView;
protected int width, height, definedWidthForExpand, definedHeightForExpand;
protected InterstitialManager interstitialManager;
private int screenVisibility;
protected WebViewBase currentWebViewBase;
protected Animation fadeInAnimation;
protected Animation fadeOutAnimation;
public static boolean isImproveWebview;
public PrebidWebViewBase(
Context context,
InterstitialManager interstitialManager
) {
//a null context to super(), a framelayout, could crash. So, catch this exception
super(context);
this.context = context;
this.interstitialManager = interstitialManager;
screenVisibility = getVisibility();
handler = new Handler(Looper.getMainLooper());
}
public void initTwoPartAndLoad(String url) {
//do it in banner child class
}
public void loadHTML(String html, int width, int height) {
//call child's
}
public void destroy() {
Views.removeFromParent(this);
removeAllViews();
WebView currentWebView = (webView != null) ? webView : mraidWebView;
// IMPORTANT: Delayed execution was implemented due to this issue: jira/browse/MOBILE-5380
// We need to give OMID time to finish method execution inside the webview
handler.removeCallbacksAndMessages(null);
if (!isImproveWebview) {
handler.postDelayed(new WebViewCleanupRunnable(currentWebView), WEBVIEW_DESTROY_DELAY_MS);
} else {
handler.postDelayed(() -> {
new WebViewCleanupRunnable(currentWebView).run();
webView = null;
}, WEBVIEW_DESTROY_DELAY_MS);
}
}
public void initMraidExpanded() {
runOnUiThread(() -> {
try {
readyForMraidExpanded();
}
catch (Exception e) {
LogUtil.error(TAG, "initMraidExpanded failed: " + Log.getStackTraceString(e));
}
});
}
private void readyForMraidExpanded() {
if (mraidWebView != null && mraidWebView.getMRAIDInterface() != null) {
mraidWebView.getMRAIDInterface().onReadyExpanded();
}
}
@Override
public void preloaded(WebViewBase adBaseView) {
//do it in child
}
public void handleOpen(String url) {
if (currentWebViewBase != null && currentWebViewBase.getMRAIDInterface() != null) {
currentWebViewBase.getMRAIDInterface().open(url);
}
}
@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
super.onWindowFocusChanged(hasWindowFocus);
int visibility = (!hasWindowFocus ? View.INVISIBLE : View.VISIBLE);
if (Utils.hasScreenVisibilityChanged(screenVisibility, visibility)) {
//visibility has changed. Send the changed value for mraid update for banners
screenVisibility = visibility;
if (currentWebViewBase != null && currentWebViewBase.getMRAIDInterface() != null) {
currentWebViewBase.getMRAIDInterface()
.handleScreenViewabilityChange(Utils.isScreenVisible(screenVisibility));
}
}
}
@Override
public void openExternalLink(String url) {
//No need to separate the apis for mraid & non-mraid as they all go to the same methods.
if (webViewDelegate != null) {
webViewDelegate.webViewShouldOpenExternalLink(url);
}
}
@Override
public void openMraidExternalLink(String url) {
if (webViewDelegate != null) {
webViewDelegate.webViewShouldOpenMRAIDLink(url);
}
}
@Override
public void onAdWebViewWindowFocusChanged(boolean hasFocus) {
if (creative != null) {
creative.changeVisibilityTrackerState(hasFocus);
}
}
public void onViewExposureChange(ViewExposure viewExposure) {
if (currentWebViewBase != null && currentWebViewBase.getMRAIDInterface() != null) {
currentWebViewBase.getMRAIDInterface().getJsExecutor().executeExposureChange(viewExposure);
}
}
public WebViewBase getOldWebView() {
return oldWebViewBase;
}
public void setOldWebView(WebViewBase oldWebView) {
oldWebViewBase = oldWebView;
}
public void setWebViewDelegate(WebViewDelegate delegate) {
webViewDelegate = delegate;
}
public HTMLCreative getCreative() {
return creative;
}
public void setCreative(HTMLCreative creative) {
this.creative = creative;
}
public WebViewBase getWebView() {
return webView;
}
public WebViewBanner getMraidWebView() {
return mraidWebView;
}
//gets expand properties & also a close view(irrespective of usecustomclose is false)
public void loadMraidExpandProperties() {
//do it in child classs
}
protected void renderAdView(WebViewBase webViewBase) {
if (webViewBase == null) {
LogUtil.warning(TAG, "WebviewBase is null");
return;
}
if (getContext() != null) {
fadeInAnimation = AnimationUtils.loadAnimation(getContext(), android.R.anim.fade_in);
}
if (!PrebidMobile.isViewabilityV3()) {
if (webViewBase.isMRAID() && webViewBase.getMRAIDInterface() != null) {
webViewBase.getMRAIDInterface().getJsExecutor().executeOnViewableChange(true);
}
}
webViewBase.startAnimation(fadeInAnimation);
webViewBase.setVisibility(View.VISIBLE);
displayAdViewPlacement(webViewBase);
}
public void executeOnViewableChange() {
if (currentWebViewBase != null) {
if (currentWebViewBase.isMRAID() && currentWebViewBase.getMRAIDInterface() != null) {
currentWebViewBase.getMRAIDInterface().getJsExecutor().executeOnViewableChange(true);
}
}
}
protected void displayAdViewPlacement(WebViewBase webViewBase) {
renderPlacement(webViewBase, width, height);
if (webViewBase.getAdWidth() != 0) {
getLayoutParams().width = webViewBase.getAdWidth();
}
if (webViewBase.getAdHeight() != 0) {
getLayoutParams().height = webViewBase.getAdHeight();
}
invalidate();
}
private void renderPlacement(WebViewBase webViewBase, int width, int height) {
if (context == null) {
LogUtil.warning(TAG, "Context is null");
return;
}
if (webViewBase == null) {
LogUtil.warning(TAG, "WebviewBase is null");
return;
}
int orientation = Configuration.ORIENTATION_UNDEFINED;
WindowManager windowManager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
int screenWidth = Utils.getScreenWidth(windowManager);
int screenHeight = Utils.getScreenHeight(windowManager);
int deviceWidth = Math.min(screenWidth, screenHeight);
int deviceHeight = Math.max(screenWidth, screenHeight);
DeviceInfoManager deviceManager = ManagersResolver.getInstance().getDeviceManager();
if (deviceManager != null) {
orientation = deviceManager.getDeviceOrientation();
}
float factor = getScaleFactor(webViewBase, orientation, deviceWidth, deviceHeight);
webViewBase.setAdWidth(Math.round((width * factor)));
webViewBase.setAdHeight(Math.round((height * factor)));
}
private float getScaleFactor(WebViewBase webViewBase, int orientation, int deviceWidth, int deviceHeight) {
float factor = 1.0f;
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
if (width < deviceHeight) {
factor = factor * deviceWidth / width;
} else {
factor = factor * deviceHeight / width;
}
}
else {
if (width < deviceWidth) {
factor = factor * deviceWidth / width;
} else {
factor = factor * deviceWidth / width;
}
}
if (factor > webViewBase.densityScalingFactor()) {
factor = (float) (1.0f * webViewBase.densityScalingFactor());
}
return factor;
}
protected void runOnUiThread(Runnable runnable) {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(runnable);
}
private static final class WebViewCleanupRunnable implements Runnable {
private static final String TAG = WebViewCleanupRunnable.class.getSimpleName();
private final WeakReference<WebView> weakWebView;
WebViewCleanupRunnable(WebView webViewBase) {
weakWebView = new WeakReference<>(webViewBase);
}
@Override
public void run() {
WebView webViewBase = weakWebView.get();
if (webViewBase == null) {
LogUtil.debug(TAG, "Unable to execute destroy on WebView. WebView is null.");
return;
}
if (isImproveWebview) {
webViewBase.clearCache(true);
webViewBase.clearHistory();
webViewBase.removeJavascriptInterface("jsBridge");
if (webViewBase.getParent() != null) {
((ViewGroup) webViewBase.getParent()).removeView(webViewBase);
}
webViewBase.setWebChromeClient(null);
}
//MOBILE-2950 ARKAI3 - Inline Video of the webview is not stopped on back key press
webViewBase.destroy();
}
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview/PrebidWebViewInterstitial.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.webview;
import android.content.Context;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.api.exceptions.AdException;
import org.prebid.mobile.rendering.views.interstitial.InterstitialManager;
public class PrebidWebViewInterstitial extends PrebidWebViewBase
implements PreloadManager.PreloadedListener, MraidEventsManager.MraidListener {
private final String TAG = PrebidWebViewInterstitial.class.getSimpleName();
public PrebidWebViewInterstitial(Context context, InterstitialManager interstitialManager) {
super(context, interstitialManager);
}
@Override
public void loadHTML(String html, int width, int height) {
LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
setLayoutParams(layoutParams);
this.width = width;
this.height = height;
//A null context can crash with an exception in webView creation through WebViewBanner. Catch it
webView = new WebViewInterstitial(context, html, width, height, this, this);
webView.setJSName("WebViewInterstitial");
webView.initContainsIFrame(creative.getCreativeModel().getHtml());
webView.setTargetUrl(creative.getCreativeModel().getTargetUrl());
webView.loadAd();
}
@Override
public void preloaded(WebViewBase adBaseView) {
if (adBaseView == null) {
//This should never happen.
LogUtil.error(TAG, "Failed to preload an interstitial. Webview is null.");
if (webViewDelegate != null) {
webViewDelegate.webViewFailedToLoad(new AdException(
AdException.INTERNAL_ERROR,
"Preloaded adview is null!"
));
}
return;
}
currentWebViewBase = adBaseView;
if (webViewDelegate != null) {
webViewDelegate.webViewReadyToDisplay();
}
}
} |
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview/PreloadManager.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.webview;
public class PreloadManager {
public interface PreloadedListener {
void preloaded(WebViewBase adBaseView);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview/WebViewBanner.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.webview;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.rendering.models.internal.MraidEvent;
import org.prebid.mobile.rendering.utils.helpers.HandlerQueueManager;
import org.prebid.mobile.rendering.views.webview.mraid.BannerJSInterface;
import org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface;
import org.prebid.mobile.rendering.views.webview.mraid.JsExecutor;
public class WebViewBanner extends WebViewBase {
private static final String TAG = WebViewBanner.class.getSimpleName();
private MraidEvent mraidEvent;
public WebViewBanner(Context context, String html, int width, int height, PreloadManager.PreloadedListener preloadedListener, MraidEventsManager.MraidListener mraidListener) {
super(context, html, width, height, preloadedListener, mraidListener);
}
//2nd webview for 2-part expand
public WebViewBanner(Context context, PreloadManager.PreloadedListener preloadedListener, MraidEventsManager.MraidListener mraidListener) {
super(context, preloadedListener, mraidListener);
init();
}
@Override
public void init() {
//imp for the mraid to work(2 part expand mainly)
initWebView();
setMRAIDInterface();
}
public MraidEvent getMraidEvent() {
return mraidEvent;
}
public void setMraidEvent(MraidEvent event) {
mraidEvent = event;
}
public void setMRAIDInterface() {
BaseJSInterface mraid = new BannerJSInterface(getContext(), this, new JsExecutor(this,
new Handler(Looper.getMainLooper()),
new HandlerQueueManager()));
addJavascriptInterface(mraid, "jsBridge");
LogUtil.debug(TAG, "JS bridge initialized");
setBaseJSInterface(mraid);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview/WebViewBase.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.webview;
import android.content.Context;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import org.json.JSONObject;
import org.prebid.mobile.PrebidMobile;
import org.prebid.mobile.rendering.interstitial.AdBaseDialog;
import org.prebid.mobile.rendering.models.CreativeModel;
import org.prebid.mobile.rendering.models.internal.MraidVariableContainer;
import org.prebid.mobile.rendering.sdk.JSLibraryManager;
import org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.prebid.mobile.rendering.views.webview.AdWebViewClient.AdAssetsLoadedListener;
public class WebViewBase extends AdWebView implements AdAssetsLoadedListener {
private static final String TAG = WebViewBase.class.getSimpleName();
private static final String REGEX_IFRAME = "(<iframe[^>]*)>";
protected MraidEventsManager.MraidListener mraidListener;
protected String MRAIDBridgeName;
private PreloadManager.PreloadedListener preloadedListener;
private BaseJSInterface mraidInterface;
private String adHTML;
private AdBaseDialog dialog;
private boolean containsIFrame;
private boolean isClicked = false;
protected boolean isMRAID;
private String targetUrl;
// for debugging page load issue
public JSONObject adLogData = new JSONObject();
public WebViewBase(
Context context,
String html,
int width,
int height,
PreloadManager.PreloadedListener preloadedListener,
MraidEventsManager.MraidListener mraidInterface
) {
super(context);
this.width = width;
this.height = height;
adHTML = html;
this.preloadedListener = preloadedListener;
mraidListener = mraidInterface;
initWebView();
}
public WebViewBase(Context context, PreloadManager.PreloadedListener preloadedListener, MraidEventsManager.MraidListener mraidHelper) {
super(context);
this.preloadedListener = preloadedListener;
mraidListener = mraidHelper;
}
@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
super.onWindowFocusChanged(hasWindowFocus);
mraidListener.onAdWebViewWindowFocusChanged(hasWindowFocus);
}
@Override
public void startLoadingAssets() {
mraidInterface.loading();
}
@Override
public void adAssetsLoaded() {
if (isMRAID) {
getMRAIDInterface().prepareAndSendReady();
}
if (preloadedListener != null) {
preloadedListener.preloaded(this);
}
}
@Override
public void notifyMraidScriptInjected() {
isMRAID = true;
}
@Override
public void destroy() {
super.destroy();
mraidInterface.destroy();
}
@Override
protected void onSizeChanged(int w, int h, int ow, int oh) {
super.onSizeChanged(w, h, ow, oh);
if (isMRAID()) {
getMRAIDInterface().updateScreenMetricsAsync(null);
}
}
public void loadAd() {
//inject MRAID here
initLoad();
setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
setIsClicked(true);
return (event.getAction() == MotionEvent.ACTION_MOVE);
}
});
/****
* Sometimes assets just don't load into the WebView, event though the
* onPageFinished is called. So replacing the following loadData call
* with loadDataWithBaseURL, although it doesn't seem to have an effect!
* http
* ://stackoverflow.com/questions/2969949/cant-loadAdConfiguration-image-in-webview-
* via-javascript
* ***/
loadDataWithBaseURL(PrebidMobile.SCHEME_HTTPS + "://" + domain + "/", adHTML, "text/html", "utf-8", null);
}
public void setJSName(String name) {
MRAIDBridgeName = name;
}
public String getJSName() {
return MRAIDBridgeName;
}
public MraidEventsManager.MraidListener getMraidListener() {
return mraidListener;
}
public void setDialog(AdBaseDialog dialog) {
this.dialog = dialog;
}
public AdBaseDialog getDialog() {
return dialog;
}
public boolean isClicked() {
return isClicked;
}
public void setIsClicked(boolean isClicked) {
this.isClicked = isClicked;
}
public PreloadManager.PreloadedListener getPreloadedListener() {
return preloadedListener;
}
/**
* Initializes {@link #containsIFrame}. Sets true if <iframe> tag was found in html
*
* @param html html without injected {@link R.raw#omsdk_v1} NOTE: Without injected {@link R.raw#omsdk_v1}
* because {@link R.raw#omsdk_v1} contains <iframe>
*/
public void initContainsIFrame(String html) {
Pattern iframePattern = Pattern.compile(REGEX_IFRAME, Pattern.CASE_INSENSITIVE);
Matcher matcher = iframePattern.matcher(html);
containsIFrame = matcher.find();
}
/**
* @return true if html in {@link #initContainsIFrame(String)} contained <iframe>
*/
public boolean containsIFrame() {
return containsIFrame;
}
public ViewGroup getParentContainer() {
ViewParent parent = getParent();
if (parent instanceof ViewGroup) {
return (ViewGroup) parent;
}
return null;
}
public void detachFromParent() {
ViewGroup parent = getParentContainer();
if (parent != null) {
parent.removeView(this);
}
}
public BaseJSInterface getMRAIDInterface() {
return mraidInterface;
}
public void setBaseJSInterface(BaseJSInterface mraid) {
mraidInterface = mraid;
}
public void setAdWidth(int width) {
this.width = width;
}
public int getAdWidth() {
return width;
}
public void setAdHeight(int height) {
this.height = height;
}
public int getAdHeight() {
return height;
}
public boolean isMRAID() {
return isMRAID;
}
public void setTargetUrl(String targetUrl) {
this.targetUrl = targetUrl;
}
public String getTargetUrl() {
return targetUrl;
}
public void initLoad() {
setVisibility(INVISIBLE);
if (MraidVariableContainer.getDisabledFlags() == null) {
MraidVariableContainer.setDisabledSupportFlags(0);
}
//IMPORTANT: sets the webviewclient to get callbacks on webview
final String mraidScript = JSLibraryManager.getInstance(getContext()).getMRAIDScript();
setMraidAdAssetsLoadListener(this,
mraidScript);
/*
* Keep this for development purposes...very handy!
*/
//adHTML = Utils.loadStringFromFile(getResources(), R.raw.testmraidfullad);
// adHTML = Utils.loadStringFromFile(getResources(), R.raw.html);
adHTML = createAdHTML(adHTML);
}
public void sendClickCallBack(String url) {
post(() -> mraidListener.openMraidExternalLink(url));
}
public boolean canHandleClick() {
return getMRAIDInterface() != null && getPreloadedListener() != null;
}
protected void initWebView() {
super.initializeWebView();
super.initializeWebSettings();
}
private String createAdHTML(String originalHtml) {
String meta = buildViewportMetaTag();
String centerAdStyle = "<style type='text/css'>html,body {margin: 0;padding: 0;width: 100%;height: 100%;}html {display: table;}body {display: table-cell;vertical-align: middle;text-align: center;}</style>";
originalHtml = "<html><head>" + meta
+ "<body>"
+ centerAdStyle
+ originalHtml
+ "</body></html>";
return originalHtml;
}
private String buildViewportMetaTag() {
String meta;
// Android 2.2: viewport meta tag does not seem to be supported at all.
//
// Android 2.3.x/3.x: By setting user-scalable=no you disable the
// scaling of the viewport meta tag yourself
// as well. This is probably why your width option is having no effect.
// To allow the browser to scale your
// content, you need to set user-scalable=yes, then to disable zoom you
// can set the min and max scale to the
// same value so it cannot shrink or grow. Toy with the initial scale
// until your site fits snugly.
//
// Android 4.x: Same rule apply as 2.3.x except the min and max scales
// are not honored anymore and if you use
// user-scalable=yes the user can always zoom, setting it to 'no' means
// your own scale is ignored, this is the
// issue I'm facing now that drew me to this question... You cannot seem
// to disable zoom and scale at the same
// time in 4.x.
//
// Note, when you work with this area of code, it goes hand in hand with code
// in AdWebView in the initializeWebSettings method, in particular the webSettings.
// Also, important, if one changes the AndroidManifest.xml for targetSDKVersion from <=17 to >=19
// The new OS 19 (KitKat) will have a drastic effect on the WebView. Which is why we have
// forked the code.
//
String scale = getInitialScaleValue();
String metaTag;
if (scale != null && !scale.isEmpty()) {
metaTag = "<meta name='viewport' content='width=device-width, initial-scale=" + scale + ", minimum-scale=0.01' />";
} else {
metaTag = "<meta name='viewport' content='width=device-width' />";
}
return metaTag;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview/WebViewInterstitial.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.webview;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.rendering.utils.helpers.HandlerQueueManager;
import org.prebid.mobile.rendering.views.webview.PreloadManager.PreloadedListener;
import org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface;
import org.prebid.mobile.rendering.views.webview.mraid.InterstitialJSInterface;
import org.prebid.mobile.rendering.views.webview.mraid.JsExecutor;
public class WebViewInterstitial extends WebViewBase {
private static final String TAG = WebViewInterstitial.class.getSimpleName();
public WebViewInterstitial(Context context, String html, int width, int height, PreloadedListener preloadedListener, MraidEventsManager.MraidListener mraidListener) {
super(context, html, width, height, preloadedListener, mraidListener);
}
public void setJSName(String name) {
MRAIDBridgeName = name;
}
@Override
public void init() {
initWebView();
setMRAIDInterface();
}
public void setMRAIDInterface() {
BaseJSInterface mraid = new InterstitialJSInterface(getContext(), this, new JsExecutor(this,
new Handler(Looper.getMainLooper()),
new HandlerQueueManager()));
addJavascriptInterface(mraid, "jsBridge");
LogUtil.debug(TAG, "JS bridge initialized");
setBaseJSInterface(mraid);
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview/mraid/BannerJSInterface.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.webview.mraid;
import android.content.Context;
import android.webkit.JavascriptInterface;
import org.prebid.mobile.rendering.views.webview.WebViewBase;
public class BannerJSInterface extends BaseJSInterface {
/**
* Instantiate the interface and set the context
*/
public BannerJSInterface(Context context, WebViewBase adBaseView, JsExecutor jsExecutor) {
super(context, adBaseView, jsExecutor);
}
@Override
@JavascriptInterface
public String getPlacementType() {
return "inline";
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview/mraid/BaseJSInterface.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.webview.mraid;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.*;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.webkit.JavascriptInterface;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.rendering.models.HTMLCreative;
import org.prebid.mobile.rendering.models.internal.MraidEvent;
import org.prebid.mobile.rendering.models.internal.MraidVariableContainer;
import org.prebid.mobile.rendering.mraid.methods.MraidEventHandlerNotifierRunnable;
import org.prebid.mobile.rendering.mraid.methods.MraidScreenMetrics;
import org.prebid.mobile.rendering.mraid.methods.network.GetOriginalUrlTask;
import org.prebid.mobile.rendering.mraid.methods.network.RedirectUrlListener;
import org.prebid.mobile.rendering.networking.BaseNetworkTask;
import org.prebid.mobile.rendering.networking.parameters.GeoLocationParameterBuilder;
import org.prebid.mobile.rendering.sdk.ManagersResolver;
import org.prebid.mobile.rendering.sdk.deviceData.managers.DeviceInfoManager;
import org.prebid.mobile.rendering.sdk.deviceData.managers.LocationInfoManager;
import org.prebid.mobile.rendering.utils.broadcast.MraidOrientationBroadcastReceiver;
import org.prebid.mobile.rendering.utils.device.DeviceVolumeObserver;
import org.prebid.mobile.rendering.utils.helpers.AppInfoManager;
import org.prebid.mobile.rendering.utils.helpers.HandlerQueueManager;
import org.prebid.mobile.rendering.utils.helpers.MraidUtils;
import org.prebid.mobile.rendering.utils.helpers.Utils;
import org.prebid.mobile.rendering.views.webview.PrebidWebViewBase;
import org.prebid.mobile.rendering.views.webview.WebViewBase;
import java.lang.ref.WeakReference;
import java.util.concurrent.FutureTask;
import java.util.concurrent.RunnableFuture;
@SuppressLint("NewApi")
public class BaseJSInterface implements JSInterface {
private static final String TAG = BaseJSInterface.class.getSimpleName();
@NonNull private final WeakReference<Activity> weakActivity;
protected Context context;
protected WebViewBase adBaseView;
private final JsExecutor jsExecutor;
private final DeviceVolumeObserver deviceVolumeObserver;
private final MraidEvent mraidEvent = new MraidEvent();
private final MraidVariableContainer mraidVariableContainer = new MraidVariableContainer();
// An ad container, which contains the ad web view in default state, but is empty when expanded.
protected PrebidWebViewBase defaultAdContainer;
@NonNull @VisibleForTesting final MraidScreenMetrics screenMetrics;
@NonNull final ScreenMetricsWaiter screenMetricsWaiter;
private AsyncTask redirectedUrlAsyncTask;
private LayoutParams defaultLayoutParams;
private MraidOrientationBroadcastReceiver orientationBroadcastReceiver = new MraidOrientationBroadcastReceiver(this);
public BaseJSInterface(
Context context,
final WebViewBase adBaseView,
JsExecutor jsExecutor
) {
this.context = context;
this.adBaseView = adBaseView;
this.jsExecutor = jsExecutor;
this.jsExecutor.setMraidVariableContainer(mraidVariableContainer);
if (context instanceof Activity) {
weakActivity = new WeakReference<>((Activity) context);
} else {
weakActivity = new WeakReference<>(null);
}
//need this for all metric updates - DONOT do this here cos metric update happens in a thread & this js class may not
//have been initiated by then.
defaultAdContainer = (PrebidWebViewBase) adBaseView.getPreloadedListener();
screenMetrics = new MraidScreenMetrics(this.context, this.context.getResources().getDisplayMetrics().density);
screenMetricsWaiter = new ScreenMetricsWaiter();
deviceVolumeObserver = new DeviceVolumeObserver(this.context.getApplicationContext(),
new Handler(Looper.getMainLooper()),
this.jsExecutor::executeAudioVolumeChange
);
}
@Override
@JavascriptInterface
public String getMaxSize() {
JSONObject maxSize = new JSONObject();
try {
final Rect currentMaxSizeRect = screenMetrics.getCurrentMaxSizeRect();
if (currentMaxSizeRect != null) {
maxSize.put(JSON_WIDTH, currentMaxSizeRect.width());
maxSize.put(JSON_HEIGHT, currentMaxSizeRect.height());
return maxSize.toString();
}
}
catch (Exception e) {
LogUtil.error(TAG, "Failed getMaxSize() for MRAID: " + Log.getStackTraceString(e));
}
return "{}";
}
@Override
@JavascriptInterface
public String getScreenSize() {
JSONObject position = new JSONObject();
try {
DeviceInfoManager deviceManager = ManagersResolver.getInstance().getDeviceManager();
position.put(JSON_WIDTH, (int) (deviceManager.getScreenWidth() / Utils.DENSITY));
position.put(JSON_HEIGHT, (int) (deviceManager.getScreenHeight() / Utils.DENSITY));
return position.toString();
}
catch (Exception e) {
LogUtil.error(TAG, "Failed getScreenSize() for MRAID: " + Log.getStackTraceString(e));
}
return "{}";
}
@Override
@JavascriptInterface
public String getDefaultPosition() {
JSONObject position = new JSONObject();
try {
Rect rect = screenMetrics.getDefaultPosition();
position.put(JSON_X, (int) (rect.left / Utils.DENSITY));
position.put(JSON_Y, (int) (rect.top / Utils.DENSITY));
position.put(JSON_WIDTH, (int) (rect.right / Utils.DENSITY - rect.left / Utils.DENSITY));
position.put(JSON_HEIGHT, (int) (rect.bottom / Utils.DENSITY - rect.top / Utils.DENSITY));
return position.toString();
}
catch (Exception e) {
LogUtil.error(TAG, "Failed to get defaultPosition for MRAID: " + Log.getStackTraceString(e));
}
return "{}";
}
@Override
@JavascriptInterface
public String getCurrentPosition() {
JSONObject position = new JSONObject();
Rect rect = new Rect();
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable mainThreadRunnable = () -> adBaseView.getGlobalVisibleRect(rect);
RunnableFuture<Void> task = new FutureTask<>(mainThreadRunnable, null);
try {
mainHandler.post(task);
task.get();
position.put(JSON_X, (int) (rect.left / Utils.DENSITY));
position.put(JSON_Y, (int) (rect.top / Utils.DENSITY));
position.put(JSON_WIDTH, (int) (rect.right / Utils.DENSITY - rect.left / Utils.DENSITY));
position.put(JSON_HEIGHT, (int) (rect.bottom / Utils.DENSITY - rect.top / Utils.DENSITY));
return position.toString();
}
catch (Exception e) {
LogUtil.error(TAG, "Failed to get currentPosition for MRAID: " + Log.getStackTraceString(e));
}
return "{}";
}
@Override
@JavascriptInterface
public void onOrientationPropertiesChanged(String properties) {
mraidVariableContainer.setOrientationProperties(properties);
mraidEvent.mraidAction = ACTION_ORIENTATION_CHANGE;
mraidEvent.mraidActionHelper = properties;
notifyMraidEventHandler();
}
@Override
@JavascriptInterface
public String getPlacementType() {
// This is overridden in the sub class
return null;
}
@Override
@JavascriptInterface
public void close() {
mraidEvent.mraidAction = ACTION_CLOSE;
notifyMraidEventHandler();
}
@Override
@JavascriptInterface
public void resize() {
// passing this off to the MRAIDResize facade
// trying to thin out this to make this
// refactorable for the future
mraidEvent.mraidAction = ACTION_RESIZE;
if (adBaseView.isMRAID() && orientationBroadcastReceiver != null && orientationBroadcastReceiver.isOrientationChanged()) {
updateScreenMetricsAsync(this::notifyMraidEventHandler);
} else {
notifyMraidEventHandler();
}
if (adBaseView.isMRAID() && orientationBroadcastReceiver != null) {
orientationBroadcastReceiver.setOrientationChanged(false);
}
}
@Override
@JavascriptInterface
public void expand() {
LogUtil.debug(TAG, "Expand with no url");
expand(null);
}
@Override
@JavascriptInterface
public void expand(final String url) {
LogUtil.debug(TAG, "Expand with url: " + url);
mraidEvent.mraidAction = ACTION_EXPAND;
mraidEvent.mraidActionHelper = url;
//call creative's api that handles all mraid events
notifyMraidEventHandler();
}
@Override
@JavascriptInterface
public void open(String url) {
adBaseView.sendClickCallBack(url);
mraidEvent.mraidAction = ACTION_OPEN;
mraidEvent.mraidActionHelper = url;
notifyMraidEventHandler();
}
@Override
@JavascriptInterface
public void javaScriptCallback(String handlerHash, String method, String value) {
HandlerQueueManager handlerQueueManager = jsExecutor.getHandlerQueueManager();
Handler handler = handlerQueueManager.findHandler(handlerHash);
if (handler != null) {
Message responseMessage = new Message();
Bundle bundle = new Bundle();
bundle.putString(JSON_METHOD, method);
bundle.putString(JSON_VALUE, value);
responseMessage.setData(bundle);
handler.dispatchMessage(responseMessage);
handlerQueueManager.removeHandler(handlerHash);
}
}
@Override
@JavascriptInterface
public void createCalendarEvent(String parameters) {
adBaseView.sendClickCallBack(parameters);
mraidEvent.mraidAction = ACTION_CREATE_CALENDAR_EVENT;
mraidEvent.mraidActionHelper = parameters;
notifyMraidEventHandler();
}
@Override
@JavascriptInterface
public void storePicture(String url) {
adBaseView.sendClickCallBack(url);
mraidEvent.mraidAction = ACTION_STORE_PICTURE;
mraidEvent.mraidActionHelper = url;
notifyMraidEventHandler();
}
@Override
@JavascriptInterface
public boolean supports(String feature) {
return MraidUtils.isFeatureSupported(feature);
}
@Override
@JavascriptInterface
public void playVideo(String url) {
mraidEvent.mraidAction = ACTION_PLAY_VIDEO;
mraidEvent.mraidActionHelper = url;
notifyMraidEventHandler();
}
@Override
@Deprecated
@JavascriptInterface
public void shouldUseCustomClose(String useCustomClose) {
jsExecutor.executeNativeCallComplete();
LogUtil.debug(TAG, "Deprecated: useCustomClose was deprecated in MRAID 3");
}
@Override
@JavascriptInterface
public String getLocation() {
LocationInfoManager locationInfoManager = ManagersResolver.getInstance().getLocationManager();
JSONObject location = new JSONObject();
if (locationInfoManager.isLocationAvailable()) {
try {
location.put(LOCATION_LAT, locationInfoManager.getLatitude());
location.put(LOCATION_LON, locationInfoManager.getLongitude());
// type - static value "1" - GPS provider
location.put(LOCATION_TYPE, GeoLocationParameterBuilder.LOCATION_SOURCE_GPS);
location.put(LOCATION_ACCURACY, locationInfoManager.getAccuracy());
location.put(LOCATION_LASTFIX, locationInfoManager.getElapsedSeconds());
return location.toString();
}
catch (JSONException e) {
LogUtil.error(TAG, "MRAID: Error providing location: " + Log.getStackTraceString(e));
}
}
return LOCATION_ERROR;
}
@Override
@JavascriptInterface
public String getCurrentAppOrientation() {
DeviceInfoManager deviceManager = ManagersResolver.getInstance().getDeviceManager();
int deviceOrientation = deviceManager.getDeviceOrientation();
String orientation = deviceOrientation == Configuration.ORIENTATION_PORTRAIT
? "portrait"
: "landscape";
JSONObject deviceOrientationJson = new JSONObject();
try {
deviceOrientationJson.put(DEVICE_ORIENTATION, orientation);
deviceOrientationJson.put(DEVICE_ORIENTATION_LOCKED, deviceManager.isActivityOrientationLocked(context));
return deviceOrientationJson.toString();
}
catch (JSONException e) {
LogUtil.error(TAG, "MRAID: Error providing deviceOrientationJson: " + Log.getStackTraceString(e));
}
return "{}";
}
@Override
@JavascriptInterface
public void unload() {
LogUtil.debug(TAG, "unload called");
mraidEvent.mraidAction = ACTION_UNLOAD;
notifyMraidEventHandler();
}
public void onStateChange(String state) {
if (state == null) {
LogUtil.debug(TAG, "onStateChange failure. State is null");
return;
}
orientationBroadcastReceiver.setState(state);
updateScreenMetricsAsync(() -> jsExecutor.executeStateChange(state));
}
public void handleScreenViewabilityChange(boolean isViewable) {
jsExecutor.executeOnViewableChange(isViewable);
if (isViewable) {
deviceVolumeObserver.start();
}
else {
deviceVolumeObserver.stop();
jsExecutor.executeAudioVolumeChange(null);
}
}
public MraidVariableContainer getMraidVariableContainer() {
return mraidVariableContainer;
}
public MraidScreenMetrics getScreenMetrics() {
return screenMetrics;
}
public PrebidWebViewBase getDefaultAdContainer() {
return defaultAdContainer;
}
public void onError(String message, String action) {
jsExecutor.executeOnError(message, action);
}
public void followToOriginalUrl(String url, final RedirectUrlListener listener) {
GetOriginalUrlTask.GetUrlParams params = new BaseNetworkTask.GetUrlParams();
params.url = url;
params.name = BaseNetworkTask.REDIRECT_TASK;
params.requestType = "GET";
params.userAgent = AppInfoManager.getUserAgent();
GetOriginalUrlTask redirectTask = new GetOriginalUrlTask(new OriginalUrlResponseCallBack(listener));
redirectedUrlAsyncTask = redirectTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
}
public void setDefaultLayoutParams(LayoutParams originalParentLayoutParams) {
defaultLayoutParams = originalParentLayoutParams;
}
public LayoutParams getDefaultLayoutParams() {
return defaultLayoutParams;
}
public ViewGroup getRootView() {
final View bestRootView = Views.getTopmostView(weakActivity.get(), defaultAdContainer);
return bestRootView instanceof ViewGroup ? (ViewGroup) bestRootView : defaultAdContainer;
}
public JsExecutor getJsExecutor() {
return jsExecutor;
}
public void loading() {
jsExecutor.loading();
}
public void onReadyExpanded() {
if (adBaseView != null) {
Rect defaultPosition = new Rect();
adBaseView.getGlobalVisibleRect(defaultPosition);
screenMetrics.setDefaultPosition(defaultPosition);
supports(MraidVariableContainer.getDisabledFlags());
updateScreenMetricsAsync(() -> {
LogUtil.debug(TAG, "MRAID OnReadyExpanded Fired");
jsExecutor.executeStateChange(STATE_EXPANDED);
jsExecutor.executeOnReadyExpanded();
});
}
}
public void prepareAndSendReady() {
/*
* Page 28 of the MRAID 2.0 spec says "Note that when getting the expand
* properties before setting them, the values for width and height will
* reflect the actual values of the screen. This will allow ad designers
* who want to use application or device values to adjust as necessary."
* This means we should set the expandProperties with the screen width
* and height immediately upon prepareAndSendReady.
*/
if (adBaseView != null && screenMetrics.getDefaultPosition() == null) {
Rect defaultPosition = new Rect();
adBaseView.getGlobalVisibleRect(defaultPosition);
screenMetrics.setDefaultPosition(defaultPosition);
registerReceiver();
jsExecutor.executeDisabledFlags(MraidVariableContainer.getDisabledFlags());
jsExecutor.executeStateChange(STATE_DEFAULT);
jsExecutor.executeOnReady();
}
}
/**
* Updates screen metrics, calling the successRunnable once they are available. The
* successRunnable will always be called asynchronously, ie on the next main thread loop.
*/
public void updateScreenMetricsAsync(
@Nullable
final Runnable successRunnable) {
if (adBaseView == null) {
return;
}
defaultAdContainer = (PrebidWebViewBase) adBaseView.getPreloadedListener();
// Determine which web view should be used for the current ad position
LogUtil.debug(TAG, "updateMetrics() Width: " + adBaseView.getWidth() + " Height: " + adBaseView.getHeight());
// Wait for the next draw pass on the default ad container and current web view
screenMetricsWaiter.queueMetricsRequest(() -> {
if (context != null) {
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
screenMetrics.setScreenSize(displayMetrics.widthPixels, displayMetrics.heightPixels);
}
int[] location = new int[2];
View rootView = getRootView();
if (rootView != null) {
rootView.getLocationOnScreen(location);
screenMetrics.setRootViewPosition(location[0], location[1], rootView.getWidth(), rootView.getHeight());
}
adBaseView.getLocationOnScreen(location);
screenMetrics.setCurrentAdPosition(location[0], location[1], adBaseView.getWidth(), adBaseView.getHeight());
defaultAdContainer.getLocationOnScreen(location);
screenMetrics.setDefaultAdPosition(location[0],
location[1],
defaultAdContainer.getWidth(),
defaultAdContainer.getHeight()
);
notifyScreenMetricsChanged();
if (successRunnable != null) {
successRunnable.run();
}
screenMetricsWaiter.finishAndStartNextRequest();
}, successRunnable != null, defaultAdContainer, adBaseView);
}
public void destroy() {
screenMetricsWaiter.cancelPendingRequests();
orientationBroadcastReceiver.unregister();
deviceVolumeObserver.stop();
if (redirectedUrlAsyncTask != null) {
redirectedUrlAsyncTask.cancel(true);
}
// Remove all ad containers from view hierarchy
Views.removeFromParent(defaultAdContainer);
context = null;
}
protected void notifyScreenMetricsChanged() {
final Rect rootViewRectDips = screenMetrics.getRootViewRectDips();
screenMetrics.setCurrentMaxSizeRect(rootViewRectDips);
jsExecutor.executeSetScreenSize(screenMetrics.getScreenRectDips());
jsExecutor.executeSetMaxSize(rootViewRectDips);
jsExecutor.executeSetCurrentPosition(screenMetrics.getCurrentAdRectDips());
jsExecutor.executeSetDefaultPosition(screenMetrics.getDefaultAdRectDips());
jsExecutor.executeOnSizeChange(screenMetrics.getCurrentAdRect());
}
private void notifyMraidEventHandler() {
orientationBroadcastReceiver.setMraidAction(mraidEvent.mraidAction);
HTMLCreative htmlCreative = ((PrebidWebViewBase) adBaseView.getPreloadedListener()).getCreative();
adBaseView.post(new MraidEventHandlerNotifierRunnable(htmlCreative, adBaseView, mraidEvent, jsExecutor));
}
private void registerReceiver() {
if (adBaseView.isMRAID()) {
orientationBroadcastReceiver.register(context);
}
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview/mraid/InterstitialJSInterface.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.webview.mraid;
import android.content.Context;
import android.webkit.JavascriptInterface;
import org.prebid.mobile.rendering.views.webview.WebViewBase;
public class InterstitialJSInterface extends BaseJSInterface {
private static final String TAG = InterstitialJSInterface.class.getSimpleName();
/**
* Instantiate the interface and set the context
*/
public InterstitialJSInterface(Context context, WebViewBase adBaseView, JsExecutor jsExecutor) {
super(context, adBaseView, jsExecutor);
}
@Override
@JavascriptInterface
public String getPlacementType() {
return "interstitial";
}
@Override
@JavascriptInterface
public void expand() {
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview/mraid/JSInterface.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.webview.mraid;
import android.webkit.JavascriptInterface;
public interface JSInterface {
String ACTION_GET_MAX_SIZE = "getMaxSize";
String ACTION_GET_SCREEN_SIZE = "getScreenSize";
String ACTION_GET_DEFAULT_POSITION = "getDefaultPosition";
String ACTION_GET_CURRENT_POSITION = "getCurrentPosition";
String ACTION_GET_PLACEMENT_TYPE = "getPlacementType";
String ACTION_CLOSE = "close";
String ACTION_RESIZE = "resize";
String ACTION_EXPAND = "expand";
String ACTION_ORIENTATION_CHANGE= "orientationchange";
String ACTION_OPEN = "open";
String ACTION_CREATE_CALENDAR_EVENT = "createCalendarEvent";
String ACTION_STORE_PICTURE = "storePicture";
String ACTION_PLAY_VIDEO = "playVideo";
String ACTION_UNLOAD = "unload";
String STATE_LOADING = "loading";
String STATE_DEFAULT = "default";
String STATE_EXPANDED = "expanded";
String STATE_RESIZED = "resized";
String STATE_HIDDEN = "hidden";
String JSON_METHOD = "method";
String JSON_VALUE = "value";
String JSON_WIDTH = "width";
String JSON_HEIGHT = "height";
String JSON_IS_MODAL = "isModal";
String JSON_X = "x";
String JSON_Y = "y";
String LOCATION_ERROR = "-1";
String LOCATION_LAT = "lat";
String LOCATION_LON = "lon";
String LOCATION_ACCURACY = "accuracy";
String LOCATION_TYPE = "type";
String LOCATION_LASTFIX = "lastfix";
String DEVICE_ORIENTATION = "orientation";
String DEVICE_ORIENTATION_LOCKED = "locked";
@JavascriptInterface
String getMaxSize();
@JavascriptInterface
String getScreenSize();
@JavascriptInterface
String getDefaultPosition();
@JavascriptInterface
String getCurrentPosition();
@JavascriptInterface
void onOrientationPropertiesChanged(String properties);
@JavascriptInterface
String getPlacementType();
@JavascriptInterface
void close();
@JavascriptInterface
void resize();
@JavascriptInterface
void expand();
@JavascriptInterface
void expand(String url);
@JavascriptInterface
void open(String url);
@JavascriptInterface
void javaScriptCallback(String handlerHash, String method, String value);
@JavascriptInterface
void createCalendarEvent(String parameters);
@JavascriptInterface
void storePicture(String url);
@JavascriptInterface
boolean supports(String feature);
@JavascriptInterface
void playVideo(String url);
@Deprecated
@JavascriptInterface
void shouldUseCustomClose(String useCustomClose);
@JavascriptInterface
String getLocation();
@JavascriptInterface
String getCurrentAppOrientation();
@JavascriptInterface
void unload();
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview/mraid/JsExecutor.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.webview.mraid;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.webkit.WebView;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.rendering.models.internal.MraidVariableContainer;
import org.prebid.mobile.rendering.utils.exposure.ViewExposure;
import org.prebid.mobile.rendering.utils.helpers.HandlerQueueManager;
import org.prebid.mobile.rendering.views.webview.WebViewBase;
import java.lang.ref.WeakReference;
import java.util.Locale;
public class JsExecutor {
private static final String TAG = JsExecutor.class.getSimpleName();
private final HandlerQueueManager handlerQueueManager;
private final WebView webView;
private final Handler scriptExecutionHandler;
private MraidVariableContainer mraidVariableContainer;
public JsExecutor(
WebView webView,
Handler scriptExecutionHandler,
HandlerQueueManager handlerQueueManager
) {
this.webView = webView;
this.handlerQueueManager = handlerQueueManager;
this.scriptExecutionHandler = scriptExecutionHandler;
}
public void setMraidVariableContainer(@NonNull MraidVariableContainer mraidVariableContainer) {
this.mraidVariableContainer = mraidVariableContainer;
}
public HandlerQueueManager getHandlerQueueManager() {
return handlerQueueManager;
}
public void executeGetResizeProperties(Handler handler) {
evaluateJavaScriptMethodWithResult("getResizeProperties", handler);
}
public void executeGetExpandProperties(Handler handler) {
evaluateJavaScriptMethodWithResult("getExpandProperties", handler);
}
public void executeSetScreenSize(Rect screenSize) {
evaluateJavaScript(String.format(Locale.US, "mraid.setScreenSize(%d, %d);",
screenSize.width(), screenSize.height()));
}
public void executeSetMaxSize(Rect maxSize) {
evaluateJavaScript(String.format(Locale.US, "mraid.setMaxSize(%d, %d);",
maxSize.width(), maxSize.height()));
}
public void executeSetCurrentPosition(Rect currentPosition) {
evaluateJavaScript(String.format(Locale.US, "mraid.setCurrentPosition(%d, %d, %d, %d);",
currentPosition.left, currentPosition.top,
currentPosition.width(), currentPosition.height()));
}
public void executeSetDefaultPosition(Rect defaultPosition) {
evaluateJavaScript(String.format(Locale.US, "mraid.setDefaultPosition(%d, %d, %d, %d);",
defaultPosition.left, defaultPosition.top,
defaultPosition.width(), defaultPosition.height()));
}
public void executeOnSizeChange(Rect rect) {
evaluateJavaScript(String.format(Locale.US, "mraid.onSizeChange(%d, %d);",
rect.width(), rect.height()));
}
public void executeOnError(String message, String action) {
evaluateJavaScript(String.format("mraid.onError('%1$s', '%2$s');", message, action));
}
public void executeDisabledFlags(String disabledFlags) {
evaluateMraidScript(disabledFlags);
}
public void executeOnReadyExpanded() {
mraidVariableContainer.setCurrentState(JSInterface.STATE_EXPANDED);
evaluateMraidScript("mraid.onReadyExpanded();");
}
public void executeOnReady() {
mraidVariableContainer.setCurrentState(JSInterface.STATE_DEFAULT);
evaluateMraidScript("mraid.onReady();");
}
public void executeAudioVolumeChange(Float volume) {
evaluateMraidScript("mraid.onAudioVolumeChange(" + volume + ");");
}
public void executeStateChange(String state) {
if (!TextUtils.equals(state, mraidVariableContainer.getCurrentState())) {
mraidVariableContainer.setCurrentState(state);
evaluateMraidScript(String.format("mraid.onStateChange('%1$s');", state));
}
}
/**
* Deprecated since SDK v4.12.0 (since MRAID 3 implementation)
*/
@Deprecated
public void executeOnViewableChange(boolean isViewable) {
final Boolean currentViewable = mraidVariableContainer.getCurrentViewable();
if (currentViewable == null || currentViewable != isViewable) {
mraidVariableContainer.setCurrentViewable(isViewable);
evaluateJavaScript(String.format("mraid.onViewableChange(%1$b);", isViewable));
}
}
public void executeExposureChange(ViewExposure viewExposure) {
String exposureChangeString = viewExposure != null ? viewExposure.toString() : null;
if (!TextUtils.equals(exposureChangeString, mraidVariableContainer.getCurrentExposure())) {
evaluateMraidScript(String.format("mraid.onExposureChange('%1$s');", exposureChangeString));
mraidVariableContainer.setCurrentExposure(exposureChangeString);
}
}
public void executeNativeCallComplete() {
evaluateMraidScript("mraid.nativeCallComplete();");
}
public void loading() {
mraidVariableContainer.setCurrentState(JSInterface.STATE_LOADING);
}
@VisibleForTesting
String getCurrentState() {
return mraidVariableContainer.getCurrentState();
}
@VisibleForTesting
void evaluateJavaScript(final String script) {
if (webView == null) {
LogUtil.debug(TAG, "evaluateJavaScript failure. webView is null");
return;
}
LogUtil.debug(TAG, "evaluateJavaScript: " + script);
try {
String scriptToEvaluate = "javascript: if (window.mraid && (window.mraid.getState() != 'loading' ) && ( window.mraid.getState() != 'hidden') ) { " + script + " }";
scriptExecutionHandler.post(new EvaluateScriptRunnable(webView, scriptToEvaluate));
} catch (Exception e) {
LogUtil.error(TAG, "evaluateJavaScript failed for script " + script + Log.getStackTraceString(e));
}
}
@VisibleForTesting
void evaluateJavaScriptMethodWithResult(String method, Handler handler) {
if (webView instanceof WebViewBase && ((WebViewBase) webView).isMRAID()) {
String handlerHash = handlerQueueManager.queueHandler(handler);
if (handlerHash != null) {
evaluateJavaScript("jsBridge.javaScriptCallback('" + handlerHash + "', '" + method + "', (function() { var retVal = mraid." + method + "(); if (typeof retVal === 'object') { retVal = JSON.stringify(retVal); } return retVal; })())");
}
} else if (handler != null) {
Message responseMessage = new Message();
Bundle bundle = new Bundle();
bundle.putString(JSInterface.JSON_METHOD, method);
bundle.putString(JSInterface.JSON_VALUE, "");
responseMessage.setData(bundle);
handler.dispatchMessage(responseMessage);
}
}
@VisibleForTesting
void evaluateMraidScript(final String script) {
if (webView == null) {
LogUtil.debug(TAG, "evaluateMraidScript failure. webView is null");
return;
}
try {
String scriptToEvaluate = "javascript: if (window.mraid ) { " + script + " }";
scriptExecutionHandler.post(new EvaluateScriptRunnable(webView, scriptToEvaluate));
} catch (Exception e) {
LogUtil.error(TAG, "evaluateMraidScript failed: " + Log.getStackTraceString(e));
}
}
@VisibleForTesting
static class EvaluateScriptRunnable implements Runnable {
private static final String TAG = EvaluateScriptRunnable.class.getSimpleName();
private final WeakReference<WebView> weakAdView;
private final String script;
EvaluateScriptRunnable(
WebView webViewBase,
String script
) {
weakAdView = new WeakReference<>(webViewBase);
this.script = script;
}
@Override
public void run() {
WebView webView = weakAdView.get();
if (webView == null) {
LogUtil.error(TAG, "Failed to evaluate script. WebView is null");
return;
}
webView.loadUrl(script);
}
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview/mraid/MraidWebViewClient.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.webview.mraid;
import android.net.Uri;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
import androidx.annotation.VisibleForTesting;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.rendering.mraid.MraidEnv;
import org.prebid.mobile.rendering.utils.helpers.Utils;
import org.prebid.mobile.rendering.views.webview.AdWebViewClient;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Locale;
/**
* Handles injecting the MRAID javascript to the 2nd webview, when encountering mraid.js urls
*/
public class MraidWebViewClient extends AdWebViewClient {
private static String TAG = MraidWebViewClient.class.getSimpleName();
private static final String MRAID_JS = "mraid.js";
private String mraidInjectionJavascript;
public MraidWebViewClient(AdAssetsLoadedListener adAssetsLoadedListener, String mraidScript) {
super(adAssetsLoadedListener);
mraidInjectionJavascript = "javascript:" + MraidEnv.getWindowMraidEnv() + mraidScript;
}
@Override
public WebResourceResponse shouldInterceptRequest(final WebView view, final String url) {
if (matchesInjectionUrl(url)) {
return createMraidInjectionResponse();
}
else {
return super.shouldInterceptRequest(view, url);
}
}
@VisibleForTesting
boolean matchesInjectionUrl(final String url) {
final Uri uri = Uri.parse(url.toLowerCase(Locale.US));
return MRAID_JS.equals(uri.getLastPathSegment());
}
private WebResourceResponse createMraidInjectionResponse() {
if (Utils.isNotBlank(mraidInjectionJavascript)) {
adAssetsLoadedListener.notifyMraidScriptInjected();
InputStream data = new ByteArrayInputStream(mraidInjectionJavascript.getBytes());
return new WebResourceResponse("text/javascript", "UTF-8", data);
} else {
LogUtil.error(TAG, "Failed to inject mraid.js into twoPart mraid webview");
}
return null;
}
} |
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview/mraid/OriginalUrlResponseCallBack.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.webview.mraid;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.rendering.mraid.methods.network.RedirectUrlListener;
import org.prebid.mobile.rendering.networking.BaseNetworkTask;
import org.prebid.mobile.rendering.networking.ResponseHandler;
class OriginalUrlResponseCallBack implements ResponseHandler {
private static final String TAG = OriginalUrlResponseCallBack.class.getSimpleName();
private RedirectUrlListener redirectUrlListener;
OriginalUrlResponseCallBack(RedirectUrlListener redirectUrlListener) {
this.redirectUrlListener = redirectUrlListener;
}
@Override
public void onResponse(BaseNetworkTask.GetUrlResult result) {
if (result == null) {
LogUtil.error(TAG, "getOriginalURLCallback onResponse failed. Result is null");
notifyFailureListener();
return;
}
if (redirectUrlListener != null) {
redirectUrlListener.onSuccess(result.originalUrl, result.contentType);
}
}
@Override
public void onError(String msg, long responseTime) {
LogUtil.error(TAG, "Failed with " + msg);
notifyFailureListener();
}
@Override
public void onErrorWithException(Exception e, long responseTime) {
LogUtil.error(TAG, "Failed with " + e.getMessage());
notifyFailureListener();
}
private void notifyFailureListener() {
if (redirectUrlListener != null) {
redirectUrlListener.onFailed();
}
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview/mraid/ScreenMetricsWaiter.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.webview.mraid;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.view.ViewTreeObserver;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.rendering.views.webview.PrebidWebViewBase;
import java.util.LinkedList;
public class ScreenMetricsWaiter {
private final static String TAG = ScreenMetricsWaiter.class.getSimpleName();
@NonNull private final Handler handler = new Handler(Looper.getMainLooper());
private LinkedList<WaitRequest> waitRequestQueue = new LinkedList<>();
void queueMetricsRequest(
@NonNull
Runnable successRunnable, boolean isAnswerRequired,
@NonNull
View... views) {
WaitRequest newWaitRequest = new WaitRequest(handler, successRunnable, isAnswerRequired, views);
if (waitRequestQueue.isEmpty()) {
newWaitRequest.start();
}
waitRequestQueue.addLast(newWaitRequest);
LogUtil.debug(TAG, "New request queued. Queue size: " + waitRequestQueue.size());
}
void finishAndStartNextRequest() {
waitRequestQueue.removeFirst();
WaitRequest firstInQueueRequest = waitRequestQueue.peekFirst();
LogUtil.debug(TAG, "Request finished. Queue size: " + waitRequestQueue.size());
if (firstInQueueRequest != null) {
firstInQueueRequest.start();
}
}
void cancelPendingRequests() {
WaitRequest waitRequest = waitRequestQueue.pollFirst();
while (waitRequest != null) {
waitRequest.cancel();
waitRequest = waitRequestQueue.pollFirst();
}
}
static class WaitRequest {
@NonNull private final View[] views;
@NonNull private final Handler handler;
@Nullable private Runnable successRunnable;
private boolean isAnswerRequired;
int waitCount;
private WaitRequest(
@NonNull Handler handler,
@NonNull Runnable successRunnable,
boolean isAnswerRequired,
@NonNull final View[] views
) {
this.isAnswerRequired = isAnswerRequired;
this.handler = handler;
this.successRunnable = successRunnable;
this.views = views;
}
private void countDown() {
waitCount--;
if (waitCount == 0 && successRunnable != null) {
successRunnable.run();
successRunnable = null;
}
}
private final Runnable waitingRunnable = new Runnable() {
@Override
public void run() {
for (final View view : views) {
boolean isTwoPart = false;
if (view instanceof PrebidWebViewBase && ((PrebidWebViewBase) view).getMraidWebView() != null) {
String jsName = ((PrebidWebViewBase) view).getMraidWebView().getJSName();
isTwoPart = "twopart".equals(jsName);
}
// Immediately count down for any views that already have a size
if (view.getHeight() > 0 || view.getWidth() > 0 || isAnswerRequired || isTwoPart) {
countDown();
LogUtil.debug(TAG,
"Get known metrics for: " + view.getClass()
.getSimpleName() + ", h: " + view.getHeight() + ", w: " + view.getWidth()
);
continue;
}
// For views that didn't have a size, listen (once) for a preDraw. Note
// that this doesn't leak because the ViewTreeObserver gets detached when
// the view is no longer part of the view hierarchy.
LogUtil.debug(TAG, "Create listener for: " + view.getClass().getSimpleName());
view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
LogUtil.debug(TAG, "Get metrics from listener for: " + view.getClass().getSimpleName() + ", h: " + view.getHeight() + ", w: " + view.getWidth());
view.getViewTreeObserver().removeOnPreDrawListener(this);
countDown();
return true;
}
});
}
}
};
void start() {
waitCount = views.length;
handler.post(waitingRunnable);
}
void cancel() {
handler.removeCallbacks(waitingRunnable);
successRunnable = null;
}
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/rendering/views/webview/mraid/Views.java | /*
* Copyright 2018-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.rendering.views.webview.mraid;
import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import org.prebid.mobile.LogUtil;
public class Views {
public static final String TAG = Views.class.getSimpleName();
public static void removeFromParent(@Nullable View view) {
if (view == null || view.getParent() == null) {
return;
}
if (view.getParent() instanceof ViewGroup) {
((ViewGroup) view.getParent()).removeView(view);
}
}
/**
* Finds the topmost view in the current Activity or current view hierarchy.
*
* @param context If an Activity Context, used to obtain the Activity's DecorView. This is
* ignored if it is a non-Activity Context.
* @param view A View in the currently displayed view hierarchy. If a null or non-Activity
* Context is provided, this View's topmost parent is used to determine the
* rootView.
* @return The topmost View in the currency Activity or current view hierarchy. Null if no
* applicable View can be found.
*/
@Nullable
public static View getTopmostView(@Nullable final Context context, @Nullable final View view) {
final View rootViewFromActivity = getRootViewFromActivity(context);
final View rootViewFromView = getRootViewFromView(view);
// Prefer to use the rootView derived from the Activity's DecorView since it provides a
// consistent value when the View is not attached to the Window. Fall back to the passed-in
// View's hierarchy if necessary.
return rootViewFromActivity != null
? rootViewFromActivity
: rootViewFromView;
}
@Nullable
private static View getRootViewFromActivity(@Nullable final Context context) {
if (!(context instanceof Activity)) {
return null;
}
return ((Activity) context).getWindow().getDecorView().findViewById(android.R.id.content);
}
@Nullable
private static View getRootViewFromView(@Nullable final View view) {
if (view == null) {
return null;
}
if (!ViewCompat.isAttachedToWindow(view)) {
LogUtil.debug(TAG, "Attempting to call View.getRootView() on an unattached View.");
}
final View rootView = view.getRootView();
if (rootView == null) {
return null;
}
final View rootContentView = rootView.findViewById(android.R.id.content);
return rootContentView != null
? rootContentView
: rootView;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/tasksmanager/BackgroundThreadExecutor.java | /*
* Copyright 2020-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.tasksmanager;
import android.os.Handler;
import android.os.HandlerThread;
import androidx.annotation.VisibleForTesting;
public class BackgroundThreadExecutor implements CancellableExecutor {
private Handler handler;
private boolean running = false;
private final int HANDLER_COUNT = 3;
private int index = 0;
BackgroundThreadExecutor() {
HandlerThread backgroundThread = new HandlerThread("BackgroundThread");
backgroundThread.start();
handler = new Handler(backgroundThread.getLooper());
running = true;
}
@Override
public void execute(Runnable runnable) {
if (running) {
handler.post(runnable);
}
}
@Override
public boolean cancel(Runnable runnable) {
if (running) {
handler.removeCallbacks(runnable);
return true;
}
return false;
}
public void shutdown() {
if (running) {
handler.getLooper().quit();
handler = null;
running = false;
}
}
public void startThread() {
if (!running) {
HandlerThread backgroundThread = new HandlerThread("BackgroundThread");
backgroundThread.start();
handler = new Handler(backgroundThread.getLooper());
running = true;
}
}
@VisibleForTesting
public Handler getBackgroundHandler() {
return handler;
}
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/tasksmanager/CancellableExecutor.java | /*
* Copyright 2020-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.tasksmanager;
import java.util.concurrent.Executor;
public interface CancellableExecutor extends Executor {
boolean cancel(Runnable runnable);
}
|
0 | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile | java-sources/ai/themsp/prebid-core/2.0.3.30/main/org/prebid/mobile/tasksmanager/MainThreadExecutor.java | /*
* Copyright 2020-2021 Prebid.org, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.prebid.mobile.tasksmanager;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.VisibleForTesting;
public class MainThreadExecutor implements CancellableExecutor {
private final Handler handler = new Handler(Looper.getMainLooper());
@Override
public void execute(Runnable runnable) {
handler.post(runnable);
}
@Override
public boolean cancel(Runnable runnable) {
handler.removeCallbacks(runnable);
return true;
}
@VisibleForTesting
public Handler getMainExecutor() {
return handler;
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.