8000 New header design: icons, app colors and edit text mode · WindowxDeveloper/Android@26268cc · GitHub
[go: up one dir, main page]

Skip to content

Commit 26268cc

Browse files
authored
New header design: icons, app colors and edit text mode
• Move privacy grade to the left and tabs to the main toolbar • New icons, colors and edit text behavior • Update fire text in tab switcher to use new icon • Remove unused resources
1 parent f2ea5f5 commit 26268cc

38 files changed

+242
-155
lines changed

app/lint.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<lint>
33
<issue id="IconColors">
44
<ignore path="src/main/res/drawable*/privacygrade_icon_*" />
5-
<ignore path="src/main/res/drawable*/icon_fire*" />
65
</issue>
76
<issue id="IconExpectedSize">
87
<ignore path="src/main/res/drawable-*/privacygrade_icon_*" />

app/src/androidTest/java/com/duckduckgo/app/browser/BrowserTabViewModelTest.kt

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,43 @@ class BrowserTabViewModelTest {
390390
}
391391

392392
@Test
393-
fun whenOmnibarInputHasFocusThenFireButtonIsShown() {
393+
fun whenOmnibarInputHasFocusThenFireButtonIsHidden() {
394394
testee.onOmnibarInputStateChanged("", true)
395-
assertTrue(testee.viewState.value!!.showFireButton)
395+
assertFalse(testee.viewState.value!!.showFireButton)
396+
}
397+
398+
@Test
399+
fun whenInitialisedThenTabsButtonIsShown() {
400+
assertTrue(testee.viewState.value!!.showTabsButton)
401+
}
402+
403+
@Test
404+
fun whenOmnibarInputDoesNotHaveFocusThenTabsButtonIsShown() {
405+
testee.onOmnibarInputStateChanged("", false)
406+
assertTrue(testee.viewState.value!!.showTabsButton)
407+
}
408+
409+
@Test
410+
fun whenOmnibarInputHasFocusThenTabsButtonIsNotShown() {
411+
testee.onOmnibarInputStateChanged("", true)
412+
assertFalse(testee.viewState.value!!.showTabsButton)
413+
}
414+
415+
@Test
416+
fun whenInitialisedThenMenuButtonIsShown() {
417+
assertTrue(testee.viewState.value!!.showMenuButton)
418+
}
419+
420+
@Test
421+
fun whenOmnibarInputDoesNotHaveFocusThenMenuButtonIsShown() {
422+
testee.onOmnibarInputStateChanged("", false)
423+
assertTrue(testee.viewState.value!!.showMenuButton)
424+
}
425+
426+
@Test
427+
fun whenOmnibarInputHasFocusThenMenuButtonIsNotShown() {
428+
testee.onOmnibarInputStateChanged("", true)
429+
assertFalse(testee.viewState.value!!.showMenuButton)
396430
}
397431

398432
@Test

app/src/main/java/com/duckduckgo/app/browser/BrowserTabFragment.kt

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ import android.webkit.WebView
4747
import android.webkit.WebView.FindListener
4848
import android.widget.EditText
4949
import android.widget.TextView
50+
import androidx.view.isVisible
5051
import androidx.view.postDelayed
51-
import androidx.view.updatePaddingRelative
5252
import com.duckduckgo.app.bookmarks.ui.SaveBookmarkDialogFragment
5353
import com.duckduckgo.app.browser.BrowserTabViewModel.*
5454
import com.duckduckgo.app.browser.autoComplete.BrowserAutoCompleteSuggestionsAdapter
@@ -64,6 +64,7 @@ import com.duckduckgo.app.privacy.model.PrivacyGrade
6464
import com.duckduckgo.app.privacy.renderer.icon
6565
import dagger.android.support.AndroidSupportInjection
6666
import kotlinx.android.synthetic.main.fragment_browser_tab.*
67+
import kotlinx.android.synthetic.main.fragment_browser_tab.view.*
6768
import kotlinx.android.synthetic.main.include_find_in_page.*
6869
import kotlinx.android.synthetic.main.popup_window_browser_menu.view.*
6970
import org.jetbrains.anko.longToast
@@ -117,12 +118,16 @@ class BrowserTabFragment : Fragment(), FindListener {
117118
private val browserActivity
118119
get() = activity as? BrowserActivity
119120

120-
private val privacyGradeMenu: MenuItem?
121-
get() = toolbar.menu.findItem(R.id.privacyDashboard)
121+
private val tabsButton: MenuItem?
122+
get() = toolbar.menu.findItem(R.id.tabs)
122123

123-
private val fireMenu: MenuItem?
124+
private val fireMenuButton: MenuItem?
124125
get() = toolbar.menu.findItem(R.id.fire)
125126

127+
private val menuButton: MenuItem?
128+
get() = toolbar.menu.findItem(R.id.browserPopup)
129+
130+
126131
private var webView: WebView? = null
127132

128133
private val findInPageTextWatcher = object : TextChangedWatcher() {
@@ -181,7 +186,6 @@ class BrowserTabFragment : Fragment(), FindListener {
181186
onMenuItemClicked(view.forwardPopupMenuItem) { webView?.goForward() }
182187
onMenuItemClicked(view.backPopupMenuItem) { webView?.goBack() }
183188
onMenuItemClicked(view.refreshPopupMenuItem) { webView?.reload() }
184-
onMenuItemClicked(view.tabsMenuItem) { browserActivity?.launchTabSwitcher() }
185189
onMenuItemClicked(view.newTabPopupMenuItem) { browserActivity?.launchNewTab() }
186190
onMenuItemClicked(view.bookmarksPopupMenuItem) { browserActivity?.launchBookmarks() }
187191
onMenuItemClicked(view.addBookmarksPopupMenuItem) { addBookmark() }
@@ -338,15 +342,14 @@ class BrowserTabFragment : Fragment(), FindListener {
338342
}
339343

340344
pageLoadingIndicator.progress = viewState.progress
341-
342-
when (viewState.showClearButton) {
343-
true -> showClearButton()
344-
false -> hideClearButton()
345-
}
346-
347345
renderToolbarButtons(viewState)
348346
renderPopupMenu(viewState)
349347

348+
when (viewState.isEditing) {
349+
true -> omniBarContainer.setBackgroundResource(R.drawable.omnibar_editing_background)
350+
false -> omniBarContainer.background = null
351+
}
352+
350353
when (viewState.autoComplete.showSuggestions) {
351354
false -> autoCompleteSuggestionsList.gone()
352355
true -> {
@@ -367,8 +370,11 @@ class BrowserTabFragment : Fragment(), FindListener {
367370
}
368371

369372
private fun renderToolbarButtons(viewState: ViewState) {
370-
fireMenu?.isVisible = viewState.showFireButton
371-
privacyGradeMenu?.isVisible = viewState.showPrivacyGrade
373+
privacyGradeButton?.isVisible = viewState.showPrivacyGrade
374+
clearTextButton?.isVisible = viewState.showClearButton
375+
tabsButton?.isVisible = viewState.showTabsButton
376+
fireMenuButton?.isVisible = viewState.showFireButton
377+
menuButton?.isVisible = viewState.showMenuButton
372378
}
373379

374380
private fun renderPopupMenu(viewState: ViewState) {
@@ -428,20 +434,6 @@ class BrowserTabFragment : Fragment(), FindListener {
428434
activity?.toggleFullScreen()
429435
}
430436

431-
private fun showClearButton() {
432-
omnibarTextInput.post {
433-
clearOmnibarInputButton?.show()
434-
omnibarTextInput?.updatePaddingRelative(end = 40.toPx())
435-
}
436-
}
437-
438-
private fun hideClearButton() {
439-
omnibarTextInput.post {
440-
clearOmnibarInputButton?.hide()
441-
omnibarTextInput?.updatePaddingRelative(end = 10.toPx())
442-
}
443-
}
444-
445437
private fun shouldUpdateOmnibarTextInput(viewState: ViewState, omnibarInput: String?) =
446438
!viewState.isEditing && omnibarTextInput.isDifferent(omnibarInput)
447439

@@ -450,8 +442,8 @@ class BrowserTabFragment : Fragment(), FindListener {
450442

451443
toolbar.setOnMenuItemClickListener {
452444
when (it.itemId) {
453-
R.id.privacyDashboard -> {
454-
browserActivity?.launchPrivacyDashboard()
445+
R.id.tabs -> {
446+
browserActivity?.launchTabSwitcher()
455447
return@setOnMenuItemClickListener true
456448
}
457449
R.id.fire -> {
@@ -467,13 +459,18 @@ class BrowserTabFragment : Fragment(), FindListener {
467459
}
468460
}
469461

462+
toolbar.privacyGradeButton.setOnClickListener {
463+
browserActivity?.launchPrivacyDashboard()
464+
}
465+
470466
viewModel.viewState.value?.let {
471467
renderToolbarButtons(it)
472468
}
473469

474470
viewModel.privacyGrade.observe(this, Observer<PrivacyGrade> {
475471
it?.let {
476-
privacyGradeMenu?.icon = context?.getDrawable(it.icon())
472+
val drawable = context?.getDrawable(it.icon()) ?: return@let
473+
privacyGradeButton?.setImageDrawable(drawable)
477474
}
478475
})
479476
}
@@ -514,7 +511,7 @@ class BrowserTabFragment : Fragment(), FindListener {
514511
false
515512
})
516513

517-
clearOmnibarInputButton.setOnClickListener { omnibarTextInput.setText("") }
514+
clearTextButton.setOnClickListener { omnibarTextInput.setText("") }
518515
}
519516

520517
private fun configureKeyboardAwareLogoAnimation() {

app/src/main/java/com/duckduckgo/app/browser/BrowserTabViewModel.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ class BrowserTabViewModel(
8080
val omnibarText: String = "",
8181
val isEditing: Boolean = false,
8282
val browserShowing: Boolean = false,
83-
val showClearButton: Boolean = false,
8483
val showPrivacyGrade: Boolean = false,
84+
val showClearButton: Boolean = false,
85+
val showTabsButton: Boolean = true,
8586
val showFireButton: Boolean = true,
87+
val showMenuButton: Boolean = true,
8688
val canAddBookmarks: Boolean = false,
8789
val isFullScreen: Boolean = false,
8890
val autoComplete: AutoCompleteViewState = AutoCompleteViewState(),
@@ -336,8 +338,11 @@ class BrowserTabViewModel(
336338

337339
viewState.value = currentViewState().copy(
338340
isEditing = hasFocus,
341+
showPrivacyGrade = appConfigurationDownloaded && currentViewState.browserShowing,
342+
showTabsButton = !hasFocus,
343+
showFireButton = !hasFocus,
344+
showMenuButton = !hasFocus,
339345
showClearButton = showClearButton,
340-
showPrivacyGrade = appConfigurationDownloaded && !hasFocus && currentViewState.browserShowing,
341346
autoComplete = AutoCompleteViewState(showAutoCompleteSuggestions, autoCompleteSearchResults)
342347
)
343348

app/src/main/java/com/duckduckgo/app/tabs/ui/TabSwitcherActivity.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class TabSwitcherActivity : DuckDuckGoActivity(), TabSwitcherAdapter.TabSwitched
5151
super.onCreate(savedInstanceState)
5252
setContentView(R.layout.activity_tab_switcher)
5353
configureToolbar()
54-
configureFireText()
5554
configureRecycler()
5655
configureObservers()
5756
}
@@ -61,15 +60,6 @@ class TabSwitcherActivity : DuckDuckGoActivity(), TabSwitcherAdapter.TabSwitched
6160
supportActionBar?.setDisplayHomeAsUpEnabled(true)
6261
}
6362

64-
/**
65-
* We set this manually as using the unicode fire char to strings.xml crashes
66-
* on Android 5.0
67-
*/
68-
private fun configureFireText() {
69-
val fireIcon = String(Character.toChars(0x1F525))
70-
fireText.text = getString(R.string.tapFireToForget, fireIcon)
71-
}
72-
7363
private fun configureRecycler() {
7464
tabsRecycler.layoutManager = LinearLayoutManager(this)
7565
tabsRecycler.adapter = tabsAdapter
-2 KB
Binary file not shown.
-1.2 KB
Binary file not shown.
-2.87 KB
Binary file not shown.
-4.66 KB
Binary file not shown.
-6.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)
0