增加添加到主页
This commit is contained in:
parent
10980bd750
commit
79bdf2b7c8
|
@ -2,7 +2,7 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.hty.browser"
|
||||
android:versionCode="4"
|
||||
android:versionName="4.35">
|
||||
android:versionName="4.36">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 查询网络状态权限 -->
|
||||
|
|
|
@ -9,7 +9,7 @@ p { text-indent:2em; }
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h2 align=center><img src=logo.png><br>海天鹰浏览器 V4.35</h2>
|
||||
<h2 align=center><img src=logo.png><br>海天鹰浏览器 V4.36</h2>
|
||||
<p>内置扩展的浏览器。</p>
|
||||
<p>扩展:链接关键字过滤,链接关键字高亮,图片自定义过滤,视频独立播放。</p>
|
||||
<p>作者:海天鹰</p>
|
||||
|
@ -23,6 +23,7 @@ p { text-indent:2em; }
|
|||
<p><a href="https://stackoverflow.com/questions/3462582/display-the-android-webviews-favicon" target="_blank">获取网页图标</a></p>
|
||||
<p><a href="https://www.jianshu.com/p/c9a18050a249" target="_blank">字符串转Bitmap</a></p>
|
||||
<h3>更新日志:</h3>
|
||||
<h3>V4.36 (2024-03-25)</h3><ol><li>增加添加网址到主页。</li></ol>
|
||||
<h3>V4.35 (2024-03-16)</h3><ol><li>增加自定义主页。</li></ol>
|
||||
<h3>V4.34 (2024-01-30)</h3><ol><li>增加hash链接转magnet。</li></ol>
|
||||
<h3>V4.33 (2024-01-19)</h3><ol><li>收藏夹分类:使用下拉列表代替单选组。</li></ol>
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<title>主页</title>
|
||||
</head>
|
||||
<style>
|
||||
div { user-select:none; }
|
||||
a { text-decoration:none; }
|
||||
span { display:inline-block; margin:5px; }
|
||||
a, img { -webkit-user-drag:none; }
|
||||
|
@ -56,7 +57,7 @@ document.addEventListener('click', function(e){
|
|||
function genList() {
|
||||
json = JSON.parse(localStorage.webfav);
|
||||
list.innerHTML = '';
|
||||
for (var i=0; i<json.length; i++) {
|
||||
for (var i=0; i<json.length; i++) {
|
||||
var a = document.createElement('a');
|
||||
a.href = json[i].website;
|
||||
a.target = '_blank';
|
||||
|
@ -164,14 +165,28 @@ menu_delete.addEventListener('click', function(){
|
|||
});
|
||||
|
||||
button_confirm.addEventListener('click', function(e){
|
||||
if (title.value == '') {
|
||||
alert('标题不能为空');
|
||||
return;
|
||||
}
|
||||
if (website.value == '') {
|
||||
alert('网址不能为空');
|
||||
return;
|
||||
}
|
||||
for (var i=0; i<json.length; i++) {
|
||||
if (json[i].website == website.value){
|
||||
alert('网址已经存在!');
|
||||
return;
|
||||
}
|
||||
}
|
||||
dialog.close();
|
||||
if (type1 == 0) {
|
||||
if (type1 == 0) {//添加
|
||||
json = JSON.parse(localStorage.webfav);
|
||||
json.push({
|
||||
'title': title.value,
|
||||
'website': website.value
|
||||
title: title.value,
|
||||
website: website.value
|
||||
});
|
||||
} else if (type1 == 1) {
|
||||
} else if (type1 == 1) {//修改
|
||||
json[id].title = title.value;
|
||||
json[id].website = website.value;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ import android.view.View;
|
|||
import android.view.View.OnCreateContextMenuListener;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
|
@ -112,7 +114,7 @@ public class FavoriteActivity extends Activity {
|
|||
String title = ((TextView) info.targetView.findViewById(R.id.title)).getText().toString();
|
||||
menu.setHeaderIcon(R.drawable.link);
|
||||
menu.setHeaderTitle(title);
|
||||
String[] sm = { "在新窗口中打开", "复制链接", "分享", "修改", "删除" };
|
||||
String[] sm = { "在新窗口中打开", "复制链接", "分享", "修改", "删除", "添加到主页" };
|
||||
for (int i=0; i<sm.length; i++) {
|
||||
menu.add(0, i, i, sm[i]);
|
||||
}
|
||||
|
@ -408,6 +410,15 @@ public class FavoriteActivity extends Activity {
|
|||
} else
|
||||
Toast.makeText(getApplicationContext(), "删除失败", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
case 5:
|
||||
WebView webView = new WebView(FavoriteActivity.this);
|
||||
WebSettings webSettings = webView.getSettings();
|
||||
webSettings.setJavaScriptEnabled(true);
|
||||
webSettings.setDomStorageEnabled(true);
|
||||
webView.loadUrl("file:///android_asset/home.htm");
|
||||
String js = "javascript:window.onload=function(){var json=JSON.parse(localStorage.webfav);for(var i=0;i<json.length;i++){if(json[i].website=='" + url + "'){alert('网址已经存在!');return;}}json.push({title: '" + title + "',website:'" + url + "'});localStorage.webfav=JSON.stringify(json);}";
|
||||
webView.loadUrl(js);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -683,7 +683,7 @@ public class MainActivity extends Activity {
|
|||
}
|
||||
|
||||
private void MenuDialog() {
|
||||
String[] items = { "新建窗口", "关闭当前窗口", "收藏当前页", "收藏夹", "查找", "分享", "网页信息", "视频独立播放", "视频截图", "视频在播放器中打开", "资源探查", "查看源码", "保存", "全屏", "广告屏蔽", "清除当前页面缓存", "设置", "检查更新", "关于", "退出", "ExpandableListView" };
|
||||
String[] items = { "新建窗口", "关闭当前窗口", "收藏当前页", "收藏夹", "查找", "分享", "网页信息", "视频独立播放", "视频截图", "视频在播放器中打开", "资源探查", "查看源码", "保存", "全屏", "广告屏蔽", "清除当前页面缓存", "设置", "检查更新", "关于", "退出", "ExpandableListView", "添加到主页" };
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("菜单");
|
||||
//builder.setIcon(android.R.drawable.ic_menu_preferences);
|
||||
|
@ -882,7 +882,7 @@ public class MainActivity extends Activity {
|
|||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Date date = new Date();
|
||||
SimpleDateFormat SDF = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
SimpleDateFormat SDF = new SimpleDateFormat("yyyyMMddHHmmss", Locale.getDefault());
|
||||
String stime = SDF.format(date);
|
||||
Uri.parse(MediaStore.Images.Media.insertImage(getApplicationContext().getContentResolver(), bitmap, stime, "海天鹰浏览器视频截图"));
|
||||
}
|
||||
|
@ -985,6 +985,15 @@ public class MainActivity extends Activity {
|
|||
intent = new Intent(MainActivity.this, FavoriteActivity1.class);
|
||||
startActivityForResult(intent, 0);
|
||||
break;
|
||||
case 21:
|
||||
WebView webView = new WebView(MainActivity.this);
|
||||
WebSettings webSettings = webView.getSettings();
|
||||
webSettings.setJavaScriptEnabled(true);
|
||||
webSettings.setDomStorageEnabled(true);
|
||||
webView.loadUrl("file:///android_asset/home.htm");
|
||||
js = "javascript:window.onload=function(){var json=JSON.parse(localStorage.webfav);for(var i=0;i<json.length;i++){if(json[i].website=='" + urln + "'){alert('网址已经存在!');return;}}json.push({title: '" + ptitle + "',website:'" + urln + "'});localStorage.webfav=JSON.stringify(json);}";
|
||||
webView.loadUrl(js);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1281,23 +1290,11 @@ public class MainActivity extends Activity {
|
|||
@Override
|
||||
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
|
||||
super.onReceivedError(view, errorCode, description, failingUrl);
|
||||
//Toast.makeText(getApplicationContext(), "ReceivedError:" + errorCode, Toast.LENGTH_SHORT).show();
|
||||
//if (isNetworkConnected()) {
|
||||
switch (errorCode) {
|
||||
// case WebViewClient.ERROR_HOST_LOOKUP: // 找不到主机,跳转百度搜索
|
||||
// Log.e(Thread.currentThread().getStackTrace()[2] + "", failingUrl);
|
||||
// String url = "http://m.baidu.com/s?word=" + urlo;
|
||||
// editText_url.setText(url);
|
||||
// view.loadUrl(url);
|
||||
// urln = url;
|
||||
// break;
|
||||
default:
|
||||
Log.e(Thread.currentThread().getStackTrace()[2] + "", failingUrl);
|
||||
view.loadDataWithBaseURL(failingUrl, "<html><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\"/><title>" + failingUrl + "</title><body><h1>无法访问此网站</h1><p>" + failingUrl + " 无法访问,因为:<br>" + description + "</p></body></html>", "text/html", "utf-8", "");
|
||||
}
|
||||
//} else {
|
||||
// view.loadDataWithBaseURL("", "<html><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\"/><title>网络未连接</title><style>h1{font-size:10vw;margin:40vh auto;text-align:center;}</style><body><h1>网络未连接</h1></body></html>", "text/html", "utf-8", "");
|
||||
//}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -113,7 +113,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
Loading…
Reference in New Issue