Loading core/java/android/widget/SearchView.java +26 −0 Original line number Diff line number Diff line Loading @@ -45,7 +45,9 @@ import android.text.TextUtils; import android.text.TextWatcher; import android.text.style.ImageSpan; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.util.Log; import android.util.TypedValue; import android.view.CollapsibleActionView; import android.view.KeyEvent; import android.view.LayoutInflater; Loading Loading @@ -1722,6 +1724,14 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { mThreshold = getThreshold(); } @Override protected void onFinishInflate() { super.onFinishInflate(); DisplayMetrics metrics = getResources().getDisplayMetrics(); setMinWidth((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, getSearchViewTextMinWidthDp(), metrics)); } void setSearchView(SearchView searchView) { mSearchView = searchView; } Loading Loading @@ -1818,5 +1828,21 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { return super.onKeyPreIme(keyCode, event); } /** * Get minimum width of the search view text entry area. */ private int getSearchViewTextMinWidthDp() { final Configuration configuration = getResources().getConfiguration(); final int width = configuration.screenWidthDp; final int height = configuration.screenHeightDp; final int orientation = configuration.orientation; if (width >= 960 && height >= 720 && orientation == Configuration.ORIENTATION_LANDSCAPE) { return 256; } else if (width >= 600 || (width >= 640 && height >= 480)) { return 192; }; return 160; } } } core/java/com/android/internal/view/ActionBarPolicy.java +5 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,11 @@ public class ActionBarPolicy { // The embedded tabs policy changed in Jellybean; give older apps the old policy // so they get what they expect. return mContext.getResources().getBoolean(R.bool.action_bar_embed_tabs_pre_jb); final Configuration configuration = mContext.getResources().getConfiguration(); final int width = configuration.screenWidthDp; final int height = configuration.screenHeightDp; return configuration.orientation == Configuration.ORIENTATION_LANDSCAPE || width >= 480 || (width >= 640 && height >= 480); } public int getTabContainerHeight() { Loading core/java/com/android/internal/view/menu/ActionMenuItemView.java +14 −4 Original line number Diff line number Diff line Loading @@ -72,8 +72,7 @@ public class ActionMenuItemView extends TextView public ActionMenuItemView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); final Resources res = context.getResources(); mAllowTextWithIcon = res.getBoolean( com.android.internal.R.bool.config_allowActionMenuItemTextWithIcon); mAllowTextWithIcon = shouldAllowTextWithIcon(); final TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.ActionMenuItemView, defStyleAttr, defStyleRes); mMinWidth = a.getDimensionPixelSize( Loading @@ -93,11 +92,22 @@ public class ActionMenuItemView extends TextView public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); mAllowTextWithIcon = getContext().getResources().getBoolean( com.android.internal.R.bool.config_allowActionMenuItemTextWithIcon); mAllowTextWithIcon = shouldAllowTextWithIcon(); updateTextButtonVisibility(); } /** * Whether action menu items should obey the "withText" showAsAction flag. This may be set to * false for situations where space is extremely limited. --> */ private boolean shouldAllowTextWithIcon() { final Configuration configuration = getContext().getResources().getConfiguration(); final int width = configuration.screenWidthDp; final int height = configuration.screenHeightDp; return width >= 480 || (width >= 640 && height >= 480) || configuration.orientation == Configuration.ORIENTATION_LANDSCAPE; } @Override public void setPadding(int l, int t, int r, int b) { mSavedPaddingLeft = l; Loading core/res/res/layout/search_view.xml +1 −2 Original line number Diff line number Diff line Loading @@ -81,7 +81,6 @@ android:layout_height="36dip" android:layout_width="0dp" android:layout_weight="1" android:minWidth="@dimen/search_view_text_min_width" android:layout_gravity="bottom" android:paddingStart="@dimen/dropdownitem_text_padding_left" android:paddingEnd="@dimen/dropdownitem_text_padding_right" Loading core/res/res/values-large/dimens.xml +0 −3 Original line number Diff line number Diff line Loading @@ -24,9 +24,6 @@ <!-- keyboardHeight = key_height*4 + key_bottom_gap*3 --> <dimen name="password_keyboard_height">48.0mm</dimen> <!-- Minimum width of the search view text entry area. --> <dimen name="search_view_text_min_width">192dip</dimen> <item type="dimen" name="dialog_min_width_major">55%</item> <item type="dimen" name="dialog_min_width_minor">80%</item> Loading Loading
core/java/android/widget/SearchView.java +26 −0 Original line number Diff line number Diff line Loading @@ -45,7 +45,9 @@ import android.text.TextUtils; import android.text.TextWatcher; import android.text.style.ImageSpan; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.util.Log; import android.util.TypedValue; import android.view.CollapsibleActionView; import android.view.KeyEvent; import android.view.LayoutInflater; Loading Loading @@ -1722,6 +1724,14 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { mThreshold = getThreshold(); } @Override protected void onFinishInflate() { super.onFinishInflate(); DisplayMetrics metrics = getResources().getDisplayMetrics(); setMinWidth((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, getSearchViewTextMinWidthDp(), metrics)); } void setSearchView(SearchView searchView) { mSearchView = searchView; } Loading Loading @@ -1818,5 +1828,21 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { return super.onKeyPreIme(keyCode, event); } /** * Get minimum width of the search view text entry area. */ private int getSearchViewTextMinWidthDp() { final Configuration configuration = getResources().getConfiguration(); final int width = configuration.screenWidthDp; final int height = configuration.screenHeightDp; final int orientation = configuration.orientation; if (width >= 960 && height >= 720 && orientation == Configuration.ORIENTATION_LANDSCAPE) { return 256; } else if (width >= 600 || (width >= 640 && height >= 480)) { return 192; }; return 160; } } }
core/java/com/android/internal/view/ActionBarPolicy.java +5 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,11 @@ public class ActionBarPolicy { // The embedded tabs policy changed in Jellybean; give older apps the old policy // so they get what they expect. return mContext.getResources().getBoolean(R.bool.action_bar_embed_tabs_pre_jb); final Configuration configuration = mContext.getResources().getConfiguration(); final int width = configuration.screenWidthDp; final int height = configuration.screenHeightDp; return configuration.orientation == Configuration.ORIENTATION_LANDSCAPE || width >= 480 || (width >= 640 && height >= 480); } public int getTabContainerHeight() { Loading
core/java/com/android/internal/view/menu/ActionMenuItemView.java +14 −4 Original line number Diff line number Diff line Loading @@ -72,8 +72,7 @@ public class ActionMenuItemView extends TextView public ActionMenuItemView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); final Resources res = context.getResources(); mAllowTextWithIcon = res.getBoolean( com.android.internal.R.bool.config_allowActionMenuItemTextWithIcon); mAllowTextWithIcon = shouldAllowTextWithIcon(); final TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.ActionMenuItemView, defStyleAttr, defStyleRes); mMinWidth = a.getDimensionPixelSize( Loading @@ -93,11 +92,22 @@ public class ActionMenuItemView extends TextView public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); mAllowTextWithIcon = getContext().getResources().getBoolean( com.android.internal.R.bool.config_allowActionMenuItemTextWithIcon); mAllowTextWithIcon = shouldAllowTextWithIcon(); updateTextButtonVisibility(); } /** * Whether action menu items should obey the "withText" showAsAction flag. This may be set to * false for situations where space is extremely limited. --> */ private boolean shouldAllowTextWithIcon() { final Configuration configuration = getContext().getResources().getConfiguration(); final int width = configuration.screenWidthDp; final int height = configuration.screenHeightDp; return width >= 480 || (width >= 640 && height >= 480) || configuration.orientation == Configuration.ORIENTATION_LANDSCAPE; } @Override public void setPadding(int l, int t, int r, int b) { mSavedPaddingLeft = l; Loading
core/res/res/layout/search_view.xml +1 −2 Original line number Diff line number Diff line Loading @@ -81,7 +81,6 @@ android:layout_height="36dip" android:layout_width="0dp" android:layout_weight="1" android:minWidth="@dimen/search_view_text_min_width" android:layout_gravity="bottom" android:paddingStart="@dimen/dropdownitem_text_padding_left" android:paddingEnd="@dimen/dropdownitem_text_padding_right" Loading
core/res/res/values-large/dimens.xml +0 −3 Original line number Diff line number Diff line Loading @@ -24,9 +24,6 @@ <!-- keyboardHeight = key_height*4 + key_bottom_gap*3 --> <dimen name="password_keyboard_height">48.0mm</dimen> <!-- Minimum width of the search view text entry area. --> <dimen name="search_view_text_min_width">192dip</dimen> <item type="dimen" name="dialog_min_width_major">55%</item> <item type="dimen" name="dialog_min_width_minor">80%</item> Loading