Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
094409a
Remove unused activity
CDRussell May 8, 2019
453675c
Suppress lint warning
CDRussell May 8, 2019
2ecd2a6
Add new onboarding page implementation
CDRussell May 8, 2019
86512da
Remove redundant assets
CDRussell May 8, 2019
d5351b1
Add new assets
CDRussell May 8, 2019
624e8ac
Reorder elements on unified welcome screen
CDRussell May 8, 2019
d24391b
Update set default screen to match new designs
CDRussell May 8, 2019
451ad74
Add tests for onboarding logic
CDRussell May 8, 2019
2bd9df3
Add landscape version of default browser
CDRussell May 8, 2019
354d781
Ensure continue button retains correct text across config changes
CDRussell May 9, 2019
91b008e
Behavioural differences between launching onboarding from settings
CDRussell May 9, 2019
8287385
Add pixels for onboarding default browser
CDRussell May 9, 2019
e06289c
Code tidy
CDRussell May 9, 2019
dd440ba
Code tidy
CDRussell May 9, 2019
c78537e
Code tidy
CDRussell May 9, 2019
96ea98c
Removing unused resources
CDRussell May 9, 2019
8dbaa35
Update tooling
CDRussell May 10, 2019
60fd127
More centered view for unified welcome screen
CDRussell May 10, 2019
18655a5
Tidying up UI
CDRussell May 10, 2019
5e7a448
Rollback to earlier material design version as this one crashes webview
CDRussell May 10, 2019
d3169c9
Rollback AGP and gradle version to make testing easier
CDRussell May 10, 2019
e08f5b9
Replace vectors with PNGs (blurry on API 21)
CDRussell May 10, 2019
84b1801
Make buttons the same size
CDRussell May 10, 2019
2867525
Update pixel value
CDRussell May 10, 2019
26421da
Merge branch 'develop' into feature/onboarding_improvements
CDRussell May 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@ captures/
fastlane/report.xml

# Bitrise configuration
bitrise.yml
bitrise.yml

# NDK files
**/.cxx
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ android {

ext {
androidX = "1.0.2"
materialDesign = "1.0.0"
materialDesign = "1.1.0-alpha05"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: Consider avoiding alpha in future

architectureComponents = "1.1.1"
architectureComponentsExtensions = "1.1.1"
androidKtx = "1.0.1"
fragmentKtx = "1.0.0"
constraintLayout = "2.0.0-alpha3"
constraintLayout = "2.0.0-beta1"
lifecycle = "2.1.0-alpha04"
room = "2.1.0-alpha05"
workManager = "2.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
package com.duckduckgo.app.onboarding.ui

import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import com.duckduckgo.app.browser.R
import com.duckduckgo.app.browser.defaultbrowsing.DefaultBrowserDetector
import com.duckduckgo.app.onboarding.store.OnboardingStore
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.never
import com.nhaarman.mockitokotlin2.verify
import com.nhaarman.mockitokotlin2.whenever
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Assert.*
import org.junit.Rule
import org.junit.Test

Expand All @@ -50,29 +50,79 @@ class OnboardingViewModelTest {
}

@Test
fun whenFirstPageRequestedThenProtectDataReturned() {
val page = testee.getItem(0)
assertTrue(page is OnboardingPageFragment.ProtectDataPage)
fun whenFreshInstallFirstPageRequestedThenUnifiedWelcomePageReturned() {
val page = testee.getItem(0, isFreshAppInstall = true)
assertTrue(page is OnboardingPageFragment.UnifiedWelcomePage)
}

@Test
fun whenSecondPageRequestedThenNoTracePageReturned() {
val page = testee.getItem(1)
assertTrue(page is OnboardingPageFragment.NoTracePage)
fun whenNotFreshInstallFirstPageRequestedThenUnifiedWelcomePageReturned() {
val page = testee.getItem(0, isFreshAppInstall = false)
assertTrue(page is OnboardingPageFragment.UnifiedWelcomePage)
}

@Test
fun whenThirdPageRequestedWithDefaultBrowserCapableThenDefaultBrowserPageReturned() {
whenever(mockDefaultBrowserDetector.deviceSupportsDefaultBrowserConfiguration()).thenReturn(true)
val page = testee.getItem(2)
fun whenFreshInstallSecondPageRequestedWithDefaultBrowserCapableThenDefaultBrowserPageReturned() {
configureDeviceSupportsDefaultBrowser()
val page = testee.getItem(1, isFreshAppInstall = true)
assertTrue(page is OnboardingPageFragment.DefaultBrowserPage)
}

@Test
fun whenThirdPageRequestedButDefaultBrowserNotCapableThenNoPageReturned() {
whenever(mockDefaultBrowserDetector.deviceSupportsDefaultBrowserConfiguration()).thenReturn(false)
val page = testee.getItem(2)
fun whenNotFreshInstallSecondPageRequestedWithDefaultBrowserCapableThenNoPageReturned() {
configureDeviceSupportsDefaultBrowser()
val page = testee.getItem(1, isFreshAppInstall = false)
assertNull(page)
}

@Test
fun whenFreshInstallSecondPageRequestedButDefaultBrowserNotCapableThenNoPageReturned() {
configureDeviceDoesNotSupportDefaultBrowser()
val page = testee.getItem(1, isFreshAppInstall = true)
assertNull(page)
}

@Test
fun whenNotFreshInstallSecondPageRequestedButDefaultBrowserNotCapableThenNoPageReturned() {
configureDeviceDoesNotSupportDefaultBrowser()
val page = testee.getItem(1, isFreshAppInstall = false)
assertNull(page)
}

@Test
fun whenDefaultBrowserSupportedThenFirstPageShowsContinueTextOnButton() {
configureDeviceSupportsDefaultBrowser()
val resourceId = testee.getContinueButtonTextResourceId(0, isFreshAppInstall = true)
assertEquals(R.string.onboardingContinue, resourceId)
}

@Test
fun whenFreshInstallDefaultBrowserNotSupportedThenFirstPageShowsFinalTextOnButton() {
configureDeviceDoesNotSupportDefaultBrowser()
val resourceId = testee.getContinueButtonTextResourceId(0, isFreshAppInstall = true)
assertEquals(R.string.onboardingContinueFinalPage, resourceId)
}

@Test
fun whenNotFreshInstallDefaultBrowserSupportedThenFirstPageShowsBackTextOnButton() {
configureDeviceSupportsDefaultBrowser()
val resourceId = testee.getContinueButtonTextResourceId(0, isFreshAppInstall = false)
assertEquals(R.string.onboardingBackButton, resourceId)
}

@Test
fun whenNotFreshInstallDefaultBrowserNotSupportedThenFirstPageShowsBackTextOnButton() {
configureDeviceDoesNotSupportDefaultBrowser()
val resourceId = testee.getContinueButtonTextResourceId(0, isFreshAppInstall = false)
assertEquals(R.string.onboardingBackButton, resourceId)
}

private fun configureDeviceSupportsDefaultBrowser() {
whenever(mockDefaultBrowserDetector.deviceSupportsDefaultBrowserConfiguration()).thenReturn(true)
}

private fun configureDeviceDoesNotSupportDefaultBrowser() {
whenever(mockDefaultBrowserDetector.deviceSupportsDefaultBrowserConfiguration()).thenReturn(false)
}

}
3 changes: 0 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@
<activity
android:name="com.duckduckgo.app.bookmarks.ui.BookmarksActivity"
android:label="@string/bookmarksActivityTitle" />
<activity
android:name=".defaultbrowsing.DefaultBrowserInfoActivity"
android:theme="@style/ModalCardTheme" />
<activity
android:name="com.duckduckgo.app.fire.FireActivity"
android:process="@string/fireProcessName" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,12 @@ class BrowserTabFragment : Fragment(), FindListener, CoroutineScope {
}

private fun showAuthenticationDialog(request: BasicAuthenticationRequest) {
val dialog = HttpAuthenticationDialogFragment.createHttpAuthenticationDialog(request.site)

dialog.show(activity?.supportFragmentManager, AUTHENTICATION_DIALOG_TAG)
dialog.listener = viewModel
dialog.request = request
activity?.supportFragmentManager?.let { fragmentManager ->
val dialog = HttpAuthenticationDialogFragment.createHttpAuthenticationDialog(request.site)
dialog.show(fragmentManager, AUTHENTICATION_DIALOG_TAG)
dialog.listener = viewModel
dialog.request = request
}
}

private fun saveBasicAuthCredentials(request: BasicAuthenticationRequest, credentials: BasicAuthenticationCredentials) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import android.webkit.CookieManager
import com.duckduckgo.app.browser.*
import com.duckduckgo.app.browser.addtohome.AddToHomeCapabilityDetector
import com.duckduckgo.app.browser.addtohome.AddToHomeSystemCapabilityDetector
import com.duckduckgo.app.browser.defaultbrowsing.DefaultBrowserObserver
import com.duckduckgo.app.browser.defaultbrowsing.AndroidDefaultBrowserDetector
import com.duckduckgo.app.browser.defaultbrowsing.DefaultBrowserDetector
import com.duckduckgo.app.browser.defaultbrowsing.DefaultBrowserObserver
import com.duckduckgo.app.browser.session.WebViewSessionInMemoryStorage
import com.duckduckgo.app.browser.session.WebViewSessionStorage
import com.duckduckgo.app.fire.DuckDuckGoCookieManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import com.duckduckgo.app.bookmarks.ui.BookmarksActivity
import com.duckduckgo.app.brokensite.BrokenSiteActivity
import com.duckduckgo.app.browser.BrowserActivity
import com.duckduckgo.app.browser.BrowserTabFragment
import com.duckduckgo.app.browser.defaultbrowsing.DefaultBrowserInfoActivity
import com.duckduckgo.app.browser.rating.ui.AppEnjoymentDialogFragment
import com.duckduckgo.app.browser.rating.ui.GiveFeedbackDialogFragment
import com.duckduckgo.app.browser.rating.ui.RateAppDialogFragment
Expand Down Expand Up @@ -111,10 +110,6 @@ abstract class AndroidBindingModule {
@ContributesAndroidInjector
abstract fun bookmarksActivity(): BookmarksActivity

@ActivityScoped
@ContributesAndroidInjector
abstract fun defaultBrowserInfoActivity(): DefaultBrowserInfoActivity

@ActivityScoped
@ContributesAndroidInjector
abstract fun fireActivity(): FireActivity
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/duckduckgo/app/launch/LaunchActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package com.duckduckgo.app.launch

import androidx.lifecycle.Observer
import android.os.Bundle
import androidx.lifecycle.Observer
import com.duckduckgo.app.browser.BrowserActivity
import com.duckduckgo.app.browser.R
import com.duckduckgo.app.global.DuckDuckGoActivity
Expand Down Expand Up @@ -55,7 +55,7 @@ class LaunchActivity : DuckDuckGoActivity() {
startActivity(BrowserActivity.intent(this))

if (showOnboarding) {
startActivity(OnboardingActivity.intent(this))
startActivity(OnboardingActivity.intent(this, isFreshAppInstall = true))
}

finish()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package com.duckduckgo.app.onboarding.ui
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.annotation.ColorInt
import androidx.core.content.ContextCompat
import com.duckduckgo.app.browser.R
Expand All @@ -42,15 +41,15 @@ class OnboardingActivity : DuckDuckGoActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_onboarding)
configurePager()
configurePager(intent.getBooleanExtra(IS_FRESH_INSTALL_EXTRA, true))
}

override fun onResume() {
updateColor(viewPageAdapter.color(this, viewPager.currentItem))
super.onResume()
}

fun onContinueClicked(view: View) {
fun onContinueClicked() {
val next = viewPager.currentItem + 1
if (next < viewPager.adapter!!.count) {
viewPager.setCurrentItem(next, true)
Expand All @@ -60,9 +59,9 @@ class OnboardingActivity : DuckDuckGoActivity() {
}
}

private fun configurePager() {
private fun configurePager(isFreshAppInstall: Boolean) {

viewPageAdapter = PagerAdapter(supportFragmentManager, viewModel)
viewPageAdapter = PagerAdapter(supportFragmentManager, viewModel, isFreshAppInstall)
viewPager.adapter = viewPageAdapter
val pageListener = ColorChangingPageListener(colorCombiner, object : NewColorListener {
override fun update(@ColorInt color: Int) = updateColor(color)
Expand All @@ -80,8 +79,13 @@ class OnboardingActivity : DuckDuckGoActivity() {
}

companion object {
fun intent(context: Context): Intent {
return Intent(context, OnboardingActivity::class.java)

private const val IS_FRESH_INSTALL_EXTRA = "IS_FRESH_INSTALL_EXTRA"

fun intent(context: Context, isFreshAppInstall: Boolean): Intent {
val intent = Intent(context, OnboardingActivity::class.java)
intent.putExtra(IS_FRESH_INSTALL_EXTRA, isFreshAppInstall)
return intent
}
}
}
Loading