Make Wikivoyage available only for OsmAnd+
This commit is contained in:
parent
fcc8297cc6
commit
35bc92244f
6 changed files with 50 additions and 39 deletions
|
@ -78,20 +78,20 @@
|
|||
<Button
|
||||
android:id="@+id/button_action"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="33dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
android:background="@drawable/buy_btn_background_light"
|
||||
android:minWidth="40dp"
|
||||
android:paddingLeft="18dp"
|
||||
android:paddingRight="18dp"
|
||||
android:minWidth="@dimen/list_header_height"
|
||||
android:minHeight="@dimen/list_content_padding_large"
|
||||
android:paddingLeft="@dimen/bottom_sheet_exit_button_margin"
|
||||
android:paddingRight="@dimen/bottom_sheet_exit_button_margin"
|
||||
android:text="@string/get_plugin"
|
||||
android:textColor="@color/buy_button_color"
|
||||
android:textColor="@color/text_color_tab_active_light"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
android:paddingEnd="18dp"
|
||||
android:paddingStart="18dp" />
|
||||
android:paddingEnd="@dimen/bottom_sheet_exit_button_margin"
|
||||
android:paddingStart="@dimen/bottom_sheet_exit_button_margin" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -94,13 +94,13 @@
|
|||
android:layout_marginRight="@dimen/list_header_padding"
|
||||
android:minWidth="@dimen/list_header_height"
|
||||
android:minHeight="@dimen/list_content_padding_large"
|
||||
android:paddingStart="@dimen/context_menu_progress_padding_left"
|
||||
android:paddingLeft="@dimen/context_menu_progress_padding_left"
|
||||
android:paddingEnd="@dimen/context_menu_progress_padding_left"
|
||||
android:paddingRight="@dimen/context_menu_progress_padding_left"
|
||||
android:paddingStart="@dimen/bottom_sheet_exit_button_margin"
|
||||
android:paddingLeft="@dimen/bottom_sheet_exit_button_margin"
|
||||
android:paddingEnd="@dimen/bottom_sheet_exit_button_margin"
|
||||
android:paddingRight="@dimen/bottom_sheet_exit_button_margin"
|
||||
android:text="@string/buy"
|
||||
android:textColor="@color/text_color_tab_active_light"
|
||||
android:visibility="gone" />
|
||||
android:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -322,7 +322,8 @@ public class ItemViewHolder {
|
|||
clickAction = RightButtonAction.ASK_FOR_SRTM_PLUGIN_ENABLE;
|
||||
}
|
||||
|
||||
} else if (indexItem.getType() == DownloadActivityType.WIKIPEDIA_FILE
|
||||
} else if ((indexItem.getType() == DownloadActivityType.WIKIPEDIA_FILE
|
||||
|| indexItem.getType() == DownloadActivityType.TRAVEL_FILE)
|
||||
&& !Version.isPaidVersion(context.getMyApplication())) {
|
||||
clickAction = RightButtonAction.ASK_FOR_FULL_VERSION_PURCHASE;
|
||||
} else if (indexItem.getType() == DownloadActivityType.DEPTH_CONTOUR_FILE && !depthContoursPurchased) {
|
||||
|
|
|
@ -156,7 +156,7 @@ public class ExploreRvAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
|
||||
public void addNeededMapsCard(TravelNeededMapsCard card) {
|
||||
this.neededMapsCard = card;
|
||||
if (neededMapsCardExists(getNeededMapsCardPosition())) {
|
||||
if (isCardExists(getNeededMapsCardPosition(), TravelNeededMapsCard.TYPE)) {
|
||||
updateNeededMapsCard(false);
|
||||
} else if (addItem(getNeededMapsCardPosition(), card)) {
|
||||
notifyDataSetChanged();
|
||||
|
@ -164,15 +164,15 @@ public class ExploreRvAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
}
|
||||
|
||||
public void updateNeededMapsCard(boolean onlyProgress) {
|
||||
if(onlyProgress) {
|
||||
if (onlyProgress) {
|
||||
TravelNeededMapsCard nd = this.neededMapsCard;
|
||||
if(nd != null) {
|
||||
if (nd != null) {
|
||||
nd.updateView();
|
||||
}
|
||||
return;
|
||||
}
|
||||
int pos = getNeededMapsCardPosition();
|
||||
if (neededMapsCardExists(pos)) {
|
||||
if (isCardExists(pos, TravelNeededMapsCard.TYPE)) {
|
||||
notifyItemChanged(pos);
|
||||
}
|
||||
}
|
||||
|
@ -180,42 +180,39 @@ public class ExploreRvAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
public void removeNeededMapsCard() {
|
||||
this.neededMapsCard = null;
|
||||
int pos = getNeededMapsCardPosition();
|
||||
if (neededMapsCardExists(pos)) {
|
||||
if (isCardExists(pos, TravelNeededMapsCard.TYPE)) {
|
||||
removeItem(pos);
|
||||
notifyItemRemoved(pos);
|
||||
}
|
||||
}
|
||||
|
||||
private int getNeededMapsCardPosition() {
|
||||
if (downloadUpdateCardExists(FIRST_POSITION)) {
|
||||
if (isCardExists(FIRST_POSITION, TravelDownloadUpdateCard.TYPE)) {
|
||||
return SECOND_POSITION;
|
||||
}
|
||||
return FIRST_POSITION;
|
||||
}
|
||||
|
||||
private boolean neededMapsCardExists(int position) {
|
||||
return items.size() > position && items.get(position).getCardType() == TravelNeededMapsCard.TYPE;
|
||||
}
|
||||
|
||||
public void addDownloadUpdateCard(TravelDownloadUpdateCard card) {
|
||||
this.downloadCard = card;
|
||||
if (downloadUpdateCardExists(getDownloadUpdateCardPosition())) {
|
||||
int pos = getDownloadUpdateCardPosition();
|
||||
if (isCardExists(pos, TravelDownloadUpdateCard.TYPE)) {
|
||||
updateDownloadUpdateCard(false);
|
||||
} else if (addItem(getDownloadUpdateCardPosition(), card)) {
|
||||
} else if (addItem(pos, card)) {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateDownloadUpdateCard(boolean onlyProgress) {
|
||||
if(onlyProgress) {
|
||||
if (onlyProgress) {
|
||||
TravelDownloadUpdateCard dc = this.downloadCard;
|
||||
if(dc != null) {
|
||||
if (dc != null) {
|
||||
dc.updateView();
|
||||
}
|
||||
return;
|
||||
}
|
||||
int pos = getDownloadUpdateCardPosition();
|
||||
if (downloadUpdateCardExists(pos)) {
|
||||
if (isCardExists(pos, TravelDownloadUpdateCard.TYPE)) {
|
||||
notifyItemChanged(pos);
|
||||
}
|
||||
}
|
||||
|
@ -223,7 +220,7 @@ public class ExploreRvAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
public void removeDownloadUpdateCard() {
|
||||
this.downloadCard = null;
|
||||
int pos = getDownloadUpdateCardPosition();
|
||||
if (downloadUpdateCardExists(pos)) {
|
||||
if (isCardExists(pos, TravelDownloadUpdateCard.TYPE)) {
|
||||
removeItem(pos);
|
||||
notifyItemRemoved(pos);
|
||||
}
|
||||
|
@ -233,7 +230,7 @@ public class ExploreRvAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
return FIRST_POSITION;
|
||||
}
|
||||
|
||||
private boolean downloadUpdateCardExists(int position) {
|
||||
return items.size() > position && items.get(position).getCardType() == TravelDownloadUpdateCard.TYPE;
|
||||
private boolean isCardExists(int position, int cardType) {
|
||||
return items.size() > position && items.get(position).getCardType() == cardType;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -287,7 +287,8 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
|
|||
|
||||
@Override
|
||||
public void onIndexItemClick(IndexItem item) {
|
||||
if (item.getType() == DownloadActivityType.WIKIPEDIA_FILE && !Version.isPaidVersion(app)) {
|
||||
if ((item.getType() == DownloadActivityType.WIKIPEDIA_FILE
|
||||
|| item.getType() == DownloadActivityType.TRAVEL_FILE) && !Version.isPaidVersion(app)) {
|
||||
FragmentManager fm = getFragmentManager();
|
||||
if (fm != null) {
|
||||
ChoosePlanDialogFragment.showWikipediaInstance(fm);
|
||||
|
@ -342,7 +343,8 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
|
|||
|
||||
@Override
|
||||
public void onIndexItemClick(IndexItem item) {
|
||||
if (item.getType() == DownloadActivityType.WIKIPEDIA_FILE && !Version.isPaidVersion(app)) {
|
||||
if ((item.getType() == DownloadActivityType.WIKIPEDIA_FILE
|
||||
|| item.getType() == DownloadActivityType.TRAVEL_FILE) && !Version.isPaidVersion(app)) {
|
||||
FragmentManager fm = getFragmentManager();
|
||||
if (fm != null) {
|
||||
ChoosePlanDialogFragment.showWikipediaInstance(fm);
|
||||
|
|
|
@ -111,7 +111,7 @@ public class TravelNeededMapsCard extends BaseTravelCard {
|
|||
boolean downloading = downloadThread.isDownloading(item);
|
||||
boolean currentDownloading = downloading && downloadThread.getCurrentDownloadingItem() == item;
|
||||
boolean lastItem = i == items.size() - 1;
|
||||
View view = holder.itemsContainer.getChildAt(i);
|
||||
final View view = holder.itemsContainer.getChildAt(i);
|
||||
|
||||
if (item.isDownloaded()) {
|
||||
view.setOnClickListener(null);
|
||||
|
@ -131,12 +131,23 @@ public class TravelNeededMapsCard extends BaseTravelCard {
|
|||
if (item.isDownloaded()) {
|
||||
iconAction.setVisibility(View.GONE);
|
||||
buttonAction.setVisibility(View.GONE);
|
||||
|
||||
} else {
|
||||
boolean showBtn = !paidVersion && item.getType() == DownloadActivityType.WIKIPEDIA_FILE;
|
||||
boolean showBtn = !paidVersion
|
||||
&& (item.getType() == DownloadActivityType.WIKIPEDIA_FILE
|
||||
|| item.getType() == DownloadActivityType.TRAVEL_FILE);
|
||||
iconAction.setVisibility(showBtn ? View.GONE : View.VISIBLE);
|
||||
buttonAction.setVisibility(showBtn ? View.VISIBLE : View.GONE);
|
||||
if (!showBtn) {
|
||||
if (showBtn) {
|
||||
buttonAction.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
view.callOnClick();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
iconAction.setImageDrawable(downloading ? cancelIcon : downloadIcon);
|
||||
buttonAction.setOnClickListener(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,7 +189,7 @@ public class TravelNeededMapsCard extends BaseTravelCard {
|
|||
* @return true if button is visible, false otherwise.
|
||||
*/
|
||||
private boolean updateSecondaryButton(NeededMapsVH vh) {
|
||||
vh.secondaryBtnContainer.setVisibility(View.VISIBLE);
|
||||
vh.secondaryBtnContainer.setVisibility(Version.isPaidVersion(app) ? View.VISIBLE : View.GONE);
|
||||
vh.secondaryBtn.setText(isDownloading() ? R.string.shared_string_cancel : R.string.later);
|
||||
vh.secondaryBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -195,7 +206,7 @@ public class TravelNeededMapsCard extends BaseTravelCard {
|
|||
* @return true if button is visible, false otherwise.
|
||||
*/
|
||||
private boolean updatePrimaryButton(NeededMapsVH vh) {
|
||||
if (showPrimaryButton()) {
|
||||
if (showPrimaryButton() && Version.isPaidVersion(app)) {
|
||||
boolean enabled = isInternetAvailable();
|
||||
vh.primaryBtnContainer.setVisibility(View.VISIBLE);
|
||||
vh.primaryBtnContainer.setBackgroundResource(getPrimaryBtnBgRes(enabled));
|
||||
|
|
Loading…
Reference in a new issue