新建收藏增加分类,修改导出HTML
This commit is contained in:
parent
fb386af64f
commit
47d2634531
|
@ -23,7 +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.29 (2023-02-22)</h3><ol><li>收藏夹增加分类。</li></ol>
|
||||
<h3>V4.29 (2023-02-22)</h3><ol><li>收藏夹增加分类。</li><li>修改导出HTML和CSV方法。</li></ol>
|
||||
<h3>V4.28 (2022-11-07)</h3><ol><li>资源探查脚本支持返回多个对象。<br>分类标题增加数量。<br>使用 <details> 代替 <div>,分类可折叠。</li></ol>
|
||||
<h3>V4.27 (2022-10-22)</h3><ol><li>修改收藏夹数据库目录。</li><li>收藏夹增加分享数据库功能。</li></ol>
|
||||
<h3>V4.26 (2022-07-23)</h3><ol><li>增加页面信息。</li><li>增加资源探查。</li></ol>
|
||||
|
|
|
@ -107,7 +107,6 @@ public class FavoriteActivity extends Activity {
|
|||
}
|
||||
});
|
||||
|
||||
//search(0, "");
|
||||
RadioButton radioButton = (RadioButton) radioGroup.getChildAt(0);
|
||||
radioButton.performClick();
|
||||
}
|
||||
|
@ -136,8 +135,8 @@ public class FavoriteActivity extends Activity {
|
|||
public void onClick(DialogInterface dialog, int which) {
|
||||
String s = editText1.getText().toString();
|
||||
DBHelper helper = new DBHelper(getApplicationContext());
|
||||
Cursor c = helper.category(s);
|
||||
if (c.getCount() == 0) {
|
||||
Cursor cursor = helper.category(s);
|
||||
if (cursor.getCount() == 0) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("category", s);
|
||||
helper.insert("category", values);
|
||||
|
@ -164,23 +163,31 @@ public class FavoriteActivity extends Activity {
|
|||
}
|
||||
break;
|
||||
case 2:
|
||||
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";
|
||||
DBHelper helper = new DBHelper(getApplicationContext());
|
||||
Cursor cursor = helper.query("");
|
||||
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>\na { 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; }\ntd:nth-child(3) { white-space: nowrap; }\n</style>\n</head>\n<body>\n<h2 align=center>收藏夹" + cursor.getCount() + "</h2>\n<table>\n<tr><th>标题</th><th>网址</th><th>分类</th></tr>\n";
|
||||
if (cursor != null) {
|
||||
while (cursor.moveToNext()) {
|
||||
String title = cursor.getString(cursor.getColumnIndex("title"));
|
||||
String website = cursor.getString(cursor.getColumnIndex("website"));
|
||||
String category = cursor.getString(cursor.getColumnIndex("category"));
|
||||
s = s + "<tr><td>" + title + "</td><td><a href=\"" + website + "\" target=\"_blank\">" + website + "</a></td><td>" + category + "</td></tr>\n";
|
||||
}
|
||||
}
|
||||
s += "</table>\n</body>\n</html>";
|
||||
writeFile("webfav.htm", s);
|
||||
break;
|
||||
case 3:
|
||||
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";
|
||||
helper = new DBHelper(getApplicationContext());
|
||||
cursor = helper.query("");
|
||||
if (cursor != null) {
|
||||
while (cursor.moveToNext()) {
|
||||
String title = cursor.getString(cursor.getColumnIndex("title"));
|
||||
String website = cursor.getString(cursor.getColumnIndex("website"));
|
||||
String category = cursor.getString(cursor.getColumnIndex("category"));
|
||||
s = s + title.replace(",", ",") + "," + website + "," + category + "\n";
|
||||
}
|
||||
}
|
||||
writeFile("webfav.csv", s);
|
||||
break;
|
||||
|
|
|
@ -97,6 +97,7 @@ import android.widget.ImageButton;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -712,9 +713,24 @@ public class MainActivity extends Activity {
|
|||
ET_title.setHint("网址");
|
||||
ET_url.setText(list_webView.get(currentPage).getUrl());
|
||||
layout.addView(ET_url);
|
||||
final Spinner spinner = new Spinner(MainActivity.this);
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add("");
|
||||
DBHelper helper = new DBHelper(MainActivity.this);
|
||||
Cursor cursor = helper.category("");
|
||||
if (cursor != null) {
|
||||
while (cursor.moveToNext()) {
|
||||
String s = cursor.getString(cursor.getColumnIndex("category"));
|
||||
list.add(s);
|
||||
}
|
||||
}
|
||||
ArrayAdapter adapter = new ArrayAdapter(getApplicationContext(), android.R.layout.simple_spinner_item, list);
|
||||
spinner.setAdapter(adapter);
|
||||
layout.addView(spinner);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
||||
Bitmap icon = list_webView.get(currentPage).getFavicon();
|
||||
if(icon == null) icon = BitmapFactory.decodeResource(getResources(), R.drawable.network);
|
||||
if (icon == null)
|
||||
icon = BitmapFactory.decodeResource(getResources(), R.drawable.network);
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.postScale((float)100/icon.getWidth(), (float)100/icon.getHeight());
|
||||
Bitmap bitmap = Bitmap.createBitmap(icon, 0, 0, icon.getWidth(), icon.getHeight(), matrix, true);
|
||||
|
@ -742,6 +758,7 @@ public class MainActivity extends Activity {
|
|||
ContentValues values = new ContentValues();
|
||||
values.put("website", surl);
|
||||
values.put("title", stitle);
|
||||
values.put("category", spinner.getSelectedItem().toString());
|
||||
helper.insert("webfav", values);
|
||||
IMM.hideSoftInputFromWindow(ET_title.getWindowToken(), 0);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue