link of keywords hide and highlight can be set
This commit is contained in:
parent
278e169477
commit
4d6588f728
|
@ -2,7 +2,7 @@
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.hty.browser"
|
package="com.hty.browser"
|
||||||
android:versionCode="3"
|
android:versionCode="3"
|
||||||
android:versionName="3.10">
|
android:versionName="3.11">
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="16"
|
android:minSdkVersion="16"
|
||||||
|
|
|
@ -9,17 +9,17 @@ p { text-indent:2em; }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h2 align=center><img src=logo.png><br>海天鹰浏览器 V3.10</h2>
|
<h2 align=center><img src=logo.png><br>海天鹰浏览器 V3.11</h2>
|
||||||
<p>内置扩展的浏览器。</p>
|
<p>内置扩展的浏览器。</p>
|
||||||
<p>扩展:[国产]高亮,广告图片自定义过滤。</p>
|
<p>扩展:链接关键字过滤,链接关键字高亮,图片自定义过滤,视频独立播放。</p>
|
||||||
<p>作者:黄颖</p>
|
<p>作者:黄颖</p>
|
||||||
<p>主页:<a href="https://github.com/sonichy" target="_blank">https://github.com/sonichy</a></p>
|
<p>源码:<a href="https://github.com/sonichy/Android_HTYBrowser" target="_blank">https://github.com/sonichy/Android_HTYBrowser</a></p>
|
||||||
<p>E-mail:sonichy@163.com</p>
|
<p>E-mail:sonichy@163.com</p>
|
||||||
<p>QQ:84429027</p>
|
|
||||||
<h3>参考:</h3>
|
<h3>参考:</h3>
|
||||||
<p><a href="https://www.jianshu.com/p/6e38e1ef203a" target="_blank">Android WebView 三种文件下载方式</a></p>
|
<p><a href="https://www.jianshu.com/p/6e38e1ef203a" target="_blank">Android WebView 三种文件下载方式</a></p>
|
||||||
<p><a href="https://blog.csdn.net/lowprofile_coding/article/details/77852131" target="_blank">自动安装apk包</a></p>
|
<p><a href="https://blog.csdn.net/lowprofile_coding/article/details/77852131" target="_blank">自动安装apk包</a></p>
|
||||||
<h3>更新日志:</h3>
|
<h3>更新日志:</h3>
|
||||||
|
<h3>V3.11 (2019-02-13)</h3><ol><li>链接中的关键字屏蔽、高亮可设置。</li></ol>
|
||||||
<h3>V3.10 (2019-02-10)</h3><ol><li>增加:收藏前修改,收藏后修改,修改校验。</li></ol>
|
<h3>V3.10 (2019-02-10)</h3><ol><li>增加:收藏前修改,收藏后修改,修改校验。</li></ol>
|
||||||
<h3>V3.9 (2018-12-20)</h3><ol><li>视频独立播放JS读不到iframe里的video,使用跳转iframe代替。</li></ol>
|
<h3>V3.9 (2018-12-20)</h3><ol><li>视频独立播放JS读不到iframe里的video,使用跳转iframe代替。</li></ol>
|
||||||
<h3>V3.8 (2018-07-14)</h3><ol><li>增加定位权限。</li></ol>
|
<h3>V3.8 (2018-07-14)</h3><ol><li>增加定位权限。</li></ol>
|
||||||
|
|
|
@ -226,10 +226,6 @@ public class MainActivity extends Activity {
|
||||||
public void onPageFinished(WebView view, String url) {
|
public void onPageFinished(WebView view, String url) {
|
||||||
super.onPageFinished(view, url);
|
super.onPageFinished(view, url);
|
||||||
pgb1.setVisibility(View.INVISIBLE);
|
pgb1.setVisibility(View.INVISIBLE);
|
||||||
String js = "";
|
|
||||||
// 链接关键字链接高亮、屏蔽
|
|
||||||
js = "javascript:var a=document.getElementsByTagName('a');for(var i=0;i<a.length;i++){if(a[i].textContent.indexOf('国产')!=-1){a[i].style.color='white';a[i].style.backgroundColor='#DA3434';}if(a[i].textContent.indexOf('习近平')!=-1 || a[i].textContent.indexOf('总书记')!=-1){a[i].textContent='';}}";
|
|
||||||
view.loadUrl(js);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -280,24 +276,30 @@ public class MainActivity extends Activity {
|
||||||
public void onProgressChanged(WebView view, int newProgress) {
|
public void onProgressChanged(WebView view, int newProgress) {
|
||||||
super.onProgressChanged(view, newProgress);
|
super.onProgressChanged(view, newProgress);
|
||||||
pgb1.setProgress(newProgress);
|
pgb1.setProgress(newProgress);
|
||||||
/*
|
|
||||||
if(!isFullScreen) {
|
|
||||||
if (newProgress == 100) {
|
|
||||||
pgb1.setVisibility(View.INVISIBLE);
|
|
||||||
} else {
|
|
||||||
pgb1.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if(sharedPreferences.getBoolean("switch_adBlock",true)){
|
if(sharedPreferences.getBoolean("switch_adBlock",true)){
|
||||||
ADBlock();
|
ADBlock();
|
||||||
}
|
}
|
||||||
if(sharedPreferences.getBoolean("switch_iframeBlock",false)) {
|
if(sharedPreferences.getBoolean("switch_iframeBlock",false)) {
|
||||||
//Log.e("line292", "progress:" + newProgress);
|
|
||||||
if (!view.getUrl().contains("baidu.com")){
|
if (!view.getUrl().contains("baidu.com")){
|
||||||
iframeBlock();
|
iframeBlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 链接关键字屏蔽
|
||||||
|
if(sharedPreferences.getBoolean("switch_filter",false)){
|
||||||
|
String sf = sharedPreferences.getString("filter","");
|
||||||
|
if(!sf.equals("")) {
|
||||||
|
String js = "javascript:var s='"+sf+"';var sl=s.split(';');var a=document.getElementsByTagName('a');for(var i=0;i<a.length;i++){for(var j=0;j<sl.length;j++){if(a[i].textContent.indexOf(sl[j])!=-1){a[i].textContent='';}}}";
|
||||||
|
view.loadUrl(js);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 链接关键字高亮
|
||||||
|
if(sharedPreferences.getBoolean("switch_highlight",false)){
|
||||||
|
String shl = sharedPreferences.getString("highlight","");
|
||||||
|
if(!shl.equals("")) {
|
||||||
|
String js = "javascript:var s='"+shl+"';var sl=s.split(';');var a=document.getElementsByTagName('a');for(var i=0;i<a.length;i++){for(var j=0;j<sl.length;j++){if(a[i].textContent.indexOf(sl[j])!=-1){a[i].style.color='white';a[i].style.backgroundColor='#DA3434';}}}";
|
||||||
|
view.loadUrl(js);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取网页标题
|
// 获取网页标题
|
||||||
|
@ -534,10 +536,9 @@ public class MainActivity extends Activity {
|
||||||
private class MyWebViewDownLoadListener implements DownloadListener {
|
private class MyWebViewDownLoadListener implements DownloadListener {
|
||||||
@Override
|
@Override
|
||||||
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
|
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
|
||||||
// Uri uri = Uri.parse(url);
|
Log.e("Download", url);
|
||||||
// Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
//if(!url.contains("baidu.com"))
|
||||||
// startActivity(intent);
|
downloadBySystem(url, "", "");
|
||||||
downloadBySystem(url,"","");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -727,7 +728,6 @@ public class MainActivity extends Activity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
// if (this.getResources().getConfiguration().orientation ==
|
// if (this.getResources().getConfiguration().orientation ==
|
||||||
// Configuration.ORIENTATION_LANDSCAPE) {
|
// Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
|
@ -813,7 +813,6 @@ public class MainActivity extends Activity {
|
||||||
helper.insert(values);
|
helper.insert(values);
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(getApplicationContext(), "网址已存在", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getApplicationContext(), "网址已存在", Toast.LENGTH_SHORT).show();
|
||||||
IMM.hideSoftInputFromWindow(ET_title.getWindowToken(), 0);
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
//关闭
|
//关闭
|
||||||
|
@ -821,6 +820,7 @@ public class MainActivity extends Activity {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
|
IMM.hideSoftInputFromWindow(ET_title.getWindowToken(), 0);
|
||||||
} else {
|
} else {
|
||||||
if (stitle.equals("")){
|
if (stitle.equals("")){
|
||||||
ET_title.setError("标题不能为空!");
|
ET_title.setError("标题不能为空!");
|
||||||
|
|
|
@ -8,30 +8,38 @@ import android.preference.PreferenceActivity;
|
||||||
|
|
||||||
public class SettingsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener{
|
public class SettingsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener{
|
||||||
|
|
||||||
private EditTextPreference ETP_homepage;
|
private EditTextPreference ETP_homepage, ETP_filter, ETP_highlight;
|
||||||
SharedPreferences sharedPreferences;
|
SharedPreferences SP;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
addPreferencesFromResource(R.xml.preference);
|
addPreferencesFromResource(R.xml.preference);
|
||||||
ETP_homepage = (EditTextPreference) findPreference("homepage");
|
ETP_homepage = (EditTextPreference) findPreference("homepage");
|
||||||
sharedPreferences = getPreferenceScreen().getSharedPreferences();
|
ETP_filter = (EditTextPreference) findPreference("filter");
|
||||||
sharedPreferences.registerOnSharedPreferenceChangeListener(this);
|
ETP_highlight = (EditTextPreference) findPreference("highlight");
|
||||||
|
SP = getPreferenceScreen().getSharedPreferences();
|
||||||
|
SP.registerOnSharedPreferenceChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
// Activity启动时,修改列表项目值
|
// 启动时显示
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
ETP_homepage.setSummary(sharedPreferences.getString("homepage","http://www.baidu.com"));
|
ETP_homepage.setSummary(SP.getString("homepage","http://www.baidu.com"));
|
||||||
|
ETP_filter.setSummary(SP.getString("filter",""));
|
||||||
|
ETP_highlight.setSummary(SP.getString("highlight",""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
// 编辑后确定,修改列表项目值
|
// 修改后显示
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
if(key.equals("homepage")){
|
if(key.equals("homepage")){
|
||||||
ETP_homepage.setSummary(sharedPreferences.getString(key,""));
|
ETP_homepage.setSummary(sharedPreferences.getString(key,""));
|
||||||
|
}else if(key.equals("filter")){
|
||||||
|
ETP_filter.setSummary(sharedPreferences.getString(key,""));
|
||||||
|
}else if(key.equals("highlight")){
|
||||||
|
ETP_highlight.setSummary(sharedPreferences.getString(key,""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,53 @@
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:title="设置">
|
android:title="设置">
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:key="homepage"
|
android:key="homepage"
|
||||||
android:defaultValue="http://www.baidu.com"
|
android:defaultValue="http://www.baidu.com"
|
||||||
android:summary="http://www.baidu.com"
|
android:summary="http://www.baidu.com"
|
||||||
android:title="主页"
|
android:title="主页"
|
||||||
android:background="#282828"/>
|
android:textColor="@android:color/holo_blue_dark"/>
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="switch_adBlock"
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:title="广告过滤"/>
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="switch_iframeBlock"
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:title="iframe过滤"/>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:title="关键字过滤">
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="switch_adBlock"
|
android:key="switch_filter"
|
||||||
android:defaultValue="true"
|
|
||||||
android:title="广告过滤"/>
|
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="switch_iframeBlock"
|
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:title="iframe过滤"/>
|
android:title="过滤开关"/>
|
||||||
|
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="filter"
|
||||||
|
android:title="过滤文本"
|
||||||
|
android:summary="关键字之间用;间隔"
|
||||||
|
android:textColor="@android:color/holo_blue_dark"/>
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:title="关键字高亮">
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="switch_highlight"
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:title="高亮开关"/>
|
||||||
|
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="highlight"
|
||||||
|
android:title="高亮文本"
|
||||||
|
android:summary="关键字之间用;间隔"
|
||||||
|
android:textColor="@android:color/holo_blue_dark"/>
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
Loading…
Reference in New Issue