diff --git a/android/build.gradle b/android/build.gradle
index dd3e21ed34..b73a44fe22 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -55,11 +55,9 @@ dependencies {
implementation 'com.android.support:support-annotations:'+ propSupportLibraryVersion
implementation 'com.android.support:support-compat:27.1.1'+ propSupportLibraryVersion
- implementation 'com.google.android.gms:play-services-ads:' + propPlayServicesVersion
implementation 'com.google.android.gms:play-services-location:' + propPlayServicesVersion
implementation 'com.google.android.gms:play-services-analytics:' + propPlayServicesVersion
implementation 'com.google.android.gms:play-services-gcm:' + propPlayServicesVersion
- implementation 'com.google.android.gms:play-services-ads:' + propPlayServicesVersion
implementation 'com.google.android.gms:play-services-auth:' + propPlayServicesVersion
implementation 'com.google.android.gms:play-services-basement:' + propPlayServicesVersion
@@ -94,7 +92,6 @@ dependencies {
implementation 'com.github.bumptech.glide:glide:3.7.0'
// Java concurrency annotations
implementation 'net.jcip:jcip-annotations:1.0'
- implementation 'com.android.support:multidex:1.0.3'
implementation 'com.appsflyer:af-android-sdk:4.8.7'
implementation ("ru.mail:libnotify:0.1.177-notify-support-v107-sdk-26@aar") {
transitive = true
diff --git a/android/res/values/attrs.xml b/android/res/values/attrs.xml
index b6dc13f45a..efced5aff1 100644
--- a/android/res/values/attrs.xml
+++ b/android/res/values/attrs.xml
@@ -51,8 +51,6 @@
-
-
@@ -60,31 +58,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
false
false
diff --git a/android/res/values/styles-google-ads.xml b/android/res/values/styles-google-ads.xml
deleted file mode 100644
index c3181d0178..0000000000
--- a/android/res/values/styles-google-ads.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
-
-
diff --git a/android/src/com/mapswithme/maps/ads/GoogleSearchAd.java b/android/src/com/mapswithme/maps/ads/GoogleSearchAd.java
deleted file mode 100644
index 1612acbdad..0000000000
--- a/android/src/com/mapswithme/maps/ads/GoogleSearchAd.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.mapswithme.maps.ads;
-
-import android.support.annotation.NonNull;
-
-import com.mapswithme.maps.Framework;
-
-public class GoogleSearchAd
-{
- @NonNull
- private String mAdUnitId = "";
-
- public GoogleSearchAd()
- {
- Banner[] banners = Framework.nativeGetSearchBanners();
- if (banners == null)
- return;
-
- for (Banner b : banners)
- {
- if (b.getProvider().equals(Providers.GOOGLE))
- {
- mAdUnitId = b.getId();
- break;
- }
- }
- }
-
- @NonNull
- public String getAdUnitId() { return mAdUnitId; }
-}
diff --git a/android/src/com/mapswithme/maps/search/GoogleAdsBanner.java b/android/src/com/mapswithme/maps/search/GoogleAdsBanner.java
deleted file mode 100644
index cd156ffd94..0000000000
--- a/android/src/com/mapswithme/maps/search/GoogleAdsBanner.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.mapswithme.maps.search;
-
-import android.support.annotation.NonNull;
-
-import com.google.android.gms.ads.search.SearchAdView;
-
-class GoogleAdsBanner implements SearchData
-{
- @NonNull
- private SearchAdView mAdView;
-
- GoogleAdsBanner(@NonNull SearchAdView adView)
- {
- this.mAdView = adView;
- }
-
- @NonNull
- SearchAdView getAdView()
- {
- return mAdView;
- }
-
- @Override
- public int getItemViewType()
- {
- return SearchResultTypes.TYPE_GOOGLE_ADS;
- }
-}
diff --git a/android/src/com/mapswithme/maps/search/GoogleAdsLoader.java b/android/src/com/mapswithme/maps/search/GoogleAdsLoader.java
deleted file mode 100644
index 1e6b131c1a..0000000000
--- a/android/src/com/mapswithme/maps/search/GoogleAdsLoader.java
+++ /dev/null
@@ -1,151 +0,0 @@
-package com.mapswithme.maps.search;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-
-import com.google.ads.mediation.admob.AdMobAdapter;
-import com.google.android.gms.ads.AdListener;
-import com.google.android.gms.ads.AdSize;
-import com.google.android.gms.ads.search.SearchAdRequest;
-import com.google.android.gms.ads.search.SearchAdView;
-import com.mapswithme.maps.R;
-import com.mapswithme.maps.ads.GoogleSearchAd;
-import com.mapswithme.util.ThemeUtils;
-import com.mapswithme.util.concurrency.UiThread;
-
-class GoogleAdsLoader
-{
- private long mLoadingDelay;
- @NonNull
- private final Bundle mStyleParams = new Bundle();
- @Nullable
- private GoogleSearchAd mGoogleSearchAd;
- @Nullable
- private Runnable mLoadingTask;
- @NonNull
- private String mQuery = "";
- @Nullable
- private AdvertLoadingListener mLoadingListener;
-
- GoogleAdsLoader(@NonNull Context context, long loadingDelay)
- {
- this.mLoadingDelay = loadingDelay;
- initStyle(context);
- }
-
- void scheduleAdsLoading(@NonNull final Context context, @NonNull final String query)
- {
- cancelAdsLoading();
- mQuery = query;
-
- mGoogleSearchAd = new GoogleSearchAd();
- if (mGoogleSearchAd.getAdUnitId().isEmpty())
- return;
-
- mLoadingTask = new Runnable()
- {
- @Override
- public void run()
- {
- performLoading(context);
- }
- };
- UiThread.runLater(mLoadingTask, mLoadingDelay);
- }
-
- void cancelAdsLoading()
- {
- if (mLoadingTask != null)
- {
- UiThread.cancelDelayedTasks(mLoadingTask);
- mLoadingTask = null;
- }
- }
-
- private void updateAdView(SearchAdView searchAdView)
- {
- SearchAdRequest.Builder builder = new SearchAdRequest.Builder()
- .setQuery(mQuery)
- .addNetworkExtrasBundle(AdMobAdapter.class, mStyleParams);
-
- searchAdView.loadAd(builder.build());
- }
-
- void attach(@NonNull AdvertLoadingListener listener)
- {
- mLoadingListener = listener;
- }
-
- void detach()
- {
- mLoadingListener = null;
- }
-
- private void initStyle(@NonNull Context context)
- {
- TypedArray attrs = context.obtainStyledAttributes(ThemeUtils.isNightTheme() ?
- R.style.GoogleAdsDark : R.style.GoogleAdsLight, R.styleable.GoogleAds);
-
- mStyleParams.putString("csa_width", "auto");
- mStyleParams.putString("csa_colorLocation", attrs.getString(R.styleable.GoogleAds_colorLocation));
- mStyleParams.putString("csa_fontSizeLocation", attrs.getString(R.styleable.GoogleAds_fontSizeLocation));
- mStyleParams.putString("csa_clickToCall", attrs.getString(R.styleable.GoogleAds_clickToCall));
- mStyleParams.putString("csa_location", attrs.getString(R.styleable.GoogleAds_location));
- mStyleParams.putString("csa_sellerRatings", attrs.getString(R.styleable.GoogleAds_sellerRatings));
- mStyleParams.putString("csa_siteLinks", attrs.getString(R.styleable.GoogleAds_siteLinks));
- mStyleParams.putString("csa_number", attrs.getString(R.styleable.GoogleAds_number));
- mStyleParams.putString("csa_fontSizeAnnotation", attrs.getString(R.styleable.GoogleAds_fontSizeAnnotation));
- mStyleParams.putString("csa_fontSizeAttribution", attrs.getString(R.styleable.GoogleAds_fontSizeAttribution));
- mStyleParams.putString("csa_fontSizeDescription", attrs.getString(R.styleable.GoogleAds_fontSizeDescription));
- mStyleParams.putString("csa_fontSizeDomainLink", attrs.getString(R.styleable.GoogleAds_fontSizeDomainLink));
- mStyleParams.putString("csa_fontSizeTitle", attrs.getString(R.styleable.GoogleAds_fontSizeTitle));
- mStyleParams.putString("csa_colorAdBorder", attrs.getString(R.styleable.GoogleAds_colorAdBorder));
- mStyleParams.putString("csa_colorAnnotation", attrs.getString(R.styleable.GoogleAds_colorAnnotation));
- mStyleParams.putString("csa_colorAttribution", attrs.getString(R.styleable.GoogleAds_colorAttribution));
- mStyleParams.putString("csa_colorBackground", attrs.getString(R.styleable.GoogleAds_colorBackground));
- mStyleParams.putString("csa_colorDomainLink", attrs.getString(R.styleable.GoogleAds_colorDomainLink));
- mStyleParams.putString("csa_colorText", attrs.getString(R.styleable.GoogleAds_colorText));
- mStyleParams.putString("csa_colorTitleLink", attrs.getString(R.styleable.GoogleAds_colorTitleLink));
- mStyleParams.putString("csa_attributionSpacingBelow", attrs.getString(R.styleable.GoogleAds_attributionSpacingBelow));
- mStyleParams.putString("csa_noTitleUnderline", attrs.getString(R.styleable.GoogleAds_noTitleUnderline));
- mStyleParams.putString("csa_titleBold", attrs.getString(R.styleable.GoogleAds_titleBold));
- attrs.recycle();
- }
-
- private void performLoading(@NonNull Context context)
- {
- if (mGoogleSearchAd == null)
- throw new AssertionError("mGoogleSearchAd can't be null here");
-
- final SearchAdView view = new SearchAdView(context);
- view.setAdSize(AdSize.SEARCH);
- view.setAdUnitId(mGoogleSearchAd.getAdUnitId());
- updateAdView(view);
- view.setAdListener(new AdListener()
- {
- @Override
- public void onAdLoaded()
- {
- mLoadingTask = null;
- if (mLoadingListener != null)
- {
- mLoadingListener.onLoadingFinished(view);
- }
- }
-
- @Override
- public void onAdFailedToLoad(int i)
- {
- mLoadingTask = null;
- }
- });
- }
-
- interface AdvertLoadingListener
- {
- void onLoadingFinished(@NonNull SearchAdView searchAdView);
- }
-}
diff --git a/android/src/com/mapswithme/maps/search/NativeSearchListener.java b/android/src/com/mapswithme/maps/search/NativeSearchListener.java
index 58106af041..75e546bed6 100644
--- a/android/src/com/mapswithme/maps/search/NativeSearchListener.java
+++ b/android/src/com/mapswithme/maps/search/NativeSearchListener.java
@@ -1,5 +1,7 @@
package com.mapswithme.maps.search;
+import android.support.annotation.NonNull;
+
/**
* Native search will return results via this interface.
*/
@@ -10,7 +12,7 @@ public interface NativeSearchListener
* @param results Search results.
* @param timestamp Timestamp of search request.
*/
- void onResultsUpdate(SearchResult[] results, long timestamp, boolean isHotel);
+ void onResultsUpdate(@NonNull SearchResult[] results, long timestamp, boolean isHotel);
/**
* @param timestamp Timestamp of search request.
diff --git a/android/src/com/mapswithme/maps/search/SearchAdapter.java b/android/src/com/mapswithme/maps/search/SearchAdapter.java
index 74f9ed8f29..901017c380 100644
--- a/android/src/com/mapswithme/maps/search/SearchAdapter.java
+++ b/android/src/com/mapswithme/maps/search/SearchAdapter.java
@@ -8,6 +8,7 @@ import android.support.annotation.AttrRes;
import android.support.annotation.ColorInt;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
@@ -18,7 +19,6 @@ import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.FrameLayout;
import android.widget.TextView;
import com.mapswithme.HotelUtils;
@@ -35,12 +35,16 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
+import static com.mapswithme.maps.search.SearchResult.TYPE_LOCAL_ADS_CUSTOMER;
+import static com.mapswithme.maps.search.SearchResult.TYPE_RESULT;
+import static com.mapswithme.maps.search.SearchResult.TYPE_SUGGEST;
import static com.mapswithme.util.Constants.Rating.RATING_INCORRECT_VALUE;
class SearchAdapter extends RecyclerView.Adapter
{
private final SearchFragment mSearchFragment;
- private SearchData[] mResults;
+ @Nullable
+ private SearchResult[] mResults;
@NonNull
private final FilteredHotelIds mFilteredHotelIds = new FilteredHotelIds();
private final Drawable mClosedMarkerBackground;
@@ -52,7 +56,7 @@ class SearchAdapter extends RecyclerView.Adapter 0 &&
- SearchResult.class.isInstance(mResults[0]) &&
- ((SearchResult) mResults[0]).type != SearchResultTypes.TYPE_SUGGEST);
+ mResults[0].type != TYPE_SUGGEST);
}
@Override
@@ -476,7 +457,7 @@ class SearchAdapter extends RecyclerView.Adapter mHiddenCommands = new ArrayList<>();
@@ -109,11 +89,6 @@ public class SearchFragment extends BaseMwmFragment
if (!isAdded())
return;
- UiThread.cancelDelayedTasks(mSearchEndTask);
- UiThread.cancelDelayedTasks(mResultsShowingTask);
- mGoogleAdView = null;
- stopAdsLoading();
-
if (TextUtils.isEmpty(query))
{
mSearchAdapter.clear();
@@ -129,12 +104,6 @@ public class SearchFragment extends BaseMwmFragment
return;
}
- if (mAdsLoader != null && !isTabletSearch() && query.length() >= MIN_QUERY_LENGTH_FOR_AD)
- {
- mAdsRequested = true;
- mAdsLoader.scheduleAdsLoading(getActivity(), query);
- }
-
runSearch();
}
@@ -217,10 +186,6 @@ public class SearchFragment extends BaseMwmFragment
@Nullable
private BookingFilterParams mInitialFilterParams;
- private boolean mIsHotel;
- @NonNull
- private SearchResult[] mSearchResults = new SearchResult[0];
-
private final LocationListener mLocationListener = new LocationListener.Simple()
{
@Override
@@ -344,16 +309,6 @@ public class SearchFragment extends BaseMwmFragment
mSearchAdapter = new SearchAdapter(this);
readArguments();
- if (ConnectionState.isWifiConnected())
- {
- mAdsLoader = new GoogleAdsLoader(getContext(), ADS_DELAY_MS);
- mAdsLoader.attach(searchAdView ->
- {
- mGoogleAdView = searchAdView;
- mAdsRequested = false;
- });
- }
-
ViewGroup root = (ViewGroup) view;
mAppBarLayout = root.findViewById(R.id.app_bar);
mToolbarLayout = mAppBarLayout.findViewById(R.id.collapsing_toolbar);
@@ -477,14 +432,6 @@ public class SearchFragment extends BaseMwmFragment
super.onDestroy();
}
- @Override
- public void onDestroyView()
- {
- if (mAdsLoader != null)
- mAdsLoader.detach();
- super.onDestroyView();
- }
-
private String getQuery()
{
return mToolbarController.getQuery();
@@ -663,37 +610,18 @@ public class SearchFragment extends BaseMwmFragment
}
@Override
- public void onResultsUpdate(SearchResult[] results, long timestamp, boolean isHotel)
+ public void onResultsUpdate(@NonNull SearchResult[] results, long timestamp, boolean isHotel)
{
if (!isAdded() || !mToolbarController.hasQuery())
return;
- mSearchResults = results;
- mIsHotel = isHotel;
-
- if (mAdsRequested)
- {
- UiThread.cancelDelayedTasks(mResultsShowingTask);
- UiThread.runLater(mResultsShowingTask, RESULTS_DELAY_MS);
- }
- else
- {
- refreshSearchResults();
- }
+ refreshSearchResults(isHotel, results);
}
@Override
public void onResultsEnd(long timestamp)
{
- if (mAdsRequested)
- {
- UiThread.cancelDelayedTasks(mSearchEndTask);
- UiThread.runLater(mSearchEndTask, RESULTS_DELAY_MS);
- }
- else
- {
- onSearchEnd();
- }
+ onSearchEnd();
}
@Override
@@ -723,36 +651,13 @@ public class SearchFragment extends BaseMwmFragment
// Do nothing by default.
}
- private void refreshSearchResults()
+ private void refreshSearchResults(boolean isHotel, @NonNull SearchResult[] results)
{
- // Search is running hence results updated.
- stopAdsLoading();
mSearchRunning = true;
updateFrames();
- mSearchAdapter.refreshData(combineResultsWithAds());
+ mSearchAdapter.refreshData(results);
mToolbarController.showProgress(true);
- updateFilterButton(mIsHotel);
- }
-
- @NonNull
- private SearchData[] combineResultsWithAds()
- {
- if (mSearchResults.length < AD_POSITION || mGoogleAdView == null)
- return mSearchResults;
-
- List result = new LinkedList<>();
- int counter = 0;
- for (SearchResult r : mSearchResults)
- {
- if (r.type != SearchResultTypes.TYPE_SUGGEST && counter++ == AD_POSITION)
- result.add(new GoogleAdsBanner(mGoogleAdView));
- else
- result.add(r);
- }
-
- SearchData[] resultArray = new SearchData[result.size()];
- result.toArray(resultArray);
- return resultArray;
+ updateFilterButton(isHotel);
}
private void updateFilterButton(boolean isHotel)
@@ -832,15 +737,6 @@ public class SearchFragment extends BaseMwmFragment
return mToolbarController;
}
- private void stopAdsLoading()
- {
- if (mAdsLoader == null)
- return;
-
- mAdsLoader.cancelAdsLoading();
- mAdsRequested = false;
- }
-
private static class BadStorageCommand extends HiddenCommand.BaseHiddenCommand
{
protected BadStorageCommand(@NonNull String command)
diff --git a/android/src/com/mapswithme/maps/search/SearchResult.java b/android/src/com/mapswithme/maps/search/SearchResult.java
index 3f8a5cdbdf..0e5382db21 100644
--- a/android/src/com/mapswithme/maps/search/SearchResult.java
+++ b/android/src/com/mapswithme/maps/search/SearchResult.java
@@ -4,16 +4,16 @@ import android.support.annotation.NonNull;
import com.mapswithme.maps.bookmarks.data.FeatureId;
-import static com.mapswithme.maps.search.SearchResultTypes.TYPE_LOCAL_ADS_CUSTOMER;
-import static com.mapswithme.maps.search.SearchResultTypes.TYPE_RESULT;
-import static com.mapswithme.maps.search.SearchResultTypes.TYPE_SUGGEST;
-
/**
* Class instances are created from native code.
*/
@SuppressWarnings("unused")
-public class SearchResult implements SearchData, PopularityProvider
+public class SearchResult implements PopularityProvider
{
+ public static final int TYPE_SUGGEST = 0;
+ public static final int TYPE_RESULT = 1;
+ public static final int TYPE_LOCAL_ADS_CUSTOMER = 2;
+
// Values should match osm::YesNoUnknown enum.
public static final int OPEN_NOW_UNKNOWN = 0;
public static final int OPEN_NOW_YES = 1;
@@ -98,12 +98,6 @@ public class SearchResult implements SearchData, PopularityProvider
this.highlightRanges = highlightRanges;
}
- @Override
- public int getItemViewType()
- {
- return type;
- }
-
@NonNull
@Override
public Popularity getPopularity()
diff --git a/android/src/com/mapswithme/maps/search/SearchResultTypes.java b/android/src/com/mapswithme/maps/search/SearchResultTypes.java
deleted file mode 100644
index 03a8c5463c..0000000000
--- a/android/src/com/mapswithme/maps/search/SearchResultTypes.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.mapswithme.maps.search;
-
-class SearchResultTypes
-{
- static final int TYPE_SUGGEST = 0;
- static final int TYPE_RESULT = 1;
- static final int TYPE_LOCAL_ADS_CUSTOMER = 2;
- static final int TYPE_GOOGLE_ADS = 3;
-}