[android] bookmarks catalog headers are provided

This commit is contained in:
Arsentiy Milchakov 2019-11-14 20:26:32 +03:00 committed by Maksim Andrianov
parent 29261796d4
commit 047d6fc6b4
3 changed files with 25 additions and 3 deletions

View file

@ -1064,6 +1064,14 @@ Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeGetCatalogFrontend
return ToJavaString(env, bm.GetCatalog().GetFrontendUrl(static_cast<UTM>(utm)));
}
JNIEXPORT jobjectArray JNICALL
Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeGetCatalogHeaders(JNIEnv * env,
jobject)
{
auto & bm = frm()->GetBookmarkManager();
return jni::ToKeyValueArray(env, bm.GetCatalog().GetHeaders());
}
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeInjectCatalogUTMContent(JNIEnv * env,
jobject, jstring url, jint content)

View file

@ -31,6 +31,7 @@ import com.mapswithme.maps.PrivateVariables;
import com.mapswithme.maps.R;
import com.mapswithme.maps.auth.BaseWebViewMwmFragment;
import com.mapswithme.maps.auth.TargetFragmentCallback;
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
import com.mapswithme.maps.dialog.AlertDialog;
import com.mapswithme.maps.dialog.AlertDialogCallback;
import com.mapswithme.maps.dialog.ConfirmationDialogFactory;
@ -48,6 +49,7 @@ import com.mapswithme.maps.purchase.SubscriptionType;
import com.mapswithme.util.ConnectionState;
import com.mapswithme.util.CrashlyticsUtils;
import com.mapswithme.util.HttpClient;
import com.mapswithme.util.KeyValue;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;
import com.mapswithme.util.log.Logger;
@ -299,9 +301,11 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment
if (!TextUtils.isEmpty(productDetailsBundle))
headers.put(HttpClient.HEADER_BUNDLE_TIERS, productDetailsBundle);
String deviceId = Framework.nativeGetDeviceId();
if (!TextUtils.isEmpty(deviceId))
headers.put(HttpClient.HEADER_DEVICE_ID, deviceId);
for (KeyValue header : BookmarkManager.INSTANCE.getCatalogHeaders())
{
if (!TextUtils.isEmpty(header.mValue))
headers.put(header.mKey, header.mValue);
}
mWebView.loadUrl(getCatalogUrlOrThrow(), headers);
UserActionsLogger.logBookmarksCatalogShownEvent();

View file

@ -10,6 +10,7 @@ import com.mapswithme.maps.base.DataChangedListener;
import com.mapswithme.maps.base.Observable;
import com.mapswithme.maps.PrivateVariables;
import com.mapswithme.maps.metrics.UserActionsLogger;
import com.mapswithme.util.KeyValue;
import com.mapswithme.util.UTM;
import com.mapswithme.util.statistics.Statistics;
@ -714,6 +715,12 @@ public enum BookmarkManager
return nativeGetCatalogFrontendUrl(utm);
}
@NonNull
public KeyValue[] getCatalogHeaders()
{
return nativeGetCatalogHeaders();
}
@NonNull
public String injectCatalogUTMContent(@NonNull String url, @UTM.UTMContentType int content)
{
@ -1034,6 +1041,9 @@ public enum BookmarkManager
@NonNull
private static native String nativeGetCatalogFrontendUrl(@UTM.UTMType int utm);
@NonNull
private static native KeyValue[] nativeGetCatalogHeaders();
@NonNull
private static native String nativeInjectCatalogUTMContent(@NonNull String url,
@UTM.UTMContentType int content);