mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-25 15:23:52 +00:00
[android] Drop products features on the place page
Signed-off-by: Jean-Baptiste Charron <jeanbaptiste.charron@outlook.fr>
This commit is contained in:
@@ -13,7 +13,6 @@ import app.organicmaps.api.RequestType;
|
||||
import app.organicmaps.bookmarks.data.DistanceAndAzimut;
|
||||
import app.organicmaps.bookmarks.data.FeatureId;
|
||||
import app.organicmaps.bookmarks.data.MapObject;
|
||||
import app.organicmaps.products.ProductsConfig;
|
||||
import app.organicmaps.sdk.routing.JunctionInfo;
|
||||
import app.organicmaps.sdk.routing.RouteMarkData;
|
||||
import app.organicmaps.sdk.routing.RouteMarkType;
|
||||
@@ -347,15 +346,5 @@ public class Framework
|
||||
public static native boolean nativeHasPlacePageInfo();
|
||||
|
||||
public static native void nativeMemoryWarning();
|
||||
|
||||
public static native boolean nativeShouldShowProducts();
|
||||
|
||||
@Nullable
|
||||
public static native ProductsConfig nativeGetProductsConfiguration();
|
||||
|
||||
public static native void nativeDidCloseProductsPopup(String reason);
|
||||
|
||||
public static native void nativeDidSelectProduct(String title, String link);
|
||||
|
||||
public static native void nativeSaveRoute();
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package app.organicmaps.products;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
// Called from JNI.
|
||||
@Keep
|
||||
@SuppressWarnings("unused")
|
||||
public class Product {
|
||||
@Nullable
|
||||
public String title;
|
||||
|
||||
@Nullable
|
||||
public String link;
|
||||
|
||||
public Product(@Nullable String title, @Nullable String link) {
|
||||
this.title = title;
|
||||
this.link = link;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package app.organicmaps.products;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
// Called from JNI.
|
||||
@Keep
|
||||
@SuppressWarnings("unused")
|
||||
public class ProductsConfig {
|
||||
public ProductsConfig(@Nullable String placePagePrompt, @Nullable Product[] products) {
|
||||
this.placePagePrompt = placePagePrompt;
|
||||
this.products = products;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String placePagePrompt;
|
||||
|
||||
@Nullable
|
||||
public Product[] products;
|
||||
}
|
||||
@@ -56,13 +56,5 @@ public final class Constants
|
||||
public static final String XIAOMI = "XIAOMI";
|
||||
}
|
||||
|
||||
public static class ProductsPopupCloseReason
|
||||
{
|
||||
public static final String CLOSE = "close";
|
||||
public static final String REMIND_LATER = "remind_later";
|
||||
public static final String ALREADY_DONATED = "already_donated";
|
||||
public static final String SELECT_PRODUCT = "select_product";
|
||||
}
|
||||
|
||||
private Constants() {}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,6 @@ public class PlacePageView extends Fragment implements View.OnClickListener,
|
||||
{
|
||||
private static final String PREF_COORDINATES_FORMAT = "coordinates_format";
|
||||
private static final String BOOKMARK_FRAGMENT_TAG = "BOOKMARK_FRAGMENT_TAG";
|
||||
private static final String PRODUCTS_FRAGMENT_TAG = "PRODUCTS_FRAGMENT_TAG";
|
||||
private static final String WIKIPEDIA_FRAGMENT_TAG = "WIKIPEDIA_FRAGMENT_TAG";
|
||||
private static final String PHONE_FRAGMENT_TAG = "PHONE_FRAGMENT_TAG";
|
||||
private static final String OPENING_HOURS_FRAGMENT_TAG = "OPENING_HOURS_FRAGMENT_TAG";
|
||||
@@ -391,18 +390,6 @@ public class PlacePageView extends Fragment implements View.OnClickListener,
|
||||
updateViewFragment(PlacePageWikipediaFragment.class, WIKIPEDIA_FRAGMENT_TAG, R.id.place_page_wikipedia_fragment, hasWikipediaEntry());
|
||||
}
|
||||
|
||||
// private boolean hasProductsEntry()
|
||||
// {
|
||||
// return Framework.nativeShouldShowProducts();
|
||||
// }
|
||||
|
||||
// private void updateProductsView()
|
||||
// {
|
||||
// var hasProductsEntry = hasProductsEntry();
|
||||
//
|
||||
// updateViewFragment(PlacePageProductsFragment.class, PRODUCTS_FRAGMENT_TAG, R.id.place_page_products_fragment, hasProductsEntry);
|
||||
// }
|
||||
|
||||
private void setTextAndColorizeSubtitle()
|
||||
{
|
||||
String text = mMapObject.getSubtitle();
|
||||
@@ -493,7 +480,6 @@ public class PlacePageView extends Fragment implements View.OnClickListener,
|
||||
}
|
||||
updateLinksView();
|
||||
updateOpeningHoursView();
|
||||
//updateProductsView(); Disable begging message on placepage
|
||||
updateWikipediaView();
|
||||
updateBookmarkView();
|
||||
updatePhoneView();
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
package app.organicmaps.widget.placepage.sections;
|
||||
|
||||
import static androidx.core.util.ObjectsCompat.requireNonNull;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import app.organicmaps.Framework;
|
||||
import app.organicmaps.R;
|
||||
import app.organicmaps.products.Product;
|
||||
import app.organicmaps.products.ProductsConfig;
|
||||
import app.organicmaps.util.Constants;
|
||||
import app.organicmaps.util.UiUtils;
|
||||
import app.organicmaps.util.Utils;
|
||||
|
||||
public class PlacePageProductsFragment extends Fragment
|
||||
{
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
|
||||
{
|
||||
return inflater.inflate(R.layout.place_page_products_fragment, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
var config = Framework.nativeGetProductsConfiguration();
|
||||
if (config != null && isValidConfig(config))
|
||||
{
|
||||
UiUtils.show(view);
|
||||
|
||||
updateView(view, config);
|
||||
} else
|
||||
{
|
||||
UiUtils.hide(view);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateView(@NonNull View view, @NonNull ProductsConfig config)
|
||||
{
|
||||
var layoutInflater = LayoutInflater.from(view.getContext());
|
||||
|
||||
TextView productsPrompt = requireNonNull(view.findViewById(R.id.products_prompt));
|
||||
LinearLayout productsButtons = requireNonNull(view.findViewById(R.id.products_buttons));
|
||||
View closeButton = requireNonNull(view.findViewById(R.id.products_close));
|
||||
View productsRemindLater = requireNonNull(view.findViewById(R.id.products_remind_later));
|
||||
View alreadyDonated = requireNonNull(view.findViewById(R.id.products_already_donated));
|
||||
|
||||
productsPrompt.setText(config.placePagePrompt);
|
||||
|
||||
productsButtons.removeAllViews();
|
||||
|
||||
for (var product : Objects.requireNonNull(config.products))
|
||||
{
|
||||
var button = (Button) layoutInflater.inflate(R.layout.item_product, productsButtons, false);
|
||||
button.setText(product.title);
|
||||
button.setOnClickListener((v) -> {
|
||||
onProductSelected(product);
|
||||
});
|
||||
|
||||
productsButtons.addView(button);
|
||||
}
|
||||
|
||||
closeButton.setOnClickListener((v) -> {
|
||||
closeWithReason(view, Constants.ProductsPopupCloseReason.CLOSE);
|
||||
});
|
||||
|
||||
productsRemindLater.setOnClickListener((v) -> {
|
||||
closeWithReason(view, Constants.ProductsPopupCloseReason.REMIND_LATER);
|
||||
});
|
||||
|
||||
alreadyDonated.setOnClickListener((v) -> {
|
||||
closeWithReason(view, Constants.ProductsPopupCloseReason.ALREADY_DONATED);
|
||||
});
|
||||
}
|
||||
|
||||
private void closeWithReason(View view, String reason)
|
||||
{
|
||||
Framework.nativeDidCloseProductsPopup(reason);
|
||||
UiUtils.hide(view);
|
||||
}
|
||||
|
||||
private void onProductSelected(Product product)
|
||||
{
|
||||
Utils.openUrl(requireActivity(), product.link);
|
||||
Framework.nativeDidSelectProduct(product.title, product.link);
|
||||
}
|
||||
|
||||
private boolean isValidConfig(@NonNull ProductsConfig config)
|
||||
{
|
||||
return config.products != null && config.products.length > 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user