Skip to content

Commit 88014b8

Browse files
committed
Merge branch 'release/4.0.6'
2 parents ff7eb65 + 6b13ecd commit 88014b8

File tree

10 files changed

+71
-21
lines changed

10 files changed

+71
-21
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ apply plugin: 'kotlin-kapt'
66
apply from: '../versioning.gradle'
77

88
ext {
9-
VERSION_NAME = "4.0.4"
9+
VERSION_NAME = "4.0.6"
1010
}
1111

1212
android {

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import android.arch.persistence.room.Room
2424
import android.net.Uri
2525
import android.support.test.InstrumentationRegistry
2626
import com.duckduckgo.app.autocomplete.api.AutoCompleteApi
27+
import com.duckduckgo.app.blockingObserve
2728
import com.duckduckgo.app.bookmarks.db.BookmarkEntity
2829
import com.duckduckgo.app.bookmarks.db.BookmarksDao
2930
import com.duckduckgo.app.bookmarks.ui.BookmarksActivity
@@ -45,7 +46,9 @@ import com.duckduckgo.app.settings.db.SettingsDataStore
4546
import com.duckduckgo.app.trackerdetection.model.TrackerNetwork
4647
import com.duckduckgo.app.trackerdetection.model.TrackerNetworks
4748
import com.duckduckgo.app.trackerdetection.model.TrackingEvent
49+
import com.nhaarman.mockito_kotlin.any
4850
import com.nhaarman.mockito_kotlin.doReturn
51+
import com.nhaarman.mockito_kotlin.mock
4952
import com.nhaarman.mockito_kotlin.whenever
5053
import org.junit.After
5154
import org.junit.Assert.*
@@ -100,11 +103,7 @@ class BrowserViewModelTest {
100103
private lateinit var db: AppDatabase
101104
private lateinit var appConfigurationDao: AppConfigurationDao
102105

103-
private val testOmnibarConverter: OmnibarEntryConverter = object : OmnibarEntryConverter {
104-
override fun convertUri(input: String): String = "duckduckgo.com"
105-
override fun isWebUrl(inputQuery: String): Boolean = true
106-
override fun convertQueryToUri(inputQuery: String): Uri = Uri.parse("duckduckgo.com")
107-
}
106+
private val mockOmnibarConverter: OmnibarEntryConverter = mock()
108107

109108
private lateinit var testee: BrowserViewModel
110109

@@ -118,7 +117,7 @@ class BrowserViewModelTest {
118117
appConfigurationDao = db.appConfigurationDao()
119118

120119
testee = BrowserViewModel(
121-
queryUrlConverter = testOmnibarConverter,
120+
queryUrlConverter = mockOmnibarConverter,
122121
duckDuckGoUrlDetector = DuckDuckGoUrlDetector(),
123122
termsOfServiceStore = mockTermsOfServiceStore,
124123
trackerNetworks = TrackerNetworks(),
@@ -132,6 +131,9 @@ class BrowserViewModelTest {
132131

133132
testee.url.observeForever(mockQueryObserver)
134133
testee.command.observeForever(mockNavigationObserver)
134+
135+
whenever(mockOmnibarConverter.convertQueryToUri(any())).thenReturn(Uri.parse("duckduckgo.com"))
136+
135137
}
136138

137139
@After
@@ -142,6 +144,13 @@ class BrowserViewModelTest {
142144
testee.command.removeObserver(mockNavigationObserver)
143145
}
144146

147+
@Test
148+
fun whenSubmittedQueryHasWhitespaceItIsTrimmed() {
149+
testee.onUserSubmittedQuery(" nytimes.com ")
150+
verify(mockOmnibarConverter).isWebUrl("nytimes.com")
151+
assertEquals("nytimes.com", testee.viewState.value!!.omnibarText)
152+
}
153+
145154
@Test
146155
fun whenBookmarksResultCodeIsOpenUrlThenNavigate() {
147156
testee.receivedBookmarksResult(BookmarksActivity.OPEN_URL_RESULT_CODE, "www.example.com")

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import com.duckduckgo.app.privacymonitor.renderer.icon
4747
import com.duckduckgo.app.privacymonitor.ui.PrivacyDashboardActivity
4848
import com.duckduckgo.app.settings.SettingsActivity
4949
import kotlinx.android.synthetic.main.activity_browser.*
50-
import kotlinx.android.synthetic.main.popup_window_brower_menu.view.*
50+
import kotlinx.android.synthetic.main.popup_window_browser_menu.view.*
5151
import org.jetbrains.anko.doAsync
5252
import org.jetbrains.anko.toast
5353
import org.jetbrains.anko.uiThread
@@ -279,7 +279,9 @@ class BrowserActivity : DuckDuckGoActivity() {
279279
}
280280

281281
webView.setOnTouchListener { _, _ ->
282-
focusDummy.requestFocus()
282+
if (omnibarTextInput.isFocused) {
283+
focusDummy.requestFocus()
284+
}
283285
false
284286
}
285287

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ class BrowserPopupMenu : PopupWindow {
3030
constructor(layoutInflater: LayoutInflater, view: View = BrowserPopupMenu.inflate(layoutInflater))
3131
: super(view, WRAP_CONTENT, WRAP_CONTENT, true) {
3232

33-
if (SDK_INT <= 21) {
34-
// popupwindow gets stuck on the screen on API 21 without a background color.
35-
// Adding it however garbles the elevation so we cannot have elevation here
33+
if (SDK_INT <= 22) {
34+
// popupwindow gets stuck on the screen on API 22 (tested on 23) without a background
35+
// color. Adding it however garbles the elevation so we cannot have elevation here.
3636
setBackgroundDrawable(ColorDrawable(Color.WHITE))
3737
} else {
3838
elevation = 6.toFloat()
@@ -54,7 +54,7 @@ class BrowserPopupMenu : PopupWindow {
5454
val margin = 30
5555

5656
fun inflate(layoutInflater: LayoutInflater): View {
57-
return layoutInflater.inflate(R.layout.popup_window_brower_menu, null)
57+
return layoutInflater.inflate(R.layout.popup_window_browser_menu, null)
5858
}
5959

6060
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,11 @@ class BrowserViewModel(
153153
if (input.isBlank()) {
154154
return
155155
}
156-
url.value = buildUrl(input)
156+
val trimmedInput = input.trim()
157+
url.value = buildUrl(trimmedInput)
157158
viewState.value = currentViewState().copy(
158159
showClearButton = false,
159-
omnibarText = input,
160+
omnibarText = trimmedInput,
160161
showAutoCompleteSuggestions = false,
161162
autoCompleteSearchResults = AutoCompleteResult("", emptyList()))
162163
}

app/src/main/java/com/duckduckgo/app/home/HomeActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import com.duckduckgo.app.global.view.FireDialog
3535
import com.duckduckgo.app.settings.SettingsActivity
3636
import kotlinx.android.synthetic.main.activity_home.*
3737
import kotlinx.android.synthetic.main.content_home.*
38-
import kotlinx.android.synthetic.main.popup_window_brower_menu.view.*
38+
import kotlinx.android.synthetic.main.popup_window_browser_menu.view.*
3939
import org.jetbrains.anko.toast
4040
import javax.inject.Inject
4141
import javax.inject.Provider
Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (c) 2018 DuckDuckGo
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
218
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3-
<item android:state_enabled="false" android:color="@color/paleOrange" />
4-
<item android:color="@color/white"/>
19+
<item android:color="@color/subtleGrey" android:state_enabled="false"/>
20+
<item android:color="@color/brownishGray"/>
521
</selector>

app/src/main/res/color/browser_menu_text.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (c) 2018 DuckDuckGo
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
218
<selector xmlns:android="http://schemas.android.com/apk/res/android">
319
<item android:state_enabled="false" android:color="@color/paleBrownishGray" />
420
<item android:color="@color/brownishGray"/>

app/src/main/res/layout/popup_window_brower_menu.xml renamed to app/src/main/res/layout/popup_window_browser_menu.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
android:id="@+id/header"
2525
android:layout_width="match_parent"
2626
android:layout_height="50dp"
27-
android:background="@color/colorAccent"
27+
android:background="@color/white"
2828
android:gravity="center"
2929
android:orientation="horizontal">
3030

@@ -59,13 +59,19 @@
5959
android:src="@drawable/ic_bookmark_24px" />
6060

6161
</LinearLayout>
62+
63+
<FrameLayout
64+
android:layout_width="match_parent"
65+
android:layout_height="1dp"
66+
android:background="@color/white_two"
67+
app:layout_constraintBottom_toBottomOf="@+id/header" />
6268

6369
<LinearLayout
6470
android:layout_width="wrap_content"
6571
android:layout_height="wrap_content"
6672
android:orientation="vertical"
6773
android:paddingBottom="20dp"
68-
android:paddingTop="20dp"
74+
android:paddingTop="13dp"
6975
app:layout_constraintTop_toBottomOf="@id/header">
7076

7177
<TextView

app/src/main/res/values/colors.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
<color name="subtleGrey">#f0f0f0</color>
2222
<color name="subtleGreyTwo">#D8D8D8</color>
2323

24-
<color name="paleOrange">#DA8E76</color>
2524
<color name="orange">#de5833</color>
2625
<color name="brickOrange">#d03a10</color>
2726

@@ -32,5 +31,6 @@
3231
<color name="muddyGreen">#58732e</color>
3332
<color name="midGreen">#3fa140</color>
3433

34+
<color name="white_two">#e4e4e4</color>
3535

3636
</resources>

0 commit comments

Comments
 (0)