Add wikivoyage welcome screen

This commit is contained in:
Alex Sytnyk 2018-04-21 01:55:28 +03:00
parent b282190700
commit 727283c513
8 changed files with 172 additions and 2 deletions

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/wikivoyage_active_light"/>
<corners android:radius="3dp"/>
</shape>

View file

@ -0,0 +1,90 @@
<?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="match_parent"
android:layout_height="match_parent"
android:background="?attr/wikivoyage_welcome_bg_color"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/main_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/wikivoyage_welcome_image_top_margin"
tools:ignore="ContentDescription"
tools:src="@drawable/img_start_screen_travel_night"/>
<ImageView
android:id="@+id/back_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/content_padding"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/access_shared_string_navigate_up"
tools:src="@drawable/ic_arrow_back"/>
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/wikivoyage_welcome_content_margin"
android:layout_marginRight="@dimen/wikivoyage_welcome_content_margin"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/wikivoyage_welcome_title_bottom_margin"
android:layout_marginTop="@dimen/wikivoyage_welcome_title_top_margin"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:text="@string/travel_guide"
android:textColor="?attr/wikivoyage_primary_text_color"
android:textSize="@dimen/welcome_header_text_size"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:ellipsize="end"
android:text="@string/travel_guide_description"
android:textColor="@color/wikivoyage_secondary_text"
android:textSize="@dimen/default_list_text_size"/>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="@dimen/wikivoyage_welcome_content_margin"
android:layout_marginTop="@dimen/content_padding"
android:background="@drawable/wikivoyage_welcome_btn_bg">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/continue_button"
android:layout_width="wrap_content"
android:layout_height="@dimen/wikivoyage_card_button_height"
android:background="?attr/selectableItemBackgroundBorderless"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:text="@string/shared_string_continue"
android:textColor="@color/color_white"
android:textSize="@dimen/text_button_text_size"
osmand:typeface="@string/font_roboto_medium"/>
</FrameLayout>
</LinearLayout>
</LinearLayout>

View file

@ -202,4 +202,5 @@
<dimen name="wikivoyage_welcome_title_top_margin">30dp</dimen>
<dimen name="wikivoyage_welcome_title_bottom_margin">23dp</dimen>
<dimen name="wikivoyage_welcome_content_margin">48dp</dimen>
<dimen name="wikivoyage_card_button_height">54dp</dimen>
</resources>

View file

@ -285,6 +285,7 @@
<dimen name="wikivoyage_welcome_title_top_margin">20dp</dimen>
<dimen name="wikivoyage_welcome_title_bottom_margin">15dp</dimen>
<dimen name="wikivoyage_welcome_content_margin">32dp</dimen>
<dimen name="wikivoyage_card_button_height">36dp</dimen>
<dimen name="text_button_letter_spacing" format="float">0.01</dimen>
</resources>

View file

@ -9,6 +9,8 @@
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="travel_guide_description">Browse the Wikivoyage guides to the most interesting places on the planet inside OsmAnd without an internet connection.</string>
<string name="travel_guide">Travel Guide</string>
<string name="purchase_dialog_title">Choose plan</string>
<string name="purchase_dialog_travel_description">To read Travel articles offline, you need to purchase one of the following items.</string>
<string name="purchase_dialog_subtitle">Choose suitable item:</string>

View file

@ -717,6 +717,8 @@ public class OsmandSettings {
public final CommonPreference<Boolean> SHOW_LINES_TO_FIRST_MARKERS = new BooleanPreference("show_lines_to_first_markers", false).makeProfile();
public final CommonPreference<Boolean> SHOW_ARROWS_TO_FIRST_MARKERS = new BooleanPreference("show_arrows_to_first_markers", false).makeProfile();
public final CommonPreference<Boolean> WIKIVOYAGE_FIRST_ACCESS = new BooleanPreference("wikivoyage_first_access", true).makeGlobal();
public final CommonPreference<Boolean> WIKIVOYAGE_SHOW_IMAGES_ASKED = new BooleanPreference("wikivoyage_show_images_asked", false).makeGlobal();
public final CommonPreference<WikivoyageShowImages> WIKIVOYAGE_SHOW_IMAGES = new EnumIntPreference<>("wikivoyage_show_imgs", WikivoyageShowImages.OFF, WikivoyageShowImages.values()).makeGlobal();

View file

@ -62,6 +62,7 @@ import net.osmand.plus.views.BaseMapLayer;
import net.osmand.plus.views.MapControlsLayer;
import net.osmand.plus.views.MapTileLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.wikivoyage.WikivoyageWelcomeDialogFragment;
import net.osmand.plus.wikivoyage.explore.WikivoyageExploreDialogFragment;
import net.osmand.router.GeneralRouter;
@ -770,9 +771,13 @@ public class MapActivityActions implements DialogProvider {
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
getMyApplication().getTravelDbHelper().initTravelBooks();
MapActivity.clearPrevActivityIntent();
WikivoyageExploreDialogFragment.showInstance(mapActivity.getSupportFragmentManager());
if (settings.WIKIVOYAGE_FIRST_ACCESS.get()) {
WikivoyageWelcomeDialogFragment.showInstance(mapActivity.getSupportFragmentManager());
} else {
getMyApplication().getTravelDbHelper().initTravelBooks();
WikivoyageExploreDialogFragment.showInstance(mapActivity.getSupportFragmentManager());
}
return true;
}
}).createItem());

View file

@ -0,0 +1,60 @@
package net.osmand.plus.wikivoyage;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import net.osmand.plus.R;
import net.osmand.plus.wikivoyage.explore.WikivoyageExploreDialogFragment;
public class WikivoyageWelcomeDialogFragment extends WikivoyageBaseDialogFragment {
public static final String TAG = WikivoyageWelcomeDialogFragment.class.getSimpleName();
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View mainView = inflate(R.layout.fragment_wikivoyage_welcome_dialog, container);
ImageView backBtn = (ImageView) mainView.findViewById(R.id.back_button);
backBtn.setImageDrawable(getContentIcon(R.drawable.ic_arrow_back));
backBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
int imgId = nightMode ? R.drawable.img_start_screen_travel_night : R.drawable.img_start_screen_travel_day;
((ImageView) mainView.findViewById(R.id.main_image)).setImageResource(imgId);
mainView.findViewById(R.id.continue_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentActivity activity = getActivity();
if (activity != null) {
getMyApplication().getTravelDbHelper().initTravelBooks();
WikivoyageExploreDialogFragment.showInstance(activity.getSupportFragmentManager());
dismiss();
}
}
});
return mainView;
}
public static boolean showInstance(FragmentManager fm) {
try {
new WikivoyageWelcomeDialogFragment().show(fm, TAG);
return true;
} catch (RuntimeException e) {
return false;
}
}
}