mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-26 01:28:50 -05:00
110 lines
2.8 KiB
Java
110 lines
2.8 KiB
Java
/*
|
|
* 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.view;
|
|
|
|
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;
|
|
|
|
import com.fsck.k9.activity.AccessibleEmailContentActivity;
|
|
|
|
public class AccessibleWebView extends TextView
|
|
{
|
|
private Context mContext;
|
|
private String mHtmlSource;
|
|
private WebView mDummyWebView;
|
|
|
|
public AccessibleWebView(Context context)
|
|
{
|
|
super(context);
|
|
init(context);
|
|
}
|
|
|
|
public AccessibleWebView(Context context, AttributeSet attributes)
|
|
{
|
|
super(context, attributes);
|
|
init(context);
|
|
}
|
|
|
|
private void init(Context context)
|
|
{
|
|
mContext = context;
|
|
mDummyWebView = new WebView(context);
|
|
setFocusable(true);
|
|
setFocusableInTouchMode(true);
|
|
setOnClickListener(new OnClickListener()
|
|
{
|
|
@Override
|
|
public void onClick(View arg0)
|
|
{
|
|
diveIn();
|
|
}
|
|
});
|
|
}
|
|
|
|
public void loadData(String data, String mimeType, String encoding)
|
|
{
|
|
mHtmlSource = data;
|
|
this.setText(Html.fromHtml(mHtmlSource, null, null));
|
|
}
|
|
|
|
public WebSettings getSettings()
|
|
{
|
|
return mDummyWebView.getSettings();
|
|
}
|
|
|
|
public void loadDataWithBaseURL(String baseUrl, String data, String mimeType, String encoding,
|
|
String historyUrl)
|
|
{
|
|
mHtmlSource = data;
|
|
this.setText(Html.fromHtml(mHtmlSource, null, null));
|
|
}
|
|
|
|
public boolean zoomIn()
|
|
{
|
|
if (getTextSize() < 100)
|
|
{
|
|
setTextSize(getTextSize() + 5);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public boolean zoomOut()
|
|
{
|
|
if (getTextSize() > 5)
|
|
{
|
|
setTextSize(getTextSize() - 5);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private void diveIn()
|
|
{
|
|
Intent i = new Intent();
|
|
i.setClass(mContext, AccessibleEmailContentActivity.class);
|
|
i.putExtra("content", mHtmlSource);
|
|
mContext.startActivity(i);
|
|
}
|
|
}
|