Skip to content

Commit 28fff5a

Browse files
authored
Feature/david/contrast colors change (#838)
* fixed colors for dialogs in settings screen * change app icon dialog styling * changed dialog for report broken site * fixing edit bookmark dialog theming * no need to set the theme per dialog, it inherits from the theme * using the new popup menu * added new popup menu * added popup layout * added support for dark theme in fire dialog * all dialogs are using the same theme * using white instead of grayish * changed text and icon colors in light and dark mode * adding new colors for contrast * cleaning up bad color * updated bg color in fire dialog * adding colors so we pass the color contrast test * final tweaks to the toolbar, removing elevation and adding custom shadow * back to it's proper experiment definition * last ui review changes * clean up bottom bar background color * fixed version for release * experiment back to original value * applying ktlint * adding text color for the dialogs * revert changes to dialogs, they don't belong here * remove unnecessary imports * more cleanup reveryting changes * revert change in bookmarks
1 parent 078f039 commit 28fff5a

24 files changed

+253
-99
lines changed

app/src/main/java/com/duckduckgo/app/bookmarks/ui/BookmarksActivity.kt

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

1717
package com.duckduckgo.app.bookmarks.ui
1818

19-
import android.app.AlertDialog
2019
import android.content.Context
2120
import android.content.Intent
2221
import android.net.Uri
@@ -26,7 +25,7 @@ import android.view.Menu
2625
import android.view.View
2726
import android.view.ViewGroup
2827
import android.widget.ImageView
29-
import android.widget.PopupMenu
28+
import androidx.appcompat.app.AlertDialog
3029
import androidx.appcompat.widget.SearchView
3130
import androidx.lifecycle.Observer
3231
import androidx.recyclerview.widget.RecyclerView.Adapter
@@ -46,6 +45,15 @@ import com.duckduckgo.app.global.view.show
4645
import kotlinx.android.synthetic.main.content_bookmarks.*
4746
import kotlinx.android.synthetic.main.include_toolbar.*
4847
import kotlinx.android.synthetic.main.view_bookmark_entry.view.*
48+
import kotlinx.android.synthetic.main.content_bookmarks.emptyBookmarks
49+
import kotlinx.android.synthetic.main.content_bookmarks.recycler
50+
import kotlinx.android.synthetic.main.include_toolbar.toolbar
51+
import kotlinx.android.synthetic.main.popup_window_bookmarks_menu.view.deleteBookmark
52+
import kotlinx.android.synthetic.main.popup_window_bookmarks_menu.view.editBookmark
53+
import kotlinx.android.synthetic.main.view_bookmark_entry.view.favicon
54+
import kotlinx.android.synthetic.main.view_bookmark_entry.view.overflowMenu
55+
import kotlinx.android.synthetic.main.view_bookmark_entry.view.title
56+
import kotlinx.android.synthetic.main.view_bookmark_entry.view.url
4957
import timber.log.Timber
5058

5159
class BookmarksActivity : DuckDuckGoActivity() {
@@ -64,7 +72,7 @@ class BookmarksActivity : DuckDuckGoActivity() {
6472
}
6573

6674
private fun setupBookmarksRecycler() {
67-
adapter = BookmarksAdapter(applicationContext, viewModel)
75+
adapter = BookmarksAdapter(layoutInflater, viewModel)
6876
recycler.adapter = adapter
6977
}
7078

@@ -126,10 +134,13 @@ class BookmarksActivity : DuckDuckGoActivity() {
126134
deleteDialog = AlertDialog.Builder(this)
127135
.setTitle(title)
128136
.setMessage(message)
129-
.setPositiveButton(android.R.string.yes) { _, _ -> delete(bookmark) }
130-
.setNegativeButton(android.R.string.no) { _, _ -> }
131-
.create()
132-
deleteDialog?.show()
137+
.setPositiveButton(android.R.string.yes) { _, _ ->
138+
delete(bookmark)
139+
}
140+
.setNegativeButton(android.R.string.no) { dialog, _ ->
141+
dialog.dismiss()
142+
}
143+
.show()
133144
}
134145

135146
private fun delete(bookmark: BookmarkEntity) {
@@ -151,7 +162,7 @@ class BookmarksActivity : DuckDuckGoActivity() {
151162
}
152163

153164
class BookmarksAdapter(
154-
private val context: Context,
165+
private val layoutInflater: LayoutInflater,
155166
private val viewModel: BookmarksViewModel
156167
) : Adapter<BookmarksViewHolder>() {
157168

@@ -164,7 +175,7 @@ class BookmarksActivity : DuckDuckGoActivity() {
164175
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BookmarksViewHolder {
165176
val inflater = LayoutInflater.from(parent.context)
166177
val view = inflater.inflate(R.layout.view_bookmark_entry, parent, false)
167-
return BookmarksViewHolder(view, viewModel)
178+
return BookmarksViewHolder(layoutInflater, view, viewModel)
168179
}
169180

170181
override fun onBindViewHolder(holder: BookmarksViewHolder, position: Int) {
@@ -176,8 +187,7 @@ class BookmarksActivity : DuckDuckGoActivity() {
176187
}
177188
}
178189

179-
class BookmarksViewHolder(itemView: View, private val viewModel: BookmarksViewModel) :
180-
ViewHolder(itemView) {
190+
class BookmarksViewHolder(val layoutInflater: LayoutInflater, itemView: View, private val viewModel: BookmarksViewModel) : ViewHolder(itemView) {
181191

182192
lateinit var bookmark: BookmarkEntity
183193

@@ -217,23 +227,14 @@ class BookmarksActivity : DuckDuckGoActivity() {
217227
return uri.baseHost ?: return urlString
218228
}
219229

220-
private fun showOverFlowMenu(overflowMenu: ImageView, bookmark: BookmarkEntity) {
221-
val popup = PopupMenu(overflowMenu.context, overflowMenu)
222-
popup.inflate(R.menu.bookmarks_individual_overflow_menu)
223-
popup.setOnMenuItemClickListener {
224-
when (it.itemId) {
225-
226-
R.id.edit -> {
227-
editBookmark(bookmark); true
228-
}
229-
R.id.delete -> {
230-
deleteBookmark(bookmark); true
231-
}
232-
else -> false
233-
234-
}
230+
private fun showOverFlowMenu(anchor: ImageView, bookmark: BookmarkEntity) {
231+
val popupMenu = BookmarksPopupMenu(layoutInflater)
232+
val view = popupMenu.contentView
233+
popupMenu.apply {
234+
onMenuItemClicked(view.editBookmark) { editBookmark(bookmark) }
235+
onMenuItemClicked(view.deleteBookmark) { deleteBookmark(bookmark) }
235236
}
236-
popup.show()
237+
popupMenu.show(itemView, anchor)
237238
}
238239

239240
private fun editBookmark(bookmark: BookmarkEntity) {
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright (c) 2020 DuckDuckGo
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.duckduckgo.app.bookmarks.ui
18+
19+
import android.graphics.Color
20+
import android.graphics.drawable.ColorDrawable
21+
import android.os.Build.VERSION.SDK_INT
22+
import android.view.Gravity
23+
import android.view.LayoutInflater
24+
import android.view.View
25+
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
26+
import android.widget.PopupWindow
27+
import com.duckduckgo.app.browser.R
28+
29+
class BookmarksPopupMenu(layoutInflater: LayoutInflater, view: View = inflate(layoutInflater, R.layout.popup_window_bookmarks_menu)) :
30+
PopupWindow(view, WRAP_CONTENT, WRAP_CONTENT, true) {
31+
32+
init {
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.
36+
setBackgroundDrawable(ColorDrawable(Color.WHITE))
37+
} else {
38+
elevation = ELEVATION
39+
}
40+
animationStyle = android.R.style.Animation_Dialog
41+
}
42+
43+
fun onMenuItemClicked(menuView: View, onClick: () -> Unit) {
44+
menuView.setOnClickListener {
45+
onClick()
46+
dismiss()
47+
}
48+
}
49+
50+
fun show(rootView: View, anchorView: View) {
51+
val anchorLocation = IntArray(2)
52+
anchorView.getLocationOnScreen(anchorLocation)
53+
val x = MARGIN
54+
val y = anchorLocation[1] + MARGIN
55+
showAtLocation(rootView, Gravity.TOP or Gravity.END, x, y)
56+
}
57+
58+
companion object {
59+
60+
private const val MARGIN = 30
61+
private const val ELEVATION = 6f
62+
63+
fun inflate(layoutInflater: LayoutInflater, resourceId: Int): View {
64+
return layoutInflater.inflate(resourceId, null)
65+
}
66+
}
67+
}

app/src/main/java/com/duckduckgo/app/icon/ui/ChangeIconActivity.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import androidx.lifecycle.Observer
2424
import androidx.recyclerview.widget.GridLayoutManager
2525
import com.duckduckgo.app.browser.R
2626
import com.duckduckgo.app.global.DuckDuckGoActivity
27+
import kotlinx.android.synthetic.main.content_app_icons.appIconsList
28+
import kotlinx.android.synthetic.main.include_toolbar.toolbar
2729
import kotlinx.android.synthetic.main.content_app_icons.*
2830
import kotlinx.android.synthetic.main.include_toolbar.*
2931

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717

1818
<selector xmlns:android="http://schemas.android.com/apk/res/android">
1919
<item android:state_enabled="false" android:color="@color/midGray" />
20-
<item android:color="@color/grayish"/>
20+
<item android:color="@color/white"/>
2121
</selector>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717

1818
<selector xmlns:android="http://schemas.android.com/apk/res/android">
1919
<item android:state_enabled="false" android:color="@color/pinkish_grey_two" />
20-
<item android:color="@color/grayishBrown"/>
20+
<item android:color="@color/almostBlackDark"/>
2121
</selector>

app/src/main/res/drawable/bottom_navigation_bar_bg.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@
4343
<item>
4444
<shape android:shape="rectangle">
4545
<padding android:top="1dp"/>
46-
<solid android:color="#50CCCCCC" />
46+
<solid android:color="?attr/toolbarBgBorderColor" />
4747
</shape>
4848
</item>
4949
<item>
5050
<shape
5151
android:shape="rectangle">
52-
<solid android:color="?attr/colorPrimary"/>
52+
<solid android:color="?attr/toolbarBgColor"/>
5353
</shape>
5454
</item>
5555
</layer-list>

app/src/main/res/drawable/ic_cancel_brownish_24dp.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
android:viewportWidth="24.0"
2121
android:viewportHeight="24.0">
2222
<path
23-
android:fillColor="@color/brownishGray"
23+
android:fillColor="?normalTextColor"
2424
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z" />
2525
</vector>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (c) 2020 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+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
18+
<item android:id="@android:id/background">
19+
<shape>
20+
<solid
21+
android:color="?toolbarBgColor" />
22+
</shape>
23+
</item>
24+
25+
<item
26+
android:id="@android:id/progress">
27+
<clip>
28+
<shape>
29+
<solid
30+
android:color="?colorAccent" />
31+
</shape>
32+
</clip>
33+
</item>
34+
35+
</layer-list>

app/src/main/res/drawable/popup_menu_bg.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
-->
1616

1717
<shape xmlns:android="http://schemas.android.com/apk/res/android">
18-
<solid android:color="?attr/colorPrimary"/>
18+
<solid android:color="?attr/dialogBgColor"/>
1919
<corners android:radius="8dp" />
2020
</shape>

app/src/main/res/layout/activity_system_search.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
android:paddingEnd="16dp"
143143
android:paddingBottom="2dp"
144144
android:text="@string/systemSearchDeviceAppLabel"
145-
android:textColor="@color/grayish"
145+
android:textColor="?normalTextColor"
146146
android:textSize="13sp"
147147
app:layout_constraintEnd_toEndOf="parent"
148148
app:layout_constraintStart_toStartOf="parent"

0 commit comments

Comments
 (0)