1
0
Fork 0

For #12804: Set min height for search engine radio button

master
Hakkı Kaan Çalışkan 2020-07-21 23:55:30 +03:00 committed by Emily Kager
parent 46511d6f8e
commit b3b7566fcf
3 changed files with 13 additions and 22 deletions

View File

@ -93,7 +93,7 @@ class AddSearchEngineFragment : Fragment(), CompoundButton.OnCheckedChangeListen
availableEngines.forEachIndexed(setupSearchEngineItem) availableEngines.forEachIndexed(setupSearchEngineItem)
val engineItem = makeCustomButton(layoutInflater, res = resources) val engineItem = makeCustomButton(layoutInflater)
engineItem.id = CUSTOM_INDEX engineItem.id = CUSTOM_INDEX
engineItem.radio_button.isChecked = selectedIndex == CUSTOM_INDEX engineItem.radio_button.isChecked = selectedIndex == CUSTOM_INDEX
engineViews.add(engineItem) engineViews.add(engineItem)
@ -249,12 +249,11 @@ class AddSearchEngineFragment : Fragment(), CompoundButton.OnCheckedChangeListen
toggleCustomForm(selectedIndex == -1) toggleCustomForm(selectedIndex == -1)
} }
private fun makeCustomButton(layoutInflater: LayoutInflater, res: Resources): View { private fun makeCustomButton(layoutInflater: LayoutInflater): View {
val wrapper = layoutInflater val wrapper = layoutInflater
.inflate(R.layout.custom_search_engine_radio_button, null) as ConstraintLayout .inflate(R.layout.custom_search_engine_radio_button, null) as ConstraintLayout
wrapper.setOnClickListener { wrapper.radio_button.isChecked = true } wrapper.setOnClickListener { wrapper.radio_button.isChecked = true }
wrapper.radio_button.setOnCheckedChangeListener(this) wrapper.radio_button.setOnCheckedChangeListener(this)
wrapper.minHeight = res.getDimensionPixelSize(R.dimen.radio_button_preference_height)
return wrapper return wrapper
} }
@ -280,7 +279,6 @@ class AddSearchEngineFragment : Fragment(), CompoundButton.OnCheckedChangeListen
engineIcon.setBounds(0, 0, iconSize, iconSize) engineIcon.setBounds(0, 0, iconSize, iconSize)
wrapper.engine_icon.setImageDrawable(engineIcon) wrapper.engine_icon.setImageDrawable(engineIcon)
wrapper.overflow_menu.visibility = View.GONE wrapper.overflow_menu.visibility = View.GONE
wrapper.minHeight = res.getDimensionPixelSize(R.dimen.radio_button_preference_height)
return wrapper return wrapper
} }

View File

@ -7,6 +7,7 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="@dimen/search_engine_radio_button_height" android:layout_height="@dimen/search_engine_radio_button_height"
android:minHeight="@dimen/radio_button_preference_height"
android:layout_width="match_parent" android:layout_width="match_parent"
android:background="?android:selectableItemBackground" android:background="?android:selectableItemBackground"
android:clickable="true" android:clickable="true"

View File

@ -2,12 +2,12 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public <!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="@dimen/search_engine_radio_button_height" android:layout_height="@dimen/search_engine_radio_button_height"
android:layout_width="match_parent" android:layout_width="match_parent"
android:minHeight="@dimen/radio_button_preference_height"
android:background="?android:selectableItemBackground" android:background="?android:selectableItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true"> android:focusable="true">
@ -18,18 +18,14 @@
android:importantForAccessibility="no" android:importantForAccessibility="no"
android:textAppearance="?android:attr/textAppearanceListItem" android:textAppearance="?android:attr/textAppearanceListItem"
android:layout_marginStart="@dimen/search_bar_search_engine_icon_padding" android:layout_marginStart="@dimen/search_bar_search_engine_icon_padding"
app:layout_constraintStart_toStartOf="parent" android:layout_gravity="center" />
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
<ImageView <ImageView
android:id="@+id/engine_icon" android:id="@+id/engine_icon"
android:importantForAccessibility="no" android:importantForAccessibility="no"
android:layout_width="@dimen/search_engine_engine_icon_height" android:layout_width="@dimen/search_engine_engine_icon_height"
android:layout_height="@dimen/search_engine_engine_icon_height" android:layout_height="@dimen/search_engine_engine_icon_height"
android:layout_marginStart="@dimen/search_bar_search_icon_margin" android:layout_marginStart="@dimen/search_bar_search_icon_margin"
app:layout_constraintStart_toEndOf="@id/radio_button" android:layout_gravity="center" />
app:layout_constraintTop_toTopOf="@id/radio_button"
app:layout_constraintBottom_toBottomOf="@id/radio_button" />
<TextView <TextView
android:id="@+id/engine_text" android:id="@+id/engine_text"
android:textColor="?primaryText" android:textColor="?primaryText"
@ -37,19 +33,15 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/radio_button_padding_horizontal" android:layout_marginStart="@dimen/radio_button_padding_horizontal"
android:layout_marginEnd="@dimen/radio_button_padding_horizontal" android:layout_marginEnd="@dimen/radio_button_padding_horizontal"
android:textAlignment="viewStart"
android:textSize="16sp" android:textSize="16sp"
app:layout_constraintStart_toEndOf="@id/engine_icon" tools:text="Google"
app:layout_constraintTop_toTopOf="@id/engine_icon" android:layout_weight="1"
app:layout_constraintEnd_toEndOf="parent" /> android:layout_gravity="center" />
<ImageButton <ImageButton
android:id="@+id/overflow_menu" android:id="@+id/overflow_menu"
android:layout_width="@dimen/glyph_button_width" android:layout_width="@dimen/glyph_button_width"
android:layout_height="@dimen/glyph_button_height" android:layout_height="@dimen/glyph_button_height"
android:background="?android:attr/selectableItemBackgroundBorderless" android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/content_description_menu" android:contentDescription="@string/content_description_menu"
app:srcCompat="@drawable/ic_menu" app:srcCompat="@drawable/ic_menu" />
app:layout_constraintBottom_toBottomOf="parent" </LinearLayout>
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>