Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable swipe-to-refresh for browser tabs (#864)
* Enable swipe-to-refresh for browser tabs - Including SwipeRefreshLayout dependencies & adapted fragment - Minor fix for DuckDuckGoWebView to work with SwipeRefreshLayout Resolves: #33 * Fix for lint * Replaced single quotes with double quotes in gradle file * Swipe-to-refresh fixes for draggable content - Added callback to allow WebView control over SwipeRefreshLayout - Added logic to disable swipe refresh when WebView is not clampedY before * Always show overScrollMode to make swipe-refresh behavior more clear * Changed overscroll effect to black for all themes to highlight swipe-refresh * Disable swipe to refresh on pages that define overscrollBehavior - Added JavaScript interface to retrieve the css overscrollBehaviorY value - Added switch on custom WebView to allow disabling swipe to refresh completely - Minor fix for lastClampedY issue on pages where height <= window to detect whether we actually are clampedY at the top * Replaced JS interface with evaluateJavascript call * Minor refactor, moved webView related logic into webView class
- Loading branch information
Showing
7 changed files
with
138 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
app/src/main/java/com/duckduckgo/app/browser/ui/ScrollAwareRefreshLayout.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2020 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. | ||
*/ | ||
|
||
package com.duckduckgo.app.browser.ui | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout | ||
|
||
class ScrollAwareRefreshLayout(context: Context, attrs: AttributeSet?) : SwipeRefreshLayout(context, attrs) { | ||
|
||
private var canChildScrollUpCallback: (() -> Boolean)? = null | ||
|
||
fun setProgressViewStartOffset(start: Int) { | ||
mOriginalOffsetTop = start | ||
} | ||
|
||
override fun canChildScrollUp(): Boolean { | ||
return canChildScrollUpCallback?.invoke() ?: super.canChildScrollUp() | ||
} | ||
|
||
fun setCanChildScrollUpCallback(callback: () -> Boolean) { | ||
canChildScrollUpCallback = callback | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters