/**
* Shadow - Anonymous web browser for Android devices
* Copyright (C) 2009 Connell Gauld
*
* Thanks to University of Cambridge,
* Alastair Beresford and Andrew Rice
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package uk.ac.cam.cl.dtg.android.tor.Shadow;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.http.client.ClientProtocolException;
import uk.ac.cam.cl.dtg.android.tor.TorProxyLib.ITorProxyControl;
import uk.ac.cam.cl.dtg.android.tor.TorProxyLib.TorProxyLib;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.SearchManager;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.PaintDrawable;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.preference.PreferenceManager;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.webkit.PluginData;
import android.webkit.UrlInterceptHandler;
import android.webkit.UrlInterceptRegistry;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.webkit.CacheManager.CacheResult;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
/**
* The main browser activity
* @author Connell Gauld
*
*/
public class Shadow extends Activity implements UrlInterceptHandler,
OnClickListener {
// TorProxy service
private ITorProxyControl mControlService = null;
private final IntentFilter torStatusFilter = new IntentFilter(
TorProxyLib.STATUS_CHANGE_INTENT);
private AnonProxy mAnonProxy = null;
// UI elements
private ShadowWebView mWebView = null;
private LinearLayout mNoTorLayout = null;
private LinearLayout mWebLayout = null;
private Button mStartTor = null;
private LinearLayout mCookieIcon = null;
private TextView mTorStatus = null;
// Misc
private Drawable mGenericFavicon = null;
private boolean mInLoad = false;
private Menu mMenu = null;
private boolean mLastIsTorActive = true;
private CookieManager mCookieManager = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set up title bar of window
this.requestWindowFeature(Window.FEATURE_LEFT_ICON);
this.requestWindowFeature(Window.FEATURE_RIGHT_ICON);
this.requestWindowFeature(Window.FEATURE_PROGRESS);
this.requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
// Allow search to start by just typing
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
setContentView(R.layout.main);
// Register to capture all URLs in the WebView
UrlInterceptRegistry.registerHandler(this);
mCookieManager = CookieManager.getInstance(this);
mAnonProxy = new AnonProxy();
// Grab UI elements
mWebView = (ShadowWebView) findViewById(R.id.WebView);
mNoTorLayout = (LinearLayout) findViewById(R.id.NoTorLayout);
mWebLayout = (LinearLayout) findViewById(R.id.WebLayout);
mStartTor = (Button) findViewById(R.id.StartTor);
mCookieIcon = (LinearLayout) findViewById(R.id.CookieIcon);
mTorStatus = (TextView) findViewById(R.id.torStatus);
// Set up UI elements
mStartTor.setOnClickListener(this);
mWebView.setWebViewClient(mWebViewClient);
mWebView.setWebChromeClient(mWebViewChrome);
mWebView.getSettings().setBuiltInZoomControls(true);
mWebView.getSettings().setLoadsImagesAutomatically(true);
mWebView.setBlockedCookiesView(mCookieIcon);
mCookieIcon.setOnClickListener(this);
// Misc
mGenericFavicon = getResources().getDrawable(
R.drawable.app_web_browser_sm);
// TODO - properly handle initial Intents
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(this);
String starturl = prefs.getString(getString(R.string.pref_homepage),
getString(R.string.default_homepage));
mCookieManager.setBehaviour(prefs.getString("pref_cookiebehaviour",
"whitelist"));
Intent i = getIntent();
if (i != null) {
if (Intent.ACTION_VIEW.equals(i.getAction())) {
onNewIntent(i);
return;
}
}
loadUrl(starturl);
}
// Service connection to TorProxy service
private ServiceConnection mSvcConn = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mControlService = ITorProxyControl.Stub.asInterface(service);
updateTorStatus();
}
@Override
public void onServiceDisconnected(ComponentName name) {
mControlService = null;
updateTorStatus();
}
};
/*
* Set the title bar icon to the supplied bitmap. Yoinked from the Android
* browser
*/
private void setFavicon(Bitmap icon) {
Drawable[] array = new Drawable[2];
PaintDrawable p = new PaintDrawable(Color.WHITE);
p.setCornerRadius(3f);
array[0] = p;
if (icon == null) {
array[1] = mGenericFavicon;
} else {
array[1] = new BitmapDrawable(icon);
}
LayerDrawable d = new LayerDrawable(array);
d.setLayerInset(1, 2, 2, 2, 2);
getWindow().setFeatureDrawable(Window.FEATURE_LEFT_ICON, d);
}
/**
* Yoinked from android source
*
* @param url
* @return
*/
private static String buildTitleUrl(String url) {
String titleUrl = null;
if (url != null) {
try {
// parse the url string
URL urlObj = new URL(url);
if (urlObj != null) {
titleUrl = "";
String protocol = urlObj.getProtocol();
String host = urlObj.getHost();
if (host != null && 0 < host.length()) {
titleUrl = host;
if (protocol != null) {
// if a secure site, add an "https://" prefix!
if (protocol.equalsIgnoreCase("https")) {
titleUrl = protocol + "://" + host;
}
}
}
}
} catch (MalformedURLException e) {
}
}
return titleUrl;
}
static final Pattern ACCEPTED_URI_SCHEMA = Pattern.compile("(?i)"
+ // switch on case insensitive matching
"("
+ // begin group for schema
"(?:http|https|file):\\/\\/"
+ "|(?:data|about|content|javascript):" + ")" + "(.*)");
private String smartUrlFilter(String url) {
String inUrl = url.trim();
boolean hasSpace = inUrl.indexOf(' ') != -1;
Matcher matcher = ACCEPTED_URI_SCHEMA.matcher(inUrl);
if (matcher.matches()) {
if (hasSpace) {
inUrl = inUrl.replace(" ", "%20");
}
// force scheme to lowercase
String scheme = matcher.group(1);
String lcScheme = scheme.toLowerCase();
if (!lcScheme.equals(scheme)) {
return lcScheme + matche
没有合适的资源?快使用搜索试试~ 我知道了~
小程序源码 聊天通讯 TorProxy和Shadow开源项目.rar
共244个文件
svn-base:96个
all-wcprops:40个
entries:40个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 39 浏览量
2023-03-29
19:50:48
上传
评论
收藏 6.5MB RAR 举报
温馨提示
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,本人不对所涉及的版权问题或内容负法律责任。如有侵权,请举报或通知本人删除。
资源推荐
资源详情
资源评论
收起资源包目录
小程序源码 聊天通讯 TorProxy和Shadow开源项目.rar (244个子文件)
all-wcprops 3KB
all-wcprops 1KB
all-wcprops 1011B
all-wcprops 1010B
all-wcprops 704B
all-wcprops 641B
all-wcprops 583B
all-wcprops 583B
all-wcprops 482B
all-wcprops 474B
all-wcprops 474B
all-wcprops 462B
all-wcprops 365B
all-wcprops 285B
all-wcprops 250B
all-wcprops 222B
all-wcprops 133B
all-wcprops 126B
all-wcprops 126B
all-wcprops 122B
all-wcprops 122B
all-wcprops 114B
all-wcprops 114B
all-wcprops 110B
all-wcprops 110B
all-wcprops 107B
all-wcprops 107B
all-wcprops 105B
all-wcprops 105B
all-wcprops 103B
all-wcprops 103B
all-wcprops 100B
all-wcprops 100B
all-wcprops 100B
all-wcprops 99B
all-wcprops 97B
all-wcprops 97B
all-wcprops 97B
all-wcprops 97B
all-wcprops 86B
resources.ap_ 46KB
resources.ap_ 27KB
TorProxy.apk 970KB
Shadow.apk 83KB
.classpath 434B
.classpath 339B
COPYING 18KB
classes.dex 1.91MB
classes.dex 72KB
entries 3KB
entries 2KB
entries 1KB
entries 1KB
entries 1KB
entries 896B
entries 879B
entries 705B
entries 698B
entries 687B
entries 669B
entries 617B
entries 541B
entries 407B
entries 391B
entries 376B
entries 291B
entries 286B
entries 271B
entries 271B
entries 265B
entries 264B
entries 264B
entries 262B
entries 260B
entries 260B
entries 252B
entries 252B
entries 252B
entries 248B
entries 248B
entries 247B
entries 245B
entries 245B
entries 241B
entries 241B
entries 241B
entries 238B
entries 237B
entries 229B
home 2KB
error.htm 3KB
about.htm 2KB
about.htm 2KB
unknownhosterror.htm 2KB
sslerror.htm 2KB
Shadow.java 20KB
SSLSocketFactory.java 15KB
AnonProxy.java 10KB
PostProcessor.java 8KB
CookieManager.java 7KB
共 244 条
- 1
- 2
- 3
资源评论
荣华富贵8
- 粉丝: 215
- 资源: 7653
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- IPinfo API 的官方 Java 库(IP 地理位置和其他类型的 IP 数据).zip
- IntelliJ IDEA 针对 Square 的 Java 和 Android 项目的代码样式设置 .zip
- Gradle,Maven 插件将 Java 应用程序打包为原生 Windows、MacOS 或 Linux 可执行文件并为其创建安装程序 .zip
- Google Maps API Web 服务的 Java 客户端库.zip
- Google Java 核心库.zip
- GitBook 教授 Javascript 编程基础知识.zip
- Generation.org 开发的 JAVA 模块练习.zip
- FastDFS Java 客户端 SDK.zip
- etcd java 客户端.zip
- Esercizi di informatica!执行计划,metti alla prova!.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功