Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Checks:
-hicpp-move-const-arg,
llvm-*,
-llvm-header-guard
WarningsAsErrors: '*'
WarningsAsErrors: ''
HeaderFilterRegex: '(Browser|Common|JNI)/[^/]+\.h$'
AnalyzeTemporaryDtors: false
FormatStyle: file
Expand Down
9 changes: 8 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ plugins {
}

tasks.register("clean", Delete) {
delete rootProject.layout.buildDirectory
def buildDir = rootProject.layout.buildDirectory.get().asFile
if (buildDir.exists()) {
buildDir.eachFile { file ->
if (file.name != "cerbero" && file.name != "sysroot") {
delete file
}
}
}
delete file(".git/hooks/pre-commit")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ class BrowserFragment : Fragment(R.layout.fragment_browser) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
hideKeyboard()
onCommit(binding.toolbarEditText.text.toString())
binding.toolbarEditText.clearFocus()
selectedTab().webview.requestFocus()
true
} else {
false
Expand Down Expand Up @@ -163,6 +165,18 @@ class BrowserFragment : Fragment(R.layout.fragment_browser) {
}
fullscreenView = null
}

override fun onUriChanged(view: WPEView, uri: String) {
super.onUriChanged(view, uri)
binding.toolbarEditText.setText(uri)
}
}
}

selectedTab.webview.wpeViewClient = object : WPEViewClient() {
override fun onPageStarted(view: WPEView, url: String) {
super.onPageStarted(view, url)
binding.toolbarEditText.setText(url)
}
}
}
Expand Down Expand Up @@ -204,7 +218,7 @@ class BrowserFragment : Fragment(R.layout.fragment_browser) {

private fun onCommit(text: String) {
val url: String = if ((text.contains(".") || text.contains(":")) && !text.contains(" ")) {
Utils.normalizeAddress(text)
normalizeAddress(text)
} else {
SEARCH_URI_BASE + text
}
Expand All @@ -217,7 +231,7 @@ class BrowserFragment : Fragment(R.layout.fragment_browser) {
manager.hideSoftInputFromWindow(requireView().windowToken, 0)
}

private fun selectedTab() : Tab {
internal fun selectedTab() : Tab {
// For now assume we always have at least one tab
val selectedTabId = browserViewModel.browserState.value.selectedTabId
return browserViewModel.findTab(selectedTabId!!)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,17 @@ class MainActivity : AppCompatActivity(R.layout.activity_main) {
super.onConfigurationChanged(newConfig)
Log.d(TAG, "onConfigurationChanged")
}

@Deprecated("Deprecated in superclass")
override fun onBackPressed() {
val currentFragment = navHost.childFragmentManager.fragments.firstOrNull()
if (currentFragment is BrowserFragment) {
val webView = currentFragment.selectedTab().webview
if (webView.canGoBack()) {
webView.goBack()
return
}
}
super.onBackPressed()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,18 @@ fun View.requestApplyStandardInsets() {
requestApplyInsetsWhenAttached()
}

object Utils {
private fun addressHasWebScheme(address: String) : Boolean {
// Ensures that the address has an HTTP/HTTPS scheme, adding HTTPS if missing
fun normalizeAddress(address: String): String {
// Returns true if a scheme exists and is "http" or "https" (case-insensitive)
val hasWebScheme = try {
val uri = URI(address)
return uri.scheme?.let {
it == "http"
} ?: false
uri.scheme?.lowercase() in listOf("http", "https")
} catch (_: Exception) {
false
}

fun normalizeAddress(address: String) : String {
return if (!addressHasWebScheme(address)) {
return "http://$address"
} else {
address
}
if (hasWebScheme) {
return address
}
return "https://$address"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/light_grey_30"/>
<corners android:radius="8dp"/>
<stroke android:color="@color/violet_70" android:width="2dp"/>
<corners android:radius="16dp"/>
</shape>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<vector android:height="24dp" android:tint="#000000"
<vector android:height="24dp" android:tint="?attr/colorControlNormal"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,16c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<vector android:height="24dp" android:tint="#000000"
<vector android:height="24dp" android:tint="?attr/colorControlNormal"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98 0,-0.34 -0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.09,-0.16 -0.26,-0.25 -0.44,-0.25 -0.06,0 -0.12,0.01 -0.17,0.03l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.06,-0.02 -0.12,-0.03 -0.18,-0.03 -0.17,0 -0.34,0.09 -0.43,0.25l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98 0,0.33 0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.09,0.16 0.26,0.25 0.44,0.25 0.06,0 0.12,-0.01 0.17,-0.03l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.06,0.02 0.12,0.03 0.18,0.03 0.17,0 0.34,-0.09 0.43,-0.25l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM17.45,11.27c0.04,0.31 0.05,0.52 0.05,0.73 0,0.21 -0.02,0.43 -0.05,0.73l-0.14,1.13 0.89,0.7 1.08,0.84 -0.7,1.21 -1.27,-0.51 -1.04,-0.42 -0.9,0.68c-0.43,0.32 -0.84,0.56 -1.25,0.73l-1.06,0.43 -0.16,1.13 -0.2,1.35h-1.4l-0.19,-1.35 -0.16,-1.13 -1.06,-0.43c-0.43,-0.18 -0.83,-0.41 -1.23,-0.71l-0.91,-0.7 -1.06,0.43 -1.27,0.51 -0.7,-1.21 1.08,-0.84 0.89,-0.7 -0.14,-1.13c-0.03,-0.31 -0.05,-0.54 -0.05,-0.74s0.02,-0.43 0.05,-0.73l0.14,-1.13 -0.89,-0.7 -1.08,-0.84 0.7,-1.21 1.27,0.51 1.04,0.42 0.9,-0.68c0.43,-0.32 0.84,-0.56 1.25,-0.73l1.06,-0.43 0.16,-1.13 0.2,-1.35h1.39l0.19,1.35 0.16,1.13 1.06,0.43c0.43,0.18 0.83,0.41 1.23,0.71l0.91,0.7 1.06,-0.43 1.27,-0.51 0.7,1.21 -1.07,0.85 -0.89,0.7 0.14,1.13zM12,8c-2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4zM12,14c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<vector android:autoMirrored="true" android:height="24dp"
android:tint="#000000" android:viewportHeight="24"
android:tint="?attr/colorControlNormal" android:viewportHeight="24"
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M19,11H7.83l4.88,-4.88c0.39,-0.39 0.39,-1.03 0,-1.42 -0.39,-0.39 -1.02,-0.39 -1.41,0l-6.59,6.59c-0.39,0.39 -0.39,1.02 0,1.41l6.59,6.59c0.39,0.39 1.02,0.39 1.41,0 0.39,-0.39 0.39,-1.02 0,-1.41L7.83,13H19c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1z"/>
</vector>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<vector android:autoMirrored="true" android:height="24dp"
android:tint="#000000" android:viewportHeight="24"
android:tint="?attr/colorControlNormal" android:viewportHeight="24"
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M5,13h11.17l-4.88,4.88c-0.39,0.39 -0.39,1.03 0,1.42 0.39,0.39 1.02,0.39 1.41,0l6.59,-6.59c0.39,-0.39 0.39,-1.02 0,-1.41l-6.58,-6.6c-0.39,-0.39 -1.02,-0.39 -1.41,0 -0.39,0.39 -0.39,1.02 0,1.41L16.17,11H5c-0.55,0 -1,0.45 -1,1s0.45,1 1,1z"/>
</vector>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<vector android:height="24dp" android:tint="#000000"
<vector android:height="24dp" android:tint="?attr/colorControlNormal"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M17.65,6.35c-1.63,-1.63 -3.94,-2.57 -6.48,-2.31 -3.67,0.37 -6.69,3.35 -7.1,7.02C3.52,15.91 7.27,20 12,20c3.19,0 5.93,-1.87 7.21,-4.56 0.32,-0.67 -0.16,-1.44 -0.9,-1.44 -0.37,0 -0.72,0.2 -0.88,0.53 -1.13,2.43 -3.84,3.97 -6.8,3.31 -2.22,-0.49 -4.01,-2.3 -4.48,-4.52C5.31,9.44 8.26,6 12,6c1.66,0 3.14,0.69 4.22,1.78l-1.51,1.51c-0.63,0.63 -0.19,1.71 0.7,1.71H19c0.55,0 1,-0.45 1,-1V6.41c0,-0.89 -1.08,-1.34 -1.71,-0.71l-0.64,0.65z"/>
Expand Down
19 changes: 10 additions & 9 deletions tools/minibrowser/src/main/res/layout/fragment_browser.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
android:id="@+id/tab_container_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/page_progress" />
android:layout_above="@id/toolbar" />

<ProgressBar
android:id="@+id/page_progress"
style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_height="8dp"
android:background="@android:color/transparent"
android:layout_above="@id/toolbar"
android:progressTint="@color/violet_70"/>
Expand All @@ -27,29 +27,30 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:actionBarSize"
android:layout_alignParentBottom="true"
android:background="?android:statusBarColor">
android:layout_alignParentBottom="true">

<FrameLayout
android:id="@+id/toolbar_edit_text_wrapper"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_height="match_parent"
android:layout_marginTop="4dp"
android:background="@drawable/address_view_background"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:clickable="true"
android:contentDescription="@string/search_hint"
android:focusable="true"
>
android:focusable="true">

<EditText
android:id="@+id/toolbar_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:importantForAutofill="no"
android:inputType="text|textUri"
android:selectAllOnFocus="true"
android:singleLine="true"
android:layout_gravity="start|center_vertical"
android:layout_marginStart="16dp"
android:hint="@string/search_hint"/>
</FrameLayout>

Expand Down
1 change: 1 addition & 0 deletions tools/scripts/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class Bootstrap:
("wpe-1.0", "wpe"),
("wpe-android", "wpe-android"),
("wpe-webkit-2.0", "wpe-webkit"),
("wpe-webkit-2.0/wpe-platform", "wpe-platform"),
("xkbcommon", "xkbcommon")
]
_soname_replacements = [
Expand Down
20 changes: 13 additions & 7 deletions wpeview/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ set_target_properties(soup-3.0 PROPERTIES IMPORTED_LOCATION
add_library(WPEWebKit-2.0 SHARED IMPORTED)
set_target_properties(
WPEWebKit-2.0
PROPERTIES IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/imported/lib/${ANDROID_ABI}/libWPEWebKit-2.0.so"
INTERFACE_INCLUDE_DIRECTORIES
"${CMAKE_SOURCE_DIR}/imported/include/wpe-webkit;${CMAKE_SOURCE_DIR}/imported/include/libsoup-3.0")
PROPERTIES
IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/imported/lib/${ANDROID_ABI}/libWPEWebKit-2.0.so"
INTERFACE_INCLUDE_DIRECTORIES
"${CMAKE_SOURCE_DIR}/imported/include/wpe-webkit;${CMAKE_SOURCE_DIR}/imported/include/wpe-platform;${CMAKE_SOURCE_DIR}/imported/include;${CMAKE_SOURCE_DIR}/imported/include/libsoup-3.0"
)

add_library(libwpe-1.0 SHARED IMPORTED)
set_target_properties(
Expand Down Expand Up @@ -109,6 +111,7 @@ target_link_libraries(
${android-lib}
${log-lib}
${sync-lib}
gio-2.0
glib-2.0
gobject-2.0
gstreamer-1.0
Expand All @@ -120,7 +123,6 @@ add_library(
WPEAndroidRuntime SHARED
Runtime/EntryPoint.cpp
Runtime/Fence.cpp
Runtime/InputMethodContext.cpp
Runtime/LooperThread.cpp
Runtime/MessagePump.cpp
Runtime/RendererSurfaceControl.cpp
Expand All @@ -132,9 +134,14 @@ add_library(
Runtime/WKWebContext.cpp
Runtime/WKSettings.cpp
Runtime/WKWebsiteDataManager.cpp
Runtime/WKWebView.cpp)
Runtime/WKWebView.cpp
Runtime/WPEViewAndroid.cpp
Common/WPEDisplayAndroid.cpp
Common/WPEInputMethodContextAndroid.cpp
Common/WPEToplevelAndroid.cpp)
target_configure_quality(WPEAndroidRuntime)
target_compile_definitions(WPEAndroidRuntime PRIVATE WPE_ENABLE_PROCESS)
target_include_directories(WPEAndroidRuntime PRIVATE Runtime Common)
target_link_libraries(
WPEAndroidRuntime
EGL
Expand All @@ -144,7 +151,6 @@ target_link_libraries(
gobject-2.0
libwpe-1.0
soup-3.0
WPEBackend
WPEWebKit-2.0
WPEAndroidCommon)

Expand All @@ -156,7 +162,7 @@ target_link_libraries(
gio-2.0
glib-2.0
gmodule-2.0
WPEBackend
WPEWebKit-2.0
WPEAndroidRuntime
WPEAndroidCommon
WPEWebDriver)
Loading
Loading