mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-26 07:43:36 +00:00
[android][ios] Remove Kayak links
Signed-off-by: Harry bond <me@hbond.xyz>
This commit is contained in:
committed by
Konstantin Pastbin
parent
017a5c6cab
commit
70ed37b648
@@ -465,17 +465,6 @@ public class Framework
|
||||
|
||||
public static native void nativeMemoryWarning();
|
||||
|
||||
/**
|
||||
* @param countryIsoCode Two-letter ISO country code to use country-specific Kayak.com domain.
|
||||
* @param uri `$HOTEL_NAME,-c$CITY_ID-h$HOTEL_ID` URI.
|
||||
* @param firstDaySec the epoch seconds of the first day of planned stay.
|
||||
* @param lastDaySec the epoch seconds of the last day of planned stay.
|
||||
* @return a URL to Kayak's hotel page.
|
||||
*/
|
||||
@Nullable
|
||||
public static native String nativeGetKayakHotelLink(@NonNull String countryIsoCode, @NonNull String uri,
|
||||
long firstDaySec, long lastDaySec);
|
||||
|
||||
public static native boolean nativeShouldShowProducts();
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -1742,33 +1742,6 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
||||
return false;
|
||||
}
|
||||
|
||||
public void openKayakLink(@NonNull String url)
|
||||
{
|
||||
// The disclaimer is not needed if a user had explicitly opted-in via the setting.
|
||||
if (Config.isKayakDisclaimerAccepted() || Config.isKayakDisplayEnabled())
|
||||
{
|
||||
Utils.openUrl(this, url);
|
||||
return;
|
||||
}
|
||||
|
||||
dismissAlertDialog();
|
||||
mAlertDialog = new MaterialAlertDialogBuilder(this, R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(R.string.how_to_support_us)
|
||||
.setMessage(R.string.dialog_kayak_disclaimer)
|
||||
.setCancelable(true)
|
||||
.setPositiveButton(R.string.dialog_kayak_button, (dlg, which) -> {
|
||||
Config.acceptKayakDisclaimer();
|
||||
Utils.openUrl(this, url);
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setNeutralButton(R.string.dialog_kayak_disable_button, (dlg, which) -> {
|
||||
Config.setKayakDisplay(false);
|
||||
UiUtils.hide(findViewById(R.id.ll__place_kayak));
|
||||
})
|
||||
.setOnDismissListener(dialog -> mAlertDialog = null)
|
||||
.show();
|
||||
}
|
||||
|
||||
private boolean showStartPointNotice()
|
||||
{
|
||||
final RoutingController controller = RoutingController.get();
|
||||
|
||||
@@ -282,19 +282,6 @@ public class MapObject implements PlacePageData
|
||||
return website;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getKayakUrl()
|
||||
{
|
||||
final String uri = getMetadata(Metadata.MetadataType.FMD_EXTERNAL_URI);
|
||||
if (TextUtils.isEmpty(uri))
|
||||
return "";
|
||||
final Instant firstDay = Instant.now();
|
||||
final long firstDaySec = firstDay.getEpochSecond();
|
||||
final long lastDaySec = firstDay.plus(1, ChronoUnit.DAYS).getEpochSecond();
|
||||
final String res = Framework.nativeGetKayakHotelLink(Utils.getCountryCode(), uri, firstDaySec, lastDaySec);
|
||||
return res == null ? "" : res;
|
||||
}
|
||||
|
||||
public String getApiId()
|
||||
{
|
||||
return mApiId;
|
||||
|
||||
@@ -66,7 +66,6 @@ public class SettingsPrefsFragment extends BaseXmlSettingsFragment implements La
|
||||
initPowerManagementPrefsCallbacks();
|
||||
initPlayServicesPrefsCallbacks();
|
||||
initSearchPrivacyPrefsCallbacks();
|
||||
initDisplayKayakPrefsCallbacks();
|
||||
initScreenSleepEnabledPrefsCallbacks();
|
||||
initShowOnLockScreenPrefsCallbacks();
|
||||
}
|
||||
@@ -304,21 +303,6 @@ public class SettingsPrefsFragment extends BaseXmlSettingsFragment implements La
|
||||
});
|
||||
}
|
||||
|
||||
private void initDisplayKayakPrefsCallbacks()
|
||||
{
|
||||
final TwoStatePreference pref = getPreference(getString(R.string.pref_display_kayak));
|
||||
|
||||
pref.setChecked(Config.isKayakDisplayEnabled());
|
||||
pref.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
final boolean oldVal = Config.isKayakDisplayEnabled();
|
||||
final boolean newVal = (Boolean) newValue;
|
||||
if (oldVal != newVal)
|
||||
Config.setKayakDisplay(newVal);
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private void init3dModePrefsCallbacks()
|
||||
{
|
||||
final TwoStatePreference pref = getPreference(getString(R.string.pref_3d_buildings));
|
||||
|
||||
@@ -20,8 +20,6 @@ public final class Config
|
||||
private static final String KEY_PREF_USE_GS = "UseGoogleServices";
|
||||
|
||||
private static final String KEY_MISC_DISCLAIMER_ACCEPTED = "IsDisclaimerApproved";
|
||||
private static final String KEY_PREF_KAYAK_DISPLAY = "DisplayKayak";
|
||||
private static final String KEY_MISC_KAYAK_ACCEPTED = "IsKayakApproved";
|
||||
private static final String KEY_MISC_LOCATION_REQUESTED = "LocationRequested";
|
||||
private static final String KEY_MISC_UI_THEME = "UiTheme";
|
||||
private static final String KEY_MISC_UI_THEME_SETTINGS = "UiThemeSettings";
|
||||
@@ -220,28 +218,6 @@ public final class Config
|
||||
setBool(KEY_MISC_DISCLAIMER_ACCEPTED);
|
||||
}
|
||||
|
||||
public static boolean isKayakDisplayEnabled()
|
||||
{
|
||||
// Kayak is disabled by default in F-Droid build,
|
||||
// unless a user has already accepted its disclaimer before.
|
||||
return getBool(KEY_PREF_KAYAK_DISPLAY, !isFdroid() || isKayakDisclaimerAccepted());
|
||||
}
|
||||
|
||||
public static void setKayakDisplay(boolean enabled)
|
||||
{
|
||||
setBool(KEY_PREF_KAYAK_DISPLAY, enabled);
|
||||
}
|
||||
|
||||
public static boolean isKayakDisclaimerAccepted()
|
||||
{
|
||||
return getBool(KEY_MISC_KAYAK_ACCEPTED);
|
||||
}
|
||||
|
||||
public static void acceptKayakDisclaimer()
|
||||
{
|
||||
setBool(KEY_MISC_KAYAK_ACCEPTED);
|
||||
}
|
||||
|
||||
public static boolean isLocationRequested()
|
||||
{
|
||||
return getBool(KEY_MISC_LOCATION_REQUESTED);
|
||||
|
||||
@@ -46,7 +46,6 @@ public class PlacePageLinksFragment extends Fragment implements Observer<MapObje
|
||||
private View mLinePage;
|
||||
private TextView mTvLinePage;
|
||||
|
||||
private View mKayak;
|
||||
private View mWebsite;
|
||||
private TextView mTvWebsite;
|
||||
private View mWebsiteMenu;
|
||||
@@ -76,7 +75,6 @@ public class PlacePageLinksFragment extends Fragment implements Observer<MapObje
|
||||
{
|
||||
return switch (type)
|
||||
{
|
||||
case FMD_EXTERNAL_URI -> mMapObject.getKayakUrl();
|
||||
case FMD_WEBSITE ->
|
||||
mMapObject.getWebsiteUrl(false /* strip */, Metadata.MetadataType.FMD_WEBSITE);
|
||||
case FMD_WEBSITE_MENU ->
|
||||
@@ -105,20 +103,6 @@ public class PlacePageLinksFragment extends Fragment implements Observer<MapObje
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
mFrame = view;
|
||||
|
||||
mKayak = mFrame.findViewById(R.id.ll__place_kayak);
|
||||
mKayak.setOnClickListener((v) -> {
|
||||
final String url = mMapObject.getKayakUrl();
|
||||
final MwmActivity activity = (MwmActivity) requireActivity();
|
||||
if (!TextUtils.isEmpty(url))
|
||||
activity.openKayakLink(url);
|
||||
});
|
||||
mKayak.setOnLongClickListener((v) -> {
|
||||
final String url = mMapObject.getKayakUrl();
|
||||
if (!TextUtils.isEmpty(url))
|
||||
PlacePageUtils.copyToClipboard(requireContext(), mFrame, url);
|
||||
return true;
|
||||
});
|
||||
|
||||
mWebsite = mFrame.findViewById(R.id.ll__place_website);
|
||||
mTvWebsite = mFrame.findViewById(R.id.tv__place_website);
|
||||
mWebsite.setOnClickListener((v) -> openUrl(Metadata.MetadataType.FMD_WEBSITE));
|
||||
@@ -224,9 +208,6 @@ public class PlacePageLinksFragment extends Fragment implements Observer<MapObje
|
||||
|
||||
final String line = mMapObject.getMetadata(Metadata.MetadataType.FMD_CONTACT_LINE);
|
||||
refreshMetadataOrHide(line, mLinePage, mTvLinePage);
|
||||
|
||||
final String kayak = Config.isKayakDisplayEnabled() ? mMapObject.getKayakUrl() : null;
|
||||
UiUtils.showIf(!TextUtils.isEmpty(kayak), mKayak);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user