查看图片在新窗口中打开,删除、修改收藏记住位置
This commit is contained in:
parent
271b19a84f
commit
31db197c83
|
@ -2,17 +2,16 @@
|
||||||
<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="4"
|
android:versionCode="4"
|
||||||
android:versionName="4.11">
|
android:versionName="4.13">
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
|
||||||
android:hardwareAccelerated="true"
|
|
||||||
android:icon="@drawable/ic_launcher"
|
android:icon="@drawable/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@android:style/Theme.Holo.Light.NoActionBar">
|
android:theme="@android:style/Theme.Holo.Light">
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
android:theme="@android:style/Theme.Holo.Light.NoActionBar"
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:configChanges="orientation|keyboardHidden|screenSize">
|
android:configChanges="orientation|keyboardHidden|screenSize">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -28,6 +27,8 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW"/>
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
|
<action android:name="android.intent.action.SEARCH"/>
|
||||||
|
<action android:name="android.intent.action.WEB_SEARCH"/>
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
<category android:name="android.intent.category.BROWSABLE"/>
|
<category android:name="android.intent.category.BROWSABLE"/>
|
||||||
<data android:scheme="file"/>
|
<data android:scheme="file"/>
|
||||||
|
@ -35,12 +36,16 @@
|
||||||
<data android:mimeType="text/plain"/>
|
<data android:mimeType="text/plain"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".FavoriteActivity"/>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.hty.browser.SettingsActivity"
|
android:name=".FavoriteActivity"
|
||||||
|
android:icon="@android:drawable/btn_star_big_on"
|
||||||
|
android:label="收藏夹"
|
||||||
|
android:parentActivityName=".MainActivity"/>
|
||||||
|
<activity
|
||||||
|
android:name=".SettingsActivity"
|
||||||
android:label="设置"
|
android:label="设置"
|
||||||
android:theme="@android:style/Theme.Holo">
|
android:icon="@android:drawable/ic_menu_preferences"
|
||||||
</activity>
|
android:parentActivityName=".MainActivity"/>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
|
|
@ -9,7 +9,7 @@ p { text-indent:2em; }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h2 align=center><img src=logo.png><br>海天鹰浏览器 V4.11</h2>
|
<h2 align=center><img src=logo.png><br>海天鹰浏览器 V4.13</h2>
|
||||||
<p>内置扩展的浏览器。</p>
|
<p>内置扩展的浏览器。</p>
|
||||||
<p>扩展:链接关键字过滤,链接关键字高亮,图片自定义过滤,视频独立播放。</p>
|
<p>扩展:链接关键字过滤,链接关键字高亮,图片自定义过滤,视频独立播放。</p>
|
||||||
<p>作者:海天鹰</p>
|
<p>作者:海天鹰</p>
|
||||||
|
@ -23,6 +23,8 @@ 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://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>
|
<p><a href="https://www.jianshu.com/p/c9a18050a249" target="_blank">字符串转Bitmap</a></p>
|
||||||
<h3>更新日志:</h3>
|
<h3>更新日志:</h3>
|
||||||
|
<h3>V4.13 (2020-08-30)</h3><ol><li>图片查看改为在新窗口中打开。</li><li>修复修改、删除收藏不能记忆位置问题。</li></ol>
|
||||||
|
<h3>V4.12 (2020-07-17)</h3><ol><li>适配全面屏导航栏背景色。</li><li>收藏夹无标题栏自定义菜单改成标题栏菜单。</li></ol>
|
||||||
<h3>V4.11 (2020-03-03)</h3><ol><li>收藏夹增加数目统计。</li><li>收藏夹增加菜单,导出HTML、CSV。</li></ol>
|
<h3>V4.11 (2020-03-03)</h3><ol><li>收藏夹增加数目统计。</li><li>收藏夹增加菜单,导出HTML、CSV。</li></ol>
|
||||||
<h3>V4.10 (2019-12-17)</h3><ol><li>优化视频独立播放。</li></ol>
|
<h3>V4.10 (2019-12-17)</h3><ol><li>优化视频独立播放。</li></ol>
|
||||||
<h3>V4.9 (2019-11-06)</h3><ol><li>收藏夹网址增加分享功能。</li></ol>
|
<h3>V4.9 (2019-11-06)</h3><ol><li>收藏夹网址增加分享功能。</li></ol>
|
||||||
|
|
|
@ -16,7 +16,9 @@ import android.text.TextWatcher;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnCreateContextMenuListener;
|
import android.view.View.OnCreateContextMenuListener;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
@ -24,7 +26,6 @@ import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
@ -40,14 +41,12 @@ import java.io.FileWriter;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
public class FavoriteActivity extends Activity {
|
public class FavoriteActivity extends Activity {
|
||||||
SimpleCursorAdapter adapter;
|
|
||||||
ListView listView;
|
|
||||||
EditText editText;
|
EditText editText;
|
||||||
InputMethodManager IMM;
|
|
||||||
ImageButton imageButton_clear;
|
ImageButton imageButton_clear;
|
||||||
|
InputMethodManager IMM;
|
||||||
|
ListView listView;
|
||||||
|
SimpleCursorAdapter adapter;
|
||||||
int position = 0;
|
int position = 0;
|
||||||
TextView textView_title;
|
|
||||||
Button button_favback;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -55,11 +54,8 @@ public class FavoriteActivity extends Activity {
|
||||||
setContentView(R.layout.activity_favorite);
|
setContentView(R.layout.activity_favorite);
|
||||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||||
IMM = (InputMethodManager) getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
IMM = (InputMethodManager) getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
button_favback = (Button) findViewById(R.id.button_favback);
|
|
||||||
button_favback.setText("<");
|
|
||||||
textView_title = (TextView) findViewById(R.id.textView_title);
|
|
||||||
imageButton_clear = (ImageButton) findViewById(R.id.imageButton_clear);
|
imageButton_clear = (ImageButton) findViewById(R.id.imageButton_clear);
|
||||||
imageButton_clear.setOnClickListener(new ButtonListener());
|
imageButton_clear.setOnClickListener(new OnClickListener());
|
||||||
imageButton_clear.setVisibility(View.GONE);
|
imageButton_clear.setVisibility(View.GONE);
|
||||||
editText = (EditText) findViewById(R.id.editText);
|
editText = (EditText) findViewById(R.id.editText);
|
||||||
editText.addTextChangedListener(new EditChangedListener());
|
editText.addTextChangedListener(new EditChangedListener());
|
||||||
|
@ -87,23 +83,64 @@ public class FavoriteActivity extends Activity {
|
||||||
menu.add(0, 3, 3, "分享");
|
menu.add(0, 3, 3, "分享");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
listView.setOnTouchListener(new View.OnTouchListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
|
IMM.hideSoftInputFromWindow(editText.getWindowToken(), 0);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
search(editText.getText().toString());
|
search(editText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
class ButtonListener implements View.OnClickListener {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
switch (v.getId()) {
|
String[] sm = { "导出HTML", "导出CSV" };
|
||||||
case R.id.imageButton_clear:
|
for (int i=0; i<sm.length; i++) {
|
||||||
editText.setText("");
|
menu.add(0, i, i, sm[i]);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
int id = item.getItemId();
|
||||||
|
switch (id) {
|
||||||
|
case 0:
|
||||||
|
String s = "<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\"/>\n<title>收藏夹</title>\n<style>a { text-decoration:none; }\ntable { table-layout:fixed; width:100%; border-collapse:collapse; }\nth, td { border:1px solid black; padding:5px; overflow:hidden; text-overflow: ellipsis; }\n</style>\n</head>\n<body>\n<h2 align=center>收藏夹" + adapter.getCount() + "</h2>\n<table>\n<tr><th>标题</th><th>网址</th></tr>\n";
|
||||||
|
for (int i=0; i<adapter.getCount(); i++){
|
||||||
|
LinearLayout layout = (LinearLayout) listView.getAdapter().getView(i, null, null);
|
||||||
|
TextView textView_title = (TextView) layout.findViewById(R.id.title);
|
||||||
|
TextView textView_website = (TextView) layout.findViewById(R.id.website);
|
||||||
|
s = s + "<tr><td>" + textView_title.getText().toString() + "</td><td><a href=\"" + textView_website.getText().toString() + "\" target=\"_blank\">" + textView_website.getText().toString() + "</a></td></tr>\n";
|
||||||
|
}
|
||||||
|
s += "</table>\n</body>\n</html>";
|
||||||
|
writeFile("webfav.htm", s);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
s = "";
|
||||||
|
for (int i=0; i<adapter.getCount(); i++){
|
||||||
|
LinearLayout layout = (LinearLayout) listView.getAdapter().getView(i, null, null);
|
||||||
|
TextView textView_title = (TextView) layout.findViewById(R.id.title);
|
||||||
|
TextView textView_website = (TextView) layout.findViewById(R.id.website);
|
||||||
|
s = s + textView_title.getText().toString().replace(",", ",") + "," + textView_website.getText().toString() + "\n";
|
||||||
|
}
|
||||||
|
writeFile("webfav.csv", s);
|
||||||
|
break;
|
||||||
|
case android.R.id.home:
|
||||||
|
IMM.hideSoftInputFromWindow(editText.getWindowToken(), 0);
|
||||||
|
finish();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextItemSelected(MenuItem item) {
|
public boolean onContextItemSelected(MenuItem item) {
|
||||||
AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
|
AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
|
||||||
|
position = menuInfo.position;
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case 0:
|
case 0:
|
||||||
ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||||
|
@ -112,7 +149,6 @@ public class FavoriteActivity extends Activity {
|
||||||
Toast.makeText(getApplicationContext(), "链接已复制", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getApplicationContext(), "链接已复制", Toast.LENGTH_SHORT).show();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
position = listView.getFirstVisiblePosition();
|
|
||||||
int id = Integer.parseInt(((TextView) menuInfo.targetView.findViewById(R.id.id)).getText().toString());
|
int id = Integer.parseInt(((TextView) menuInfo.targetView.findViewById(R.id.id)).getText().toString());
|
||||||
DBHelper helper = new DBHelper(getApplicationContext());
|
DBHelper helper = new DBHelper(getApplicationContext());
|
||||||
helper.del(id);
|
helper.del(id);
|
||||||
|
@ -189,12 +225,12 @@ public class FavoriteActivity extends Activity {
|
||||||
//通过反射获取dialog中的私有属性mShowing
|
//通过反射获取dialog中的私有属性mShowing
|
||||||
field = dialog.getClass().getSuperclass().getDeclaredField("mShowing");
|
field = dialog.getClass().getSuperclass().getDeclaredField("mShowing");
|
||||||
field.setAccessible(true);//设置该属性可以访问
|
field.setAccessible(true);//设置该属性可以访问
|
||||||
} catch (Exception ex) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
field.set(dialog, true);
|
field.set(dialog, true);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
} catch (Exception ex) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -211,16 +247,22 @@ public class FavoriteActivity extends Activity {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void favback(View v) {
|
class OnClickListener implements View.OnClickListener {
|
||||||
IMM.hideSoftInputFromWindow(editText.getWindowToken(), 0);
|
@Override
|
||||||
finish();
|
public void onClick(View v) {
|
||||||
|
switch (v.getId()) {
|
||||||
|
case R.id.imageButton_clear:
|
||||||
|
editText.setText("");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void search(String s) {
|
void search(String s) {
|
||||||
DBHelper helper = new DBHelper(this);
|
DBHelper helper = new DBHelper(this);
|
||||||
Cursor cursor1 = helper.query(s);
|
Cursor cursor1 = helper.query(s);
|
||||||
int count = cursor1.getCount();
|
int count = cursor1.getCount();
|
||||||
textView_title.setText("收藏夹" + count);
|
setTitle("收藏夹" + count);
|
||||||
String[] from = { "_id", "title", "website", "website" };
|
String[] from = { "_id", "title", "website", "website" };
|
||||||
int[] to = { R.id.id, R.id.title, R.id.website, R.id.imageView_favicon };
|
int[] to = { R.id.id, R.id.title, R.id.website, R.id.imageView_favicon };
|
||||||
adapter = new SimpleCursorAdapter(this, R.layout.favorite_row, cursor1, from, to, 0);
|
adapter = new SimpleCursorAdapter(this, R.layout.favorite_row, cursor1, from, to, 0);
|
||||||
|
@ -268,49 +310,16 @@ public class FavoriteActivity extends Activity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void menuFav(View v) {
|
|
||||||
String[] items = { "导出HTML", "导出CSV" };
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
||||||
builder.setTitle("收藏夹");
|
|
||||||
builder.setIcon(android.R.drawable.btn_star_big_on);
|
|
||||||
builder.setItems(items, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
dialog.dismiss();
|
|
||||||
switch (which) {
|
|
||||||
case 0:
|
|
||||||
String s = "<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\"/>\n<title>收藏夹</title>\n<style>a { text-decoration:none; }\ntable { table-layout:fixed; width:100%; border-collapse:collapse; }\nth, td { border:1px solid black; padding:5px; overflow:hidden; text-overflow: ellipsis; }\n</style>\n</head>\n<body>\n<h2 align=center>收藏夹" + adapter.getCount() + "</h2>\n<table>\n<tr><th>标题</th><th>网址</th></tr>\n";
|
|
||||||
for (int i=0; i<adapter.getCount(); i++){
|
|
||||||
LinearLayout layout = (LinearLayout) listView.getAdapter().getView(i, null, null);
|
|
||||||
TextView textView_title = (TextView) layout.findViewById(R.id.title);
|
|
||||||
TextView textView_website = (TextView) layout.findViewById(R.id.website);
|
|
||||||
s = s + "<tr><td>" + textView_title.getText().toString() + "</td><td><a href=\"" + textView_website.getText().toString() + "\" target=\"_blank\">" + textView_website.getText().toString() + "</a></td></tr>\n";
|
|
||||||
}
|
|
||||||
s += "</table>\n</body>\n</html>";
|
|
||||||
writeFile("webfav.htm", s);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
s = "";
|
|
||||||
for (int i=0; i<adapter.getCount(); i++){
|
|
||||||
LinearLayout layout = (LinearLayout) listView.getAdapter().getView(i, null, null);
|
|
||||||
TextView textView_title = (TextView) layout.findViewById(R.id.title);
|
|
||||||
TextView textView_website = (TextView) layout.findViewById(R.id.website);
|
|
||||||
s = s + textView_title.getText().toString() + "," + textView_website.getText().toString() + "\n";
|
|
||||||
}
|
|
||||||
writeFile("webfav.csv", s);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.create().show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeFile(String filename, String s) {
|
void writeFile(String filename, String s) {
|
||||||
File file = new File(MainActivity.dir, filename);
|
File file = new File(MainActivity.dir, filename);
|
||||||
try {
|
try {
|
||||||
BufferedWriter bw = new BufferedWriter(new FileWriter(file, false)); //false覆盖
|
BufferedWriter BW = new BufferedWriter(new FileWriter(file, false)); //false覆盖
|
||||||
bw.write(s);
|
if(filename.endsWith(".csv")){
|
||||||
bw.flush();
|
BW.write('\ufeff'); // Excel通过文件的BOM头来判断文件编码
|
||||||
|
BW.flush();
|
||||||
|
}
|
||||||
|
BW.write(s);
|
||||||
|
BW.flush();
|
||||||
Toast.makeText(FavoriteActivity.this, "写文件 " + MainActivity.dir + File.separator + filename + " 成功", Toast.LENGTH_SHORT).show();
|
Toast.makeText(FavoriteActivity.this, "写文件 " + MainActivity.dir + File.separator + filename + " 成功", Toast.LENGTH_SHORT).show();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(Thread.currentThread().getStackTrace()[2] + "", e.toString());
|
Log.e(Thread.currentThread().getStackTrace()[2] + "", e.toString());
|
||||||
|
|
|
@ -266,8 +266,7 @@ public class MainActivity extends Activity {
|
||||||
// 退出全屏
|
// 退出全屏
|
||||||
private void quitFullScreen() {
|
private void quitFullScreen() {
|
||||||
if (customViewCallback != null) {
|
if (customViewCallback != null) {
|
||||||
// 隐藏掉
|
customViewCallback.onCustomViewHidden(); // 隐藏
|
||||||
customViewCallback.onCustomViewHidden();
|
|
||||||
}
|
}
|
||||||
// RelativeLayout1.setVisibility(View.VISIBLE);
|
// RelativeLayout1.setVisibility(View.VISIBLE);
|
||||||
LinearLayout1.setVisibility(View.VISIBLE);
|
LinearLayout1.setVisibility(View.VISIBLE);
|
||||||
|
@ -404,7 +403,8 @@ public class MainActivity extends Activity {
|
||||||
menu.add(0, 4, 4, "屏蔽图片");
|
menu.add(0, 4, 4, "屏蔽图片");
|
||||||
menu.add(0, 5, 5, "隐藏图片");
|
menu.add(0, 5, 5, "隐藏图片");
|
||||||
} else if (result.getType() == HitTestResult.SRC_ANCHOR_TYPE) {
|
} else if (result.getType() == HitTestResult.SRC_ANCHOR_TYPE) {
|
||||||
menu.setHeaderIcon(android.R.drawable.ic_menu_sort_alphabetically);
|
menu.setHeaderIcon(R.drawable.link);
|
||||||
|
menu.add(0, 0, 0, "在新窗口打开链接");
|
||||||
menu.add(0, 2, 2, "下载");
|
menu.add(0, 2, 2, "下载");
|
||||||
menu.add(0, 3, 3, "复制链接");
|
menu.add(0, 3, 3, "复制链接");
|
||||||
}
|
}
|
||||||
|
@ -414,25 +414,24 @@ public class MainActivity extends Activity {
|
||||||
public boolean onContextItemSelected(MenuItem item) {
|
public boolean onContextItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case 0:
|
case 0:
|
||||||
list_webView.get(currentPage).loadUrl(HTRE);
|
newWindow(HTRE);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
ClipboardManager mClipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
ClipboardManager clipboardManager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
ContentValues values = new ContentValues(2);
|
ContentValues values = new ContentValues(2);
|
||||||
values.put(MediaStore.Images.Media.MIME_TYPE, "Image/jpg");
|
values.put(MediaStore.Images.Media.MIME_TYPE, "Image/jpg");
|
||||||
values.put(MediaStore.Images.Media.DATA, HTRE);
|
values.put(MediaStore.Images.Media.DATA, HTRE);
|
||||||
ContentResolver theContent = getContentResolver();
|
ContentResolver theContent = getContentResolver();
|
||||||
Uri imageUri = theContent.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
|
Uri imageUri = theContent.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
|
||||||
ClipData theClip = ClipData.newUri(getContentResolver(), "Image", imageUri);
|
ClipData clipData = ClipData.newUri(getContentResolver(), "Image", imageUri);
|
||||||
mClipboard.setPrimaryClip(theClip);
|
clipboardManager.setPrimaryClip(clipData);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
//downloadBySystem(HTRE, "", "");
|
|
||||||
dialog_new_download(HTRE, "", "");
|
dialog_new_download(HTRE, "", "");
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||||
cm.setPrimaryClip(ClipData.newPlainText("link", HTRE));
|
clipboardManager.setPrimaryClip(ClipData.newPlainText("link", HTRE));
|
||||||
Toast.makeText(getApplicationContext(), "链接已复制", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getApplicationContext(), "链接已复制", Toast.LENGTH_SHORT).show();
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
|
@ -639,14 +638,15 @@ public class MainActivity extends Activity {
|
||||||
String[] items = { "新建窗口", "关闭当前窗口", "收藏当前页", "收藏夹", "查找", "分享", "视频独立播放", "视频截图", "视频在播放器中打开", "查看源码", "主页", "全屏", "广告过滤规则", "设置", "检查更新", "关于", "退出", "清除缓存" };
|
String[] items = { "新建窗口", "关闭当前窗口", "收藏当前页", "收藏夹", "查找", "分享", "视频独立播放", "视频截图", "视频在播放器中打开", "查看源码", "主页", "全屏", "广告过滤规则", "设置", "检查更新", "关于", "退出", "清除缓存" };
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle("菜单");
|
builder.setTitle("菜单");
|
||||||
builder.setIcon(android.R.drawable.ic_menu_preferences);
|
//builder.setIcon(android.R.drawable.ic_menu_preferences);
|
||||||
|
builder.setIcon(R.drawable.ic_launcher);
|
||||||
builder.setItems(items, new DialogInterface.OnClickListener() {
|
builder.setItems(items, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
switch (which) {
|
switch (which) {
|
||||||
case 0:
|
case 0:
|
||||||
newWindow(sharedPreferences.getString("homepage","http://www.baidu.com"));
|
newWindow(sharedPreferences.getString("homepage", "http://www.baidu.com"));
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
list_webView.remove(currentPage);
|
list_webView.remove(currentPage);
|
||||||
|
@ -794,7 +794,7 @@ public class MainActivity extends Activity {
|
||||||
builder.setPositiveButton("保存", new DialogInterface.OnClickListener() {
|
builder.setPositiveButton("保存", new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
String dir = Environment.getExternalStorageDirectory().getPath() + "/Pictures/Screenshots/";
|
String dir = Environment.getExternalStorageDirectory().getPath() + "/DCIM/Screenshots/";
|
||||||
File temp = new File(dir); // 如果文件夹不存在则创建
|
File temp = new File(dir); // 如果文件夹不存在则创建
|
||||||
if (!temp.exists()) {
|
if (!temp.exists()) {
|
||||||
temp.mkdir();
|
temp.mkdir();
|
||||||
|
@ -813,7 +813,7 @@ public class MainActivity extends Activity {
|
||||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, BOS);
|
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, BOS);
|
||||||
try {
|
try {
|
||||||
BOS.flush();
|
BOS.flush();
|
||||||
}catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -852,7 +852,7 @@ public class MainActivity extends Activity {
|
||||||
Uri uri = Uri.parse(value);
|
Uri uri = Uri.parse(value);
|
||||||
intent1.setDataAndType(uri, type);
|
intent1.setDataAndType(uri, type);
|
||||||
startActivity(intent1);
|
startActivity(intent1);
|
||||||
}catch (ActivityNotFoundException e){
|
} catch (ActivityNotFoundException e) {
|
||||||
Log.e(Thread.currentThread().getStackTrace()[2] + "", "" + e);
|
Log.e(Thread.currentThread().getStackTrace()[2] + "", "" + e);
|
||||||
Toast.makeText(getApplicationContext(), "系统默认播放器不能打开视频", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getApplicationContext(), "系统默认播放器不能打开视频", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
@ -884,7 +884,7 @@ public class MainActivity extends Activity {
|
||||||
new Thread(CU).start();
|
new Thread(CU).start();
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
list_webView.get(currentPage).loadUrl("file:///android_asset/about.htm");
|
newWindow("file:///android_asset/about.htm");
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
unregisterReceiver(receiver);
|
unregisterReceiver(receiver);
|
||||||
|
@ -1185,7 +1185,7 @@ public class MainActivity extends Activity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void newWindow(String surl){
|
void newWindow(String surl) {
|
||||||
WebView webView = new WebView(MainActivity.this);
|
WebView webView = new WebView(MainActivity.this);
|
||||||
settingWebView(webView);
|
settingWebView(webView);
|
||||||
webView.loadUrl(surl);
|
webView.loadUrl(surl);
|
||||||
|
@ -1196,43 +1196,28 @@ public class MainActivity extends Activity {
|
||||||
button_page.setText(currentPage + 1 + "");
|
button_page.setText(currentPage + 1 + "");
|
||||||
}
|
}
|
||||||
|
|
||||||
void settingWebView(WebView webView){
|
void settingWebView(WebView webView) {
|
||||||
// 菜单
|
registerForContextMenu(webView); // 注册菜单
|
||||||
registerForContextMenu(webView);
|
webView.requestFocusFromTouch(); // 请求触摸焦点
|
||||||
// 支持获取手势焦点
|
|
||||||
webView.requestFocusFromTouch();
|
|
||||||
// 允许调试
|
|
||||||
if(Build.VERSION.SDK_INT >= 19) {
|
if(Build.VERSION.SDK_INT >= 19) {
|
||||||
webView.setWebContentsDebuggingEnabled(true);
|
webView.setWebContentsDebuggingEnabled(true); // 允许调试
|
||||||
}
|
}
|
||||||
WebSettings webSettings = webView.getSettings();
|
WebSettings webSettings = webView.getSettings();
|
||||||
// 开启JS
|
webSettings.setJavaScriptEnabled(true); // 开启JS
|
||||||
webSettings.setJavaScriptEnabled(true);
|
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);// 允许JS打开窗口
|
||||||
// 开启JS能打开窗口
|
webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);// 开启缓存
|
||||||
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
|
|
||||||
// 开启缓存
|
|
||||||
webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
|
|
||||||
// 自适应屏幕
|
// 自适应屏幕
|
||||||
webSettings.setUseWideViewPort(true);
|
webSettings.setUseWideViewPort(true);
|
||||||
webSettings.setLoadWithOverviewMode(true);
|
webSettings.setLoadWithOverviewMode(true);
|
||||||
// 支持缩放
|
webSettings.setSupportZoom(true); // 支持缩放
|
||||||
webSettings.setSupportZoom(true);
|
webSettings.setBuiltInZoomControls(true);// 启用内置缩放控件
|
||||||
// 启用内置缩放控件
|
webSettings.setDisplayZoomControls(false); // 隐藏缩放控件
|
||||||
webSettings.setBuiltInZoomControls(true);
|
webSettings.setAllowFileAccess(true);// 开启文件访问
|
||||||
// 隐藏缩放控件
|
webSettings.setDatabaseEnabled(true); // 开启数据库
|
||||||
webSettings.setDisplayZoomControls(false);
|
webSettings.setDomStorageEnabled(true); // 开启localStorage
|
||||||
// 开启访问文件
|
webSettings.setGeolocationEnabled(true); // 开启定位
|
||||||
webSettings.setAllowFileAccess(true);
|
webSettings.setSupportMultipleWindows(true); // 支持多窗口
|
||||||
// 开启数据库
|
webSettings.setAllowUniversalAccessFromFileURLs(true); // 允许跨域
|
||||||
webSettings.setDatabaseEnabled(true);
|
|
||||||
// 开启localStorage
|
|
||||||
webSettings.setDomStorageEnabled(true);
|
|
||||||
// 开启定位
|
|
||||||
webSettings.setGeolocationEnabled(true);
|
|
||||||
// 支持多窗口
|
|
||||||
webSettings.setSupportMultipleWindows(true);
|
|
||||||
// 允许跨域
|
|
||||||
webSettings.setAllowUniversalAccessFromFileURLs(true);
|
|
||||||
|
|
||||||
webView.setWebViewClient(new WebViewClient() {
|
webView.setWebViewClient(new WebViewClient() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -26,20 +26,21 @@ public class SettingsActivity extends PreferenceActivity implements OnSharedPref
|
||||||
// 启动时显示
|
// 启动时显示
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
ETP_homepage.setSummary(SP.getString("homepage","http://www.baidu.com"));
|
ETP_homepage.setSummary(SP.getString("homepage", "http://www.baidu.com"));
|
||||||
ETP_filter.setSummary(SP.getString("filter",""));
|
ETP_filter.setSummary(SP.getString("filter", ""));
|
||||||
ETP_highlight.setSummary(SP.getString("highlight",""));
|
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")){
|
}else if(key.equals("filter")){
|
||||||
ETP_filter.setSummary(sharedPreferences.getString(key,""));
|
ETP_filter.setSummary(sharedPreferences.getString(key, ""));
|
||||||
}else if(key.equals("highlight")){
|
}else if(key.equals("highlight")){
|
||||||
ETP_highlight.setSummary(sharedPreferences.getString(key,""));
|
ETP_highlight.setSummary(sharedPreferences.getString(key, ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -6,44 +6,6 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".FavoriteActivity" >
|
tools:context=".FavoriteActivity" >
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" >
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textView_title"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerInParent="true"
|
|
||||||
android:text="收藏夹"
|
|
||||||
android:textSize="20sp" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/button_favback"
|
|
||||||
style="@android:style/Widget.DeviceDefault.Button.Small"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentRight="false"
|
|
||||||
android:layout_centerVertical="false"
|
|
||||||
android:alpha="0.3"
|
|
||||||
android:background="@null"
|
|
||||||
android:onClick="favback"
|
|
||||||
android:text="←"
|
|
||||||
android:textSize="30sp" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
style="@android:style/Widget.DeviceDefault.Button.Small"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:alpha="0.3"
|
|
||||||
android:background="@null"
|
|
||||||
android:onClick="menuFav"
|
|
||||||
android:text="≡"
|
|
||||||
android:textSize="30sp" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -124,6 +124,7 @@
|
||||||
android:layout_height="100sp"
|
android:layout_height="100sp"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:adjustViewBounds="false"
|
android:adjustViewBounds="false"
|
||||||
|
android:background="@null"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
android:src="@drawable/play" />
|
android:src="@drawable/play" />
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue