Merge pull request #5855 from alexzatsepin/MAPSME-4307-mopub-privacy-notice

Mapsme 4307 mopub privacy notice
This commit is contained in:
Aleksandr Zatsepin 2017-04-18 11:21:33 +03:00 committed by GitHub
commit 6740fe4930
7 changed files with 80 additions and 0 deletions

View file

@ -1,6 +1,7 @@
package com.mapswithme.maps.ads;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
@ -75,4 +76,11 @@ class FacebookNativeAd extends CachedMwmNativeAd
{
return Providers.FACEBOOK;
}
@Nullable
@Override
public String getPrivacyInfoUrl()
{
return mAd.getAdChoicesLinkUrl();
}
}

View file

@ -1,6 +1,7 @@
package com.mapswithme.maps.ads;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
@ -74,4 +75,11 @@ class MopubNativeAd extends CachedMwmNativeAd
{
mNativeAd.prepare(view);
}
@Nullable
@Override
public String getPrivacyInfoUrl()
{
return mAd.getPrivacyInformationIconClickThroughUrl();
}
}

View file

@ -1,6 +1,7 @@
package com.mapswithme.maps.ads;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
/**
@ -44,4 +45,10 @@ public interface MwmNativeAd
*/
@NonNull
String getProvider();
/**
* Returns a privacy information url, or <code>null</code> if not set.
*/
@Nullable
String getPrivacyInfoUrl();
}

View file

@ -1,6 +1,7 @@
package com.mapswithme.maps.ads;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
@ -82,4 +83,11 @@ class MyTargetNativeAd extends CachedMwmNativeAd
{
return Providers.MY_TARGET;
}
@Nullable
@Override
public String getPrivacyInfoUrl()
{
return null;
}
}

View file

@ -6,6 +6,7 @@ import android.content.Context;
import android.content.res.Resources;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
@ -22,6 +23,7 @@ import com.mapswithme.maps.ads.NativeAdListener;
import com.mapswithme.util.Config;
import com.mapswithme.util.ThemeUtils;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;
import com.mapswithme.util.log.Logger;
import com.mapswithme.util.log.LoggerFactory;
import com.mapswithme.util.statistics.Statistics;
@ -94,6 +96,16 @@ final class BannerController
mActionSmall = (TextView) bannerView.findViewById(R.id.tv__action_small);
mActionLarge = (TextView) bannerView.findViewById(R.id.tv__action_large);
mAds = bannerView.findViewById(R.id.tv__ads);
mAds.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
handlePrivacyInfoUrl();
}
});
Resources res = mFrame.getResources();
UiUtils.expandTouchAreaForView(mAds, (int) res.getDimension(R.dimen.margin_quarter_plus));
loader.setAdListener(new MyNativeAdsListener());
mAdsLoader = loader;
mAdTracker = tracker;
@ -107,6 +119,18 @@ final class BannerController
});
}
private void handlePrivacyInfoUrl()
{
if (mCurrentAd == null)
return;
String privacyUrl = mCurrentAd.getPrivacyInfoUrl();
if (TextUtils.isEmpty(privacyUrl))
return;
Utils.openUrl(mFrame.getContext(), privacyUrl);
}
private void setErrorStatus(boolean value)
{
mError = value;

View file

@ -29,6 +29,7 @@ import android.text.TextUtils;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.TouchDelegate;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
@ -469,6 +470,25 @@ public final class UiUtils
view.setBackgroundResource(getStyledResourceId(view.getContext(), res));
}
public static void expandTouchAreaForView(@NonNull final View view, final int extraArea)
{
final View parent = (View) view.getParent();
parent.post(new Runnable()
{
@Override
public void run()
{
Rect rect = new Rect();
view.getHitRect(rect);
rect.top -= extraArea;
rect.left -= extraArea;
rect.right += extraArea;
rect.bottom += extraArea;
parent.setTouchDelegate(new TouchDelegate(rect, view));
}
});
}
// utility class
private UiUtils() {}
}

View file

@ -202,6 +202,11 @@ public class Utils
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.Url.TWITTER_MAPSME_HTTP)));
}
public static void openUrl(@NonNull Context activity, @NonNull String url)
{
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
}
public static void sendSupportMail(@NonNull Activity activity, @NonNull String subject)
{
LoggerFactory.INSTANCE.zipLogs(new OnZipCompletedCallback(activity, subject));