collapsing toolbar

This commit is contained in:
veliymolfar 2020-02-24 16:34:05 +02:00
parent a28d9f84c4
commit ff570d4b81
6 changed files with 290 additions and 182 deletions

View file

@ -1,135 +1,157 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.design.widget.CoordinatorLayout 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/activity_background_basic"
android:orientation="vertical">
android:background="?attr/activity_background_basic">
<LinearLayout
android:id="@+id/toolbar_layout"
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:orientation="vertical">
android:layout_height="match_parent"
osmand:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:minHeight="@dimen/toolbar_height" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/title"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/content_padding"
android:paddingTop="@dimen/list_header_settings_top_margin"
android:paddingEnd="@dimen/content_padding"
android:paddingBottom="@dimen/list_header_settings_top_margin"
android:text="@string/shared_string_import"
android:textColor="?attr/app_bar_primary_item_color"
android:textSize="@dimen/dialog_header_text_size"
osmand:typeface="@string/font_roboto_medium" />
android:orientation="vertical">
</LinearLayout>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:paddingStart="@dimen/content_padding"
android:paddingTop="@dimen/list_header_settings_top_margin"
android:paddingEnd="@dimen/content_padding"
android:paddingBottom="@dimen/list_header_settings_top_margin"
android:text="@string/select_data_to_import"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:paddingStart="@dimen/content_padding"
android:paddingTop="@dimen/list_header_settings_top_margin"
android:paddingEnd="@dimen/content_padding"
android:paddingBottom="@dimen/list_header_settings_top_margin"
android:text="@string/select_data_to_import"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size" />
<include layout="@layout/card_bottom_divider" />
<include layout="@layout/card_bottom_divider" />
<net.osmand.view.NonScrollExpandableList
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@null"
android:dividerHeight="0dp"
android:drawSelectorOnTop="false"
android:groupIndicator="@android:color/transparent"
android:listSelector="@android:color/transparent"
android:paddingBottom="@dimen/dialog_button_ex_height" />
<ExpandableListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:divider="@null"
android:dividerHeight="0dp"
android:drawSelectorOnTop="false"
android:groupIndicator="@android:color/transparent"
android:listSelector="@android:color/transparent" />
</LinearLayout>
<include layout="@layout/divider" />
</android.support.v4.widget.NestedScrollView>
<LinearLayout
android:id="@+id/buttons_container"
android:layout_width="match_parent"
android:layout_height="@dimen/dialog_button_ex_height"
android:layout_gravity="bottom"
android:background="?attr/bg_color"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="@dimen/content_padding_small">
android:orientation="vertical">
<FrameLayout
android:layout_width="0dp"
<include layout="@layout/divider" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
android:orientation="horizontal"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="@dimen/content_padding_small">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/select_button"
android:layout_width="match_parent"
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:ellipsize="end"
android:gravity="start|center_vertical"
android:maxLines="1"
android:paddingLeft="@dimen/content_padding_small"
android:paddingTop="@dimen/content_padding_half"
android:paddingRight="@dimen/content_padding_small"
android:paddingBottom="@dimen/content_padding_half"
android:text="@string/shared_string_select_all"
android:textColor="?attr/active_color_basic"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Select all" />
android:layout_weight="1">
</FrameLayout>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/select_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:ellipsize="end"
android:gravity="start|center_vertical"
android:maxLines="1"
android:paddingLeft="@dimen/content_padding_small"
android:paddingTop="@dimen/content_padding_half"
android:paddingRight="@dimen/content_padding_small"
android:paddingBottom="@dimen/content_padding_half"
android:text="@string/shared_string_select_all"
android:textColor="?attr/active_color_basic"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Select all" />
<View
android:layout_width="@dimen/content_padding"
android:layout_height="match_parent" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/dlg_btn_primary">
<View
android:layout_width="@dimen/content_padding"
android:layout_height="match_parent" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/continue_button"
android:layout_width="match_parent"
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:ellipsize="end"
android:gravity="end|center_vertical"
android:maxLines="1"
android:paddingLeft="@dimen/content_padding_small"
android:paddingTop="@dimen/content_padding_half"
android:paddingRight="@dimen/content_padding_small"
android:paddingBottom="@dimen/content_padding_half"
android:text="@string/shared_string_continue"
android:textColor="?attr/dlg_btn_primary_text"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Continue" />
android:layout_weight="1"
android:background="?attr/dlg_btn_primary">
</FrameLayout>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/continue_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:ellipsize="end"
android:gravity="end|center_vertical"
android:maxLines="1"
android:paddingLeft="@dimen/content_padding_small"
android:paddingTop="@dimen/content_padding_half"
android:paddingRight="@dimen/content_padding_small"
android:paddingBottom="@dimen/content_padding_half"
android:text="@string/shared_string_continue"
android:textColor="?attr/dlg_btn_primary_text"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Continue" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/actionModeBackground">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height_expanded"
osmand:collapsedTitleTextAppearance="@style/AppBarTitle"
osmand:expandedTitleGravity="start|bottom"
osmand:expandedTitleTextAppearance="@style/AppBarTitle"
osmand:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:minHeight="@dimen/toolbar_height"
osmand:layout_collapseMode="pin"
osmand:layout_scrollFlags="scroll|enterAlways|exitUntilCollapsed"
osmand:title="@string/shared_string_import">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>

View file

@ -1,105 +1,132 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/activity_background_basic"
android:orientation="vertical">
android:background="?attr/activity_background_basic">
<android.support.v4.widget.NestedScrollView
android:id="@+id/nested_scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
osmand:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:paddingStart="@dimen/content_padding"
android:paddingTop="@dimen/list_header_settings_top_margin"
android:paddingEnd="@dimen/content_padding"
android:paddingBottom="@dimen/list_header_settings_top_margin"
android:text="@string/import_duplicates_description"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size" />
<include
android:id="@+id/description_divider"
layout="@layout/card_bottom_divider" />
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<LinearLayout
android:id="@+id/buttons_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:layout_gravity="bottom"
android:background="?attr/bg_color"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:minHeight="@dimen/toolbar_height" />
<include layout="@layout/divider" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/title"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/content_padding"
android:paddingTop="@dimen/list_header_settings_top_margin"
android:paddingEnd="@dimen/content_padding"
android:paddingBottom="@dimen/list_header_settings_top_margin"
android:text="@string/import_duplicates_title"
android:textColor="?attr/app_bar_primary_item_color"
android:textSize="@dimen/dialog_header_text_size"
osmand:typeface="@string/font_roboto_medium" />
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/content_padding">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/content_padding_half"
android:background="?attr/dlg_btn_secondary">
<net.osmand.view.ComplexButton
android:id="@+id/keep_both_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
osmand:setSubText="@string/keep_both_desc"
osmand:setSubTextColor="?android:textColorSecondary"
osmand:setText="@string/keep_both"
osmand:setTextColor="?attr/active_color_basic" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/dlg_btn_primary">
<net.osmand.view.ComplexButton
android:id="@+id/replace_all_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
osmand:setSubText="@string/replace_all_desc"
osmand:setSubTextColor="?android:textColorTertiaryInverse"
osmand:setText="@string/replace_all"
osmand:setTextColor="?attr/dlg_btn_primary_text" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/description"
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:paddingStart="@dimen/content_padding"
android:paddingTop="@dimen/list_header_settings_top_margin"
android:paddingEnd="@dimen/content_padding"
android:paddingBottom="@dimen/list_header_settings_top_margin"
android:text="@string/import_duplicates_description"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size" />
android:background="?attr/actionModeBackground">
<include
android:id="@+id/description_divider"
layout="@layout/card_bottom_divider" />
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<include layout="@layout/divider" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical"
android:padding="@dimen/content_padding">
<FrameLayout
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/content_padding_half"
android:background="?attr/dlg_btn_secondary">
android:layout_height="@dimen/toolbar_height_expanded"
osmand:collapsedTitleTextAppearance="@style/AppBarTitle"
osmand:expandedTitleGravity="start|bottom"
osmand:expandedTitleTextAppearance="@style/AppBarTitle"
osmand:layout_scrollFlags="scroll|exitUntilCollapsed">
<net.osmand.view.ComplexButton
android:id="@+id/keep_both_btn"
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
osmand:setSubText="@string/keep_both_desc"
osmand:setSubTextColor="?android:textColorSecondary"
osmand:setText="@string/keep_both"
osmand:setTextColor="?attr/active_color_basic" />
android:layout_height="@dimen/toolbar_height"
android:minHeight="@dimen/toolbar_height"
osmand:layout_collapseMode="pin"
osmand:layout_scrollFlags="scroll|enterAlways|exitUntilCollapsed"
osmand:title="@string/shared_string_import">
</FrameLayout>
</android.support.v7.widget.Toolbar>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/dlg_btn_primary">
</android.support.design.widget.CollapsingToolbarLayout>
<net.osmand.view.ComplexButton
android:id="@+id/replace_all_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
osmand:setSubText="@string/replace_all_desc"
osmand:setSubTextColor="?android:textColorTertiaryInverse"
osmand:setText="@string/replace_all"
osmand:setTextColor="?attr/dlg_btn_primary_text" />
</android.support.design.widget.AppBarLayout>
</FrameLayout>
</LinearLayout>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>

View file

@ -319,6 +319,7 @@
<dimen name="coords_input_keyboard_item_height">56dp</dimen>
<dimen name="toolbar_height">56dp</dimen>
<dimen name="toolbar_height_expanded">112dp</dimen>
<dimen name="wikivoyage_search_list_header_height">36dp</dimen>
<dimen name="wikivoyage_article_card_icon_size">80dp</dimen>

View file

@ -749,4 +749,9 @@
<item name="colorControlHighlight">?attr/app_bar_primary_item_color</item>
</style>
<style name="AppBarTitle" parent="TextAppearance.AppCompat.Title">
<item name="android:textColor">?attr/app_bar_primary_item_color</item>
<item name="android:textSize">@dimen/dialog_header_text_size</item>
</style>
</resources>

View file

@ -1,16 +1,20 @@
package net.osmand.plus.settings;
import android.app.Dialog;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.LinearLayout;
import net.osmand.map.ITileSource;
import net.osmand.plus.AppInitializer;
@ -38,9 +42,10 @@ public class ImportDuplicatesFragment extends BaseOsmAndDialogFragment implement
public static final String TAG = ImportSettingsFragment.class.getSimpleName();
private OsmandApplication app;
private RecyclerView list;
private LinearLayout buttonsContainer;
private NestedScrollView nestedScroll;
private List<? super Object> duplicatesList;
private List<SettingsItem> settingsItems;
private DuplicatesSettingsAdapter adapter;
private File file;
private boolean nightMode;
@ -82,6 +87,8 @@ public class ImportDuplicatesFragment extends BaseOsmAndDialogFragment implement
setupToolbar((Toolbar) root.findViewById(R.id.toolbar));
ComplexButton replaceAllBtn = root.findViewById(R.id.replace_all_btn);
ComplexButton keepBothBtn = root.findViewById(R.id.keep_both_btn);
buttonsContainer = root.findViewById(R.id.buttons_container);
nestedScroll = root.findViewById(R.id.nested_scroll);
keepBothBtn.setIcon(getPaintedContentIcon(R.drawable.ic_action_keep_both,
nightMode
? getResources().getColor(R.color.icon_color_active_dark)
@ -95,6 +102,22 @@ public class ImportDuplicatesFragment extends BaseOsmAndDialogFragment implement
keepBothBtn.setOnClickListener(this);
replaceAllBtn.setOnClickListener(this);
list = root.findViewById(R.id.list);
ViewTreeObserver treeObserver = buttonsContainer.getViewTreeObserver();
treeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (buttonsContainer != null) {
ViewTreeObserver vts = buttonsContainer.getViewTreeObserver();
int height = buttonsContainer.getMeasuredHeight();
nestedScroll.setPadding(0, 0, 0, height);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
vts.removeOnGlobalLayoutListener(this);
} else {
vts.removeGlobalOnLayoutListener(this);
}
}
}
});
return root;
}
@ -117,7 +140,7 @@ public class ImportDuplicatesFragment extends BaseOsmAndDialogFragment implement
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
adapter = new DuplicatesSettingsAdapter(getMyApplication(), prepareDuplicates(), nightMode);
DuplicatesSettingsAdapter adapter = new DuplicatesSettingsAdapter(getMyApplication(), prepareDuplicates(), nightMode);
list.setLayoutManager(new LinearLayoutManager(getMyApplication()));
list.setAdapter(adapter);
}
@ -236,6 +259,7 @@ public class ImportDuplicatesFragment extends BaseOsmAndDialogFragment implement
dismiss();
}
});
toolbar.setTitle(getString(R.string.import_duplicates_title));
}
public void setDuplicatesList(List<? super Object> duplicatesList) {

View file

@ -0,0 +1,29 @@
package net.osmand.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.ExpandableListView;
public class NonScrollExpandableList extends ExpandableListView {
public NonScrollExpandableList(Context context) {
super(context);
}
public NonScrollExpandableList(Context context, AttributeSet attrs) {
super(context, attrs);
}
public NonScrollExpandableList(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int heightMeasureSpec_custom = MeasureSpec.makeMeasureSpec(
Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom);
ViewGroup.LayoutParams params = getLayoutParams();
params.height = getMeasuredHeight();
}
}