forked from organicmaps/organicmaps
Revert "[android] Remove a referral code from “Photos, reviews, booking”"
This reverts commit ee7e87fa1e
.
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
parent
16c8355c3a
commit
e10afa843e
7 changed files with 11 additions and 21 deletions
|
@ -1984,13 +1984,12 @@ Java_app_organicmaps_Framework_nativeMemoryWarning(JNIEnv *, jclass)
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL
|
JNIEXPORT jstring JNICALL
|
||||||
Java_app_organicmaps_Framework_nativeGetKayakHotelLink(JNIEnv * env, jclass, jstring countryIsoCode, jstring uri,
|
Java_app_organicmaps_Framework_nativeGetKayakHotelLink(JNIEnv * env, jclass, jstring countryIsoCode, jstring uri,
|
||||||
jlong firstDaySec, jlong lastDaySec, jboolean isReferral)
|
jlong firstDaySec, jlong lastDaySec)
|
||||||
{
|
{
|
||||||
string const url = osm::GetKayakHotelURLFromURI(jni::ToNativeString(env, countryIsoCode),
|
string const url = osm::GetKayakHotelURLFromURI(jni::ToNativeString(env, countryIsoCode),
|
||||||
jni::ToNativeString(env, uri),
|
jni::ToNativeString(env, uri),
|
||||||
static_cast<time_t>(firstDaySec),
|
static_cast<time_t>(firstDaySec),
|
||||||
static_cast<time_t>(lastDaySec),
|
static_cast<time_t>(lastDaySec));
|
||||||
isReferral);
|
|
||||||
return url.empty() ? nullptr : jni::ToJavaString(env, url);
|
return url.empty() ? nullptr : jni::ToJavaString(env, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -456,10 +456,9 @@ public class Framework
|
||||||
* @param uri `$HOTEL_NAME,-c$CITY_ID-h$HOTEL_ID` URI.
|
* @param uri `$HOTEL_NAME,-c$CITY_ID-h$HOTEL_ID` URI.
|
||||||
* @param firstDaySec the epoch seconds of the first day of planned stay.
|
* @param firstDaySec the epoch seconds of the first day of planned stay.
|
||||||
* @param lastDaySec the epoch seconds of the last day of planned stay.
|
* @param lastDaySec the epoch seconds of the last day of planned stay.
|
||||||
* @param isReferral enable referral code to help the project.
|
|
||||||
* @return a URL to Kayak's hotel page.
|
* @return a URL to Kayak's hotel page.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static native String nativeGetKayakHotelLink(@NonNull String countryIsoCode, @NonNull String uri,
|
public static native String nativeGetKayakHotelLink(@NonNull String countryIsoCode, @NonNull String uri,
|
||||||
long firstDaySec, long lastDaySec, boolean isReferral);
|
long firstDaySec, long lastDaySec);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1726,7 +1726,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
||||||
|
|
||||||
public void openKayakLink(@NonNull String url)
|
public void openKayakLink(@NonNull String url)
|
||||||
{
|
{
|
||||||
if (Config.isKayakDisclaimerAccepted() || !Config.isKayakReferralAllowed())
|
if (Config.isKayakDisclaimerAccepted())
|
||||||
{
|
{
|
||||||
Utils.openUrl(this, url);
|
Utils.openUrl(this, url);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -13,7 +13,6 @@ import androidx.core.os.ParcelCompat;
|
||||||
import app.organicmaps.Framework;
|
import app.organicmaps.Framework;
|
||||||
import app.organicmaps.routing.RoutePointInfo;
|
import app.organicmaps.routing.RoutePointInfo;
|
||||||
import app.organicmaps.search.Popularity;
|
import app.organicmaps.search.Popularity;
|
||||||
import app.organicmaps.util.Config;
|
|
||||||
import app.organicmaps.util.Utils;
|
import app.organicmaps.util.Utils;
|
||||||
import app.organicmaps.widget.placepage.PlacePageData;
|
import app.organicmaps.widget.placepage.PlacePageData;
|
||||||
|
|
||||||
|
@ -292,8 +291,7 @@ public class MapObject implements PlacePageData
|
||||||
final Instant firstDay = Instant.now();
|
final Instant firstDay = Instant.now();
|
||||||
final long firstDaySec = firstDay.getEpochSecond();
|
final long firstDaySec = firstDay.getEpochSecond();
|
||||||
final long lastDaySec = firstDay.plus(1, ChronoUnit.DAYS).getEpochSecond();
|
final long lastDaySec = firstDay.plus(1, ChronoUnit.DAYS).getEpochSecond();
|
||||||
final boolean isReferral = Config.isKayakReferralAllowed();
|
final String res = Framework.nativeGetKayakHotelLink(Utils.getCountryCode(), uri, firstDaySec, lastDaySec);
|
||||||
final String res = Framework.nativeGetKayakHotelLink(Utils.getCountryCode(), uri, firstDaySec, lastDaySec, isReferral);
|
|
||||||
return res == null ? "" : res;
|
return res == null ? "" : res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -229,11 +229,6 @@ public final class Config
|
||||||
setBool(KEY_MISC_KAYAK_ACCEPTED);
|
setBool(KEY_MISC_KAYAK_ACCEPTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isKayakReferralAllowed()
|
|
||||||
{
|
|
||||||
return !isFdroid();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isLocationRequested()
|
public static boolean isLocationRequested()
|
||||||
{
|
{
|
||||||
return getBool(KEY_MISC_LOCATION_REQUESTED);
|
return getBool(KEY_MISC_LOCATION_REQUESTED);
|
||||||
|
|
|
@ -88,7 +88,7 @@ const map<string, string> KAYAK_DOMAINS = {
|
||||||
|
|
||||||
string GetKayakHotelURL(const string & countryIsoCode, uint64_t kayakHotelId,
|
string GetKayakHotelURL(const string & countryIsoCode, uint64_t kayakHotelId,
|
||||||
const string & kayakHotelName, uint64_t kayakCityId,
|
const string & kayakHotelName, uint64_t kayakCityId,
|
||||||
time_t firstDay, time_t lastDay, bool isReferral)
|
time_t firstDay, time_t lastDay)
|
||||||
{
|
{
|
||||||
// https://www.kayak.com.tr/hotels/Elexus-Hotel-Resort--Spa--Casino,Kyrenia-c7163-h2651619-details/2023-10-03/2023-10-04/1adults
|
// https://www.kayak.com.tr/hotels/Elexus-Hotel-Resort--Spa--Casino,Kyrenia-c7163-h2651619-details/2023-10-03/2023-10-04/1adults
|
||||||
|
|
||||||
|
@ -97,8 +97,7 @@ string GetKayakHotelURL(const string & countryIsoCode, uint64_t kayakHotelId,
|
||||||
url << "https://";
|
url << "https://";
|
||||||
auto const it = KAYAK_DOMAINS.find(countryIsoCode);
|
auto const it = KAYAK_DOMAINS.find(countryIsoCode);
|
||||||
url << ((it == KAYAK_DOMAINS.end()) ? KAYAK_DOMAINS.find("US")->second : it->second);
|
url << ((it == KAYAK_DOMAINS.end()) ? KAYAK_DOMAINS.find("US")->second : it->second);
|
||||||
if (isReferral)
|
url << "/in?" << "a=" << KAYAK_AFFILIATE << "&url=";
|
||||||
url << "/in?" << "a=" << KAYAK_AFFILIATE << "&url=";
|
|
||||||
url << "/hotels/";
|
url << "/hotels/";
|
||||||
url << url::Slug(kayakHotelName) << ",";
|
url << url::Slug(kayakHotelName) << ",";
|
||||||
url << "-c" << kayakCityId << "-h" << kayakHotelId << "-details";
|
url << "-c" << kayakCityId << "-h" << kayakHotelId << "-details";
|
||||||
|
@ -115,7 +114,7 @@ string GetKayakHotelURL(const string & countryIsoCode, uint64_t kayakHotelId,
|
||||||
}
|
}
|
||||||
|
|
||||||
string GetKayakHotelURLFromURI(const string & countryIsoCode, const string & uri,
|
string GetKayakHotelURLFromURI(const string & countryIsoCode, const string & uri,
|
||||||
time_t firstDay, time_t lastDay, bool isReferral)
|
time_t firstDay, time_t lastDay)
|
||||||
{
|
{
|
||||||
// Elexus Hotel Resort & Spa & Casino,-c7163-h1696321580
|
// Elexus Hotel Resort & Spa & Casino,-c7163-h1696321580
|
||||||
|
|
||||||
|
@ -134,7 +133,7 @@ string GetKayakHotelURLFromURI(const string & countryIsoCode, const string & uri
|
||||||
!to_uint64(uri.substr(c + 3, h - c - 3).c_str(), kayakCityId))
|
!to_uint64(uri.substr(c + 3, h - c - 3).c_str(), kayakCityId))
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
return GetKayakHotelURL(countryIsoCode, kayakHotelId, kayakHotelName, kayakCityId, firstDay, lastDay, isReferral);
|
return GetKayakHotelURL(countryIsoCode, kayakHotelId, kayakHotelName, kayakCityId, firstDay, lastDay);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace osm
|
} // namespace osm
|
||||||
|
|
|
@ -8,8 +8,8 @@ namespace osm {
|
||||||
|
|
||||||
std::string GetKayakHotelURL(const std::string & countryIsoCode, uint64_t kayakHotelId,
|
std::string GetKayakHotelURL(const std::string & countryIsoCode, uint64_t kayakHotelId,
|
||||||
const std::string & kayakHotelName, uint64_t kayakCityId,
|
const std::string & kayakHotelName, uint64_t kayakCityId,
|
||||||
time_t firstDay, time_t lastDay, bool isReferral = true);
|
time_t firstDay, time_t lastDay);
|
||||||
|
|
||||||
std::string GetKayakHotelURLFromURI(const std::string & countryIsoCode, const std::string & uri,
|
std::string GetKayakHotelURLFromURI(const std::string & countryIsoCode, const std::string & uri,
|
||||||
time_t firstDay, time_t lastDay, bool isReferral = true);
|
time_t firstDay, time_t lastDay);
|
||||||
} // namespace osm
|
} // namespace osm
|
||||||
|
|
Loading…
Add table
Reference in a new issue