收藏夹:修改、删除分类
This commit is contained in:
parent
2b8a445081
commit
d0a9897716
|
@ -44,9 +44,9 @@
|
|||
android:label="收藏夹"
|
||||
android:parentActivityName=".MainActivity"/>
|
||||
<activity
|
||||
android:name=".SettingsActivity"
|
||||
android:label="设置"
|
||||
android:name=".SettingsActivity"
|
||||
android:icon="@android:drawable/ic_menu_preferences"
|
||||
android:label="设置"
|
||||
android:parentActivityName=".MainActivity"/>
|
||||
</application>
|
||||
|
||||
|
|
|
@ -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><li>修改导出HTML和CSV方法。</li></ol>
|
||||
<h3>V4.29 (2023-02-26)</h3><ol><li>收藏夹增加分类。</li><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>
|
||||
|
|
|
@ -113,7 +113,7 @@ public class FavoriteActivity extends Activity {
|
|||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
String[] sm = { "新建分类", "分享数据库", "导出HTML", "导出CSV" };
|
||||
String[] sm = { "新建分类", "分类管理", "分享数据库", "导出HTML", "导出CSV" };
|
||||
for (int i=0; i<sm.length; i++) {
|
||||
menu.add(0, i, i, sm[i]);
|
||||
}
|
||||
|
@ -142,6 +142,8 @@ public class FavoriteActivity extends Activity {
|
|||
helper.insert("category", values);
|
||||
IMM.hideSoftInputFromWindow(editText1.getWindowToken(), 0);
|
||||
genCategory();
|
||||
RadioButton radioButton = (RadioButton) radioGroup.getChildAt(0);
|
||||
radioButton.performClick();
|
||||
} else {
|
||||
Toast.makeText(getApplicationContext(), "分类已存在", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
@ -151,6 +153,53 @@ public class FavoriteActivity extends Activity {
|
|||
builder.create().show();
|
||||
break;
|
||||
case 1:
|
||||
builder = new AlertDialog.Builder(FavoriteActivity.this);
|
||||
builder.setIcon(android.R.drawable.ic_menu_edit);
|
||||
RadioButton radioButton = (RadioButton) findViewById(radioGroup.getCheckedRadioButtonId());
|
||||
if (radioButton == null)
|
||||
break;
|
||||
final String title = radioButton.getText().toString();
|
||||
if (title.equals("无分类"))
|
||||
break;
|
||||
builder.setTitle(title);
|
||||
final EditText editText_rename = new EditText(FavoriteActivity.this);
|
||||
editText_rename.setText(title);
|
||||
editText_rename.setSelection(title.length());
|
||||
builder.setView(editText_rename);
|
||||
builder.setPositiveButton("重命名", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
DBHelper helper = new DBHelper(getApplicationContext());
|
||||
SQLiteDatabase db = helper.getWritableDatabase();
|
||||
ContentValues values = new ContentValues();
|
||||
String category = editText_rename.getText().toString();
|
||||
values.put("category", category);
|
||||
db.update("category", values, "category = '" + title + "'", null);
|
||||
db.update(helper.TableName, values, "category = '" + title + "'", null);
|
||||
genCategory();
|
||||
RadioButton radioButton = (RadioButton) radioGroup.getChildAt(0);
|
||||
radioButton.performClick();
|
||||
IMM.hideSoftInputFromWindow(editText_rename.getWindowToken(), 0);
|
||||
}
|
||||
});
|
||||
builder.setNeutralButton("删除", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
DBHelper helper = new DBHelper(getApplicationContext());
|
||||
SQLiteDatabase db = helper.getWritableDatabase();
|
||||
db.delete("category", "category=?", new String[] { title });
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("category", "");
|
||||
db.update(helper.TableName, values, "category = '" + title + "'", null);
|
||||
genCategory();
|
||||
RadioButton radioButton = (RadioButton) radioGroup.getChildAt(0);
|
||||
radioButton.performClick();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton("取消", null);
|
||||
builder.create().show();
|
||||
break;
|
||||
case 2:
|
||||
File file = new File(DBHelper.DATABASE_NAME);
|
||||
if (file.exists()) {
|
||||
Intent intent = new Intent();
|
||||
|
@ -162,31 +211,31 @@ public class FavoriteActivity extends Activity {
|
|||
Toast.makeText(getApplicationContext(), "数据库文件不存在", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
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 title1 = 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 = s + "<tr><td>" + title1 + "</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:
|
||||
case 4:
|
||||
s = "";
|
||||
helper = new DBHelper(getApplicationContext());
|
||||
cursor = helper.query("");
|
||||
if (cursor != null) {
|
||||
while (cursor.moveToNext()) {
|
||||
String title = cursor.getString(cursor.getColumnIndex("title"));
|
||||
String title1 = 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";
|
||||
s = s + title1.replace(",", ",") + "," + website + "," + category + "\n";
|
||||
}
|
||||
}
|
||||
writeFile("webfav.csv", s);
|
||||
|
@ -348,6 +397,7 @@ public class FavoriteActivity extends Activity {
|
|||
class RadioButtonOnClickListener implements View.OnClickListener {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
IMM.hideSoftInputFromWindow(editText.getWindowToken(), 0);
|
||||
RadioButton radioButton = (RadioButton) v;
|
||||
String s = radioButton.getText().toString();
|
||||
search(1, s);
|
||||
|
@ -392,6 +442,7 @@ public class FavoriteActivity extends Activity {
|
|||
}
|
||||
|
||||
void genCategory() {
|
||||
IMM.hideSoftInputFromWindow(editText.getWindowToken(), 0);
|
||||
radioGroup.removeAllViews();
|
||||
DBHelper helper = new DBHelper(this);
|
||||
Cursor cursor = helper.category("");
|
||||
|
|
|
@ -1042,7 +1042,7 @@ public class MainActivity extends Activity {
|
|||
|
||||
void DialogBlockList(){
|
||||
final String[] datas = ReadFile("blockrules").split("\n");
|
||||
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, datas);
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, datas);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setIcon(R.drawable.ic_launcher);
|
||||
builder.setTitle("屏蔽规则列表:");
|
||||
|
|
Loading…
Reference in New Issue