Home | History | Annotate | Download | only in util
      1 /*
      2  * ConnectBot: simple, powerful, open-source SSH client for Android
      3  * Copyright 2007 Kenny Root, Jeffrey Sharkey
      4  *
      5  * Licensed under the Apache License, Version 2.0 (the "License");
      6  * you may not use this file except in compliance with the License.
      7  * You may obtain a copy of the License at
      8  *
      9  *     http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  * Unless required by applicable law or agreed to in writing, software
     12  * distributed under the License is distributed on an "AS IS" BASIS,
     13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  * See the License for the specific language governing permissions and
     15  * limitations under the License.
     16  */
     17 
     18 package org.connectbot.util;
     19 
     20 import android.content.Context;
     21 import android.util.AttributeSet;
     22 import android.webkit.WebSettings;
     23 import android.webkit.WebView;
     24 
     25 import org.connectbot.HelpActivity;
     26 
     27 /**
     28  * @author Kenny Root
     29  *
     30  */
     31 public class HelpTopicView extends WebView {
     32   public HelpTopicView(Context context, AttributeSet attrs, int defStyle) {
     33     super(context, attrs, defStyle);
     34     initialize();
     35   }
     36 
     37   public HelpTopicView(Context context, AttributeSet attrs) {
     38     super(context, attrs);
     39     initialize();
     40   }
     41 
     42   public HelpTopicView(Context context) {
     43     super(context);
     44     initialize();
     45   }
     46 
     47   private void initialize() {
     48     WebSettings wSet = getSettings();
     49     //wSet.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
     50     wSet.setUseWideViewPort(false);
     51   }
     52 
     53   public HelpTopicView setTopic(String topic) {
     54     String path =
     55         String.format("file:///android_asset/%s/%s%s", HelpActivity.HELPDIR, topic,
     56             HelpActivity.SUFFIX);
     57     loadUrl(path);
     58 
     59     computeScroll();
     60 
     61     return this;
     62   }
     63 }
     64