am 34191c0a: am 86ed92ac: (-s ours) Update build files for lmp-mr1-ub-docs samples r7
* commit '34191c0a566b25e1b1bbf29c65e6ddac74942f2a':
Update build files for lmp-mr1-ub-docs samples r7
diff --git a/build/sdk-darwin-x86.atree b/build/sdk-darwin-x86.atree
index 0ebccf2..6efec25 100644
--- a/build/sdk-darwin-x86.atree
+++ b/build/sdk-darwin-x86.atree
@@ -28,9 +28,9 @@
lib/libclang.dylib strip build-tools/${PLATFORM_NAME}/../lib/libclang.dylib
lib/libc++.dylib strip build-tools/${PLATFORM_NAME}/../lib/libc++.dylib
-prebuilts/sdk/tools/darwin/arm-linux-androideabi-ld strip build-tools/${PLATFORM_NAME}/arm-linux-androideabi-ld
-prebuilts/sdk/tools/darwin/i686-linux-android-ld strip build-tools/${PLATFORM_NAME}/i686-linux-android-ld
-prebuilts/sdk/tools/darwin/mipsel-linux-android-ld strip build-tools/${PLATFORM_NAME}/mipsel-linux-android-ld
+prebuilts/sdk/tools/darwin/bin/arm-linux-androideabi-ld strip build-tools/${PLATFORM_NAME}/arm-linux-androideabi-ld
+prebuilts/sdk/tools/darwin/bin/i686-linux-android-ld strip build-tools/${PLATFORM_NAME}/i686-linux-android-ld
+prebuilts/sdk/tools/darwin/bin/mipsel-linux-android-ld strip build-tools/${PLATFORM_NAME}/mipsel-linux-android-ld
dalvik/dx/etc/mainDexClasses build-tools/${PLATFORM_NAME}/mainDexClasses
diff --git a/build/sdk-linux-x86.atree b/build/sdk-linux-x86.atree
index 71b5c0d..ec8364f 100644
--- a/build/sdk-linux-x86.atree
+++ b/build/sdk-linux-x86.atree
@@ -28,9 +28,9 @@
lib/libclang.so strip build-tools/${PLATFORM_NAME}/../lib/libclang.so
lib/libc++.so strip build-tools/${PLATFORM_NAME}/../lib/libc++.so
-prebuilts/sdk/tools/linux/arm-linux-androideabi-ld strip build-tools/${PLATFORM_NAME}/arm-linux-androideabi-ld
-prebuilts/sdk/tools/linux/i686-linux-android-ld strip build-tools/${PLATFORM_NAME}/i686-linux-android-ld
-prebuilts/sdk/tools/linux/mipsel-linux-android-ld strip build-tools/${PLATFORM_NAME}/mipsel-linux-android-ld
+prebuilts/sdk/tools/linux/bin/arm-linux-androideabi-ld strip build-tools/${PLATFORM_NAME}/arm-linux-androideabi-ld
+prebuilts/sdk/tools/linux/bin/i686-linux-android-ld strip build-tools/${PLATFORM_NAME}/i686-linux-android-ld
+prebuilts/sdk/tools/linux/bin/mipsel-linux-android-ld strip build-tools/${PLATFORM_NAME}/mipsel-linux-android-ld
dalvik/dx/etc/mainDexClasses build-tools/${PLATFORM_NAME}/mainDexClasses
diff --git a/build/sdk-windows-x86.atree b/build/sdk-windows-x86.atree
index e3c4add..5fc9677 100644
--- a/build/sdk-windows-x86.atree
+++ b/build/sdk-windows-x86.atree
@@ -96,13 +96,13 @@
bin/bcc_compat.exe strip build-tools/${PLATFORM_NAME}/bcc_compat.exe
rm build-tools/${PLATFORM_NAME}/arm-linux-androideabi-ld
-prebuilts/sdk/tools/windows/arm-linux-androideabi-ld.exe strip build-tools/${PLATFORM_NAME}/arm-linux-androideabi-ld.exe
+prebuilts/sdk/tools/windows/bin/arm-linux-androideabi-ld.exe strip build-tools/${PLATFORM_NAME}/arm-linux-androideabi-ld.exe
rm build-tools/${PLATFORM_NAME}/i686-linux-android-ld
-prebuilts/sdk/tools/windows/i686-linux-android-ld.exe strip build-tools/${PLATFORM_NAME}/i686-linux-android-ld.exe
+prebuilts/sdk/tools/windows/bin/i686-linux-android-ld.exe strip build-tools/${PLATFORM_NAME}/i686-linux-android-ld.exe
rm build-tools/${PLATFORM_NAME}/mipsel-linux-android-ld
-prebuilts/sdk/tools/windows/mipsel-linux-android-ld.exe strip build-tools/${PLATFORM_NAME}/mipsel-linux-android-ld.exe
+prebuilts/sdk/tools/windows/bin/mipsel-linux-android-ld.exe strip build-tools/${PLATFORM_NAME}/mipsel-linux-android-ld.exe
dalvik/dx/etc/mainDexClasses.bat build-tools/${PLATFORM_NAME}/mainDexClasses.bat
diff --git a/build/sdk.atree b/build/sdk.atree
index bfdd8fd..41094a8 100644
--- a/build/sdk.atree
+++ b/build/sdk.atree
@@ -481,6 +481,7 @@
# TODO: add .project, .classpath, etc.
frameworks/support/v7/recyclerview/README.txt extras/android/support/v7/recyclerview/README.txt
frameworks/support/v7/recyclerview/AndroidManifest.xml extras/android/support/v7/recyclerview/AndroidManifest.xml
+frameworks/support/v7/recyclerview/res extras/android/support/v7/recyclerview/res
${OUT_DIR}/target/common/obj/PACKAGING/android-support-v7-recyclerview_intermediates/android-support-v7-recyclerview.jar extras/android/support/v7/recyclerview/libs/android-support-v7-recyclerview.jar
frameworks/support/v17/leanback/README.txt extras/android/support/v17/leanback/README.txt
diff --git a/samples/Support7Demos/Android.mk b/samples/Support7Demos/Android.mk
index cd6c308..371c737 100644
--- a/samples/Support7Demos/Android.mk
+++ b/samples/Support7Demos/Android.mk
@@ -35,11 +35,16 @@
frameworks/support/v7/appcompat/res \
frameworks/support/v7/gridlayout/res \
frameworks/support/v7/mediarouter/res \
- frameworks/support/v7/cardview/res
+ frameworks/support/v7/cardview/res \
+ frameworks/support/design/res \
+ frameworks/support/v7/recyclerview/res
+
LOCAL_AAPT_FLAGS := \
--auto-add-overlay \
--extra-packages android.support.v7.appcompat \
--extra-packages android.support.v7.cardview \
--extra-packages android.support.v7.gridlayout \
- --extra-packages android.support.v7.mediarouter
+ --extra-packages android.support.v7.mediarouter \
+ --extra-packages android.support.design \
+ --extra-packages android.support.v7.recyclerview
include $(BUILD_PACKAGE)
diff --git a/samples/Support7Demos/AndroidManifest.xml b/samples/Support7Demos/AndroidManifest.xml
index 26f2a57..77a403a 100644
--- a/samples/Support7Demos/AndroidManifest.xml
+++ b/samples/Support7Demos/AndroidManifest.xml
@@ -388,5 +388,22 @@
android:label="@string/palette"
android:theme="@style/Theme.AppCompat" />
+ <!-- item touch helper demo activities-->
+ <activity android:name=".widget.touch.SwipeToDismissActivity"
+ android:label="@string/swipe_to_dismiss_activity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="com.example.android.supportv7.SAMPLE_CODE"/>
+ </intent-filter>
+ </activity>
+ <activity android:name=".widget.touch.DragAndDropActivity"
+ android:label="@string/drag_and_drop_activity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="com.example.android.supportv7.SAMPLE_CODE"/>
+ </intent-filter>
+ </activity>
</application>
+
+
</manifest>
diff --git a/samples/Support7Demos/res/layout/activity_item_touch.xml b/samples/Support7Demos/res/layout/activity_item_touch.xml
new file mode 100644
index 0000000..d809b0e
--- /dev/null
+++ b/samples/Support7Demos/res/layout/activity_item_touch.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <android.support.v7.widget.RecyclerView
+ android:layout_width="fill_parent"
+ android:layout_height="60dp"
+ android:scrollbars="horizontal"
+ android:id="@+id/config_recycler_view"/>
+ <android.support.v7.widget.RecyclerView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:id="@+id/recycler_view"/>
+</LinearLayout>
\ No newline at end of file
diff --git a/samples/Support7Demos/res/layout/config_view_toggle.xml b/samples/Support7Demos/res/layout/config_view_toggle.xml
new file mode 100644
index 0000000..ac187ff
--- /dev/null
+++ b/samples/Support7Demos/res/layout/config_view_toggle.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<CheckBox xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent">
+
+</CheckBox>
\ No newline at end of file
diff --git a/samples/Support7Demos/res/layout/touch_item.xml b/samples/Support7Demos/res/layout/touch_item.xml
new file mode 100644
index 0000000..7ff9547
--- /dev/null
+++ b/samples/Support7Demos/res/layout/touch_item.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:card="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ card:cardUseCompatPadding="true"
+ android:background="@color/card_classic"
+ android:layout_height="wrap_content">
+ <TextView android:layout_width="wrap_content"
+ android:textColor="@android:color/black"
+ android:layout_height="@dimen/touch_item_min_height"
+ android:id="@+id/text_view"/>
+ <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:layout_gravity="end|center_vertical"
+ android:id="@+id/action_button" android:visibility="gone"/>
+ <FrameLayout
+ android:id="@+id/overlay"
+ android:visibility="gone"
+ android:background="@color/card_tropical"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/touch_item_min_height">
+ <TextView android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="@string/swiping"/>
+ </FrameLayout>
+</android.support.v7.widget.CardView>
\ No newline at end of file
diff --git a/samples/Support7Demos/res/values/dimens.xml b/samples/Support7Demos/res/values/dimens.xml
index f952d18..f2520b9 100644
--- a/samples/Support7Demos/res/values/dimens.xml
+++ b/samples/Support7Demos/res/values/dimens.xml
@@ -17,5 +17,6 @@
<resources>
<dimen name="color_palette_size">60dp</dimen>
+ <dimen name="touch_item_min_height">60dp</dimen>
</resources>
diff --git a/samples/Support7Demos/res/values/strings.xml b/samples/Support7Demos/res/values/strings.xml
index 6e2c2f7..d34dab5 100644
--- a/samples/Support7Demos/res/values/strings.xml
+++ b/samples/Support7Demos/res/values/strings.xml
@@ -178,5 +178,16 @@
<string name="sorted_list_activity">Sorted List</string>
<string name="add_new_item">Add New Item</string>
<string name="start_action_mode">Start Action Mode</string>
-
+ <string name="swipe_to_dismiss_activity">RecyclerView/ItemTouchHelper/Swipe To Dismiss</string>
+ <string name="drag_and_drop_activity">RecyclerView/ItemTouchHelper/Drag and Drop Activity</string>
+ <string name="swipe_start">start</string>
+ <string name="swipe_end">end</string>
+ <string name="pointer_swipe_enabled">pointer swipe</string>
+ <string name="custom_swipe_enabled">custom swipe</string>
+ <string name="drag_up">up</string>
+ <string name="drag_down">down</string>
+ <string name="long_press_drag">long press drag</string>
+ <string name="drag">drag me</string>
+ <string name="swipe">swipe me</string>
+ <string name="swiping">swiping</string>
</resources>
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/widget/BaseLayoutManagerActivity.java b/samples/Support7Demos/src/com/example/android/supportv7/widget/BaseLayoutManagerActivity.java
index 4bb64f4..782da52 100644
--- a/samples/Support7Demos/src/com/example/android/supportv7/widget/BaseLayoutManagerActivity.java
+++ b/samples/Support7Demos/src/com/example/android/supportv7/widget/BaseLayoutManagerActivity.java
@@ -19,12 +19,15 @@
import com.example.android.supportv7.Cheeses;
import com.example.android.supportv7.R;
import com.example.android.supportv7.widget.adapter.SimpleStringAdapter;
+import com.example.android.supportv7.widget.util.ConfigToggle;
+import com.example.android.supportv7.widget.util.ConfigViewHolder;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
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 android.widget.BaseAdapter;
@@ -167,56 +170,11 @@
abstract ConfigToggle[] createConfigToggles();
- private class ConfigViewHolder extends RecyclerView.ViewHolder
- implements CompoundButton.OnCheckedChangeListener {
-
- private CheckBox mCheckBox;
-
- private ConfigToggle mConfigToggle;
-
- public ConfigViewHolder(View itemView) {
- super(itemView);
- mCheckBox = (CheckBox) itemView;
- mCheckBox.setOnCheckedChangeListener(this);
- }
-
- public void bind(ConfigToggle toggle) {
- mConfigToggle = toggle;
- mCheckBox.setText(toggle.getText());
- mCheckBox.setChecked(toggle.isChecked());
- }
-
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- if (mConfigToggle != null) {
- mConfigToggle.onChange(isChecked);
- }
- }
- }
-
-
- public abstract static class ConfigToggle {
-
- private String mLabel;
-
- protected ConfigToggle(Context context, int labelId) {
- mLabel = context.getResources().getString(labelId);
- }
-
- public String getText() {
- return mLabel;
- }
-
- abstract public boolean isChecked();
-
- abstract public void onChange(boolean newValue);
- }
-
-
private RecyclerView.Adapter mConfigAdapter = new RecyclerView.Adapter<ConfigViewHolder>() {
@Override
public ConfigViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- return new ConfigViewHolder(new CheckBox(parent.getContext()));
+ return new ConfigViewHolder(LayoutInflater.from(parent.getContext())
+ .inflate(R.layout.config_view_toggle, parent, false));
}
@Override
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/widget/GridLayoutManagerActivity.java b/samples/Support7Demos/src/com/example/android/supportv7/widget/GridLayoutManagerActivity.java
index ef25c0b..3ce5c60 100644
--- a/samples/Support7Demos/src/com/example/android/supportv7/widget/GridLayoutManagerActivity.java
+++ b/samples/Support7Demos/src/com/example/android/supportv7/widget/GridLayoutManagerActivity.java
@@ -18,6 +18,7 @@
import com.example.android.supportv7.Cheeses;
import com.example.android.supportv7.R;
import com.example.android.supportv7.widget.adapter.SimpleStringAdapter;
+import com.example.android.supportv7.widget.util.ConfigToggle;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.GridLayoutManager;
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/widget/LinearLayoutManagerActivity.java b/samples/Support7Demos/src/com/example/android/supportv7/widget/LinearLayoutManagerActivity.java
index 9aaa558..7482e3e 100644
--- a/samples/Support7Demos/src/com/example/android/supportv7/widget/LinearLayoutManagerActivity.java
+++ b/samples/Support7Demos/src/com/example/android/supportv7/widget/LinearLayoutManagerActivity.java
@@ -22,6 +22,7 @@
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import com.example.android.supportv7.R;
+import com.example.android.supportv7.widget.util.ConfigToggle;
/**
* A sample activity that uses {@link LinearLayoutManager}.
@@ -41,7 +42,7 @@
}
@Override
- BaseLayoutManagerActivity.ConfigToggle[] createConfigToggles() {
+ ConfigToggle[] createConfigToggles() {
return new ConfigToggle[]{
new ConfigToggle(this, R.string.checkbox_orientation) {
@Override
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/widget/touch/DragAndDropActivity.java b/samples/Support7Demos/src/com/example/android/supportv7/widget/touch/DragAndDropActivity.java
new file mode 100644
index 0000000..7f9f7e5
--- /dev/null
+++ b/samples/Support7Demos/src/com/example/android/supportv7/widget/touch/DragAndDropActivity.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2015 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.supportv7.widget.touch;
+
+import com.example.android.supportv7.R;
+import com.example.android.supportv7.widget.util.ConfigToggle;
+
+import android.annotation.TargetApi;
+import android.os.Build;
+import android.support.v4.view.MotionEventCompat;
+import android.support.v7.widget.RecyclerView;
+import android.support.v7.widget.helper.ItemTouchHelper;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+
+public class DragAndDropActivity extends ItemTouchHelperActivity {
+
+ boolean mDragUpEnabled = true;
+ boolean mDragDownEnabled = true;
+ boolean mLongPressDragEnabled = true;
+
+ @Override
+ ConfigToggle[] createConfigToggles() {
+ return new ConfigToggle[]{
+ new ConfigToggle(this, R.string.drag_up) {
+ @Override
+ public boolean isChecked() {
+ return mDragUpEnabled;
+ }
+
+ @Override
+ public void onChange(boolean newValue) {
+ mDragUpEnabled = newValue;
+ }
+ },
+ new ConfigToggle(this, R.string.drag_down) {
+ @Override
+ public boolean isChecked() {
+ return mDragDownEnabled;
+ }
+
+ @Override
+ public void onChange(boolean newValue) {
+ mDragDownEnabled = newValue;
+ }
+ },
+ new ConfigToggle(this, R.string.long_press_drag) {
+ @Override
+ public boolean isChecked() {
+ return mLongPressDragEnabled;
+ }
+
+ @Override
+ public void onChange(boolean newValue) {
+ mLongPressDragEnabled = newValue;
+ mAdapter.notifyDataSetChanged();
+ }
+ }
+ };
+ }
+
+ @Override
+ public boolean isLongPressDragEnabled() {
+ return mLongPressDragEnabled;
+ }
+
+ @Override
+ public void onBind(ItemTouchViewHolder viewHolder) {
+ super.onBind(viewHolder);
+ viewHolder.actionButton.setVisibility(mLongPressDragEnabled ? View.GONE : View.VISIBLE);
+ }
+
+ @Override
+ public void clearView(RecyclerView.ViewHolder viewHolder) {
+ super.clearView(viewHolder);
+ ItemTouchViewHolder touchVH = (ItemTouchViewHolder) viewHolder;
+ touchVH.cardView.setCardBackgroundColor(getResources().getColor(android.R.color.white));
+ touchVH.overlay.setVisibility(View.GONE);
+ }
+
+ @Override
+ public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) {
+ ItemTouchViewHolder touchVH = (ItemTouchViewHolder) viewHolder;
+ if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) {
+ touchVH.cardView.setCardBackgroundColor(getResources().getColor(R.color.card_aquatic));
+ }
+ super.onSelectedChanged(viewHolder, actionState);
+ }
+
+ @Override
+ public ItemTouchViewHolder onCreateViewHolder(ViewGroup parent) {
+ final ItemTouchViewHolder vh = super.onCreateViewHolder(parent);
+ vh.actionButton.setText(R.string.drag);
+ vh.actionButton.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
+ mItemTouchHelper.startDrag(vh);
+ }
+ return false;
+ }
+ });
+ return vh;
+ }
+
+ @Override
+ public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
+ return mCallback.makeMovementFlags(
+ (mDragUpEnabled ? ItemTouchHelper.UP : 0) |
+ (mDragDownEnabled ? ItemTouchHelper.DOWN : 0), 0);
+ }
+}
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/widget/touch/ItemTouchHelperActivity.java b/samples/Support7Demos/src/com/example/android/supportv7/widget/touch/ItemTouchHelperActivity.java
new file mode 100644
index 0000000..54a0bb3
--- /dev/null
+++ b/samples/Support7Demos/src/com/example/android/supportv7/widget/touch/ItemTouchHelperActivity.java
@@ -0,0 +1,283 @@
+/*
+ * Copyright (C) 2015 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.supportv7.widget.touch;
+
+import com.example.android.supportv7.Cheeses;
+import com.example.android.supportv7.R;
+import com.example.android.supportv7.widget.util.ConfigToggle;
+import com.example.android.supportv7.widget.util.ConfigViewHolder;
+
+import android.app.Activity;
+import android.graphics.Canvas;
+import android.os.Bundle;
+import android.support.v7.widget.CardView;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.support.v7.widget.helper.ItemTouchHelper;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.TextView;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Sample activity from which ItemTouchHelper demo activities inherit.
+ */
+abstract public class ItemTouchHelperActivity extends Activity {
+
+ public RecyclerView mRecyclerView;
+
+ public ItemTouchAdapter mAdapter;
+
+ public ItemTouchHelper mItemTouchHelper;
+
+ public ItemTouchHelper.Callback mCallback;
+
+ private ConfigToggle[] mConfigToggles;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_item_touch);
+ mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
+ mRecyclerView.setHasFixedSize(true);
+ mAdapter = createAdapter();
+ mRecyclerView.setAdapter(mAdapter);
+ mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
+ mItemTouchHelper = createItemTouchHelper();
+ mItemTouchHelper.attachToRecyclerView(mRecyclerView);
+ initToggles();
+ }
+
+ private void initToggles() {
+ mConfigToggles = createConfigToggles();
+ RecyclerView configView = (RecyclerView) findViewById(R.id.config_recycler_view);
+ configView.setAdapter(new RecyclerView.Adapter<ConfigViewHolder>() {
+ @Override
+ public ConfigViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ return new ConfigViewHolder(LayoutInflater.from(parent.getContext())
+ .inflate(R.layout.config_view_toggle, parent, false));
+ }
+
+ @Override
+ public void onBindViewHolder(ConfigViewHolder holder, int position) {
+ ConfigToggle toggle = mConfigToggles[position];
+ holder.bind(toggle);
+ }
+
+ @Override
+ public int getItemCount() {
+ return mConfigToggles.length;
+ }
+ });
+ configView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL,
+ false));
+ configView.setHasFixedSize(true);
+ }
+
+ abstract ConfigToggle[] createConfigToggles();
+
+ public ItemTouchHelper createItemTouchHelper() {
+ mCallback = createCallback();
+ return new ItemTouchHelper(mCallback);
+ }
+
+ public ItemTouchHelper.Callback createCallback() {
+ return new ItemTouchHelper.Callback() {
+ @Override
+ public int getMovementFlags(RecyclerView recyclerView,
+ RecyclerView.ViewHolder viewHolder) {
+ return ItemTouchHelperActivity.this.getMovementFlags(recyclerView, viewHolder);
+ }
+
+ @Override
+ public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder,
+ RecyclerView.ViewHolder target) {
+ mAdapter.move(viewHolder.getAdapterPosition(), target.getAdapterPosition());
+ return true;
+ }
+
+ @Override
+ public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
+ mAdapter.delete(viewHolder.getAdapterPosition());
+ }
+
+ @Override
+ public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) {
+ super.onSelectedChanged(viewHolder, actionState);
+ ItemTouchHelperActivity.this.onSelectedChanged(viewHolder, actionState);
+ }
+
+ @Override
+ public void onChildDraw(Canvas c, RecyclerView recyclerView,
+ RecyclerView.ViewHolder viewHolder,
+ float dX, float dY, int actionState, boolean isCurrentlyActive) {
+ if (ItemTouchHelperActivity.this.onChildDraw(c, recyclerView, viewHolder,
+ dX, dY, actionState, isCurrentlyActive)) {
+ return;
+ }
+ super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState,
+ isCurrentlyActive);
+ }
+
+ @Override
+ public void onChildDrawOver(Canvas c, RecyclerView recyclerView,
+ RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState,
+ boolean isCurrentlyActive) {
+ if (ItemTouchHelperActivity.this.onChildDrawOver(c, recyclerView, viewHolder,
+ dX, dY, actionState, isCurrentlyActive)) {
+ return;
+ }
+ super.onChildDrawOver(c, recyclerView, viewHolder, dX, dY, actionState,
+ isCurrentlyActive);
+ }
+
+ @Override
+ public boolean isLongPressDragEnabled() {
+ return ItemTouchHelperActivity.this.isLongPressDragEnabled();
+ }
+
+ @Override
+ public boolean isItemViewSwipeEnabled() {
+ return ItemTouchHelperActivity.this.isPointerSwipeEnabled();
+ }
+
+ @Override
+ public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
+ super.clearView(recyclerView, viewHolder);
+ ItemTouchHelperActivity.this.clearView(viewHolder);
+ }
+ };
+ }
+
+ /**
+ * @return True if we should NOT call parent
+ */
+ public boolean onChildDraw(Canvas c, RecyclerView recyclerView,
+ RecyclerView.ViewHolder viewHolder,
+ float dX, float dY, int actionState, boolean isCurrentlyActive) {
+ return false;
+ }
+
+ /**
+ * @return True if we should NOT call parent
+ */
+ public boolean onChildDrawOver(Canvas c, RecyclerView recyclerView,
+ RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState,
+ boolean isCurrentlyActive) {
+ return false;
+ }
+
+ public void clearView(RecyclerView.ViewHolder viewHolder) {
+
+ }
+
+ public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) {
+
+ }
+
+ public boolean isLongPressDragEnabled() {
+ return true;
+ }
+
+ public boolean isPointerSwipeEnabled() {
+ return true;
+ }
+
+ public ItemTouchViewHolder onCreateViewHolder(ViewGroup parent) {
+ ItemTouchViewHolder itemTouchViewHolder = new ItemTouchViewHolder(
+ LayoutInflater.from(parent.getContext())
+ .inflate(R.layout.touch_item, parent, false));
+ return itemTouchViewHolder;
+ }
+
+ abstract public int getMovementFlags(RecyclerView recyclerView,
+ RecyclerView.ViewHolder viewHolder);
+
+ public ItemTouchAdapter createAdapter() {
+ return new ItemTouchAdapter();
+ }
+
+ public void onBind(ItemTouchViewHolder viewHolder) {
+
+ }
+
+ public void onCreateViewHolder(ItemTouchViewHolder viewHolder) {
+
+ }
+
+ public class ItemTouchViewHolder extends RecyclerView.ViewHolder {
+
+ public final TextView textView;
+
+ public final Button actionButton;
+
+ public final CardView cardView;
+
+ public final View overlay;
+
+ public ItemTouchViewHolder(View itemView) {
+ super(itemView);
+ cardView = (CardView) itemView;
+ textView = (TextView) itemView.findViewById(R.id.text_view);
+ actionButton = (Button) itemView.findViewById(R.id.action_button);
+ overlay = itemView.findViewById(R.id.overlay);
+ }
+ }
+
+ public class ItemTouchAdapter extends RecyclerView.Adapter<ItemTouchViewHolder> {
+
+ private List<String> mItems = new ArrayList<String>();
+
+ public ItemTouchAdapter() {
+ mItems.addAll(Arrays.asList(Cheeses.sCheeseStrings));
+ }
+
+ @Override
+ public ItemTouchViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ return ItemTouchHelperActivity.this.onCreateViewHolder(parent);
+ }
+
+ @Override
+ public void onBindViewHolder(ItemTouchViewHolder holder, int position) {
+ holder.textView.setText(mItems.get(position));
+ onBind(holder);
+ }
+
+ public void delete(int position) {
+ mItems.remove(position);
+ notifyItemRemoved(position);
+ }
+
+ public void move(int from, int to) {
+ String prev = mItems.remove(from);
+ mItems.add(to > from ? to - 1 : to, prev);
+ notifyItemMoved(from, to);
+ }
+
+ @Override
+ public int getItemCount() {
+ return mItems.size();
+ }
+ }
+
+
+}
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/widget/touch/SwipeToDismissActivity.java b/samples/Support7Demos/src/com/example/android/supportv7/widget/touch/SwipeToDismissActivity.java
new file mode 100644
index 0000000..bb7e27e
--- /dev/null
+++ b/samples/Support7Demos/src/com/example/android/supportv7/widget/touch/SwipeToDismissActivity.java
@@ -0,0 +1,173 @@
+/*
+ * Copyright (C) 2015 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.supportv7.widget.touch;
+
+import com.example.android.supportv7.R;
+import com.example.android.supportv7.widget.util.ConfigToggle;
+
+import android.annotation.TargetApi;
+import android.graphics.Canvas;
+import android.os.Build;
+import android.support.v4.view.MotionEventCompat;
+import android.support.v7.widget.RecyclerView;
+import android.support.v7.widget.helper.ItemTouchHelper;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+
+public class SwipeToDismissActivity extends ItemTouchHelperActivity {
+ boolean mSwipeStartEnabled = true;
+ boolean mSwipeEndEnabled = true;
+ boolean mPointerSwipeEnabled = true;
+ boolean mCustomSwipeEnabled = false;
+
+ @Override
+ ConfigToggle[] createConfigToggles() {
+ ConfigToggle[] configToggles = {
+ new ConfigToggle(this, R.string.swipe_start) {
+ @Override
+ public boolean isChecked() {
+ return mSwipeStartEnabled;
+ }
+
+ @Override
+ public void onChange(boolean newValue) {
+ mSwipeStartEnabled = newValue;
+ }
+ },
+ new ConfigToggle(this, R.string.swipe_end) {
+ @Override
+ public boolean isChecked() {
+ return mSwipeEndEnabled;
+ }
+
+ @Override
+ public void onChange(boolean newValue) {
+ mSwipeEndEnabled = newValue;
+ }
+ },
+ new ConfigToggle(this, R.string.pointer_swipe_enabled) {
+ @Override
+ public boolean isChecked() {
+ return mPointerSwipeEnabled;
+ }
+
+ @Override
+ public void onChange(boolean newValue) {
+ mPointerSwipeEnabled = newValue;
+ mAdapter.notifyDataSetChanged();
+ }
+ }
+ };
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
+ ConfigToggle[] copy = new ConfigToggle[configToggles.length + 1];
+ System.arraycopy(configToggles, 0, copy, 0, configToggles.length);
+ copy[copy.length - 1] = new ConfigToggle(this, R.string.custom_swipe_enabled) {
+ @Override
+ public boolean isChecked() {
+ return mCustomSwipeEnabled;
+ }
+
+ @Override
+ public void onChange(boolean newValue) {
+ mCustomSwipeEnabled = newValue;
+ }
+ };
+ return copy;
+ } else {
+ return configToggles;
+ }
+ }
+
+ @Override
+ public void onBind(ItemTouchViewHolder viewHolder) {
+ super.onBind(viewHolder);
+ viewHolder.actionButton.setVisibility(mPointerSwipeEnabled ? View.GONE : View.VISIBLE);
+ }
+
+ @Override
+ public void clearView(RecyclerView.ViewHolder viewHolder) {
+ super.clearView(viewHolder);
+ ItemTouchViewHolder touchVH = (ItemTouchViewHolder) viewHolder;
+ touchVH.cardView.setCardBackgroundColor(getResources().getColor(android.R.color.white));
+ touchVH.overlay.setVisibility(View.GONE);
+ }
+
+ @Override
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
+ public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) {
+ ItemTouchViewHolder touchVH = (ItemTouchViewHolder) viewHolder;
+ if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) {
+ touchVH.cardView.setCardBackgroundColor(getResources().getColor(R.color.card_aquatic));
+ if (mCustomSwipeEnabled) {
+ // hide it
+ touchVH.overlay.setTranslationX(viewHolder.itemView.getWidth());
+ touchVH.overlay.setVisibility(View.VISIBLE);
+ }
+ }
+ super.onSelectedChanged(viewHolder, actionState);
+ }
+
+ @Override
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
+ public boolean onChildDraw(Canvas c, RecyclerView recyclerView,
+ RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState,
+ boolean isCurrentlyActive) {
+ if (!mCustomSwipeEnabled) {
+ return false;
+ }
+ ItemTouchViewHolder touchVH = (ItemTouchViewHolder) viewHolder;
+ final float dir = Math.signum(dX);
+ if (dir == 0) {
+ touchVH.overlay.setTranslationX(-touchVH.overlay.getWidth());
+ } else {
+ final float overlayOffset = dX - dir * viewHolder.itemView.getWidth();
+ touchVH.overlay.setTranslationX(overlayOffset);
+ }
+ float alpha = (float) (.2 + .8 * Math.abs(dX) / viewHolder.itemView.getWidth());
+ touchVH.overlay.setAlpha(alpha);
+ return true;
+ }
+
+ @Override
+ public ItemTouchViewHolder onCreateViewHolder(ViewGroup parent) {
+ final ItemTouchViewHolder vh = super.onCreateViewHolder(parent);
+ vh.actionButton.setText(R.string.swipe);
+ vh.actionButton.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
+ mItemTouchHelper.startSwipe(vh);
+ }
+ return false;
+ }
+ });
+ return vh;
+ }
+
+ @Override
+ public boolean isPointerSwipeEnabled() {
+ return mPointerSwipeEnabled;
+ }
+
+ @Override
+ public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
+ return mCallback.makeMovementFlags(0,
+ (mSwipeStartEnabled ? ItemTouchHelper.START : 0) |
+ (mSwipeEndEnabled ? ItemTouchHelper.END : 0));
+ }
+}
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/widget/util/ConfigToggle.java b/samples/Support7Demos/src/com/example/android/supportv7/widget/util/ConfigToggle.java
new file mode 100644
index 0000000..eae04b0
--- /dev/null
+++ b/samples/Support7Demos/src/com/example/android/supportv7/widget/util/ConfigToggle.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2015 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.supportv7.widget.util;
+
+import android.content.Context;
+
+abstract public class ConfigToggle {
+ private String mLabel;
+
+ protected ConfigToggle(Context context, int labelId) {
+ mLabel = context.getResources().getString(labelId);
+ }
+
+ public String getText() {
+ return mLabel;
+ }
+
+ abstract public boolean isChecked();
+
+ abstract public void onChange(boolean newValue);
+}
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/widget/util/ConfigViewHolder.java b/samples/Support7Demos/src/com/example/android/supportv7/widget/util/ConfigViewHolder.java
new file mode 100644
index 0000000..1bdf155
--- /dev/null
+++ b/samples/Support7Demos/src/com/example/android/supportv7/widget/util/ConfigViewHolder.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2015 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.supportv7.widget.util;
+
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+
+public class ConfigViewHolder extends RecyclerView.ViewHolder
+ implements CompoundButton.OnCheckedChangeListener {
+
+ private CheckBox mCheckBox;
+
+ private ConfigToggle mConfigToggle;
+
+ public ConfigViewHolder(View itemView) {
+ super(itemView);
+ mCheckBox = (CheckBox) itemView;
+ mCheckBox.setOnCheckedChangeListener(this);
+ }
+
+ public void bind(ConfigToggle toggle) {
+ mConfigToggle = toggle;
+ mCheckBox.setText(toggle.getText());
+ mCheckBox.setChecked(toggle.isChecked());
+ }
+
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ if (mConfigToggle != null) {
+ mConfigToggle.onChange(isChecked);
+ }
+ }
+}
diff --git a/samples/SupportDesignDemos/Android.mk b/samples/SupportDesignDemos/Android.mk
index 6da1811..f70b6e1 100644
--- a/samples/SupportDesignDemos/Android.mk
+++ b/samples/SupportDesignDemos/Android.mk
@@ -25,13 +25,16 @@
LOCAL_STATIC_JAVA_LIBRARIES := \
android-support-v4 \
android-support-v7-appcompat \
+ android-support-v7-recyclerview \
android-support-design
LOCAL_RESOURCE_DIR = \
$(LOCAL_PATH)/res \
frameworks/support/v7/appcompat/res \
+ frameworks/support/v7/recyclerview/res \
frameworks/support/design/res
LOCAL_AAPT_FLAGS := \
--auto-add-overlay \
--extra-packages android.support.v7.appcompat \
+ --extra-packages android.support.v7.recyclerview \
--extra-packages android.support.design
include $(BUILD_PACKAGE)
diff --git a/samples/SupportDesignDemos/AndroidManifest.xml b/samples/SupportDesignDemos/AndroidManifest.xml
index 8fcdf38..0835d23 100644
--- a/samples/SupportDesignDemos/AndroidManifest.xml
+++ b/samples/SupportDesignDemos/AndroidManifest.xml
@@ -68,6 +68,7 @@
android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
+ <category android:name="com.example.android.support.design.SAMPLE_CODE" />
</intent-filter>
</activity>
@@ -89,5 +90,86 @@
</intent-filter>
</activity>
+ <activity android:name=".widget.SnackbarWithoutCoordinatorLayout"
+ android:label="@string/design_snackbar_without_col"
+ android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.example.android.support.design.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name=".widget.AppBarLayoutToolbarScrollTabsScroll"
+ android:label="@string/design_appbar_toolbar_scroll_tabs_scroll"
+ android:theme="@style/Theme.Design">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.example.android.support.design.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name=".widget.AppBarLayoutToolbarScrollTabsPin"
+ android:label="@string/design_appbar_toolbar_scroll_tabs_pin"
+ android:theme="@style/Theme.Design">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.example.android.support.design.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name=".widget.AppBarLayoutToolbarCollapseThenPin"
+ android:label="@string/design_appbar_collapsing_toolbar_pin"
+ android:theme="@style/Theme.Design">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.example.android.support.design.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name=".widget.AppBarLayoutToolbarCollapseThenPinWithFab"
+ android:label="@string/design_appbar_collapsing_toolbar_pin_fab"
+ android:theme="@style/Theme.Design">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.example.android.support.design.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name=".widget.AppBarLayoutToolbarCollapseThenScroll"
+ android:label="@string/design_appbar_collapsing_toolbar_scroll"
+ android:theme="@style/Theme.Design">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.example.android.support.design.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name=".widget.AppBarLayoutToolbarCollapseWithImage"
+ android:label="@string/design_appbar_collapsing_toolbar_with_image"
+ android:theme="@style/Theme.Design">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.example.android.support.design.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name=".widget.AppBarLayoutToolbarCollapseWithImageWithInsets"
+ android:label="@string/design_appbar_collapsing_toolbar_with_image_insets"
+ android:theme="@style/Theme.Design.TransparentStatus">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.example.android.support.design.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name=".widget.AppBarLayoutToolbarParallaxOverlapContent"
+ android:label="@string/design_appbar_parallax_overlap"
+ android:theme="@style/Theme.Design">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.example.android.support.design.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
</application>
</manifest>
diff --git a/samples/SupportDesignDemos/res/drawable-nodpi/photo.jpg b/samples/SupportDesignDemos/res/drawable-nodpi/photo.jpg
new file mode 100644
index 0000000..d5a2ef0
--- /dev/null
+++ b/samples/SupportDesignDemos/res/drawable-nodpi/photo.jpg
Binary files differ
diff --git a/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_pin.xml b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_pin.xml
new file mode 100644
index 0000000..2809b04
--- /dev/null
+++ b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_pin.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 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.
+-->
+
+<android.support.design.widget.CoordinatorLayout
+ 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.support.design.widget.AppBarLayout
+ android:layout_height="192dp"
+ android:layout_width="match_parent"
+ android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
+
+ <android.support.design.widget.CollapsingToolbarLayout
+ android:id="@+id/collapsing_app_bar"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_scrollFlags="scroll|exitUntilCollapsed">
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_height="?attr/actionBarSize"
+ android:layout_width="match_parent"
+ app:layout_collapseMode="pin"/>
+
+ </android.support.design.widget.CollapsingToolbarLayout>
+
+ </android.support.design.widget.AppBarLayout>
+
+ <include layout="@layout/include_appbar_recyclerview"/>
+
+</android.support.design.widget.CoordinatorLayout>
diff --git a/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_pin_with_fab.xml b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_pin_with_fab.xml
new file mode 100644
index 0000000..cff9d92
--- /dev/null
+++ b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_pin_with_fab.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 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.
+-->
+
+<android.support.design.widget.CoordinatorLayout
+ 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.support.design.widget.AppBarLayout
+ android:id="@+id/appbar"
+ android:layout_height="192dp"
+ android:layout_width="match_parent"
+ android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
+
+ <android.support.design.widget.CollapsingToolbarLayout
+ android:id="@+id/collapsing_app_bar"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_scrollFlags="scroll|exitUntilCollapsed">
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_height="?attr/actionBarSize"
+ android:layout_width="match_parent"
+ app:layout_collapseMode="pin"/>
+
+ </android.support.design.widget.CollapsingToolbarLayout>
+
+ </android.support.design.widget.AppBarLayout>
+
+ <include layout="@layout/include_appbar_scrollview"/>
+
+ <android.support.design.widget.FloatingActionButton
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ app:layout_anchor="@id/appbar"
+ app:layout_anchorGravity="bottom|right|end"
+ android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha"
+ android:layout_marginRight="16dp"
+ android:clickable="true"
+ app:fabSize="mini"/>
+
+</android.support.design.widget.CoordinatorLayout>
diff --git a/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_scroll.xml b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_scroll.xml
new file mode 100644
index 0000000..a865ca3
--- /dev/null
+++ b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_scroll.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 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.
+-->
+
+<android.support.design.widget.CoordinatorLayout 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.support.design.widget.AppBarLayout
+ android:layout_height="192dp"
+ android:layout_width="match_parent"
+ android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
+
+ <android.support.design.widget.CollapsingToolbarLayout
+ android:id="@+id/collapsing_app_bar"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed">
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_height="?attr/actionBarSize"
+ android:layout_width="match_parent"
+ app:layout_collapseMode="pin"/>
+
+ </android.support.design.widget.CollapsingToolbarLayout>
+
+ </android.support.design.widget.AppBarLayout>
+
+ <include layout="@layout/include_appbar_scrollview"/>
+
+</android.support.design.widget.CoordinatorLayout>
diff --git a/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_with_image.xml b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_with_image.xml
new file mode 100644
index 0000000..ebdbf10
--- /dev/null
+++ b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_with_image.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 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.
+-->
+
+<android.support.design.widget.CoordinatorLayout
+ 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.support.design.widget.AppBarLayout
+ android:layout_height="192dp"
+ android:layout_width="match_parent"
+ android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
+
+ <android.support.design.widget.CollapsingToolbarLayout
+ android:id="@+id/collapsing_app_bar"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_scrollFlags="scroll|exitUntilCollapsed"
+ app:contentScrim="?attr/colorPrimary">
+
+ <ImageView
+ android:id="@+id/app_bar_image"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_collapseMode="parallax"
+ android:src="@drawable/photo"
+ android:scaleType="centerCrop"/>
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_height="?attr/actionBarSize"
+ android:layout_width="match_parent"
+ app:layout_collapseMode="pin"/>
+
+ </android.support.design.widget.CollapsingToolbarLayout>
+
+ </android.support.design.widget.AppBarLayout>
+
+ <include layout="@layout/include_appbar_scrollview"/>
+
+</android.support.design.widget.CoordinatorLayout>
diff --git a/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_with_image_insets.xml b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_with_image_insets.xml
new file mode 100644
index 0000000..95f13c3
--- /dev/null
+++ b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_with_image_insets.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2015 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.
+ -->
+
+<android.support.design.widget.CoordinatorLayout
+ 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:fitsSystemWindows="true">
+
+ <android.support.design.widget.AppBarLayout
+ android:layout_height="256dp"
+ android:layout_width="match_parent"
+ android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
+ android:fitsSystemWindows="true">
+
+ <android.support.design.widget.CollapsingToolbarLayout
+ android:id="@+id/collapsing_app_bar"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_scrollFlags="scroll|exitUntilCollapsed"
+ app:contentScrim="?attr/colorPrimary">
+
+ <ImageView
+ android:id="@+id/app_bar_image"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_collapseMode="parallax"
+ android:src="@drawable/photo"
+ android:scaleType="centerCrop"/>
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_height="?attr/actionBarSize"
+ android:layout_width="match_parent"
+ app:layout_collapseMode="pin"/>
+
+ </android.support.design.widget.CollapsingToolbarLayout>
+
+ </android.support.design.widget.AppBarLayout>
+
+ <include layout="@layout/include_appbar_scrollview"/>
+
+</android.support.design.widget.CoordinatorLayout>
diff --git a/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_parallax_overlap.xml b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_parallax_overlap.xml
new file mode 100644
index 0000000..98158e7
--- /dev/null
+++ b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_parallax_overlap.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 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.
+-->
+
+<android.support.design.widget.CoordinatorLayout
+ 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.support.design.widget.AppBarLayout
+ android:layout_height="192dp"
+ android:layout_width="match_parent"
+ android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
+
+ <android.support.design.widget.CollapsingToolbarLayout
+ android:id="@+id/collapsing_app_bar"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_scrollFlags="scroll|exitUntilCollapsed"
+ app:layout_scrollInterpolator="@android:anim/decelerate_interpolator"
+ app:contentScrim="?attr/colorPrimary">
+
+ <ImageView
+ android:id="@+id/app_bar_image"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:src="@drawable/photo"
+ android:scaleType="centerCrop"/>
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_height="?attr/actionBarSize"
+ android:layout_width="match_parent"
+ app:layout_collapseMode="pin"/>
+
+ </android.support.design.widget.CollapsingToolbarLayout>
+
+ </android.support.design.widget.AppBarLayout>
+
+ <include layout="@layout/include_appbar_scrollview_with_image" />
+
+</android.support.design.widget.CoordinatorLayout>
diff --git a/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_scroll_tabs_pinned.xml b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_scroll_tabs_pinned.xml
new file mode 100644
index 0000000..ea94c8a
--- /dev/null
+++ b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_scroll_tabs_pinned.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 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.
+-->
+
+<android.support.design.widget.CoordinatorLayout
+ 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.support.design.widget.AppBarLayout
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_height="?attr/actionBarSize"
+ android:layout_width="match_parent"
+ app:layout_scrollFlags="scroll|enterAlways"/>
+
+ <android.support.design.widget.TabLayout
+ android:id="@+id/tabs"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ app:tabMode="scrollable"/>
+
+ </android.support.design.widget.AppBarLayout>
+
+ <include layout="@layout/include_appbar_recyclerview"/>
+
+</android.support.design.widget.CoordinatorLayout>
+
diff --git a/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_scroll_tabs_scroll.xml b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_scroll_tabs_scroll.xml
new file mode 100644
index 0000000..580c5c4
--- /dev/null
+++ b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_scroll_tabs_scroll.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 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.
+-->
+
+<android.support.design.widget.CoordinatorLayout
+ 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.support.design.widget.AppBarLayout
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_height="?attr/actionBarSize"
+ android:layout_width="match_parent"
+ app:layout_scrollFlags="scroll|enterAlways"/>
+
+ <android.support.design.widget.TabLayout
+ android:id="@+id/tabs"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ app:layout_scrollFlags="scroll|enterAlways"
+ app:tabMode="scrollable"/>
+
+ </android.support.design.widget.AppBarLayout>
+
+ <include layout="@layout/include_appbar_scrollview"/>
+
+</android.support.design.widget.CoordinatorLayout>
+
diff --git a/samples/SupportDesignDemos/res/layout/design_snackbar_without_col.xml b/samples/SupportDesignDemos/res/layout/design_snackbar_without_col.xml
new file mode 100644
index 0000000..055479a
--- /dev/null
+++ b/samples/SupportDesignDemos/res/layout/design_snackbar_without_col.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2015 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.
+ -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/content_view"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="16dp"
+ android:orientation="vertical">
+
+ <Button
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/snackbar_show_short"
+ android:onClick="showShort"/>
+
+ <Button
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/snackbar_show_short_action"
+ android:onClick="showAction"/>
+
+ <Button
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/snackbar_show_long"
+ android:onClick="showLong"/>
+
+ <Button
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/snackbar_show_long_action"
+ android:onClick="showLongAction"/>
+
+ <Button
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/snackbar_show_long_long_action"
+ android:onClick="showLongLongAction"/>
+
+</LinearLayout>
diff --git a/samples/SupportDesignDemos/res/layout/include_appbar_recyclerview.xml b/samples/SupportDesignDemos/res/layout/include_appbar_recyclerview.xml
new file mode 100644
index 0000000..ab255e4
--- /dev/null
+++ b/samples/SupportDesignDemos/res/layout/include_appbar_recyclerview.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2015 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.
+ -->
+<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/appbar_recyclerview"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior" />
\ No newline at end of file
diff --git a/samples/SupportDesignDemos/res/layout/include_appbar_scrollview.xml b/samples/SupportDesignDemos/res/layout/include_appbar_scrollview.xml
new file mode 100644
index 0000000..b10752a
--- /dev/null
+++ b/samples/SupportDesignDemos/res/layout/include_appbar_scrollview.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 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.
+-->
+<android.support.v4.widget.NestedScrollView 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"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="1000dp"
+ android:orientation="vertical">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
+ android:text="@string/scroll_top" />
+
+ <TextView
+ android:id="@+id/textview_dialogue"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="16dp"/>
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
+ android:text="@string/scroll_bottom" />
+
+ </LinearLayout>
+
+</android.support.v4.widget.NestedScrollView>
\ No newline at end of file
diff --git a/samples/SupportDesignDemos/res/layout/include_appbar_scrollview_with_image.xml b/samples/SupportDesignDemos/res/layout/include_appbar_scrollview_with_image.xml
new file mode 100644
index 0000000..a5392b2
--- /dev/null
+++ b/samples/SupportDesignDemos/res/layout/include_appbar_scrollview_with_image.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 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.
+-->
+<android.support.v4.widget.NestedScrollView 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"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior"
+ app:behavior_overlapTop="32dp">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="1000dp"
+ android:orientation="vertical">
+
+ <ImageView android:layout_width="72dp"
+ android:layout_height="72dp"
+ android:src="@drawable/app_sample_code"
+ android:layout_marginLeft="16dp"/>
+
+ <TextView
+ android:id="@+id/textview_dialogue"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="16dp"/>
+
+ </LinearLayout>
+
+</android.support.v4.widget.NestedScrollView>
\ No newline at end of file
diff --git a/samples/SupportDesignDemos/res/menu/sample_actions.xml b/samples/SupportDesignDemos/res/menu/sample_actions.xml
new file mode 100644
index 0000000..280005a
--- /dev/null
+++ b/samples/SupportDesignDemos/res/menu/sample_actions.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 Google Inc.
+
+ 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.
+-->
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+ <item android:id="@+id/action_search"
+ android:title="@string/menu_search"
+ android:icon="@drawable/abc_ic_search_api_mtrl_alpha"
+ app:showAsAction="ifRoom"/>
+ <item android:id="@+id/action_settings"
+ android:title="@string/menu_settings"
+ app:showAsAction="never"/>
+</menu>
diff --git a/samples/SupportDesignDemos/res/values-v21/styles.xml b/samples/SupportDesignDemos/res/values-v21/styles.xml
index 8faf5e6..298dcf3 100644
--- a/samples/SupportDesignDemos/res/values-v21/styles.xml
+++ b/samples/SupportDesignDemos/res/values-v21/styles.xml
@@ -17,6 +17,11 @@
<resources>
+ <style name="Theme.Design.TransparentStatus">
+ <item name="android:statusBarColor">@android:color/transparent</item>
+ <item name="android:windowDrawsSystemBarBackgrounds">true</item>
+ </style>
+
<style name="Theme.Navigation" parent="Theme.Navigation.Base">
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
diff --git a/samples/SupportDesignDemos/res/values/strings.xml b/samples/SupportDesignDemos/res/values/strings.xml
index b2cb6d7..c1d0bd6 100644
--- a/samples/SupportDesignDemos/res/values/strings.xml
+++ b/samples/SupportDesignDemos/res/values/strings.xml
@@ -56,10 +56,25 @@
<string name="design_snackbar_basic">Snackbar/Usage</string>
<string name="design_snackbar_fab">Snackbar/Coordinated with FAB</string>
+ <string name="design_snackbar_without_col">Snackbar/Usage without CoordinatorLayout</string>
<string name="snackbar_show_short">Snackbar (short message)</string>
<string name="snackbar_show_long">Snackbar (long message)</string>
<string name="snackbar_show_short_action">Show (short message + action)</string>
<string name="snackbar_show_long_action">Show (long message + action)</string>
<string name="snackbar_show_long_long_action">Show (long message + long action)</string>
+ <string name="design_appbar_toolbar_scroll_tabs_scroll">AppBar/Toolbar Scroll + Tabs Scroll</string>
+ <string name="design_appbar_toolbar_scroll_tabs_pin">AppBar/Toolbar Scroll + Tabs Pin</string>
+ <string name="design_appbar_collapsing_toolbar_pin">AppBar/Collapsing Toolbar (pinned)</string>
+ <string name="design_appbar_collapsing_toolbar_pin_fab">AppBar/Collapsing Toolbar (pinned with FAB)</string>
+ <string name="design_appbar_collapsing_toolbar_scroll">AppBar/Collapsing Toolbar (scroll off)</string>
+ <string name="design_appbar_collapsing_toolbar_with_image">AppBar/Collapsing Toolbar + Parallax Image</string>
+ <string name="design_appbar_collapsing_toolbar_with_image_insets">AppBar/Collapsing Toolbar + Parallax Image + Insets</string>
+ <string name="design_appbar_parallax_overlap">AppBar/Parallax Overlapping content</string>
+ <string name="scroll_top">Top</string>
+ <string name="scroll_bottom">Bottom</string>
+ <string name="menu_search">Search</string>
+ <string name="menu_settings">Settings</string>
+
+
</resources>
diff --git a/samples/SupportDesignDemos/res/values/styles.xml b/samples/SupportDesignDemos/res/values/styles.xml
index a63f93f..456ae58 100644
--- a/samples/SupportDesignDemos/res/values/styles.xml
+++ b/samples/SupportDesignDemos/res/values/styles.xml
@@ -23,6 +23,8 @@
<item name="colorAccent">#FFAB40</item>
</style>
+ <style name="Theme.Design.TransparentStatus">
+ </style>
<style name="Theme.FAB" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#ff00bcd4</item>
diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseThenPin.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseThenPin.java
new file mode 100644
index 0000000..2403852
--- /dev/null
+++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseThenPin.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2015 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 com.example.android.support.design.R;
+
+public class AppBarLayoutToolbarCollapseThenPin extends AppBarLayoutUsageBase {
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.design_appbar_toolbar_collapse_pin;
+ }
+}
diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseThenPinWithFab.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseThenPinWithFab.java
new file mode 100644
index 0000000..97a7a77
--- /dev/null
+++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseThenPinWithFab.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2015 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 com.example.android.support.design.R;
+
+public class AppBarLayoutToolbarCollapseThenPinWithFab extends AppBarLayoutUsageBase {
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.design_appbar_toolbar_collapse_pin_with_fab;
+ }
+}
diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseThenScroll.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseThenScroll.java
new file mode 100644
index 0000000..2a4cd26
--- /dev/null
+++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseThenScroll.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2015 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 com.example.android.support.design.R;
+
+public class AppBarLayoutToolbarCollapseThenScroll extends AppBarLayoutUsageBase {
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.design_appbar_toolbar_collapse_scroll;
+ }
+}
diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseWithImage.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseWithImage.java
new file mode 100644
index 0000000..8a11278
--- /dev/null
+++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseWithImage.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2015 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 com.example.android.support.design.R;
+
+public class AppBarLayoutToolbarCollapseWithImage extends AppBarLayoutUsageBase {
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.design_appbar_toolbar_collapse_with_image;
+ }
+}
diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseWithImageWithInsets.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseWithImageWithInsets.java
new file mode 100644
index 0000000..5a16d60
--- /dev/null
+++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseWithImageWithInsets.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2015 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 com.example.android.support.design.R;
+
+public class AppBarLayoutToolbarCollapseWithImageWithInsets extends AppBarLayoutUsageBase {
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.design_appbar_toolbar_collapse_with_image_insets;
+ }
+}
diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarParallaxOverlapContent.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarParallaxOverlapContent.java
new file mode 100644
index 0000000..8e45a36
--- /dev/null
+++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarParallaxOverlapContent.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2015 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 com.example.android.support.design.R;
+
+public class AppBarLayoutToolbarParallaxOverlapContent extends AppBarLayoutUsageBase {
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.design_appbar_toolbar_parallax_overlap;
+ }
+
+ @Override
+ protected boolean displayTitle() {
+ return false;
+ }
+}
diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarScrollTabsPin.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarScrollTabsPin.java
new file mode 100644
index 0000000..f153d8b
--- /dev/null
+++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarScrollTabsPin.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2015 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 com.example.android.support.design.R;
+
+public class AppBarLayoutToolbarScrollTabsPin extends AppBarLayoutUsageBase {
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.design_appbar_toolbar_scroll_tabs_pinned;
+ }
+}
diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarScrollTabsScroll.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarScrollTabsScroll.java
new file mode 100644
index 0000000..f48031f
--- /dev/null
+++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarScrollTabsScroll.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2015 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 com.example.android.support.design.R;
+
+public class AppBarLayoutToolbarScrollTabsScroll extends AppBarLayoutUsageBase {
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.design_appbar_toolbar_scroll_tabs_scroll;
+ }
+}
diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutUsageBase.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutUsageBase.java
new file mode 100644
index 0000000..f91ef51
--- /dev/null
+++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutUsageBase.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2015 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 com.example.android.support.design.Cheeses;
+import com.example.android.support.design.R;
+import com.example.android.support.design.Shakespeare;
+
+import android.os.Bundle;
+import android.support.design.widget.CollapsingToolbarLayout;
+import android.support.design.widget.TabLayout;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.support.v7.widget.Toolbar;
+import android.text.TextUtils;
+import android.view.Menu;
+import android.widget.TextView;
+
+import java.util.Random;
+
+abstract class AppBarLayoutUsageBase extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(getLayoutId());
+
+ // Retrieve the Toolbar from our content view, and set it as the action bar
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout)
+ findViewById(R.id.collapsing_app_bar);
+ if (appBarLayout != null && displayTitle()) {
+ appBarLayout.setTitle(getTitle());
+ }
+
+ TextView dialog = (TextView) findViewById(R.id.textview_dialogue);
+ if (dialog != null) {
+ dialog.setText(TextUtils.concat(Shakespeare.DIALOGUE));
+ }
+
+ RecyclerView recyclerView = (RecyclerView) findViewById(R.id.appbar_recyclerview);
+ if (recyclerView != null) {
+ setupRecyclerView(recyclerView);
+ }
+
+ TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
+ if (tabLayout != null) {
+ setupTabs(tabLayout);
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.sample_actions, menu);
+ return true;
+ }
+
+ private void addRandomTab(TabLayout tabLayout) {
+ Random r = new Random();
+ String cheese = Cheeses.sCheeseStrings[r.nextInt(Cheeses.sCheeseStrings.length)];
+ tabLayout.addTab(tabLayout.newTab().setText(cheese));
+ }
+
+ private void setupTabs(TabLayout tabLayout) {
+ for (int i = 0; i < 10; i++) {
+ addRandomTab(tabLayout);
+ }
+ }
+
+ private void setupRecyclerView(RecyclerView recyclerView) {
+ recyclerView.setLayoutManager(new LinearLayoutManager(recyclerView.getContext()));
+ recyclerView.setAdapter(new SimpleStringRecyclerViewAdapter(this, Cheeses.sCheeseStrings));
+ }
+
+ protected boolean displayTitle() {
+ return true;
+ }
+
+ protected abstract int getLayoutId();
+
+}
diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/SimpleStringRecyclerViewAdapter.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/SimpleStringRecyclerViewAdapter.java
new file mode 100644
index 0000000..2f9b79f
--- /dev/null
+++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/SimpleStringRecyclerViewAdapter.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2015 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 com.example.android.support.design.R;
+
+import android.content.Context;
+import android.graphics.Color;
+import android.support.v7.widget.RecyclerView;
+import android.text.Layout;
+import android.util.TypedValue;
+import android.view.LayoutInflater;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import java.util.ArrayList;
+import java.util.Collections;
+
+public class SimpleStringRecyclerViewAdapter
+ extends RecyclerView.Adapter<SimpleStringRecyclerViewAdapter.ViewHolder> {
+
+ private int mBackground;
+
+ private ArrayList<String> mValues;
+
+ public static class ViewHolder extends RecyclerView.ViewHolder {
+ public String mBoundString;
+ public TextView mTextView;
+
+ public ViewHolder(TextView v) {
+ super(v);
+ mTextView = v;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " '" + mTextView.getText();
+ }
+ }
+
+ public String getValueAt(int position) {
+ return mValues.get(position);
+ }
+
+ public SimpleStringRecyclerViewAdapter(Context context, String[] strings) {
+ TypedValue val = new TypedValue();
+ if (context.getTheme() != null) {
+ context.getTheme().resolveAttribute(R.attr.selectableItemBackground, val, true);
+ }
+ mBackground = val.resourceId;
+ mValues = new ArrayList<>();
+ Collections.addAll(mValues, strings);
+ }
+
+ @Override
+ public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ TextView textView = (TextView) LayoutInflater.from(parent.getContext())
+ .inflate(android.R.layout.simple_list_item_1, parent, false);
+ textView.setBackgroundResource(mBackground);
+ return new ViewHolder(textView);
+ }
+
+ @Override
+ public void onBindViewHolder(ViewHolder holder, int position) {
+ holder.mBoundString = mValues.get(position);
+ holder.mTextView.setText(position + ": " + mValues.get(position));
+ }
+
+ @Override
+ public int getItemCount() {
+ return mValues.size();
+ }
+}
diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/SnackbarWithFloatingActionButton.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/SnackbarWithFloatingActionButton.java
index cf8ec8a..1b79543 100644
--- a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/SnackbarWithFloatingActionButton.java
+++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/SnackbarWithFloatingActionButton.java
@@ -25,7 +25,7 @@
import android.view.ViewGroup;
/**
- * This demonstrates idiomatic usage of the Floating Action Button
+ * This demonstrates idiomatic usage of Snackbar with a Floating Action Button present
*/
public class SnackbarWithFloatingActionButton extends SnackbarUsage {
diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/SnackbarWithoutCoordinatorLayout.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/SnackbarWithoutCoordinatorLayout.java
new file mode 100644
index 0000000..71257b5
--- /dev/null
+++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/SnackbarWithoutCoordinatorLayout.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2015 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 com.example.android.support.design.R;
+
+/**
+ * This demonstrates idiomatic usage of Snackbar without a CoordinatorLayout
+ */
+public class SnackbarWithoutCoordinatorLayout extends SnackbarUsage {
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.design_snackbar_without_col;
+ }
+
+}
\ No newline at end of file
diff --git a/samples/SupportLeanbackDemos/Android.mk b/samples/SupportLeanbackDemos/Android.mk
index 41424a7..55bbe44 100644
--- a/samples/SupportLeanbackDemos/Android.mk
+++ b/samples/SupportLeanbackDemos/Android.mk
@@ -28,8 +28,10 @@
android-support-v17-leanback
LOCAL_RESOURCE_DIR = \
$(LOCAL_PATH)/res \
- frameworks/support/v17/leanback/res
+ frameworks/support/v17/leanback/res \
+ frameworks/support/v7/recyclerview/res
LOCAL_AAPT_FLAGS := \
--auto-add-overlay \
- --extra-packages android.support.v17.leanback
+ --extra-packages android.support.v17.leanback \
+ --extra-packages android.support.v7.recyclerview
include $(BUILD_PACKAGE)
diff --git a/samples/SupportLeanbackDemos/AndroidManifest.xml b/samples/SupportLeanbackDemos/AndroidManifest.xml
index e429423..837a123 100644
--- a/samples/SupportLeanbackDemos/AndroidManifest.xml
+++ b/samples/SupportLeanbackDemos/AndroidManifest.xml
@@ -33,6 +33,10 @@
android:theme="@style/Theme.Example.Leanback.Details"
android:exported="true" />
+ <activity android:name="SearchDetailsActivity"
+ android:theme="@style/Theme.Example.Leanback.SearchDetails"
+ android:exported="true" />
+
<activity android:name="RowsActivity"
android:theme="@style/Theme.Example.Leanback.Rows"
android:exported="true" />
@@ -56,5 +60,9 @@
android:theme="@style/Theme.Example.Leanback.GuidedStep"
android:exported="true" />
+ <activity android:name="DetailsPresenterSelectionActivity"
+ android:theme="@style/Theme.Example.Leanback.GuidedStep"
+ android:exported="true" />
+
</application>
</manifest>
diff --git a/samples/SupportLeanbackDemos/res/layout/details.xml b/samples/SupportLeanbackDemos/res/layout/details.xml
index 4af4e6a..3159f54 100644
--- a/samples/SupportLeanbackDemos/res/layout/details.xml
+++ b/samples/SupportLeanbackDemos/res/layout/details.xml
@@ -16,7 +16,7 @@
-->
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
- android:name="com.example.android.leanback.DetailsFragment"
+ android:name="com.example.android.leanback.NewDetailsFragment"
android:id="@+id/details_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
diff --git a/samples/SupportLeanbackDemos/res/layout/legacy_details.xml b/samples/SupportLeanbackDemos/res/layout/legacy_details.xml
new file mode 100644
index 0000000..4af4e6a
--- /dev/null
+++ b/samples/SupportLeanbackDemos/res/layout/legacy_details.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 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.
+-->
+
+<fragment xmlns:android="http://schemas.android.com/apk/res/android"
+ android:name="com.example.android.leanback.DetailsFragment"
+ android:id="@+id/details_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+/>
diff --git a/samples/SupportLeanbackDemos/res/values/strings.xml b/samples/SupportLeanbackDemos/res/values/strings.xml
index 09e43a6..125b0df 100644
--- a/samples/SupportLeanbackDemos/res/values/strings.xml
+++ b/samples/SupportLeanbackDemos/res/values/strings.xml
@@ -25,6 +25,8 @@
<string name="search_description">SearchFragment test</string>
<string name="details">Details</string>
<string name="details_description">DetailsFragment test</string>
+ <string name="search_details">Search Details</string>
+ <string name="search_details_description">Search style DetailsFragment test</string>
<string name="playback">Playback</string>
<string name="playback_description">PlaybackOverlay test</string>
<string name="hgrid">Horizontal Grid</string>
@@ -35,6 +37,10 @@
<string name="guidedstep_description">GuidedStepFragment test</string>
<string name="browseerror">Browse Error</string>
<string name="browseerror_description">BrowseError test</string>
+ <string name="detail_presenter_options">Choose Presenter for Details</string>
+ <string name="detail_presenter_options_description">Choose Presenter for Details</string>
+ <string name="legacydetails_off">Use New DetailsPresenter</string>
+ <string name="legacydetails_on">Use Legacy DetailsPresenter</string>
<!-- Strings related to guided sequence activity -->
<string name="guidedstep_first_title">First</string>
diff --git a/samples/SupportLeanbackDemos/res/values/themes.xml b/samples/SupportLeanbackDemos/res/values/themes.xml
index 5d7c232..696d82c 100644
--- a/samples/SupportLeanbackDemos/res/values/themes.xml
+++ b/samples/SupportLeanbackDemos/res/values/themes.xml
@@ -19,6 +19,8 @@
</style>
<style name="Theme.Example.Leanback.Browse" parent="Theme.Leanback.Browse">
</style>
+ <style name="Theme.Example.Leanback.SearchDetails" parent="Theme.Leanback.Details.NoSharedElementTransition">
+ </style>
<style name="Theme.Example.Leanback.Details" parent="Theme.Leanback.Details">
</style>
<style name="Theme.Example.Leanback.Rows" parent="Theme.Leanback">
diff --git a/samples/SupportLeanbackDemos/src/com/example/android/leanback/DetailsActivity.java b/samples/SupportLeanbackDemos/src/com/example/android/leanback/DetailsActivity.java
index d6c52ab..f199e9d 100644
--- a/samples/SupportLeanbackDemos/src/com/example/android/leanback/DetailsActivity.java
+++ b/samples/SupportLeanbackDemos/src/com/example/android/leanback/DetailsActivity.java
@@ -21,17 +21,28 @@
public static final String EXTRA_ITEM = "item";
public static final String SHARED_ELEMENT_NAME = "hero";
+ public static boolean USE_LEGACY_PRESENTER = false;
+
+ private boolean useLegacyFragment() {
+ return (USE_LEGACY_PRESENTER && !(this instanceof SearchDetailsActivity));
+ }
+
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
- setContentView(R.layout.details);
+ setContentView(useLegacyFragment() ? R.layout.legacy_details : R.layout.details);
if (savedInstanceState == null) {
// Only pass object to fragment when activity is first time created,
// later object is modified and persisted with fragment state.
- ((DetailsFragment)getFragmentManager().findFragmentById(R.id.details_fragment))
+ if (useLegacyFragment()) {
+ ((DetailsFragment)getFragmentManager().findFragmentById(R.id.details_fragment))
.setItem((PhotoItem) getIntent().getParcelableExtra(EXTRA_ITEM));
+ } else {
+ ((NewDetailsFragment)getFragmentManager().findFragmentById(R.id.details_fragment))
+ .setItem((PhotoItem) getIntent().getParcelableExtra(EXTRA_ITEM));
+ }
}
}
diff --git a/samples/SupportLeanbackDemos/src/com/example/android/leanback/DetailsPresenterSelectionActivity.java b/samples/SupportLeanbackDemos/src/com/example/android/leanback/DetailsPresenterSelectionActivity.java
new file mode 100644
index 0000000..ac0b671
--- /dev/null
+++ b/samples/SupportLeanbackDemos/src/com/example/android/leanback/DetailsPresenterSelectionActivity.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2014 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.leanback;
+
+import android.app.Activity;
+import android.app.FragmentManager;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.support.v17.leanback.app.GuidedStepFragment;
+import android.support.v17.leanback.widget.GuidedAction;
+import android.support.v17.leanback.widget.GuidanceStylist;
+import android.support.v17.leanback.widget.GuidanceStylist.Guidance;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Activity that showcases different aspects of GuidedStepFragments.
+ */
+public class DetailsPresenterSelectionActivity extends Activity {
+
+ private static final int OPTION_CHECK_SET_ID = 10;
+
+ private static final long ACTION_ID_SWITCH_LEGACY_ON = 10000;
+ private static final long ACTION_ID_SWITCH_LEGACY_OFF = 10001;
+
+
+ private static final String[] OPTION_NAMES = { "Use new details presenter", "Use legacy details presenter" };
+ private static final String[] OPTION_DESCRIPTIONS = { "Use new details presenter",
+ "Use legacy details presenter"};
+ private static final long[] OPTION_IDS = {ACTION_ID_SWITCH_LEGACY_OFF, ACTION_ID_SWITCH_LEGACY_ON};
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ GuidedStepFragment.add(getFragmentManager(), new SetupFragment());
+ }
+
+ private static void addAction(List<GuidedAction> actions, long id, String title, String desc) {
+ actions.add(new GuidedAction.Builder()
+ .id(id)
+ .title(title)
+ .description(desc)
+ .build());
+ }
+
+ private static void addCheckedAction(List<GuidedAction> actions, Context context,
+ long id, String title, String desc, boolean checked) {
+ actions.add(new GuidedAction.Builder()
+ .title(title)
+ .description(desc)
+ .id(id)
+ .checkSetId(OPTION_CHECK_SET_ID)
+ .checked(checked)
+ .build());
+ }
+
+ private static class SetupFragment extends GuidedStepFragment {
+
+ @Override
+ public Guidance onCreateGuidance(Bundle savedInstanceState) {
+ String title = getString(R.string.guidedstep_second_title);
+ String breadcrumb = getString(R.string.guidedstep_second_breadcrumb);
+ String description = getString(R.string.guidedstep_second_description);
+ Drawable icon = getActivity().getDrawable(R.drawable.ic_main_icon);
+ return new Guidance(title, description, breadcrumb, icon);
+ }
+
+ @Override
+ public GuidanceStylist onCreateGuidanceStylist() {
+ return new GuidanceStylist() {
+ @Override
+ public int onProvideLayoutId() {
+ return R.layout.guidedstep_second_guidance;
+ }
+ };
+ }
+
+ @Override
+ public void onCreateActions(List<GuidedAction> actions, Bundle savedInstanceState) {
+ for (int i = 0; i < OPTION_NAMES.length; i++) {
+ boolean checked = false;
+ if (OPTION_IDS[i] == ACTION_ID_SWITCH_LEGACY_ON) {
+ if (DetailsActivity.USE_LEGACY_PRESENTER) {
+ checked = true;
+ }
+ } else if (OPTION_IDS[i] == ACTION_ID_SWITCH_LEGACY_OFF) {
+ if (!DetailsActivity.USE_LEGACY_PRESENTER) {
+ checked = true;
+ }
+ }
+ addCheckedAction(actions, getActivity(), OPTION_IDS[i], OPTION_NAMES[i],
+ OPTION_DESCRIPTIONS[i], checked);
+ }
+ }
+
+ @Override
+ public void onGuidedActionClicked(GuidedAction action) {
+ if (action.getId() == ACTION_ID_SWITCH_LEGACY_ON) {
+ DetailsActivity.USE_LEGACY_PRESENTER = action.isChecked();
+ } else if (action.getId() == ACTION_ID_SWITCH_LEGACY_OFF) {
+ DetailsActivity.USE_LEGACY_PRESENTER = !action.isChecked();
+ }
+ getActivity().finish();
+ }
+
+ }
+
+}
diff --git a/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java b/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java
index 3a3d712..1f9e96c 100644
--- a/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java
+++ b/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java
@@ -35,8 +35,8 @@
*/
public class GuidedStepActivity extends Activity {
- private static final int CONTINUE = 0;
- private static final int BACK = 1;
+ private static final int CONTINUE = 1;
+ private static final int BACK = 2;
private static final int OPTION_CHECK_SET_ID = 10;
private static final int DEFAULT_OPTION = 0;
@@ -107,6 +107,8 @@
private static class SecondStepFragment extends GuidedStepFragment {
+ private int mSelectedOption = DEFAULT_OPTION;
+
@Override
public Guidance onCreateGuidance(Bundle savedInstanceState) {
String title = getString(R.string.guidedstep_second_title);
@@ -144,12 +146,17 @@
actions.get(actions.size() -1).setChecked(true);
}
}
+ addAction(actions, CONTINUE, "Continue", "");
}
@Override
public void onGuidedActionClicked(GuidedAction action) {
- FragmentManager fm = getFragmentManager();
- GuidedStepFragment.add(fm, new ThirdStepFragment(getSelectedActionPosition()-1));
+ if (action.getId() == CONTINUE) {
+ FragmentManager fm = getFragmentManager();
+ GuidedStepFragment.add(fm, new ThirdStepFragment(mSelectedOption));
+ } else {
+ mSelectedOption = getSelectedActionPosition()-1;
+ }
}
}
diff --git a/samples/SupportLeanbackDemos/src/com/example/android/leanback/MainActivity.java b/samples/SupportLeanbackDemos/src/com/example/android/leanback/MainActivity.java
index da6e0af..8b0b04d 100644
--- a/samples/SupportLeanbackDemos/src/com/example/android/leanback/MainActivity.java
+++ b/samples/SupportLeanbackDemos/src/com/example/android/leanback/MainActivity.java
@@ -59,6 +59,10 @@
addAction(actions, DetailsActivity.class, R.string.details, R.string.details_description);
actions.get(actions.size()-1).getIntent().putExtra(DetailsActivity.EXTRA_ITEM,
new PhotoItem("Hello world", R.drawable.gallery_photo_1));
+ addAction(actions, SearchDetailsActivity.class, R.string.search_details,
+ R.string.search_details_description);
+ actions.get(actions.size()-1).getIntent().putExtra(DetailsActivity.EXTRA_ITEM,
+ new PhotoItem("Hello world", R.drawable.gallery_photo_1));
addAction(actions, PlaybackOverlayActivity.class, R.string.playback,
R.string.playback_description);
addAction(actions, HorizontalGridTestActivity.class, R.string.hgrid,
@@ -69,6 +73,9 @@
R.string.guidedstep_description);
addAction(actions, BrowseErrorActivity.class, R.string.browseerror,
R.string.browseerror_description);
+ addAction(actions, DetailsPresenterSelectionActivity.class,
+ R.string.detail_presenter_options,
+ R.string.detail_presenter_options_description);
}
private void addAction(List<GuidedAction> actions, Class cls, int titleRes, int descRes) {
diff --git a/samples/SupportLeanbackDemos/src/com/example/android/leanback/NewDetailsFragment.java b/samples/SupportLeanbackDemos/src/com/example/android/leanback/NewDetailsFragment.java
new file mode 100644
index 0000000..445e148
--- /dev/null
+++ b/samples/SupportLeanbackDemos/src/com/example/android/leanback/NewDetailsFragment.java
@@ -0,0 +1,254 @@
+/*
+ * Copyright (C) 2014 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.leanback;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.res.Resources;
+import android.os.Bundle;
+import android.os.Handler;
+import android.support.v4.app.ActivityOptionsCompat;
+import android.support.v17.leanback.widget.Action;
+import android.support.v17.leanback.widget.ArrayObjectAdapter;
+import android.support.v17.leanback.widget.ClassPresenterSelector;
+import android.support.v17.leanback.widget.DetailsOverviewRow;
+import android.support.v17.leanback.widget.FullWidthDetailsOverviewRowPresenter;
+import android.support.v17.leanback.widget.FullWidthDetailsOverviewSharedElementHelper;
+import android.support.v17.leanback.widget.HeaderItem;
+import android.support.v17.leanback.widget.ImageCardView;
+import android.support.v17.leanback.widget.ListRow;
+import android.support.v17.leanback.widget.ListRowPresenter;
+import android.support.v17.leanback.widget.OnActionClickedListener;
+import android.support.v17.leanback.widget.OnItemViewClickedListener;
+import android.support.v17.leanback.widget.OnItemViewSelectedListener;
+import android.support.v17.leanback.widget.Presenter;
+import android.support.v17.leanback.widget.Row;
+import android.support.v17.leanback.widget.RowPresenter;
+import android.support.v17.leanback.widget.SparseArrayObjectAdapter;
+import android.util.Log;
+import android.view.View;
+import android.widget.Toast;
+
+public class NewDetailsFragment extends android.support.v17.leanback.app.DetailsFragment {
+ private static final String TAG = "leanback.DetailsFragment";
+ private static final String ITEM = "item";
+
+ private static final int NUM_ROWS = 3;
+ private ArrayObjectAdapter mRowsAdapter;
+ private PhotoItem mPhotoItem;
+ final CardPresenter cardPresenter = new CardPresenter();
+ private BackgroundHelper mBackgroundHelper = new BackgroundHelper();
+
+ private static final int ACTION_PLAY = 1;
+ private static final int ACTION_RENT = 2;
+ private static final int ACTION_BUY = 3;
+
+ private boolean TEST_OVERVIEW_ROW_ON_SECOND;
+ private boolean TEST_SHARED_ELEMENT_TRANSITION;
+ private boolean TEST_ENTRANCE_TRANSITION;
+
+ private static final long TIME_TO_LOAD_OVERVIEW_ROW_MS = 1000;
+ private static final long TIME_TO_LOAD_RELATED_ROWS_MS = 2000;
+
+ private Action mActionPlay;
+ private Action mActionRent;
+ private Action mActionBuy;
+
+ private FullWidthDetailsOverviewSharedElementHelper mHelper;
+
+ private void initializeTest() {
+ Activity activity = getActivity();
+ TEST_SHARED_ELEMENT_TRANSITION = null != activity.getWindow().getSharedElementEnterTransition();
+ TEST_OVERVIEW_ROW_ON_SECOND = !TEST_SHARED_ELEMENT_TRANSITION;
+ TEST_ENTRANCE_TRANSITION = true;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ Log.i(TAG, "onCreate");
+ super.onCreate(savedInstanceState);
+ initializeTest();
+
+ setBadgeDrawable(getActivity().getResources().getDrawable(R.drawable.ic_title));
+ setTitle("Leanback Sample App");
+ setOnSearchClickedListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Intent intent = new Intent(getActivity(), SearchActivity.class);
+ startActivity(intent);
+ }
+ });
+
+ mActionPlay = new Action(ACTION_PLAY, "Play");
+ mActionRent = new Action(ACTION_RENT, "Rent", "$3.99",
+ getResources().getDrawable(R.drawable.ic_action_a));
+ mActionBuy = new Action(ACTION_BUY, "Buy $9.99");
+
+ ClassPresenterSelector ps = new ClassPresenterSelector();
+ FullWidthDetailsOverviewRowPresenter dorPresenter =
+ new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter());
+ dorPresenter.setOnActionClickedListener(new OnActionClickedListener() {
+ @Override
+ public void onActionClicked(Action action) {
+ Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
+ int indexOfOverviewRow = TEST_OVERVIEW_ROW_ON_SECOND ? 1 : 0;
+ DetailsOverviewRow dor = (DetailsOverviewRow) mRowsAdapter.get(indexOfOverviewRow);
+ if (action.getId() == ACTION_BUY) {
+ // on the UI thread, we can modify actions adapter directly
+ SparseArrayObjectAdapter actions = (SparseArrayObjectAdapter)
+ dor.getActionsAdapter();
+ actions.set(ACTION_PLAY, mActionPlay);
+ actions.clear(ACTION_RENT);
+ actions.clear(ACTION_BUY);
+ dor.setItem(mPhotoItem.getTitle() + "(Owned)");
+ dor.setImageDrawable(getResources().getDrawable(R.drawable.details_img_16x9));
+ } else if (action.getId() == ACTION_RENT) {
+ // on the UI thread, we can modify actions adapter directly
+ SparseArrayObjectAdapter actions = (SparseArrayObjectAdapter)
+ dor.getActionsAdapter();
+ actions.set(ACTION_PLAY, mActionPlay);
+ actions.clear(ACTION_RENT);
+ dor.setItem(mPhotoItem.getTitle() + "(Rented)");
+ } else if (action.getId() == ACTION_PLAY) {
+ Intent intent = new Intent(getActivity(), PlaybackOverlayActivity.class);
+ getActivity().startActivity(intent);
+ }
+ }
+ });
+ if (TEST_OVERVIEW_ROW_ON_SECOND) {
+ dorPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_SMALL);
+ }
+
+ ps.addClassPresenter(DetailsOverviewRow.class, dorPresenter);
+ ps.addClassPresenter(ListRow.class, new ListRowPresenter());
+
+ mRowsAdapter = new ArrayObjectAdapter(ps);
+
+ PhotoItem item = (PhotoItem) (savedInstanceState != null ?
+ savedInstanceState.getParcelable(ITEM) : null);
+ if (item != null) {
+ setItem(item);
+ }
+
+ setOnItemViewClickedListener(new OnItemViewClickedListener() {
+ @Override
+ public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
+ RowPresenter.ViewHolder rowViewHolder, Row row) {
+ Log.i(TAG, "onItemClicked: " + item + " row " + row);
+ if (item instanceof PhotoItem){
+ Intent intent = new Intent(getActivity(), DetailsActivity.class);
+ intent.putExtra(DetailsActivity.EXTRA_ITEM, (PhotoItem) item);
+
+ Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(
+ getActivity(),
+ ((ImageCardView)itemViewHolder.view).getMainImageView(),
+ DetailsActivity.SHARED_ELEMENT_NAME).toBundle();
+ getActivity().startActivity(intent, bundle);
+ }
+ }
+ });
+ setOnItemViewSelectedListener(new OnItemViewSelectedListener() {
+ @Override
+ public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item,
+ RowPresenter.ViewHolder rowViewHolder, Row row) {
+ Log.i(TAG, "onItemSelected: " + item + " row " + row);
+ }
+ });
+
+ if (TEST_SHARED_ELEMENT_TRANSITION) {
+ mHelper = new FullWidthDetailsOverviewSharedElementHelper();
+ mHelper.setSharedElementEnterTransition(getActivity(),
+ DetailsActivity.SHARED_ELEMENT_NAME);
+ dorPresenter.setListener(mHelper);
+ dorPresenter.setParticipatingEntranceTransition(false);
+ } else {
+ dorPresenter.setParticipatingEntranceTransition(true);
+ }
+ if (TEST_ENTRANCE_TRANSITION) {
+ // don't run entrance transition if Activity is restored.
+ if (savedInstanceState == null) {
+ prepareEntranceTransition();
+ }
+ }
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putParcelable(ITEM, mPhotoItem);
+ }
+
+ public void setItem(PhotoItem photoItem) {
+ mPhotoItem = photoItem;
+
+ mRowsAdapter.clear();
+ new Handler().postDelayed(new Runnable() {
+ public void run() {
+ if (TEST_OVERVIEW_ROW_ON_SECOND) {
+ ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenter);
+ listRowAdapter.add(new PhotoItem("Hello world", R.drawable.gallery_photo_1));
+ listRowAdapter.add(new PhotoItem("This is a test", R.drawable.gallery_photo_2));
+ listRowAdapter.add(new PhotoItem("Android TV", R.drawable.gallery_photo_3));
+ listRowAdapter.add(new PhotoItem("Leanback", R.drawable.gallery_photo_4));
+ HeaderItem header = new HeaderItem(0, "Search Result");
+ mRowsAdapter.add(0, new ListRow(header, listRowAdapter));
+ }
+
+ Resources res = getActivity().getResources();
+ DetailsOverviewRow dor = new DetailsOverviewRow(mPhotoItem.getTitle());
+ dor.setImageDrawable(res.getDrawable(mPhotoItem.getImageResourceId()));
+ SparseArrayObjectAdapter adapter = new SparseArrayObjectAdapter();
+ adapter.set(ACTION_RENT, mActionRent);
+ adapter.set(ACTION_BUY, mActionBuy);
+ dor.setActionsAdapter(adapter);
+ int indexOfOverviewRow = TEST_OVERVIEW_ROW_ON_SECOND ? 1 : 0;
+ mRowsAdapter.add(indexOfOverviewRow, dor);
+ setSelectedPosition(0, true);
+ if (TEST_SHARED_ELEMENT_TRANSITION) {
+ if (mHelper != null && !mHelper.getAutoStartSharedElementTransition()) {
+ mHelper.startPostponedEnterTransition();
+ }
+ }
+ }
+ }, TIME_TO_LOAD_OVERVIEW_ROW_MS);
+
+ new Handler().postDelayed(new Runnable() {
+ public void run() {
+ for (int i = 0; i < NUM_ROWS; ++i) {
+ ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenter);
+ listRowAdapter.add(new PhotoItem("Hello world", R.drawable.gallery_photo_1));
+ listRowAdapter.add(new PhotoItem("This is a test", R.drawable.gallery_photo_2));
+ listRowAdapter.add(new PhotoItem("Android TV", R.drawable.gallery_photo_3));
+ listRowAdapter.add(new PhotoItem("Leanback", R.drawable.gallery_photo_4));
+ HeaderItem header = new HeaderItem(i, "Row " + i);
+ mRowsAdapter.add(new ListRow(header, listRowAdapter));
+ }
+ if (TEST_ENTRANCE_TRANSITION) {
+ startEntranceTransition();
+ }
+ }
+ }, TIME_TO_LOAD_RELATED_ROWS_MS);
+ setAdapter(mRowsAdapter);
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+ if (mPhotoItem != null) {
+ mBackgroundHelper.setBackground(
+ getActivity(), mPhotoItem.getImageResourceId());
+ }
+ }
+
+}
diff --git a/samples/SupportLeanbackDemos/src/com/example/android/leanback/SearchDetailsActivity.java b/samples/SupportLeanbackDemos/src/com/example/android/leanback/SearchDetailsActivity.java
new file mode 100644
index 0000000..da9e08e
--- /dev/null
+++ b/samples/SupportLeanbackDemos/src/com/example/android/leanback/SearchDetailsActivity.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2014 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.leanback;
+
+/**
+ * Same implementation as DetailsActivity for different entries in AndroidManifest.
+ */
+public class SearchDetailsActivity extends DetailsActivity
+{
+}
diff --git a/sdk/support_source.prop_template b/sdk/support_source.prop_template
index f5b217e..03d6962 100644
--- a/sdk/support_source.prop_template
+++ b/sdk/support_source.prop_template
@@ -1,5 +1,5 @@
Pkg.UserSrc=false
-Pkg.Revision=${PLATFORM_SDK_VERSION}.0.0
+Pkg.Revision=${PLATFORM_SDK_VERSION}.1.1
Extra.Vendor=android
Extra.VendorId=android
Extra.VendorDisplay=Android