summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDake Gu <dake@google.com>2015-11-13 13:09:38 -0800
committerDake Gu <dake@google.com>2015-11-13 13:14:42 -0800
commitd775d3a528d7a1d4dc41a7cc847322a2fbef6da3 (patch)
tree2aa0641256c0aa14737a91c95a2731f33d5d5bdb
parentfffb2474d2aa360caab8084d0e3e68290f2a1530 (diff)
downloadandroid_development-d775d3a528d7a1d4dc41a7cc847322a2fbef6da3.tar.gz
android_development-d775d3a528d7a1d4dc41a7cc847322a2fbef6da3.tar.bz2
android_development-d775d3a528d7a1d4dc41a7cc847322a2fbef6da3.zip
SupportLeanbackDemos: guidedstep changes
1. no longer provide a view to host background view 2. add demo of checkbox 3. add demo of customize Ime options. Change-Id: I76dbbbd7e341906ff4e7b8923b1ddc2c01026f44
-rw-r--r--samples/SupportLeanbackDemos/res/layout/browse.xml5
-rw-r--r--samples/SupportLeanbackDemos/res/layout/browse_support.xml5
-rw-r--r--samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java40
-rw-r--r--samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepSupportActivity.java40
4 files changed, 54 insertions, 36 deletions
diff --git a/samples/SupportLeanbackDemos/res/layout/browse.xml b/samples/SupportLeanbackDemos/res/layout/browse.xml
index 1642c4457..ca196912c 100644
--- a/samples/SupportLeanbackDemos/res/layout/browse.xml
+++ b/samples/SupportLeanbackDemos/res/layout/browse.xml
@@ -27,11 +27,6 @@
android:layout_height="match_parent"
/>
- <!-- container for hosting GuidedStepFragment background -->
- <FrameLayout android:id="@+id/lb_guidedstep_background"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-
<!-- container for hosting GuidedStepFragment -->
<FrameLayout android:id="@+id/lb_guidedstep_host"
android:layout_width="match_parent"
diff --git a/samples/SupportLeanbackDemos/res/layout/browse_support.xml b/samples/SupportLeanbackDemos/res/layout/browse_support.xml
index b0c72a48b..23058ad9f 100644
--- a/samples/SupportLeanbackDemos/res/layout/browse_support.xml
+++ b/samples/SupportLeanbackDemos/res/layout/browse_support.xml
@@ -29,11 +29,6 @@
android:layout_height="match_parent"
/>
- <!-- container for hosting GuidedStepFragment background -->
- <FrameLayout android:id="@+id/lb_guidedstep_background"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-
<!-- container for hosting GuidedStepFragment -->
<FrameLayout android:id="@+id/lb_guidedstep_host"
android:layout_width="match_parent"
diff --git a/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java b/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java
index 66888ab6a..734ec347f 100644
--- a/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java
+++ b/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java
@@ -25,13 +25,16 @@ 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.GuidedActionsStylist;
import android.support.v17.leanback.widget.GuidanceStylist;
import android.support.v17.leanback.widget.GuidanceStylist.Guidance;
+import android.support.v17.leanback.widget.GuidedActionsStylist.ViewHolder;
import android.text.InputType;
import android.text.TextUtils;
import android.util.Log;
import android.view.ViewGroup;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
+import android.view.inputmethod.EditorInfo;
import java.util.List;
@@ -52,8 +55,6 @@ public class GuidedStepActivity extends Activity {
private static final String[] OPTION_NAMES = { "Option A", "Option B", "Option C" };
private static final String[] OPTION_DESCRIPTIONS = { "Here's one thing you can do",
"Here's another thing you can do", "Here's one more thing you can do" };
- private static final int[] OPTION_DRAWABLES = { R.drawable.ic_guidedstep_option_a,
- R.drawable.ic_guidedstep_option_b, R.drawable.ic_guidedstep_option_c };
private static final String TAG = GuidedStepActivity.class.getSimpleName();
@@ -136,13 +137,12 @@ public class GuidedStepActivity extends Activity {
.build());
}
- private static void addCheckedAction(List<GuidedAction> actions, int iconResId, Context context,
- String title, String desc) {
+ private static void addCheckedAction(List<GuidedAction> actions, Context context,
+ String title, String desc, int checkSetId) {
actions.add(new GuidedAction.Builder()
.title(title)
.description(desc)
- .checkSetId(OPTION_CHECK_SET_ID)
- .iconResourceId(iconResId, context)
+ .checkSetId(checkSetId)
.build());
}
@@ -181,14 +181,24 @@ public class GuidedStepActivity extends Activity {
}
}
- @Override
- protected int getContainerIdForBackground() {
- return R.id.lb_guidedstep_background;
- }
}
public static class SecondStepFragment extends GuidedStepFragment {
+ public GuidedActionsStylist onCreateActionsStylist() {
+ return new GuidedActionsStylist() {
+ protected void setupImeOptions(GuidedActionsStylist.ViewHolder vh,
+ GuidedAction action) {
+ if (action.getId() == PASSWORD) {
+ vh.getEditableDescriptionView().setImeActionLabel("Confirm!",
+ EditorInfo.IME_ACTION_DONE);
+ } else {
+ super.setupImeOptions(vh, action);
+ }
+ }
+ };
+ }
+
@Override
public Guidance onCreateGuidance(Bundle savedInstanceState) {
String title = getString(R.string.guidedstep_second_title);
@@ -311,12 +321,16 @@ public class GuidedStepActivity extends Activity {
.focusable(false)
.build());
for (int i = 0; i < OPTION_NAMES.length; i++) {
- addCheckedAction(actions, OPTION_DRAWABLES[i], getActivity(), OPTION_NAMES[i],
- OPTION_DESCRIPTIONS[i]);
+ addCheckedAction(actions, getActivity(), OPTION_NAMES[i],
+ OPTION_DESCRIPTIONS[i], GuidedAction.DEFAULT_CHECK_SET_ID);
if (i == DEFAULT_OPTION) {
actions.get(actions.size() -1).setChecked(true);
}
}
+ for (int i = 0; i < OPTION_NAMES.length; i++) {
+ addCheckedAction(actions, getActivity(), OPTION_NAMES[i],
+ OPTION_DESCRIPTIONS[i], GuidedAction.CHECKBOX_CHECK_SET_ID);
+ }
}
@Override
@@ -334,7 +348,7 @@ public class GuidedStepActivity extends Activity {
arguments.putInt(FourthStepFragment.EXTRA_OPTION, mSelectedOption);
f.setArguments(arguments);
GuidedStepFragment.add(fm, f, R.id.lb_guidedstep_host);
- } else {
+ } else if (action.getCheckSetId() == GuidedAction.DEFAULT_CHECK_SET_ID) {
mSelectedOption = getSelectedActionPosition()-1;
}
}
diff --git a/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepSupportActivity.java b/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepSupportActivity.java
index 70a0db844..3975dd6bc 100644
--- a/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepSupportActivity.java
+++ b/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepSupportActivity.java
@@ -27,13 +27,16 @@ import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v17.leanback.app.GuidedStepSupportFragment;
import android.support.v17.leanback.widget.GuidedAction;
+import android.support.v17.leanback.widget.GuidedActionsStylist;
import android.support.v17.leanback.widget.GuidanceStylist;
import android.support.v17.leanback.widget.GuidanceStylist.Guidance;
+import android.support.v17.leanback.widget.GuidedActionsStylist.ViewHolder;
import android.text.InputType;
import android.text.TextUtils;
import android.util.Log;
import android.view.ViewGroup;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
+import android.view.inputmethod.EditorInfo;
import java.util.List;
@@ -54,8 +57,6 @@ public class GuidedStepSupportActivity extends FragmentActivity {
private static final String[] OPTION_NAMES = { "Option A", "Option B", "Option C" };
private static final String[] OPTION_DESCRIPTIONS = { "Here's one thing you can do",
"Here's another thing you can do", "Here's one more thing you can do" };
- private static final int[] OPTION_DRAWABLES = { R.drawable.ic_guidedstep_option_a,
- R.drawable.ic_guidedstep_option_b, R.drawable.ic_guidedstep_option_c };
private static final String TAG = GuidedStepSupportActivity.class.getSimpleName();
@@ -138,13 +139,12 @@ public class GuidedStepSupportActivity extends FragmentActivity {
.build());
}
- private static void addCheckedAction(List<GuidedAction> actions, int iconResId, Context context,
- String title, String desc) {
+ private static void addCheckedAction(List<GuidedAction> actions, Context context,
+ String title, String desc, int checkSetId) {
actions.add(new GuidedAction.Builder()
.title(title)
.description(desc)
- .checkSetId(OPTION_CHECK_SET_ID)
- .iconResourceId(iconResId, context)
+ .checkSetId(checkSetId)
.build());
}
@@ -183,14 +183,24 @@ public class GuidedStepSupportActivity extends FragmentActivity {
}
}
- @Override
- protected int getContainerIdForBackground() {
- return R.id.lb_guidedstep_background;
- }
}
public static class SecondStepFragment extends GuidedStepSupportFragment {
+ public GuidedActionsStylist onCreateActionsStylist() {
+ return new GuidedActionsStylist() {
+ protected void setupImeOptions(GuidedActionsStylist.ViewHolder vh,
+ GuidedAction action) {
+ if (action.getId() == PASSWORD) {
+ vh.getEditableDescriptionView().setImeActionLabel("Confirm!",
+ EditorInfo.IME_ACTION_DONE);
+ } else {
+ super.setupImeOptions(vh, action);
+ }
+ }
+ };
+ }
+
@Override
public Guidance onCreateGuidance(Bundle savedInstanceState) {
String title = getString(R.string.guidedstep_second_title);
@@ -313,12 +323,16 @@ public class GuidedStepSupportActivity extends FragmentActivity {
.focusable(false)
.build());
for (int i = 0; i < OPTION_NAMES.length; i++) {
- addCheckedAction(actions, OPTION_DRAWABLES[i], getActivity(), OPTION_NAMES[i],
- OPTION_DESCRIPTIONS[i]);
+ addCheckedAction(actions, getActivity(), OPTION_NAMES[i],
+ OPTION_DESCRIPTIONS[i], GuidedAction.DEFAULT_CHECK_SET_ID);
if (i == DEFAULT_OPTION) {
actions.get(actions.size() -1).setChecked(true);
}
}
+ for (int i = 0; i < OPTION_NAMES.length; i++) {
+ addCheckedAction(actions, getActivity(), OPTION_NAMES[i],
+ OPTION_DESCRIPTIONS[i], GuidedAction.CHECKBOX_CHECK_SET_ID);
+ }
}
@Override
@@ -336,7 +350,7 @@ public class GuidedStepSupportActivity extends FragmentActivity {
arguments.putInt(FourthStepFragment.EXTRA_OPTION, mSelectedOption);
f.setArguments(arguments);
GuidedStepSupportFragment.add(fm, f, R.id.lb_guidedstep_host);
- } else {
+ } else if (action.getCheckSetId() == GuidedAction.DEFAULT_CHECK_SET_ID) {
mSelectedOption = getSelectedActionPosition()-1;
}
}