diff --git a/samples/SupportDesignDemos/AndroidManifest.xml b/samples/SupportDesignDemos/AndroidManifest.xml index 5ea1b3d27..c68faa47d 100644 --- a/samples/SupportDesignDemos/AndroidManifest.xml +++ b/samples/SupportDesignDemos/AndroidManifest.xml @@ -289,5 +289,14 @@ + + + + + + + diff --git a/samples/SupportDesignDemos/res/values/strings.xml b/samples/SupportDesignDemos/res/values/strings.xml index 91a0dbfe2..df23798a9 100644 --- a/samples/SupportDesignDemos/res/values/strings.xml +++ b/samples/SupportDesignDemos/res/values/strings.xml @@ -30,6 +30,7 @@ BottomSheet/With ScrollView in background BottomSheet/With Fragment BottomSheet/Modal + BottomSheet/Modal (Skip collapsed) Normal size Mini size diff --git a/samples/SupportDesignDemos/res/values/styles.xml b/samples/SupportDesignDemos/res/values/styles.xml index db0440196..432bc3ed3 100644 --- a/samples/SupportDesignDemos/res/values/styles.xml +++ b/samples/SupportDesignDemos/res/values/styles.xml @@ -59,4 +59,16 @@ @dimen/bottom_sheet_horizontal_margin + + + + + + \ No newline at end of file diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/BottomSheetModal.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/BottomSheetModal.java index f55c5905c..262f3908a 100644 --- a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/BottomSheetModal.java +++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/BottomSheetModal.java @@ -16,69 +16,10 @@ package com.example.android.support.design.widget; -import com.example.android.support.design.Cheeses; -import com.example.android.support.design.R; - -import android.content.Context; -import android.os.Bundle; -import android.support.annotation.Nullable; import android.support.design.widget.BottomSheetDialogFragment; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; /** * This demonstrates basic usage of {@link BottomSheetDialogFragment}. */ -public class BottomSheetModal extends AppCompatActivity { - - private static final String FRAGMENT_MODAL = "modal"; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.design_bottom_sheet_modal); - findViewById(R.id.show).setOnClickListener(mOnClickListener); - } - - private View.OnClickListener mOnClickListener = new View.OnClickListener() { - @Override - public void onClick(View v) { - switch (v.getId()) { - case R.id.show: - new ModalFragment().show(getSupportFragmentManager(), FRAGMENT_MODAL); - break; - } - } - }; - - /** - * This is the bottom sheet. - */ - public static class ModalFragment extends BottomSheetDialogFragment { - - @Nullable - @Override - public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, - @Nullable Bundle savedInstanceState) { - return inflater.inflate(R.layout.design_bottom_sheet_recyclerview, container, false); - } - - @Override - public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { - // For the scrolling content, you can use RecyclerView, NestedScrollView or any other - // View that inherits NestedScrollingChild - RecyclerView recyclerView = - (RecyclerView) view.findViewById(R.id.bottom_sheet_recyclerview); - Context context = recyclerView.getContext(); - recyclerView.setLayoutManager(new LinearLayoutManager(context)); - recyclerView.setAdapter(new SimpleStringRecyclerViewAdapter(context, - Cheeses.sCheeseStrings)); - } - - } - +public class BottomSheetModal extends BottomSheetModalBase { } diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/BottomSheetModalBase.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/BottomSheetModalBase.java new file mode 100644 index 000000000..84c260a4c --- /dev/null +++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/BottomSheetModalBase.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.android.support.design.widget; + +import android.content.Context; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.design.widget.BottomSheetDialogFragment; +import android.support.v7.app.AppCompatActivity; +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 com.example.android.support.design.Cheeses; +import com.example.android.support.design.R; + +abstract class BottomSheetModalBase extends AppCompatActivity { + + private static final String FRAGMENT_MODAL = "modal"; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.design_bottom_sheet_modal); + findViewById(R.id.show).setOnClickListener(mOnClickListener); + } + + private View.OnClickListener mOnClickListener = new View.OnClickListener() { + @Override + public void onClick(View v) { + switch (v.getId()) { + case R.id.show: + new ModalFragment().show(getSupportFragmentManager(), FRAGMENT_MODAL); + break; + } + } + }; + + /** + * This is the bottom sheet. + */ + public static class ModalFragment extends BottomSheetDialogFragment { + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { + return inflater.inflate(R.layout.design_bottom_sheet_recyclerview, container, false); + } + + @Override + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + // For the scrolling content, you can use RecyclerView, NestedScrollView or any other + // View that inherits NestedScrollingChild + RecyclerView recyclerView = + (RecyclerView) view.findViewById(R.id.bottom_sheet_recyclerview); + Context context = recyclerView.getContext(); + recyclerView.setLayoutManager(new LinearLayoutManager(context)); + recyclerView.setAdapter(new SimpleStringRecyclerViewAdapter(context, + Cheeses.sCheeseStrings)); + } + + } + +} diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/BottomSheetModalSkipCollapsed.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/BottomSheetModalSkipCollapsed.java new file mode 100644 index 000000000..509dd7c95 --- /dev/null +++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/BottomSheetModalSkipCollapsed.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.android.support.design.widget; + +import android.support.design.widget.BottomSheetDialogFragment; + +/** + * This demonstrates basic usage of {@link BottomSheetDialogFragment}. + * + *

This version has behavior_skipCollapsed="true" in its theme.

+ */ +public class BottomSheetModalSkipCollapsed extends BottomSheetModalBase { +}