Skip to content

Commit

Permalink
Merge branch 'release/4.0.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
subsymbolic committed Jan 22, 2018
2 parents ff7eb65 + 6b13ecd commit 88014b8
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 21 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ apply plugin: 'kotlin-kapt'
apply from: '../versioning.gradle'

ext {
VERSION_NAME = "4.0.4"
VERSION_NAME = "4.0.6"
}

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import android.arch.persistence.room.Room
import android.net.Uri
import android.support.test.InstrumentationRegistry
import com.duckduckgo.app.autocomplete.api.AutoCompleteApi
import com.duckduckgo.app.blockingObserve
import com.duckduckgo.app.bookmarks.db.BookmarkEntity
import com.duckduckgo.app.bookmarks.db.BookmarksDao
import com.duckduckgo.app.bookmarks.ui.BookmarksActivity
Expand All @@ -45,7 +46,9 @@ import com.duckduckgo.app.settings.db.SettingsDataStore
import com.duckduckgo.app.trackerdetection.model.TrackerNetwork
import com.duckduckgo.app.trackerdetection.model.TrackerNetworks
import com.duckduckgo.app.trackerdetection.model.TrackingEvent
import com.nhaarman.mockito_kotlin.any
import com.nhaarman.mockito_kotlin.doReturn
import com.nhaarman.mockito_kotlin.mock
import com.nhaarman.mockito_kotlin.whenever
import org.junit.After
import org.junit.Assert.*
Expand Down Expand Up @@ -100,11 +103,7 @@ class BrowserViewModelTest {
private lateinit var db: AppDatabase
private lateinit var appConfigurationDao: AppConfigurationDao

private val testOmnibarConverter: OmnibarEntryConverter = object : OmnibarEntryConverter {
override fun convertUri(input: String): String = "duckduckgo.com"
override fun isWebUrl(inputQuery: String): Boolean = true
override fun convertQueryToUri(inputQuery: String): Uri = Uri.parse("duckduckgo.com")
}
private val mockOmnibarConverter: OmnibarEntryConverter = mock()

private lateinit var testee: BrowserViewModel

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

testee = BrowserViewModel(
queryUrlConverter = testOmnibarConverter,
queryUrlConverter = mockOmnibarConverter,
duckDuckGoUrlDetector = DuckDuckGoUrlDetector(),
termsOfServiceStore = mockTermsOfServiceStore,
trackerNetworks = TrackerNetworks(),
Expand All @@ -132,6 +131,9 @@ class BrowserViewModelTest {

testee.url.observeForever(mockQueryObserver)
testee.command.observeForever(mockNavigationObserver)

whenever(mockOmnibarConverter.convertQueryToUri(any())).thenReturn(Uri.parse("duckduckgo.com"))

}

@After
Expand All @@ -142,6 +144,13 @@ class BrowserViewModelTest {
testee.command.removeObserver(mockNavigationObserver)
}

@Test
fun whenSubmittedQueryHasWhitespaceItIsTrimmed() {
testee.onUserSubmittedQuery(" nytimes.com ")
verify(mockOmnibarConverter).isWebUrl("nytimes.com")
assertEquals("nytimes.com", testee.viewState.value!!.omnibarText)
}

@Test
fun whenBookmarksResultCodeIsOpenUrlThenNavigate() {
testee.receivedBookmarksResult(BookmarksActivity.OPEN_URL_RESULT_CODE, "www.example.com")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import com.duckduckgo.app.privacymonitor.renderer.icon
import com.duckduckgo.app.privacymonitor.ui.PrivacyDashboardActivity
import com.duckduckgo.app.settings.SettingsActivity
import kotlinx.android.synthetic.main.activity_browser.*
import kotlinx.android.synthetic.main.popup_window_brower_menu.view.*
import kotlinx.android.synthetic.main.popup_window_browser_menu.view.*
import org.jetbrains.anko.doAsync
import org.jetbrains.anko.toast
import org.jetbrains.anko.uiThread
Expand Down Expand Up @@ -279,7 +279,9 @@ class BrowserActivity : DuckDuckGoActivity() {
}

webView.setOnTouchListener { _, _ ->
focusDummy.requestFocus()
if (omnibarTextInput.isFocused) {
focusDummy.requestFocus()
}
false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class BrowserPopupMenu : PopupWindow {
constructor(layoutInflater: LayoutInflater, view: View = BrowserPopupMenu.inflate(layoutInflater))
: super(view, WRAP_CONTENT, WRAP_CONTENT, true) {

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

fun inflate(layoutInflater: LayoutInflater): View {
return layoutInflater.inflate(R.layout.popup_window_brower_menu, null)
return layoutInflater.inflate(R.layout.popup_window_browser_menu, null)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,11 @@ class BrowserViewModel(
if (input.isBlank()) {
return
}
url.value = buildUrl(input)
val trimmedInput = input.trim()
url.value = buildUrl(trimmedInput)
viewState.value = currentViewState().copy(
showClearButton = false,
omnibarText = input,
omnibarText = trimmedInput,
showAutoCompleteSuggestions = false,
autoCompleteSearchResults = AutoCompleteResult("", emptyList()))
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/duckduckgo/app/home/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import com.duckduckgo.app.global.view.FireDialog
import com.duckduckgo.app.settings.SettingsActivity
import kotlinx.android.synthetic.main.activity_home.*
import kotlinx.android.synthetic.main.content_home.*
import kotlinx.android.synthetic.main.popup_window_brower_menu.view.*
import kotlinx.android.synthetic.main.popup_window_browser_menu.view.*
import org.jetbrains.anko.toast
import javax.inject.Inject
import javax.inject.Provider
Expand Down
20 changes: 18 additions & 2 deletions app/src/main/res/color/browser_menu_icon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2018 DuckDuckGo
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="@color/paleOrange" />
<item android:color="@color/white"/>
<item android:color="@color/subtleGrey" android:state_enabled="false"/>
<item android:color="@color/brownishGray"/>
</selector>
16 changes: 16 additions & 0 deletions app/src/main/res/color/browser_menu_text.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2018 DuckDuckGo
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="@color/paleBrownishGray" />
<item android:color="@color/brownishGray"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/colorAccent"
android:background="@color/white"
android:gravity="center"
android:orientation="horizontal">

Expand Down Expand Up @@ -59,13 +59,19 @@
android:src="@drawable/ic_bookmark_24px" />

</LinearLayout>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/white_two"
app:layout_constraintBottom_toBottomOf="@+id/header" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="20dp"
android:paddingTop="20dp"
android:paddingTop="13dp"
app:layout_constraintTop_toBottomOf="@id/header">

<TextView
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<color name="subtleGrey">#f0f0f0</color>
<color name="subtleGreyTwo">#D8D8D8</color>

<color name="paleOrange">#DA8E76</color>
<color name="orange">#de5833</color>
<color name="brickOrange">#d03a10</color>

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

<color name="white_two">#e4e4e4</color>

</resources>

0 comments on commit 88014b8

Please sign in to comment.