2010-08-17 22:01:10 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 The IDEAL Group
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package com.fsck.k9.web;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.text.Html;
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.view.View;
|
|
|
|
import android.webkit.WebSettings;
|
|
|
|
import android.webkit.WebView;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
2010-08-17 22:48:55 -04:00
|
|
|
public class AccessibleWebView extends TextView
|
|
|
|
{
|
2010-09-02 22:15:57 -04:00
|
|
|
private Context mContext;
|
|
|
|
private String mHtmlSource;
|
|
|
|
private WebView mDummyWebView;
|
2010-08-17 22:01:10 -04:00
|
|
|
|
2010-08-17 22:48:55 -04:00
|
|
|
public AccessibleWebView(Context context)
|
|
|
|
{
|
2010-08-17 22:01:10 -04:00
|
|
|
super(context);
|
2010-09-02 22:15:57 -04:00
|
|
|
init(context);
|
2010-08-17 22:01:10 -04:00
|
|
|
}
|
|
|
|
|
2010-08-17 22:48:55 -04:00
|
|
|
public AccessibleWebView(Context context, AttributeSet attributes)
|
|
|
|
{
|
2010-08-17 22:01:10 -04:00
|
|
|
super(context, attributes);
|
2010-09-02 22:15:57 -04:00
|
|
|
init(context);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void init(Context context)
|
|
|
|
{
|
|
|
|
mContext = context;
|
|
|
|
mDummyWebView = new WebView(context);
|
2010-08-17 22:01:10 -04:00
|
|
|
setFocusable(true);
|
|
|
|
setFocusableInTouchMode(true);
|
2010-08-17 22:48:55 -04:00
|
|
|
setOnClickListener(new OnClickListener()
|
|
|
|
{
|
2010-08-17 22:01:10 -04:00
|
|
|
@Override
|
2010-08-17 22:48:55 -04:00
|
|
|
public void onClick(View arg0)
|
|
|
|
{
|
2010-08-17 22:01:10 -04:00
|
|
|
diveIn();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2010-08-17 22:48:55 -04:00
|
|
|
public void loadData(String data, String mimeType, String encoding)
|
|
|
|
{
|
2010-09-02 22:15:57 -04:00
|
|
|
mHtmlSource = data;
|
|
|
|
this.setText(Html.fromHtml(mHtmlSource, null, null));
|
2010-08-17 22:01:10 -04:00
|
|
|
}
|
|
|
|
|
2010-08-17 22:48:55 -04:00
|
|
|
public WebSettings getSettings()
|
|
|
|
{
|
2010-09-02 22:15:57 -04:00
|
|
|
return mDummyWebView.getSettings();
|
2010-08-17 22:01:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public void loadDataWithBaseURL(String baseUrl, String data, String mimeType, String encoding,
|
2010-08-17 22:48:55 -04:00
|
|
|
String historyUrl)
|
|
|
|
{
|
2010-09-02 22:15:57 -04:00
|
|
|
mHtmlSource = data;
|
|
|
|
this.setText(Html.fromHtml(mHtmlSource, null, null));
|
2010-08-17 22:01:10 -04:00
|
|
|
}
|
|
|
|
|
2010-08-17 22:48:55 -04:00
|
|
|
public boolean zoomIn()
|
|
|
|
{
|
|
|
|
if (getTextSize() < 100)
|
|
|
|
{
|
2010-08-17 22:01:10 -04:00
|
|
|
setTextSize(getTextSize() + 5);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-08-17 22:48:55 -04:00
|
|
|
public boolean zoomOut()
|
|
|
|
{
|
|
|
|
if (getTextSize() > 5)
|
|
|
|
{
|
2010-08-17 22:01:10 -04:00
|
|
|
setTextSize(getTextSize() - 5);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-08-17 22:48:55 -04:00
|
|
|
private void diveIn()
|
|
|
|
{
|
2010-08-17 22:01:10 -04:00
|
|
|
Intent i = new Intent();
|
2010-09-02 22:15:57 -04:00
|
|
|
i.setClass(mContext, AccessibleEmailContentActivity.class);
|
|
|
|
i.putExtra("content", mHtmlSource);
|
|
|
|
mContext.startActivity(i);
|
2010-08-17 22:01:10 -04:00
|
|
|
}
|
|
|
|
}
|