1
0
Fork 0

For #1421 - Fix Shortcut ToggleButton states

master
Emily Kager 2019-04-05 11:18:27 -07:00 committed by Jeff Boek
parent e7998b35e9
commit 9cb252da40
4 changed files with 26 additions and 14 deletions

View File

@ -10,7 +10,6 @@ import androidx.navigation.Navigation
import io.reactivex.Observer import io.reactivex.Observer
import kotlinx.android.synthetic.main.fragment_search.* import kotlinx.android.synthetic.main.fragment_search.*
import mozilla.components.browser.search.SearchEngine import mozilla.components.browser.search.SearchEngine
import org.jetbrains.anko.textColor
import org.mozilla.fenix.DefaultThemeManager import org.mozilla.fenix.DefaultThemeManager
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.search.SearchFragmentDirections import org.mozilla.fenix.search.SearchFragmentDirections
@ -66,11 +65,14 @@ class ShortcutEngineManager(
private fun showShortcutEnginePicker() { private fun showShortcutEnginePicker() {
with(context) { with(context) {
awesomeBarUIView.search_shortcuts_button.compoundDrawables[0].setTint(ContextCompat.getColor(this, awesomeBarUIView.search_shortcuts_button?.isChecked = true
DefaultThemeManager.resolveAttribute(R.attr.pillWrapperBackground, this)))
awesomeBarUIView.search_shortcuts_button.textColor = ContextCompat.getColor(this, awesomeBarUIView.search_shortcuts_button.compoundDrawables[0]?.setTint(
DefaultThemeManager.resolveAttribute(R.attr.pillWrapperBackground, this)) ContextCompat.getColor(
this,
DefaultThemeManager.resolveAttribute(R.attr.pillWrapperBackground, this)
)
)
awesomeBarUIView.view.removeAllProviders() awesomeBarUIView.view.removeAllProviders()
awesomeBarUIView.view.addProviders(shortcutsEnginePickerProvider!!) awesomeBarUIView.view.addProviders(shortcutsEnginePickerProvider!!)
@ -79,11 +81,13 @@ class ShortcutEngineManager(
private fun hideShortcutEnginePicker() { private fun hideShortcutEnginePicker() {
with(context) { with(context) {
awesomeBarUIView.search_shortcuts_button.compoundDrawables[0].setTint(ContextCompat.getColor(this, awesomeBarUIView.search_shortcuts_button?.isChecked = false
DefaultThemeManager.resolveAttribute(R.attr.searchShortcutsTextColor, this))) awesomeBarUIView.search_shortcuts_button.compoundDrawables[0]?.setTint(
ContextCompat.getColor(
awesomeBarUIView.search_shortcuts_button.textColor = ContextCompat.getColor(this, this,
DefaultThemeManager.resolveAttribute(R.attr.searchShortcutsTextColor, this)) DefaultThemeManager.resolveAttribute(R.attr.searchShortcutsTextColor, this)
)
)
awesomeBarUIView.view.removeProviders(shortcutsEnginePickerProvider!!) awesomeBarUIView.view.removeProviders(shortcutsEnginePickerProvider!!)
} }

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?attr/pillWrapperBackground" android:state_checked="true" />
<!-- Default State -->
<item android:color="?attr/searchShortcutsTextColor" />
</selector>

View File

@ -79,7 +79,6 @@
style="@style/search_pill" style="@style/search_pill"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:drawableStart="@drawable/ic_qr" android:drawableStart="@drawable/ic_qr"
android:textColor="?attr/searchShortcutsTextColor"
android:textOff="@string/search_scan_button" android:textOff="@string/search_scan_button"
android:textOn="@string/search_scan_button" /> android:textOn="@string/search_scan_button" />
@ -87,7 +86,6 @@
android:id="@+id/search_shortcuts_button" android:id="@+id/search_shortcuts_button"
style="@style/search_pill" style="@style/search_pill"
android:drawableStart="@drawable/ic_search" android:drawableStart="@drawable/ic_search"
android:textColor="?attr/searchShortcutsTextColor"
android:textOff="@string/search_shortcuts_button" android:textOff="@string/search_shortcuts_button"
android:textOn="@string/search_shortcuts_button" /> android:textOn="@string/search_shortcuts_button" />
</LinearLayout> </LinearLayout>

View File

@ -2,7 +2,7 @@
<!-- 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/. -->
<resources> <resources xmlns:tools="http://schemas.android.com/tools">
<style name="NormalThemeBase" parent="Theme.AppCompat.DayNight.NoActionBar"> <style name="NormalThemeBase" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="android:statusBarColor">@color/status_bar_color_normal_theme</item> <item name="android:statusBarColor">@color/status_bar_color_normal_theme</item>
@ -157,7 +157,8 @@
<item name="android:layout_height">32dp</item> <item name="android:layout_height">32dp</item>
<item name="android:textAllCaps">false</item> <item name="android:textAllCaps">false</item>
<item name="android:textSize">14sp</item> <item name="android:textSize">14sp</item>
<item name="android:textColor">@color/search_pill_primary</item> <item name="android:textColor">@color/toggle_text_color</item>
<item name="android:drawableTint" tools:targetApi="m">@color/toggle_text_color</item>
<item name="android:layout_gravity">center_vertical</item> <item name="android:layout_gravity">center_vertical</item>
<item name="android:gravity">center_vertical</item> <item name="android:gravity">center_vertical</item>
<item name="android:singleLine">true</item> <item name="android:singleLine">true</item>