[F-Droid] Remove a referral code from “Photos, reviews, booking” #7262

Merged
root merged 1 commit from rt-android-fdroid-links into master 2024-01-29 06:45:46 +00:00
7 changed files with 23 additions and 12 deletions

View file

@ -1903,7 +1903,7 @@ Java_app_organicmaps_Framework_nativeMemoryWarning(JNIEnv *, jclass)
JNIEXPORT jstring JNICALL
Java_app_organicmaps_Framework_nativeGetKayakHotelLink(JNIEnv * env, jclass, jstring countryIsoCode, jstring uri,
jobject firstDay, jobject lastDay)
jobject firstDay, jobject lastDay, jboolean isReferral)
{
static jmethodID dateGetTime = jni::GetMethodID(env, firstDay, "getTime", "()J");
jlong firstDaySec = env->CallLongMethod(firstDay, dateGetTime) / 1000L;
@ -1912,7 +1912,8 @@ Java_app_organicmaps_Framework_nativeGetKayakHotelLink(JNIEnv * env, jclass, jst
string const url = osm::GetKayakHotelURLFromURI(jni::ToNativeString(env, countryIsoCode),
jni::ToNativeString(env, uri),
static_cast<time_t>(firstDaySec),
static_cast<time_t>(lastDaySec));
static_cast<time_t>(lastDaySec),
isReferral);
return url.empty() ? nullptr : jni::ToJavaString(env, url);
}

View file

@ -445,9 +445,11 @@ public class Framework
* @param uri `$HOTEL_NAME,-c$CITY_ID-h$HOTEL_ID` URI.
* @param startDay the first day of planned stay.
* @param lastDay the last day of planned stay.
* @param isReferral enable referral code to help the project.
* @return a URL to Kayak's hotel page.
*/
@Nullable
public static native String nativeGetKayakHotelLink(@NonNull String countryIsoCode, @NonNull String uri,
@NonNull Date firstDay, @NonNull Date lastDay);
@NonNull Date firstDay, @NonNull Date lastDay,
boolean isReferral);
}

View file

@ -1639,7 +1639,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
public void openKayakLink(@NonNull String url)
{
if (Config.isKayakDisclaimerAccepted())
if (Config.isKayakDisclaimerAccepted() || !Config.isKayakReferralAllowed())
{
Utils.openUrl(this, url);
return;

View file

@ -12,6 +12,7 @@ import androidx.core.os.ParcelCompat;
import app.organicmaps.Framework;
import app.organicmaps.routing.RoutePointInfo;
import app.organicmaps.search.Popularity;
import app.organicmaps.util.Config;
import app.organicmaps.util.Utils;
import app.organicmaps.widget.placepage.PlacePageData;
@ -288,7 +289,8 @@ public class MapObject implements PlacePageData
return "";
final Date firstDay = new Date();
final Date lastDay = new Date(firstDay.getTime() + (1000 * 60 * 60 * 24));
final String res = Framework.nativeGetKayakHotelLink(Utils.getCountryCode(), uri, firstDay, lastDay);
final boolean isReferral = Config.isKayakReferralAllowed();
final String res = Framework.nativeGetKayakHotelLink(Utils.getCountryCode(), uri, firstDay, lastDay, isReferral);
return res == null ? "" : res;
}

View file

@ -228,6 +228,12 @@ public final class Config
setBool(KEY_MISC_KAYAK_ACCEPTED);
}
@SuppressWarnings("ConstantConditions") // BuildConfig
public static boolean isKayakReferralAllowed()
{
return !BuildConfig.FLAVOR.equals("fdroid");
}
public static boolean isLocationRequested()
{
return getBool(KEY_MISC_LOCATION_REQUESTED);
@ -357,7 +363,6 @@ public final class Config
return url;
}
@NonNull
@SuppressWarnings("ConstantConditions") // BuildConfig
public static boolean isOsmLoginEnabled(@NonNull Context context)
{

View file

@ -88,7 +88,7 @@ const map<string, string> KAYAK_DOMAINS = {
string GetKayakHotelURL(const string & countryIsoCode, uint64_t kayakHotelId,
const string & kayakHotelName, uint64_t kayakCityId,
time_t firstDay, time_t lastDay)
time_t firstDay, time_t lastDay, bool isReferral)
{
// https://www.kayak.com.tr/hotels/Elexus-Hotel-Resort--Spa--Casino,Kyrenia-c7163-h2651619-details/2023-10-03/2023-10-04/1adults
@ -97,7 +97,8 @@ string GetKayakHotelURL(const string & countryIsoCode, uint64_t kayakHotelId,
url << "https://";
auto const it = KAYAK_DOMAINS.find(countryIsoCode);
url << ((it == KAYAK_DOMAINS.end()) ? KAYAK_DOMAINS.find("US")->second : it->second);
url << "/in?" << "a=" << KAYAK_AFFILIATE << "&url=";
if (isReferral)
url << "/in?" << "a=" << KAYAK_AFFILIATE << "&url=";
url << "/hotels/";
url << url::Slug(kayakHotelName) << ",";
url << "-c" << kayakCityId << "-h" << kayakHotelId << "-details";
@ -114,7 +115,7 @@ string GetKayakHotelURL(const string & countryIsoCode, uint64_t kayakHotelId,
}
string GetKayakHotelURLFromURI(const string & countryIsoCode, const string & uri,
time_t firstDay, time_t lastDay)
time_t firstDay, time_t lastDay, bool isReferral)
{
// Elexus Hotel Resort & Spa & Casino,-c7163-h1696321580
@ -133,7 +134,7 @@ string GetKayakHotelURLFromURI(const string & countryIsoCode, const string & uri
!to_uint64(uri.substr(c + 3, h - c - 3).c_str(), kayakCityId))
return {};
return GetKayakHotelURL(countryIsoCode, kayakHotelId, kayakHotelName, kayakCityId, firstDay, lastDay);
return GetKayakHotelURL(countryIsoCode, kayakHotelId, kayakHotelName, kayakCityId, firstDay, lastDay, isReferral);
}
} // namespace osm

View file

@ -8,8 +8,8 @@ namespace osm {
std::string GetKayakHotelURL(const std::string & countryIsoCode, uint64_t kayakHotelId,
const std::string & kayakHotelName, uint64_t kayakCityId,
time_t firstDay, time_t lastDay);
time_t firstDay, time_t lastDay, bool isReferral = true);
Review

Looks like default values are never used?

Looks like default values are never used?
Review

Used by tests and iOS.

Used by tests and iOS.
std::string GetKayakHotelURLFromURI(const std::string & countryIsoCode, const std::string & uri,
time_t firstDay, time_t lastDay);
time_t firstDay, time_t lastDay, bool isReferral = true);
} // namespace osm