summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDake Gu <dake@google.com>2015-10-28 13:42:25 -0700
committerDake Gu <dake@google.com>2015-10-28 13:43:44 -0700
commit37836fd9d739385fdbdc8cd38b11451ef1df6a34 (patch)
tree890f7fbd0de8813213141cef7b552ec32dcb2014
parent23ee659cba7f4375d2beb3f39289937f425b2666 (diff)
downloadandroid_development-37836fd9d739385fdbdc8cd38b11451ef1df6a34.tar.gz
android_development-37836fd9d739385fdbdc8cd38b11451ef1df6a34.tar.bz2
android_development-37836fd9d739385fdbdc8cd38b11451ef1df6a34.zip
GuidedStep example: Use standard action IDs and titles
Bug 25193684 Change-Id: Iced3aa78db1437d1823b60d2be1188993f557958
-rw-r--r--samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java36
-rw-r--r--samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepSupportActivity.java36
2 files changed, 44 insertions, 28 deletions
diff --git a/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java b/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java
index fdec4d88c..52ed739b0 100644
--- a/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java
+++ b/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java
@@ -40,7 +40,6 @@ import java.util.List;
*/
public class GuidedStepActivity extends Activity {
- private static final int CONTINUE = 1;
private static final int BACK = 2;
private static final int FIRST_NAME = 3;
@@ -163,16 +162,20 @@ public class GuidedStepActivity extends Activity {
@Override
public void onCreateActions(List<GuidedAction> actions, Bundle savedInstanceState) {
- addAction(actions, CONTINUE, "Continue", "Let's do it");
- addAction(actions, BACK, "Cancel", "Nevermind");
+ actions.add(new GuidedAction.Builder().constructContinue(getActivity())
+ .description("Let's do it")
+ .build());
+ actions.add(new GuidedAction.Builder().constructCancel(getActivity())
+ .description("Never mind")
+ .build());
}
@Override
public void onGuidedActionClicked(GuidedAction action) {
FragmentManager fm = getFragmentManager();
- if (action.getId() == CONTINUE) {
+ if (action.getId() == GuidedAction.ACTION_ID_CONTINUE) {
GuidedStepFragment.add(fm, new SecondStepFragment(), android.R.id.content);
- } else {
+ } else if (action.getId() == GuidedAction.ACTION_ID_CANCEL){
finishGuidedStepFragments();
}
}
@@ -202,13 +205,15 @@ public class GuidedStepActivity extends Activity {
"Input credit card number", "Input credit card number");
addEditableDescriptionAction(actions, PASSWORD, "Password", "", "",
InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
- addAction(actions, CONTINUE, "Continue", "Continue");
+ actions.add(new GuidedAction.Builder().constructContinue(getActivity())
+ .description("Continue")
+ .build());
actions.get(actions.size() - 1).setEnabled(false);
}
@Override
public void onGuidedActionClicked(GuidedAction action) {
- if (action.getId() == CONTINUE) {
+ if (action.getId() == GuidedAction.ACTION_ID_CONTINUE) {
FragmentManager fm = getFragmentManager();
GuidedStepFragment.add(fm, new ThirdStepFragment());
}
@@ -259,8 +264,8 @@ public class GuidedStepActivity extends Activity {
}
void updateContinue(boolean enabled) {
- findActionById(CONTINUE).setEnabled(enabled);
- notifyActionChanged(findActionPositionById(CONTINUE));
+ findActionById(GuidedAction.ACTION_ID_CONTINUE).setEnabled(enabled);
+ notifyActionChanged(findActionPositionById(GuidedAction.ACTION_ID_CONTINUE));
}
}
@@ -305,12 +310,13 @@ public class GuidedStepActivity extends Activity {
actions.get(actions.size() -1).setChecked(true);
}
}
- addAction(actions, CONTINUE, "Continue", "");
+ actions.add(new GuidedAction.Builder().constructContinue(getActivity())
+ .build());
}
@Override
public void onGuidedActionClicked(GuidedAction action) {
- if (action.getId() == CONTINUE) {
+ if (action.getId() == GuidedAction.ACTION_ID_CONTINUE) {
FragmentManager fm = getFragmentManager();
FourthStepFragment f = new FourthStepFragment();
Bundle arguments = new Bundle();
@@ -347,15 +353,17 @@ public class GuidedStepActivity extends Activity {
@Override
public void onCreateActions(List<GuidedAction> actions, Bundle savedInstanceState) {
- addAction(actions, CONTINUE, "Done", "All finished");
+ actions.add(new GuidedAction.Builder().constructFinish(getActivity())
+ .description("All Done...")
+ .build());
addAction(actions, BACK, "Start Over", "Let's try this again...");
}
@Override
public void onGuidedActionClicked(GuidedAction action) {
- if (action.getId() == CONTINUE) {
+ if (action.getId() == GuidedAction.ACTION_ID_FINISH) {
finishGuidedStepFragments();
- } else {
+ } else if (action.getId() == BACK) {
// pop 4, 3, 2
popBackStackToGuidedStepFragment(SecondStepFragment.class,
FragmentManager.POP_BACK_STACK_INCLUSIVE);
diff --git a/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepSupportActivity.java b/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepSupportActivity.java
index 5ac34dd37..7f3a33a84 100644
--- a/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepSupportActivity.java
+++ b/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepSupportActivity.java
@@ -42,7 +42,6 @@ import java.util.List;
*/
public class GuidedStepSupportActivity extends FragmentActivity {
- private static final int CONTINUE = 1;
private static final int BACK = 2;
private static final int FIRST_NAME = 3;
@@ -165,16 +164,20 @@ public class GuidedStepSupportActivity extends FragmentActivity {
@Override
public void onCreateActions(List<GuidedAction> actions, Bundle savedInstanceState) {
- addAction(actions, CONTINUE, "Continue", "Let's do it");
- addAction(actions, BACK, "Cancel", "Nevermind");
+ actions.add(new GuidedAction.Builder().constructContinue(getActivity())
+ .description("Let's do it")
+ .build());
+ actions.add(new GuidedAction.Builder().constructCancel(getActivity())
+ .description("Never mind")
+ .build());
}
@Override
public void onGuidedActionClicked(GuidedAction action) {
FragmentManager fm = getFragmentManager();
- if (action.getId() == CONTINUE) {
+ if (action.getId() == GuidedAction.ACTION_ID_CONTINUE) {
GuidedStepSupportFragment.add(fm, new SecondStepFragment(), android.R.id.content);
- } else {
+ } else if (action.getId() == GuidedAction.ACTION_ID_CANCEL){
finishGuidedStepSupportFragments();
}
}
@@ -204,13 +207,15 @@ public class GuidedStepSupportActivity extends FragmentActivity {
"Input credit card number", "Input credit card number");
addEditableDescriptionAction(actions, PASSWORD, "Password", "", "",
InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
- addAction(actions, CONTINUE, "Continue", "Continue");
+ actions.add(new GuidedAction.Builder().constructContinue(getActivity())
+ .description("Continue")
+ .build());
actions.get(actions.size() - 1).setEnabled(false);
}
@Override
public void onGuidedActionClicked(GuidedAction action) {
- if (action.getId() == CONTINUE) {
+ if (action.getId() == GuidedAction.ACTION_ID_CONTINUE) {
FragmentManager fm = getFragmentManager();
GuidedStepSupportFragment.add(fm, new ThirdStepFragment());
}
@@ -261,8 +266,8 @@ public class GuidedStepSupportActivity extends FragmentActivity {
}
void updateContinue(boolean enabled) {
- findActionById(CONTINUE).setEnabled(enabled);
- notifyActionChanged(findActionPositionById(CONTINUE));
+ findActionById(GuidedAction.ACTION_ID_CONTINUE).setEnabled(enabled);
+ notifyActionChanged(findActionPositionById(GuidedAction.ACTION_ID_CONTINUE));
}
}
@@ -307,12 +312,13 @@ public class GuidedStepSupportActivity extends FragmentActivity {
actions.get(actions.size() -1).setChecked(true);
}
}
- addAction(actions, CONTINUE, "Continue", "");
+ actions.add(new GuidedAction.Builder().constructContinue(getActivity())
+ .build());
}
@Override
public void onGuidedActionClicked(GuidedAction action) {
- if (action.getId() == CONTINUE) {
+ if (action.getId() == GuidedAction.ACTION_ID_CONTINUE) {
FragmentManager fm = getFragmentManager();
FourthStepFragment f = new FourthStepFragment();
Bundle arguments = new Bundle();
@@ -349,15 +355,17 @@ public class GuidedStepSupportActivity extends FragmentActivity {
@Override
public void onCreateActions(List<GuidedAction> actions, Bundle savedInstanceState) {
- addAction(actions, CONTINUE, "Done", "All finished");
+ actions.add(new GuidedAction.Builder().constructFinish(getActivity())
+ .description("All Done...")
+ .build());
addAction(actions, BACK, "Start Over", "Let's try this again...");
}
@Override
public void onGuidedActionClicked(GuidedAction action) {
- if (action.getId() == CONTINUE) {
+ if (action.getId() == GuidedAction.ACTION_ID_FINISH) {
finishGuidedStepSupportFragments();
- } else {
+ } else if (action.getId() == BACK) {
// pop 4, 3, 2
popBackStackToGuidedStepSupportFragment(SecondStepFragment.class,
FragmentManager.POP_BACK_STACK_INCLUSIVE);