Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4844] Enable property for setBuiltInZoomControls in WebViews on Android

GitHub Issuen/a
TypeNew Feature
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2011-10-03T07:30:38.000+0000
Affected Version/sRelease 1.7.2
Fix Version/sSprint 2011-39, Release 1.8.0
ComponentsAndroid
Labelsmodule_webview, qe-testadded
ReporterMatthew Congrove
AssigneeAllen Yeung
Created2011-07-31T22:50:55.000+0000
Updated2013-11-25T08:49:31.000+0000

Description

Request that Appcelerator expose the setBuiltInZoomControls property on WebViews within Android so that zooming functionality can be _disabled_ in the application. Perhaps a property name like disableZoom might be more appropriate. Android documentation: http://developer.android.com/reference/android/webkit/WebSettings.html#setBuiltInZoomControls(boolean)

Comments

  1. Anirudh Nagesh 2011-08-04

    Associated helpdesk ticket:

    appc.me/c/APP-864343 Changing the customer priority to Within release.
  2. Christopher Bailey 2011-09-23

    Thanks very much for working on this, it's very important to us (HotelTonight)! I've tested this with continuous build 1.8.0.v20110923102146, but setting enableZoomControls to false doesn't seem to turn off the display of the zoom controls. Upon further research, the solution appears to require calling both the native setBuiltInZoomControls, as you do now (in TiUIWebView.java), as well as setSupportZoom. I have added this to the Titanium code, built the SDK, built my app with this new SDK build, and tested it, and it does indeed solve it. I thus hope this addition/change can be part of this fix. Note, I found this solution via the following in case it's of interest: http://stackoverflow.com/questions/5125851/enable-disable-zoom-in-android-webview
  3. Allen Yeung 2011-09-28

    I just tried the latest build with my app.js, and it seems to be working. Could you provide an app.js so I can try to reproduce the issue you are having? Thanks, Allen
  4. Christopher Bailey 2011-09-28

    I just downloaded the latest continuous build for today, and it's still happening - on some devices. Here's a screenshot: https://skitch.com/chrisrbailey/fh2nb/android-zoom-controls-on-webview This occurs on my HTC Thunderbolt, but not on an Droid X or an LG Optimus: HTC Thunderbolt: Android 2.2.1, Verizon, Webkit/533.1, screen: 480x800 Droid X: Android 2.2.1, Verizon, screen: 480x854 LG Optimus S: Android 2.2.2, Sprint, screen: 320x480 To reproduce this, use a Titanium app that contains a window that has a WebView control. Open that up, ensure a web page loads in the webview, then scroll the webpage. You'll then see the zoom controls appear, again on some devices. The above screenshot was taken on an HTC Thunderbolt, using Titanium build 1.8.0.v20110926132318. As other Android developers have found, this depends on the device, but it seems, it's not enough to just call setBuiltInZoomControls, you also need to call setSupportZoom in order to affect this on all devices (see my prior comment and the Stack Overflow thread).
  5. Christopher Bailey 2011-09-29

    Note, I just sent a GitHub pull request with my change for this, that I've tested on the Thunderbolt (and others) and shown to work. https://github.com/appcelerator/titanium_mobile/pull/510
  6. Allen Yeung 2011-09-29

    I've added your proposed change with support to change zoomControls after initialization. Thanks for your input.
  7. Allen Yeung 2011-09-29

    For testing I used this app.js
       
       
       // this sets the background color of the master UIView (when there are no windows/tab groups on it)
       Titanium.UI.setBackgroundColor('#000');
       
       // create tab group
       var tabGroup = Titanium.UI.createTabGroup();
       
       var overlay = Titanium.UI.createView();
       
       var html = '<html><body>';
       html += '<div> take a photo!!</div>';
       html +='</body></html>';
       var webview = Ti.UI.createWebView({
       	backgroundColor:'#fff',
       	html:html
       });
       
       
       overlay.add(webview);
       webview.setEnableZoomControls(false);
       //
       // create base UI tab and root window
       //
       var win1 = Titanium.UI.createWindow({  
           title:'Tab 1',
           backgroundColor:'#fff'
       });
       
       win1.add(overlay);
       
       var tab1 = Titanium.UI.createTab({  
           icon:'KS_nav_views.png',
           title:'Tab 1',
           window:win1
       });
       
       var label1 = Titanium.UI.createLabel({
       	color:'#999',
       	text:'I am Window 1',
       	font:{fontSize:20,fontFamily:'Helvetica Neue'},
       	textAlign:'center',
       	width:'auto'
       });
       
       // win1.add(label1);
       
       //
       // create controls tab and root window
       //
       var win2 = Titanium.UI.createWindow({  
           title:'Tab 2',
           backgroundColor:'#fff'
       });
       var tab2 = Titanium.UI.createTab({  
           icon:'KS_nav_ui.png',
           title:'Tab 2',
           window:win2
       });
       
       var label2 = Titanium.UI.createLabel({
       	color:'#999',
       	text:'I am Window 2',
       	font:{fontSize:20,fontFamily:'Helvetica Neue'},
       	textAlign:'center',
       	width:'auto'
       });
       
       win2.add(label2);
       
       
       
       //
       //  add tabs
       //
       tabGroup.addTab(tab1);  
       tabGroup.addTab(tab2);  
       
       
       // open tab group
       tabGroup.open();
       
    This code should not have zoom controls, since we disabled it. If you enable it with webview.setEnableZoomControls(true), the zoom controls should show up.
  8. Alan Vaghti 2011-11-22

    Closing. Verified fix on a Nexus One 2.2.2 with SDK 1.8.0.1.v20111122105459. Tested with Allen's app. User can zoom in and out, but zoom controls are disabled. If setEnableZoomControls is set to true, zoom controls are enabled.
  9. jithinpv 2013-11-25

    Anvil test case added. PR link: https://github.com/appcelerator/titanium_mobile/pull/5020

JSON Source