|
| 1 | +// (C) Copyright 2025 Moodle Pty Ltd. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package com.moodle.moodlemobile; |
| 16 | + |
| 17 | +import org.apache.cordova.CordovaInterface; |
| 18 | +import org.apache.cordova.CordovaPlugin; |
| 19 | +import org.apache.cordova.CordovaWebView; |
| 20 | + |
| 21 | +import android.util.Log; |
| 22 | +import android.webkit.WebSettings; |
| 23 | +import android.webkit.WebSettings.ZoomDensity; |
| 24 | +import android.webkit.WebView; |
| 25 | + |
| 26 | +public class PinchToZoom extends CordovaPlugin { |
| 27 | + |
| 28 | + public static final String TAG = "PinchToZoom"; |
| 29 | + |
| 30 | + @Override |
| 31 | + public void initialize(CordovaInterface cordova, CordovaWebView webView) { |
| 32 | + Log.d(TAG, "Initializing pinch-to-zoom"); |
| 33 | + |
| 34 | + super.initialize(cordova, webView); |
| 35 | + |
| 36 | + WebSettings settings = ((WebView) webView.getView()).getSettings(); |
| 37 | + settings.setBuiltInZoomControls(true); |
| 38 | + settings.setDefaultZoom(WebSettings.ZoomDensity.MEDIUM); |
| 39 | + settings.setDisplayZoomControls(false); |
| 40 | + settings.setSupportZoom(true); |
| 41 | + } |
| 42 | +} |
0 commit comments