Merge "Updating SupportLeanbackDemo to showcase GuidedStepFragment." into mnc-ub-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c140afb120
@@ -98,6 +98,16 @@
|
|||||||
android:windowSoftInputMode="adjustResize"
|
android:windowSoftInputMode="adjustResize"
|
||||||
android:exported="true" />
|
android:exported="true" />
|
||||||
|
|
||||||
|
<activity android:name="GuidedStepHalfScreenActivity"
|
||||||
|
android:theme="@style/Theme.Example.Leanback.GuidedStep.Half"
|
||||||
|
android:windowSoftInputMode="adjustResize"
|
||||||
|
android:exported="true" />
|
||||||
|
|
||||||
|
<activity android:name="GuidedStepSupportHalfScreenActivity"
|
||||||
|
android:theme="@style/Theme.Example.Leanback.GuidedStep.Half"
|
||||||
|
android:windowSoftInputMode="adjustResize"
|
||||||
|
android:exported="true" />
|
||||||
|
|
||||||
<activity android:name="DetailsPresenterSelectionActivity"
|
<activity android:name="DetailsPresenterSelectionActivity"
|
||||||
android:theme="@style/Theme.Example.Leanback.GuidedStep"
|
android:theme="@style/Theme.Example.Leanback.GuidedStep"
|
||||||
android:exported="true" />
|
android:exported="true" />
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import getopt
|
||||||
|
|
||||||
def write_java_head(tofile, name):
|
def write_java_head(tofile, name):
|
||||||
tofile.write("/* This file is auto-generated from {}.java. DO NOT MODIFY. */\n\n".format(name))
|
tofile.write("/* This file is auto-generated from {}.java. DO NOT MODIFY. */\n\n".format(name))
|
||||||
@@ -36,6 +37,20 @@ for line in file:
|
|||||||
file.close()
|
file.close()
|
||||||
outfile.close()
|
outfile.close()
|
||||||
|
|
||||||
|
file = open('src/com/example/android/leanback/GuidedStepHalfScreenActivity.java', 'r')
|
||||||
|
outfile = open('src/com/example/android/leanback/GuidedStepSupportHalfScreenActivity.java', 'w')
|
||||||
|
write_java_head(outfile, "GuidedStepHalfScreenActivity")
|
||||||
|
for line in file:
|
||||||
|
line = line.replace('android.app.Fragment', 'android.support.v4.app.Fragment')
|
||||||
|
line = line.replace('android.app.Activity', 'android.support.v4.app.FragmentActivity')
|
||||||
|
line = line.replace('GuidedStepFragment', 'GuidedStepSupportFragment')
|
||||||
|
line = line.replace('GuidedStepActivity', 'GuidedStepSupportActivity')
|
||||||
|
line = line.replace('GuidedStepHalfScreenActivity', 'GuidedStepSupportHalfScreenActivity')
|
||||||
|
line = line.replace('extends Activity', 'extends FragmentActivity')
|
||||||
|
outfile.write(line)
|
||||||
|
file.close()
|
||||||
|
outfile.close()
|
||||||
|
|
||||||
file = open('src/com/example/android/leanback/BrowseFragment.java', 'r')
|
file = open('src/com/example/android/leanback/BrowseFragment.java', 'r')
|
||||||
outfile = open('src/com/example/android/leanback/BrowseSupportFragment.java', 'w')
|
outfile = open('src/com/example/android/leanback/BrowseSupportFragment.java', 'w')
|
||||||
write_java_head(outfile, "BrowseFragment")
|
write_java_head(outfile, "BrowseFragment")
|
||||||
@@ -49,6 +64,7 @@ for line in file:
|
|||||||
line = line.replace('DetailsActivity', 'DetailsSupportActivity')
|
line = line.replace('DetailsActivity', 'DetailsSupportActivity')
|
||||||
line = line.replace('SearchActivity', 'SearchSupportActivity')
|
line = line.replace('SearchActivity', 'SearchSupportActivity')
|
||||||
line = line.replace('RowsActivity', 'RowsSupportActivity')
|
line = line.replace('RowsActivity', 'RowsSupportActivity')
|
||||||
|
line = line.replace('GuidedStepHalfScreenActivity', 'GuidedStepSupportHalfScreenActivity')
|
||||||
outfile.write(line)
|
outfile.write(line)
|
||||||
file.close()
|
file.close()
|
||||||
outfile.close()
|
outfile.close()
|
||||||
|
|||||||
@@ -46,8 +46,10 @@
|
|||||||
<string name="vgrid_support">Vertical Grid(support version)</string>
|
<string name="vgrid_support">Vertical Grid(support version)</string>
|
||||||
<string name="vgrid_support_description">VerticalGridSupportFragment test</string>
|
<string name="vgrid_support_description">VerticalGridSupportFragment test</string>
|
||||||
<string name="guidedstep">Guided Step</string>
|
<string name="guidedstep">Guided Step</string>
|
||||||
|
<string name="guidedstephalfscreen">Guided Step Half Screen</string>
|
||||||
<string name="guidedstep_description">GuidedStepFragment test</string>
|
<string name="guidedstep_description">GuidedStepFragment test</string>
|
||||||
<string name="guidedstepsupport">Guided Step(support version)</string>
|
<string name="guidedstepsupport">Guided Step(support version)</string>
|
||||||
|
<string name="guidedstepsupporthalfscreen">Guided Step Half Screen(support version)</string>
|
||||||
<string name="guidedstepsupport_description">GuidedStepSupportFragment test</string>
|
<string name="guidedstepsupport_description">GuidedStepSupportFragment test</string>
|
||||||
<string name="browseerror">Browse Error</string>
|
<string name="browseerror">Browse Error</string>
|
||||||
<string name="browseerror_description">BrowseError test</string>
|
<string name="browseerror_description">BrowseError test</string>
|
||||||
|
|||||||
@@ -35,4 +35,6 @@
|
|||||||
<style name="Theme.Example.Leanback.GuidedStep.First">
|
<style name="Theme.Example.Leanback.GuidedStep.First">
|
||||||
<item name="guidanceIconStyle">@style/Widget.Example.Leanback.FirstStepGuidanceIconStyle</item>
|
<item name="guidanceIconStyle">@style/Widget.Example.Leanback.FirstStepGuidanceIconStyle</item>
|
||||||
</style>
|
</style>
|
||||||
|
<style name="Theme.Example.Leanback.GuidedStep.Half" parent="Theme.Leanback.GuidedStep.Half">
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ package com.example.android.leanback;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.v4.app.ActivityOptionsCompat;
|
|
||||||
import android.support.v17.leanback.app.GuidedStepFragment;
|
import android.support.v17.leanback.app.GuidedStepFragment;
|
||||||
import android.support.v17.leanback.widget.ArrayObjectAdapter;
|
import android.support.v17.leanback.widget.ArrayObjectAdapter;
|
||||||
import android.support.v17.leanback.widget.HeaderItem;
|
import android.support.v17.leanback.widget.HeaderItem;
|
||||||
@@ -28,6 +27,7 @@ import android.support.v17.leanback.widget.OnItemViewSelectedListener;
|
|||||||
import android.support.v17.leanback.widget.Presenter;
|
import android.support.v17.leanback.widget.Presenter;
|
||||||
import android.support.v17.leanback.widget.Row;
|
import android.support.v17.leanback.widget.Row;
|
||||||
import android.support.v17.leanback.widget.RowPresenter;
|
import android.support.v17.leanback.widget.RowPresenter;
|
||||||
|
import android.support.v4.app.ActivityOptionsCompat;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -111,8 +111,8 @@ public class BrowseFragment extends android.support.v17.leanback.app.BrowseFragm
|
|||||||
listRowAdapter.add(new PhotoItem("This is a test", "Only a test", R.drawable.gallery_photo_2));
|
listRowAdapter.add(new PhotoItem("This is a test", "Only a test", R.drawable.gallery_photo_2));
|
||||||
listRowAdapter.add(new PhotoItem("Android TV", "by Google", R.drawable.gallery_photo_3));
|
listRowAdapter.add(new PhotoItem("Android TV", "by Google", R.drawable.gallery_photo_3));
|
||||||
listRowAdapter.add(new PhotoItem("Leanback", R.drawable.gallery_photo_4));
|
listRowAdapter.add(new PhotoItem("Leanback", R.drawable.gallery_photo_4));
|
||||||
listRowAdapter.add(new PhotoItem("Hello world", R.drawable.gallery_photo_5));
|
listRowAdapter.add(new PhotoItem("GuidedStep (Slide left/right)", R.drawable.gallery_photo_5));
|
||||||
listRowAdapter.add(new PhotoItem("This is a test", "Open GuidedStepFragment", R.drawable.gallery_photo_6));
|
listRowAdapter.add(new PhotoItem("GuidedStep (Slide bottom up)", "Open GuidedStepFragment", R.drawable.gallery_photo_6));
|
||||||
listRowAdapter.add(new PhotoItem("Android TV", "open RowsActivity", R.drawable.gallery_photo_7));
|
listRowAdapter.add(new PhotoItem("Android TV", "open RowsActivity", R.drawable.gallery_photo_7));
|
||||||
listRowAdapter.add(new PhotoItem("Leanback", "open BrowseActivity", R.drawable.gallery_photo_8));
|
listRowAdapter.add(new PhotoItem("Leanback", "open BrowseActivity", R.drawable.gallery_photo_8));
|
||||||
HeaderItem header = new HeaderItem(i, "Row " + i);
|
HeaderItem header = new HeaderItem(i, "Row " + i);
|
||||||
@@ -130,9 +130,13 @@ public class BrowseFragment extends android.support.v17.leanback.app.BrowseFragm
|
|||||||
Bundle bundle;
|
Bundle bundle;
|
||||||
if (((PhotoItem) item).getImageResourceId() == R.drawable.gallery_photo_6) {
|
if (((PhotoItem) item).getImageResourceId() == R.drawable.gallery_photo_6) {
|
||||||
GuidedStepFragment.add(getFragmentManager(),
|
GuidedStepFragment.add(getFragmentManager(),
|
||||||
new GuidedStepActivity.FirstStepFragment(),
|
new GuidedStepHalfScreenActivity.FirstStepFragment(),
|
||||||
R.id.lb_guidedstep_host);
|
R.id.lb_guidedstep_host);
|
||||||
return;
|
return;
|
||||||
|
} else if (((PhotoItem) item).getImageResourceId() == R.drawable.gallery_photo_5) {
|
||||||
|
GuidedStepFragment.add(getFragmentManager(),
|
||||||
|
new GuidedStepActivity.FirstStepFragment(), R.id.lb_guidedstep_host);
|
||||||
|
return;
|
||||||
} else if ( ((PhotoItem) item).getImageResourceId() == R.drawable.gallery_photo_8) {
|
} else if ( ((PhotoItem) item).getImageResourceId() == R.drawable.gallery_photo_8) {
|
||||||
intent = new Intent(getActivity(), BrowseActivity.class);
|
intent = new Intent(getActivity(), BrowseActivity.class);
|
||||||
bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity())
|
bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity())
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ package com.example.android.leanback;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.v4.app.ActivityOptionsCompat;
|
|
||||||
import android.support.v17.leanback.app.GuidedStepSupportFragment;
|
import android.support.v17.leanback.app.GuidedStepSupportFragment;
|
||||||
import android.support.v17.leanback.widget.ArrayObjectAdapter;
|
import android.support.v17.leanback.widget.ArrayObjectAdapter;
|
||||||
import android.support.v17.leanback.widget.HeaderItem;
|
import android.support.v17.leanback.widget.HeaderItem;
|
||||||
@@ -30,6 +29,7 @@ import android.support.v17.leanback.widget.OnItemViewSelectedListener;
|
|||||||
import android.support.v17.leanback.widget.Presenter;
|
import android.support.v17.leanback.widget.Presenter;
|
||||||
import android.support.v17.leanback.widget.Row;
|
import android.support.v17.leanback.widget.Row;
|
||||||
import android.support.v17.leanback.widget.RowPresenter;
|
import android.support.v17.leanback.widget.RowPresenter;
|
||||||
|
import android.support.v4.app.ActivityOptionsCompat;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -113,8 +113,8 @@ public class BrowseSupportFragment extends android.support.v17.leanback.app.Brow
|
|||||||
listRowAdapter.add(new PhotoItem("This is a test", "Only a test", R.drawable.gallery_photo_2));
|
listRowAdapter.add(new PhotoItem("This is a test", "Only a test", R.drawable.gallery_photo_2));
|
||||||
listRowAdapter.add(new PhotoItem("Android TV", "by Google", R.drawable.gallery_photo_3));
|
listRowAdapter.add(new PhotoItem("Android TV", "by Google", R.drawable.gallery_photo_3));
|
||||||
listRowAdapter.add(new PhotoItem("Leanback", R.drawable.gallery_photo_4));
|
listRowAdapter.add(new PhotoItem("Leanback", R.drawable.gallery_photo_4));
|
||||||
listRowAdapter.add(new PhotoItem("Hello world", R.drawable.gallery_photo_5));
|
listRowAdapter.add(new PhotoItem("GuidedStep (Slide left/right)", R.drawable.gallery_photo_5));
|
||||||
listRowAdapter.add(new PhotoItem("This is a test", "Open GuidedStepSupportFragment", R.drawable.gallery_photo_6));
|
listRowAdapter.add(new PhotoItem("GuidedStep (Slide bottom up)", "Open GuidedStepSupportFragment", R.drawable.gallery_photo_6));
|
||||||
listRowAdapter.add(new PhotoItem("Android TV", "open RowsSupportActivity", R.drawable.gallery_photo_7));
|
listRowAdapter.add(new PhotoItem("Android TV", "open RowsSupportActivity", R.drawable.gallery_photo_7));
|
||||||
listRowAdapter.add(new PhotoItem("Leanback", "open BrowseSupportActivity", R.drawable.gallery_photo_8));
|
listRowAdapter.add(new PhotoItem("Leanback", "open BrowseSupportActivity", R.drawable.gallery_photo_8));
|
||||||
HeaderItem header = new HeaderItem(i, "Row " + i);
|
HeaderItem header = new HeaderItem(i, "Row " + i);
|
||||||
@@ -132,9 +132,13 @@ public class BrowseSupportFragment extends android.support.v17.leanback.app.Brow
|
|||||||
Bundle bundle;
|
Bundle bundle;
|
||||||
if (((PhotoItem) item).getImageResourceId() == R.drawable.gallery_photo_6) {
|
if (((PhotoItem) item).getImageResourceId() == R.drawable.gallery_photo_6) {
|
||||||
GuidedStepSupportFragment.add(getFragmentManager(),
|
GuidedStepSupportFragment.add(getFragmentManager(),
|
||||||
new GuidedStepSupportActivity.FirstStepFragment(),
|
new GuidedStepSupportHalfScreenActivity.FirstStepFragment(),
|
||||||
R.id.lb_guidedstep_host);
|
R.id.lb_guidedstep_host);
|
||||||
return;
|
return;
|
||||||
|
} else if (((PhotoItem) item).getImageResourceId() == R.drawable.gallery_photo_5) {
|
||||||
|
GuidedStepSupportFragment.add(getFragmentManager(),
|
||||||
|
new GuidedStepSupportActivity.FirstStepFragment(), R.id.lb_guidedstep_host);
|
||||||
|
return;
|
||||||
} else if ( ((PhotoItem) item).getImageResourceId() == R.drawable.gallery_photo_8) {
|
} else if ( ((PhotoItem) item).getImageResourceId() == R.drawable.gallery_photo_8) {
|
||||||
intent = new Intent(getActivity(), BrowseSupportActivity.class);
|
intent = new Intent(getActivity(), BrowseSupportActivity.class);
|
||||||
bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity())
|
bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity())
|
||||||
|
|||||||
@@ -24,12 +24,12 @@ import android.content.res.Configuration;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v17.leanback.app.GuidedStepFragment;
|
import android.support.v17.leanback.app.GuidedStepFragment;
|
||||||
import android.support.v17.leanback.widget.GuidedAction;
|
|
||||||
import android.support.v17.leanback.widget.GuidedDatePickerAction;
|
|
||||||
import android.support.v17.leanback.widget.GuidedActionsStylist;
|
|
||||||
import android.support.v17.leanback.widget.GuidanceStylist;
|
import android.support.v17.leanback.widget.GuidanceStylist;
|
||||||
import android.support.v17.leanback.widget.GuidanceStylist.Guidance;
|
import android.support.v17.leanback.widget.GuidanceStylist.Guidance;
|
||||||
|
import android.support.v17.leanback.widget.GuidedAction;
|
||||||
|
import android.support.v17.leanback.widget.GuidedActionsStylist;
|
||||||
import android.support.v17.leanback.widget.GuidedActionsStylist.ViewHolder;
|
import android.support.v17.leanback.widget.GuidedActionsStylist.ViewHolder;
|
||||||
|
import android.support.v17.leanback.widget.GuidedDatePickerAction;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -172,6 +172,7 @@ public class GuidedStepActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class FirstStepFragment extends GuidedStepFragment {
|
public static class FirstStepFragment extends GuidedStepFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int onProvideTheme() {
|
public int onProvideTheme() {
|
||||||
return R.style.Theme_Example_Leanback_GuidedStep_First;
|
return R.style.Theme_Example_Leanback_GuidedStep_First;
|
||||||
@@ -208,7 +209,6 @@ public class GuidedStepActivity extends Activity {
|
|||||||
finishGuidedStepFragments();
|
finishGuidedStepFragments();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ArrayList<String> sCards = new ArrayList<String>();
|
static ArrayList<String> sCards = new ArrayList<String>();
|
||||||
|
|||||||
@@ -0,0 +1,141 @@
|
|||||||
|
/*
|
||||||
|
* 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.graphics.drawable.Drawable;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v17.leanback.app.GuidedStepFragment;
|
||||||
|
import android.support.v17.leanback.widget.GuidanceStylist;
|
||||||
|
import android.support.v17.leanback.widget.GuidanceStylist.Guidance;
|
||||||
|
import android.support.v17.leanback.widget.GuidedAction;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activity that showcases different aspects of GuidedStepFragments in half
|
||||||
|
* screen mode. This is achieved by setting the theme for this activity
|
||||||
|
* to {@code Theme.Example.Leanback.GuidedStep.Half}.
|
||||||
|
*/
|
||||||
|
public class GuidedStepHalfScreenActivity extends Activity {
|
||||||
|
private static final String TAG = "leanback.GuidedStepSupportHalfScreenActivity";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
Log.v(TAG, "onCreate");
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.guided_step_activity);
|
||||||
|
GuidedStepFragment.addAsRoot(this, new FirstStepFragment(), R.id.lb_guidedstep_host);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class FirstStepFragment extends GuidedStepFragment {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Guidance onCreateGuidance(Bundle savedInstanceState) {
|
||||||
|
String title = getString(R.string.guidedstep_first_title);
|
||||||
|
String breadcrumb = getString(R.string.guidedstep_first_breadcrumb);
|
||||||
|
String description = getString(R.string.guidedstep_first_description);
|
||||||
|
Drawable icon = getActivity().getResources().getDrawable(R.drawable.ic_main_icon);
|
||||||
|
return new Guidance(title, description, breadcrumb, icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateActions(List<GuidedAction> actions, Bundle savedInstanceState) {
|
||||||
|
Context context = getActivity();
|
||||||
|
actions.add(new GuidedAction.Builder(context)
|
||||||
|
.clickAction(GuidedAction.ACTION_ID_CONTINUE)
|
||||||
|
.description("Just do it")
|
||||||
|
.build());
|
||||||
|
actions.add(new GuidedAction.Builder(context)
|
||||||
|
.clickAction(GuidedAction.ACTION_ID_CANCEL)
|
||||||
|
.description("Never mind")
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
public FirstStepFragment() {
|
||||||
|
setEntranceTransitionType(GuidedStepFragment.SLIDE_FROM_BOTTOM);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This fragment could be used by an activity using theme
|
||||||
|
* {@code Theme.Leanback.GuidedStep.Half} or something else (BrowseActivity).
|
||||||
|
* In order to provide a consistent half screen experience under
|
||||||
|
* both scenarios, we override onProvideTheme method.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int onProvideTheme() {
|
||||||
|
return R.style.Theme_Example_Leanback_GuidedStep_Half;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGuidedActionClicked(GuidedAction action) {
|
||||||
|
FragmentManager fm = getFragmentManager();
|
||||||
|
if (action.getId() == GuidedAction.ACTION_ID_CONTINUE) {
|
||||||
|
GuidedStepFragment.add(fm, new SecondStepFragment(), R.id.lb_guidedstep_host);
|
||||||
|
} else if (action.getId() == GuidedAction.ACTION_ID_CANCEL){
|
||||||
|
finishGuidedStepFragments();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SecondStepFragment extends GuidedStepFragment {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int onProvideTheme() {
|
||||||
|
return R.style.Theme_Example_Leanback_GuidedStep_Half;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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().getResources().getDrawable(R.drawable.ic_main_icon);
|
||||||
|
return new Guidance(title, description, breadcrumb, icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateActions(List<GuidedAction> actions, Bundle savedInstanceState) {
|
||||||
|
Context context = getActivity();
|
||||||
|
actions.add(new GuidedAction.Builder(context)
|
||||||
|
.clickAction(GuidedAction.ACTION_ID_FINISH)
|
||||||
|
.description("Done")
|
||||||
|
.build());
|
||||||
|
actions.add(new GuidedAction.Builder(context)
|
||||||
|
.clickAction(GuidedAction.ACTION_ID_CANCEL)
|
||||||
|
.description("Never mind")
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateButtonActions(List<GuidedAction> actions, Bundle savedInstanceState) {
|
||||||
|
actions.add(new GuidedAction.Builder(getActivity())
|
||||||
|
.clickAction(GuidedAction.ACTION_ID_CANCEL)
|
||||||
|
.description("Cancel")
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGuidedActionClicked(GuidedAction action) {
|
||||||
|
FragmentManager fm = getFragmentManager();
|
||||||
|
fm.popBackStack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,12 +26,12 @@ import android.content.res.Configuration;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v17.leanback.app.GuidedStepSupportFragment;
|
import android.support.v17.leanback.app.GuidedStepSupportFragment;
|
||||||
import android.support.v17.leanback.widget.GuidedAction;
|
|
||||||
import android.support.v17.leanback.widget.GuidedDatePickerAction;
|
|
||||||
import android.support.v17.leanback.widget.GuidedActionsStylist;
|
|
||||||
import android.support.v17.leanback.widget.GuidanceStylist;
|
import android.support.v17.leanback.widget.GuidanceStylist;
|
||||||
import android.support.v17.leanback.widget.GuidanceStylist.Guidance;
|
import android.support.v17.leanback.widget.GuidanceStylist.Guidance;
|
||||||
|
import android.support.v17.leanback.widget.GuidedAction;
|
||||||
|
import android.support.v17.leanback.widget.GuidedActionsStylist;
|
||||||
import android.support.v17.leanback.widget.GuidedActionsStylist.ViewHolder;
|
import android.support.v17.leanback.widget.GuidedActionsStylist.ViewHolder;
|
||||||
|
import android.support.v17.leanback.widget.GuidedDatePickerAction;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -174,6 +174,7 @@ public class GuidedStepSupportActivity extends FragmentActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class FirstStepFragment extends GuidedStepSupportFragment {
|
public static class FirstStepFragment extends GuidedStepSupportFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int onProvideTheme() {
|
public int onProvideTheme() {
|
||||||
return R.style.Theme_Example_Leanback_GuidedStep_First;
|
return R.style.Theme_Example_Leanback_GuidedStep_First;
|
||||||
@@ -210,7 +211,6 @@ public class GuidedStepSupportActivity extends FragmentActivity {
|
|||||||
finishGuidedStepSupportFragments();
|
finishGuidedStepSupportFragments();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ArrayList<String> sCards = new ArrayList<String>();
|
static ArrayList<String> sCards = new ArrayList<String>();
|
||||||
|
|||||||
@@ -0,0 +1,143 @@
|
|||||||
|
/* This file is auto-generated from GuidedStepHalfScreenActivity.java. DO NOT MODIFY. */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.support.v4.app.FragmentActivity;
|
||||||
|
import android.support.v4.app.FragmentManager;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v17.leanback.app.GuidedStepSupportFragment;
|
||||||
|
import android.support.v17.leanback.widget.GuidanceStylist;
|
||||||
|
import android.support.v17.leanback.widget.GuidanceStylist.Guidance;
|
||||||
|
import android.support.v17.leanback.widget.GuidedAction;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activity that showcases different aspects of GuidedStepSupportFragments in half
|
||||||
|
* screen mode. This is achieved by setting the theme for this activity
|
||||||
|
* to {@code Theme.Example.Leanback.GuidedStep.Half}.
|
||||||
|
*/
|
||||||
|
public class GuidedStepSupportHalfScreenActivity extends FragmentActivity {
|
||||||
|
private static final String TAG = "leanback.GuidedStepSupportHalfScreenActivity";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
Log.v(TAG, "onCreate");
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.guided_step_activity);
|
||||||
|
GuidedStepSupportFragment.addAsRoot(this, new FirstStepFragment(), R.id.lb_guidedstep_host);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class FirstStepFragment extends GuidedStepSupportFragment {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Guidance onCreateGuidance(Bundle savedInstanceState) {
|
||||||
|
String title = getString(R.string.guidedstep_first_title);
|
||||||
|
String breadcrumb = getString(R.string.guidedstep_first_breadcrumb);
|
||||||
|
String description = getString(R.string.guidedstep_first_description);
|
||||||
|
Drawable icon = getActivity().getResources().getDrawable(R.drawable.ic_main_icon);
|
||||||
|
return new Guidance(title, description, breadcrumb, icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateActions(List<GuidedAction> actions, Bundle savedInstanceState) {
|
||||||
|
Context context = getActivity();
|
||||||
|
actions.add(new GuidedAction.Builder(context)
|
||||||
|
.clickAction(GuidedAction.ACTION_ID_CONTINUE)
|
||||||
|
.description("Just do it")
|
||||||
|
.build());
|
||||||
|
actions.add(new GuidedAction.Builder(context)
|
||||||
|
.clickAction(GuidedAction.ACTION_ID_CANCEL)
|
||||||
|
.description("Never mind")
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
public FirstStepFragment() {
|
||||||
|
setEntranceTransitionType(GuidedStepSupportFragment.SLIDE_FROM_BOTTOM);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This fragment could be used by an activity using theme
|
||||||
|
* {@code Theme.Leanback.GuidedStep.Half} or something else (BrowseActivity).
|
||||||
|
* In order to provide a consistent half screen experience under
|
||||||
|
* both scenarios, we override onProvideTheme method.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int onProvideTheme() {
|
||||||
|
return R.style.Theme_Example_Leanback_GuidedStep_Half;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGuidedActionClicked(GuidedAction action) {
|
||||||
|
FragmentManager fm = getFragmentManager();
|
||||||
|
if (action.getId() == GuidedAction.ACTION_ID_CONTINUE) {
|
||||||
|
GuidedStepSupportFragment.add(fm, new SecondStepFragment(), R.id.lb_guidedstep_host);
|
||||||
|
} else if (action.getId() == GuidedAction.ACTION_ID_CANCEL){
|
||||||
|
finishGuidedStepSupportFragments();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SecondStepFragment extends GuidedStepSupportFragment {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int onProvideTheme() {
|
||||||
|
return R.style.Theme_Example_Leanback_GuidedStep_Half;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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().getResources().getDrawable(R.drawable.ic_main_icon);
|
||||||
|
return new Guidance(title, description, breadcrumb, icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateActions(List<GuidedAction> actions, Bundle savedInstanceState) {
|
||||||
|
Context context = getActivity();
|
||||||
|
actions.add(new GuidedAction.Builder(context)
|
||||||
|
.clickAction(GuidedAction.ACTION_ID_FINISH)
|
||||||
|
.description("Done")
|
||||||
|
.build());
|
||||||
|
actions.add(new GuidedAction.Builder(context)
|
||||||
|
.clickAction(GuidedAction.ACTION_ID_CANCEL)
|
||||||
|
.description("Never mind")
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateButtonActions(List<GuidedAction> actions, Bundle savedInstanceState) {
|
||||||
|
actions.add(new GuidedAction.Builder(getActivity())
|
||||||
|
.clickAction(GuidedAction.ACTION_ID_CANCEL)
|
||||||
|
.description("Cancel")
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGuidedActionClicked(GuidedAction action) {
|
||||||
|
FragmentManager fm = getFragmentManager();
|
||||||
|
fm.popBackStack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,13 +20,16 @@ import android.app.Activity;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.ActivityOptionsCompat;
|
|
||||||
import android.support.v17.leanback.app.GuidedStepFragment;
|
import android.support.v17.leanback.app.GuidedStepFragment;
|
||||||
import android.support.v17.leanback.widget.GuidedAction;
|
|
||||||
import android.support.v17.leanback.widget.GuidanceStylist.Guidance;
|
import android.support.v17.leanback.widget.GuidanceStylist.Guidance;
|
||||||
|
import android.support.v17.leanback.widget.GuidedAction;
|
||||||
|
import android.support.v4.app.ActivityOptionsCompat;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity that allows navigation among the demo activities.
|
* Activity that allows navigation among the demo activities.
|
||||||
@@ -41,10 +44,10 @@ public class MainActivity extends Activity {
|
|||||||
|
|
||||||
mGuidedStepFragment = new StepFragment();
|
mGuidedStepFragment = new StepFragment();
|
||||||
GuidedStepFragment.addAsRoot(this, mGuidedStepFragment, android.R.id.content);
|
GuidedStepFragment.addAsRoot(this, mGuidedStepFragment, android.R.id.content);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class StepFragment extends GuidedStepFragment {
|
public static class StepFragment extends GuidedStepFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Guidance onCreateGuidance(Bundle savedInstanceState) {
|
public Guidance onCreateGuidance(Bundle savedInstanceState) {
|
||||||
String title = getString(R.string.main_title);
|
String title = getString(R.string.main_title);
|
||||||
@@ -83,6 +86,11 @@ public class MainActivity extends Activity {
|
|||||||
R.string.guidedstep_description);
|
R.string.guidedstep_description);
|
||||||
addAction(actions, GuidedStepSupportActivity.class, R.string.guidedstepsupport,
|
addAction(actions, GuidedStepSupportActivity.class, R.string.guidedstepsupport,
|
||||||
R.string.guidedstepsupport_description);
|
R.string.guidedstepsupport_description);
|
||||||
|
addAction(actions, GuidedStepHalfScreenActivity.class, R.string.guidedstephalfscreen,
|
||||||
|
R.string.guidedstep_description);
|
||||||
|
addAction(actions, GuidedStepSupportHalfScreenActivity.class,
|
||||||
|
R.string.guidedstepsupporthalfscreen,
|
||||||
|
R.string.guidedstep_description);
|
||||||
addAction(actions, BrowseErrorActivity.class, R.string.browseerror,
|
addAction(actions, BrowseErrorActivity.class, R.string.browseerror,
|
||||||
R.string.browseerror_description);
|
R.string.browseerror_description);
|
||||||
addAction(actions, BrowseErrorSupportActivity.class, R.string.browseerror_support,
|
addAction(actions, BrowseErrorSupportActivity.class, R.string.browseerror_support,
|
||||||
|
|||||||
Reference in New Issue
Block a user