Bug 807606 - Add some padding to the inputs in the PromptService and wrap them in a Scrollview. r=wesj

This commit is contained in:
Kartikaya Gupta 2013-01-24 15:41:35 -05:00
parent 0433e6c111
commit 0872349970
2 changed files with 13 additions and 2 deletions

View File

@ -38,6 +38,7 @@ import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.TimePicker;
@ -64,6 +65,7 @@ public class PromptService implements OnClickListener, OnCancelListener, OnItemC
private final int mTopBottomTextWithIconPadding;
private final int mIconTextPadding;
private final int mIconSize;
private final int mInputPaddingSize;
PromptService() {
sInflater = LayoutInflater.from(GeckoApp.mAppContext);
@ -74,6 +76,7 @@ public class PromptService implements OnClickListener, OnCancelListener, OnItemC
mTopBottomTextWithIconPadding = (int) (res.getDimension(R.dimen.prompt_service_top_bottom_text_with_icon_padding));
mIconTextPadding = (int) (res.getDimension(R.dimen.prompt_service_icon_text_padding));
mIconSize = (int) (res.getDimension(R.dimen.prompt_service_icon_size));
mInputPaddingSize = (int) (res.getDimension(R.dimen.prompt_service_inputs_padding));
GeckoAppShell.getEventDispatcher().registerEventListener("Prompt:Show", this);
}
@ -273,6 +276,11 @@ public class PromptService implements OnClickListener, OnCancelListener, OnItemC
return promptServiceResult;
}
private View applyInputStyle(View view) {
view.setPadding(mInputPaddingSize, 0, mInputPaddingSize, 0);
return view;
}
public void show(String aTitle, String aText, PromptListItem[] aMenuList, boolean aMultipleSelection) {
GeckoApp.assertOnUiThread();
@ -324,7 +332,7 @@ public class PromptService implements OnClickListener, OnCancelListener, OnItemC
}
} else if (length == 1) {
try {
builder.setView(mInputs[0].getView());
builder.setView(applyInputStyle(mInputs[0].getView()));
} catch(UnsupportedOperationException ex) {
// We cannot display these input widgets with this sdk version,
// do not display any dialog and finish the prompt now.
@ -345,7 +353,9 @@ public class PromptService implements OnClickListener, OnCancelListener, OnItemC
finishDialog("{\"button\": -1}");
return;
}
builder.setView((View)linearLayout);
ScrollView view = new ScrollView(GeckoApp.mAppContext);
view.addView(linearLayout);
builder.setView(applyInputStyle(view));
}
length = mButtons == null ? 0 : mButtons.length;

View File

@ -40,6 +40,7 @@
<dimen name="prompt_service_group_padding_size">32dp</dimen>
<dimen name="prompt_service_icon_size">72dp</dimen>
<dimen name="prompt_service_icon_text_padding">10dp</dimen>
<dimen name="prompt_service_inputs_padding">16dp</dimen>
<dimen name="prompt_service_left_right_text_with_icon_padding">10dp</dimen>
<dimen name="prompt_service_top_bottom_text_with_icon_padding">8dp</dimen>
<dimen name="remote_tab_child_row_height">64dp</dimen>