Skip to content

Commit 49b4f44

Browse files
committed
Merge branch 'release/5.2.0'
2 parents 1b8e5bf + 61dcf7a commit 49b4f44

File tree

18 files changed

+212
-27
lines changed

18 files changed

+212
-27
lines changed

CONTRIBUTING.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Contributing to DuckDuckGo
2+
3+
Thank you for taking the time to contribute to DuckDuckGo! :sparkles:
4+
5+
We are pleased to open up the project to you - our community. How can you contribute?
6+
7+
## Share feedback and bug reports
8+
See [README.md](README.md)
9+
10+
## Contribute Code
11+
12+
We have labeled tasks you can help with as [help wanted](https://github.com/duckduckgo/Android/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22).
13+
As we are still opening up our repo, we cannot yet accept PRs outside this list. If you have a great idea
14+
you really want to implement, start by logging an issue for us and mention that you are interested in helping.
15+
If it fits with our product direction and is a good candidate for community development we may be able to bend
16+
the rules and work with you to develop it.
17+
18+
## Style Guide
19+
20+
We care about clean code. Refer to our [style guide](styleguide/STYLEGUIDE.md).
21+
22+
23+
## Commit Messages
24+
25+
See Chris Beams' guide to writing good commit messages https://chris.beams.io/posts/git-commit/

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
# DuckDuckGo Android
22

3-
Welcome to our android application. While it is still too early to accept contributions, we are excited to engage the community in development and will open up this project to contributions in the future.
3+
Welcome to our android application. We are excited to engage the community in development, see [CONTRIBUTING.md](CONTRIBUTING.md).
44

5-
If you are trying to contribute in other ways, that happens over at [DuckDuckHack](http://duckduckhack.com) or on [GitHub](http://github.com/duckduckgo).
65

76
## Discuss
87

9-
Contact us at [email protected] if you want to get more involved, have questions or want to chat.
8+
Contact us at [email protected] if you have questions, feedback or want to chat.
9+
10+
## Reporting Bugs
11+
12+
We want our app to be as stable as possible thus your bug reports are immensely valuable. When reporting bugs let us know the:
13+
* App version
14+
* Device make and model
15+
* Android version
16+
* Steps to reproduce the bug
17+
* Expected behavior
18+
* Actual behavior
19+
20+
Email bug reports to [email protected]
21+
1022

1123
## License
12-
DuckDuckGo android is distributed under the Apache 2.0 [license](https://github.com/duckduckgo/ios/blob/master/LICENSE).
24+
DuckDuckGo android is distributed under the Apache 2.0 [license](LICENSE).

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 = "5.1.0"
9+
VERSION_NAME = "5.2.0"
1010
USE_ORCHESTRATOR = project.hasProperty('orchestrator') ? project.property('orchestrator') : false
1111
}
1212

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.duckduckgo.app.browser
1818

19+
import android.support.test.InstrumentationRegistry
1920
import android.webkit.CookieManager
2021
import android.webkit.ValueCallback
2122
import android.webkit.WebStorage
@@ -36,10 +37,9 @@ class WebDataManagerTest {
3637

3738
private val testee = WebDataManager(host)
3839

39-
4040
@Test
4141
fun whenDataClearedThenCacheHistoryAndStorageDataCleared() {
42-
testee.clearData(mockWebView, mockStorage)
42+
testee.clearData(mockWebView, mockStorage, InstrumentationRegistry.getTargetContext())
4343
verify(mockWebView).clearHistory()
4444
verify(mockWebView).clearCache(true)
4545
verify(mockStorage).deleteAllData()

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ import com.duckduckgo.app.global.ViewModelFactory
6262
import com.duckduckgo.app.global.view.*
6363
import com.duckduckgo.app.privacy.model.PrivacyGrade
6464
import com.duckduckgo.app.privacy.renderer.icon
65+
import com.duckduckgo.app.tabs.model.TabEntity
66+
import com.duckduckgo.app.tabs.ui.TabIconRenderer
6567
import dagger.android.support.AndroidSupportInjection
6668
import kotlinx.android.synthetic.main.fragment_browser_tab.*
6769
import kotlinx.android.synthetic.main.fragment_browser_tab.view.*
@@ -103,7 +105,6 @@ class BrowserTabFragment : Fragment(), FindListener {
103105

104106
private lateinit var autoCompleteSuggestionsAdapter: BrowserAutoCompleteSuggestionsAdapter
105107

106-
107108
// Used to represent a file to download, but may first require permission
108109
private var pendingFileDownload: PendingFileDownload? = null
109110

@@ -165,7 +166,10 @@ class BrowserTabFragment : Fragment(), FindListener {
165166
configureFindInPage()
166167
configureAutoComplete()
167168
configureKeyboardAwareLogoAnimation()
168-
consumeSharedText()
169+
170+
if (savedInstanceState == null) {
171+
consumeSharedText()
172+
}
169173
}
170174

171175
private fun consumeSharedText() {
@@ -206,6 +210,10 @@ class BrowserTabFragment : Fragment(), FindListener {
206210
it?.let { render(it) }
207211
})
208212

213+
viewModel.tabs.observe(this, Observer<List<TabEntity>> {
214+
it?.let { renderTabIcon(it)}
215+
})
216+
209217
viewModel.url.observe(this, Observer {
210218
it?.let { navigate(it) }
211219
})
@@ -394,6 +402,12 @@ class BrowserTabFragment : Fragment(), FindListener {
394402
popupMenu.contentView.findInPageMenuItem?.isEnabled = viewState.canFindInPage
395403
}
396404

405+
private fun renderTabIcon(tabs: List<TabEntity>) {
406+
context?.let {
407+
tabsButton?.icon = TabIconRenderer.icon(it, tabs.count())
408+
}
409+
}
410+
397411
private fun hideFindInPage() {
398412
if (findInPageContainer.visibility != View.GONE) {
399413
focusDummy.requestFocus()
@@ -793,4 +807,6 @@ class BrowserTabFragment : Fragment(), FindListener {
793807
return fragment
794808
}
795809
}
810+
811+
796812
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.duckduckgo.app.browser
1818

19+
import android.arch.lifecycle.LiveData
1920
import android.arch.lifecycle.MutableLiveData
2021
import android.arch.lifecycle.Observer
2122
import android.arch.lifecycle.ViewModel
@@ -52,6 +53,7 @@ import com.duckduckgo.app.privacy.model.PrivacyGrade
5253
import com.duckduckgo.app.privacy.model.improvedGrade
5354
import com.duckduckgo.app.settings.db.SettingsDataStore
5455
import com.duckduckgo.app.statistics.api.StatisticsUpdater
56+
import com.duckduckgo.app.tabs.model.TabEntity
5557
import com.duckduckgo.app.tabs.model.TabRepository
5658
import com.duckduckgo.app.trackerdetection.model.TrackingEvent
5759
import com.jakewharton.rxrelay2.PublishRelay
@@ -113,6 +115,7 @@ class BrowserTabViewModel(
113115
}
114116

115117
val viewState: MutableLiveData<ViewState> = MutableLiveData()
118+
val tabs: LiveData<List<TabEntity>> = tabRepository.liveTabs
116119
val privacyGrade: MutableLiveData<PrivacyGrade> = MutableLiveData()
117120
val url: SingleLiveEvent<String> = SingleLiveEvent()
118121
val command: SingleLiveEvent<Command> = SingleLiveEvent()

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,4 @@ class BrowserViewModel(private val tabRepository: TabRepository) : ViewModel() {
7979
fun onClearComplete() {
8080
command.value = DisplayMessage(R.string.fireDataCleared)
8181
}
82-
}
83-
84-
85-
82+
}

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,32 @@
1616

1717
package com.duckduckgo.app.browser
1818

19+
import android.content.Context
20+
import android.os.Build
1921
import android.webkit.CookieManager
2022
import android.webkit.WebStorage
2123
import android.webkit.WebView
24+
import android.webkit.WebViewDatabase
2225

2326
class WebDataManager(private val host: String) {
2427

25-
fun clearData(webView: WebView, webStorage: WebStorage) {
28+
fun clearData(webView: WebView, webStorage: WebStorage, context: Context) {
2629
webView.clearCache(true)
2730
webView.clearHistory()
2831
webStorage.deleteAllData()
32+
webView.clearFormData()
33+
34+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
35+
clearFormData(WebViewDatabase.getInstance(context))
36+
}
37+
}
38+
39+
/**
40+
* Deprecated and not needed on Oreo or later
41+
*/
42+
@Suppress("DEPRECATION")
43+
private fun clearFormData(webViewDatabase: WebViewDatabase) {
44+
webViewDatabase.clearFormData()
2945
}
3046

3147
fun clearExternalCookies(cookieManager: CookieManager, clearAllCallback: (() -> Unit)) {

app/src/main/java/com/duckduckgo/app/global/job/JobBuilder.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.duckduckgo.app.global.job
1818

1919
import android.app.job.JobInfo
20+
import android.app.job.JobInfo.BACKOFF_POLICY_EXPONENTIAL
2021
import android.content.ComponentName
2122
import android.content.Context
2223
import com.duckduckgo.app.job.AppConfigurationJobService
@@ -32,6 +33,7 @@ class JobBuilder @Inject constructor(){
3233
return JobInfo.Builder(APP_CONFIGURATION_JOB_ID, ComponentName(context, AppConfigurationJobService::class.java))
3334
.setPeriodic(TimeUnit.HOURS.toMillis(3))
3435
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
36+
.setBackoffCriteria(TimeUnit.MINUTES.toMillis(30), BACKOFF_POLICY_EXPONENTIAL)
3537
.setPersisted(true)
3638
.build()
3739
}

app/src/main/java/com/duckduckgo/app/global/view/FireDialog.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class FireDialog(context: Context, clearStarted: (() -> Unit), clearComplete: ((
3939

4040
clearAllOption.setOnClickListener {
4141
clearStarted()
42-
dataManager.clearData(WebView(context), WebStorage.getInstance())
42+
dataManager.clearData(WebView(context), WebStorage.getInstance(), context)
4343
dataManager.clearExternalCookies(CookieManager.getInstance(), clearComplete)
4444
dismiss()
4545
}

0 commit comments

Comments
 (0)