Add bottom navigation view to the main wikivoyage screen

This commit is contained in:
Alex Sytnyk 2018-04-05 16:55:27 +03:00
parent ae6ef269b1
commit 93af1b763f
3 changed files with 97 additions and 57 deletions

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
@ -8,80 +9,103 @@
android:background="?attr/wikivoyage_bg_color"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/dashboard_map_toolbar"
android:minHeight="@dimen/dashboard_map_toolbar"
osmand:contentInsetLeft="54dp"
osmand:contentInsetStart="54dp">
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/dashboard_map_toolbar"
android:minHeight="@dimen/dashboard_map_toolbar"
osmand:contentInsetLeft="54dp"
osmand:contentInsetStart="54dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/toolbar_text"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:text="@string/shared_string_travel"
android:textColor="?attr/wikivoyage_app_bar_text_color"
android:textSize="@dimen/dialog_header_text_size"
osmand:typeface="@string/font_roboto_medium"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/options_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="@string/shared_string_options"
android:textAllCaps="true"
android:textColor="?attr/wikivoyage_active_color"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
<LinearLayout
android:id="@+id/search_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="@dimen/dashboard_map_toolbar"
android:background="?attr/bg_color"
android:gravity="center_vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/toolbar_text"
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_weight="1"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:text="@string/shared_string_travel"
android:textColor="?attr/wikivoyage_app_bar_text_color"
android:textSize="@dimen/dialog_header_text_size"
osmand:typeface="@string/font_roboto_medium"/>
android:text="@string/search_poi_category_hint"
android:textColor="?attr/searchbar_text_hint"
android:textSize="@dimen/default_list_text_size_large"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/options_button"
<ImageView
android:id="@+id/search_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="@string/shared_string_options"
android:textAllCaps="true"
android:textColor="?attr/wikivoyage_active_color"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium"/>
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:contentDescription="@string/shared_string_search"
tools:src="@drawable/ic_action_search_dark"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
<LinearLayout
android:id="@+id/search_button"
android:layout_width="match_parent"
android:layout_height="@dimen/dashboard_map_toolbar"
android:background="?attr/bg_color"
android:gravity="center_vertical">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_weight="1"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:text="@string/search_poi_category_hint"
android:textColor="?attr/searchbar_text_hint"
android:textSize="@dimen/default_list_text_size_large"/>
<ImageView
android:id="@+id/search_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:contentDescription="@string/shared_string_search"
tools:src="@drawable/ic_action_search_dark"/>
<net.osmand.plus.LockableViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/wikivoyage_card_bg_color"
app:itemBackground="?attr/wikivoyage_card_bg_color"
app:menu="@menu/wikivoyage_bottom_navigation"
tools:itemIconTint="@color/bottom_navigation_color_selector_light"
tools:itemTextColor="@color/bottom_navigation_color_selector_light"/>
</LinearLayout>

View file

@ -2,9 +2,11 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/action_explore"
android:icon="@drawable/ic_action_explore_part1"
android:title="@string/shared_string_explore"/>
<item
android:id="@+id/action_saved_articles"
android:icon="@drawable/ic_action_read_later"
android:title="@string/saved_articles"/>
</menu>

View file

@ -1,8 +1,10 @@
package net.osmand.plus.wikivoyage;
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.BottomNavigationView;
import android.support.v4.app.FragmentManager;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
@ -10,6 +12,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import net.osmand.AndroidUtils;
import net.osmand.plus.R;
import net.osmand.plus.wikivoyage.search.WikivoyageSearchDialogFragment;
@ -34,9 +37,20 @@ public class WikivoyageExploreDialogFragment extends WikivoyageBaseDialogFragmen
}
});
ColorStateList navColorStateList = createBottomNavColorStateList();
BottomNavigationView bottomNav = (BottomNavigationView) mainView.findViewById(R.id.bottom_navigation);
bottomNav.setItemIconTintList(navColorStateList);
bottomNav.setItemTextColor(navColorStateList);
return mainView;
}
private ColorStateList createBottomNavColorStateList() {
return AndroidUtils.createCheckedColorStateList(getContext(), nightMode,
R.color.icon_color, R.color.wikivoyage_active_light,
R.color.icon_color, R.color.wikivoyage_active_dark);
}
public static boolean showInstance(FragmentManager fm) {
try {
WikivoyageExploreDialogFragment fragment = new WikivoyageExploreDialogFragment();