fix: swipe-to-refresh hijacks upward scroll in WebView
Added setOnChildScrollUpCallback — only allows pull-to-refresh when WebView scrollY is 0 (at the very top). When scrolled down, the gesture passes through to the WebView for normal scrolling. Also fixed: url_label/hint now say 'base URL' instead of misleading 'server URL'/'public URL'.
This commit is contained in:
@@ -64,6 +64,10 @@ public class MainActivity extends AppCompatActivity {
|
||||
btnRefresh.setOnClickListener(v -> webView.reload());
|
||||
btnSettings.setOnClickListener(v -> showSettingsDialog());
|
||||
|
||||
// Only allow pull-to-refresh when WebView is scrolled to the top
|
||||
swipeRefresh.setEnabled(false);
|
||||
swipeRefresh.setOnChildScrollUpCallback((parent, child) -> webView.getScrollY() > 0);
|
||||
|
||||
SharedPreferences prefs = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
|
||||
serverUrl = prefs.getString(KEY_SERVER_URL, "");
|
||||
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
<string name="refresh">Refresh</string>
|
||||
<string name="settings">Settings</string>
|
||||
<string name="settings_title">Server Configuration</string>
|
||||
<string name="url_label">Enter your Meal Tracker server URL:</string>
|
||||
<string name="url_hint_text">The address where your meal tracker is hosted.\nExample: https://meals.example.com</string>
|
||||
<string name="url_label">Enter your Meal Tracker base URL:</string>
|
||||
<string name="url_hint_text">The base address of your meal tracker server.\nExample: https://meals.example.com</string>
|
||||
<string name="save">Save</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="clear_data">Clear Data</string>
|
||||
<string name="url_saved">Connected to server</string>
|
||||
<string name="url_empty">Please enter a server URL</string>
|
||||
<string name="url_empty">Please enter a base URL</string>
|
||||
<string name="error_no_network">No network connection.\nTap to retry.</string>
|
||||
<string name="error_load_failed">Could not reach the server.\nCheck the URL and tap to retry.\n\nTip: make sure the URL opens in a browser first.</string>
|
||||
<string name="error_http">Server returned HTTP %d.\nCheck your server URL and tap to retry.</string>
|
||||
<string name="server_not_configured">No server configured.\nTap the gear icon ⚙ to enter your server URL.</string>
|
||||
<string name="error_http">Server returned HTTP %d.\nCheck your base URL and tap to retry.</string>
|
||||
<string name="server_not_configured">No server configured.\nTap the gear icon ⚙ to enter your base URL.</string>
|
||||
<string name="data_cleared">Local data cleared</string>
|
||||
<string name="ssl_error_title">⚠ Certificate Warning</string>
|
||||
<string name="ssl_error_msg">The server at %1$s uses an untrusted certificate (error %2$d).\n\nThis is common for self-hosted servers. Proceed only if you trust this server.</string>
|
||||
|
||||
Reference in New Issue
Block a user