Commit 6aa732f8 authored by primiano@chromium.org's avatar primiano@chromium.org

[Android] SelectPopupDialog - resolve style for <select> dialogs.

Right now the <select> dialogs use directly
R.layout.select_dialog_(multi|single)choice defined in the Android
framework. Adding an extra level of indirection to them through attrs
since other builds need to override these two layouts.

BUG=285270
NOTRY=true

Review URL: https://chromiumcodereview.appspot.com/23523025

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221396 0039d316-1c4b-4281-b951-d872f2087c98
parent 89f5a178
......@@ -10,4 +10,8 @@
<item name="action_mode_share_drawable">@drawable/ic_menu_share_holo_light</item>
<item name="action_mode_web_search_drawable">@drawable/ic_menu_search_holo_light</item>
</style>
<style name="SelectPopupDialog">
<item name="select_dialog_singlechoice">@android:layout/select_dialog_singlechoice</item>
<item name="select_dialog_multichoice">@android:layout/select_dialog_multichoice</item>
</style>
</resources>
......@@ -8,4 +8,6 @@
<resources>
<attr name="action_mode_share_drawable" format="reference" />
<attr name="action_mode_web_search_drawable" format="reference" />
<attr name="select_dialog_multichoice" format="reference" />
<attr name="select_dialog_singlechoice" format="reference" />
</resources>
......@@ -19,6 +19,8 @@ public final class R {
public static final class attr {
public static int action_mode_share_drawable;
public static int action_mode_web_search_drawable;
public static int select_dialog_multichoice;
public static int select_dialog_singlechoice;
}
public static final class dimen {
public static int link_preview_overlay_radius;
......@@ -73,5 +75,6 @@ public final class R {
}
public static final class style {
public static int ContentActionBar;
public static int SelectPopupDialog;
}
}
......@@ -8,6 +8,7 @@ import org.chromium.content.browser.ContentViewCore;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.res.TypedArray;
import android.util.SparseBooleanArray;
import android.view.View;
import android.view.ViewGroup;
......@@ -17,6 +18,8 @@ import android.widget.ArrayAdapter;
import android.widget.CheckedTextView;
import android.widget.ListView;
import org.chromium.content.R;
/**
* Handles the popup dialog for the <select> HTML tag support.
*/
......@@ -24,6 +27,11 @@ public class SelectPopupDialog {
// The currently showing popup dialog, null if none is showing.
private static SelectPopupDialog sShownDialog;
private static final int[] SELECT_DIALOG_ATTRS = {
R.attr.select_dialog_multichoice,
R.attr.select_dialog_singlechoice
};
// The dialog hosting the popup list view.
private AlertDialog mListBoxPopup = null;
......@@ -48,9 +56,7 @@ public class SelectPopupDialog {
private boolean mAreAllItemsEnabled;
public SelectPopupArrayAdapter(String[] labels, int[] enabled, boolean multiple) {
super(mContentViewCore.getContext(), multiple ?
android.R.layout.select_dialog_multichoice :
android.R.layout.select_dialog_singlechoice, labels);
super(mContentViewCore.getContext(), getSelectDialogLayout(multiple), labels);
mItemEnabled = enabled;
mAreAllItemsEnabled = true;
for (int item : mItemEnabled) {
......@@ -99,6 +105,15 @@ public class SelectPopupDialog {
}
}
private int getSelectDialogLayout(boolean isMultiChoice) {
int resource_id;
TypedArray styledAttributes = mContentViewCore.getContext().obtainStyledAttributes(
R.style.SelectPopupDialog, SELECT_DIALOG_ATTRS);
resource_id = styledAttributes.getResourceId(isMultiChoice ? 0 : 1, 0);
styledAttributes.recycle();
return resource_id;
}
private SelectPopupDialog(ContentViewCore contentViewCore, String[] labels, int[] enabled,
boolean multiple, int[] selected) {
mContentViewCore = contentViewCore;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment