[android] Added catalog viewpager, modified search screen and view
Before Width: | Height: | Size: 213 B |
Before Width: | Height: | Size: 497 B |
Before Width: | Height: | Size: 145 B |
Before Width: | Height: | Size: 330 B |
Before Width: | Height: | Size: 208 B |
Before Width: | Height: | Size: 606 B |
Before Width: | Height: | Size: 311 B |
Before Width: | Height: | Size: 902 B |
Before Width: | Height: | Size: 369 B |
Before Width: | Height: | Size: 1.2 KiB |
25
android/res/layout/fragment_bookmark_categories_pager.xml
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.design.widget.TabLayout
|
||||
android:id="@+id/sliding_tabs_layout"
|
||||
style="@style/MwmWidget.TabLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/tabs_height"/>
|
||||
|
||||
<FrameLayout
|
||||
android:foreground="@drawable/shadow_top"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_0"
|
||||
android:layout_weight="1">
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/viewpager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
|
@ -15,7 +15,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:elevation="@dimen/margin_half_plus"
|
||||
android:elevation="@dimen/dp_0"
|
||||
app:elevation="@dimen/dp_0"
|
||||
tools:targetApi="lollipop">
|
||||
<android.support.design.widget.CollapsingToolbarLayout
|
||||
android:id="@+id/collapsing_toolbar"
|
||||
|
|
8
android/res/layout/non_elevated_toolbar.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v7.widget.Toolbar
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/toolbar"
|
||||
style="@style/MwmWidget.ToolbarStyle.NoElevation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:theme="@style/MwmWidget.ToolbarTheme"/>
|
|
@ -245,4 +245,5 @@
|
|||
<!-- Bookmarks-->
|
||||
<dimen name="bookmark_hide_btn_padding_top">22dp</dimen>
|
||||
<dimen name="bookmark_recycler_view_bottom_margin">80dp</dimen>
|
||||
<dimen name="dp_0">0dp</dimen>
|
||||
</resources>
|
||||
|
|
|
@ -192,8 +192,9 @@
|
|||
<item name="android:textColor">?bannerText</item>
|
||||
</style>
|
||||
|
||||
<style name="MwmTextAppearance.Tab" parent="MwmTextAppearance.Body4">
|
||||
<style name="MwmTextAppearance.Tab" parent="MwmTextAppearance.Body3">
|
||||
<item name="android:textAllCaps">true</item>
|
||||
<item name="android:textColor">@color/white_secondary</item>
|
||||
</style>
|
||||
|
||||
<style name="MwmTextAppearance.Discovery.Subtitle" parent="MwmTextAppearance.Body3">
|
||||
|
|
|
@ -311,10 +311,12 @@
|
|||
|
||||
<style name="MwmWidget.TabLayout" parent="Widget.Design.TabLayout">
|
||||
<item name="tabMaxWidth">0dp</item>
|
||||
<item name="tabIndicatorColor">?colorAccent</item>
|
||||
<item name="tabTextAppearance">@style/MwmTextAppearance.Tab</item>
|
||||
<item name="tabMode">fixed</item>
|
||||
<item name="tabGravity">fill</item>
|
||||
<item name="tabBackground">?colorPrimary</item>
|
||||
<item name="tabIndicatorColor">@color/white_primary</item>
|
||||
<item name="tabSelectedTextColor">@color/white_primary</item>
|
||||
</style>
|
||||
|
||||
<style name="MwmWidget.Downloader.ToolbarButton">
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
package com.mapswithme.maps.bookmarks;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.TabLayout;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseMwmFragment;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class BookmarkCategoriesPagerFragment extends BaseMwmFragment
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
View root = inflater.inflate(R.layout.fragment_bookmark_categories_pager, null);
|
||||
ViewPager viewPager = root.findViewById(R.id.viewpager);
|
||||
TabLayout tabLayout = root.findViewById(R.id.sliding_tabs_layout);
|
||||
|
||||
FragmentManager fm = getActivity().getSupportFragmentManager();
|
||||
BookmarksPagerAdapter adapter = new BookmarksPagerAdapter(getContext(),
|
||||
fm,
|
||||
prepareAdapterDataSet());
|
||||
viewPager.setAdapter(adapter);
|
||||
tabLayout.setupWithViewPager(viewPager);
|
||||
return root;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private static List<BookmarksPageFactory> prepareAdapterDataSet()
|
||||
{
|
||||
return Arrays.asList(BookmarksPageFactory.PRIVATE, BookmarksPageFactory.CATALOG);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package com.mapswithme.maps.bookmarks;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
|
||||
public enum BookmarksPageFactory
|
||||
{
|
||||
CATALOG(new AdapterResourceProvider.Catalog())
|
||||
{
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment instantiateFragment()
|
||||
{
|
||||
return new CachedBookmarksFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTitle()
|
||||
{
|
||||
return R.string.bookmarks_page_downloaded;
|
||||
}
|
||||
},
|
||||
PRIVATE
|
||||
{
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment instantiateFragment()
|
||||
{
|
||||
return new BookmarkCategoriesFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTitle()
|
||||
{
|
||||
return R.string.bookmarks_page_my;
|
||||
}
|
||||
};
|
||||
|
||||
@NonNull
|
||||
private AdapterResourceProvider mResProvider;
|
||||
|
||||
BookmarksPageFactory(@NonNull AdapterResourceProvider resourceProvider)
|
||||
{
|
||||
mResProvider = resourceProvider;
|
||||
}
|
||||
|
||||
BookmarksPageFactory()
|
||||
{
|
||||
this(new AdapterResourceProvider.Default());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public AdapterResourceProvider getResProvider()
|
||||
{
|
||||
return mResProvider;
|
||||
}
|
||||
|
||||
public static BookmarksPageFactory get(String value)
|
||||
{
|
||||
for (BookmarksPageFactory each : values())
|
||||
{
|
||||
if (TextUtils.equals(each.name(), value))
|
||||
{
|
||||
return each;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException(new StringBuilder()
|
||||
.append("not found enum instance for value = ")
|
||||
.append(value)
|
||||
.toString());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public abstract Fragment instantiateFragment();
|
||||
|
||||
public abstract int getTitle();
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.mapswithme.maps.bookmarks;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentPagerAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BookmarksPagerAdapter extends FragmentPagerAdapter
|
||||
{
|
||||
@NonNull
|
||||
private final List<BookmarksPageFactory> mFactories;
|
||||
@NonNull
|
||||
private final Context mContext;
|
||||
|
||||
public BookmarksPagerAdapter(@NonNull Context context,
|
||||
@NonNull FragmentManager fm,
|
||||
@NonNull List<BookmarksPageFactory> factories)
|
||||
{
|
||||
super(fm);
|
||||
mContext = context.getApplicationContext();
|
||||
mFactories = factories;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position)
|
||||
{
|
||||
return mFactories.get(position).instantiateFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position)
|
||||
{
|
||||
int titleResId = mFactories.get(position).getTitle();
|
||||
return mContext.getResources().getString(titleResId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount()
|
||||
{
|
||||
return mFactories.size();
|
||||
}
|
||||
}
|
|
@ -23,12 +23,6 @@ class TabAdapter extends FragmentPagerAdapter
|
|||
{
|
||||
HISTORY
|
||||
{
|
||||
@Override
|
||||
public int getIconRes()
|
||||
{
|
||||
return R.drawable.ic_search_tab_history;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTitleRes()
|
||||
{
|
||||
|
@ -44,12 +38,6 @@ class TabAdapter extends FragmentPagerAdapter
|
|||
|
||||
CATEGORIES
|
||||
{
|
||||
@Override
|
||||
public int getIconRes()
|
||||
{
|
||||
return R.drawable.ic_search_tab_categories;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTitleRes()
|
||||
{
|
||||
|
@ -63,7 +51,6 @@ class TabAdapter extends FragmentPagerAdapter
|
|||
}
|
||||
};
|
||||
|
||||
public abstract int getIconRes();
|
||||
public abstract int getTitleRes();
|
||||
public abstract Class<? extends Fragment> getFragmentClass();
|
||||
}
|
||||
|
@ -85,7 +72,7 @@ class TabAdapter extends FragmentPagerAdapter
|
|||
{
|
||||
super.onPageSelected(position);
|
||||
if (mTabSelectedListener != null)
|
||||
mTabSelectedListener.onTabSelected(TABS[position]);
|
||||
mTabSelectedListener.onTabSelected(Tab.values()[position]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,8 +102,6 @@ class TabAdapter extends FragmentPagerAdapter
|
|||
}
|
||||
}
|
||||
|
||||
static final Tab[] TABS = Tab.values();
|
||||
|
||||
private final ViewPager mPager;
|
||||
private final List<Class<? extends Fragment>> mClasses = new ArrayList<>();
|
||||
private final SparseArray<Fragment> mFragments = new SparseArray<>();
|
||||
|
@ -126,7 +111,7 @@ class TabAdapter extends FragmentPagerAdapter
|
|||
{
|
||||
super(fragmentManager);
|
||||
|
||||
for (Tab tab : TABS)
|
||||
for (Tab tab : Tab.values())
|
||||
mClasses.add(tab.getFragmentClass());
|
||||
|
||||
final List<Fragment> fragments = fragmentManager.getFragments();
|
||||
|
@ -160,14 +145,11 @@ class TabAdapter extends FragmentPagerAdapter
|
|||
{
|
||||
final Context context = tabs.getContext();
|
||||
|
||||
for (Tab tab : TABS)
|
||||
for (Tab tab : Tab.values())
|
||||
{
|
||||
TabLayout.Tab t = tabs.newTab();
|
||||
t.setIcon(tab.getIconRes());
|
||||
t.setText(tab.getTitleRes());
|
||||
tabs.addTab(t, false);
|
||||
tabs.setTabTextColors(getTabTextColor(context));
|
||||
Graphics.tint(context, t.getIcon());
|
||||
}
|
||||
|
||||
ViewPager.OnPageChangeListener listener = new PageChangedListener(tabs);
|
||||
|
|