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