Merge pull request #5263 from osmandapp/WikivoyageExploreCards
add explore cards to wikivoyage
This commit is contained in:
commit
3d3b9fb9f3
10 changed files with 310 additions and 7 deletions
|
@ -6,9 +6,11 @@
|
|||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/shared_string_explore"/>
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="@dimen/map_markers_recycler_view_padding_bottom"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
68
OsmAnd/res/layout/wikivoyage_open_beta_card.xml
Normal file
68
OsmAnd/res/layout/wikivoyage_open_beta_card.xml
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="@dimen/list_content_padding"
|
||||
android:layout_marginTop="@dimen/list_content_padding"
|
||||
android:background="@drawable/travel_card_bg">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/background_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/welcome_to_open_beta"
|
||||
tools:src="@drawable/img_help_wikivoyage_articles" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/list_content_padding"
|
||||
android:layout_marginEnd="@dimen/list_content_padding"
|
||||
android:layout_marginLeft="@dimen/list_content_padding"
|
||||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
android:layout_marginStart="@dimen/list_content_padding"
|
||||
android:layout_marginTop="@dimen/bottom_sheet_icon_margin"
|
||||
tools:text="@string/welcome_to_open_beta" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/list_content_padding"
|
||||
android:layout_marginEnd="@dimen/list_content_padding"
|
||||
android:layout_marginLeft="@dimen/list_content_padding"
|
||||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
android:layout_marginStart="@dimen/list_content_padding"
|
||||
tools:text="@string/welcome_to_open_beta_description" />
|
||||
|
||||
<View
|
||||
android:id="@+id/bottom_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/wikivoyage_card_divider_color" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/bottom_button_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/bottom_sheet_title_height"
|
||||
android:layout_gravity="center"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="@string/get_unlimited_access" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
79
OsmAnd/res/layout/wikivoyage_start_editing_card.xml
Normal file
79
OsmAnd/res/layout/wikivoyage_start_editing_card.xml
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="@dimen/list_content_padding"
|
||||
android:layout_marginTop="@dimen/list_content_padding"
|
||||
android:background="@drawable/travel_card_bg">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/wikivoyage_start_editing_image_background"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/list_content_padding"
|
||||
android:layout_marginEnd="@dimen/list_content_padding"
|
||||
android:layout_marginLeft="@dimen/list_content_padding"
|
||||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
android:layout_marginStart="@dimen/list_content_padding"
|
||||
android:layout_marginTop="42dp"
|
||||
android:layout_weight="1"
|
||||
android:textColor="@color/primary_text_dark"
|
||||
tools:text="@string/start_editing_card_image_text" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/background_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/wikivoyage_explore_card_image_height"
|
||||
android:contentDescription="@string/welcome_to_open_beta"
|
||||
android:src="@drawable/img_help_wikivoyage_contribute" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/list_content_padding"
|
||||
android:layout_marginEnd="@dimen/list_content_padding"
|
||||
android:layout_marginLeft="@dimen/list_content_padding"
|
||||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
android:layout_marginStart="@dimen/list_content_padding"
|
||||
android:layout_marginTop="@dimen/list_content_padding"
|
||||
tools:text="@string/start_editing_card_description" />
|
||||
|
||||
<View
|
||||
android:id="@+id/bottom_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/wikivoyage_card_divider_color" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/bottom_button_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/bottom_sheet_title_height"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="@string/start_editing" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -428,5 +428,6 @@
|
|||
<color name="wikivoyage_primary_text_light">#212121</color>
|
||||
<color name="wikivoyage_primary_text_dark">#cccccc</color>
|
||||
<color name="wikivoyage_secondary_text">#727272</color>
|
||||
<color name="wikivoyage_start_editing_image_background">#339966</color>
|
||||
|
||||
</resources>
|
|
@ -291,5 +291,7 @@
|
|||
<dimen name="wikivoyage_search_icon_margin_right">22dp</dimen>
|
||||
<dimen name="wikivoyage_search_divider_margin_start">64dp</dimen>
|
||||
|
||||
<dimen name="wikivoyage_explore_card_image_height">144dp</dimen>
|
||||
|
||||
<dimen name="text_button_letter_spacing" format="float">0.01</dimen>
|
||||
</resources>
|
|
@ -9,6 +9,12 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="start_editing_card_image_text">The free worldwide travel guide that anyone can edit.</string>
|
||||
<string name="welcome_to_open_beta_description">Travel is based on Wikivoyage. During open beta testing you have the opportunity to evaluate all the features for free. After the end of the beta period, Travel will be available to subscribers of OsmAnd Unlimited and the owners of OsmAnd+</string>
|
||||
<string name="start_editing_card_description">You can edit any article on Wikivoyage, and we hope that you do. We need your knowledge, your experience, your talent, and your attention</string>
|
||||
<string name="start_editing">Start editing</string>
|
||||
<string name="get_unlimited_access">Get unlimited access</string>
|
||||
<string name="welcome_to_open_beta">Welcome, to the open beta!</string>
|
||||
<string name="travel_guide">Travel Guide</string>
|
||||
<string name="travel_guide_description">Browse the Wikivoyage guides to the most interesting places on the planet inside OsmAnd without an internet connection.</string>
|
||||
<string name="monthly_map_updates">Map updates: <b>every month</b></string>
|
||||
|
@ -20,7 +26,7 @@
|
|||
<string name="purchase_subscription_title">Subscribe - %1$s</string>
|
||||
|
||||
<string name="wikivoyage_offline">Wikivoyage offline</string>
|
||||
|
||||
|
||||
<string name="unlimited_downloads">Unlimited downloads</string>
|
||||
<string name="wikipedia_offline">Wikipedia offline</string>
|
||||
<string name="contour_lines_sea_depth">Contour lines + Sea depth</string>
|
||||
|
|
|
@ -3,18 +3,41 @@ package net.osmand.plus.wikivoyage.explore;
|
|||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||
import net.osmand.plus.wikivoyage.explore.travelcards.BaseTravelCard;
|
||||
import net.osmand.plus.wikivoyage.explore.travelcards.OpenBetaTravelCard;
|
||||
import net.osmand.plus.wikivoyage.explore.travelcards.StartEditingTravelCard;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ExploreTabFragment extends BaseOsmAndFragment {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_explore_tab, container, false);
|
||||
OsmandApplication app = getMyApplication();
|
||||
boolean nightMode = !getSettings().isLightContent();
|
||||
|
||||
final View mainView = inflater.inflate(R.layout.fragment_explore_tab, container, false);
|
||||
|
||||
ArrayList<BaseTravelCard> items = new ArrayList<>();
|
||||
|
||||
OpenBetaTravelCard openBetaTravelCard = new OpenBetaTravelCard(app, nightMode, getFragmentManager());
|
||||
StartEditingTravelCard startEditingTravelCard = new StartEditingTravelCard(app, nightMode);
|
||||
items.add(openBetaTravelCard);
|
||||
items.add(startEditingTravelCard);
|
||||
|
||||
final RecyclerView rv = (RecyclerView) mainView.findViewById(R.id.recycler_view);
|
||||
rv.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
return mainView;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,4 +45,4 @@ public abstract class BaseTravelCard {
|
|||
protected Drawable getColoredIcon(@DrawableRes int icon, @ColorRes int color) {
|
||||
return app.getIconsCache().getIcon(icon, color);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package net.osmand.plus.wikivoyage.explore.travelcards;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.dialogs.ChoosePlanDialogFragment;
|
||||
|
||||
public class OpenBetaTravelCard extends BaseTravelCard {
|
||||
|
||||
private FragmentManager fragmentManager;
|
||||
|
||||
public OpenBetaTravelCard(OsmandApplication app, boolean nightMode, FragmentManager fragmentManager) {
|
||||
super(app, nightMode);
|
||||
this.fragmentManager = fragmentManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder) {
|
||||
if (viewHolder instanceof OpenBetaTravelVH) {
|
||||
final OpenBetaTravelVH holder = (OpenBetaTravelVH) viewHolder;
|
||||
holder.title.setText(R.string.welcome_to_open_beta);
|
||||
holder.description.setText(R.string.welcome_to_open_beta_description);
|
||||
holder.backgroundImage.setImageResource(R.drawable.img_help_wikivoyage_articles);
|
||||
holder.button.setText(R.string.get_unlimited_access);
|
||||
holder.button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ChoosePlanDialogFragment.showFreeVersionInstance(fragmentManager);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class OpenBetaTravelVH extends RecyclerView.ViewHolder {
|
||||
|
||||
final TextView title;
|
||||
final TextView description;
|
||||
final TextView button;
|
||||
final ImageView backgroundImage;
|
||||
|
||||
OpenBetaTravelVH(final View itemView) {
|
||||
super(itemView);
|
||||
title = (TextView) itemView.findViewById(R.id.title);
|
||||
description = (TextView) itemView.findViewById(R.id.description);
|
||||
button = (TextView) itemView.findViewById(R.id.bottom_button_text);
|
||||
backgroundImage = (ImageView) itemView.findViewById(R.id.background_image);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCardType() {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package net.osmand.plus.wikivoyage.explore.travelcards;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.customtabs.CustomTabsIntent;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
||||
public class StartEditingTravelCard extends BaseTravelCard {
|
||||
|
||||
public StartEditingTravelCard(OsmandApplication app, boolean nightMode) {
|
||||
super(app, nightMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder) {
|
||||
if (viewHolder instanceof StartEditingTravelVH) {
|
||||
final StartEditingTravelVH holder = (StartEditingTravelVH) viewHolder;
|
||||
holder.title.setText(R.string.start_editing_card_image_text);
|
||||
holder.description.setText(R.string.start_editing_card_description);
|
||||
holder.backgroundImage.setImageResource(R.drawable.img_help_wikivoyage_contribute);
|
||||
holder.button.setText(R.string.start_editing);
|
||||
holder.button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder()
|
||||
.setToolbarColor(ContextCompat.getColor(app, nightMode ? R.color.actionbar_dark_color : R.color.actionbar_light_color))
|
||||
.build();
|
||||
String text = "https://" + app.getLanguage().toLowerCase() + ".m.wikivoyage.org";
|
||||
customTabsIntent.launchUrl(app, Uri.parse(text));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class StartEditingTravelVH extends RecyclerView.ViewHolder {
|
||||
|
||||
final TextView title;
|
||||
final TextView description;
|
||||
final TextView button;
|
||||
final ImageView backgroundImage;
|
||||
|
||||
StartEditingTravelVH(final View itemView) {
|
||||
super(itemView);
|
||||
title = (TextView) itemView.findViewById(R.id.title);
|
||||
description = (TextView) itemView.findViewById(R.id.description);
|
||||
button = (TextView) itemView.findViewById(R.id.bottom_button_text);
|
||||
backgroundImage = (ImageView) itemView.findViewById(R.id.background_image);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCardType() {
|
||||
return 1;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue