Home | History | Annotate | Download | only in preferences
      1 /*
      2  * Copyright (C) 2011 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.browser.preferences;
     18 
     19 import android.content.Context;
     20 import android.text.TextUtils;
     21 import android.util.AttributeSet;
     22 
     23 import com.android.browser.BrowserSettings;
     24 import com.android.browser.BrowserWebView;
     25 import com.android.browser.WebViewProperties;
     26 
     27 public class InvertedContrastPreview extends WebViewPreview {
     28 
     29     static final String IMG_ROOT = "content://com.android.browser.home/res/raw/";
     30     static final String[] THUMBS = new String[] {
     31         "thumb_google",
     32         "thumb_amazon",
     33         "thumb_cnn",
     34         "thumb_espn",
     35         "", // break
     36         "thumb_bbc",
     37         "thumb_nytimes",
     38         "thumb_weatherchannel",
     39         "thumb_picasa",
     40     };
     41 
     42     String mHtml;
     43 
     44     public InvertedContrastPreview(
     45             Context context, AttributeSet attrs, int defStyle) {
     46         super(context, attrs, defStyle);
     47     }
     48 
     49     public InvertedContrastPreview(Context context, AttributeSet attrs) {
     50         super(context, attrs);
     51     }
     52 
     53     public InvertedContrastPreview(Context context) {
     54         super(context);
     55     }
     56 
     57     @Override
     58     protected void init(Context context) {
     59         super.init(context);
     60         StringBuilder builder = new StringBuilder("<html><body style=\"width: 1000px\">");
     61         for (String thumb : THUMBS) {
     62             if (TextUtils.isEmpty(thumb)) {
     63                 builder.append("<br />");
     64                 continue;
     65             }
     66             builder.append("<img src=\"");
     67             builder.append(IMG_ROOT);
     68             builder.append(thumb);
     69             builder.append("\" />&nbsp;");
     70         }
     71         builder.append("</body></html>");
     72         mHtml = builder.toString();
     73     }
     74 
     75     @Override
     76     protected void updatePreview(boolean forceReload) {
     77     }
     78 
     79 }
     80