165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane/* 265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * Copyright (C) 2014 The Android Open Source Project 365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * 465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * Licensed under the Apache License, Version 2.0 (the "License"); 565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * you may not use this file except in compliance with the License. 665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * You may obtain a copy of the License at 765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * 865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * http://www.apache.org/licenses/LICENSE-2.0 965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * 1065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * Unless required by applicable law or agreed to in writing, software 1165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * distributed under the License is distributed on an "AS IS" BASIS, 1265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * See the License for the specific language governing permissions and 1465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * limitations under the License. 1565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane */ 1665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 1765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lanepackage com.android.tv.settings.connectivity; 1865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 1965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport com.android.tv.settings.connectivity.setup.MessageWizardFragment; 2065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport com.android.tv.settings.connectivity.setup.SelectFromListWizardFragment; 2165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport com.android.tv.settings.connectivity.setup.TextInputWizardFragment; 2265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport com.android.tv.settings.connectivity.setup.PasswordInputWizardFragment; 2365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport com.android.tv.settings.connectivity.setup.SelectFromListWizardFragment.ListItem; 2465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport com.android.tv.settings.form.FormPage; 2565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport com.android.tv.settings.form.FormPageResultListener; 2665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport com.android.tv.settings.R; 2765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 2865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport android.app.Fragment; 2965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport android.app.FragmentManager; 3065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport android.app.FragmentTransaction; 3165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport android.content.Context; 3265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport android.os.Bundle; 3365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport android.text.TextUtils; 3465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport android.util.Log; 3565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 3665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport java.util.ArrayList; 3765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 3865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane/** 3965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * Displays form pages. 4065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane */ 4165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lanepublic class FormPageDisplayer 4265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane implements TextInputWizardFragment.Listener, SelectFromListWizardFragment.Listener, 4365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane PasswordInputWizardFragment.Listener { 4465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 4565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane public static final int DISPLAY_TYPE_TEXT_INPUT = 1; 4665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane public static final int DISPLAY_TYPE_LIST_CHOICE = 2; 4765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane public static final int DISPLAY_TYPE_LOADING = 3; 4865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane public static final int DISPLAY_TYPE_PASSWORD_INPUT = 4; 4965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 5065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane public interface FormPageInfo { 5165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane /** 5265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * @return the resource id of the title for this page. 5365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane */ 5465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane int getTitleResourceId(); 5565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 5665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane /** 5765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * @return the resource id of the description for this page. 0 if no description. 5865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane */ 5965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane int getDescriptionResourceId(); 6065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 6165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane /** 6265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * @return the input type for the editable text field for this page. 6365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane */ 6465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane int getInputType(); 6565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 6665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane /** 6765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * @return the way this form page should be displayed. 6865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane */ 6965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane int getDisplayType(); 7065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 7165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane /** 7265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * @return the set of choices for this form page. 7365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane */ 7465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane ArrayList<SelectFromListWizardFragment.ListItem> getChoices(Context context, 7565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane ArrayList<SelectFromListWizardFragment.ListItem> extraChoices); 7665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 7765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 7865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane public interface UserActivityListener { 7965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane void onUserActivity(); 8065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 8165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 8265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private static final String TAG = "FormPageDisplayer"; 8365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private static final boolean DEBUG = false; 8465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private static final String RESULT_LIST_ITEM = "result_list_item"; 8565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 8665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private final Context mContext; 8765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private final FragmentManager mFragmentManager; 8865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private TextInputWizardFragment.Listener mTextInputWizardFragmentListener; 8965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private PasswordInputWizardFragment.Listener mPasswordInputWizardFragmentListener; 9065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private SelectFromListWizardFragment.Listener mSelectFromListWizardFragmentListener; 9165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private int mContentViewId; 9265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 9365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane public FormPageDisplayer(Context context, FragmentManager fragmentManager, int contentViewId) { 9465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane mContext = context; 9565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane mFragmentManager = fragmentManager; 9665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane mContentViewId = contentViewId; 9765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 9865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 9965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane @Override 10065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane public boolean onTextInputComplete(String text) { 10165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane if (mTextInputWizardFragmentListener != null) { 10265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return mTextInputWizardFragmentListener.onTextInputComplete(text); 10365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 10465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return true; 10565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 10665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 10765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane @Override 10865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane public boolean onPasswordInputComplete(String text) { 10965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane if (mPasswordInputWizardFragmentListener != null) { 11065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return mPasswordInputWizardFragmentListener.onPasswordInputComplete(text); 11165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 11265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return true; 11365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 11465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 11565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane @Override 11665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane public void onListSelectionComplete(ListItem listItem) { 11765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane if (mSelectFromListWizardFragmentListener != null) { 11865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane mSelectFromListWizardFragmentListener.onListSelectionComplete(listItem); 11965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 12065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 12165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 12265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane @Override 12365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane public void onListFocusChanged(ListItem listItem) { 12465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane if (mSelectFromListWizardFragmentListener != null) { 12565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane mSelectFromListWizardFragmentListener.onListFocusChanged(listItem); 12665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 12765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 12865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 12965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane public Fragment displayPage(FormPageInfo formPageInfo, String titleArgument, 13065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane String descriptionArgument, 13165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane ArrayList<SelectFromListWizardFragment.ListItem> extraChoices, 13265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane FormPage previousFormPage, UserActivityListener userActivityListener, 13365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane boolean showProgress, FormPage currentFormPage, 13465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane FormPageResultListener formPageResultListener, boolean forward, boolean emptyAllowed) { 13565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane if (DEBUG) { 13665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane Log.d(TAG, "Displaying: " + currentFormPage.getTitle()); 13765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 13865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane switch (formPageInfo.getDisplayType()) { 13965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane case DISPLAY_TYPE_LIST_CHOICE: 14065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return displayList(formPageInfo, titleArgument, descriptionArgument, extraChoices, 14165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane currentFormPage, formPageResultListener, previousFormPage, 14265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane userActivityListener, forward); 14365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 14465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane case DISPLAY_TYPE_TEXT_INPUT: 14565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return displayTextInput(formPageInfo, titleArgument, descriptionArgument, 14665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane currentFormPage, formPageResultListener, previousFormPage, forward, 14765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane emptyAllowed); 14865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 14965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane case DISPLAY_TYPE_PASSWORD_INPUT: 15065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return displayPasswordInput(formPageInfo, titleArgument, descriptionArgument, 15165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane currentFormPage, formPageResultListener, previousFormPage, forward, 15265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane emptyAllowed); 15365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 15465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane case DISPLAY_TYPE_LOADING: 15565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return displayLoading(formPageInfo, titleArgument, showProgress, forward); 15665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 15765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane default: 15865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return null; 15965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 16065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 16165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 16265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane public ListItem getListItem(FormPage formPage) { 16365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return formPage.getData().getParcelable(RESULT_LIST_ITEM); 16465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 16565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 16665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane public void displayFragment(Fragment fragment, boolean forward) { 16765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane FragmentTransaction transaction = mFragmentManager.beginTransaction(); 16865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane if (forward) { 16965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); 17065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } else { 17165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE); 17265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 17365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane transaction.replace(mContentViewId, fragment).commit(); 17465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 17565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 17665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private Fragment displayList(final FormPageInfo formPageInfo, String titleArgument, 17765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane String descriptionArgument, 17865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane ArrayList<SelectFromListWizardFragment.ListItem> extraChoices, final FormPage formPage, 17965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane final FormPageResultListener formPageResultListener, FormPage lastPage, 18065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane final UserActivityListener userActivityListener, boolean forward) { 18165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane Fragment fragment = SelectFromListWizardFragment.newInstance( 18265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane getTitle(formPageInfo, titleArgument), 18365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane getDescription(formPageInfo, descriptionArgument), 18465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane formPageInfo.getChoices(mContext, extraChoices), lastPage == null ? null 18565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane : (ListItem) lastPage.getData().getParcelable(RESULT_LIST_ITEM)); 18665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane displayFragment(fragment, forward); 18765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane mSelectFromListWizardFragmentListener = new SelectFromListWizardFragment.Listener() { 18865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane @Override 18965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane public void onListSelectionComplete(ListItem selection) { 19065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane Bundle result = new Bundle(); 19165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane result.putParcelable(RESULT_LIST_ITEM, selection); 19265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane result.putString(FormPage.DATA_KEY_SUMMARY_STRING, selection.getName()); 19365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane formPageResultListener.onBundlePageResult(formPage, result); 19465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 19565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 19665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane @Override 19765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane public void onListFocusChanged(ListItem listItem) { 19865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane if (userActivityListener != null) { 19965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane userActivityListener.onUserActivity(); 20065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 20165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 20265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane }; 20365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return fragment; 20465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 20565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 20665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private Fragment displayTextInput(FormPageInfo formPageInfo, String titleArgument, 20765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane String descriptionArgument, final FormPage formPage, 20865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane final FormPageResultListener listener, FormPage lastPage, boolean forward, 20965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane final boolean emptyAllowed) { 21065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane Fragment fragment = TextInputWizardFragment.newInstance( 21165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane getTitle(formPageInfo, titleArgument), 21265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane getDescription(formPageInfo, descriptionArgument), 21365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane formPageInfo.getInputType(), lastPage == null ? null : lastPage.getDataSummary()); 21465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane displayFragment(fragment, forward); 21565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 21665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane mTextInputWizardFragmentListener = new TextInputWizardFragment.Listener() { 21765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane @Override 21865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane public boolean onTextInputComplete(String text) { 21965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane if (!TextUtils.isEmpty(text) || emptyAllowed) { 22065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane Bundle result = new Bundle(); 22165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane result.putString(FormPage.DATA_KEY_SUMMARY_STRING, text); 22265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane listener.onBundlePageResult(formPage, result); 22365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return true; 22465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 22565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return false; 22665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 22765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane }; 22865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return fragment; 22965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 23065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 23165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private Fragment displayPasswordInput(FormPageInfo formPageInfo, String titleArgument, 23265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane String descriptionArgument, final FormPage formPage, 23365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane final FormPageResultListener listener, FormPage lastPage, boolean forward, 23465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane final boolean emptyAllowed) { 23565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane Fragment fragment = PasswordInputWizardFragment.newInstance( 23665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane getTitle(formPageInfo, titleArgument), 23765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane getDescription(formPageInfo, descriptionArgument), formPageInfo.getInputType(), 23865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane lastPage == null ? null : lastPage.getDataSummary()); 23965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane displayFragment(fragment, forward); 24065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 24165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane mPasswordInputWizardFragmentListener = new PasswordInputWizardFragment.Listener() { 24265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane @Override 24365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane public boolean onPasswordInputComplete(String text) { 24465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane if (!TextUtils.isEmpty(text) || emptyAllowed) { 24565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane Bundle result = new Bundle(); 24665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane result.putString(FormPage.DATA_KEY_SUMMARY_STRING, text); 24765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane listener.onBundlePageResult(formPage, result); 24865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return true; 24965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 25065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return false; 25165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 25265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane }; 25365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return fragment; 25465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 25565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 25665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private Fragment displayLoading(FormPageInfo formPageInfo, String argument, 25765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane boolean showProgress, boolean forward) { 25865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane Fragment fragment = MessageWizardFragment.newInstance( 25965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane getTitle(formPageInfo, argument), showProgress); 26065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane displayFragment(fragment, forward); 26165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return fragment; 26265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 26365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 26465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private String getTitle(FormPageInfo formPageInfo, String argument) { 26565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return mContext.getString(formPageInfo.getTitleResourceId(), argument); 26665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 26765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 26865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private String getDescription(FormPageInfo formPageInfo, String argument) { 26965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane int descriptionResourceId = formPageInfo.getDescriptionResourceId(); 27065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return (descriptionResourceId != 0) ? mContext.getString(descriptionResourceId, argument) 27165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane : null; 27265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 27365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane} 274