Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit f228f4e

Browse files
committed
[[ BrowserWidget ]] Implement scrollbars & useragent properties on Android
1 parent 6cabb70 commit f228f4e

File tree

2 files changed

+56
-9
lines changed

2 files changed

+56
-9
lines changed

engine/src/java/com/runrev/android/libraries/LibBrowser.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,16 @@ public boolean onTouch(View v, MotionEvent event) {
394394
setOnTouchListener(null);
395395
}
396396

397+
public String getUserAgent()
398+
{
399+
return getSettings().getUserAgentString();
400+
}
401+
402+
public void setUserAgent(String p_useragent)
403+
{
404+
getSettings().setUserAgentString(p_useragent);
405+
}
406+
397407
/* ACTIONS */
398408

399409
public void goBack(int p_steps)

libbrowser/src/libbrowser_android.cpp

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ class MCAndroidWebViewBrowser : public MCBrowserBase
120120

121121
virtual bool GetRect(MCBrowserRect &r_rect)
122122
{
123-
// TODO - implement
123+
// TODO - implement (not needed when used with native layers)
124124
return false;
125125
}
126126

127127
virtual bool SetRect(const MCBrowserRect &p_rect)
128128
{
129-
// TODO - implement
129+
// TODO - implement (not needed when used with native layers)
130130
return false;
131131
}
132132

@@ -165,6 +165,9 @@ class MCAndroidWebViewBrowser : public MCBrowserBase
165165
case kMCBrowserURL:
166166
return GetUrl(r_utf8_string);
167167

168+
case kMCBrowserUserAgent:
169+
return GetUserAgent(r_utf8_string);
170+
168171
default:
169172
break;
170173
}
@@ -174,7 +177,15 @@ class MCAndroidWebViewBrowser : public MCBrowserBase
174177

175178
virtual bool SetStringProperty(MCBrowserProperty p_property, const char *p_utf8_string)
176179
{
177-
// TODO - implement
180+
switch (p_property)
181+
{
182+
case kMCBrowserUserAgent:
183+
return SetUserAgent(p_utf8_string);
184+
185+
default:
186+
break;
187+
}
188+
178189
return false;
179190
}
180191

@@ -242,20 +253,46 @@ class MCAndroidWebViewBrowser : public MCBrowserBase
242253
private:
243254
bool GetScrollbarsEnabled(bool &r_value)
244255
{
245-
// TODO - implement
246-
return false;
256+
MCAndroidObjectRemoteCall(m_view, "getScrollingEnabled", "b", &r_value);
257+
return true;
247258
}
248259

249260
bool SetScrollbarsEnabled(bool p_value)
250261
{
251-
// TODO - implement
252-
return false;
262+
MCAndroidObjectRemoteCall(m_view, "setScrollingEnabled", "vb", nil, p_value);
263+
return true;
253264
}
254265

255266
bool GetUrl(char *&r_utf8_string)
256267
{
257-
// TODO - implement
258-
return false;
268+
char *t_url;
269+
t_url = nil;
270+
271+
MCAndroidObjectRemoteCall(m_view, "getUrl", "s", &t_url);
272+
if (t_url == nil)
273+
return false;
274+
275+
r_utf8_string = t_url;
276+
return true;
277+
}
278+
279+
bool GetUserAgent(char *&r_useragent)
280+
{
281+
char *t_useragent;
282+
t_useragent = nil;
283+
MCAndroidObjectRemoteCall(m_view, "getUserAgent", "s", &t_useragent);
284+
285+
if (t_useragent == nil)
286+
return false;
287+
288+
r_useragent = t_useragent;
289+
return true;
290+
}
291+
292+
bool SetUserAgent(const char *p_useragent)
293+
{
294+
MCAndroidObjectRemoteCall(m_view, "setUserAgent", "vs", nil, p_useragent);
295+
return true;
259296
}
260297
};
261298

0 commit comments

Comments
 (0)