SupportLeanbackDemos: guidedstep changes am: d775d3a528

am: 3af594e9d7

* commit '3af594e9d7764e810a98937769de2199b71c7aa8':
  SupportLeanbackDemos: guidedstep changes
This commit is contained in:
Dake Gu
2015-11-13 21:59:15 +00:00
committed by android-build-merger
4 changed files with 54 additions and 36 deletions

View File

@@ -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"

View File

@@ -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"

View File

@@ -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;
}
}

View File

@@ -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;
}
}